From 96bb0a09bc8d74a087b07e57a8d6dc48c6660c5d Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Thu, 28 Mar 2024 11:58:13 -0700 Subject: [PATCH] feat: add timer and text (#1891) Signed-off-by: Jason C. Leach --- app/src/localization/en/index.ts | 3 ++- app/src/localization/fr/index.ts | 3 ++- app/src/localization/pt-br/index.ts | 3 ++- app/src/screens/PersonCredential.tsx | 33 +++++++++++++++++++++++++--- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/src/localization/en/index.ts b/app/src/localization/en/index.ts index 2b2365ce..4d9f69b2 100644 --- a/app/src/localization/en/index.ts +++ b/app/src/localization/en/index.ts @@ -78,7 +78,8 @@ const translation = { "AppOnOtherDevice": "I have it on another device", "CreatePersonCred": "Step 2: Create your Person credential", "StartProcess": "Start the process", - "PageTitle": "Person Credential" + "PageTitle": "Person Credential", + "PleaseWait": "Please wait as we get things ready for you", }, "NetInfo": { "NoInternetConnectionTitle": "No internet connection", diff --git a/app/src/localization/fr/index.ts b/app/src/localization/fr/index.ts index 0bd17004..597dd4e1 100644 --- a/app/src/localization/fr/index.ts +++ b/app/src/localization/fr/index.ts @@ -77,7 +77,8 @@ const translation = { "AppOnOtherDevice": "I have it on another device (FR)", "CreatePersonCred": "Step 2: Create your Person credential (FR)", "StartProcess": "Start the process (FR)", - "PageTitle": "Person Credential (FR)" + "PageTitle": "Person Credential (FR)", + "PleaseWait": "Please wait as we get things ready for you (FR)", }, "NetInfo": { "NoInternetConnectionTitle": "No internet connection (FR)", diff --git a/app/src/localization/pt-br/index.ts b/app/src/localization/pt-br/index.ts index f6e3227a..c7efa859 100644 --- a/app/src/localization/pt-br/index.ts +++ b/app/src/localization/pt-br/index.ts @@ -77,7 +77,8 @@ const translation = { "AppOnOtherDevice": "I have it on another device (PT-BR)", "CreatePersonCred": "Step 2: Create your Person credential (PT-BR)", "StartProcess": "Start the process (PT-BR)", - "PageTitle": "Person Credential (PT-BR)" + "PageTitle": "Person Credential (PT-BR)", + "PleaseWait": "Please wait as we get things ready for you (PT-BR)", }, "NetInfo": { "NoInternetConnectionTitle": "No internet connection (PT-BR)", diff --git a/app/src/screens/PersonCredential.tsx b/app/src/screens/PersonCredential.tsx index c23a2303..bae87518 100644 --- a/app/src/screens/PersonCredential.tsx +++ b/app/src/screens/PersonCredential.tsx @@ -10,9 +10,10 @@ import { BifoldAgent, Screens, Stacks, + InfoTextBox, } from '@hyperledger/aries-bifold-core' import { useNavigation } from '@react-navigation/native' -import React, { useState, useCallback, useEffect } from 'react' +import React, { useState, useCallback, useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View, TouchableOpacity, Linking, Platform, ScrollView } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' @@ -25,6 +26,8 @@ import { getAvailableAttestationCredentials } from '../helpers/Attestation' import { connectToIASAgent, authenticateWithServiceCard, WellKnownAgentDetails } from '../helpers/BCIDHelper' import { BCState } from '../store' +const attestationProofRequestWaitTimeout = 10000 + export default function PersonCredential() { const { agent } = useAgent() const [store] = useStore() @@ -39,6 +42,7 @@ export default function PersonCredential() { const [remoteAgentDetails, setRemoteAgentDetails] = useState() const { loading: attestationLoading } = useAttestation ? useAttestation() : { loading: false } const [didCompleteAttestationProofRequest, sedDidCompleteAttestationProofRequest] = useState(false) + const timer = useRef() const styles = StyleSheet.create({ pageContainer: { @@ -143,6 +147,24 @@ export default function PersonCredential() { .then((remoteAgentDetails: WellKnownAgentDetails) => { setRemoteAgentDetails(remoteAgentDetails) + timer.current = setTimeout(() => { + if (!remoteAgentDetails || !remoteAgentDetails.connectionId) { + return + } + + const proofRequest = receivedProofRequests.find( + (proof) => proof.connectionId === remoteAgentDetails.connectionId + ) + if (!proofRequest) { + // No proof from our IAS Agent to respond to, do nothing. + agent.config.logger.info( + `Waited ${attestationProofRequestWaitTimeout / 1000}sec on attestation proof request, continuing` + ) + + sedDidCompleteAttestationProofRequest(true) + } + }, attestationProofRequestWaitTimeout) + agent.config.logger.error(`Connected to IAS agent, connectionId: ${remoteAgentDetails?.connectionId}`) }) .catch((error) => { @@ -158,8 +180,6 @@ export default function PersonCredential() { return } - // TODO:(jl) We need to set a 10 second timeout. - // We have an attestation credential and can respond to an // attestation proof request. const proofRequest = receivedProofRequests.find((proof) => proof.connectionId === remoteAgentDetails.connectionId) @@ -168,6 +188,8 @@ export default function PersonCredential() { return } + timer.current && clearTimeout(timer.current) + acceptAttestationProofRequest(agent, proofRequest) .then((status: boolean) => { // We can unblock the workflow and proceed with @@ -294,6 +316,11 @@ export default function PersonCredential() { {t('PersonCredential.CreatePersonCred')} + {workflowInProgress ? ( + + {t('PersonCredential.PleaseWait')} + + ) : null} {appInstalled ? (