@bifold/core 1.0.0 → 2.0.1

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 (373) hide show
  1. package/lib/commonjs/App.js +26 -22
  2. package/lib/commonjs/App.js.map +1 -1
  3. package/lib/commonjs/components/inputs/BiometryControl.js +176 -0
  4. package/lib/commonjs/components/inputs/BiometryControl.js.map +1 -0
  5. package/lib/commonjs/components/misc/ConnectionAlert.js +2 -2
  6. package/lib/commonjs/components/misc/ConnectionAlert.js.map +1 -1
  7. package/lib/commonjs/components/misc/InfoBox.js +3 -2
  8. package/lib/commonjs/components/misc/InfoBox.js.map +1 -1
  9. package/lib/commonjs/components/misc/{PINCreateHeader.js → PINHeader.js} +4 -4
  10. package/lib/commonjs/components/misc/PINHeader.js.map +1 -0
  11. package/lib/commonjs/components/misc/PINValidationHelper.js +50 -0
  12. package/lib/commonjs/components/misc/PINValidationHelper.js.map +1 -0
  13. package/lib/commonjs/components/views/PushNotificationsContent.js +52 -0
  14. package/lib/commonjs/components/views/PushNotificationsContent.js.map +1 -0
  15. package/lib/commonjs/components/views/PushNotificationsDisabledContent.js +47 -0
  16. package/lib/commonjs/components/views/PushNotificationsDisabledContent.js.map +1 -0
  17. package/lib/commonjs/container-api.js +8 -3
  18. package/lib/commonjs/container-api.js.map +1 -1
  19. package/lib/commonjs/container-impl.js +25 -21
  20. package/lib/commonjs/container-impl.js.map +1 -1
  21. package/lib/commonjs/contexts/activity.js +17 -41
  22. package/lib/commonjs/contexts/activity.js.map +1 -1
  23. package/lib/commonjs/contexts/auth.js +16 -6
  24. package/lib/commonjs/contexts/auth.js.map +1 -1
  25. package/lib/commonjs/contexts/navigation.js +24 -0
  26. package/lib/commonjs/contexts/navigation.js.map +1 -0
  27. package/lib/commonjs/contexts/reducers/store.js +14 -0
  28. package/lib/commonjs/contexts/reducers/store.js.map +1 -1
  29. package/lib/commonjs/contexts/theme.js +36 -3
  30. package/lib/commonjs/contexts/theme.js.map +1 -1
  31. package/lib/commonjs/hooks/deep-links.js +2 -4
  32. package/lib/commonjs/hooks/deep-links.js.map +1 -1
  33. package/lib/commonjs/hooks/{initialize-agent.js → useBifoldAgentSetup.js} +24 -44
  34. package/lib/commonjs/hooks/useBifoldAgentSetup.js.map +1 -0
  35. package/lib/commonjs/hooks/useOnboardingState.js +3 -3
  36. package/lib/commonjs/hooks/useOnboardingState.js.map +1 -1
  37. package/lib/commonjs/hooks/usePINValidation.js +82 -0
  38. package/lib/commonjs/hooks/usePINValidation.js.map +1 -0
  39. package/lib/commonjs/index.js +34 -33
  40. package/lib/commonjs/index.js.map +1 -1
  41. package/lib/commonjs/localization/en/index.js +31 -25
  42. package/lib/commonjs/localization/en/index.js.map +1 -1
  43. package/lib/commonjs/localization/fr/index.js +18 -6
  44. package/lib/commonjs/localization/fr/index.js.map +1 -1
  45. package/lib/commonjs/localization/pt-br/index.js +43 -37
  46. package/lib/commonjs/localization/pt-br/index.js.map +1 -1
  47. package/lib/commonjs/navigators/MainStack.js +31 -8
  48. package/lib/commonjs/navigators/MainStack.js.map +1 -1
  49. package/lib/commonjs/navigators/OnboardingScreens.js +8 -8
  50. package/lib/commonjs/navigators/OnboardingScreens.js.map +1 -1
  51. package/lib/commonjs/navigators/OnboardingStack.js +20 -12
  52. package/lib/commonjs/navigators/OnboardingStack.js.map +1 -1
  53. package/lib/commonjs/navigators/RootStack.js +27 -30
  54. package/lib/commonjs/navigators/RootStack.js.map +1 -1
  55. package/lib/commonjs/navigators/SettingStack.js +14 -15
  56. package/lib/commonjs/navigators/SettingStack.js.map +1 -1
  57. package/lib/commonjs/navigators/defaultStackOptions.js +13 -2
  58. package/lib/commonjs/navigators/defaultStackOptions.js.map +1 -1
  59. package/lib/commonjs/onboarding.js +12 -5
  60. package/lib/commonjs/onboarding.js.map +1 -1
  61. package/lib/commonjs/screens/Biometry.js +62 -0
  62. package/lib/commonjs/screens/Biometry.js.map +1 -0
  63. package/lib/commonjs/screens/CredentialOffer.js +2 -2
  64. package/lib/commonjs/screens/CredentialOffer.js.map +1 -1
  65. package/lib/commonjs/screens/Onboarding.js.map +1 -1
  66. package/lib/commonjs/screens/PINChange.js +212 -0
  67. package/lib/commonjs/screens/PINChange.js.map +1 -0
  68. package/lib/commonjs/screens/PINCreate.js +47 -224
  69. package/lib/commonjs/screens/PINCreate.js.map +1 -1
  70. package/lib/commonjs/screens/Preface.js.map +1 -1
  71. package/lib/commonjs/screens/ProofRequest.js +112 -33
  72. package/lib/commonjs/screens/ProofRequest.js.map +1 -1
  73. package/lib/commonjs/screens/PushNotifications.js +71 -0
  74. package/lib/commonjs/screens/PushNotifications.js.map +1 -0
  75. package/lib/commonjs/screens/Settings.js +8 -24
  76. package/lib/commonjs/screens/Settings.js.map +1 -1
  77. package/lib/commonjs/screens/Splash.js +7 -23
  78. package/lib/commonjs/screens/Splash.js.map +1 -1
  79. package/lib/commonjs/screens/Terms.js.map +1 -1
  80. package/lib/commonjs/screens/ToggleBiometry.js +135 -0
  81. package/lib/commonjs/screens/ToggleBiometry.js.map +1 -0
  82. package/lib/commonjs/screens/{PushNotification.js → TogglePushNotifications.js} +41 -99
  83. package/lib/commonjs/screens/TogglePushNotifications.js.map +1 -0
  84. package/lib/commonjs/theme.js +4 -2
  85. package/lib/commonjs/theme.js.map +1 -1
  86. package/lib/commonjs/types/navigators.js +5 -2
  87. package/lib/commonjs/types/navigators.js.map +1 -1
  88. package/lib/commonjs/utils/{PINCreationValidation.js → PINValidation.js} +4 -4
  89. package/lib/commonjs/utils/PINValidation.js.map +1 -0
  90. package/lib/commonjs/utils/agent.js.map +1 -1
  91. package/lib/commonjs/utils/helpers.js +2 -0
  92. package/lib/commonjs/utils/helpers.js.map +1 -1
  93. package/lib/module/App.js +24 -20
  94. package/lib/module/App.js.map +1 -1
  95. package/lib/module/components/inputs/BiometryControl.js +167 -0
  96. package/lib/module/components/inputs/BiometryControl.js.map +1 -0
  97. package/lib/module/components/misc/ConnectionAlert.js +2 -2
  98. package/lib/module/components/misc/ConnectionAlert.js.map +1 -1
  99. package/lib/module/components/misc/InfoBox.js +3 -2
  100. package/lib/module/components/misc/InfoBox.js.map +1 -1
  101. package/lib/module/components/misc/{PINCreateHeader.js → PINHeader.js} +4 -4
  102. package/lib/module/components/misc/PINHeader.js.map +1 -0
  103. package/lib/module/components/misc/PINValidationHelper.js +43 -0
  104. package/lib/module/components/misc/PINValidationHelper.js.map +1 -0
  105. package/lib/module/components/views/PushNotificationsContent.js +45 -0
  106. package/lib/module/components/views/PushNotificationsContent.js.map +1 -0
  107. package/lib/module/components/views/PushNotificationsDisabledContent.js +40 -0
  108. package/lib/module/components/views/PushNotificationsDisabledContent.js.map +1 -0
  109. package/lib/module/container-api.js +7 -2
  110. package/lib/module/container-api.js.map +1 -1
  111. package/lib/module/container-impl.js +25 -21
  112. package/lib/module/container-impl.js.map +1 -1
  113. package/lib/module/contexts/activity.js +17 -41
  114. package/lib/module/contexts/activity.js.map +1 -1
  115. package/lib/module/contexts/auth.js +16 -6
  116. package/lib/module/contexts/auth.js.map +1 -1
  117. package/lib/module/contexts/navigation.js +17 -0
  118. package/lib/module/contexts/navigation.js.map +1 -0
  119. package/lib/module/contexts/reducers/store.js +14 -0
  120. package/lib/module/contexts/reducers/store.js.map +1 -1
  121. package/lib/module/contexts/theme.js +36 -4
  122. package/lib/module/contexts/theme.js.map +1 -1
  123. package/lib/module/hooks/deep-links.js +2 -4
  124. package/lib/module/hooks/deep-links.js.map +1 -1
  125. package/lib/module/hooks/{initialize-agent.js → useBifoldAgentSetup.js} +25 -45
  126. package/lib/module/hooks/useBifoldAgentSetup.js.map +1 -0
  127. package/lib/module/hooks/useOnboardingState.js +3 -3
  128. package/lib/module/hooks/useOnboardingState.js.map +1 -1
  129. package/lib/module/hooks/usePINValidation.js +75 -0
  130. package/lib/module/hooks/usePINValidation.js.map +1 -0
  131. package/lib/module/index.js +6 -6
  132. package/lib/module/index.js.map +1 -1
  133. package/lib/module/localization/en/index.js +31 -25
  134. package/lib/module/localization/en/index.js.map +1 -1
  135. package/lib/module/localization/fr/index.js +18 -6
  136. package/lib/module/localization/fr/index.js.map +1 -1
  137. package/lib/module/localization/pt-br/index.js +43 -37
  138. package/lib/module/localization/pt-br/index.js.map +1 -1
  139. package/lib/module/navigators/MainStack.js +32 -9
  140. package/lib/module/navigators/MainStack.js.map +1 -1
  141. package/lib/module/navigators/OnboardingScreens.js +8 -8
  142. package/lib/module/navigators/OnboardingScreens.js.map +1 -1
  143. package/lib/module/navigators/OnboardingStack.js +21 -12
  144. package/lib/module/navigators/OnboardingStack.js.map +1 -1
  145. package/lib/module/navigators/RootStack.js +26 -29
  146. package/lib/module/navigators/RootStack.js.map +1 -1
  147. package/lib/module/navigators/SettingStack.js +14 -15
  148. package/lib/module/navigators/SettingStack.js.map +1 -1
  149. package/lib/module/navigators/defaultStackOptions.js +13 -2
  150. package/lib/module/navigators/defaultStackOptions.js.map +1 -1
  151. package/lib/module/onboarding.js +10 -4
  152. package/lib/module/onboarding.js.map +1 -1
  153. package/lib/module/screens/Biometry.js +53 -0
  154. package/lib/module/screens/Biometry.js.map +1 -0
  155. package/lib/module/screens/CredentialOffer.js +2 -2
  156. package/lib/module/screens/CredentialOffer.js.map +1 -1
  157. package/lib/module/screens/Onboarding.js.map +1 -1
  158. package/lib/module/screens/PINChange.js +203 -0
  159. package/lib/module/screens/PINChange.js.map +1 -0
  160. package/lib/module/screens/PINCreate.js +49 -226
  161. package/lib/module/screens/PINCreate.js.map +1 -1
  162. package/lib/module/screens/Preface.js.map +1 -1
  163. package/lib/module/screens/ProofRequest.js +113 -34
  164. package/lib/module/screens/ProofRequest.js.map +1 -1
  165. package/lib/module/screens/PushNotifications.js +63 -0
  166. package/lib/module/screens/PushNotifications.js.map +1 -0
  167. package/lib/module/screens/Settings.js +9 -25
  168. package/lib/module/screens/Settings.js.map +1 -1
  169. package/lib/module/screens/Splash.js +7 -23
  170. package/lib/module/screens/Splash.js.map +1 -1
  171. package/lib/module/screens/Terms.js.map +1 -1
  172. package/lib/module/screens/ToggleBiometry.js +126 -0
  173. package/lib/module/screens/ToggleBiometry.js.map +1 -0
  174. package/lib/module/screens/TogglePushNotifications.js +112 -0
  175. package/lib/module/screens/TogglePushNotifications.js.map +1 -0
  176. package/lib/module/theme.js +3 -1
  177. package/lib/module/theme.js.map +1 -1
  178. package/lib/module/types/navigators.js +5 -2
  179. package/lib/module/types/navigators.js.map +1 -1
  180. package/lib/module/utils/{PINCreationValidation.js → PINValidation.js} +2 -2
  181. package/lib/module/utils/PINValidation.js.map +1 -0
  182. package/lib/module/utils/agent.js.map +1 -1
  183. package/lib/module/utils/helpers.js +2 -0
  184. package/lib/module/utils/helpers.js.map +1 -1
  185. package/lib/typescript/src/App.d.ts +3 -3
  186. package/lib/typescript/src/App.d.ts.map +1 -1
  187. package/lib/typescript/src/components/inputs/BiometryControl.d.ts +9 -0
  188. package/lib/typescript/src/components/inputs/BiometryControl.d.ts.map +1 -0
  189. package/lib/typescript/src/components/misc/ConnectionAlert.d.ts +1 -1
  190. package/lib/typescript/src/components/misc/ConnectionAlert.d.ts.map +1 -1
  191. package/lib/typescript/src/components/misc/InfoBox.d.ts +1 -0
  192. package/lib/typescript/src/components/misc/InfoBox.d.ts.map +1 -1
  193. package/lib/typescript/src/components/misc/PINHeader.d.ts +6 -0
  194. package/lib/typescript/src/components/misc/PINHeader.d.ts.map +1 -0
  195. package/lib/typescript/src/components/misc/PINValidationHelper.d.ts +8 -0
  196. package/lib/typescript/src/components/misc/PINValidationHelper.d.ts.map +1 -0
  197. package/lib/typescript/src/components/views/PushNotificationsContent.d.ts +4 -0
  198. package/lib/typescript/src/components/views/PushNotificationsContent.d.ts.map +1 -0
  199. package/lib/typescript/src/components/views/PushNotificationsDisabledContent.d.ts +4 -0
  200. package/lib/typescript/src/components/views/PushNotificationsDisabledContent.d.ts.map +1 -0
  201. package/lib/typescript/src/container-api.d.ts +24 -13
  202. package/lib/typescript/src/container-api.d.ts.map +1 -1
  203. package/lib/typescript/src/container-impl.d.ts +4 -2
  204. package/lib/typescript/src/container-impl.d.ts.map +1 -1
  205. package/lib/typescript/src/contexts/activity.d.ts.map +1 -1
  206. package/lib/typescript/src/contexts/auth.d.ts +3 -1
  207. package/lib/typescript/src/contexts/auth.d.ts.map +1 -1
  208. package/lib/typescript/src/contexts/navigation.d.ts +8 -0
  209. package/lib/typescript/src/contexts/navigation.d.ts.map +1 -0
  210. package/lib/typescript/src/contexts/reducers/store.d.ts +3 -1
  211. package/lib/typescript/src/contexts/reducers/store.d.ts.map +1 -1
  212. package/lib/typescript/src/contexts/theme.d.ts +9 -3
  213. package/lib/typescript/src/contexts/theme.d.ts.map +1 -1
  214. package/lib/typescript/src/hooks/deep-links.d.ts.map +1 -1
  215. package/lib/typescript/src/hooks/useBifoldAgentSetup.d.ts +10 -0
  216. package/lib/typescript/src/hooks/useBifoldAgentSetup.d.ts.map +1 -0
  217. package/lib/typescript/src/hooks/useOnboardingState.d.ts +2 -1
  218. package/lib/typescript/src/hooks/useOnboardingState.d.ts.map +1 -1
  219. package/lib/typescript/src/hooks/usePINValidation.d.ts +20 -0
  220. package/lib/typescript/src/hooks/usePINValidation.d.ts.map +1 -0
  221. package/lib/typescript/src/index.d.ts +9 -7
  222. package/lib/typescript/src/index.d.ts.map +1 -1
  223. package/lib/typescript/src/localization/en/index.d.ts +23 -17
  224. package/lib/typescript/src/localization/en/index.d.ts.map +1 -1
  225. package/lib/typescript/src/localization/fr/index.d.ts +14 -2
  226. package/lib/typescript/src/localization/fr/index.d.ts.map +1 -1
  227. package/lib/typescript/src/localization/pt-br/index.d.ts +23 -17
  228. package/lib/typescript/src/localization/pt-br/index.d.ts.map +1 -1
  229. package/lib/typescript/src/navigators/MainStack.d.ts.map +1 -1
  230. package/lib/typescript/src/navigators/OnboardingScreens.d.ts +3 -3
  231. package/lib/typescript/src/navigators/OnboardingScreens.d.ts.map +1 -1
  232. package/lib/typescript/src/navigators/OnboardingStack.d.ts +7 -1
  233. package/lib/typescript/src/navigators/OnboardingStack.d.ts.map +1 -1
  234. package/lib/typescript/src/navigators/RootStack.d.ts.map +1 -1
  235. package/lib/typescript/src/navigators/SettingStack.d.ts.map +1 -1
  236. package/lib/typescript/src/navigators/defaultStackOptions.d.ts.map +1 -1
  237. package/lib/typescript/src/onboarding.d.ts +4 -2
  238. package/lib/typescript/src/onboarding.d.ts.map +1 -1
  239. package/lib/typescript/src/screens/Biometry.d.ts +4 -0
  240. package/lib/typescript/src/screens/Biometry.d.ts.map +1 -0
  241. package/lib/typescript/src/screens/{PushNotification.d.ts → PINChange.d.ts} +3 -3
  242. package/lib/typescript/src/screens/PINChange.d.ts.map +1 -0
  243. package/lib/typescript/src/screens/PINCreate.d.ts.map +1 -1
  244. package/lib/typescript/src/screens/ProofRequest.d.ts.map +1 -1
  245. package/lib/typescript/src/screens/PushNotifications.d.ts +4 -0
  246. package/lib/typescript/src/screens/PushNotifications.d.ts.map +1 -0
  247. package/lib/typescript/src/screens/Settings.d.ts.map +1 -1
  248. package/lib/typescript/src/screens/Splash.d.ts +7 -4
  249. package/lib/typescript/src/screens/Splash.d.ts.map +1 -1
  250. package/lib/typescript/src/screens/ToggleBiometry.d.ts +4 -0
  251. package/lib/typescript/src/screens/ToggleBiometry.d.ts.map +1 -0
  252. package/lib/typescript/src/screens/TogglePushNotifications.d.ts +4 -0
  253. package/lib/typescript/src/screens/TogglePushNotifications.d.ts.map +1 -0
  254. package/lib/typescript/src/theme.d.ts +3 -1
  255. package/lib/typescript/src/theme.d.ts.map +1 -1
  256. package/lib/typescript/src/types/navigators.d.ts +11 -13
  257. package/lib/typescript/src/types/navigators.d.ts.map +1 -1
  258. package/lib/typescript/src/types/state.d.ts +1 -0
  259. package/lib/typescript/src/types/state.d.ts.map +1 -1
  260. package/lib/typescript/src/utils/{PINCreationValidation.d.ts → PINValidation.d.ts} +2 -2
  261. package/lib/typescript/src/utils/PINValidation.d.ts.map +1 -0
  262. package/lib/typescript/src/utils/agent.d.ts +1 -2
  263. package/lib/typescript/src/utils/agent.d.ts.map +1 -1
  264. package/lib/typescript/src/utils/helpers.d.ts.map +1 -1
  265. package/package.json +5 -5
  266. package/src/App.tsx +41 -40
  267. package/src/components/inputs/BiometryControl.tsx +176 -0
  268. package/src/components/misc/ConnectionAlert.tsx +3 -3
  269. package/src/components/misc/InfoBox.tsx +3 -1
  270. package/src/components/misc/{PINCreateHeader.tsx → PINHeader.tsx} +4 -4
  271. package/src/components/misc/PINValidationHelper.tsx +48 -0
  272. package/src/components/views/PushNotificationsContent.tsx +51 -0
  273. package/src/components/views/PushNotificationsDisabledContent.tsx +47 -0
  274. package/src/container-api.ts +27 -11
  275. package/src/container-impl.ts +31 -27
  276. package/src/contexts/activity.tsx +17 -42
  277. package/src/contexts/auth.tsx +18 -6
  278. package/src/contexts/navigation.tsx +19 -0
  279. package/src/contexts/reducers/store.ts +12 -0
  280. package/src/contexts/theme.tsx +51 -0
  281. package/src/hooks/deep-links.ts +2 -4
  282. package/src/hooks/{initialize-agent.ts → useBifoldAgentSetup.ts} +32 -54
  283. package/src/hooks/useOnboardingState.ts +10 -3
  284. package/src/hooks/usePINValidation.ts +98 -0
  285. package/src/index.ts +12 -14
  286. package/src/localization/en/index.ts +26 -20
  287. package/src/localization/fr/index.ts +32 -20
  288. package/src/localization/pt-br/index.ts +39 -33
  289. package/src/navigators/MainStack.tsx +29 -8
  290. package/src/navigators/OnboardingScreens.ts +11 -11
  291. package/src/navigators/OnboardingStack.tsx +26 -14
  292. package/src/navigators/RootStack.tsx +31 -25
  293. package/src/navigators/SettingStack.tsx +15 -16
  294. package/src/navigators/defaultStackOptions.tsx +13 -2
  295. package/src/onboarding.ts +12 -5
  296. package/src/screens/Biometry.tsx +57 -0
  297. package/src/screens/CredentialOffer.tsx +2 -2
  298. package/src/screens/Onboarding.tsx +2 -2
  299. package/src/screens/PINChange.tsx +250 -0
  300. package/src/screens/PINCreate.tsx +51 -267
  301. package/src/screens/Preface.tsx +2 -2
  302. package/src/screens/ProofRequest.tsx +140 -48
  303. package/src/screens/PushNotifications.tsx +59 -0
  304. package/src/screens/Settings.tsx +5 -10
  305. package/src/screens/Splash.tsx +10 -22
  306. package/src/screens/Terms.tsx +2 -2
  307. package/src/screens/ToggleBiometry.tsx +167 -0
  308. package/src/screens/TogglePushNotifications.tsx +118 -0
  309. package/src/theme.ts +5 -1
  310. package/src/types/navigators.ts +11 -12
  311. package/src/types/state.ts +1 -0
  312. package/src/utils/{PINCreationValidation.ts → PINValidation.ts} +1 -1
  313. package/src/utils/agent.ts +1 -2
  314. package/src/utils/helpers.ts +2 -0
  315. package/lib/commonjs/components/misc/ActivityLogLink.js +0 -44
  316. package/lib/commonjs/components/misc/ActivityLogLink.js.map +0 -1
  317. package/lib/commonjs/components/misc/PINCreateHeader.js.map +0 -1
  318. package/lib/commonjs/components/modals/NotificationModal.js +0 -121
  319. package/lib/commonjs/components/modals/NotificationModal.js.map +0 -1
  320. package/lib/commonjs/components/texts/Label.js +0 -57
  321. package/lib/commonjs/components/texts/Label.js.map +0 -1
  322. package/lib/commonjs/components/texts/Title.js +0 -29
  323. package/lib/commonjs/components/texts/Title.js.map +0 -1
  324. package/lib/commonjs/components/views/ModularView.js +0 -41
  325. package/lib/commonjs/components/views/ModularView.js.map +0 -1
  326. package/lib/commonjs/hooks/initialize-agent.js.map +0 -1
  327. package/lib/commonjs/screens/PushNotification.js.map +0 -1
  328. package/lib/commonjs/screens/UseBiometry.js +0 -315
  329. package/lib/commonjs/screens/UseBiometry.js.map +0 -1
  330. package/lib/commonjs/utils/PINCreationValidation.js.map +0 -1
  331. package/lib/module/components/misc/ActivityLogLink.js +0 -37
  332. package/lib/module/components/misc/ActivityLogLink.js.map +0 -1
  333. package/lib/module/components/misc/PINCreateHeader.js.map +0 -1
  334. package/lib/module/components/modals/NotificationModal.js +0 -112
  335. package/lib/module/components/modals/NotificationModal.js.map +0 -1
  336. package/lib/module/components/texts/Label.js +0 -50
  337. package/lib/module/components/texts/Label.js.map +0 -1
  338. package/lib/module/components/texts/Title.js +0 -22
  339. package/lib/module/components/texts/Title.js.map +0 -1
  340. package/lib/module/components/views/ModularView.js +0 -34
  341. package/lib/module/components/views/ModularView.js.map +0 -1
  342. package/lib/module/hooks/initialize-agent.js.map +0 -1
  343. package/lib/module/screens/PushNotification.js +0 -170
  344. package/lib/module/screens/PushNotification.js.map +0 -1
  345. package/lib/module/screens/UseBiometry.js +0 -306
  346. package/lib/module/screens/UseBiometry.js.map +0 -1
  347. package/lib/module/utils/PINCreationValidation.js.map +0 -1
  348. package/lib/typescript/src/components/misc/ActivityLogLink.d.ts +0 -4
  349. package/lib/typescript/src/components/misc/ActivityLogLink.d.ts.map +0 -1
  350. package/lib/typescript/src/components/misc/PINCreateHeader.d.ts +0 -6
  351. package/lib/typescript/src/components/misc/PINCreateHeader.d.ts.map +0 -1
  352. package/lib/typescript/src/components/modals/NotificationModal.d.ts +0 -17
  353. package/lib/typescript/src/components/modals/NotificationModal.d.ts.map +0 -1
  354. package/lib/typescript/src/components/texts/Label.d.ts +0 -9
  355. package/lib/typescript/src/components/texts/Label.d.ts.map +0 -1
  356. package/lib/typescript/src/components/texts/Title.d.ts +0 -8
  357. package/lib/typescript/src/components/texts/Title.d.ts.map +0 -1
  358. package/lib/typescript/src/components/views/ModularView.d.ts +0 -9
  359. package/lib/typescript/src/components/views/ModularView.d.ts.map +0 -1
  360. package/lib/typescript/src/hooks/initialize-agent.d.ts +0 -7
  361. package/lib/typescript/src/hooks/initialize-agent.d.ts.map +0 -1
  362. package/lib/typescript/src/screens/PushNotification.d.ts.map +0 -1
  363. package/lib/typescript/src/screens/UseBiometry.d.ts +0 -4
  364. package/lib/typescript/src/screens/UseBiometry.d.ts.map +0 -1
  365. package/lib/typescript/src/utils/PINCreationValidation.d.ts.map +0 -1
  366. package/src/components/misc/ActivityLogLink.tsx +0 -34
  367. package/src/components/modals/NotificationModal.tsx +0 -127
  368. package/src/components/texts/Label.tsx +0 -51
  369. package/src/components/texts/Title.tsx +0 -25
  370. package/src/components/views/ModularView.tsx +0 -35
  371. package/src/contexts/theme.ts +0 -9
  372. package/src/screens/PushNotification.tsx +0 -186
  373. package/src/screens/UseBiometry.tsx +0 -357
@@ -0,0 +1,250 @@
1
+ import { ParamListBase, useNavigation } from '@react-navigation/native'
2
+ import { StackNavigationProp, StackScreenProps } from '@react-navigation/stack'
3
+ import React, { useCallback, useMemo, useRef, useState } from 'react'
4
+ import { useTranslation } from 'react-i18next'
5
+ import {
6
+ AccessibilityInfo,
7
+ DeviceEventEmitter,
8
+ findNodeHandle,
9
+ Keyboard,
10
+ StyleSheet,
11
+ TextInput,
12
+ TouchableOpacity,
13
+ View,
14
+ } from 'react-native'
15
+
16
+ // eslint-disable-next-line import/no-named-as-default
17
+ import { ButtonType } from '../components/buttons/Button-api'
18
+ import PINInput from '../components/inputs/PINInput'
19
+ import PINValidationHelper from '../components/misc/PINValidationHelper'
20
+ import AlertModal from '../components/modals/AlertModal'
21
+ import KeyboardView from '../components/views/KeyboardView'
22
+ import { EventTypes, minPINLength } from '../constants'
23
+ import { TOKENS, useServices } from '../container-api'
24
+ import { useAnimatedComponents } from '../contexts/animated-components'
25
+ import { useAuth } from '../contexts/auth'
26
+ import { useStore } from '../contexts/store'
27
+ import { useTheme } from '../contexts/theme'
28
+ import { usePINValidation } from '../hooks/usePINValidation'
29
+ import { HistoryCardType, HistoryRecord } from '../modules/history/types'
30
+ import { BifoldError } from '../types/error'
31
+ import { OnboardingStackParams, Screens } from '../types/navigators'
32
+ import { useAppAgent } from '../utils/agent'
33
+ import { testIdWithKey } from '../utils/testable'
34
+
35
+ const PINChange: React.FC<StackScreenProps<ParamListBase, Screens.ChangePIN>> = () => {
36
+ const { agent } = useAppAgent()
37
+ const { checkWalletPIN, rekeyWallet } = useAuth()
38
+ const [PIN, setPIN] = useState('')
39
+ const [PINTwo, setPINTwo] = useState('')
40
+ const [PINOld, setPINOld] = useState('')
41
+ const [isLoading, setIsLoading] = useState(false)
42
+ const navigation = useNavigation<StackNavigationProp<OnboardingStackParams>>()
43
+ const [store] = useStore()
44
+ const { t } = useTranslation()
45
+ const { ColorPallet } = useTheme()
46
+ const { ButtonLoading } = useAnimatedComponents()
47
+ const PINTwoInputRef = useRef<TextInput>(null)
48
+ const createPINButtonRef = useRef<TouchableOpacity>(null)
49
+
50
+ const [
51
+ PINHeader,
52
+ Button,
53
+ inlineMessages,
54
+ logger,
55
+ historyManagerCurried,
56
+ historyEnabled,
57
+ historyEventsLogger,
58
+ ] = useServices([
59
+ TOKENS.COMPONENT_PIN_HEADER,
60
+ TOKENS.COMP_BUTTON,
61
+ TOKENS.INLINE_ERRORS,
62
+ TOKENS.UTIL_LOGGER,
63
+ TOKENS.FN_LOAD_HISTORY,
64
+ TOKENS.HISTORY_ENABLED,
65
+ TOKENS.HISTORY_EVENTS_LOGGER,
66
+ ])
67
+
68
+ const {
69
+ PINValidations,
70
+ validatePINEntry,
71
+ inlineMessageField1,
72
+ inlineMessageField2,
73
+ modalState,
74
+ setModalState,
75
+ clearModal,
76
+ PINSecurity,
77
+ } = usePINValidation(PIN, PINTwo)
78
+
79
+ const style = StyleSheet.create({
80
+ screenContainer: {
81
+ height: '100%',
82
+ backgroundColor: ColorPallet.brand.primaryBackground,
83
+ padding: 20,
84
+ justifyContent: 'space-between',
85
+ },
86
+
87
+ // below used as helpful labels for views, no properties needed atp
88
+ contentContainer: {},
89
+ controlsContainer: {},
90
+ })
91
+
92
+ const checkOldPIN = useCallback(
93
+ async (PIN: string): Promise<boolean> => {
94
+ const valid = await checkWalletPIN(PIN)
95
+ if (!valid) {
96
+ setModalState({
97
+ visible: true,
98
+ title: t('PINCreate.InvalidPIN'),
99
+ message: t(`PINCreate.Message.OldPINIncorrect`),
100
+ onModalDismiss: clearModal,
101
+ })
102
+ }
103
+ return valid
104
+ },
105
+ [checkWalletPIN, t, setModalState, clearModal]
106
+ )
107
+
108
+ const logHistoryRecord = useCallback(() => {
109
+ try {
110
+ if (!(agent && historyEnabled)) {
111
+ logger.trace(
112
+ `[${PINChange.name}]:[logHistoryRecord] Skipping history log, either history function disabled or agent undefined`
113
+ )
114
+ return
115
+ }
116
+ const historyManager = historyManagerCurried(agent)
117
+ /** Save history record for pin edited */
118
+ const recordData: HistoryRecord = {
119
+ type: HistoryCardType.PinChanged,
120
+ message: HistoryCardType.PinChanged,
121
+ createdAt: new Date(),
122
+ }
123
+
124
+ historyManager.saveHistory(recordData)
125
+ } catch (err: unknown) {
126
+ logger.error(`[${PINChange.name}]:[logHistoryRecord] Error saving history: ${err}`)
127
+ }
128
+ }, [agent, historyEnabled, logger, historyManagerCurried])
129
+
130
+ const handleChangePinTap = async () => {
131
+ try {
132
+ setIsLoading(true)
133
+ const valid = validatePINEntry(PIN, PINTwo)
134
+ if (valid) {
135
+ const oldPinValid = await checkOldPIN(PINOld)
136
+ if (oldPinValid) {
137
+ const success = await rekeyWallet(agent, PINOld, PIN, store.preferences.useBiometry)
138
+ if (success) {
139
+ if (historyEventsLogger.logPinChanged) {
140
+ logHistoryRecord()
141
+ }
142
+
143
+ setModalState({
144
+ visible: true,
145
+ title: t('PINChange.PinChangeSuccessTitle'),
146
+ message: t('PINChange.PinChangeSuccessMessage'),
147
+ onModalDismiss: () => {
148
+ navigation.navigate(Screens.Settings as never)
149
+ clearModal()
150
+ },
151
+ })
152
+ }
153
+ }
154
+ }
155
+ } catch (err: unknown) {
156
+ const error = new BifoldError(t('Error.Title1049'), t('Error.Message1049'), (err as Error)?.message ?? err, 1049)
157
+
158
+ DeviceEventEmitter.emit(EventTypes.ERROR_ADDED, error)
159
+ } finally {
160
+ setIsLoading(false)
161
+ }
162
+ }
163
+
164
+ const isContinueDisabled = useMemo((): boolean => {
165
+ if (inlineMessages || isLoading) {
166
+ return false
167
+ }
168
+
169
+ return PIN === '' || PINTwo === '' || PINOld === '' || PIN.length < minPINLength || PINTwo.length < minPINLength
170
+ }, [inlineMessages, isLoading, PIN, PINTwo, PINOld])
171
+
172
+
173
+ return (
174
+ <KeyboardView>
175
+ <View style={style.screenContainer}>
176
+ <View style={style.contentContainer}>
177
+ <PINHeader updatePin />
178
+ <PINInput
179
+ label={t('PINChange.EnterOldPINTitle')}
180
+ testID={testIdWithKey('EnterOldPIN')}
181
+ accessibilityLabel={t('PINChange.EnterOldPIN')}
182
+ onPINChanged={(p: string) => {
183
+ setPINOld(p)
184
+ }}
185
+ />
186
+ <PINInput
187
+ label={t('PINChange.EnterPINTitle')}
188
+ onPINChanged={(p: string) => {
189
+ setPIN(p)
190
+ if (p.length === minPINLength && PINTwoInputRef?.current) {
191
+ PINTwoInputRef.current.focus()
192
+ const reactTag = findNodeHandle(PINTwoInputRef.current)
193
+ if (reactTag) {
194
+ AccessibilityInfo.setAccessibilityFocus(reactTag)
195
+ }
196
+ }
197
+ }}
198
+ testID={testIdWithKey('EnterPIN')}
199
+ accessibilityLabel={t('PINCreate.EnterPIN')}
200
+ autoFocus={false}
201
+ inlineMessage={inlineMessageField1}
202
+ />
203
+ <PINInput
204
+ label={t('PINChange.ReenterPIN')}
205
+ onPINChanged={(p: string) => {
206
+ setPINTwo(p)
207
+ if (p.length === minPINLength) {
208
+ Keyboard.dismiss()
209
+ const reactTag = createPINButtonRef?.current && findNodeHandle(createPINButtonRef.current)
210
+ if (reactTag) {
211
+ AccessibilityInfo.setAccessibilityFocus(reactTag)
212
+ }
213
+ }
214
+ }}
215
+ testID={testIdWithKey('ReenterPIN')}
216
+ accessibilityLabel={t('PINChange.ReenterPIN')}
217
+ autoFocus={false}
218
+ ref={PINTwoInputRef}
219
+ inlineMessage={inlineMessageField2}
220
+ />
221
+ {PINSecurity.displayHelper && (
222
+ <PINValidationHelper validations={PINValidations} />
223
+ )}
224
+ {modalState.visible && (
225
+ <AlertModal
226
+ title={modalState.title}
227
+ message={modalState.message}
228
+ submit={modalState.onModalDismiss}
229
+ />
230
+ )}
231
+ </View>
232
+ <View style={style.controlsContainer}>
233
+ <Button
234
+ title={t('PINChange.ChangePIN')}
235
+ testID={testIdWithKey('ChangePIN')}
236
+ accessibilityLabel={t('PINChange.ChangePIN')}
237
+ buttonType={ButtonType.Primary}
238
+ disabled={isContinueDisabled}
239
+ onPress={handleChangePinTap}
240
+ ref={createPINButtonRef}
241
+ >
242
+ {isLoading ? <ButtonLoading /> : null}
243
+ </Button>
244
+ </View>
245
+ </View>
246
+ </KeyboardView>
247
+ )
248
+ }
249
+
250
+ export default PINChange
@@ -1,22 +1,22 @@
1
- import { ParamListBase, useNavigation } from '@react-navigation/native'
2
- import { StackNavigationProp, StackScreenProps } from '@react-navigation/stack'
3
- import React, { useState, useRef, useEffect, useCallback } from 'react'
1
+ import { ParamListBase } from '@react-navigation/native'
2
+ import { StackScreenProps } from '@react-navigation/stack'
3
+ import React, { useCallback, useMemo, useRef, useState } from 'react'
4
4
  import { useTranslation } from 'react-i18next'
5
5
  import {
6
6
  AccessibilityInfo,
7
+ DeviceEventEmitter,
7
8
  Keyboard,
8
9
  StyleSheet,
9
- View,
10
10
  TextInput,
11
11
  TouchableOpacity,
12
+ View,
12
13
  findNodeHandle,
13
- DeviceEventEmitter,
14
14
  } from 'react-native'
15
- import Icon from 'react-native-vector-icons/MaterialIcons'
16
15
 
17
16
  // eslint-disable-next-line import/no-named-as-default
18
17
  import { ButtonType } from '../components/buttons/Button-api'
19
18
  import PINInput from '../components/inputs/PINInput'
19
+ import PINValidationHelper from '../components/misc/PINValidationHelper'
20
20
  import AlertModal from '../components/modals/AlertModal'
21
21
  import KeyboardView from '../components/views/KeyboardView'
22
22
  import { EventTypes, minPINLength } from '../constants'
@@ -26,81 +26,46 @@ import { useAuth } from '../contexts/auth'
26
26
  import { DispatchAction } from '../contexts/reducers/store'
27
27
  import { useStore } from '../contexts/store'
28
28
  import { useTheme } from '../contexts/theme'
29
+ import { usePINValidation } from '../hooks/usePINValidation'
29
30
  import { BifoldError } from '../types/error'
30
- import { AuthenticateStackParams, Screens } from '../types/navigators'
31
- import { PINCreationValidations, PINValidationsType } from '../utils/PINCreationValidation'
31
+ import { Screens } from '../types/navigators'
32
32
  import { testIdWithKey } from '../utils/testable'
33
- import { InlineErrorType, InlineMessageProps } from '../components/inputs/InlineErrorText'
34
- import { HistoryCardType, HistoryRecord } from '../modules/history/types'
35
- import { useAppAgent } from '../utils/agent'
36
- import { ThemedText } from '../components/texts/ThemedText'
37
33
 
38
34
  interface PINCreateProps extends StackScreenProps<ParamListBase, Screens.CreatePIN> {
39
35
  setAuthenticated: (status: boolean) => void
40
36
  explainedStatus: boolean
41
37
  }
42
38
 
43
- interface ModalState {
44
- visible: boolean
45
- title: string
46
- message: string
47
- onModalDismiss?: () => void
48
- }
49
-
50
- const PINCreate: React.FC<PINCreateProps> = ({ setAuthenticated, explainedStatus, route }) => {
51
- const updatePin = (route.params as any)?.updatePin
52
- const { agent } = useAppAgent()
53
- const { setPIN: setWalletPIN, checkWalletPIN, rekeyWallet } = useAuth()
39
+ const PINCreate: React.FC<PINCreateProps> = ({ setAuthenticated, explainedStatus }) => {
40
+ const { setPIN: setWalletPIN } = useAuth()
54
41
  const [PIN, setPIN] = useState('')
55
42
  const [PINTwo, setPINTwo] = useState('')
56
- const [PINOld, setPINOld] = useState('')
57
- const [continueEnabled, setContinueEnabled] = useState(true)
58
43
  const [isLoading, setIsLoading] = useState(false)
59
- const [modalState, setModalState] = useState<ModalState>({
60
- visible: false,
61
- title: '',
62
- message: '',
63
- })
64
- const iconSize = 24
65
- const navigation = useNavigation<StackNavigationProp<AuthenticateStackParams>>()
66
- const [store, dispatch] = useStore()
44
+ const [, dispatch] = useStore()
67
45
  const { t } = useTranslation()
68
- const [inlineMessageField1, setInlineMessageField1] = useState<InlineMessageProps>()
69
- const [inlineMessageField2, setInlineMessageField2] = useState<InlineMessageProps>()
70
46
 
71
47
  const { ColorPallet } = useTheme()
72
48
  const { ButtonLoading } = useAnimatedComponents()
73
49
  const PINTwoInputRef = useRef<TextInput>(null)
74
50
  const createPINButtonRef = useRef<TouchableOpacity>(null)
75
- const actionButtonLabel = updatePin ? t('PINCreate.ChangePIN') : t('PINCreate.CreatePIN')
76
- const actionButtonTestId = updatePin ? testIdWithKey('ChangePIN') : testIdWithKey('CreatePIN')
77
- const [
78
- PINExplainer,
79
- PINCreateHeader,
80
- { PINSecurity, showPINExplainer },
81
- Button,
82
- inlineMessages,
83
- logger,
84
- historyManagerCurried,
85
- historyEnabled,
86
- historyEventsLogger,
87
- ] = useServices([
51
+ const [PINExplainer, PINHeader, { showPINExplainer }, Button, inlineMessages] = useServices([
88
52
  TOKENS.SCREEN_PIN_EXPLAINER,
89
- TOKENS.COMPONENT_PIN_CREATE_HEADER,
53
+ TOKENS.COMPONENT_PIN_HEADER,
90
54
  TOKENS.CONFIG,
91
55
  TOKENS.COMP_BUTTON,
92
56
  TOKENS.INLINE_ERRORS,
93
- TOKENS.UTIL_LOGGER,
94
- TOKENS.FN_LOAD_HISTORY,
95
- TOKENS.HISTORY_ENABLED,
96
- TOKENS.HISTORY_EVENTS_LOGGER,
97
57
  ])
98
58
 
99
59
  const [explained, setExplained] = useState(explainedStatus || showPINExplainer === false)
100
60
 
101
- const [PINOneValidations, setPINOneValidations] = useState<PINValidationsType[]>(
102
- PINCreationValidations(PIN, PINSecurity.rules)
103
- )
61
+ const {
62
+ PINValidations,
63
+ validatePINEntry,
64
+ inlineMessageField1,
65
+ inlineMessageField2,
66
+ modalState,
67
+ PINSecurity
68
+ } = usePINValidation(PIN, PINTwo)
104
69
 
105
70
  const style = StyleSheet.create({
106
71
  screenContainer: {
@@ -118,11 +83,9 @@ const PINCreate: React.FC<PINCreateProps> = ({ setAuthenticated, explainedStatus
118
83
  const passcodeCreate = useCallback(
119
84
  async (PIN: string) => {
120
85
  try {
121
- setContinueEnabled(false)
122
86
  await setWalletPIN(PIN)
123
- // This will trigger initAgent
124
87
  setAuthenticated(true)
125
-
88
+ // this dispatch finishes this step of onboarding and will cause a navigation
126
89
  dispatch({
127
90
  type: DispatchAction.DID_CREATE_PIN,
128
91
  })
@@ -140,184 +103,39 @@ const PINCreate: React.FC<PINCreateProps> = ({ setAuthenticated, explainedStatus
140
103
  [setWalletPIN, setAuthenticated, dispatch, t]
141
104
  )
142
105
 
143
- const displayModalMessage = (title: string, message: string) => {
144
- setModalState({
145
- visible: true,
146
- title: title,
147
- message: message,
148
- })
149
- }
150
-
151
- const attentionMessage = useCallback(
152
- (title: string, message: string, pinOne: boolean) => {
153
- if (inlineMessages.enabled) {
154
- const config = {
155
- message: message,
156
- inlineType: InlineErrorType.error,
157
- config: inlineMessages,
158
- }
159
- if (pinOne) {
160
- setInlineMessageField1(config)
161
- } else {
162
- setInlineMessageField2(config)
163
- }
164
- } else {
165
- displayModalMessage(title, message)
166
- }
167
- },
168
- [inlineMessages]
169
- )
170
-
171
- const validatePINEntry = useCallback(
172
- (PINOne: string, PINTwo: string): boolean => {
173
- for (const validation of PINOneValidations) {
174
- if (validation.isInvalid) {
175
- attentionMessage(
176
- t('PINCreate.InvalidPIN'),
177
- t(`PINCreate.Message.${validation.errorName}`, validation?.errorTextAddition),
178
- true
179
- )
180
- return false
181
- }
182
- }
183
- if (PINOne !== PINTwo) {
184
- attentionMessage(t('PINCreate.InvalidPIN'), t('PINCreate.PINsDoNotMatch'), false)
185
- return false
186
- }
187
- return true
188
- },
189
- [PINOneValidations, t, attentionMessage]
190
- )
191
-
192
- const checkOldPIN = useCallback(
193
- async (PIN: string): Promise<boolean> => {
194
- const valid = await checkWalletPIN(PIN)
195
- if (!valid) {
196
- displayModalMessage(t('PINCreate.InvalidPIN'), t(`PINCreate.Message.OldPINIncorrect`))
197
- }
198
- return valid
199
- },
200
- [checkWalletPIN, t]
201
- )
202
-
203
- const confirmEntry = useCallback(
204
- async (PINOne: string, PINTwo: string) => {
205
- if (!validatePINEntry(PINOne, PINTwo)) {
206
- return
207
- }
208
-
209
- await passcodeCreate(PINOne)
210
- },
211
- [validatePINEntry, passcodeCreate]
212
- )
213
-
214
- const logHistoryRecord = useCallback(() => {
215
- try {
216
- if (!(agent && historyEnabled)) {
217
- logger.trace(
218
- `[${PINCreate.name}]:[logHistoryRecord] Skipping history log, either history function disabled or agent undefined!`
219
- )
220
- return
221
- }
222
- const historyManager = historyManagerCurried(agent)
223
- /** Save history record for pin edited */
224
- const recordData: HistoryRecord = {
225
- type: HistoryCardType.PinChanged,
226
- message: HistoryCardType.PinChanged,
227
- createdAt: new Date(),
228
- }
229
-
230
- historyManager.saveHistory(recordData)
231
- } catch (err: unknown) {
232
- logger.error(`[${PINCreate.name}]:[logHistoryRecord] Error saving history: ${err}`)
233
- }
234
- }, [agent, historyEnabled, logger, historyManagerCurried])
235
-
236
- const handleCreatePinTap = async () => {
106
+ const handleCreatePinTap = useCallback(async () => {
237
107
  setIsLoading(true)
238
- if (updatePin) {
239
- const valid = validatePINEntry(PIN, PINTwo)
240
- if (valid) {
241
- setContinueEnabled(false)
242
- const oldPinValid = await checkOldPIN(PINOld)
243
- if (oldPinValid) {
244
- const success = await rekeyWallet(PINOld, PIN, store.preferences.useBiometry)
245
- if (success) {
246
- if (historyEventsLogger.logPinChanged) {
247
- logHistoryRecord()
248
- }
249
-
250
- setModalState({
251
- visible: true,
252
- title: t('PINCreate.PinChangeSuccessTitle'),
253
- message: t('PINCreate.PinChangeSuccessMessage'),
254
- onModalDismiss: () => {
255
- navigation.navigate(Screens.Settings as never)
256
- },
257
- })
258
- }
259
- }
260
-
261
- setContinueEnabled(true)
262
- }
263
- } else {
264
- await confirmEntry(PIN, PINTwo)
108
+ if (validatePINEntry(PIN, PINTwo)) {
109
+ await passcodeCreate(PIN)
265
110
  }
266
111
  setIsLoading(false)
267
- }
112
+ }, [PIN, PINTwo, passcodeCreate, validatePINEntry])
268
113
 
269
- const isContinueDisabled = (): boolean => {
270
- if (inlineMessages) {
114
+ const isContinueDisabled = useMemo((): boolean => {
115
+ if (inlineMessages.enabled) {
271
116
  return false
272
117
  }
273
- return !continueEnabled || PIN.length < minPINLength || PINTwo.length < minPINLength
274
- }
118
+ return isLoading || PIN.length < minPINLength || PINTwo.length < minPINLength
119
+ }, [isLoading, PIN, PINTwo, inlineMessages])
275
120
 
276
- useEffect(() => {
277
- if (updatePin) {
278
- setContinueEnabled(PIN !== '' && PINTwo !== '' && PINOld !== '')
279
- }
280
- }, [updatePin, PIN, PINTwo, PINOld])
281
-
282
- const continueCreatePIN = () => {
121
+ const continueCreatePIN = useCallback(() => {
283
122
  setExplained(true)
284
- }
285
-
286
- useEffect(() => {
287
- setInlineMessageField1(undefined)
288
- setInlineMessageField2(undefined)
289
- }, [PIN, PINTwo])
123
+ }, [])
290
124
 
291
125
  return explained ? (
292
126
  <KeyboardView>
293
127
  <View style={style.screenContainer}>
294
128
  <View style={style.contentContainer}>
295
- <PINCreateHeader updatePin={updatePin} />
296
- {updatePin && (
297
- <PINInput
298
- label={t('PINCreate.EnterOldPINTitle')}
299
- testID={testIdWithKey('EnterOldPIN')}
300
- accessibilityLabel={t('PINCreate.EnterOldPIN')}
301
- onPINChanged={(p: string) => {
302
- setPINOld(p)
303
- }}
304
- />
305
- )}
129
+ <PINHeader />
306
130
  <PINInput
307
- label={t('PINCreate.EnterPINTitle', { new: updatePin ? t('PINCreate.NewPIN') + ' ' : '' })}
131
+ label={t('PINCreate.EnterPINTitle')}
308
132
  onPINChanged={(p: string) => {
309
133
  setPIN(p)
310
- setPINOneValidations(PINCreationValidations(p, PINSecurity.rules))
311
-
312
- if (p.length === minPINLength) {
313
- if (PINTwoInputRef?.current) {
314
- PINTwoInputRef.current.focus()
315
- // NOTE:(jl) `findNodeHandle` will be deprecated in React 18.
316
- // https://reactnative.dev/docs/new-architecture-library-intro#preparing-your-javascript-codebase-for-the-new-react-native-renderer-fabric
317
- const reactTag = findNodeHandle(PINTwoInputRef.current)
318
- if (reactTag) {
319
- AccessibilityInfo.setAccessibilityFocus(reactTag)
320
- }
134
+ if (p.length === minPINLength && PINTwoInputRef?.current) {
135
+ PINTwoInputRef.current.focus()
136
+ const reactTag = findNodeHandle(PINTwoInputRef.current)
137
+ if (reactTag) {
138
+ AccessibilityInfo.setAccessibilityFocus(reactTag)
321
139
  }
322
140
  }
323
141
  }}
@@ -327,79 +145,45 @@ const PINCreate: React.FC<PINCreateProps> = ({ setAuthenticated, explainedStatus
327
145
  inlineMessage={inlineMessageField1}
328
146
  />
329
147
  <PINInput
330
- label={t('PINCreate.ReenterPIN', { new: updatePin ? t('PINCreate.NewPIN') + ' ' : '' })}
148
+ label={t('PINCreate.ReenterPIN')}
331
149
  onPINChanged={(p: string) => {
332
150
  setPINTwo(p)
333
151
  if (p.length === minPINLength) {
334
152
  Keyboard.dismiss()
335
- if (createPINButtonRef?.current) {
336
- // NOTE:(jl) `findNodeHandle` will be deprecated in React 18.
337
- // https://reactnative.dev/docs/new-architecture-library-intro#preparing-your-javascript-codebase-for-the-new-react-native-renderer-fabric
338
- const reactTag = findNodeHandle(createPINButtonRef.current)
339
- if (reactTag) {
340
- AccessibilityInfo.setAccessibilityFocus(reactTag)
341
- }
153
+ const reactTag = createPINButtonRef?.current && findNodeHandle(createPINButtonRef.current)
154
+ if (reactTag) {
155
+ AccessibilityInfo.setAccessibilityFocus(reactTag)
342
156
  }
343
157
  }
344
158
  }}
345
159
  testID={testIdWithKey('ReenterPIN')}
346
- accessibilityLabel={t('PINCreate.ReenterPIN', { new: updatePin ? t('PINCreate.NewPIN') + ' ' : '' })}
160
+ accessibilityLabel={t('PINCreate.ReenterPIN')}
347
161
  autoFocus={false}
348
162
  ref={PINTwoInputRef}
349
163
  inlineMessage={inlineMessageField2}
350
164
  />
351
165
  {PINSecurity.displayHelper && (
352
- <View style={{ marginBottom: 16 }}>
353
- {PINOneValidations.map((validation, index) => {
354
- return (
355
- <View style={{ flexDirection: 'row' }} key={index}>
356
- {validation.isInvalid ? (
357
- <Icon
358
- accessibilityLabel={t('PINCreate.Helper.ClearIcon')}
359
- name="clear"
360
- size={iconSize}
361
- color={ColorPallet.notification.errorIcon}
362
- />
363
- ) : (
364
- <Icon
365
- accessibilityLabel={t('PINCreate.Helper.CheckIcon')}
366
- name="check"
367
- size={iconSize}
368
- color={ColorPallet.notification.successIcon}
369
- />
370
- )}
371
- <ThemedText style={{ paddingLeft: 4 }}>
372
- {t(`PINCreate.Helper.${validation.errorName}`, validation?.errorTextAddition)}
373
- </ThemedText>
374
- </View>
375
- )
376
- })}
377
- </View>
166
+ <PINValidationHelper validations={PINValidations} />
378
167
  )}
379
168
  {modalState.visible && (
380
169
  <AlertModal
381
170
  title={modalState.title}
382
171
  message={modalState.message}
383
- submit={() => {
384
- if (modalState.onModalDismiss) {
385
- modalState.onModalDismiss()
386
- }
387
- setModalState({ ...modalState, visible: false, onModalDismiss: undefined })
388
- }}
172
+ submit={modalState.onModalDismiss}
389
173
  />
390
174
  )}
391
175
  </View>
392
176
  <View style={style.controlsContainer}>
393
177
  <Button
394
- title={actionButtonLabel}
395
- testID={actionButtonTestId}
396
- accessibilityLabel={actionButtonLabel}
178
+ title={t('PINCreate.CreatePIN')}
179
+ testID={testIdWithKey('CreatePIN')}
180
+ accessibilityLabel={t('PINCreate.CreatePIN')}
397
181
  buttonType={ButtonType.Primary}
398
- disabled={isContinueDisabled()}
182
+ disabled={isContinueDisabled}
399
183
  onPress={handleCreatePinTap}
400
184
  ref={createPINButtonRef}
401
185
  >
402
- {!continueEnabled && isLoading ? <ButtonLoading /> : null}
186
+ {isLoading ? <ButtonLoading /> : null}
403
187
  </Button>
404
188
  </View>
405
189
  </View>