@bifold/core 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/inputs/BiometryControl.js.map +1 -1
- package/lib/commonjs/components/misc/CredentialCard.js +3 -2
- package/lib/commonjs/components/misc/CredentialCard.js.map +1 -1
- package/lib/commonjs/components/misc/FauxHeader.js +89 -0
- package/lib/commonjs/components/misc/FauxHeader.js.map +1 -0
- package/lib/commonjs/components/misc/QRScanner.js +1 -1
- package/lib/commonjs/components/misc/QRScanner.js.map +1 -1
- package/lib/commonjs/components/modals/DeveloperModal.js +43 -0
- package/lib/commonjs/components/modals/DeveloperModal.js.map +1 -0
- package/lib/commonjs/components/views/PushNotificationsContent.js.map +1 -1
- package/lib/commonjs/components/views/PushNotificationsDisabledContent.js.map +1 -1
- package/lib/commonjs/contexts/auth.js +24 -3
- package/lib/commonjs/contexts/auth.js.map +1 -1
- package/lib/commonjs/hooks/chat-messages.js +1 -1
- package/lib/commonjs/hooks/chat-messages.js.map +1 -1
- package/lib/commonjs/hooks/developer-mode.js +31 -0
- package/lib/commonjs/hooks/developer-mode.js.map +1 -0
- package/lib/commonjs/hooks/lockout.js +80 -0
- package/lib/commonjs/hooks/lockout.js.map +1 -0
- package/lib/commonjs/hooks/onboarding.js +23 -0
- package/lib/commonjs/hooks/onboarding.js.map +1 -0
- package/lib/commonjs/index.js +24 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/localization/en/index.js +2 -1
- package/lib/commonjs/localization/en/index.js.map +1 -1
- package/lib/commonjs/localization/fr/index.js +2 -1
- package/lib/commonjs/localization/fr/index.js.map +1 -1
- package/lib/commonjs/localization/pt-br/index.js +2 -1
- package/lib/commonjs/localization/pt-br/index.js.map +1 -1
- package/lib/commonjs/modules/openid/components/OpenIDCredentialCard.js +4 -5
- package/lib/commonjs/modules/openid/components/OpenIDCredentialCard.js.map +1 -1
- package/lib/commonjs/modules/openid/display.js +6 -3
- package/lib/commonjs/modules/openid/display.js.map +1 -1
- package/lib/commonjs/modules/openid/metadata.js +2 -1
- package/lib/commonjs/modules/openid/metadata.js.map +1 -1
- package/lib/commonjs/modules/openid/screens/OpenIDProofChangeCredential.js +128 -0
- package/lib/commonjs/modules/openid/screens/OpenIDProofChangeCredential.js.map +1 -0
- package/lib/commonjs/modules/openid/screens/OpenIDProofPresentation.js +99 -44
- package/lib/commonjs/modules/openid/screens/OpenIDProofPresentation.js.map +1 -1
- package/lib/commonjs/modules/openid/types.js.map +1 -1
- package/lib/commonjs/modules/openid/utils/utils.js +0 -14
- package/lib/commonjs/modules/openid/utils/utils.js.map +1 -1
- package/lib/commonjs/navigators/DeliveryStack.js +8 -0
- package/lib/commonjs/navigators/DeliveryStack.js.map +1 -1
- package/lib/commonjs/navigators/OnboardingScreens.js +0 -8
- package/lib/commonjs/navigators/OnboardingScreens.js.map +1 -1
- package/lib/commonjs/navigators/OnboardingStack.js +3 -4
- package/lib/commonjs/navigators/OnboardingStack.js.map +1 -1
- package/lib/commonjs/navigators/TabStack.js +11 -4
- package/lib/commonjs/navigators/TabStack.js.map +1 -1
- package/lib/commonjs/navigators/defaultStackOptions.js +2 -1
- package/lib/commonjs/navigators/defaultStackOptions.js.map +1 -1
- package/lib/commonjs/screens/Biometry.js.map +1 -1
- package/lib/commonjs/screens/NameWallet.js +4 -3
- package/lib/commonjs/screens/NameWallet.js.map +1 -1
- package/lib/commonjs/screens/OnboardingPages.js +8 -38
- package/lib/commonjs/screens/OnboardingPages.js.map +1 -1
- package/lib/commonjs/screens/PINChange.js +5 -1
- package/lib/commonjs/screens/PINChange.js.map +1 -1
- package/lib/commonjs/screens/PINCreate.js +4 -1
- package/lib/commonjs/screens/PINCreate.js.map +1 -1
- package/lib/commonjs/screens/PINEnter.js +114 -292
- package/lib/commonjs/screens/PINEnter.js.map +1 -1
- package/lib/commonjs/screens/PINVerify.js +181 -0
- package/lib/commonjs/screens/PINVerify.js.map +1 -0
- package/lib/commonjs/screens/PushNotifications.js.map +1 -1
- package/lib/commonjs/screens/Settings.js +9 -18
- package/lib/commonjs/screens/Settings.js.map +1 -1
- package/lib/commonjs/screens/ToggleBiometry.js +16 -24
- package/lib/commonjs/screens/ToggleBiometry.js.map +1 -1
- package/lib/commonjs/theme.js +2 -1
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/commonjs/types/navigators.js +1 -0
- package/lib/commonjs/types/navigators.js.map +1 -1
- package/lib/commonjs/utils/oca.js +46 -17
- package/lib/commonjs/utils/oca.js.map +1 -1
- package/lib/module/components/inputs/BiometryControl.js.map +1 -1
- package/lib/module/components/misc/CredentialCard.js +3 -2
- package/lib/module/components/misc/CredentialCard.js.map +1 -1
- package/lib/module/components/misc/FauxHeader.js +80 -0
- package/lib/module/components/misc/FauxHeader.js.map +1 -0
- package/lib/module/components/misc/QRScanner.js +1 -1
- package/lib/module/components/misc/QRScanner.js.map +1 -1
- package/lib/module/components/modals/DeveloperModal.js +36 -0
- package/lib/module/components/modals/DeveloperModal.js.map +1 -0
- package/lib/module/components/views/PushNotificationsContent.js.map +1 -1
- package/lib/module/components/views/PushNotificationsDisabledContent.js.map +1 -1
- package/lib/module/contexts/auth.js +22 -1
- package/lib/module/contexts/auth.js.map +1 -1
- package/lib/module/hooks/chat-messages.js +1 -1
- package/lib/module/hooks/chat-messages.js.map +1 -1
- package/lib/module/hooks/developer-mode.js +24 -0
- package/lib/module/hooks/developer-mode.js.map +1 -0
- package/lib/module/hooks/lockout.js +70 -0
- package/lib/module/hooks/lockout.js.map +1 -0
- package/lib/module/hooks/onboarding.js +16 -0
- package/lib/module/hooks/onboarding.js.map +1 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/localization/en/index.js +2 -1
- package/lib/module/localization/en/index.js.map +1 -1
- package/lib/module/localization/fr/index.js +2 -1
- package/lib/module/localization/fr/index.js.map +1 -1
- package/lib/module/localization/pt-br/index.js +2 -1
- package/lib/module/localization/pt-br/index.js.map +1 -1
- package/lib/module/modules/openid/components/OpenIDCredentialCard.js +4 -4
- package/lib/module/modules/openid/components/OpenIDCredentialCard.js.map +1 -1
- package/lib/module/modules/openid/display.js +6 -3
- package/lib/module/modules/openid/display.js.map +1 -1
- package/lib/module/modules/openid/metadata.js +2 -1
- package/lib/module/modules/openid/metadata.js.map +1 -1
- package/lib/module/modules/openid/screens/OpenIDProofChangeCredential.js +121 -0
- package/lib/module/modules/openid/screens/OpenIDProofChangeCredential.js.map +1 -0
- package/lib/module/modules/openid/screens/OpenIDProofPresentation.js +100 -45
- package/lib/module/modules/openid/screens/OpenIDProofPresentation.js.map +1 -1
- package/lib/module/modules/openid/types.js.map +1 -1
- package/lib/module/modules/openid/utils/utils.js +1 -12
- package/lib/module/modules/openid/utils/utils.js.map +1 -1
- package/lib/module/navigators/DeliveryStack.js +8 -0
- package/lib/module/navigators/DeliveryStack.js.map +1 -1
- package/lib/module/navigators/OnboardingScreens.js +0 -8
- package/lib/module/navigators/OnboardingScreens.js.map +1 -1
- package/lib/module/navigators/OnboardingStack.js +4 -5
- package/lib/module/navigators/OnboardingStack.js.map +1 -1
- package/lib/module/navigators/TabStack.js +11 -4
- package/lib/module/navigators/TabStack.js.map +1 -1
- package/lib/module/navigators/defaultStackOptions.js +2 -1
- package/lib/module/navigators/defaultStackOptions.js.map +1 -1
- package/lib/module/screens/Biometry.js.map +1 -1
- package/lib/module/screens/NameWallet.js +4 -3
- package/lib/module/screens/NameWallet.js.map +1 -1
- package/lib/module/screens/OnboardingPages.js +8 -38
- package/lib/module/screens/OnboardingPages.js.map +1 -1
- package/lib/module/screens/PINChange.js +5 -1
- package/lib/module/screens/PINChange.js.map +1 -1
- package/lib/module/screens/PINCreate.js +4 -1
- package/lib/module/screens/PINCreate.js.map +1 -1
- package/lib/module/screens/PINEnter.js +116 -294
- package/lib/module/screens/PINEnter.js.map +1 -1
- package/lib/module/screens/PINVerify.js +172 -0
- package/lib/module/screens/PINVerify.js.map +1 -0
- package/lib/module/screens/PushNotifications.js.map +1 -1
- package/lib/module/screens/Settings.js +7 -16
- package/lib/module/screens/Settings.js.map +1 -1
- package/lib/module/screens/ToggleBiometry.js +15 -23
- package/lib/module/screens/ToggleBiometry.js.map +1 -1
- package/lib/module/theme.js +2 -1
- package/lib/module/theme.js.map +1 -1
- package/lib/module/types/navigators.js +1 -0
- package/lib/module/types/navigators.js.map +1 -1
- package/lib/module/utils/oca.js +43 -15
- package/lib/module/utils/oca.js.map +1 -1
- package/lib/typescript/src/components/inputs/BiometryControl.d.ts.map +1 -1
- package/lib/typescript/src/components/misc/CredentialCard.d.ts.map +1 -1
- package/lib/typescript/src/components/misc/FauxHeader.d.ts +8 -0
- package/lib/typescript/src/components/misc/FauxHeader.d.ts.map +1 -0
- package/lib/typescript/src/components/modals/DeveloperModal.d.ts +7 -0
- package/lib/typescript/src/components/modals/DeveloperModal.d.ts.map +1 -0
- package/lib/typescript/src/contexts/auth.d.ts +1 -0
- package/lib/typescript/src/contexts/auth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/developer-mode.d.ts +4 -0
- package/lib/typescript/src/hooks/developer-mode.d.ts.map +1 -0
- package/lib/typescript/src/hooks/lockout.d.ts +9 -0
- package/lib/typescript/src/hooks/lockout.d.ts.map +1 -0
- package/lib/typescript/src/hooks/onboarding.d.ts +2 -0
- package/lib/typescript/src/hooks/onboarding.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/en/index.d.ts +1 -0
- package/lib/typescript/src/localization/en/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/fr/index.d.ts +1 -0
- package/lib/typescript/src/localization/fr/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/pt-br/index.d.ts +1 -0
- package/lib/typescript/src/localization/pt-br/index.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/components/OpenIDCredentialCard.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/display.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/metadata.d.ts +8 -1
- package/lib/typescript/src/modules/openid/metadata.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/screens/OpenIDProofChangeCredential.d.ts +6 -0
- package/lib/typescript/src/modules/openid/screens/OpenIDProofChangeCredential.d.ts.map +1 -0
- package/lib/typescript/src/modules/openid/screens/OpenIDProofPresentation.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/types.d.ts +9 -0
- package/lib/typescript/src/modules/openid/types.d.ts.map +1 -1
- package/lib/typescript/src/modules/openid/utils/utils.d.ts +1 -3
- package/lib/typescript/src/modules/openid/utils/utils.d.ts.map +1 -1
- package/lib/typescript/src/navigators/DeliveryStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/OnboardingScreens.d.ts +0 -1
- package/lib/typescript/src/navigators/OnboardingScreens.d.ts.map +1 -1
- package/lib/typescript/src/navigators/OnboardingStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/TabStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/defaultStackOptions.d.ts.map +1 -1
- package/lib/typescript/src/screens/Biometry.d.ts.map +1 -1
- package/lib/typescript/src/screens/OnboardingPages.d.ts +1 -1
- package/lib/typescript/src/screens/OnboardingPages.d.ts.map +1 -1
- package/lib/typescript/src/screens/PINChange.d.ts.map +1 -1
- package/lib/typescript/src/screens/PINCreate.d.ts.map +1 -1
- package/lib/typescript/src/screens/PINEnter.d.ts +0 -7
- package/lib/typescript/src/screens/PINEnter.d.ts.map +1 -1
- package/lib/typescript/src/screens/PINVerify.d.ts +13 -0
- package/lib/typescript/src/screens/PINVerify.d.ts.map +1 -0
- package/lib/typescript/src/screens/Settings.d.ts.map +1 -1
- package/lib/typescript/src/screens/ToggleBiometry.d.ts.map +1 -1
- package/lib/typescript/src/theme.d.ts +10 -25
- package/lib/typescript/src/theme.d.ts.map +1 -1
- package/lib/typescript/src/types/navigators.d.ts +14 -1
- package/lib/typescript/src/types/navigators.d.ts.map +1 -1
- package/lib/typescript/src/utils/oca.d.ts +7 -2
- package/lib/typescript/src/utils/oca.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/inputs/BiometryControl.tsx +16 -13
- package/src/components/misc/CredentialCard.tsx +5 -2
- package/src/components/misc/FauxHeader.tsx +75 -0
- package/src/components/misc/QRScanner.tsx +1 -1
- package/src/components/modals/DeveloperModal.tsx +30 -0
- package/src/components/views/PushNotificationsContent.tsx +15 -15
- package/src/components/views/PushNotificationsDisabledContent.tsx +10 -10
- package/src/contexts/auth.tsx +33 -1
- package/src/hooks/chat-messages.tsx +1 -1
- package/src/hooks/developer-mode.ts +25 -0
- package/src/hooks/lockout.ts +77 -0
- package/src/hooks/onboarding.ts +16 -0
- package/src/hooks/usePINValidation.ts +3 -3
- package/src/index.ts +7 -0
- package/src/localization/en/index.ts +1 -0
- package/src/localization/fr/index.ts +1 -0
- package/src/localization/pt-br/index.ts +1 -0
- package/src/modules/openid/components/OpenIDCredentialCard.tsx +3 -4
- package/src/modules/openid/display.tsx +3 -0
- package/src/modules/openid/metadata.tsx +7 -1
- package/src/modules/openid/screens/OpenIDProofChangeCredential.tsx +132 -0
- package/src/modules/openid/screens/OpenIDProofPresentation.tsx +131 -59
- package/src/modules/openid/types.tsx +8 -0
- package/src/modules/openid/utils/utils.tsx +0 -14
- package/src/navigators/DeliveryStack.tsx +9 -0
- package/src/navigators/OnboardingScreens.ts +0 -10
- package/src/navigators/OnboardingStack.tsx +2 -6
- package/src/navigators/RootStack.tsx +1 -1
- package/src/navigators/TabStack.tsx +3 -2
- package/src/navigators/defaultStackOptions.tsx +1 -0
- package/src/screens/Biometry.tsx +1 -4
- package/src/screens/NameWallet.tsx +2 -2
- package/src/screens/OnboardingPages.tsx +9 -61
- package/src/screens/PINChange.tsx +6 -9
- package/src/screens/PINCreate.tsx +7 -18
- package/src/screens/PINEnter.tsx +114 -361
- package/src/screens/PINVerify.tsx +193 -0
- package/src/screens/PushNotifications.tsx +2 -2
- package/src/screens/Settings.tsx +6 -21
- package/src/screens/ToggleBiometry.tsx +20 -34
- package/src/theme.ts +34 -3
- package/src/types/navigators.ts +18 -1
- package/src/utils/oca.ts +60 -19
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useCallback } from 'react'
|
|
2
|
+
import { useNavigation, CommonActions } from '@react-navigation/native'
|
|
3
|
+
import { useStore } from '../contexts/store'
|
|
4
|
+
import { DispatchAction } from '../contexts/reducers/store'
|
|
5
|
+
import { Screens } from '../types/navigators'
|
|
6
|
+
import { TOKENS, useServices } from '../container-api'
|
|
7
|
+
import { attemptLockoutConfig } from '../constants'
|
|
8
|
+
|
|
9
|
+
export const useAttemptLockout = () => {
|
|
10
|
+
const [store, dispatch] = useStore()
|
|
11
|
+
const navigation = useNavigation()
|
|
12
|
+
// set the attempt lockout time
|
|
13
|
+
return useCallback(
|
|
14
|
+
async (penalty: number) => {
|
|
15
|
+
dispatch({
|
|
16
|
+
type: DispatchAction.ATTEMPT_UPDATED,
|
|
17
|
+
payload: [
|
|
18
|
+
{
|
|
19
|
+
loginAttempts: store.loginAttempt.loginAttempts + 1,
|
|
20
|
+
lockoutDate: Date.now() + penalty,
|
|
21
|
+
servedPenalty: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
})
|
|
25
|
+
navigation.dispatch(
|
|
26
|
+
CommonActions.reset({
|
|
27
|
+
index: 0,
|
|
28
|
+
routes: [{ name: Screens.AttemptLockout }],
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
},
|
|
32
|
+
[store, dispatch, navigation]
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const useGetLockoutPenalty = () => {
|
|
37
|
+
const [{ attemptLockoutConfig: { baseRules, thresholdRules } = attemptLockoutConfig }] = useServices([TOKENS.CONFIG])
|
|
38
|
+
return useCallback(
|
|
39
|
+
(attempts: number) => {
|
|
40
|
+
let penalty = baseRules[attempts]
|
|
41
|
+
if (!penalty && attempts >= thresholdRules.threshold && !(attempts % thresholdRules.increment)) {
|
|
42
|
+
penalty = thresholdRules.thresholdPenaltyDuration
|
|
43
|
+
}
|
|
44
|
+
return penalty
|
|
45
|
+
},
|
|
46
|
+
[baseRules, thresholdRules]
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// This method is used to notify the app that the user is able to receive
|
|
51
|
+
// another lockout penalty
|
|
52
|
+
export const useUnMarkServedPenalty = () => {
|
|
53
|
+
const [store, dispatch] = useStore()
|
|
54
|
+
return useCallback(() => {
|
|
55
|
+
dispatch({
|
|
56
|
+
type: DispatchAction.ATTEMPT_UPDATED,
|
|
57
|
+
payload: [
|
|
58
|
+
{
|
|
59
|
+
loginAttempts: store.loginAttempt.loginAttempts,
|
|
60
|
+
lockoutDate: undefined,
|
|
61
|
+
servedPenalty: undefined,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
}, [dispatch, store.loginAttempt.loginAttempts])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const useLockout = () => {
|
|
69
|
+
const getLockoutPenalty = useGetLockoutPenalty()
|
|
70
|
+
const attemptLockout = useAttemptLockout()
|
|
71
|
+
const unMarkServedPenalty = useUnMarkServedPenalty()
|
|
72
|
+
return {
|
|
73
|
+
getLockoutPenalty,
|
|
74
|
+
attemptLockout,
|
|
75
|
+
unMarkServedPenalty,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCallback } from 'react'
|
|
2
|
+
import { useNavigation } from '@react-navigation/core'
|
|
3
|
+
import { useStore } from '../contexts/store'
|
|
4
|
+
|
|
5
|
+
export const useGotoPostAuthScreens = () => {
|
|
6
|
+
const [store] = useStore()
|
|
7
|
+
const navigation = useNavigation()
|
|
8
|
+
return useCallback(() => {
|
|
9
|
+
if (store.onboarding.postAuthScreens.length) {
|
|
10
|
+
const screen = store.onboarding.postAuthScreens[0]
|
|
11
|
+
if (screen) {
|
|
12
|
+
navigation.navigate(screen as never)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, [store.onboarding.postAuthScreens, navigation])
|
|
16
|
+
}
|
|
@@ -28,7 +28,7 @@ export const usePINValidation = (PIN: string, PINTwo: string) => {
|
|
|
28
28
|
const clearModal = useCallback(() => {
|
|
29
29
|
setModalState(initialModalState)
|
|
30
30
|
}, [])
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
const [PINValidations, setPINValidations] = useState<PINValidationsType[]>(
|
|
33
33
|
createPINValidations(PIN, PINSecurity.rules)
|
|
34
34
|
)
|
|
@@ -57,7 +57,7 @@ export const usePINValidation = (PIN: string, PINTwo: string) => {
|
|
|
57
57
|
visible: true,
|
|
58
58
|
title: title,
|
|
59
59
|
message: message,
|
|
60
|
-
onModalDismiss: clearModal
|
|
60
|
+
onModalDismiss: clearModal,
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
},
|
|
@@ -93,6 +93,6 @@ export const usePINValidation = (PIN: string, PINTwo: string) => {
|
|
|
93
93
|
modalState,
|
|
94
94
|
setModalState,
|
|
95
95
|
clearModal,
|
|
96
|
-
PINSecurity
|
|
96
|
+
PINSecurity,
|
|
97
97
|
}
|
|
98
98
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,9 @@ import { useTour } from './contexts/tour/tour-context'
|
|
|
42
42
|
import { TourProvider } from './contexts/tour/tour-provider'
|
|
43
43
|
import AttemptLockout from './screens/AttemptLockout'
|
|
44
44
|
import Developer from './screens/Developer'
|
|
45
|
+
import DeveloperModal from './components/modals/DeveloperModal'
|
|
46
|
+
import { useDeveloperMode } from './hooks/developer-mode'
|
|
47
|
+
import FauxHeader from './components/misc/FauxHeader'
|
|
45
48
|
import OnboardingPages from './screens/OnboardingPages'
|
|
46
49
|
import Preface from './screens/Preface'
|
|
47
50
|
import Splash from './screens/Splash'
|
|
@@ -107,6 +110,7 @@ export type {
|
|
|
107
110
|
IInlineInputMessage,
|
|
108
111
|
IInputs,
|
|
109
112
|
ITextTheme,
|
|
113
|
+
ITabTheme,
|
|
110
114
|
IBrandColors,
|
|
111
115
|
ISemanticColors,
|
|
112
116
|
INotificationColors,
|
|
@@ -193,6 +197,9 @@ export {
|
|
|
193
197
|
usePreventScreenCapture,
|
|
194
198
|
Splash,
|
|
195
199
|
Developer,
|
|
200
|
+
DeveloperModal,
|
|
201
|
+
useDeveloperMode,
|
|
202
|
+
FauxHeader,
|
|
196
203
|
Terms,
|
|
197
204
|
Preface,
|
|
198
205
|
UpdateAvailable,
|
|
@@ -21,9 +21,8 @@ import { MdocRecord, SdJwtVcRecord, W3cCredentialRecord } from '@credo-ts/core'
|
|
|
21
21
|
import { getCredentialForDisplay } from '../display'
|
|
22
22
|
import { BifoldError } from '../../../types/error'
|
|
23
23
|
import { EventTypes } from '../../../constants'
|
|
24
|
-
import { getAttributeField } from '../utils/utils'
|
|
25
24
|
import { Attribute } from '@bifold/oca/build/legacy'
|
|
26
|
-
import
|
|
25
|
+
import { getAttributeField } from '../../../utils/oca'
|
|
27
26
|
|
|
28
27
|
interface CredentialCardProps {
|
|
29
28
|
credentialDisplay?: W3cCredentialDisplay
|
|
@@ -66,7 +65,7 @@ const OpenIDCredentialCard: React.FC<CredentialCardProps> = ({
|
|
|
66
65
|
|
|
67
66
|
const overlayAttributeField = useMemo((): Attribute | undefined => {
|
|
68
67
|
if (!display?.primary_overlay_attribute || !credentialDisplay) return undefined
|
|
69
|
-
return getAttributeField(credentialDisplay, display.primary_overlay_attribute)
|
|
68
|
+
return getAttributeField(credentialDisplay, display.primary_overlay_attribute)?.field
|
|
70
69
|
}, [display, credentialDisplay])
|
|
71
70
|
|
|
72
71
|
const { width } = useWindowDimensions()
|
|
@@ -228,7 +227,7 @@ const OpenIDCredentialCard: React.FC<CredentialCardProps> = ({
|
|
|
228
227
|
testID={testIdWithKey('CredentialIssued')}
|
|
229
228
|
maxFontSizeMultiplier={1}
|
|
230
229
|
>
|
|
231
|
-
{overlayAttributeField.label ??
|
|
230
|
+
{overlayAttributeField.label ?? overlayAttributeField.name}: {overlayAttributeField.value}
|
|
232
231
|
</Text>
|
|
233
232
|
</View>
|
|
234
233
|
)
|
|
@@ -351,6 +351,7 @@ export function getCredentialForDisplay(
|
|
|
351
351
|
claimFormat: ClaimFormat.SdJwtVc,
|
|
352
352
|
validUntil: mapped.raw.validUntil,
|
|
353
353
|
validFrom: mapped.raw.validFrom,
|
|
354
|
+
credentialSubject: openId4VcMetadata?.credential.credential_subject,
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
|
|
@@ -383,6 +384,7 @@ export function getCredentialForDisplay(
|
|
|
383
384
|
claimFormat: ClaimFormat.MsoMdoc,
|
|
384
385
|
validUntil: mdocInstance.validityInfo.validUntil,
|
|
385
386
|
validFrom: mdocInstance.validityInfo.validFrom,
|
|
387
|
+
credentialSubject: openId4VcMetadata?.credential.credential_subject,
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
390
|
|
|
@@ -427,6 +429,7 @@ export function getCredentialForDisplay(
|
|
|
427
429
|
validFrom: credentialRecord.credential.issuanceDate
|
|
428
430
|
? new Date(credentialRecord.credential.issuanceDate)
|
|
429
431
|
: undefined,
|
|
432
|
+
credentialSubject: openId4VcMetadata?.credential.credential_subject,
|
|
430
433
|
}
|
|
431
434
|
}
|
|
432
435
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { W3cCredentialRecord, SdJwtVcRecord, MdocRecord } from '@credo-ts/core'
|
|
2
2
|
import type { OpenId4VciCredentialSupported, OpenId4VciIssuerMetadataDisplay } from '@credo-ts/openid4vc'
|
|
3
3
|
import type { MetadataDisplay } from '@sphereon/oid4vci-common'
|
|
4
|
+
import { CredentialSubjectRecord } from './types'
|
|
4
5
|
|
|
5
6
|
export interface OpenId4VcCredentialMetadata {
|
|
6
7
|
credential: {
|
|
7
8
|
display?: OpenId4VciCredentialSupported['display']
|
|
8
9
|
order?: OpenId4VciCredentialSupported['order']
|
|
10
|
+
credential_subject?: CredentialSubjectRecord
|
|
9
11
|
}
|
|
10
12
|
issuer: {
|
|
11
13
|
display?: OpenId4VciIssuerMetadataDisplay[]
|
|
@@ -13,16 +15,20 @@ export interface OpenId4VcCredentialMetadata {
|
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
export type OpenId4VcCredentialMetadataExtended = Partial<
|
|
19
|
+
OpenId4VciCredentialSupported & { credential_subject: CredentialSubjectRecord }
|
|
20
|
+
>
|
|
16
21
|
const openId4VcCredentialMetadataKey = '_bifold/openId4VcCredentialMetadata'
|
|
17
22
|
|
|
18
23
|
export function extractOpenId4VcCredentialMetadata(
|
|
19
|
-
credentialMetadata: OpenId4VciCredentialSupported
|
|
24
|
+
credentialMetadata: Partial<OpenId4VciCredentialSupported & { credential_subject: CredentialSubjectRecord }>,
|
|
20
25
|
serverMetadata: { display?: MetadataDisplay[]; id: string }
|
|
21
26
|
): OpenId4VcCredentialMetadata {
|
|
22
27
|
return {
|
|
23
28
|
credential: {
|
|
24
29
|
display: credentialMetadata.display,
|
|
25
30
|
order: credentialMetadata.order,
|
|
31
|
+
credential_subject: credentialMetadata.credential_subject,
|
|
26
32
|
},
|
|
27
33
|
issuer: {
|
|
28
34
|
display: serverMetadata.display,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { StackScreenProps } from '@react-navigation/stack'
|
|
2
|
+
import { DeliveryStackParams, Screens } from '../../../types/navigators'
|
|
3
|
+
import ScreenLayout from '../../../layout/ScreenLayout'
|
|
4
|
+
import { FlatList, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
import { useTheme } from '../../../contexts/theme'
|
|
7
|
+
import { useEffect, useState } from 'react'
|
|
8
|
+
import { MdocRecord, SdJwtVcRecord, W3cCredentialRecord } from '@credo-ts/core'
|
|
9
|
+
import { isSdJwtProofRequest, isW3CProofRequest } from '../utils/utils'
|
|
10
|
+
import { useOpenIDCredentials } from '../context/OpenIDCredentialRecordProvider'
|
|
11
|
+
import RecordLoading from '../../../components/animated/RecordLoading'
|
|
12
|
+
import { ThemedText } from '../../../components/texts/ThemedText'
|
|
13
|
+
import { testIdWithKey } from '../../../utils/testable'
|
|
14
|
+
import { CredentialCard } from '../../../components/misc'
|
|
15
|
+
|
|
16
|
+
type Props = StackScreenProps<DeliveryStackParams, Screens.OpenIDProofCredentialSelect>
|
|
17
|
+
type TypedCred = {
|
|
18
|
+
credential: W3cCredentialRecord | SdJwtVcRecord | MdocRecord
|
|
19
|
+
claimFormat: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const OpenIDProofCredentialSelect: React.FC<Props> = ({ route, navigation }: Props) => {
|
|
23
|
+
if (!route?.params) {
|
|
24
|
+
throw new Error('Change credential route params were not set properly')
|
|
25
|
+
}
|
|
26
|
+
const selectedCredentialID = route.params.selectedCredID
|
|
27
|
+
const altCredentials = route.params.altCredIDs
|
|
28
|
+
const onCredChange = route.params.onCredChange
|
|
29
|
+
const { ColorPallet, SelectedCredTheme } = useTheme()
|
|
30
|
+
const { getW3CCredentialById, getSdJwtCredentialById } = useOpenIDCredentials()
|
|
31
|
+
|
|
32
|
+
const { t } = useTranslation()
|
|
33
|
+
const [loading, setLoading] = useState(false)
|
|
34
|
+
|
|
35
|
+
const [credentialsRequested, setCredentialsRequested] = useState<Array<TypedCred>>([])
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
async function fetchCreds() {
|
|
39
|
+
if (!altCredentials) return
|
|
40
|
+
setLoading(true)
|
|
41
|
+
|
|
42
|
+
const creds: TypedCred[] = []
|
|
43
|
+
|
|
44
|
+
for (const { id, claimFormat } of Object.values(altCredentials)) {
|
|
45
|
+
let credential: W3cCredentialRecord | SdJwtVcRecord | MdocRecord | undefined
|
|
46
|
+
if (isW3CProofRequest(claimFormat)) {
|
|
47
|
+
credential = await getW3CCredentialById(id)
|
|
48
|
+
} else if (isSdJwtProofRequest(claimFormat)) {
|
|
49
|
+
credential = await getSdJwtCredentialById(id)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (credential) {
|
|
53
|
+
creds.push({
|
|
54
|
+
credential,
|
|
55
|
+
claimFormat,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
setCredentialsRequested(creds)
|
|
60
|
+
setLoading(false)
|
|
61
|
+
}
|
|
62
|
+
fetchCreds()
|
|
63
|
+
}, [altCredentials, getW3CCredentialById, getSdJwtCredentialById])
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
pageContainer: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
},
|
|
69
|
+
pageMargin: {
|
|
70
|
+
marginHorizontal: 20,
|
|
71
|
+
},
|
|
72
|
+
cardLoading: {
|
|
73
|
+
backgroundColor: ColorPallet.brand.secondaryBackground,
|
|
74
|
+
flex: 1,
|
|
75
|
+
flexGrow: 1,
|
|
76
|
+
marginVertical: 35,
|
|
77
|
+
borderRadius: 15,
|
|
78
|
+
paddingHorizontal: 10,
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const changeCred = (selection: TypedCred) => {
|
|
83
|
+
onCredChange({
|
|
84
|
+
inputDescriptorID: route.params.inputDescriptorID,
|
|
85
|
+
id: selection.credential.id,
|
|
86
|
+
claimFormat: selection.claimFormat,
|
|
87
|
+
})
|
|
88
|
+
navigation.goBack()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const listHeader = () => {
|
|
92
|
+
return (
|
|
93
|
+
<View style={{ ...styles.pageMargin, marginVertical: 20 }}>
|
|
94
|
+
{loading ? (
|
|
95
|
+
<View style={styles.cardLoading}>
|
|
96
|
+
<RecordLoading />
|
|
97
|
+
</View>
|
|
98
|
+
) : (
|
|
99
|
+
<ThemedText>{t('ProofRequest.MultipleCredentials')}</ThemedText>
|
|
100
|
+
)}
|
|
101
|
+
</View>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<ScreenLayout screen={Screens.OpenIDProofCredentialSelect}>
|
|
107
|
+
<FlatList
|
|
108
|
+
data={credentialsRequested}
|
|
109
|
+
ListHeaderComponent={listHeader}
|
|
110
|
+
renderItem={({ item }) => {
|
|
111
|
+
return (
|
|
112
|
+
<View style={styles.pageMargin}>
|
|
113
|
+
<TouchableOpacity
|
|
114
|
+
accessibilityRole="button"
|
|
115
|
+
testID={testIdWithKey(`select:${item.credential.id}`)}
|
|
116
|
+
onPress={() => changeCred(item)}
|
|
117
|
+
style={[
|
|
118
|
+
item.credential.id === selectedCredentialID ? SelectedCredTheme : undefined,
|
|
119
|
+
{ marginBottom: 10 },
|
|
120
|
+
]}
|
|
121
|
+
>
|
|
122
|
+
<CredentialCard credential={item.credential}></CredentialCard>
|
|
123
|
+
</TouchableOpacity>
|
|
124
|
+
</View>
|
|
125
|
+
)
|
|
126
|
+
}}
|
|
127
|
+
></FlatList>
|
|
128
|
+
</ScreenLayout>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default OpenIDProofCredentialSelect
|