/// <inheritdoc /> public virtual async Task <string> ProcessProofRequestAsync(IAgentContext agentContext, ProofRequestMessage proofRequest) { var requestJson = proofRequest.ProofRequestJson; var offer = JObject.Parse(requestJson); var nonce = offer["nonce"].ToObject <string>(); // Write offer record to local wallet var proofRecord = new ProofRecord { Id = Guid.NewGuid().ToString(), RequestJson = requestJson, ConnectionId = agentContext.Connection.Id, State = ProofState.Requested }; proofRecord.SetTag(TagConstants.Nonce, nonce); proofRecord.SetTag(TagConstants.Role, TagConstants.Holder); await RecordService.AddAsync(agentContext.Wallet, proofRecord); EventAggregator.Publish(new ServiceMessageProcessingEvent { RecordId = proofRecord.Id, MessageType = proofRequest.Type, }); return(proofRecord.Id); }
/// <inheritdoc /> public virtual async Task <string> ProcessProofRequestAsync(IAgentContext agentContext, ProofRequestMessage proofRequest, ConnectionRecord connection) { var requestJson = proofRequest.ProofRequestJson; // Write offer record to local wallet var proofRecord = new ProofRecord { Id = Guid.NewGuid().ToString(), RequestJson = requestJson, ConnectionId = connection.Id, State = ProofState.Requested }; proofRecord.SetTag(TagConstants.LastThreadId, proofRequest.GetThreadId()); proofRecord.SetTag(TagConstants.Role, TagConstants.Holder); await RecordService.AddAsync(agentContext.Wallet, proofRecord); EventAggregator.Publish(new ServiceMessageProcessingEvent { RecordId = proofRecord.Id, MessageType = proofRequest.Type, ThreadId = proofRequest.GetThreadId() }); return(proofRecord.Id); }
/// <inheritdoc /> public virtual async Task <(ProofRequestMessage, string)> CreateProofRequestAsync(IAgentContext agentContext, string connectionId, string proofRequestJson) { Logger.LogInformation(LoggingEvents.CreateProofRequest, "ConnectionId {0}", connectionId); var connection = await ConnectionService.GetAsync(agentContext, connectionId); if (connection.State != ConnectionState.Connected) { throw new AgentFrameworkException(ErrorCode.RecordInInvalidState, $"Connection state was invalid. Expected '{ConnectionState.Connected}', found '{connection.State}'"); } var proofJobj = JObject.Parse(proofRequestJson); var proofRecord = new ProofRecord { Id = Guid.NewGuid().ToString(), ConnectionId = connection.Id, RequestJson = proofRequestJson }; proofRecord.SetTag(TagConstants.Nonce, proofJobj["nonce"].ToObject <string>()); proofRecord.SetTag(TagConstants.Role, TagConstants.Requestor); await RecordService.AddAsync(agentContext.Wallet, proofRecord); return(new ProofRequestMessage { ProofRequestJson = proofRequestJson }, proofRecord.Id); }
private async Task ScanInvite() { var expectedFormat = ZXing.BarcodeFormat.QR_CODE; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var context = await _agentContextProvider.GetContextAsync(); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opts); if (result == null) { return; } AgentMessage message = await MessageDecoder.ParseMessageAsync(result.Text); switch (message) { case ConnectionInvitationMessage invitation: break; case RequestPresentationMessage presentation: RequestPresentationMessage proofRequest = (RequestPresentationMessage)presentation; var service = message.GetDecorator <ServiceDecorator>(DecoratorNames.ServiceDecorator); ProofRecord proofRecord = await _proofService.ProcessRequestAsync(context, proofRequest, null); proofRecord.SetTag("RecipientKey", service.RecipientKeys.ToList()[0]); proofRecord.SetTag("ServiceEndpoint", service.ServiceEndpoint); await _recordService.UpdateAsync(context.Wallet, proofRecord); _eventAggregator.Publish(new ApplicationEvent { Type = ApplicationEventType.ProofRequestUpdated }); break; default: DialogService.Alert("Invalid invitation!"); return; } Device.BeginInvokeOnMainThread(async() => { if (message is ConnectionInvitationMessage) { await NavigationService.NavigateToAsync <AcceptInviteViewModel>(message as ConnectionInvitationMessage, NavigationType.Modal); } }); }
/// <inheritdoc /> public virtual async Task <string> ProcessProofRequestAsync(IAgentContext agentContext, ProofRequestMessage proofRequest, ConnectionRecord connection, bool isVcOidc) { var requestJson = proofRequest.ProofRequestJson; // Write offer record to local wallet var proofRecord = new ProofRecord { Id = Guid.NewGuid().ToString(), RequestJson = requestJson, ConnectionId = isVcOidc ? null : connection.Id, State = ProofState.Requested }; proofRecord.SetTag(TagConstants.LastThreadId, proofRequest.GetThreadId()); proofRecord.SetTag(TagConstants.Role, TagConstants.Holder); if (!connection.Sso && !isVcOidc) { await RecordService.AddAsync(agentContext.Wallet, proofRecord); EventAggregator.Publish(new ServiceMessageProcessingEvent { RecordId = proofRecord.Id, MessageType = proofRequest.Type, ThreadId = proofRequest.GetThreadId() }); } else { if (isVcOidc) { connection.Endpoint = new AgentEndpoint { Uri = proofRequest.ServiceDecorator.ServiceEndpoint?.ToString() }; } await SelectCredentialsForProofAsync(agentContext, proofRecord, connection); } return(proofRecord.Id); }