/// <summary>
        /// This constructor is used when proof request details are fetched from mediator
        /// </summary>
        public ProofRequestViewModel(IUserDialogs userDialogs,
                                     INavigationService navigationService,
                                     IAgentProvider agentContextProvider,
                                     IProofService proofService,
                                     ILifetimeScope scope,
                                     ICredentialService credentialService,
                                     IConnectionService connectionService,
                                     IEventAggregator eventAggregator,
                                     IMessageService messageService,
                                     ProofRecord proofRecord,
                                     ConnectionRecord connection) : base("Proof Request Detail", userDialogs, navigationService)
        {
            this.userDialogs          = userDialogs;
            this.navigationService    = navigationService;
            this.agentContextProvider = agentContextProvider;
            this.proofService         = proofService;
            this.scope             = scope;
            this.credentialService = credentialService;
            this.connectionService = connectionService;
            this.eventAggregator   = eventAggregator;
            this.messageService    = messageService;
            this.proofRecord       = proofRecord;
            this.connection        = connection;
            ConnectionLogo         = connection?.Alias.ImageUrl;
            ConnectionImageSource  = Base64StringToImageSource.Base64StringToImage(connection?.Alias.ImageUrl);
            ConnectionName         = connection?.Alias.Name ?? "Scanned Presentation Request";
            ProofRequest           = JsonConvert.DeserializeObject <ProofRequest>(proofRecord.RequestJson);
            ProofRequestName       = ProofRequest?.Name;
            RequestedAttributes    = new ObservableCollection <ProofRequestAttributeViewModel>();
            HasLogo       = !string.IsNullOrWhiteSpace(ConnectionLogo);
            HasAttributes = ProofRequest.RequestedAttributes != null?ProofRequest.RequestedAttributes.Any() : false;

            ActionRequired = proofRecord.State == ProofState.Requested;
        }
        public ConnectionViewModel(IUserDialogs userDialogs,
                                   INavigationService navigationService,
                                   IAgentProvider agentContextProvider,
                                   IMessageService messageService,
                                   IDiscoveryService discoveryService,
                                   IConnectionService connectionService,
                                   IEventAggregator eventAggregator,
                                   IWalletRecordService walletRecordService,
                                   ILifetimeScope scope,
                                   ConnectionRecord record) :
            base(nameof(ConnectionViewModel),
                 userDialogs,
                 navigationService)
        {
            _agentContextProvider = agentContextProvider;
            _messageService       = messageService;
            _discoveryService     = discoveryService;
            _connectionService    = connectionService;
            _eventAggregator      = eventAggregator;
            _walletRecordSevice   = walletRecordService;
            _scope = scope;

            _record               = record;
            MyDid                 = _record.MyDid;
            TheirDid              = _record.TheirDid;
            ConnectionName        = _record.Alias?.Name ?? _record.Id;
            ConnectionSubtitle    = $"{_record.State:G}";
            ConnectionImageUrl    = _record.Alias?.ImageUrl;
            ConnectionImageSource = Base64StringToImageSource.Base64StringToImage(_record.Alias?.ImageUrl);

            Messages = new ObservableCollection <RecordBase>();
        }
        public async Task InitializeAgentInfo()
        {
            var context = await _agentContextProvider.GetContextAsync();

            var proviosioningAgent = await _provisioningService.GetProvisioningAsync(context.Wallet);

            FullName         = proviosioningAgent.Owner.Name;
            AvatarUrl        = proviosioningAgent.Owner.ImageUrl ?? "account_icon.png";
            AgentImageSource = Base64StringToImageSource.Base64StringToImage(proviosioningAgent.Owner.ImageUrl);
        }
Exemplo n.º 4
0
 public override Task InitializeAsync(object navigationData)
 {
     if (navigationData is ConnectionInvitationMessage invite)
     {
         InviteTitle        = $"Trust {invite.Label}?";
         InviterUrl         = invite.ImageUrl;
         InviterImageSource = Base64StringToImageSource.Base64StringToImage(invite.ImageUrl);
         InviteContents     = $"{invite.Label} would like to establish a pairwise DID connection with you. This will allow secure communication between you and {invite.Label}.";
         _invite            = invite;
     }
     return(base.InitializeAsync(navigationData));
 }
Exemplo n.º 5
0
        public override async Task InitializeAsync(object navigationData)
        {
            _connectionId = navigationData.ToString();
            var context = await _agentContextProvider.GetContextAsync();

            var con = await _connectionService.GetAsync(context, _connectionId);

            MyDid                 = con.MyDid;
            TheirDid              = con.TheirDid;
            Connection            = con.Alias?.Name;
            ConnectionImageSource = Base64StringToImageSource.Base64StringToImage(con.Alias?.ImageUrl);
            await base.InitializeAsync(navigationData);
        }
        public override Task InitializeAsync(object navigationData)
        {
            if (navigationData is List <object> dataList)
            {
                var request = (ConnectionRequestMessage)dataList[0];
                _connectionId = (string)dataList[1];
                //_responseMessage = (ConnectionResponseMessage)dataList[1];
                //_record = (ConnectionRecord)dataList[2];

                RequestTitle         = $"Trust {request.Label}?";
                RequesterUrl         = request.ImageUrl;
                RequesterImageSource = Base64StringToImageSource.Base64StringToImage(request.ImageUrl);
                RequestContents      = $"{request.Label} would like to establish a pairwise DID connection with you. This will allow secure communication between you and {request.Label}.";
            }
            return(base.InitializeAsync(navigationData));
        }
Exemplo n.º 7
0
        public async Task InitializeAgentInfo()
        {
            var context = await _agentContextProvider.GetContextAsync();

            _provisioningRecord = await _provisioningService.GetProvisioningAsync(context.Wallet);

            AgentName           = _provisioningRecord.Owner.Name;
            AgentImageSource    = Base64StringToImageSource.Base64StringToImage(_provisioningRecord.Owner.ImageUrl);
            MediatorEndpointUrl = _provisioningRecord.Endpoint.Uri;
            if (Preferences.ContainsKey(AppConstant.MediatorConnectionIdTagName))
            {
                var mediatorConnection = await _walletRecordService.GetAsync <ConnectionRecord>(context.Wallet, Preferences.Get(AppConstant.MediatorConnectionIdTagName, string.Empty));

                MediatorConnectionState = mediatorConnection.State.ToString();
            }
        }
        private async Task GetConnectionForCredentials()
        {
            if (AttributeCredentials == null)
            {
                return;
            }

            var agentContext = await agentContextProvider.GetContextAsync();

            foreach (var cred in AttributeCredentials)
            {
                try
                {
                    var credential = await credentialService.GetAsync(agentContext, cred.Credential.CredentialInfo.Referent);

                    if (credential == null || string.IsNullOrWhiteSpace(credential?.ConnectionId))
                    {
                        continue;
                    }

                    var connection = await connectionService.GetAsync(agentContext, credential.ConnectionId);

                    if (connection == null)
                    {
                        continue;
                    }

                    cred.CredentialConnection            = connection.Alias?.Name;
                    cred.CredentialConnectionImageUrl    = connection.Alias?.ImageUrl;
                    cred.CredentialConnectionImageSource = Base64StringToImageSource.Base64StringToImage(connection.Alias?.ImageUrl);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }
        public CredentialViewModel(IUserDialogs userDialogs,
                                   INavigationService navigationService,
                                   IConnectionService connectionService,
                                   IAgentProvider agentContextProvider,
                                   IWalletRecordService walletRecordService,
                                   IMessageService messageService,
                                   ICredentialService credentialService,
                                   IEventAggregator eventAggregator,
                                   CredentialRecord credential,
                                   ConnectionRecord connection) : base(nameof(CredentialViewModel), userDialogs, navigationService)
        {
            this._connectionService   = connectionService;
            this.agentContextProvider = agentContextProvider;
            this.walletRecordService  = walletRecordService;
            this.messageService       = messageService;
            this.credentialService    = credentialService;
            this.eventAggregator      = eventAggregator;
            this._credential          = credential;
            this._connection          = connection;

#if SMP_DEBUG
            _credentialName     = "Credential Name";
            _credentialImageUrl = "http://placekitten.com/g/200/200";
            _credentialSubtitle = "10/22/2017";
            _credentialType     = "Bank Statement";
            _qRImageUrl         = "http://placekitten.com/g/100/100";

            var attributes = new List <CredentialAttribute>(new CredentialAttribute[] {
                new CredentialAttribute
                {
                    Type  = "Text",
                    Name  = "First Name",
                    Value = "Jamie"
                },
                new CredentialAttribute
                {
                    Type  = "Text",
                    Name  = "Last Name",
                    Value = "Doe"
                },
                new CredentialAttribute
                {
                    Type  = "Text",
                    Name  = "Country of Residence",
                    Value = "New Zealand"
                },
                new CredentialAttribute
                {
                    Type    = "File",
                    Name    = "Statement",
                    Value   = "Statement.pdf",
                    FileExt = "PDF",
                    Date    = "05 Aug 2018"
                }
            });
            //_attributes = attributes.OrderByDescending(o => o.Type).OrderBy(o => o.Date);
            _attributes = attributes;
#else
            CredentialName        = _credential.SchemaId.ToCredentialName();
            CredentialImageUrl    = _connection?.Alias.ImageUrl;
            CredentialImageSource = Base64StringToImageSource.Base64StringToImage(_connection?.Alias.ImageUrl);
            CredentialSubtitle    = _connection?.Alias.Name;
            CreatedAt             = _credential.CreatedAtUtc?.ToLocalTime();
            CredentialState       = _credential.State;
            CredentialType        = _credential.TypeName;
            _isNew = IsCredentialNew(_credential);

            if (_credential.CredentialAttributesValues != null)
            {
                if (Attributes == null)
                {
                    Attributes = new List <CredentialAttribute>();
                }

                Attributes.AddRange(_credential.CredentialAttributesValues.Select((CredentialPreviewAttribute x) => new CredentialAttribute
                {
                    Name  = x.Name,
                    Value = x.Value != null ? x.Value.ToString() : string.Empty,
                    Type  = x.MimeType
                }));
            }
#endif
        }