mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-04-13 00:22:22 +00:00
wip
This commit is contained in:
parent
46d3ffcf66
commit
ee30618566
@ -474,7 +474,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract class AuthenticationProvider<TApiCredentials, TCredentialType> : AuthenticationProvider<TApiCredentials>
|
public abstract class AuthenticationProvider<TApiCredentials, TCredentialType> : AuthenticationProvider<TApiCredentials>
|
||||||
where TApiCredentials : ApiCredentials
|
where TApiCredentials : ApiCredentials
|
||||||
where TCredentialType : CredentialPair
|
where TCredentialType : CredentialSet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The specific credential type used for signing requests.
|
/// The specific credential type used for signing requests.
|
||||||
|
|||||||
@ -7,9 +7,9 @@ using System.Text;
|
|||||||
namespace CryptoExchange.Net.Authentication
|
namespace CryptoExchange.Net.Authentication
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Credential pair base class
|
/// Base class for a set of credentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class CredentialPair : ApiCredentials
|
public abstract class CredentialSet : ApiCredentials
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The (public) key/identifier for this credential pair
|
/// The (public) key/identifier for this credential pair
|
||||||
@ -19,12 +19,12 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CredentialPair() { }
|
public CredentialSet() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CredentialPair(string key)
|
public CredentialSet(string key)
|
||||||
{
|
{
|
||||||
Key = key;
|
Key = key;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Api key credentials
|
/// Api key credentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ApiKeyCredential : CredentialPair
|
public class ApiKeyCredential : CredentialSet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
@ -60,7 +60,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// HMAC credentials
|
/// HMAC credentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HMACCredential : CredentialPair
|
public class HMACCredential : CredentialSet
|
||||||
{
|
{
|
||||||
private byte[]? _sBytes;
|
private byte[]? _sBytes;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// RSA credentials
|
/// RSA credentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class RSACredential : CredentialPair
|
public abstract class RSACredential : CredentialSet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Private key
|
/// Private key
|
||||||
@ -399,7 +399,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Credentials in Ed25519 format
|
/// Credentials in Ed25519 format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Ed25519Credential : CredentialPair
|
public class Ed25519Credential : CredentialSet
|
||||||
{
|
{
|
||||||
private NSec.Cryptography.Key? _signKey;
|
private NSec.Cryptography.Key? _signKey;
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ namespace CryptoExchange.Net.Authentication
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Credentials in ECDsa format
|
/// Credentials in ECDsa format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ECDsaCredential : CredentialPair
|
public class ECDsaCredential : CredentialSet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Private key
|
/// Private key
|
||||||
@ -27,6 +27,11 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool _disposing;
|
protected bool _disposing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a proxy is configured
|
||||||
|
/// </summary>
|
||||||
|
protected bool _proxyConfigured;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the client
|
/// Name of the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -88,6 +93,8 @@ namespace CryptoExchange.Net.Clients
|
|||||||
ApiOptions = apiOptions;
|
ApiOptions = apiOptions;
|
||||||
OutputOriginalData = outputOriginalData;
|
OutputOriginalData = outputOriginalData;
|
||||||
BaseAddress = baseAddress;
|
BaseAddress = baseAddress;
|
||||||
|
|
||||||
|
_proxyConfigured = ClientOptions.Proxy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -890,6 +890,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void SetOptions(UpdateOptions<TApiCredentials> options)
|
public virtual void SetOptions(UpdateOptions<TApiCredentials> options)
|
||||||
{
|
{
|
||||||
|
_proxyConfigured = options.Proxy != null;
|
||||||
ClientOptions.Proxy = options.Proxy;
|
ClientOptions.Proxy = options.Proxy;
|
||||||
ClientOptions.RequestTimeout = options.RequestTimeout ?? ClientOptions.RequestTimeout;
|
ClientOptions.RequestTimeout = options.RequestTimeout ?? ClientOptions.RequestTimeout;
|
||||||
|
|
||||||
@ -958,15 +959,23 @@ namespace CryptoExchange.Net.Clients
|
|||||||
public override void SetApiCredentials(TApiCredentials credentials)
|
public override void SetApiCredentials(TApiCredentials credentials)
|
||||||
{
|
{
|
||||||
base.SetApiCredentials(credentials);
|
base.SetApiCredentials(credentials);
|
||||||
AuthenticationProvider = CreateAuthenticationProvider(credentials);
|
|
||||||
|
AuthenticationProvider = null;
|
||||||
|
_authProviderInitialized = false;
|
||||||
|
ApiCredentials = credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetOptions(UpdateOptions<TApiCredentials> options)
|
public override void SetOptions(UpdateOptions<TApiCredentials> options)
|
||||||
{
|
{
|
||||||
base.SetOptions(options);
|
base.SetOptions(options);
|
||||||
if (ApiCredentials != null)
|
|
||||||
AuthenticationProvider = CreateAuthenticationProvider(ApiCredentials);
|
if (options.ApiCredentials != null)
|
||||||
|
{
|
||||||
|
AuthenticationProvider = null;
|
||||||
|
_authProviderInitialized = false;
|
||||||
|
ApiCredentials = options.ApiCredentials;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1102,13 +1102,14 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void SetOptions(UpdateOptions<TApiCredentials> options)
|
public virtual void SetOptions(UpdateOptions<TApiCredentials> options)
|
||||||
{
|
{
|
||||||
var previousProxyIsSet = ClientOptions.Proxy != null;
|
var previousProxyIsSet = _proxyConfigured;
|
||||||
|
|
||||||
ClientOptions.Proxy = options.Proxy;
|
ClientOptions.Proxy = options.Proxy;
|
||||||
ClientOptions.RequestTimeout = options.RequestTimeout ?? ClientOptions.RequestTimeout;
|
ClientOptions.RequestTimeout = options.RequestTimeout ?? ClientOptions.RequestTimeout;
|
||||||
|
|
||||||
ApiCredentials = (TApiCredentials?)options.ApiCredentials?.Copy() ?? ApiCredentials;
|
ApiCredentials = (TApiCredentials?)options.ApiCredentials?.Copy() ?? ApiCredentials;
|
||||||
|
|
||||||
|
_proxyConfigured = options.Proxy != null;
|
||||||
if ((!previousProxyIsSet && options.Proxy == null)
|
if ((!previousProxyIsSet && options.Proxy == null)
|
||||||
|| _socketConnections.IsEmpty)
|
|| _socketConnections.IsEmpty)
|
||||||
{
|
{
|
||||||
@ -1180,15 +1181,23 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetApiCredentials(TApiCredentials credentials)
|
public override void SetApiCredentials(TApiCredentials credentials)
|
||||||
{
|
{
|
||||||
AuthenticationProvider = CreateAuthenticationProvider(credentials);
|
AuthenticationProvider = null;
|
||||||
|
_authProviderInitialized = false;
|
||||||
|
ApiCredentials = credentials;
|
||||||
|
|
||||||
base.SetApiCredentials(credentials);
|
base.SetApiCredentials(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetOptions(UpdateOptions<TApiCredentials> options)
|
public override void SetOptions(UpdateOptions<TApiCredentials> options)
|
||||||
{
|
{
|
||||||
if (ApiCredentials != null)
|
if (options.ApiCredentials != null)
|
||||||
AuthenticationProvider = CreateAuthenticationProvider(ApiCredentials);
|
{
|
||||||
|
AuthenticationProvider = null;
|
||||||
|
_authProviderInitialized = false;
|
||||||
|
ApiCredentials = options.ApiCredentials;
|
||||||
|
}
|
||||||
|
|
||||||
base.SetOptions(options);
|
base.SetOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user