@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.
- package/lib/commonjs/App.js +26 -22
- package/lib/commonjs/App.js.map +1 -1
- package/lib/commonjs/components/inputs/BiometryControl.js +176 -0
- package/lib/commonjs/components/inputs/BiometryControl.js.map +1 -0
- package/lib/commonjs/components/misc/ConnectionAlert.js +2 -2
- package/lib/commonjs/components/misc/ConnectionAlert.js.map +1 -1
- package/lib/commonjs/components/misc/InfoBox.js +3 -2
- package/lib/commonjs/components/misc/InfoBox.js.map +1 -1
- package/lib/commonjs/components/misc/{PINCreateHeader.js → PINHeader.js} +4 -4
- package/lib/commonjs/components/misc/PINHeader.js.map +1 -0
- package/lib/commonjs/components/misc/PINValidationHelper.js +50 -0
- package/lib/commonjs/components/misc/PINValidationHelper.js.map +1 -0
- package/lib/commonjs/components/views/PushNotificationsContent.js +52 -0
- package/lib/commonjs/components/views/PushNotificationsContent.js.map +1 -0
- package/lib/commonjs/components/views/PushNotificationsDisabledContent.js +47 -0
- package/lib/commonjs/components/views/PushNotificationsDisabledContent.js.map +1 -0
- package/lib/commonjs/container-api.js +8 -3
- package/lib/commonjs/container-api.js.map +1 -1
- package/lib/commonjs/container-impl.js +25 -21
- package/lib/commonjs/container-impl.js.map +1 -1
- package/lib/commonjs/contexts/activity.js +17 -41
- package/lib/commonjs/contexts/activity.js.map +1 -1
- package/lib/commonjs/contexts/auth.js +16 -6
- package/lib/commonjs/contexts/auth.js.map +1 -1
- package/lib/commonjs/contexts/navigation.js +24 -0
- package/lib/commonjs/contexts/navigation.js.map +1 -0
- package/lib/commonjs/contexts/reducers/store.js +14 -0
- package/lib/commonjs/contexts/reducers/store.js.map +1 -1
- package/lib/commonjs/contexts/theme.js +36 -3
- package/lib/commonjs/contexts/theme.js.map +1 -1
- package/lib/commonjs/hooks/deep-links.js +2 -4
- package/lib/commonjs/hooks/deep-links.js.map +1 -1
- package/lib/commonjs/hooks/{initialize-agent.js → useBifoldAgentSetup.js} +24 -44
- package/lib/commonjs/hooks/useBifoldAgentSetup.js.map +1 -0
- package/lib/commonjs/hooks/useOnboardingState.js +3 -3
- package/lib/commonjs/hooks/useOnboardingState.js.map +1 -1
- package/lib/commonjs/hooks/usePINValidation.js +82 -0
- package/lib/commonjs/hooks/usePINValidation.js.map +1 -0
- package/lib/commonjs/index.js +34 -33
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/localization/en/index.js +31 -25
- package/lib/commonjs/localization/en/index.js.map +1 -1
- package/lib/commonjs/localization/fr/index.js +18 -6
- package/lib/commonjs/localization/fr/index.js.map +1 -1
- package/lib/commonjs/localization/pt-br/index.js +43 -37
- package/lib/commonjs/localization/pt-br/index.js.map +1 -1
- package/lib/commonjs/navigators/MainStack.js +31 -8
- package/lib/commonjs/navigators/MainStack.js.map +1 -1
- package/lib/commonjs/navigators/OnboardingScreens.js +8 -8
- package/lib/commonjs/navigators/OnboardingScreens.js.map +1 -1
- package/lib/commonjs/navigators/OnboardingStack.js +20 -12
- package/lib/commonjs/navigators/OnboardingStack.js.map +1 -1
- package/lib/commonjs/navigators/RootStack.js +27 -30
- package/lib/commonjs/navigators/RootStack.js.map +1 -1
- package/lib/commonjs/navigators/SettingStack.js +14 -15
- package/lib/commonjs/navigators/SettingStack.js.map +1 -1
- package/lib/commonjs/navigators/defaultStackOptions.js +13 -2
- package/lib/commonjs/navigators/defaultStackOptions.js.map +1 -1
- package/lib/commonjs/onboarding.js +12 -5
- package/lib/commonjs/onboarding.js.map +1 -1
- package/lib/commonjs/screens/Biometry.js +62 -0
- package/lib/commonjs/screens/Biometry.js.map +1 -0
- package/lib/commonjs/screens/CredentialOffer.js +2 -2
- package/lib/commonjs/screens/CredentialOffer.js.map +1 -1
- package/lib/commonjs/screens/Onboarding.js.map +1 -1
- package/lib/commonjs/screens/PINChange.js +212 -0
- package/lib/commonjs/screens/PINChange.js.map +1 -0
- package/lib/commonjs/screens/PINCreate.js +47 -224
- package/lib/commonjs/screens/PINCreate.js.map +1 -1
- package/lib/commonjs/screens/Preface.js.map +1 -1
- package/lib/commonjs/screens/ProofRequest.js +112 -33
- package/lib/commonjs/screens/ProofRequest.js.map +1 -1
- package/lib/commonjs/screens/PushNotifications.js +71 -0
- package/lib/commonjs/screens/PushNotifications.js.map +1 -0
- package/lib/commonjs/screens/Settings.js +8 -24
- package/lib/commonjs/screens/Settings.js.map +1 -1
- package/lib/commonjs/screens/Splash.js +7 -23
- package/lib/commonjs/screens/Splash.js.map +1 -1
- package/lib/commonjs/screens/Terms.js.map +1 -1
- package/lib/commonjs/screens/ToggleBiometry.js +135 -0
- package/lib/commonjs/screens/ToggleBiometry.js.map +1 -0
- package/lib/commonjs/screens/{PushNotification.js → TogglePushNotifications.js} +41 -99
- package/lib/commonjs/screens/TogglePushNotifications.js.map +1 -0
- package/lib/commonjs/theme.js +4 -2
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/commonjs/types/navigators.js +5 -2
- package/lib/commonjs/types/navigators.js.map +1 -1
- package/lib/commonjs/utils/{PINCreationValidation.js → PINValidation.js} +4 -4
- package/lib/commonjs/utils/PINValidation.js.map +1 -0
- package/lib/commonjs/utils/agent.js.map +1 -1
- package/lib/commonjs/utils/helpers.js +2 -0
- package/lib/commonjs/utils/helpers.js.map +1 -1
- package/lib/module/App.js +24 -20
- package/lib/module/App.js.map +1 -1
- package/lib/module/components/inputs/BiometryControl.js +167 -0
- package/lib/module/components/inputs/BiometryControl.js.map +1 -0
- package/lib/module/components/misc/ConnectionAlert.js +2 -2
- package/lib/module/components/misc/ConnectionAlert.js.map +1 -1
- package/lib/module/components/misc/InfoBox.js +3 -2
- package/lib/module/components/misc/InfoBox.js.map +1 -1
- package/lib/module/components/misc/{PINCreateHeader.js → PINHeader.js} +4 -4
- package/lib/module/components/misc/PINHeader.js.map +1 -0
- package/lib/module/components/misc/PINValidationHelper.js +43 -0
- package/lib/module/components/misc/PINValidationHelper.js.map +1 -0
- package/lib/module/components/views/PushNotificationsContent.js +45 -0
- package/lib/module/components/views/PushNotificationsContent.js.map +1 -0
- package/lib/module/components/views/PushNotificationsDisabledContent.js +40 -0
- package/lib/module/components/views/PushNotificationsDisabledContent.js.map +1 -0
- package/lib/module/container-api.js +7 -2
- package/lib/module/container-api.js.map +1 -1
- package/lib/module/container-impl.js +25 -21
- package/lib/module/container-impl.js.map +1 -1
- package/lib/module/contexts/activity.js +17 -41
- package/lib/module/contexts/activity.js.map +1 -1
- package/lib/module/contexts/auth.js +16 -6
- package/lib/module/contexts/auth.js.map +1 -1
- package/lib/module/contexts/navigation.js +17 -0
- package/lib/module/contexts/navigation.js.map +1 -0
- package/lib/module/contexts/reducers/store.js +14 -0
- package/lib/module/contexts/reducers/store.js.map +1 -1
- package/lib/module/contexts/theme.js +36 -4
- package/lib/module/contexts/theme.js.map +1 -1
- package/lib/module/hooks/deep-links.js +2 -4
- package/lib/module/hooks/deep-links.js.map +1 -1
- package/lib/module/hooks/{initialize-agent.js → useBifoldAgentSetup.js} +25 -45
- package/lib/module/hooks/useBifoldAgentSetup.js.map +1 -0
- package/lib/module/hooks/useOnboardingState.js +3 -3
- package/lib/module/hooks/useOnboardingState.js.map +1 -1
- package/lib/module/hooks/usePINValidation.js +75 -0
- package/lib/module/hooks/usePINValidation.js.map +1 -0
- package/lib/module/index.js +6 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/localization/en/index.js +31 -25
- package/lib/module/localization/en/index.js.map +1 -1
- package/lib/module/localization/fr/index.js +18 -6
- package/lib/module/localization/fr/index.js.map +1 -1
- package/lib/module/localization/pt-br/index.js +43 -37
- package/lib/module/localization/pt-br/index.js.map +1 -1
- package/lib/module/navigators/MainStack.js +32 -9
- package/lib/module/navigators/MainStack.js.map +1 -1
- package/lib/module/navigators/OnboardingScreens.js +8 -8
- package/lib/module/navigators/OnboardingScreens.js.map +1 -1
- package/lib/module/navigators/OnboardingStack.js +21 -12
- package/lib/module/navigators/OnboardingStack.js.map +1 -1
- package/lib/module/navigators/RootStack.js +26 -29
- package/lib/module/navigators/RootStack.js.map +1 -1
- package/lib/module/navigators/SettingStack.js +14 -15
- package/lib/module/navigators/SettingStack.js.map +1 -1
- package/lib/module/navigators/defaultStackOptions.js +13 -2
- package/lib/module/navigators/defaultStackOptions.js.map +1 -1
- package/lib/module/onboarding.js +10 -4
- package/lib/module/onboarding.js.map +1 -1
- package/lib/module/screens/Biometry.js +53 -0
- package/lib/module/screens/Biometry.js.map +1 -0
- package/lib/module/screens/CredentialOffer.js +2 -2
- package/lib/module/screens/CredentialOffer.js.map +1 -1
- package/lib/module/screens/Onboarding.js.map +1 -1
- package/lib/module/screens/PINChange.js +203 -0
- package/lib/module/screens/PINChange.js.map +1 -0
- package/lib/module/screens/PINCreate.js +49 -226
- package/lib/module/screens/PINCreate.js.map +1 -1
- package/lib/module/screens/Preface.js.map +1 -1
- package/lib/module/screens/ProofRequest.js +113 -34
- package/lib/module/screens/ProofRequest.js.map +1 -1
- package/lib/module/screens/PushNotifications.js +63 -0
- package/lib/module/screens/PushNotifications.js.map +1 -0
- package/lib/module/screens/Settings.js +9 -25
- package/lib/module/screens/Settings.js.map +1 -1
- package/lib/module/screens/Splash.js +7 -23
- package/lib/module/screens/Splash.js.map +1 -1
- package/lib/module/screens/Terms.js.map +1 -1
- package/lib/module/screens/ToggleBiometry.js +126 -0
- package/lib/module/screens/ToggleBiometry.js.map +1 -0
- package/lib/module/screens/TogglePushNotifications.js +112 -0
- package/lib/module/screens/TogglePushNotifications.js.map +1 -0
- package/lib/module/theme.js +3 -1
- package/lib/module/theme.js.map +1 -1
- package/lib/module/types/navigators.js +5 -2
- package/lib/module/types/navigators.js.map +1 -1
- package/lib/module/utils/{PINCreationValidation.js → PINValidation.js} +2 -2
- package/lib/module/utils/PINValidation.js.map +1 -0
- package/lib/module/utils/agent.js.map +1 -1
- package/lib/module/utils/helpers.js +2 -0
- package/lib/module/utils/helpers.js.map +1 -1
- package/lib/typescript/src/App.d.ts +3 -3
- package/lib/typescript/src/App.d.ts.map +1 -1
- package/lib/typescript/src/components/inputs/BiometryControl.d.ts +9 -0
- package/lib/typescript/src/components/inputs/BiometryControl.d.ts.map +1 -0
- package/lib/typescript/src/components/misc/ConnectionAlert.d.ts +1 -1
- package/lib/typescript/src/components/misc/ConnectionAlert.d.ts.map +1 -1
- package/lib/typescript/src/components/misc/InfoBox.d.ts +1 -0
- package/lib/typescript/src/components/misc/InfoBox.d.ts.map +1 -1
- package/lib/typescript/src/components/misc/PINHeader.d.ts +6 -0
- package/lib/typescript/src/components/misc/PINHeader.d.ts.map +1 -0
- package/lib/typescript/src/components/misc/PINValidationHelper.d.ts +8 -0
- package/lib/typescript/src/components/misc/PINValidationHelper.d.ts.map +1 -0
- package/lib/typescript/src/components/views/PushNotificationsContent.d.ts +4 -0
- package/lib/typescript/src/components/views/PushNotificationsContent.d.ts.map +1 -0
- package/lib/typescript/src/components/views/PushNotificationsDisabledContent.d.ts +4 -0
- package/lib/typescript/src/components/views/PushNotificationsDisabledContent.d.ts.map +1 -0
- package/lib/typescript/src/container-api.d.ts +24 -13
- package/lib/typescript/src/container-api.d.ts.map +1 -1
- package/lib/typescript/src/container-impl.d.ts +4 -2
- package/lib/typescript/src/container-impl.d.ts.map +1 -1
- package/lib/typescript/src/contexts/activity.d.ts.map +1 -1
- package/lib/typescript/src/contexts/auth.d.ts +3 -1
- package/lib/typescript/src/contexts/auth.d.ts.map +1 -1
- package/lib/typescript/src/contexts/navigation.d.ts +8 -0
- package/lib/typescript/src/contexts/navigation.d.ts.map +1 -0
- package/lib/typescript/src/contexts/reducers/store.d.ts +3 -1
- package/lib/typescript/src/contexts/reducers/store.d.ts.map +1 -1
- package/lib/typescript/src/contexts/theme.d.ts +9 -3
- package/lib/typescript/src/contexts/theme.d.ts.map +1 -1
- package/lib/typescript/src/hooks/deep-links.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useBifoldAgentSetup.d.ts +10 -0
- package/lib/typescript/src/hooks/useBifoldAgentSetup.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useOnboardingState.d.ts +2 -1
- package/lib/typescript/src/hooks/useOnboardingState.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePINValidation.d.ts +20 -0
- package/lib/typescript/src/hooks/usePINValidation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/en/index.d.ts +23 -17
- package/lib/typescript/src/localization/en/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/fr/index.d.ts +14 -2
- package/lib/typescript/src/localization/fr/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/pt-br/index.d.ts +23 -17
- package/lib/typescript/src/localization/pt-br/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/MainStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/OnboardingScreens.d.ts +3 -3
- package/lib/typescript/src/navigators/OnboardingScreens.d.ts.map +1 -1
- package/lib/typescript/src/navigators/OnboardingStack.d.ts +7 -1
- package/lib/typescript/src/navigators/OnboardingStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/RootStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/SettingStack.d.ts.map +1 -1
- package/lib/typescript/src/navigators/defaultStackOptions.d.ts.map +1 -1
- package/lib/typescript/src/onboarding.d.ts +4 -2
- package/lib/typescript/src/onboarding.d.ts.map +1 -1
- package/lib/typescript/src/screens/Biometry.d.ts +4 -0
- package/lib/typescript/src/screens/Biometry.d.ts.map +1 -0
- package/lib/typescript/src/screens/{PushNotification.d.ts → PINChange.d.ts} +3 -3
- package/lib/typescript/src/screens/PINChange.d.ts.map +1 -0
- package/lib/typescript/src/screens/PINCreate.d.ts.map +1 -1
- package/lib/typescript/src/screens/ProofRequest.d.ts.map +1 -1
- package/lib/typescript/src/screens/PushNotifications.d.ts +4 -0
- package/lib/typescript/src/screens/PushNotifications.d.ts.map +1 -0
- package/lib/typescript/src/screens/Settings.d.ts.map +1 -1
- package/lib/typescript/src/screens/Splash.d.ts +7 -4
- package/lib/typescript/src/screens/Splash.d.ts.map +1 -1
- package/lib/typescript/src/screens/ToggleBiometry.d.ts +4 -0
- package/lib/typescript/src/screens/ToggleBiometry.d.ts.map +1 -0
- package/lib/typescript/src/screens/TogglePushNotifications.d.ts +4 -0
- package/lib/typescript/src/screens/TogglePushNotifications.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +3 -1
- package/lib/typescript/src/theme.d.ts.map +1 -1
- package/lib/typescript/src/types/navigators.d.ts +11 -13
- package/lib/typescript/src/types/navigators.d.ts.map +1 -1
- package/lib/typescript/src/types/state.d.ts +1 -0
- package/lib/typescript/src/types/state.d.ts.map +1 -1
- package/lib/typescript/src/utils/{PINCreationValidation.d.ts → PINValidation.d.ts} +2 -2
- package/lib/typescript/src/utils/PINValidation.d.ts.map +1 -0
- package/lib/typescript/src/utils/agent.d.ts +1 -2
- package/lib/typescript/src/utils/agent.d.ts.map +1 -1
- package/lib/typescript/src/utils/helpers.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/App.tsx +41 -40
- package/src/components/inputs/BiometryControl.tsx +176 -0
- package/src/components/misc/ConnectionAlert.tsx +3 -3
- package/src/components/misc/InfoBox.tsx +3 -1
- package/src/components/misc/{PINCreateHeader.tsx → PINHeader.tsx} +4 -4
- package/src/components/misc/PINValidationHelper.tsx +48 -0
- package/src/components/views/PushNotificationsContent.tsx +51 -0
- package/src/components/views/PushNotificationsDisabledContent.tsx +47 -0
- package/src/container-api.ts +27 -11
- package/src/container-impl.ts +31 -27
- package/src/contexts/activity.tsx +17 -42
- package/src/contexts/auth.tsx +18 -6
- package/src/contexts/navigation.tsx +19 -0
- package/src/contexts/reducers/store.ts +12 -0
- package/src/contexts/theme.tsx +51 -0
- package/src/hooks/deep-links.ts +2 -4
- package/src/hooks/{initialize-agent.ts → useBifoldAgentSetup.ts} +32 -54
- package/src/hooks/useOnboardingState.ts +10 -3
- package/src/hooks/usePINValidation.ts +98 -0
- package/src/index.ts +12 -14
- package/src/localization/en/index.ts +26 -20
- package/src/localization/fr/index.ts +32 -20
- package/src/localization/pt-br/index.ts +39 -33
- package/src/navigators/MainStack.tsx +29 -8
- package/src/navigators/OnboardingScreens.ts +11 -11
- package/src/navigators/OnboardingStack.tsx +26 -14
- package/src/navigators/RootStack.tsx +31 -25
- package/src/navigators/SettingStack.tsx +15 -16
- package/src/navigators/defaultStackOptions.tsx +13 -2
- package/src/onboarding.ts +12 -5
- package/src/screens/Biometry.tsx +57 -0
- package/src/screens/CredentialOffer.tsx +2 -2
- package/src/screens/Onboarding.tsx +2 -2
- package/src/screens/PINChange.tsx +250 -0
- package/src/screens/PINCreate.tsx +51 -267
- package/src/screens/Preface.tsx +2 -2
- package/src/screens/ProofRequest.tsx +140 -48
- package/src/screens/PushNotifications.tsx +59 -0
- package/src/screens/Settings.tsx +5 -10
- package/src/screens/Splash.tsx +10 -22
- package/src/screens/Terms.tsx +2 -2
- package/src/screens/ToggleBiometry.tsx +167 -0
- package/src/screens/TogglePushNotifications.tsx +118 -0
- package/src/theme.ts +5 -1
- package/src/types/navigators.ts +11 -12
- package/src/types/state.ts +1 -0
- package/src/utils/{PINCreationValidation.ts → PINValidation.ts} +1 -1
- package/src/utils/agent.ts +1 -2
- package/src/utils/helpers.ts +2 -0
- package/lib/commonjs/components/misc/ActivityLogLink.js +0 -44
- package/lib/commonjs/components/misc/ActivityLogLink.js.map +0 -1
- package/lib/commonjs/components/misc/PINCreateHeader.js.map +0 -1
- package/lib/commonjs/components/modals/NotificationModal.js +0 -121
- package/lib/commonjs/components/modals/NotificationModal.js.map +0 -1
- package/lib/commonjs/components/texts/Label.js +0 -57
- package/lib/commonjs/components/texts/Label.js.map +0 -1
- package/lib/commonjs/components/texts/Title.js +0 -29
- package/lib/commonjs/components/texts/Title.js.map +0 -1
- package/lib/commonjs/components/views/ModularView.js +0 -41
- package/lib/commonjs/components/views/ModularView.js.map +0 -1
- package/lib/commonjs/hooks/initialize-agent.js.map +0 -1
- package/lib/commonjs/screens/PushNotification.js.map +0 -1
- package/lib/commonjs/screens/UseBiometry.js +0 -315
- package/lib/commonjs/screens/UseBiometry.js.map +0 -1
- package/lib/commonjs/utils/PINCreationValidation.js.map +0 -1
- package/lib/module/components/misc/ActivityLogLink.js +0 -37
- package/lib/module/components/misc/ActivityLogLink.js.map +0 -1
- package/lib/module/components/misc/PINCreateHeader.js.map +0 -1
- package/lib/module/components/modals/NotificationModal.js +0 -112
- package/lib/module/components/modals/NotificationModal.js.map +0 -1
- package/lib/module/components/texts/Label.js +0 -50
- package/lib/module/components/texts/Label.js.map +0 -1
- package/lib/module/components/texts/Title.js +0 -22
- package/lib/module/components/texts/Title.js.map +0 -1
- package/lib/module/components/views/ModularView.js +0 -34
- package/lib/module/components/views/ModularView.js.map +0 -1
- package/lib/module/hooks/initialize-agent.js.map +0 -1
- package/lib/module/screens/PushNotification.js +0 -170
- package/lib/module/screens/PushNotification.js.map +0 -1
- package/lib/module/screens/UseBiometry.js +0 -306
- package/lib/module/screens/UseBiometry.js.map +0 -1
- package/lib/module/utils/PINCreationValidation.js.map +0 -1
- package/lib/typescript/src/components/misc/ActivityLogLink.d.ts +0 -4
- package/lib/typescript/src/components/misc/ActivityLogLink.d.ts.map +0 -1
- package/lib/typescript/src/components/misc/PINCreateHeader.d.ts +0 -6
- package/lib/typescript/src/components/misc/PINCreateHeader.d.ts.map +0 -1
- package/lib/typescript/src/components/modals/NotificationModal.d.ts +0 -17
- package/lib/typescript/src/components/modals/NotificationModal.d.ts.map +0 -1
- package/lib/typescript/src/components/texts/Label.d.ts +0 -9
- package/lib/typescript/src/components/texts/Label.d.ts.map +0 -1
- package/lib/typescript/src/components/texts/Title.d.ts +0 -8
- package/lib/typescript/src/components/texts/Title.d.ts.map +0 -1
- package/lib/typescript/src/components/views/ModularView.d.ts +0 -9
- package/lib/typescript/src/components/views/ModularView.d.ts.map +0 -1
- package/lib/typescript/src/hooks/initialize-agent.d.ts +0 -7
- package/lib/typescript/src/hooks/initialize-agent.d.ts.map +0 -1
- package/lib/typescript/src/screens/PushNotification.d.ts.map +0 -1
- package/lib/typescript/src/screens/UseBiometry.d.ts +0 -4
- package/lib/typescript/src/screens/UseBiometry.d.ts.map +0 -1
- package/lib/typescript/src/utils/PINCreationValidation.d.ts.map +0 -1
- package/src/components/misc/ActivityLogLink.tsx +0 -34
- package/src/components/modals/NotificationModal.tsx +0 -127
- package/src/components/texts/Label.tsx +0 -51
- package/src/components/texts/Title.tsx +0 -25
- package/src/components/views/ModularView.tsx +0 -35
- package/src/contexts/theme.ts +0 -9
- package/src/screens/PushNotification.tsx +0 -186
- 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
|
|
2
|
-
import {
|
|
3
|
-
import 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 {
|
|
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
|
-
|
|
44
|
-
|
|
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 [
|
|
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
|
|
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.
|
|
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
|
|
102
|
-
|
|
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
|
|
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 (
|
|
239
|
-
|
|
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
|
|
274
|
-
}
|
|
118
|
+
return isLoading || PIN.length < minPINLength || PINTwo.length < minPINLength
|
|
119
|
+
}, [isLoading, PIN, PINTwo, inlineMessages])
|
|
275
120
|
|
|
276
|
-
|
|
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
|
-
<
|
|
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'
|
|
131
|
+
label={t('PINCreate.EnterPINTitle')}
|
|
308
132
|
onPINChanged={(p: string) => {
|
|
309
133
|
setPIN(p)
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (
|
|
314
|
-
|
|
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'
|
|
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
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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'
|
|
160
|
+
accessibilityLabel={t('PINCreate.ReenterPIN')}
|
|
347
161
|
autoFocus={false}
|
|
348
162
|
ref={PINTwoInputRef}
|
|
349
163
|
inlineMessage={inlineMessageField2}
|
|
350
164
|
/>
|
|
351
165
|
{PINSecurity.displayHelper && (
|
|
352
|
-
<
|
|
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={
|
|
395
|
-
testID={
|
|
396
|
-
accessibilityLabel={
|
|
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
|
-
{
|
|
186
|
+
{isLoading ? <ButtonLoading /> : null}
|
|
403
187
|
</Button>
|
|
404
188
|
</View>
|
|
405
189
|
</View>
|