@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.
Files changed (252) hide show
  1. package/lib/commonjs/components/inputs/BiometryControl.js.map +1 -1
  2. package/lib/commonjs/components/misc/CredentialCard.js +3 -2
  3. package/lib/commonjs/components/misc/CredentialCard.js.map +1 -1
  4. package/lib/commonjs/components/misc/FauxHeader.js +89 -0
  5. package/lib/commonjs/components/misc/FauxHeader.js.map +1 -0
  6. package/lib/commonjs/components/misc/QRScanner.js +1 -1
  7. package/lib/commonjs/components/misc/QRScanner.js.map +1 -1
  8. package/lib/commonjs/components/modals/DeveloperModal.js +43 -0
  9. package/lib/commonjs/components/modals/DeveloperModal.js.map +1 -0
  10. package/lib/commonjs/components/views/PushNotificationsContent.js.map +1 -1
  11. package/lib/commonjs/components/views/PushNotificationsDisabledContent.js.map +1 -1
  12. package/lib/commonjs/contexts/auth.js +24 -3
  13. package/lib/commonjs/contexts/auth.js.map +1 -1
  14. package/lib/commonjs/hooks/chat-messages.js +1 -1
  15. package/lib/commonjs/hooks/chat-messages.js.map +1 -1
  16. package/lib/commonjs/hooks/developer-mode.js +31 -0
  17. package/lib/commonjs/hooks/developer-mode.js.map +1 -0
  18. package/lib/commonjs/hooks/lockout.js +80 -0
  19. package/lib/commonjs/hooks/lockout.js.map +1 -0
  20. package/lib/commonjs/hooks/onboarding.js +23 -0
  21. package/lib/commonjs/hooks/onboarding.js.map +1 -0
  22. package/lib/commonjs/index.js +24 -0
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/localization/en/index.js +2 -1
  25. package/lib/commonjs/localization/en/index.js.map +1 -1
  26. package/lib/commonjs/localization/fr/index.js +2 -1
  27. package/lib/commonjs/localization/fr/index.js.map +1 -1
  28. package/lib/commonjs/localization/pt-br/index.js +2 -1
  29. package/lib/commonjs/localization/pt-br/index.js.map +1 -1
  30. package/lib/commonjs/modules/openid/components/OpenIDCredentialCard.js +4 -5
  31. package/lib/commonjs/modules/openid/components/OpenIDCredentialCard.js.map +1 -1
  32. package/lib/commonjs/modules/openid/display.js +6 -3
  33. package/lib/commonjs/modules/openid/display.js.map +1 -1
  34. package/lib/commonjs/modules/openid/metadata.js +2 -1
  35. package/lib/commonjs/modules/openid/metadata.js.map +1 -1
  36. package/lib/commonjs/modules/openid/screens/OpenIDProofChangeCredential.js +128 -0
  37. package/lib/commonjs/modules/openid/screens/OpenIDProofChangeCredential.js.map +1 -0
  38. package/lib/commonjs/modules/openid/screens/OpenIDProofPresentation.js +99 -44
  39. package/lib/commonjs/modules/openid/screens/OpenIDProofPresentation.js.map +1 -1
  40. package/lib/commonjs/modules/openid/types.js.map +1 -1
  41. package/lib/commonjs/modules/openid/utils/utils.js +0 -14
  42. package/lib/commonjs/modules/openid/utils/utils.js.map +1 -1
  43. package/lib/commonjs/navigators/DeliveryStack.js +8 -0
  44. package/lib/commonjs/navigators/DeliveryStack.js.map +1 -1
  45. package/lib/commonjs/navigators/OnboardingScreens.js +0 -8
  46. package/lib/commonjs/navigators/OnboardingScreens.js.map +1 -1
  47. package/lib/commonjs/navigators/OnboardingStack.js +3 -4
  48. package/lib/commonjs/navigators/OnboardingStack.js.map +1 -1
  49. package/lib/commonjs/navigators/TabStack.js +11 -4
  50. package/lib/commonjs/navigators/TabStack.js.map +1 -1
  51. package/lib/commonjs/navigators/defaultStackOptions.js +2 -1
  52. package/lib/commonjs/navigators/defaultStackOptions.js.map +1 -1
  53. package/lib/commonjs/screens/Biometry.js.map +1 -1
  54. package/lib/commonjs/screens/NameWallet.js +4 -3
  55. package/lib/commonjs/screens/NameWallet.js.map +1 -1
  56. package/lib/commonjs/screens/OnboardingPages.js +8 -38
  57. package/lib/commonjs/screens/OnboardingPages.js.map +1 -1
  58. package/lib/commonjs/screens/PINChange.js +5 -1
  59. package/lib/commonjs/screens/PINChange.js.map +1 -1
  60. package/lib/commonjs/screens/PINCreate.js +4 -1
  61. package/lib/commonjs/screens/PINCreate.js.map +1 -1
  62. package/lib/commonjs/screens/PINEnter.js +114 -292
  63. package/lib/commonjs/screens/PINEnter.js.map +1 -1
  64. package/lib/commonjs/screens/PINVerify.js +181 -0
  65. package/lib/commonjs/screens/PINVerify.js.map +1 -0
  66. package/lib/commonjs/screens/PushNotifications.js.map +1 -1
  67. package/lib/commonjs/screens/Settings.js +9 -18
  68. package/lib/commonjs/screens/Settings.js.map +1 -1
  69. package/lib/commonjs/screens/ToggleBiometry.js +16 -24
  70. package/lib/commonjs/screens/ToggleBiometry.js.map +1 -1
  71. package/lib/commonjs/theme.js +2 -1
  72. package/lib/commonjs/theme.js.map +1 -1
  73. package/lib/commonjs/types/navigators.js +1 -0
  74. package/lib/commonjs/types/navigators.js.map +1 -1
  75. package/lib/commonjs/utils/oca.js +46 -17
  76. package/lib/commonjs/utils/oca.js.map +1 -1
  77. package/lib/module/components/inputs/BiometryControl.js.map +1 -1
  78. package/lib/module/components/misc/CredentialCard.js +3 -2
  79. package/lib/module/components/misc/CredentialCard.js.map +1 -1
  80. package/lib/module/components/misc/FauxHeader.js +80 -0
  81. package/lib/module/components/misc/FauxHeader.js.map +1 -0
  82. package/lib/module/components/misc/QRScanner.js +1 -1
  83. package/lib/module/components/misc/QRScanner.js.map +1 -1
  84. package/lib/module/components/modals/DeveloperModal.js +36 -0
  85. package/lib/module/components/modals/DeveloperModal.js.map +1 -0
  86. package/lib/module/components/views/PushNotificationsContent.js.map +1 -1
  87. package/lib/module/components/views/PushNotificationsDisabledContent.js.map +1 -1
  88. package/lib/module/contexts/auth.js +22 -1
  89. package/lib/module/contexts/auth.js.map +1 -1
  90. package/lib/module/hooks/chat-messages.js +1 -1
  91. package/lib/module/hooks/chat-messages.js.map +1 -1
  92. package/lib/module/hooks/developer-mode.js +24 -0
  93. package/lib/module/hooks/developer-mode.js.map +1 -0
  94. package/lib/module/hooks/lockout.js +70 -0
  95. package/lib/module/hooks/lockout.js.map +1 -0
  96. package/lib/module/hooks/onboarding.js +16 -0
  97. package/lib/module/hooks/onboarding.js.map +1 -0
  98. package/lib/module/index.js +4 -1
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/localization/en/index.js +2 -1
  101. package/lib/module/localization/en/index.js.map +1 -1
  102. package/lib/module/localization/fr/index.js +2 -1
  103. package/lib/module/localization/fr/index.js.map +1 -1
  104. package/lib/module/localization/pt-br/index.js +2 -1
  105. package/lib/module/localization/pt-br/index.js.map +1 -1
  106. package/lib/module/modules/openid/components/OpenIDCredentialCard.js +4 -4
  107. package/lib/module/modules/openid/components/OpenIDCredentialCard.js.map +1 -1
  108. package/lib/module/modules/openid/display.js +6 -3
  109. package/lib/module/modules/openid/display.js.map +1 -1
  110. package/lib/module/modules/openid/metadata.js +2 -1
  111. package/lib/module/modules/openid/metadata.js.map +1 -1
  112. package/lib/module/modules/openid/screens/OpenIDProofChangeCredential.js +121 -0
  113. package/lib/module/modules/openid/screens/OpenIDProofChangeCredential.js.map +1 -0
  114. package/lib/module/modules/openid/screens/OpenIDProofPresentation.js +100 -45
  115. package/lib/module/modules/openid/screens/OpenIDProofPresentation.js.map +1 -1
  116. package/lib/module/modules/openid/types.js.map +1 -1
  117. package/lib/module/modules/openid/utils/utils.js +1 -12
  118. package/lib/module/modules/openid/utils/utils.js.map +1 -1
  119. package/lib/module/navigators/DeliveryStack.js +8 -0
  120. package/lib/module/navigators/DeliveryStack.js.map +1 -1
  121. package/lib/module/navigators/OnboardingScreens.js +0 -8
  122. package/lib/module/navigators/OnboardingScreens.js.map +1 -1
  123. package/lib/module/navigators/OnboardingStack.js +4 -5
  124. package/lib/module/navigators/OnboardingStack.js.map +1 -1
  125. package/lib/module/navigators/TabStack.js +11 -4
  126. package/lib/module/navigators/TabStack.js.map +1 -1
  127. package/lib/module/navigators/defaultStackOptions.js +2 -1
  128. package/lib/module/navigators/defaultStackOptions.js.map +1 -1
  129. package/lib/module/screens/Biometry.js.map +1 -1
  130. package/lib/module/screens/NameWallet.js +4 -3
  131. package/lib/module/screens/NameWallet.js.map +1 -1
  132. package/lib/module/screens/OnboardingPages.js +8 -38
  133. package/lib/module/screens/OnboardingPages.js.map +1 -1
  134. package/lib/module/screens/PINChange.js +5 -1
  135. package/lib/module/screens/PINChange.js.map +1 -1
  136. package/lib/module/screens/PINCreate.js +4 -1
  137. package/lib/module/screens/PINCreate.js.map +1 -1
  138. package/lib/module/screens/PINEnter.js +116 -294
  139. package/lib/module/screens/PINEnter.js.map +1 -1
  140. package/lib/module/screens/PINVerify.js +172 -0
  141. package/lib/module/screens/PINVerify.js.map +1 -0
  142. package/lib/module/screens/PushNotifications.js.map +1 -1
  143. package/lib/module/screens/Settings.js +7 -16
  144. package/lib/module/screens/Settings.js.map +1 -1
  145. package/lib/module/screens/ToggleBiometry.js +15 -23
  146. package/lib/module/screens/ToggleBiometry.js.map +1 -1
  147. package/lib/module/theme.js +2 -1
  148. package/lib/module/theme.js.map +1 -1
  149. package/lib/module/types/navigators.js +1 -0
  150. package/lib/module/types/navigators.js.map +1 -1
  151. package/lib/module/utils/oca.js +43 -15
  152. package/lib/module/utils/oca.js.map +1 -1
  153. package/lib/typescript/src/components/inputs/BiometryControl.d.ts.map +1 -1
  154. package/lib/typescript/src/components/misc/CredentialCard.d.ts.map +1 -1
  155. package/lib/typescript/src/components/misc/FauxHeader.d.ts +8 -0
  156. package/lib/typescript/src/components/misc/FauxHeader.d.ts.map +1 -0
  157. package/lib/typescript/src/components/modals/DeveloperModal.d.ts +7 -0
  158. package/lib/typescript/src/components/modals/DeveloperModal.d.ts.map +1 -0
  159. package/lib/typescript/src/contexts/auth.d.ts +1 -0
  160. package/lib/typescript/src/contexts/auth.d.ts.map +1 -1
  161. package/lib/typescript/src/hooks/developer-mode.d.ts +4 -0
  162. package/lib/typescript/src/hooks/developer-mode.d.ts.map +1 -0
  163. package/lib/typescript/src/hooks/lockout.d.ts +9 -0
  164. package/lib/typescript/src/hooks/lockout.d.ts.map +1 -0
  165. package/lib/typescript/src/hooks/onboarding.d.ts +2 -0
  166. package/lib/typescript/src/hooks/onboarding.d.ts.map +1 -0
  167. package/lib/typescript/src/index.d.ts +5 -2
  168. package/lib/typescript/src/index.d.ts.map +1 -1
  169. package/lib/typescript/src/localization/en/index.d.ts +1 -0
  170. package/lib/typescript/src/localization/en/index.d.ts.map +1 -1
  171. package/lib/typescript/src/localization/fr/index.d.ts +1 -0
  172. package/lib/typescript/src/localization/fr/index.d.ts.map +1 -1
  173. package/lib/typescript/src/localization/pt-br/index.d.ts +1 -0
  174. package/lib/typescript/src/localization/pt-br/index.d.ts.map +1 -1
  175. package/lib/typescript/src/modules/openid/components/OpenIDCredentialCard.d.ts.map +1 -1
  176. package/lib/typescript/src/modules/openid/display.d.ts.map +1 -1
  177. package/lib/typescript/src/modules/openid/metadata.d.ts +8 -1
  178. package/lib/typescript/src/modules/openid/metadata.d.ts.map +1 -1
  179. package/lib/typescript/src/modules/openid/screens/OpenIDProofChangeCredential.d.ts +6 -0
  180. package/lib/typescript/src/modules/openid/screens/OpenIDProofChangeCredential.d.ts.map +1 -0
  181. package/lib/typescript/src/modules/openid/screens/OpenIDProofPresentation.d.ts.map +1 -1
  182. package/lib/typescript/src/modules/openid/types.d.ts +9 -0
  183. package/lib/typescript/src/modules/openid/types.d.ts.map +1 -1
  184. package/lib/typescript/src/modules/openid/utils/utils.d.ts +1 -3
  185. package/lib/typescript/src/modules/openid/utils/utils.d.ts.map +1 -1
  186. package/lib/typescript/src/navigators/DeliveryStack.d.ts.map +1 -1
  187. package/lib/typescript/src/navigators/OnboardingScreens.d.ts +0 -1
  188. package/lib/typescript/src/navigators/OnboardingScreens.d.ts.map +1 -1
  189. package/lib/typescript/src/navigators/OnboardingStack.d.ts.map +1 -1
  190. package/lib/typescript/src/navigators/TabStack.d.ts.map +1 -1
  191. package/lib/typescript/src/navigators/defaultStackOptions.d.ts.map +1 -1
  192. package/lib/typescript/src/screens/Biometry.d.ts.map +1 -1
  193. package/lib/typescript/src/screens/OnboardingPages.d.ts +1 -1
  194. package/lib/typescript/src/screens/OnboardingPages.d.ts.map +1 -1
  195. package/lib/typescript/src/screens/PINChange.d.ts.map +1 -1
  196. package/lib/typescript/src/screens/PINCreate.d.ts.map +1 -1
  197. package/lib/typescript/src/screens/PINEnter.d.ts +0 -7
  198. package/lib/typescript/src/screens/PINEnter.d.ts.map +1 -1
  199. package/lib/typescript/src/screens/PINVerify.d.ts +13 -0
  200. package/lib/typescript/src/screens/PINVerify.d.ts.map +1 -0
  201. package/lib/typescript/src/screens/Settings.d.ts.map +1 -1
  202. package/lib/typescript/src/screens/ToggleBiometry.d.ts.map +1 -1
  203. package/lib/typescript/src/theme.d.ts +10 -25
  204. package/lib/typescript/src/theme.d.ts.map +1 -1
  205. package/lib/typescript/src/types/navigators.d.ts +14 -1
  206. package/lib/typescript/src/types/navigators.d.ts.map +1 -1
  207. package/lib/typescript/src/utils/oca.d.ts +7 -2
  208. package/lib/typescript/src/utils/oca.d.ts.map +1 -1
  209. package/package.json +3 -3
  210. package/src/components/inputs/BiometryControl.tsx +16 -13
  211. package/src/components/misc/CredentialCard.tsx +5 -2
  212. package/src/components/misc/FauxHeader.tsx +75 -0
  213. package/src/components/misc/QRScanner.tsx +1 -1
  214. package/src/components/modals/DeveloperModal.tsx +30 -0
  215. package/src/components/views/PushNotificationsContent.tsx +15 -15
  216. package/src/components/views/PushNotificationsDisabledContent.tsx +10 -10
  217. package/src/contexts/auth.tsx +33 -1
  218. package/src/hooks/chat-messages.tsx +1 -1
  219. package/src/hooks/developer-mode.ts +25 -0
  220. package/src/hooks/lockout.ts +77 -0
  221. package/src/hooks/onboarding.ts +16 -0
  222. package/src/hooks/usePINValidation.ts +3 -3
  223. package/src/index.ts +7 -0
  224. package/src/localization/en/index.ts +1 -0
  225. package/src/localization/fr/index.ts +1 -0
  226. package/src/localization/pt-br/index.ts +1 -0
  227. package/src/modules/openid/components/OpenIDCredentialCard.tsx +3 -4
  228. package/src/modules/openid/display.tsx +3 -0
  229. package/src/modules/openid/metadata.tsx +7 -1
  230. package/src/modules/openid/screens/OpenIDProofChangeCredential.tsx +132 -0
  231. package/src/modules/openid/screens/OpenIDProofPresentation.tsx +131 -59
  232. package/src/modules/openid/types.tsx +8 -0
  233. package/src/modules/openid/utils/utils.tsx +0 -14
  234. package/src/navigators/DeliveryStack.tsx +9 -0
  235. package/src/navigators/OnboardingScreens.ts +0 -10
  236. package/src/navigators/OnboardingStack.tsx +2 -6
  237. package/src/navigators/RootStack.tsx +1 -1
  238. package/src/navigators/TabStack.tsx +3 -2
  239. package/src/navigators/defaultStackOptions.tsx +1 -0
  240. package/src/screens/Biometry.tsx +1 -4
  241. package/src/screens/NameWallet.tsx +2 -2
  242. package/src/screens/OnboardingPages.tsx +9 -61
  243. package/src/screens/PINChange.tsx +6 -9
  244. package/src/screens/PINCreate.tsx +7 -18
  245. package/src/screens/PINEnter.tsx +114 -361
  246. package/src/screens/PINVerify.tsx +193 -0
  247. package/src/screens/PushNotifications.tsx +2 -2
  248. package/src/screens/Settings.tsx +6 -21
  249. package/src/screens/ToggleBiometry.tsx +20 -34
  250. package/src/theme.ts +34 -3
  251. package/src/types/navigators.ts +18 -1
  252. 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,
@@ -48,6 +48,7 @@ const translation = {
48
48
  "Close": "Close",
49
49
  "Remove": "Remove",
50
50
  "GotIt": "Got it",
51
+ "Send": "Send",
51
52
  },
52
53
  "Date": {
53
54
  "ShortFormat": "MMM D",
@@ -48,6 +48,7 @@ const translation = {
48
48
  "Remove": "Supprimer",
49
49
  "Close": "Fermer",
50
50
  "GotIt": "Got it (FR)",
51
+ "Send": "Envoyer",
51
52
  },
52
53
  "Date": {
53
54
  "ShortFormat": "D MMM",
@@ -47,6 +47,7 @@ const translation = {
47
47
  "Close": "Fechar",
48
48
  "Remove": "Remover",
49
49
  "GotIt": "Got it (PT-BR)",
50
+ "Send": "Enviar",
50
51
  },
51
52
  "Date": {
52
53
  "ShortFormat": "D MMM",
@@ -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 startCase from 'lodash.startcase'
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 ?? startCase(overlayAttributeField.name || '')}: {overlayAttributeField.value}
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