@bifold/core 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/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 +16 -26
- package/lib/commonjs/contexts/activity.js.map +1 -1
- package/lib/commonjs/contexts/auth.js +2 -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 +24 -29
- 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 +16 -26
- package/lib/module/contexts/activity.js.map +1 -1
- package/lib/module/contexts/auth.js +2 -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 +23 -28
- 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 +2 -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 +16 -28
- package/src/contexts/auth.tsx +4 -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 +27 -24
- 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
package/src/container-impl.ts
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import { Agent } from '@credo-ts/core'
|
|
2
|
-
import { getProofRequestTemplates } from '@bifold/verifier'
|
|
3
1
|
import { DefaultOCABundleResolver } from '@bifold/oca/build/legacy'
|
|
2
|
+
import { getProofRequestTemplates } from '@bifold/verifier'
|
|
3
|
+
import { Agent } from '@credo-ts/core'
|
|
4
4
|
import { createContext, useContext } from 'react'
|
|
5
5
|
import { DependencyContainer } from 'tsyringe'
|
|
6
6
|
|
|
7
7
|
import * as bundle from './assets/oca-bundles.json'
|
|
8
8
|
import Button from './components/buttons/Button'
|
|
9
|
+
import ContactCredentialListItem from './components/listItems/ContactCredentialListItem'
|
|
10
|
+
import ContactListItem from './components/listItems/ContactListItem'
|
|
11
|
+
import NotificationListItem from './components/listItems/NotificationListItem'
|
|
12
|
+
import ConnectionAlert from './components/misc/ConnectionAlert'
|
|
13
|
+
import EmptyList from './components/misc/EmptyList'
|
|
14
|
+
import NoNewUpdates from './components/misc/NoNewUpdates'
|
|
15
|
+
import PINHeader from './components/misc/PINHeader'
|
|
16
|
+
import Record from './components/record/Record'
|
|
17
|
+
import HomeFooterView from './components/views/HomeFooterView'
|
|
18
|
+
import HomeHeaderView from './components/views/HomeHeaderView'
|
|
9
19
|
import defaultIndyLedgers from './configs/ledgers/indy'
|
|
10
20
|
import { LocalStorageKeys, PINRules } from './constants'
|
|
11
|
-
import {
|
|
21
|
+
import { Container, TokenMapping, TOKENS } from './container-api'
|
|
12
22
|
import { DispatchAction, ReducerAction } from './contexts/reducers/store'
|
|
13
23
|
import { defaultState } from './contexts/store'
|
|
14
24
|
import { useNotifications } from './hooks/notifications'
|
|
25
|
+
import useBifoldAgentSetup from './hooks/useBifoldAgentSetup'
|
|
26
|
+
import { Locales } from './localization'
|
|
15
27
|
import { IHistoryManager } from './modules/history'
|
|
16
28
|
import HistoryManager from './modules/history/context/historyManager'
|
|
17
29
|
import OnboardingStack from './navigators/OnboardingStack'
|
|
30
|
+
import { DefaultScreenLayoutOptions } from './navigators/defaultLayoutOptions'
|
|
18
31
|
import { DefaultScreenOptionsDictionary } from './navigators/defaultStackOptions'
|
|
32
|
+
import { generateOnboardingWorkflowSteps } from './onboarding'
|
|
33
|
+
import Biometry from './screens/Biometry'
|
|
19
34
|
import Developer from './screens/Developer'
|
|
20
35
|
import Onboarding from './screens/Onboarding'
|
|
36
|
+
import OnboardingPages from './screens/OnboardingPages'
|
|
37
|
+
import PINExplainer from './screens/PINExplainer'
|
|
21
38
|
import Preface from './screens/Preface'
|
|
39
|
+
import Scan from './screens/Scan'
|
|
22
40
|
import Splash from './screens/Splash'
|
|
23
|
-
import UpdateAvailable from './screens/UpdateAvailable'
|
|
24
41
|
import ScreenTerms, { TermsVersion } from './screens/Terms'
|
|
42
|
+
import ToggleBiometry from './screens/ToggleBiometry'
|
|
43
|
+
import UpdateAvailable from './screens/UpdateAvailable'
|
|
25
44
|
import { loadLoginAttempt } from './services/keychain'
|
|
26
45
|
import { BifoldLogger } from './services/logger'
|
|
46
|
+
import { PersistentStorage } from './services/storage'
|
|
47
|
+
import { Config, HistoryEventsLoggerConfig } from './types/config'
|
|
48
|
+
import { InlineErrorPosition } from './types/error'
|
|
27
49
|
import {
|
|
28
50
|
Migration as MigrationState,
|
|
51
|
+
PersistentState,
|
|
29
52
|
Preferences as PreferencesState,
|
|
30
53
|
State,
|
|
31
54
|
Onboarding as StoreOnboardingState,
|
|
32
55
|
Tours as ToursState,
|
|
33
|
-
PersistentState,
|
|
34
56
|
} from './types/state'
|
|
35
|
-
import OnboardingPages from './screens/OnboardingPages'
|
|
36
|
-
import UseBiometry from './screens/UseBiometry'
|
|
37
|
-
import Scan from './screens/Scan'
|
|
38
|
-
import PINExplainer from './screens/PINExplainer'
|
|
39
|
-
import HomeHeaderView from './components/views/HomeHeaderView'
|
|
40
|
-
import HomeFooterView from './components/views/HomeFooterView'
|
|
41
|
-
import EmptyList from './components/misc/EmptyList'
|
|
42
|
-
import Record from './components/record/Record'
|
|
43
|
-
import NotificationListItem from './components/listItems/NotificationListItem'
|
|
44
|
-
import NoNewUpdates from './components/misc/NoNewUpdates'
|
|
45
|
-
import PINCreateHeader from './components/misc/PINCreateHeader'
|
|
46
|
-
import { PersistentStorage } from './services/storage'
|
|
47
|
-
import { Config, HistoryEventsLoggerConfig } from './types/config'
|
|
48
|
-
import { Locales } from './localization'
|
|
49
|
-
import ContactListItem from './components/listItems/ContactListItem'
|
|
50
|
-
import ContactCredentialListItem from './components/listItems/ContactCredentialListItem'
|
|
51
|
-
import { InlineErrorPosition } from './types/error'
|
|
52
|
-
import { DefaultScreenLayoutOptions } from './navigators/defaultLayoutOptions'
|
|
53
|
-
import ConnectionAlert from './components/misc/ConnectionAlert'
|
|
54
|
-
import { generateOnboardingWorkflowSteps } from './onboarding'
|
|
55
57
|
|
|
56
58
|
export const defaultConfig: Config = {
|
|
57
59
|
PINSecurity: {
|
|
@@ -119,12 +121,14 @@ export class MainContainer implements Container {
|
|
|
119
121
|
this._container.registerInstance(TOKENS.SCREEN_SPLASH, Splash)
|
|
120
122
|
this._container.registerInstance(TOKENS.SCREEN_UPDATE_AVAILABLE, UpdateAvailable)
|
|
121
123
|
this._container.registerInstance(TOKENS.SCREEN_ONBOARDING_PAGES, OnboardingPages)
|
|
122
|
-
this._container.registerInstance(TOKENS.
|
|
123
|
-
this._container.registerInstance(TOKENS.
|
|
124
|
+
this._container.registerInstance(TOKENS.COMPONENT_PIN_HEADER, PINHeader)
|
|
125
|
+
this._container.registerInstance(TOKENS.SCREEN_BIOMETRY, Biometry)
|
|
126
|
+
this._container.registerInstance(TOKENS.SCREEN_TOGGLE_BIOMETRY, ToggleBiometry)
|
|
124
127
|
this._container.registerInstance(TOKENS.SCREEN_SCAN, Scan)
|
|
125
128
|
this._container.registerInstance(TOKENS.SCREEN_ONBOARDING_ITEM, Onboarding)
|
|
126
129
|
this._container.registerInstance(TOKENS.SCREEN_ONBOARDING, Onboarding)
|
|
127
130
|
this._container.registerInstance(TOKENS.SCREEN_PIN_EXPLAINER, PINExplainer)
|
|
131
|
+
this._container.registerInstance(TOKENS.HOOK_USE_AGENT_SETUP, useBifoldAgentSetup)
|
|
128
132
|
this._container.registerInstance(TOKENS.STACK_ONBOARDING, OnboardingStack)
|
|
129
133
|
this._container.registerInstance(TOKENS.COMP_BUTTON, Button)
|
|
130
134
|
this._container.registerInstance(TOKENS.GROUP_BY_REFERENT, false)
|
|
@@ -43,29 +43,21 @@ export const ActivityProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
43
43
|
const prevAppStateStatusRef = useRef(AppState.currentState)
|
|
44
44
|
const [appStateStatus, setAppStateStatus] = useState<AppStateStatus>(AppState.currentState)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
removeSavedWalletSecret()
|
|
53
|
-
await agent?.shutdown()
|
|
54
|
-
logger.info('Agent shutdown successfully')
|
|
55
|
-
} catch (error) {
|
|
56
|
-
logger.error(`Error during agent shutdown: ${error}`)
|
|
57
|
-
}
|
|
46
|
+
if (!agent) {
|
|
47
|
+
throw new Error('ActivityProvider must be used within agent context provider')
|
|
48
|
+
}
|
|
58
49
|
|
|
50
|
+
const lockOutUser = useCallback(() => {
|
|
51
|
+
removeSavedWalletSecret()
|
|
59
52
|
dispatch({
|
|
60
53
|
type: DispatchAction.DID_AUTHENTICATE,
|
|
61
54
|
payload: [false],
|
|
62
55
|
})
|
|
63
|
-
|
|
64
56
|
dispatch({
|
|
65
57
|
type: DispatchAction.LOCKOUT_UPDATED,
|
|
66
58
|
payload: [{ displayNotification: true }],
|
|
67
59
|
})
|
|
68
|
-
}, [
|
|
60
|
+
}, [removeSavedWalletSecret, dispatch])
|
|
69
61
|
|
|
70
62
|
const clearInactivityTimeoutIfExists = useCallback(() => {
|
|
71
63
|
if (inactivityTimeoutRef.current) {
|
|
@@ -74,7 +66,7 @@ export const ActivityProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
74
66
|
}, [])
|
|
75
67
|
|
|
76
68
|
const resetInactivityTimeout = useCallback(
|
|
77
|
-
|
|
69
|
+
(milliseconds: number) => {
|
|
78
70
|
clearInactivityTimeoutIfExists()
|
|
79
71
|
lastActiveTimeRef.current = Date.now()
|
|
80
72
|
|
|
@@ -94,15 +86,11 @@ export const ActivityProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
94
86
|
if (['active', 'inactive'].includes(prevAppStateStatusRef.current) && nextAppState === 'background') {
|
|
95
87
|
// remove timeout when backgrounded as timeout refs can be lost when app is backgrounded
|
|
96
88
|
clearInactivityTimeoutIfExists()
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
logger.info('Stopped agent message pickup')
|
|
103
|
-
} catch (err) {
|
|
104
|
-
logger.error(`Error stopping agent message pickup, ${err}`)
|
|
105
|
-
}
|
|
89
|
+
try {
|
|
90
|
+
await agent.mediationRecipient.stopMessagePickup()
|
|
91
|
+
logger.info('Stopped agent message pickup')
|
|
92
|
+
} catch (err) {
|
|
93
|
+
logger.error(`Error stopping agent message pickup, ${err}`)
|
|
106
94
|
}
|
|
107
95
|
}
|
|
108
96
|
|
|
@@ -114,9 +102,9 @@ export const ActivityProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
114
102
|
Date.now() - lastActiveTimeRef.current >= timeoutInMilliseconds.current &&
|
|
115
103
|
timeoutInMilliseconds.current > 0
|
|
116
104
|
) {
|
|
117
|
-
|
|
118
|
-
} else
|
|
119
|
-
// otherwise
|
|
105
|
+
lockOutUser()
|
|
106
|
+
} else {
|
|
107
|
+
// otherwise restart message pickup
|
|
120
108
|
try {
|
|
121
109
|
await agent.mediationRecipient.initiateMessagePickup()
|
|
122
110
|
logger.info('Restarted agent message pickup')
|
|
@@ -126,7 +114,7 @@ export const ActivityProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
126
114
|
}
|
|
127
115
|
|
|
128
116
|
// app coming into the foreground is 'user activity', reset timeout
|
|
129
|
-
|
|
117
|
+
resetInactivityTimeout(timeoutInMilliseconds.current)
|
|
130
118
|
}
|
|
131
119
|
|
|
132
120
|
prevAppStateStatusRef.current = nextAppState
|
package/src/contexts/auth.tsx
CHANGED
|
@@ -4,8 +4,7 @@ import '@hyperledger/aries-askar-react-native'
|
|
|
4
4
|
import 'reflect-metadata'
|
|
5
5
|
|
|
6
6
|
import { AskarWallet } from '@credo-ts/askar'
|
|
7
|
-
import { ConsoleLogger, LogLevel, SigningProviderRegistry } from '@credo-ts/core'
|
|
8
|
-
import { useAgent } from '@credo-ts/react-hooks'
|
|
7
|
+
import { Agent, ConsoleLogger, LogLevel, SigningProviderRegistry } from '@credo-ts/core'
|
|
9
8
|
import { agentDependencies } from '@credo-ts/react-native'
|
|
10
9
|
import React, { createContext, useCallback, useContext, useState } from 'react'
|
|
11
10
|
import { useTranslation } from 'react-i18next'
|
|
@@ -33,7 +32,7 @@ export interface AuthContext {
|
|
|
33
32
|
setPIN: (PIN: string) => Promise<void>
|
|
34
33
|
commitWalletToKeychain: (useBiometry: boolean) => Promise<boolean>
|
|
35
34
|
isBiometricsActive: () => Promise<boolean>
|
|
36
|
-
rekeyWallet: (oldPin: string, newPin: string, useBiometry?: boolean) => Promise<boolean>
|
|
35
|
+
rekeyWallet: (agent: Agent, oldPin: string, newPin: string, useBiometry?: boolean) => Promise<boolean>
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export const AuthContext = createContext<AuthContext>(null as unknown as AuthContext)
|
|
@@ -41,7 +40,6 @@ export const AuthContext = createContext<AuthContext>(null as unknown as AuthCon
|
|
|
41
40
|
export const AuthProvider: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
42
41
|
const [walletSecret, setWalletSecret] = useState<WalletSecret>()
|
|
43
42
|
const [store, dispatch] = useStore()
|
|
44
|
-
const { agent } = useAgent()
|
|
45
43
|
const { t } = useTranslation()
|
|
46
44
|
|
|
47
45
|
const setPIN = useCallback(async (PIN: string): Promise<void> => {
|
|
@@ -135,7 +133,7 @@ export const AuthProvider: React.FC<React.PropsWithChildren> = ({ children }) =>
|
|
|
135
133
|
}, [])
|
|
136
134
|
|
|
137
135
|
const rekeyWallet = useCallback(
|
|
138
|
-
async (oldPin: string, newPin: string, useBiometry?: boolean): Promise<boolean> => {
|
|
136
|
+
async (agent: Agent, oldPin: string, newPin: string, useBiometry?: boolean): Promise<boolean> => {
|
|
139
137
|
try {
|
|
140
138
|
if (!agent) {
|
|
141
139
|
// no agent set, cannot rekey the wallet
|
|
@@ -165,7 +163,7 @@ export const AuthProvider: React.FC<React.PropsWithChildren> = ({ children }) =>
|
|
|
165
163
|
}
|
|
166
164
|
return true
|
|
167
165
|
},
|
|
168
|
-
[
|
|
166
|
+
[]
|
|
169
167
|
)
|
|
170
168
|
|
|
171
169
|
return (
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NavigationContainer, NavigationContainerRef } from '@react-navigation/native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { useTheme } from './theme'
|
|
4
|
+
|
|
5
|
+
export interface NavContainerProps extends React.PropsWithChildren {
|
|
6
|
+
navigationRef: React.RefObject<NavigationContainerRef<any>> | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const NavContainer = ({ navigationRef, children }: NavContainerProps) => {
|
|
10
|
+
const { NavigationTheme } = useTheme()
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<NavigationContainer ref={navigationRef} theme={NavigationTheme}>
|
|
14
|
+
{children}
|
|
15
|
+
</NavigationContainer>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default NavContainer
|
|
@@ -59,6 +59,7 @@ enum PreferencesDispatchAction {
|
|
|
59
59
|
USE_SHAREABLE_LINK = 'preferences/useShareableLink',
|
|
60
60
|
UPDATE_ALTERNATE_CONTACT_NAMES = 'preferences/updateAlternateContactNames',
|
|
61
61
|
AUTO_LOCK_TIME = 'preferences/autoLockTime',
|
|
62
|
+
SET_THEME = 'preferences/setTheme',
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
enum ToursDispatchAction {
|
|
@@ -340,6 +341,17 @@ export const reducer = <S extends State>(state: S, action: ReducerAction<Dispatc
|
|
|
340
341
|
|
|
341
342
|
return newState
|
|
342
343
|
}
|
|
344
|
+
case PreferencesDispatchAction.SET_THEME: {
|
|
345
|
+
const theme = (action?.payload ?? []).pop() ?? ''
|
|
346
|
+
const preferences = { ...state.preferences, theme }
|
|
347
|
+
|
|
348
|
+
PersistentStorage.storeValueForKey(LocalStorageKeys.Preferences, preferences)
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
...state,
|
|
352
|
+
preferences,
|
|
353
|
+
}
|
|
354
|
+
}
|
|
343
355
|
case ToursDispatchAction.UPDATE_SEEN_TOUR_PROMPT: {
|
|
344
356
|
const seenToursPrompt: ToursState = (action?.payload ?? []).pop() ?? false
|
|
345
357
|
const tours = {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { bifoldTheme, ITheme } from '../theme'
|
|
4
|
+
import { useStore } from './store'
|
|
5
|
+
import { DispatchAction } from './reducers/store'
|
|
6
|
+
|
|
7
|
+
export interface IThemeContext extends ITheme {
|
|
8
|
+
setTheme: (themeName: string) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ThemeContext = createContext<IThemeContext>({
|
|
12
|
+
...bifoldTheme,
|
|
13
|
+
setTheme: () => {},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export interface ThemeProviderProps extends React.PropsWithChildren {
|
|
17
|
+
themes: ITheme[]
|
|
18
|
+
defaultThemeName: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ThemeProvider = ({ themes, defaultThemeName, children }: ThemeProviderProps) => {
|
|
22
|
+
const [store, dispatch] = useStore()
|
|
23
|
+
|
|
24
|
+
const activeTheme = useMemo(() => {
|
|
25
|
+
return (
|
|
26
|
+
(store.preferences.theme && themes.find((t) => t.themeName === store.preferences.theme)) ||
|
|
27
|
+
themes.find((t) => t.themeName === defaultThemeName) ||
|
|
28
|
+
themes[0]
|
|
29
|
+
)
|
|
30
|
+
}, [store.preferences.theme, themes, defaultThemeName])
|
|
31
|
+
|
|
32
|
+
const setTheme = useCallback(
|
|
33
|
+
(themeName: string) => {
|
|
34
|
+
const newTheme = themes.find((t) => t.themeName === themeName) || themes[0]
|
|
35
|
+
dispatch({ type: DispatchAction.SET_THEME, payload: [newTheme.themeName] })
|
|
36
|
+
},
|
|
37
|
+
[themes, dispatch]
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// prevent re-rendering of the context value
|
|
41
|
+
const value = useMemo(() => {
|
|
42
|
+
return {
|
|
43
|
+
...activeTheme,
|
|
44
|
+
setTheme,
|
|
45
|
+
}
|
|
46
|
+
}, [activeTheme, setTheme])
|
|
47
|
+
|
|
48
|
+
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const useTheme = () => useContext(ThemeContext)
|
package/src/hooks/deep-links.ts
CHANGED
|
@@ -27,15 +27,13 @@ export const useDeepLinks = () => {
|
|
|
27
27
|
|
|
28
28
|
// deeplink while already open
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
Linking.
|
|
30
|
+
const listener = Linking.addListener('url', ({ url }) => {
|
|
31
31
|
if (url) {
|
|
32
32
|
setStashedDeepLink(url)
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
return
|
|
37
|
-
Linking.removeAllListeners('url')
|
|
38
|
-
}
|
|
36
|
+
return listener.remove
|
|
39
37
|
})
|
|
40
38
|
|
|
41
39
|
// activate stashed deeplink when ready
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Agent, HttpOutboundTransport, WsOutboundTransport } from '@credo-ts/core'
|
|
2
2
|
import { IndyVdrPoolService } from '@credo-ts/indy-vdr/build/pool'
|
|
3
|
-
import { useAgent } from '@credo-ts/react-hooks'
|
|
4
3
|
import { agentDependencies } from '@credo-ts/react-native'
|
|
5
4
|
import { GetCredentialDefinitionRequest, GetSchemaRequest } from '@hyperledger/indy-vdr-shared'
|
|
6
|
-
import { useCallback } from 'react'
|
|
5
|
+
import { useCallback, useState } from 'react'
|
|
7
6
|
import { Config } from 'react-native-config'
|
|
8
7
|
import { CachesDirectoryPath } from 'react-native-fs'
|
|
9
8
|
|
|
@@ -14,8 +13,14 @@ import { getAgentModules, createLinkSecretIfRequired } from '../utils/agent'
|
|
|
14
13
|
import { migrateToAskar } from '../utils/migration'
|
|
15
14
|
import { WalletSecret } from '../types/security'
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export type AgentSetupReturnType = {
|
|
17
|
+
agent: Agent | null
|
|
18
|
+
initializeAgent: (walletSecret: WalletSecret) => Promise<void>
|
|
19
|
+
shutdownAndClearAgentIfExists: () => Promise<void>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
23
|
+
const [agent, setAgent] = useState<Agent | null>(null)
|
|
19
24
|
const [store, dispatch] = useStore()
|
|
20
25
|
const [cacheSchemas, cacheCredDefs, logger, indyLedgers] = useServices([
|
|
21
26
|
TOKENS.CACHE_SCHEMAS,
|
|
@@ -24,37 +29,8 @@ const useInitializeAgent = () => {
|
|
|
24
29
|
TOKENS.UTIL_LEDGERS,
|
|
25
30
|
])
|
|
26
31
|
|
|
27
|
-
const restartExistingAgent = useCallback(
|
|
28
|
-
async (walletSecret: WalletSecret) => {
|
|
29
|
-
// if the agent is initialized, it was not a clean shutdown and should be replaced, not restarted
|
|
30
|
-
if (!agent || agent.isInitialized) {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
logger.info('Agent already created, restarting...')
|
|
35
|
-
try {
|
|
36
|
-
await agent.wallet.open({
|
|
37
|
-
id: walletSecret.id,
|
|
38
|
-
key: walletSecret.key,
|
|
39
|
-
})
|
|
40
|
-
await agent.initialize()
|
|
41
|
-
} catch {
|
|
42
|
-
// if the existing agents wallet cannot be opened or initialize() fails it was
|
|
43
|
-
// again not a clean shutdown and the agent should be replaced, not restarted
|
|
44
|
-
logger.warn('Failed to restart existing agent, skipping agent restart')
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
logger.info('Successfully restarted existing agent')
|
|
49
|
-
return agent
|
|
50
|
-
},
|
|
51
|
-
[agent, logger]
|
|
52
|
-
)
|
|
53
|
-
|
|
54
32
|
const createNewAgent = useCallback(
|
|
55
|
-
async (walletSecret: WalletSecret): Promise<Agent
|
|
56
|
-
logger.info('No agent initialized, creating a new one')
|
|
57
|
-
|
|
33
|
+
async (walletSecret: WalletSecret): Promise<Agent> => {
|
|
58
34
|
const newAgent = new Agent({
|
|
59
35
|
config: {
|
|
60
36
|
label: store.preferences.walletName || 'Aries Bifold',
|
|
@@ -91,11 +67,7 @@ const useInitializeAgent = () => {
|
|
|
91
67
|
async (newAgent: Agent, walletSecret: WalletSecret) => {
|
|
92
68
|
// If we haven't migrated to Aries Askar yet, we need to do this before we initialize the agent.
|
|
93
69
|
if (!store.migration.didMigrateToAskar) {
|
|
94
|
-
newAgent.config.logger.debug('Agent not updated to Aries Askar, updating...')
|
|
95
|
-
|
|
96
70
|
await migrateToAskar(walletSecret.id, walletSecret.key, newAgent)
|
|
97
|
-
|
|
98
|
-
newAgent.config.logger.debug('Successfully finished updating agent to Aries Askar')
|
|
99
71
|
// Store that we migrated to askar.
|
|
100
72
|
dispatch({
|
|
101
73
|
type: DispatchAction.DID_MIGRATE_TO_ASKAR,
|
|
@@ -124,35 +96,41 @@ const useInitializeAgent = () => {
|
|
|
124
96
|
)
|
|
125
97
|
|
|
126
98
|
const initializeAgent = useCallback(
|
|
127
|
-
async (walletSecret: WalletSecret): Promise<
|
|
128
|
-
|
|
129
|
-
if (existingAgent) {
|
|
130
|
-
setAgent(existingAgent)
|
|
131
|
-
return existingAgent
|
|
132
|
-
}
|
|
133
|
-
|
|
99
|
+
async (walletSecret: WalletSecret): Promise<void> => {
|
|
100
|
+
logger.info('Creating agent')
|
|
134
101
|
const newAgent = await createNewAgent(walletSecret)
|
|
135
|
-
if (!newAgent) {
|
|
136
|
-
logger.error('Failed to create a new agent')
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
102
|
|
|
103
|
+
logger.info('Migrating if required...')
|
|
140
104
|
await migrateIfRequired(newAgent, walletSecret)
|
|
141
105
|
|
|
106
|
+
logger.info('Initializing agent...')
|
|
142
107
|
await newAgent.initialize()
|
|
143
108
|
|
|
109
|
+
logger.info('Creating link secret if required...')
|
|
144
110
|
await createLinkSecretIfRequired(newAgent)
|
|
145
111
|
|
|
112
|
+
logger.info('Warming up cache...')
|
|
146
113
|
await warmUpCache(newAgent)
|
|
147
114
|
|
|
115
|
+
logger.info('Agent initialized successfully')
|
|
148
116
|
setAgent(newAgent)
|
|
149
|
-
|
|
150
|
-
return newAgent
|
|
151
117
|
},
|
|
152
|
-
[logger,
|
|
118
|
+
[logger, createNewAgent, migrateIfRequired, warmUpCache]
|
|
153
119
|
)
|
|
154
120
|
|
|
155
|
-
|
|
121
|
+
const shutdownAndClearAgentIfExists = useCallback(async () => {
|
|
122
|
+
if (agent) {
|
|
123
|
+
try {
|
|
124
|
+
await agent.shutdown()
|
|
125
|
+
} catch (error) {
|
|
126
|
+
logger.error(`Error shutting down agent with shutdownAndClearAgentIfExists: ${error}`)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setAgent(null)
|
|
131
|
+
}, [agent, logger])
|
|
132
|
+
|
|
133
|
+
return { agent, initializeAgent, shutdownAndClearAgentIfExists }
|
|
156
134
|
}
|
|
157
135
|
|
|
158
|
-
export default
|
|
136
|
+
export default useBifoldAgentSetup
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Agent } from '@credo-ts/core'
|
|
1
2
|
import { useState, useEffect, useMemo } from 'react'
|
|
2
3
|
import { useNavigationState } from '@react-navigation/native'
|
|
3
4
|
import { State } from '../types/state'
|
|
@@ -12,7 +13,13 @@ export const useOnboardingState = (
|
|
|
12
13
|
store: State,
|
|
13
14
|
config: Config,
|
|
14
15
|
termsVersion: number,
|
|
15
|
-
|
|
16
|
+
agent: Agent | null,
|
|
17
|
+
generateOnboardingWorkflowSteps: (
|
|
18
|
+
store: State,
|
|
19
|
+
config: Config,
|
|
20
|
+
termsVersion: number,
|
|
21
|
+
agent: Agent | null
|
|
22
|
+
) => OnboardingTask[]
|
|
16
23
|
): {
|
|
17
24
|
onboardingState: OnboardingTask[]
|
|
18
25
|
setOnboardingState: React.Dispatch<React.SetStateAction<OnboardingTask[]>>
|
|
@@ -32,9 +39,9 @@ export const useOnboardingState = (
|
|
|
32
39
|
return
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
const onboardingTasks = generateOnboardingWorkflowSteps(store, config, termsVersion)
|
|
42
|
+
const onboardingTasks = generateOnboardingWorkflowSteps(store, config, termsVersion, agent)
|
|
36
43
|
setOnboardingState(onboardingTasks)
|
|
37
|
-
}, [store, config, termsVersion, generateOnboardingWorkflowSteps])
|
|
44
|
+
}, [store, config, termsVersion, agent, generateOnboardingWorkflowSteps])
|
|
38
45
|
|
|
39
46
|
return {
|
|
40
47
|
onboardingState,
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
3
|
+
|
|
4
|
+
import { InlineErrorType, InlineMessageProps } from '../components/inputs/InlineErrorText'
|
|
5
|
+
import { TOKENS, useServices } from '../container-api'
|
|
6
|
+
import { createPINValidations, PINValidationsType } from '../utils/PINValidation'
|
|
7
|
+
|
|
8
|
+
interface ModalState {
|
|
9
|
+
visible: boolean
|
|
10
|
+
title: string
|
|
11
|
+
message: string
|
|
12
|
+
onModalDismiss?: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const initialModalState: ModalState = {
|
|
16
|
+
visible: false,
|
|
17
|
+
title: '',
|
|
18
|
+
message: '',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const usePINValidation = (PIN: string, PINTwo: string) => {
|
|
22
|
+
const { t } = useTranslation()
|
|
23
|
+
const [{ PINSecurity }, inlineMessages] = useServices([TOKENS.CONFIG, TOKENS.INLINE_ERRORS])
|
|
24
|
+
const [inlineMessageField1, setInlineMessageField1] = useState<InlineMessageProps>()
|
|
25
|
+
const [inlineMessageField2, setInlineMessageField2] = useState<InlineMessageProps>()
|
|
26
|
+
const [modalState, setModalState] = useState<ModalState>(initialModalState)
|
|
27
|
+
|
|
28
|
+
const clearModal = useCallback(() => {
|
|
29
|
+
setModalState(initialModalState)
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
const [PINValidations, setPINValidations] = useState<PINValidationsType[]>(
|
|
33
|
+
createPINValidations(PIN, PINSecurity.rules)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setInlineMessageField1(undefined)
|
|
38
|
+
setInlineMessageField2(undefined)
|
|
39
|
+
setPINValidations(createPINValidations(PIN, PINSecurity.rules))
|
|
40
|
+
}, [PIN, PINTwo, PINSecurity.rules])
|
|
41
|
+
|
|
42
|
+
const attentionMessage = useCallback(
|
|
43
|
+
(title: string, message: string, pinOne: boolean) => {
|
|
44
|
+
if (inlineMessages.enabled) {
|
|
45
|
+
const config = {
|
|
46
|
+
message: message,
|
|
47
|
+
inlineType: InlineErrorType.error,
|
|
48
|
+
config: inlineMessages,
|
|
49
|
+
}
|
|
50
|
+
if (pinOne) {
|
|
51
|
+
setInlineMessageField1(config)
|
|
52
|
+
} else {
|
|
53
|
+
setInlineMessageField2(config)
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
setModalState({
|
|
57
|
+
visible: true,
|
|
58
|
+
title: title,
|
|
59
|
+
message: message,
|
|
60
|
+
onModalDismiss: clearModal
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[inlineMessages, clearModal]
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const validatePINEntry = useCallback(
|
|
68
|
+
(PINOne: string, PINTwo: string): boolean => {
|
|
69
|
+
for (const validation of PINValidations) {
|
|
70
|
+
if (validation.isInvalid) {
|
|
71
|
+
attentionMessage(
|
|
72
|
+
t('PINCreate.InvalidPIN'),
|
|
73
|
+
t(`PINCreate.Message.${validation.errorName}`, validation?.errorTextAddition),
|
|
74
|
+
true
|
|
75
|
+
)
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (PINOne !== PINTwo) {
|
|
80
|
+
attentionMessage(t('PINCreate.InvalidPIN'), t('PINCreate.PINsDoNotMatch'), false)
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
return true
|
|
84
|
+
},
|
|
85
|
+
[PINValidations, t, attentionMessage]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
PINValidations,
|
|
90
|
+
validatePINEntry,
|
|
91
|
+
inlineMessageField1,
|
|
92
|
+
inlineMessageField2,
|
|
93
|
+
modalState,
|
|
94
|
+
setModalState,
|
|
95
|
+
clearModal,
|
|
96
|
+
PINSecurity
|
|
97
|
+
}
|
|
98
|
+
}
|