public async Task <TokenResponse> CreateWalletAndOtp(CreateWalletRequest walletRequest, string sessionId)
        {
            Wallet wallet;

            if (sessionId == null)
            {
                wallet = await CreateWallet(walletRequest);
            }
            else
            {
                wallet = await GetWallet(sessionId);

                _cryptoService.DecryptAsServer(wallet);

                wallet.MobileNumberReference = walletRequest.MobileNumberReference;
                wallet.MobileNumber          = wallet.MobileNumber;

                await UpdateWallet(wallet);
            }

            var otpId = await _otpService.GenerateAndSendOtpAsync(walletRequest.MobileNumber);

            return(new TokenResponse
            {
                Token = _tokenService.GenerateToken(wallet.Id.ToString(), otpId)
            });
        }
Exemple #2
0
        public async Task <CoviIdWalletContract> CreateCoviIdWallet(CoviIdWalletParameters coviIdWalletParameters)
        {
            var wallet = new WalletParameters
            {
                OwnerName = $"{coviIdWalletParameters.FirstName?.Trim()}-{coviIdWalletParameters.LastName?.Trim()}"
            };

            var response = await _custodianBroker.CreateWallet(wallet);

            var pictureUrl = await _agencyBroker.UploadFiles(coviIdWalletParameters.Photo, response.WalletId);

            var newWallet = await SaveNewWalletAsync(response.WalletId);

            await _otpService.GenerateAndSendOtpAsync(coviIdWalletParameters.MobileNumber.ToString(), newWallet);

            var contract = new CoviIdWalletContract
            {
                CovidStatusUrl = $"{_configuration.GetValue<string>("CoviIDBaseUrl")}/api/verifier/{response.WalletId}/covid-credentials",
                Picture        = pictureUrl,
                WalletId       = response.WalletId
            };

            return(contract);
        }