/// <inheritdoc /> public virtual async Task CreateWalletAsync(WalletConfiguration configuration, WalletCredentials credentials) { await Wallet.CreateWalletAsync(configuration.ToJson(), credentials.ToJson()); // Create master secret. This should later be moved to a credential related context await AnonCreds.ProverCreateMasterSecretAsync(await GetWalletAsync(configuration, credentials), MasterSecretName); }
/// <inheritdoc /> public virtual async Task DeleteWalletAsync(WalletConfiguration configuration, WalletCredentials credentials) { if (Wallets.TryRemove(configuration.Id, out var wallet)) { if (wallet.IsOpen) { await wallet.CloseAsync(); } wallet.Dispose(); } await Wallet.DeleteWalletAsync(configuration.ToJson(), credentials.ToJson()); }
/// <inheritdoc /> public virtual async Task <Wallet> GetWalletAsync(WalletConfiguration configuration, WalletCredentials credentials) { if (Wallets.TryGetValue(configuration.Id, out var wallet)) { return(wallet); } wallet = await Wallet.OpenWalletAsync(configuration.ToJson(), credentials.ToJson()); Wallets.TryAdd(configuration.Id, wallet); return(wallet); }
public void WalletCredentialsSerializesToJsonCorrectly() { WalletCredentials credentials = new WalletCredentials { Key = "Key", StorageCredentials = "StorageCredentials" }; string json = credentials.ToJson(); const string result = @"{ ""key"": ""Key"", ""storage_credentials"": ""StorageCredentials"" }"; var resultObject = JValue.Parse(result); Assert.AreEqual(credentials.Key, resultObject["key"], "Key did not match"); Assert.AreEqual(credentials.StorageCredentials, resultObject["storage_credentials"], "StorageCredentials did not match"); }
/// <inheritdoc /> public virtual async Task <Wallet> GetWalletAsync(WalletConfiguration configuration, WalletCredentials credentials) { var wallet = GetWalletFromCache(configuration); if (wallet != null) { return(wallet); } try { wallet = await Wallet.OpenWalletAsync(configuration.ToJson(), credentials.ToJson()); Wallets.TryAdd(configuration.Id, wallet); } catch (WalletAlreadyOpenedException) { wallet = GetWalletFromCache(configuration); } return(wallet); }
/// <inheritdoc /> public virtual async Task CreateWalletAsync(WalletConfiguration configuration, WalletCredentials credentials) { await Wallet.CreateWalletAsync(configuration.ToJson(), credentials.ToJson()); }