public async Task <bool> CreateAgentAsync(AgentOptions options) { var discovery = await _edgeClientService.DiscoverConfigurationAsync(options.EndpointUri); discovery.ServiceEndpoint = options.EndpointUri; discovery.Invitation.ServiceEndpoint = options.EndpointUri; #if __ANDROID__ WalletConfiguration.WalletStorageConfiguration _storage = new WalletConfiguration.WalletStorageConfiguration { Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".indy_client") }; options.WalletOptions.WalletConfiguration.StorageConfiguration = _storage; #endif await _provisioningService.ProvisionAgentAsync(new AgentOptions { WalletConfiguration = options.WalletConfiguration, WalletCredentials = options.WalletCredentials, AgentKeySeed = options.AgentKeySeed, EndpointUri = options.EndpointUri, AgentName = options.AgentName == null ? "Default Agent" : options.AgentName }); await _keyValueStoreService.SetDataAsync(AgentOptionsKey, options); _options = options; var agentContext = await GetContextAsync(); var provisioning = await _provisioningService.GetProvisioningAsync(agentContext.Wallet); // Check if connection has been established with mediator agent if (provisioning.GetTag("MediatorConnectionId") == null) { var(request, record) = await _connectionService.CreateRequestAsync(agentContext, discovery.Invitation); //await _edgeClientService.AddRouteAsync(agentContext, record.MyVk); var response = await _messageService.SendReceiveAsync <ConnectionResponseMessage>(agentContext.Wallet, request, record); await _connectionService.ProcessResponseAsync(agentContext, response, record); // Remove the routing key explicitly as it won't ever be needed. // Messages will always be sent directly with return routing enabled record = await _connectionService.GetAsync(agentContext, record.Id); record.Endpoint = new AgentEndpoint(record.Endpoint.Uri, null, null); await _recordService.UpdateAsync(agentContext.Wallet, record); provisioning.SetTag("MediatorConnectionId", record.Id); await _recordService.UpdateAsync(agentContext.Wallet, provisioning); } await _edgeClientService.CreateInboxAsync(agentContext); //await _edgeClientService.AddRouteAsync(agentContext, record.MyVk); return(true); }
public async Task CreateInboxRecordWithStorageConfigurationAndCredentialsAsync() { string keyDerivationMethod = "RAW"; object storageCredentials = new {}; WalletConfiguration.WalletStorageConfiguration storageConfiguration = new WalletConfiguration.WalletStorageConfiguration(); string storageType = "postgres_storage"; IOptions <AgentOptions> options = Options.Create <AgentOptions>(new AgentOptions() { WalletConfiguration = new WalletConfiguration() { StorageType = storageType, StorageConfiguration = storageConfiguration }, WalletCredentials = new WalletCredentials() { KeyDerivationMethod = keyDerivationMethod, StorageCredentials = storageCredentials } }); UnpackedMessageContext unpackedMessage = new UnpackedMessageContext( new CreateInboxMessage(), new ConnectionRecord() { State = ConnectionState.Connected, }); routingInboxHandler = new RoutingInboxHandler(recordService.Object, walletService.Object, routingStore.Object, options, logger.Object); CreateInboxResponseMessage agentMessage = (CreateInboxResponseMessage)await routingInboxHandler.ProcessAsync(agentContext.Object, unpackedMessage); walletService.Verify(w => w.CreateWalletAsync(It.Is <WalletConfiguration>(wc => wc.Id == agentMessage.InboxId && wc.StorageConfiguration == storageConfiguration && wc.StorageType == storageType ), It.Is <WalletCredentials>(wc => wc.Key == agentMessage.InboxKey && wc.KeyDerivationMethod == keyDerivationMethod && wc.StorageCredentials == storageCredentials ))); }
public async Task <bool> CreateAgentAsync(AgentOptions options) { #if __ANDROID__ WalletConfiguration.WalletStorageConfiguration _storage = new WalletConfiguration.WalletStorageConfiguration { Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".indy_client") }; options.WalletOptions.WalletConfiguration.StorageConfiguration = _storage; #endif await _provisioningService.ProvisionAgentAsync(new ProvisioningConfiguration { WalletConfiguration = options.WalletOptions.WalletConfiguration, WalletCredentials = options.WalletOptions.WalletCredentials, AgentSeed = options.Seed, EndpointUri = options.EndpointUri != null ? new Uri($"{options.EndpointUri}") : null }); await _keyValueStoreService.SetDataAsync(AgentOptionsKey, options); _options = options; return(true); }
public void WalletStorageConfigurationModel() { WalletConfiguration.WalletStorageConfiguration walletStorageConfiguration = new WalletConfiguration.WalletStorageConfiguration { Path = Path, Url = Url, WalletScheme = WalletScheme, DatabaseName = DatabaseName, Tls = Tls, MaxConnections = MaxConnections, MinIdleCount = MinIdleCount, ConnectionTimeout = ConnectionTimeout }; walletStorageConfiguration.Should().BeEquivalentTo(new { Path, Url, WalletScheme, DatabaseName, Tls, MaxConnections, MinIdleCount, ConnectionTimeout }); walletStorageConfiguration.ToString().Should().Be( "WalletStorageConfiguration: " + $"Path={Path}" + $"Url={Url}" + $"Tls={Tls}" + $"WalletScheme={WalletScheme}" + $"DatabaseName={DatabaseName}" + $"MaxConnections={MaxConnections}" + $"MinIdleCount={MinIdleCount}" + $"ConnectionTimeout={ConnectionTimeout}"); }