@velion-la/onboarding-sdk-react-native 1.0.0-beta.10
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/CHANGELOG.md +66 -0
- package/LICENSE +12 -0
- package/README.md +888 -0
- package/app.plugin.js +101 -0
- package/lib/commonjs/camera/AddressSearchBar.js +304 -0
- package/lib/commonjs/camera/AddressSearchBar.js.map +1 -0
- package/lib/commonjs/camera/DocumentCapture.js +513 -0
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -0
- package/lib/commonjs/camera/LivenessCamera.js +628 -0
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -0
- package/lib/commonjs/camera/MapAddressPicker.js +331 -0
- package/lib/commonjs/camera/MapAddressPicker.js.map +1 -0
- package/lib/commonjs/core/VelionOnboarding.js +1113 -0
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -0
- package/lib/commonjs/core/retryStepCopy.js +43 -0
- package/lib/commonjs/core/retryStepCopy.js.map +1 -0
- package/lib/commonjs/core/routingCommands.js +62 -0
- package/lib/commonjs/core/routingCommands.js.map +1 -0
- package/lib/commonjs/core/sessionDeclinedCopy.js +56 -0
- package/lib/commonjs/core/sessionDeclinedCopy.js.map +1 -0
- package/lib/commonjs/core/sessionStateMapper.js +200 -0
- package/lib/commonjs/core/sessionStateMapper.js.map +1 -0
- package/lib/commonjs/core/sseReasonMessages.js +450 -0
- package/lib/commonjs/core/sseReasonMessages.js.map +1 -0
- package/lib/commonjs/data/iso3166Alpha2Codes.json +1 -0
- package/lib/commonjs/data/iso3166CountryNames.json +251 -0
- package/lib/commonjs/i18n/index.js +30 -0
- package/lib/commonjs/i18n/index.js.map +1 -0
- package/lib/commonjs/i18n/strings/en.js +301 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -0
- package/lib/commonjs/i18n/strings/es.js +306 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -0
- package/lib/commonjs/index.js +225 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/steps/AddressInfoStep.js +662 -0
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -0
- package/lib/commonjs/steps/DocumentsOcrStep.js +405 -0
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -0
- package/lib/commonjs/steps/EconomicActivityStep.js +214 -0
- package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -0
- package/lib/commonjs/steps/EmailContactStep.js +150 -0
- package/lib/commonjs/steps/EmailContactStep.js.map +1 -0
- package/lib/commonjs/steps/EmailOtpStep.js +225 -0
- package/lib/commonjs/steps/EmailOtpStep.js.map +1 -0
- package/lib/commonjs/steps/FaceMatchStep.js +169 -0
- package/lib/commonjs/steps/FaceMatchStep.js.map +1 -0
- package/lib/commonjs/steps/FingerprintStep.js +92 -0
- package/lib/commonjs/steps/FingerprintStep.js.map +1 -0
- package/lib/commonjs/steps/HumanBasicInfoStep.js +251 -0
- package/lib/commonjs/steps/HumanBasicInfoStep.js.map +1 -0
- package/lib/commonjs/steps/HumanExtendedInfoStep.js +275 -0
- package/lib/commonjs/steps/HumanExtendedInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LegalBasicInfoStep.js +195 -0
- package/lib/commonjs/steps/LegalBasicInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LegalExtendedInfoStep.js +173 -0
- package/lib/commonjs/steps/LegalExtendedInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LivenessMatchStep.js +1184 -0
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -0
- package/lib/commonjs/steps/PhoneContactStep.js +151 -0
- package/lib/commonjs/steps/PhoneContactStep.js.map +1 -0
- package/lib/commonjs/steps/PhoneOtpStep.js +224 -0
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -0
- package/lib/commonjs/steps/SwornDeclarationStep.js +206 -0
- package/lib/commonjs/steps/SwornDeclarationStep.js.map +1 -0
- package/lib/commonjs/steps/TaxInfoStep.js +251 -0
- package/lib/commonjs/steps/TaxInfoStep.js.map +1 -0
- package/lib/commonjs/steps/TermsAndConditionsStep.js +245 -0
- package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -0
- package/lib/commonjs/steps/_shared.js +61 -0
- package/lib/commonjs/steps/_shared.js.map +1 -0
- package/lib/commonjs/steps/types.js +6 -0
- package/lib/commonjs/steps/types.js.map +1 -0
- package/lib/commonjs/transport/api.js +176 -0
- package/lib/commonjs/transport/api.js.map +1 -0
- package/lib/commonjs/transport/irisWebSocket.js +121 -0
- package/lib/commonjs/transport/irisWebSocket.js.map +1 -0
- package/lib/commonjs/transport/secureUrl.js +50 -0
- package/lib/commonjs/transport/secureUrl.js.map +1 -0
- package/lib/commonjs/transport/sse.js +248 -0
- package/lib/commonjs/transport/sse.js.map +1 -0
- package/lib/commonjs/types/index.js +458 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/ui/MapFallbackBoundary.js +42 -0
- package/lib/commonjs/ui/MapFallbackBoundary.js.map +1 -0
- package/lib/commonjs/ui/StepShell.js +251 -0
- package/lib/commonjs/ui/StepShell.js.map +1 -0
- package/lib/commonjs/ui/VelionOnboardingScreen.js +276 -0
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -0
- package/lib/commonjs/ui/forms/index.js +38 -0
- package/lib/commonjs/ui/forms/index.js.map +1 -0
- package/lib/commonjs/ui/forms/useInlineValidation.js +88 -0
- package/lib/commonjs/ui/forms/useInlineValidation.js.map +1 -0
- package/lib/commonjs/ui/forms/validators.js +34 -0
- package/lib/commonjs/ui/forms/validators.js.map +1 -0
- package/lib/commonjs/ui/icons/HomeHeartIcon.js +38 -0
- package/lib/commonjs/ui/icons/HomeHeartIcon.js.map +1 -0
- package/lib/commonjs/ui/icons/StepIcon.js +59 -0
- package/lib/commonjs/ui/icons/StepIcon.js.map +1 -0
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js +284 -0
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js.map +1 -0
- package/lib/commonjs/ui/overlays/LoadingOverlay.js +108 -0
- package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -0
- package/lib/commonjs/ui/overlays/ProgressBar.js +101 -0
- package/lib/commonjs/ui/overlays/ProgressBar.js.map +1 -0
- package/lib/commonjs/ui/overlays/RetryDialog.js +125 -0
- package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -0
- package/lib/commonjs/ui/overlays/index.js +33 -0
- package/lib/commonjs/ui/overlays/index.js.map +1 -0
- package/lib/commonjs/ui/primitives/BackButton.js +75 -0
- package/lib/commonjs/ui/primitives/BackButton.js.map +1 -0
- package/lib/commonjs/ui/primitives/Banner.js +81 -0
- package/lib/commonjs/ui/primitives/Banner.js.map +1 -0
- package/lib/commonjs/ui/primitives/Button.js +142 -0
- package/lib/commonjs/ui/primitives/Button.js.map +1 -0
- package/lib/commonjs/ui/primitives/Card.js +50 -0
- package/lib/commonjs/ui/primitives/Card.js.map +1 -0
- package/lib/commonjs/ui/primitives/Checkbox.js +139 -0
- package/lib/commonjs/ui/primitives/Checkbox.js.map +1 -0
- package/lib/commonjs/ui/primitives/CountrySelect.js +288 -0
- package/lib/commonjs/ui/primitives/CountrySelect.js.map +1 -0
- package/lib/commonjs/ui/primitives/DatePicker.js +245 -0
- package/lib/commonjs/ui/primitives/DatePicker.js.map +1 -0
- package/lib/commonjs/ui/primitives/Input.js +101 -0
- package/lib/commonjs/ui/primitives/Input.js.map +1 -0
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +162 -0
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -0
- package/lib/commonjs/ui/primitives/Select.js +209 -0
- package/lib/commonjs/ui/primitives/Select.js.map +1 -0
- package/lib/commonjs/ui/primitives/Spinner.js +25 -0
- package/lib/commonjs/ui/primitives/Spinner.js.map +1 -0
- package/lib/commonjs/ui/primitives/index.js +89 -0
- package/lib/commonjs/ui/primitives/index.js.map +1 -0
- package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js +31 -0
- package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
- package/lib/commonjs/ui/theme/ThemeProvider.js +74 -0
- package/lib/commonjs/ui/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/ui/theme/index.js +68 -0
- package/lib/commonjs/ui/theme/index.js.map +1 -0
- package/lib/commonjs/ui/theme/tokens.js +154 -0
- package/lib/commonjs/ui/theme/tokens.js.map +1 -0
- package/lib/commonjs/utils/EventEmitter.js +144 -0
- package/lib/commonjs/utils/EventEmitter.js.map +1 -0
- package/lib/commonjs/utils/base64.js +53 -0
- package/lib/commonjs/utils/base64.js.map +1 -0
- package/lib/commonjs/utils/deviceFingerprint.js +132 -0
- package/lib/commonjs/utils/deviceFingerprint.js.map +1 -0
- package/lib/commonjs/utils/documentTypeOptions.js +35 -0
- package/lib/commonjs/utils/documentTypeOptions.js.map +1 -0
- package/lib/commonjs/utils/googleMapsPreflight.js +88 -0
- package/lib/commonjs/utils/googleMapsPreflight.js.map +1 -0
- package/lib/commonjs/utils/hmac.js +58 -0
- package/lib/commonjs/utils/hmac.js.map +1 -0
- package/lib/commonjs/utils/iso3166Countries.js +98 -0
- package/lib/commonjs/utils/iso3166Countries.js.map +1 -0
- package/lib/commonjs/utils/jpegFromUri.js +44 -0
- package/lib/commonjs/utils/jpegFromUri.js.map +1 -0
- package/lib/commonjs/utils/keepAwake.js +58 -0
- package/lib/commonjs/utils/keepAwake.js.map +1 -0
- package/lib/commonjs/utils/log.js +42 -0
- package/lib/commonjs/utils/log.js.map +1 -0
- package/lib/commonjs/utils/osGeocoder.js +70 -0
- package/lib/commonjs/utils/osGeocoder.js.map +1 -0
- package/lib/commonjs/utils/parseGoogleAddressComponents.js +74 -0
- package/lib/commonjs/utils/parseGoogleAddressComponents.js.map +1 -0
- package/lib/commonjs/utils/personNameNormalize.js +24 -0
- package/lib/commonjs/utils/personNameNormalize.js.map +1 -0
- package/lib/commonjs/utils/sdkError.js +34 -0
- package/lib/commonjs/utils/sdkError.js.map +1 -0
- package/lib/commonjs/utils/sdkVersion.js +13 -0
- package/lib/commonjs/utils/sdkVersion.js.map +1 -0
- package/lib/commonjs/utils/stepConfig.js +65 -0
- package/lib/commonjs/utils/stepConfig.js.map +1 -0
- package/lib/commonjs/utils/taxInfoConfig.js +19 -0
- package/lib/commonjs/utils/taxInfoConfig.js.map +1 -0
- package/lib/commonjs/utils/useSafeAreaInsets.js +41 -0
- package/lib/commonjs/utils/useSafeAreaInsets.js.map +1 -0
- package/lib/commonjs/utils/velionExtra.js +48 -0
- package/lib/commonjs/utils/velionExtra.js.map +1 -0
- package/lib/module/camera/AddressSearchBar.js +299 -0
- package/lib/module/camera/AddressSearchBar.js.map +1 -0
- package/lib/module/camera/DocumentCapture.js +508 -0
- package/lib/module/camera/DocumentCapture.js.map +1 -0
- package/lib/module/camera/LivenessCamera.js +623 -0
- package/lib/module/camera/LivenessCamera.js.map +1 -0
- package/lib/module/camera/MapAddressPicker.js +326 -0
- package/lib/module/camera/MapAddressPicker.js.map +1 -0
- package/lib/module/core/VelionOnboarding.js +1109 -0
- package/lib/module/core/VelionOnboarding.js.map +1 -0
- package/lib/module/core/retryStepCopy.js +39 -0
- package/lib/module/core/retryStepCopy.js.map +1 -0
- package/lib/module/core/routingCommands.js +57 -0
- package/lib/module/core/routingCommands.js.map +1 -0
- package/lib/module/core/sessionDeclinedCopy.js +52 -0
- package/lib/module/core/sessionDeclinedCopy.js.map +1 -0
- package/lib/module/core/sessionStateMapper.js +189 -0
- package/lib/module/core/sessionStateMapper.js.map +1 -0
- package/lib/module/core/sseReasonMessages.js +446 -0
- package/lib/module/core/sseReasonMessages.js.map +1 -0
- package/lib/module/data/iso3166Alpha2Codes.json +1 -0
- package/lib/module/data/iso3166CountryNames.json +251 -0
- package/lib/module/i18n/index.js +25 -0
- package/lib/module/i18n/index.js.map +1 -0
- package/lib/module/i18n/strings/en.js +297 -0
- package/lib/module/i18n/strings/en.js.map +1 -0
- package/lib/module/i18n/strings/es.js +302 -0
- package/lib/module/i18n/strings/es.js.map +1 -0
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/steps/AddressInfoStep.js +658 -0
- package/lib/module/steps/AddressInfoStep.js.map +1 -0
- package/lib/module/steps/DocumentsOcrStep.js +399 -0
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -0
- package/lib/module/steps/EconomicActivityStep.js +209 -0
- package/lib/module/steps/EconomicActivityStep.js.map +1 -0
- package/lib/module/steps/EmailContactStep.js +145 -0
- package/lib/module/steps/EmailContactStep.js.map +1 -0
- package/lib/module/steps/EmailOtpStep.js +220 -0
- package/lib/module/steps/EmailOtpStep.js.map +1 -0
- package/lib/module/steps/FaceMatchStep.js +164 -0
- package/lib/module/steps/FaceMatchStep.js.map +1 -0
- package/lib/module/steps/FingerprintStep.js +87 -0
- package/lib/module/steps/FingerprintStep.js.map +1 -0
- package/lib/module/steps/HumanBasicInfoStep.js +246 -0
- package/lib/module/steps/HumanBasicInfoStep.js.map +1 -0
- package/lib/module/steps/HumanExtendedInfoStep.js +270 -0
- package/lib/module/steps/HumanExtendedInfoStep.js.map +1 -0
- package/lib/module/steps/LegalBasicInfoStep.js +190 -0
- package/lib/module/steps/LegalBasicInfoStep.js.map +1 -0
- package/lib/module/steps/LegalExtendedInfoStep.js +168 -0
- package/lib/module/steps/LegalExtendedInfoStep.js.map +1 -0
- package/lib/module/steps/LivenessMatchStep.js +1177 -0
- package/lib/module/steps/LivenessMatchStep.js.map +1 -0
- package/lib/module/steps/PhoneContactStep.js +146 -0
- package/lib/module/steps/PhoneContactStep.js.map +1 -0
- package/lib/module/steps/PhoneOtpStep.js +219 -0
- package/lib/module/steps/PhoneOtpStep.js.map +1 -0
- package/lib/module/steps/SwornDeclarationStep.js +203 -0
- package/lib/module/steps/SwornDeclarationStep.js.map +1 -0
- package/lib/module/steps/TaxInfoStep.js +246 -0
- package/lib/module/steps/TaxInfoStep.js.map +1 -0
- package/lib/module/steps/TermsAndConditionsStep.js +240 -0
- package/lib/module/steps/TermsAndConditionsStep.js.map +1 -0
- package/lib/module/steps/_shared.js +52 -0
- package/lib/module/steps/_shared.js.map +1 -0
- package/lib/module/steps/types.js +4 -0
- package/lib/module/steps/types.js.map +1 -0
- package/lib/module/transport/api.js +173 -0
- package/lib/module/transport/api.js.map +1 -0
- package/lib/module/transport/irisWebSocket.js +115 -0
- package/lib/module/transport/irisWebSocket.js.map +1 -0
- package/lib/module/transport/secureUrl.js +45 -0
- package/lib/module/transport/secureUrl.js.map +1 -0
- package/lib/module/transport/sse.js +242 -0
- package/lib/module/transport/sse.js.map +1 -0
- package/lib/module/types/index.js +532 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/ui/MapFallbackBoundary.js +37 -0
- package/lib/module/ui/MapFallbackBoundary.js.map +1 -0
- package/lib/module/ui/StepShell.js +246 -0
- package/lib/module/ui/StepShell.js.map +1 -0
- package/lib/module/ui/VelionOnboardingScreen.js +273 -0
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -0
- package/lib/module/ui/forms/index.js +5 -0
- package/lib/module/ui/forms/index.js.map +1 -0
- package/lib/module/ui/forms/useInlineValidation.js +84 -0
- package/lib/module/ui/forms/useInlineValidation.js.map +1 -0
- package/lib/module/ui/forms/validators.js +27 -0
- package/lib/module/ui/forms/validators.js.map +1 -0
- package/lib/module/ui/icons/HomeHeartIcon.js +33 -0
- package/lib/module/ui/icons/HomeHeartIcon.js.map +1 -0
- package/lib/module/ui/icons/StepIcon.js +55 -0
- package/lib/module/ui/icons/StepIcon.js.map +1 -0
- package/lib/module/ui/overlays/AnalyzingOverlay.js +279 -0
- package/lib/module/ui/overlays/AnalyzingOverlay.js.map +1 -0
- package/lib/module/ui/overlays/LoadingOverlay.js +104 -0
- package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -0
- package/lib/module/ui/overlays/ProgressBar.js +97 -0
- package/lib/module/ui/overlays/ProgressBar.js.map +1 -0
- package/lib/module/ui/overlays/RetryDialog.js +121 -0
- package/lib/module/ui/overlays/RetryDialog.js.map +1 -0
- package/lib/module/ui/overlays/index.js +6 -0
- package/lib/module/ui/overlays/index.js.map +1 -0
- package/lib/module/ui/primitives/BackButton.js +71 -0
- package/lib/module/ui/primitives/BackButton.js.map +1 -0
- package/lib/module/ui/primitives/Banner.js +77 -0
- package/lib/module/ui/primitives/Banner.js.map +1 -0
- package/lib/module/ui/primitives/Button.js +138 -0
- package/lib/module/ui/primitives/Button.js.map +1 -0
- package/lib/module/ui/primitives/Card.js +46 -0
- package/lib/module/ui/primitives/Card.js.map +1 -0
- package/lib/module/ui/primitives/Checkbox.js +136 -0
- package/lib/module/ui/primitives/Checkbox.js.map +1 -0
- package/lib/module/ui/primitives/CountrySelect.js +284 -0
- package/lib/module/ui/primitives/CountrySelect.js.map +1 -0
- package/lib/module/ui/primitives/DatePicker.js +241 -0
- package/lib/module/ui/primitives/DatePicker.js.map +1 -0
- package/lib/module/ui/primitives/Input.js +97 -0
- package/lib/module/ui/primitives/Input.js.map +1 -0
- package/lib/module/ui/primitives/SearchableSingleSelectList.js +153 -0
- package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -0
- package/lib/module/ui/primitives/Select.js +205 -0
- package/lib/module/ui/primitives/Select.js.map +1 -0
- package/lib/module/ui/primitives/Spinner.js +21 -0
- package/lib/module/ui/primitives/Spinner.js.map +1 -0
- package/lib/module/ui/primitives/index.js +14 -0
- package/lib/module/ui/primitives/index.js.map +1 -0
- package/lib/module/ui/primitives/searchableSingleSelectFilter.js +27 -0
- package/lib/module/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
- package/lib/module/ui/theme/ThemeProvider.js +67 -0
- package/lib/module/ui/theme/ThemeProvider.js.map +1 -0
- package/lib/module/ui/theme/index.js +5 -0
- package/lib/module/ui/theme/index.js.map +1 -0
- package/lib/module/ui/theme/tokens.js +145 -0
- package/lib/module/ui/theme/tokens.js.map +1 -0
- package/lib/module/utils/EventEmitter.js +139 -0
- package/lib/module/utils/EventEmitter.js.map +1 -0
- package/lib/module/utils/base64.js +47 -0
- package/lib/module/utils/base64.js.map +1 -0
- package/lib/module/utils/deviceFingerprint.js +129 -0
- package/lib/module/utils/deviceFingerprint.js.map +1 -0
- package/lib/module/utils/documentTypeOptions.js +31 -0
- package/lib/module/utils/documentTypeOptions.js.map +1 -0
- package/lib/module/utils/googleMapsPreflight.js +84 -0
- package/lib/module/utils/googleMapsPreflight.js.map +1 -0
- package/lib/module/utils/hmac.js +53 -0
- package/lib/module/utils/hmac.js.map +1 -0
- package/lib/module/utils/iso3166Countries.js +92 -0
- package/lib/module/utils/iso3166Countries.js.map +1 -0
- package/lib/module/utils/jpegFromUri.js +40 -0
- package/lib/module/utils/jpegFromUri.js.map +1 -0
- package/lib/module/utils/keepAwake.js +53 -0
- package/lib/module/utils/keepAwake.js.map +1 -0
- package/lib/module/utils/log.js +37 -0
- package/lib/module/utils/log.js.map +1 -0
- package/lib/module/utils/osGeocoder.js +65 -0
- package/lib/module/utils/osGeocoder.js.map +1 -0
- package/lib/module/utils/parseGoogleAddressComponents.js +69 -0
- package/lib/module/utils/parseGoogleAddressComponents.js.map +1 -0
- package/lib/module/utils/personNameNormalize.js +20 -0
- package/lib/module/utils/personNameNormalize.js.map +1 -0
- package/lib/module/utils/sdkError.js +29 -0
- package/lib/module/utils/sdkError.js.map +1 -0
- package/lib/module/utils/sdkVersion.js +9 -0
- package/lib/module/utils/sdkVersion.js.map +1 -0
- package/lib/module/utils/stepConfig.js +59 -0
- package/lib/module/utils/stepConfig.js.map +1 -0
- package/lib/module/utils/taxInfoConfig.js +15 -0
- package/lib/module/utils/taxInfoConfig.js.map +1 -0
- package/lib/module/utils/useSafeAreaInsets.js +37 -0
- package/lib/module/utils/useSafeAreaInsets.js.map +1 -0
- package/lib/module/utils/velionExtra.js +44 -0
- package/lib/module/utils/velionExtra.js.map +1 -0
- package/lib/typescript/camera/AddressSearchBar.d.ts +37 -0
- package/lib/typescript/camera/AddressSearchBar.d.ts.map +1 -0
- package/lib/typescript/camera/DocumentCapture.d.ts +34 -0
- package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -0
- package/lib/typescript/camera/LivenessCamera.d.ts +67 -0
- package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -0
- package/lib/typescript/camera/MapAddressPicker.d.ts +57 -0
- package/lib/typescript/camera/MapAddressPicker.d.ts.map +1 -0
- package/lib/typescript/core/VelionOnboarding.d.ts +169 -0
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -0
- package/lib/typescript/core/retryStepCopy.d.ts +27 -0
- package/lib/typescript/core/retryStepCopy.d.ts.map +1 -0
- package/lib/typescript/core/routingCommands.d.ts +39 -0
- package/lib/typescript/core/routingCommands.d.ts.map +1 -0
- package/lib/typescript/core/sessionDeclinedCopy.d.ts +16 -0
- package/lib/typescript/core/sessionDeclinedCopy.d.ts.map +1 -0
- package/lib/typescript/core/sessionStateMapper.d.ts +52 -0
- package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -0
- package/lib/typescript/core/sseReasonMessages.d.ts +20 -0
- package/lib/typescript/core/sseReasonMessages.d.ts.map +1 -0
- package/lib/typescript/i18n/index.d.ts +13 -0
- package/lib/typescript/i18n/index.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/en.d.ts +3 -0
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/es.d.ts +297 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +26 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/steps/AddressInfoStep.d.ts +26 -0
- package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/DocumentsOcrStep.d.ts +26 -0
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -0
- package/lib/typescript/steps/EconomicActivityStep.d.ts +29 -0
- package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -0
- package/lib/typescript/steps/EmailContactStep.d.ts +15 -0
- package/lib/typescript/steps/EmailContactStep.d.ts.map +1 -0
- package/lib/typescript/steps/EmailOtpStep.d.ts +21 -0
- package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -0
- package/lib/typescript/steps/FaceMatchStep.d.ts +27 -0
- package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -0
- package/lib/typescript/steps/FingerprintStep.d.ts +25 -0
- package/lib/typescript/steps/FingerprintStep.d.ts.map +1 -0
- package/lib/typescript/steps/HumanBasicInfoStep.d.ts +25 -0
- package/lib/typescript/steps/HumanBasicInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/HumanExtendedInfoStep.d.ts +23 -0
- package/lib/typescript/steps/HumanExtendedInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/LegalBasicInfoStep.d.ts +17 -0
- package/lib/typescript/steps/LegalBasicInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/LegalExtendedInfoStep.d.ts +17 -0
- package/lib/typescript/steps/LegalExtendedInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/LivenessMatchStep.d.ts +26 -0
- package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -0
- package/lib/typescript/steps/PhoneContactStep.d.ts +15 -0
- package/lib/typescript/steps/PhoneContactStep.d.ts.map +1 -0
- package/lib/typescript/steps/PhoneOtpStep.d.ts +19 -0
- package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -0
- package/lib/typescript/steps/SwornDeclarationStep.d.ts +20 -0
- package/lib/typescript/steps/SwornDeclarationStep.d.ts.map +1 -0
- package/lib/typescript/steps/TaxInfoStep.d.ts +19 -0
- package/lib/typescript/steps/TaxInfoStep.d.ts.map +1 -0
- package/lib/typescript/steps/TermsAndConditionsStep.d.ts +21 -0
- package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -0
- package/lib/typescript/steps/_shared.d.ts +22 -0
- package/lib/typescript/steps/_shared.d.ts.map +1 -0
- package/lib/typescript/steps/types.d.ts +89 -0
- package/lib/typescript/steps/types.d.ts.map +1 -0
- package/lib/typescript/transport/api.d.ts +35 -0
- package/lib/typescript/transport/api.d.ts.map +1 -0
- package/lib/typescript/transport/irisWebSocket.d.ts +72 -0
- package/lib/typescript/transport/irisWebSocket.d.ts.map +1 -0
- package/lib/typescript/transport/secureUrl.d.ts +14 -0
- package/lib/typescript/transport/secureUrl.d.ts.map +1 -0
- package/lib/typescript/transport/sse.d.ts +54 -0
- package/lib/typescript/transport/sse.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +1219 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/ui/MapFallbackBoundary.d.ts +28 -0
- package/lib/typescript/ui/MapFallbackBoundary.d.ts.map +1 -0
- package/lib/typescript/ui/StepShell.d.ts +29 -0
- package/lib/typescript/ui/StepShell.d.ts.map +1 -0
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts +26 -0
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -0
- package/lib/typescript/ui/forms/index.d.ts +3 -0
- package/lib/typescript/ui/forms/index.d.ts.map +1 -0
- package/lib/typescript/ui/forms/useInlineValidation.d.ts +30 -0
- package/lib/typescript/ui/forms/useInlineValidation.d.ts.map +1 -0
- package/lib/typescript/ui/forms/validators.d.ts +11 -0
- package/lib/typescript/ui/forms/validators.d.ts.map +1 -0
- package/lib/typescript/ui/icons/HomeHeartIcon.d.ts +14 -0
- package/lib/typescript/ui/icons/HomeHeartIcon.d.ts.map +1 -0
- package/lib/typescript/ui/icons/StepIcon.d.ts +26 -0
- package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -0
- package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts +24 -0
- package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts.map +1 -0
- package/lib/typescript/ui/overlays/LoadingOverlay.d.ts +19 -0
- package/lib/typescript/ui/overlays/LoadingOverlay.d.ts.map +1 -0
- package/lib/typescript/ui/overlays/ProgressBar.d.ts +32 -0
- package/lib/typescript/ui/overlays/ProgressBar.d.ts.map +1 -0
- package/lib/typescript/ui/overlays/RetryDialog.d.ts +17 -0
- package/lib/typescript/ui/overlays/RetryDialog.d.ts.map +1 -0
- package/lib/typescript/ui/overlays/index.d.ts +4 -0
- package/lib/typescript/ui/overlays/index.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/BackButton.d.ts +20 -0
- package/lib/typescript/ui/primitives/BackButton.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Banner.d.ts +11 -0
- package/lib/typescript/ui/primitives/Banner.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Button.d.ts +27 -0
- package/lib/typescript/ui/primitives/Button.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Card.d.ts +10 -0
- package/lib/typescript/ui/primitives/Card.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Checkbox.d.ts +25 -0
- package/lib/typescript/ui/primitives/Checkbox.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/CountrySelect.d.ts +31 -0
- package/lib/typescript/ui/primitives/CountrySelect.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/DatePicker.d.ts +42 -0
- package/lib/typescript/ui/primitives/DatePicker.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Input.d.ts +17 -0
- package/lib/typescript/ui/primitives/Input.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts +33 -0
- package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Select.d.ts +26 -0
- package/lib/typescript/ui/primitives/Select.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Spinner.d.ts +10 -0
- package/lib/typescript/ui/primitives/Spinner.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/index.d.ts +12 -0
- package/lib/typescript/ui/primitives/index.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts +25 -0
- package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts.map +1 -0
- package/lib/typescript/ui/theme/ThemeProvider.d.ts +23 -0
- package/lib/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/ui/theme/index.d.ts +3 -0
- package/lib/typescript/ui/theme/index.d.ts.map +1 -0
- package/lib/typescript/ui/theme/tokens.d.ts +42 -0
- package/lib/typescript/ui/theme/tokens.d.ts.map +1 -0
- package/lib/typescript/utils/EventEmitter.d.ts +98 -0
- package/lib/typescript/utils/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/utils/base64.d.ts +19 -0
- package/lib/typescript/utils/base64.d.ts.map +1 -0
- package/lib/typescript/utils/deviceFingerprint.d.ts +42 -0
- package/lib/typescript/utils/deviceFingerprint.d.ts.map +1 -0
- package/lib/typescript/utils/documentTypeOptions.d.ts +13 -0
- package/lib/typescript/utils/documentTypeOptions.d.ts.map +1 -0
- package/lib/typescript/utils/googleMapsPreflight.d.ts +52 -0
- package/lib/typescript/utils/googleMapsPreflight.d.ts.map +1 -0
- package/lib/typescript/utils/hmac.d.ts +39 -0
- package/lib/typescript/utils/hmac.d.ts.map +1 -0
- package/lib/typescript/utils/iso3166Countries.d.ts +27 -0
- package/lib/typescript/utils/iso3166Countries.d.ts.map +1 -0
- package/lib/typescript/utils/jpegFromUri.d.ts +29 -0
- package/lib/typescript/utils/jpegFromUri.d.ts.map +1 -0
- package/lib/typescript/utils/keepAwake.d.ts +16 -0
- package/lib/typescript/utils/keepAwake.d.ts.map +1 -0
- package/lib/typescript/utils/log.d.ts +18 -0
- package/lib/typescript/utils/log.d.ts.map +1 -0
- package/lib/typescript/utils/osGeocoder.d.ts +38 -0
- package/lib/typescript/utils/osGeocoder.d.ts.map +1 -0
- package/lib/typescript/utils/parseGoogleAddressComponents.d.ts +43 -0
- package/lib/typescript/utils/parseGoogleAddressComponents.d.ts.map +1 -0
- package/lib/typescript/utils/personNameNormalize.d.ts +10 -0
- package/lib/typescript/utils/personNameNormalize.d.ts.map +1 -0
- package/lib/typescript/utils/sdkError.d.ts +14 -0
- package/lib/typescript/utils/sdkError.d.ts.map +1 -0
- package/lib/typescript/utils/sdkVersion.d.ts +7 -0
- package/lib/typescript/utils/sdkVersion.d.ts.map +1 -0
- package/lib/typescript/utils/stepConfig.d.ts +8 -0
- package/lib/typescript/utils/stepConfig.d.ts.map +1 -0
- package/lib/typescript/utils/taxInfoConfig.d.ts +7 -0
- package/lib/typescript/utils/taxInfoConfig.d.ts.map +1 -0
- package/lib/typescript/utils/useSafeAreaInsets.d.ts +26 -0
- package/lib/typescript/utils/useSafeAreaInsets.d.ts.map +1 -0
- package/lib/typescript/utils/velionExtra.d.ts +24 -0
- package/lib/typescript/utils/velionExtra.d.ts.map +1 -0
- package/package.json +107 -0
- package/src/camera/AddressSearchBar.tsx +363 -0
- package/src/camera/DocumentCapture.tsx +514 -0
- package/src/camera/LivenessCamera.tsx +706 -0
- package/src/camera/MapAddressPicker.tsx +391 -0
- package/src/core/VelionOnboarding.ts +1291 -0
- package/src/core/retryStepCopy.ts +54 -0
- package/src/core/routingCommands.ts +63 -0
- package/src/core/sessionDeclinedCopy.ts +76 -0
- package/src/core/sessionStateMapper.ts +232 -0
- package/src/core/sseReasonMessages.ts +531 -0
- package/src/data/iso3166Alpha2Codes.json +1 -0
- package/src/data/iso3166CountryNames.json +251 -0
- package/src/i18n/index.ts +26 -0
- package/src/i18n/strings/en.ts +335 -0
- package/src/i18n/strings/es.ts +337 -0
- package/src/index.ts +146 -0
- package/src/steps/AddressInfoStep.tsx +744 -0
- package/src/steps/DocumentsOcrStep.tsx +481 -0
- package/src/steps/EconomicActivityStep.tsx +230 -0
- package/src/steps/EmailContactStep.tsx +165 -0
- package/src/steps/EmailOtpStep.tsx +256 -0
- package/src/steps/FaceMatchStep.tsx +176 -0
- package/src/steps/FingerprintStep.tsx +99 -0
- package/src/steps/HumanBasicInfoStep.tsx +286 -0
- package/src/steps/HumanExtendedInfoStep.tsx +362 -0
- package/src/steps/LegalBasicInfoStep.tsx +214 -0
- package/src/steps/LegalExtendedInfoStep.tsx +184 -0
- package/src/steps/LivenessMatchStep.tsx +1351 -0
- package/src/steps/PhoneContactStep.tsx +166 -0
- package/src/steps/PhoneOtpStep.tsx +255 -0
- package/src/steps/SwornDeclarationStep.tsx +237 -0
- package/src/steps/TaxInfoStep.tsx +288 -0
- package/src/steps/TermsAndConditionsStep.tsx +269 -0
- package/src/steps/_shared.ts +69 -0
- package/src/steps/types.ts +93 -0
- package/src/transport/api.ts +257 -0
- package/src/transport/irisWebSocket.ts +186 -0
- package/src/transport/secureUrl.ts +47 -0
- package/src/transport/sse.ts +310 -0
- package/src/types/index.ts +1421 -0
- package/src/ui/MapFallbackBoundary.tsx +46 -0
- package/src/ui/StepShell.tsx +273 -0
- package/src/ui/VelionOnboardingScreen.tsx +297 -0
- package/src/ui/forms/index.ts +12 -0
- package/src/ui/forms/useInlineValidation.ts +115 -0
- package/src/ui/forms/validators.ts +29 -0
- package/src/ui/icons/HomeHeartIcon.tsx +34 -0
- package/src/ui/icons/StepIcon.tsx +78 -0
- package/src/ui/overlays/AnalyzingOverlay.tsx +323 -0
- package/src/ui/overlays/LoadingOverlay.tsx +115 -0
- package/src/ui/overlays/ProgressBar.tsx +106 -0
- package/src/ui/overlays/RetryDialog.tsx +128 -0
- package/src/ui/overlays/index.ts +3 -0
- package/src/ui/primitives/BackButton.tsx +65 -0
- package/src/ui/primitives/Banner.tsx +81 -0
- package/src/ui/primitives/Button.tsx +164 -0
- package/src/ui/primitives/Card.tsx +55 -0
- package/src/ui/primitives/Checkbox.tsx +153 -0
- package/src/ui/primitives/CountrySelect.tsx +356 -0
- package/src/ui/primitives/DatePicker.tsx +266 -0
- package/src/ui/primitives/Input.tsx +110 -0
- package/src/ui/primitives/SearchableSingleSelectList.tsx +195 -0
- package/src/ui/primitives/Select.tsx +259 -0
- package/src/ui/primitives/Spinner.tsx +17 -0
- package/src/ui/primitives/index.ts +16 -0
- package/src/ui/primitives/searchableSingleSelectFilter.ts +38 -0
- package/src/ui/theme/ThemeProvider.tsx +102 -0
- package/src/ui/theme/index.ts +17 -0
- package/src/ui/theme/tokens.ts +159 -0
- package/src/utils/EventEmitter.ts +155 -0
- package/src/utils/base64.ts +44 -0
- package/src/utils/deviceFingerprint.ts +184 -0
- package/src/utils/documentTypeOptions.ts +31 -0
- package/src/utils/googleMapsPreflight.ts +89 -0
- package/src/utils/hmac.ts +61 -0
- package/src/utils/iso3166Countries.ts +111 -0
- package/src/utils/jpegFromUri.ts +42 -0
- package/src/utils/keepAwake.ts +62 -0
- package/src/utils/log.ts +37 -0
- package/src/utils/osGeocoder.ts +75 -0
- package/src/utils/parseGoogleAddressComponents.ts +123 -0
- package/src/utils/personNameNormalize.ts +17 -0
- package/src/utils/sdkError.ts +40 -0
- package/src/utils/sdkVersion.ts +6 -0
- package/src/utils/stepConfig.ts +75 -0
- package/src/utils/taxInfoConfig.ts +14 -0
- package/src/utils/useSafeAreaInsets.ts +37 -0
- package/src/utils/velionExtra.ts +46 -0
|
@@ -0,0 +1,1113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VelionOnboarding = void 0;
|
|
7
|
+
var _EventEmitter = require("../utils/EventEmitter");
|
|
8
|
+
var _api = require("../transport/api");
|
|
9
|
+
var _log = require("../utils/log");
|
|
10
|
+
var _velionExtra = require("../utils/velionExtra");
|
|
11
|
+
var _sessionStateMapper = require("./sessionStateMapper");
|
|
12
|
+
var _sse = require("../transport/sse");
|
|
13
|
+
var _sessionDeclinedCopy = require("./sessionDeclinedCopy");
|
|
14
|
+
var _retryStepCopy = require("./retryStepCopy");
|
|
15
|
+
var _routingCommands = require("./routingCommands");
|
|
16
|
+
var _FingerprintStep = require("../steps/FingerprintStep");
|
|
17
|
+
var _HumanBasicInfoStep = require("../steps/HumanBasicInfoStep");
|
|
18
|
+
var _EmailContactStep = require("../steps/EmailContactStep");
|
|
19
|
+
var _PhoneContactStep = require("../steps/PhoneContactStep");
|
|
20
|
+
var _EmailOtpStep = require("../steps/EmailOtpStep");
|
|
21
|
+
var _PhoneOtpStep = require("../steps/PhoneOtpStep");
|
|
22
|
+
var _TaxInfoStep = require("../steps/TaxInfoStep");
|
|
23
|
+
var _SwornDeclarationStep = require("../steps/SwornDeclarationStep");
|
|
24
|
+
var _EconomicActivityStep = require("../steps/EconomicActivityStep");
|
|
25
|
+
var _TermsAndConditionsStep = require("../steps/TermsAndConditionsStep");
|
|
26
|
+
var _LegalBasicInfoStep = require("../steps/LegalBasicInfoStep");
|
|
27
|
+
var _HumanExtendedInfoStep = require("../steps/HumanExtendedInfoStep");
|
|
28
|
+
var _LegalExtendedInfoStep = require("../steps/LegalExtendedInfoStep");
|
|
29
|
+
var _AddressInfoStep = require("../steps/AddressInfoStep");
|
|
30
|
+
var _DocumentsOcrStep = require("../steps/DocumentsOcrStep");
|
|
31
|
+
var _LivenessMatchStep = require("../steps/LivenessMatchStep");
|
|
32
|
+
var _FaceMatchStep = require("../steps/FaceMatchStep");
|
|
33
|
+
var _types = require("../types");
|
|
34
|
+
var _react = require("react");
|
|
35
|
+
var _RetryDialog = require("../ui/overlays/RetryDialog");
|
|
36
|
+
/**
|
|
37
|
+
* @fileoverview VelionOnboarding — orchestrator for the React Native SDK.
|
|
38
|
+
*
|
|
39
|
+
* Platform-agnostic dynamic state machine: deals with HTTP, SSE, dedupe and
|
|
40
|
+
* step-module orchestration. UI mounting is delegated to a React component
|
|
41
|
+
* (`VelionOnboardingScreen`) instead of direct DOM manipulation.
|
|
42
|
+
*
|
|
43
|
+
* Invariants:
|
|
44
|
+
* - SSE dedupe by `event_id` (monotonic)
|
|
45
|
+
* - Suppress duplicate `NEXT_STEP` for the just-completed step
|
|
46
|
+
* - `RETRY_STEP` shows a retry dialog (Retry re-mounts the step, Cancel exits);
|
|
47
|
+
* once the retry quota is exhausted the backend emits SESSION_DECLINED instead
|
|
48
|
+
* - 45 s watchdog for terminal SSE event after final step → fallback GET
|
|
49
|
+
* - SESSION_DECLINED handling races with module.run()
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
53
|
+
// PUBLIC CONFIG (RN flavor)
|
|
54
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* RN-specific config. Drops web-only fields (`containerId`, `allowEmbedded`,
|
|
58
|
+
* `iframeParentOrigin`) and keeps everything else identical to
|
|
59
|
+
* `WebVelionConfig`, including `fingerprintEndpoint` and `fingerprintApiKey`
|
|
60
|
+
* — both are honoured by the native Fingerprint Pro SDK on mobile too.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
64
|
+
// INTERNAL CONTRACTS
|
|
65
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
/** Result of awaiting an active step module (see {@link VelionOnboarding.awaitModuleOutcome}). */
|
|
68
|
+
|
|
69
|
+
const BACKEND_ONLY_ORCHESTRATED_STEPS = new Set(['FACE_MATCH', 'AML_SCREENING']);
|
|
70
|
+
const DEFAULT_API_URL = 'https://sdk.velion.la/onboarding';
|
|
71
|
+
function isBackendOnlyOrchestratedStep(step) {
|
|
72
|
+
if (typeof step !== 'string' || step.trim() === '') return false;
|
|
73
|
+
return BACKEND_ONLY_ORCHESTRATED_STEPS.has(step.trim().toUpperCase());
|
|
74
|
+
}
|
|
75
|
+
function isTerminalSessionEvent(event) {
|
|
76
|
+
const t = event.event_type;
|
|
77
|
+
return t === 'SESSION_APPROVED' || t === 'SESSION_MANUAL_REVIEW' || t === 'SESSION_DECLINED' || t === 'SESSION_TERMINATED';
|
|
78
|
+
}
|
|
79
|
+
function terminalEventTypeToStatus(eventType) {
|
|
80
|
+
switch (eventType) {
|
|
81
|
+
case 'SESSION_APPROVED':
|
|
82
|
+
return 'APPROVED';
|
|
83
|
+
case 'SESSION_MANUAL_REVIEW':
|
|
84
|
+
return 'MANUAL_REVIEW';
|
|
85
|
+
case 'SESSION_DECLINED':
|
|
86
|
+
return 'DECLINED';
|
|
87
|
+
case 'SESSION_TERMINATED':
|
|
88
|
+
return 'REJECTED';
|
|
89
|
+
default:
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function isSessionTokenAuthSdkError(err) {
|
|
94
|
+
return err != null && typeof err === 'object' && err.code === _types.SdkErrorCode.SESSION_EXPIRED;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
98
|
+
// PUBLIC: ORCHESTRATOR
|
|
99
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Optional view bridge given to the orchestrator by `VelionOnboardingScreen`.
|
|
103
|
+
*
|
|
104
|
+
* The orchestrator never reads from this — it only writes:
|
|
105
|
+
* - `setLoading(text)` to display a status message between steps
|
|
106
|
+
* - `setStepNode(node)` to mount the active step's UI
|
|
107
|
+
* - `setError(err)` to surface a fatal error
|
|
108
|
+
* - `setResult(result)` on flow completion (host may show their own result)
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Top-level entry point. Instantiate once per session, call `start()`, and
|
|
113
|
+
* `destroy()` from the host's unmount path.
|
|
114
|
+
*/
|
|
115
|
+
class VelionOnboarding {
|
|
116
|
+
emitter = new _EventEmitter.TypedEventEmitter();
|
|
117
|
+
status = 'IDLE';
|
|
118
|
+
activeModule = null;
|
|
119
|
+
view = {};
|
|
120
|
+
uiHandle = {
|
|
121
|
+
setNode: node => this.view.setStepNode?.(node)
|
|
122
|
+
};
|
|
123
|
+
initAbortController = new AbortController();
|
|
124
|
+
sseAbortController = new AbortController();
|
|
125
|
+
sseCleanup = null;
|
|
126
|
+
sseTerminalResolve = null;
|
|
127
|
+
sseNextStepResolve = null;
|
|
128
|
+
queuedNextStepCommand = null;
|
|
129
|
+
lastSseEventId = '0';
|
|
130
|
+
previousStepResolve = null;
|
|
131
|
+
queuedPreviousStepCommand = null;
|
|
132
|
+
backExitResolve = null;
|
|
133
|
+
queuedBackExitStep = null;
|
|
134
|
+
backRequestInFlight = false;
|
|
135
|
+
|
|
136
|
+
/** Resolver for the in-flight retry dialog (RETRY_STEP), cleared on destroy. */
|
|
137
|
+
retryDialogResolve = null;
|
|
138
|
+
|
|
139
|
+
/** Per-step reversibility (workflow order) cached from the initial GET, used to
|
|
140
|
+
* derive `can_go_back` for steps reached via SSE (which doesn't carry it). */
|
|
141
|
+
stepReversibility = [];
|
|
142
|
+
sessionDeclineHandler = null;
|
|
143
|
+
pendingSessionDeclined = null;
|
|
144
|
+
pendingTerminalEvent = null;
|
|
145
|
+
sessionEnded = false;
|
|
146
|
+
constructor(config) {
|
|
147
|
+
const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
|
|
148
|
+
this.config = Object.freeze({
|
|
149
|
+
...config,
|
|
150
|
+
apiUrl
|
|
151
|
+
});
|
|
152
|
+
if (this.config.debug === true) (0, _log.setDebugEnabled)(true);
|
|
153
|
+
let api;
|
|
154
|
+
let constructionError = null;
|
|
155
|
+
try {
|
|
156
|
+
api = (0, _api.createApiCaller)(apiUrl, config.sessionToken, config.expiresAt);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
constructionError = err;
|
|
159
|
+
// Provide a safe-but-unused caller so typed code paths don't crash.
|
|
160
|
+
api = (0, _api.createApiCaller)('https://invalid.velion.invalid', config.sessionToken, config.expiresAt);
|
|
161
|
+
}
|
|
162
|
+
this.api = api;
|
|
163
|
+
this.constructionError = constructionError;
|
|
164
|
+
this.wireExternalCallbacks();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Connects an `OrchestratorView` (typically `VelionOnboardingScreen`). */
|
|
168
|
+
attachView(view) {
|
|
169
|
+
this.view = view;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Detaches the active view (called from screen unmount). */
|
|
173
|
+
detachView() {
|
|
174
|
+
this.view = {};
|
|
175
|
+
}
|
|
176
|
+
on(event, listener) {
|
|
177
|
+
return this.emitter.on(event, listener);
|
|
178
|
+
}
|
|
179
|
+
getStatus() {
|
|
180
|
+
return this.status;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Hot-rotate the bearer token used by every subsequent backend call. The SSE
|
|
185
|
+
* stream is also reopened so the new token reaches the server-side authenticator.
|
|
186
|
+
*/
|
|
187
|
+
refreshSessionToken(token, expiresAt) {
|
|
188
|
+
if (this.status === 'DESTROYED') return;
|
|
189
|
+
this.api.setSessionToken(token, expiresAt);
|
|
190
|
+
if (this.sseCleanup) {
|
|
191
|
+
_log.log.info('[Flow] Reopening SSE after session token rotation');
|
|
192
|
+
this.sseCleanup();
|
|
193
|
+
this.sseAbortController.abort();
|
|
194
|
+
this.sseAbortController = new AbortController();
|
|
195
|
+
this.openSseStream(token);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async start() {
|
|
199
|
+
if (this.status === 'DESTROYED') {
|
|
200
|
+
this.emitError({
|
|
201
|
+
code: _types.SdkErrorCode.INSTANCE_DESTROYED,
|
|
202
|
+
message: 'This VelionOnboarding instance has been destroyed. Create a new instance to retry.'
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (this.status !== 'IDLE') {
|
|
207
|
+
this.emitError({
|
|
208
|
+
code: _types.SdkErrorCode.ALREADY_STARTED,
|
|
209
|
+
message: 'start() was called on an already-running SDK instance. Call destroy() before re-starting.'
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this.constructionError) {
|
|
214
|
+
this.emitError(this.constructionError);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
await this.initialize();
|
|
219
|
+
} catch (err) {
|
|
220
|
+
this.emitError(err);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
destroy() {
|
|
224
|
+
if (this.status === 'DESTROYED') return;
|
|
225
|
+
this.setStatus('DESTROYED');
|
|
226
|
+
this.initAbortController.abort();
|
|
227
|
+
this.sseCleanup?.();
|
|
228
|
+
this.sseAbortController.abort();
|
|
229
|
+
this.activeModule?.destroy();
|
|
230
|
+
this.activeModule = null;
|
|
231
|
+
this.view.setStepNode?.(null);
|
|
232
|
+
this.view.setLoading?.(null);
|
|
233
|
+
this.emitter.removeAllListeners();
|
|
234
|
+
this.sessionDeclineHandler = null;
|
|
235
|
+
this.pendingSessionDeclined = null;
|
|
236
|
+
this.previousStepResolve = null;
|
|
237
|
+
this.queuedPreviousStepCommand = null;
|
|
238
|
+
this.backExitResolve = null;
|
|
239
|
+
this.queuedBackExitStep = null;
|
|
240
|
+
this.retryDialogResolve = null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ── Initialization ────────────────────────────────────────────────────────
|
|
244
|
+
|
|
245
|
+
async initialize() {
|
|
246
|
+
this.setStatus('INITIALIZING');
|
|
247
|
+
this.showLoading(this.localizedLoadingMsg());
|
|
248
|
+
let dto;
|
|
249
|
+
try {
|
|
250
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
|
|
251
|
+
signal: this.initAbortController.signal,
|
|
252
|
+
extraHeaders: {
|
|
253
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
254
|
+
Pragma: 'no-cache'
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
} catch (err) {
|
|
258
|
+
this.showLoading(null);
|
|
259
|
+
if (isSessionTokenAuthSdkError(err)) {
|
|
260
|
+
throw err;
|
|
261
|
+
}
|
|
262
|
+
throw {
|
|
263
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
264
|
+
message: `Failed to fetch session for sessionId="${this.config.sessionId}". Verify the apiUrl and sessionToken are correct.`,
|
|
265
|
+
cause: err
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const sessionState = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
|
|
269
|
+
// Cache the workflow reversibility map so the "back" control can be resolved
|
|
270
|
+
// for steps reached via SSE (which doesn't carry `can_go_back`).
|
|
271
|
+
this.stepReversibility = sessionState.stepReversibility ?? [];
|
|
272
|
+
this.emitter.emit('session:loaded', sessionState);
|
|
273
|
+
if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
|
|
274
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
|
|
275
|
+
this.completeFlow(result);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
this.validateSessionState(dto, sessionState);
|
|
279
|
+
this.sseAbortController = new AbortController();
|
|
280
|
+
this.openSseStream(this.config.sessionToken);
|
|
281
|
+
this.setStatus('RUNNING');
|
|
282
|
+
await this.runStepMachine(sessionState);
|
|
283
|
+
}
|
|
284
|
+
validateSessionState(dto, state) {
|
|
285
|
+
if ((0, _sessionStateMapper.requiresCurrentStepForSessionStatus)(dto.status) && !state.currentStep) {
|
|
286
|
+
throw {
|
|
287
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
288
|
+
message: `Session ${this.config.sessionId} reports status="${dto.status}" but no current_step. Backend payload is incomplete.`
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ── Step Machine ──────────────────────────────────────────────────────────
|
|
294
|
+
|
|
295
|
+
async runStepMachine(sessionState) {
|
|
296
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
297
|
+
if (this.pendingSessionDeclined) {
|
|
298
|
+
const ev = this.pendingSessionDeclined;
|
|
299
|
+
this.pendingSessionDeclined = null;
|
|
300
|
+
this.endFlowWithSessionDeclined(ev);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
let index = 0;
|
|
304
|
+
let currentStep = sessionState.currentStep;
|
|
305
|
+
let currentStepConfig = sessionState.currentStepConfig;
|
|
306
|
+
let currentStepResult = sessionState.currentStepResult;
|
|
307
|
+
let currentCanGoBack = currentStep ? this.resolveCanGoBack(sessionState.canGoBack, currentStep) : false;
|
|
308
|
+
const knownStepConfigs = {
|
|
309
|
+
...(sessionState.stepConfigs ?? {})
|
|
310
|
+
};
|
|
311
|
+
if (currentStep && isBackendOnlyOrchestratedStep(currentStep)) {
|
|
312
|
+
this.showLoading(this.localizedProcessingMsg());
|
|
313
|
+
try {
|
|
314
|
+
const outcome = await this.withSessionDeclineRace(this.waitForRoutingAfterBackendOnlyStep());
|
|
315
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
316
|
+
if (outcome.declined) {
|
|
317
|
+
this.endFlowWithSessionDeclined(outcome.event);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const routed = outcome.value;
|
|
321
|
+
if (!routed?.step) {
|
|
322
|
+
throw {
|
|
323
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
324
|
+
message: `Timed out waiting for ROUTING_COMMAND while the session was on a backend-only step (${String(currentStep)}).`
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
currentStep = routed.step;
|
|
328
|
+
currentStepConfig = routed.stepConfig;
|
|
329
|
+
currentStepResult = undefined;
|
|
330
|
+
currentCanGoBack = this.resolveCanGoBack(routed.canGoBack, routed.step);
|
|
331
|
+
} finally {
|
|
332
|
+
this.showLoading(null);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
while (currentStep) {
|
|
336
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
337
|
+
if (this.pendingSessionDeclined) {
|
|
338
|
+
const ev = this.pendingSessionDeclined;
|
|
339
|
+
this.pendingSessionDeclined = null;
|
|
340
|
+
this.endFlowWithSessionDeclined(ev);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.setStatus('STEP_PROCESSING');
|
|
344
|
+
this.emitter.emit('step:change', {
|
|
345
|
+
step: currentStep,
|
|
346
|
+
index
|
|
347
|
+
});
|
|
348
|
+
if (currentStepConfig) {
|
|
349
|
+
knownStepConfigs[currentStep] = currentStepConfig;
|
|
350
|
+
}
|
|
351
|
+
const module = this.createModule(currentStep, currentStepConfig, currentStepResult, currentCanGoBack);
|
|
352
|
+
this.activeModule = module;
|
|
353
|
+
let outcome;
|
|
354
|
+
try {
|
|
355
|
+
outcome = await this.awaitModuleOutcome(module.run());
|
|
356
|
+
} catch (err) {
|
|
357
|
+
module.destroy();
|
|
358
|
+
this.activeModule = null;
|
|
359
|
+
throw err;
|
|
360
|
+
}
|
|
361
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
362
|
+
module.destroy();
|
|
363
|
+
this.activeModule = null;
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (outcome.kind === 'declined') {
|
|
367
|
+
module.destroy();
|
|
368
|
+
this.activeModule = null;
|
|
369
|
+
this.endFlowWithSessionDeclined(outcome.event);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (outcome.kind === 'back') {
|
|
373
|
+
// Reverse navigation: tear down the active form and re-enter the loop on
|
|
374
|
+
// the re-opened step with its previous data as prefill. Do NOT advance
|
|
375
|
+
// the index nor emit step:complete — the step was not completed.
|
|
376
|
+
module.destroy();
|
|
377
|
+
this.activeModule = null;
|
|
378
|
+
this.view.setStepNode?.(null);
|
|
379
|
+
const command = outcome.command;
|
|
380
|
+
currentStep = command.step;
|
|
381
|
+
currentStepConfig = command.stepConfig ?? knownStepConfigs[command.step];
|
|
382
|
+
currentStepResult = command.stepResult;
|
|
383
|
+
currentCanGoBack = this.resolveCanGoBack(command.canGoBack, command.step);
|
|
384
|
+
this.showLoading(this.localizedLoadingMsg());
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (outcome.kind === 'exit') {
|
|
388
|
+
// Back on the first reversible step: there is no earlier step, so the
|
|
389
|
+
// backend told us to leave. Tear down and hand control back to the host.
|
|
390
|
+
module.destroy();
|
|
391
|
+
this.activeModule = null;
|
|
392
|
+
this.exitFlow(outcome.step);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
module.destroy();
|
|
396
|
+
this.activeModule = null;
|
|
397
|
+
this.view.setStepNode?.(null);
|
|
398
|
+
this.emitter.emit('step:complete', {
|
|
399
|
+
step: currentStep
|
|
400
|
+
});
|
|
401
|
+
this.setStatus('RUNNING');
|
|
402
|
+
index += 1;
|
|
403
|
+
this.showLoading('');
|
|
404
|
+
let next;
|
|
405
|
+
try {
|
|
406
|
+
const nextOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
|
|
407
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
408
|
+
this.showLoading(null);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (nextOutcome.declined) {
|
|
412
|
+
this.endFlowWithSessionDeclined(nextOutcome.event);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
next = nextOutcome.value;
|
|
416
|
+
} catch (err) {
|
|
417
|
+
this.showLoading(null);
|
|
418
|
+
throw err;
|
|
419
|
+
}
|
|
420
|
+
while (next?.step && next.action === 'NEXT_STEP' && next.step === currentStep) {
|
|
421
|
+
_log.log.warn('[Flow] Dropping duplicate NEXT_STEP for just-completed step', {
|
|
422
|
+
step: currentStep
|
|
423
|
+
});
|
|
424
|
+
const retryOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
|
|
425
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
426
|
+
this.showLoading(null);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (retryOutcome.declined) {
|
|
430
|
+
this.endFlowWithSessionDeclined(retryOutcome.event);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
next = retryOutcome.value;
|
|
434
|
+
}
|
|
435
|
+
if (next?.step) {
|
|
436
|
+
this.showLoading(null);
|
|
437
|
+
}
|
|
438
|
+
if (!next?.step) break;
|
|
439
|
+
|
|
440
|
+
// RETRY_STEP: the step failed but the retry quota is not exhausted. Show a
|
|
441
|
+
// retry dialog before re-presenting the step. "Retry" re-mounts the same
|
|
442
|
+
// step for a fresh submit; "Cancel" exits the flow cleanly (no verdict).
|
|
443
|
+
// When the quota IS exhausted the backend emits SESSION_DECLINED instead,
|
|
444
|
+
// so this dialog never shows for the final attempt.
|
|
445
|
+
if (next.action === 'RETRY_STEP') {
|
|
446
|
+
const choice = await this.presentRetryStepDialog(next.step);
|
|
447
|
+
if (this.sessionEnded || this.status === 'DESTROYED') return;
|
|
448
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
449
|
+
if (this.pendingSessionDeclined) {
|
|
450
|
+
const ev = this.pendingSessionDeclined;
|
|
451
|
+
this.pendingSessionDeclined = null;
|
|
452
|
+
this.endFlowWithSessionDeclined(ev);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (choice === 'cancel') {
|
|
456
|
+
this.exitFlow(next.step, 'RETRY_CANCELLED');
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
this.showLoading(this.localizedLoadingMsg());
|
|
460
|
+
}
|
|
461
|
+
currentStep = next.step;
|
|
462
|
+
currentStepConfig = next.stepConfig ?? knownStepConfigs[next.step];
|
|
463
|
+
// Forward navigation: no prefill. `can_go_back` comes from the command
|
|
464
|
+
// when the backend sends it, else derived from the reversibility map.
|
|
465
|
+
currentStepResult = undefined;
|
|
466
|
+
currentCanGoBack = this.resolveCanGoBack(next.canGoBack, next.step);
|
|
467
|
+
}
|
|
468
|
+
this.showLoading(this.localizedFinalizingMsg());
|
|
469
|
+
try {
|
|
470
|
+
if (this.pendingSessionDeclined) {
|
|
471
|
+
const ev = this.pendingSessionDeclined;
|
|
472
|
+
this.pendingSessionDeclined = null;
|
|
473
|
+
this.endFlowWithSessionDeclined(ev);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
477
|
+
const terminalOutcome = await this.withSessionDeclineRace(this.waitForTerminalSseEvent(45_000));
|
|
478
|
+
if (terminalOutcome.declined) {
|
|
479
|
+
this.endFlowWithSessionDeclined(terminalOutcome.event);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const terminalEvent = terminalOutcome.value;
|
|
483
|
+
if (terminalEvent) {
|
|
484
|
+
await this.finalizeSessionWithTerminalEvent(terminalEvent);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
await this.finalizeSessionSingleGet();
|
|
488
|
+
} finally {
|
|
489
|
+
this.showLoading(null);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
createModule(step, stepConfig, stepResult, canGoBack) {
|
|
493
|
+
const deps = {
|
|
494
|
+
api: this.api,
|
|
495
|
+
sessionId: this.config.sessionId,
|
|
496
|
+
locale: this.config.locale ?? 'es',
|
|
497
|
+
colorMode: this.config.colorMode ?? 'light',
|
|
498
|
+
ui: this.uiHandle,
|
|
499
|
+
step,
|
|
500
|
+
...(stepConfig !== undefined && {
|
|
501
|
+
stepConfig
|
|
502
|
+
}),
|
|
503
|
+
...(stepResult !== undefined && {
|
|
504
|
+
stepResult
|
|
505
|
+
}),
|
|
506
|
+
// Reverse navigation: wire the "back" control only when the backend says
|
|
507
|
+
// the user can go back from this step (`can_go_back`). The orchestrator
|
|
508
|
+
// owns the POST + SSE handshake; the step only triggers it.
|
|
509
|
+
...(canGoBack === true && {
|
|
510
|
+
onBack: () => this.requestBackNavigation(step)
|
|
511
|
+
}),
|
|
512
|
+
// Map key fallback chain:
|
|
513
|
+
// 1. `VelionConfig.googleMapsApiKey` (runtime override; takes precedence
|
|
514
|
+
// so hosts that already inject it via JS keep working).
|
|
515
|
+
// 2. `expoConfig.extra.velionGoogleMapsApiKey`, written by the SDK's
|
|
516
|
+
// Expo config plugin (`app.plugin.js`) during prebuild. This is the
|
|
517
|
+
// one-place-to-set-it path documented in the README.
|
|
518
|
+
...(() => {
|
|
519
|
+
const fromConfig = this.config.googleMapsApiKey;
|
|
520
|
+
const resolved = typeof fromConfig === 'string' && fromConfig.trim().length > 0 ? fromConfig : (0, _velionExtra.getGoogleMapsApiKeyFromExpoExtra)();
|
|
521
|
+
return resolved !== undefined ? {
|
|
522
|
+
googleMapsApiKey: resolved
|
|
523
|
+
} : {};
|
|
524
|
+
})(),
|
|
525
|
+
...(this.config.fingerprintEndpoint !== undefined && {
|
|
526
|
+
fingerprintEndpoint: this.config.fingerprintEndpoint
|
|
527
|
+
}),
|
|
528
|
+
...(this.config.fingerprintApiKey !== undefined && {
|
|
529
|
+
fingerprintApiKey: this.config.fingerprintApiKey
|
|
530
|
+
}),
|
|
531
|
+
...(this.config.fingerprintTimeoutMs !== undefined && {
|
|
532
|
+
fingerprintTimeoutMs: this.config.fingerprintTimeoutMs
|
|
533
|
+
}),
|
|
534
|
+
...(this.config.livenessCalibrationLabel !== undefined && {
|
|
535
|
+
livenessCalibrationLabel: this.config.livenessCalibrationLabel
|
|
536
|
+
}),
|
|
537
|
+
...(this.config.onLivenessVideoUploaded !== undefined && {
|
|
538
|
+
onLivenessVideoUploaded: this.config.onLivenessVideoUploaded
|
|
539
|
+
})
|
|
540
|
+
};
|
|
541
|
+
switch (step) {
|
|
542
|
+
case 'DEVICE_FINGERPRINT':
|
|
543
|
+
return new _FingerprintStep.FingerprintStep(deps);
|
|
544
|
+
case 'HUMAN_BASIC_INFO':
|
|
545
|
+
return new _HumanBasicInfoStep.HumanBasicInfoStep(deps);
|
|
546
|
+
case 'EMAIL_CONTACT':
|
|
547
|
+
return new _EmailContactStep.EmailContactStep(deps);
|
|
548
|
+
case 'PHONE_CONTACT':
|
|
549
|
+
return new _PhoneContactStep.PhoneContactStep(deps);
|
|
550
|
+
case 'EMAIL_OTP':
|
|
551
|
+
return new _EmailOtpStep.EmailOtpStep(deps);
|
|
552
|
+
case 'PHONE_OTP':
|
|
553
|
+
return new _PhoneOtpStep.PhoneOtpStep(deps);
|
|
554
|
+
case 'TAX_INFO':
|
|
555
|
+
return new _TaxInfoStep.TaxInfoStep(deps);
|
|
556
|
+
case 'SWORN_DECLARATION':
|
|
557
|
+
return new _SwornDeclarationStep.SwornDeclarationStep(deps);
|
|
558
|
+
case 'ECONOMIC_ACTIVITY_DECLARATION':
|
|
559
|
+
return new _EconomicActivityStep.EconomicActivityStep(deps);
|
|
560
|
+
case 'TERMS_AND_CONDITIONS':
|
|
561
|
+
return new _TermsAndConditionsStep.TermsAndConditionsStep(deps);
|
|
562
|
+
case 'LEGAL_BASIC_INFO':
|
|
563
|
+
return new _LegalBasicInfoStep.LegalBasicInfoStep(deps);
|
|
564
|
+
case 'HUMAN_EXTENDED_INFO':
|
|
565
|
+
return new _HumanExtendedInfoStep.HumanExtendedInfoStep(deps);
|
|
566
|
+
case 'LEGAL_EXTENDED_INFO':
|
|
567
|
+
return new _LegalExtendedInfoStep.LegalExtendedInfoStep(deps);
|
|
568
|
+
case 'ADDRESS_INFO':
|
|
569
|
+
return new _AddressInfoStep.AddressInfoStep(deps);
|
|
570
|
+
case 'DOCUMENTS_OCR':
|
|
571
|
+
return new _DocumentsOcrStep.DocumentsOcrStep(deps);
|
|
572
|
+
case 'LIVENESS_MATCH':
|
|
573
|
+
return new _LivenessMatchStep.LivenessMatchStep(deps);
|
|
574
|
+
case 'FACE_MATCH':
|
|
575
|
+
return new _FaceMatchStep.FaceMatchStep(deps);
|
|
576
|
+
default:
|
|
577
|
+
throw {
|
|
578
|
+
code: _types.SdkErrorCode.UNKNOWN,
|
|
579
|
+
message: `Step "${String(step)}" is not implemented yet in the React Native SDK. ` + 'See the port roadmap in the repo README.'
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// ── Finalization ──────────────────────────────────────────────────────────
|
|
585
|
+
|
|
586
|
+
async finalizeSessionWithTerminalEvent(event) {
|
|
587
|
+
const status = terminalEventTypeToStatus(event.event_type);
|
|
588
|
+
if (!status) {
|
|
589
|
+
await this.finalizeSessionSingleGet();
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
let dto;
|
|
593
|
+
try {
|
|
594
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
throw {
|
|
597
|
+
code: _types.SdkErrorCode.API_ERROR,
|
|
598
|
+
message: 'All steps completed but failed to retrieve the final session result.',
|
|
599
|
+
cause: err
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResultWithStatus)(dto, this.config.sessionId, status, event.reason);
|
|
603
|
+
this.completeFlow(result);
|
|
604
|
+
}
|
|
605
|
+
async finalizeSessionSingleGet() {
|
|
606
|
+
let dto;
|
|
607
|
+
try {
|
|
608
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`);
|
|
609
|
+
} catch (err) {
|
|
610
|
+
throw {
|
|
611
|
+
code: _types.SdkErrorCode.API_ERROR,
|
|
612
|
+
message: 'All steps completed but no terminal SSE event was received within the timeout, and the session fetch failed.',
|
|
613
|
+
cause: err
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
|
|
617
|
+
this.completeFlow(result);
|
|
618
|
+
}
|
|
619
|
+
completeFlow(result) {
|
|
620
|
+
this.sessionEnded = true;
|
|
621
|
+
this.setStatus('COMPLETED');
|
|
622
|
+
_log.log.info('[Flow] Session finalized', {
|
|
623
|
+
sessionId: result.sessionId,
|
|
624
|
+
status: result.status,
|
|
625
|
+
terminalReason: result.terminalReason,
|
|
626
|
+
referenceId: result.referenceId,
|
|
627
|
+
completedAt: result.completedAt
|
|
628
|
+
});
|
|
629
|
+
this.view.setResult?.(result);
|
|
630
|
+
this.emitter.emit('flow:complete', result);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Ends the flow without a verdict and notifies the host via `onExit`. Not an
|
|
635
|
+
* error: the UI is cleared so the host can dismiss the SDK. Triggered by
|
|
636
|
+
* backing out of the first reversible step (`BACK_EXIT`) or cancelling the
|
|
637
|
+
* retry dialog (`RETRY_CANCELLED`).
|
|
638
|
+
*/
|
|
639
|
+
exitFlow(step, reason = 'BACK_EXIT') {
|
|
640
|
+
if (this.sessionEnded) return;
|
|
641
|
+
this.sessionEnded = true;
|
|
642
|
+
this.view.setStepNode?.(null);
|
|
643
|
+
this.setStatus('EXITED');
|
|
644
|
+
_log.log.info('[Flow] Session exited', {
|
|
645
|
+
sessionId: this.config.sessionId,
|
|
646
|
+
reason,
|
|
647
|
+
step
|
|
648
|
+
});
|
|
649
|
+
const exit = {
|
|
650
|
+
reason,
|
|
651
|
+
...(step !== undefined && {
|
|
652
|
+
step
|
|
653
|
+
})
|
|
654
|
+
};
|
|
655
|
+
this.view.setExit?.(exit);
|
|
656
|
+
this.emitter.emit('flow:exit', exit);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Mounts the retry dialog for a `RETRY_STEP` and resolves with the user's
|
|
661
|
+
* choice. Copy is derived from the step (not the backend `reason`, which is a
|
|
662
|
+
* diagnostic string) and can be overridden per-step via `retryStepTexts`.
|
|
663
|
+
*/
|
|
664
|
+
presentRetryStepDialog(step) {
|
|
665
|
+
const copy = (0, _retryStepCopy.resolveRetryStepCopy)(this.config.locale, this.config.retryStepTexts, step);
|
|
666
|
+
_log.log.info('[Flow] Presenting RETRY_STEP dialog', {
|
|
667
|
+
step
|
|
668
|
+
});
|
|
669
|
+
return new Promise(resolve => {
|
|
670
|
+
const settle = choice => {
|
|
671
|
+
if (this.retryDialogResolve === null) return;
|
|
672
|
+
this.retryDialogResolve = null;
|
|
673
|
+
this.view.setStepNode?.(null);
|
|
674
|
+
resolve(choice);
|
|
675
|
+
};
|
|
676
|
+
this.retryDialogResolve = resolve;
|
|
677
|
+
this.view.setStepNode?.(/*#__PURE__*/(0, _react.createElement)(_RetryDialog.RetryDialog, {
|
|
678
|
+
title: copy.title,
|
|
679
|
+
message: copy.message,
|
|
680
|
+
retryLabel: copy.retryLabel,
|
|
681
|
+
cancelLabel: copy.cancelLabel,
|
|
682
|
+
onRetry: () => settle('retry'),
|
|
683
|
+
onCancel: () => settle('cancel')
|
|
684
|
+
}));
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
endFlowWithSessionDeclined(event) {
|
|
688
|
+
if (this.sessionEnded) return;
|
|
689
|
+
this.sessionEnded = true;
|
|
690
|
+
_log.log.info('[Flow] Session finalized', {
|
|
691
|
+
sessionId: this.config.sessionId,
|
|
692
|
+
status: 'DECLINED',
|
|
693
|
+
terminalReason: event.reason,
|
|
694
|
+
stepCode: event.step_code
|
|
695
|
+
});
|
|
696
|
+
const copy = (0, _sessionDeclinedCopy.resolveSessionDeclinedCopy)(this.config.locale, this.config.sessionDeclinedReasonTexts, event.reason, this.config.finalResultScreenTexts?.dismissLabel);
|
|
697
|
+
const err = {
|
|
698
|
+
code: _types.SdkErrorCode.SESSION_DECLINED,
|
|
699
|
+
message: copy.message,
|
|
700
|
+
...(event.reason !== undefined && {
|
|
701
|
+
declineReason: event.reason
|
|
702
|
+
}),
|
|
703
|
+
...(event.step_code !== undefined && {
|
|
704
|
+
stepCode: event.step_code
|
|
705
|
+
}),
|
|
706
|
+
declineTitle: copy.title,
|
|
707
|
+
declineMessage: copy.message
|
|
708
|
+
};
|
|
709
|
+
this.emitError(err);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// ── SSE plumbing ──────────────────────────────────────────────────────────
|
|
713
|
+
|
|
714
|
+
openSseStream(sessionToken) {
|
|
715
|
+
this.sseCleanup = (0, _sse.createSessionEventSource)({
|
|
716
|
+
baseUrl: this.config.apiUrl,
|
|
717
|
+
sessionId: this.config.sessionId,
|
|
718
|
+
sessionToken,
|
|
719
|
+
lastEventId: this.lastSseEventId,
|
|
720
|
+
signal: this.sseAbortController.signal,
|
|
721
|
+
onEvent: event => this.handleSseEvent(event),
|
|
722
|
+
onError: err => {
|
|
723
|
+
_log.log.warn('[Flow] SSE onError callback invoked', err);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
handleSseEvent(event) {
|
|
728
|
+
if (this.sessionEnded) return;
|
|
729
|
+
if (event.event_id !== undefined) {
|
|
730
|
+
const incoming = Number(event.event_id);
|
|
731
|
+
const lastSeen = Number(this.lastSseEventId);
|
|
732
|
+
if (Number.isFinite(incoming) && Number.isFinite(lastSeen) && incoming <= lastSeen) {
|
|
733
|
+
_log.log.info('[SSE] Skipping replayed event', {
|
|
734
|
+
eventId: event.event_id,
|
|
735
|
+
lastSeen: this.lastSseEventId,
|
|
736
|
+
eventType: event.event_type,
|
|
737
|
+
action: event.action
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (Number.isFinite(incoming)) {
|
|
742
|
+
this.lastSseEventId = String(event.event_id);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
this.config.onSessionEvent?.(event);
|
|
746
|
+
const isTerminal = isTerminalSessionEvent(event);
|
|
747
|
+
if (event.event_type === 'SESSION_DECLINED') {
|
|
748
|
+
this.pendingTerminalEvent = event;
|
|
749
|
+
if (this.sessionDeclineHandler) {
|
|
750
|
+
this.sessionDeclineHandler(event);
|
|
751
|
+
} else {
|
|
752
|
+
this.pendingSessionDeclined = event;
|
|
753
|
+
}
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (isTerminal) {
|
|
757
|
+
this.pendingTerminalEvent = event;
|
|
758
|
+
if (this.sseNextStepResolve) {
|
|
759
|
+
_log.log.info('[Flow] Terminal event interrupted ROUTING_COMMAND wait', {
|
|
760
|
+
eventType: event.event_type
|
|
761
|
+
});
|
|
762
|
+
const resolveNext = this.sseNextStepResolve;
|
|
763
|
+
this.sseNextStepResolve = null;
|
|
764
|
+
resolveNext(null);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const maybePrevious = (0, _routingCommands.parsePreviousStepCommand)(event);
|
|
768
|
+
if (maybePrevious) {
|
|
769
|
+
_log.log.info('[Flow] PREVIOUS_STEP received from SSE', {
|
|
770
|
+
step: maybePrevious.step,
|
|
771
|
+
hasStepConfig: maybePrevious.stepConfig !== undefined,
|
|
772
|
+
hasStepResult: maybePrevious.stepResult !== undefined
|
|
773
|
+
});
|
|
774
|
+
if (this.previousStepResolve) {
|
|
775
|
+
const resolve = this.previousStepResolve;
|
|
776
|
+
this.previousStepResolve = null;
|
|
777
|
+
resolve(maybePrevious);
|
|
778
|
+
} else {
|
|
779
|
+
// Defensive: a PREVIOUS_STEP arrived while no step was waiting for it
|
|
780
|
+
// (e.g. between transitions). Queue it so the next module entry honors it.
|
|
781
|
+
this.queuedPreviousStepCommand = maybePrevious;
|
|
782
|
+
}
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const maybeBackExit = (0, _routingCommands.parseBackExitCommand)(event);
|
|
786
|
+
if (maybeBackExit) {
|
|
787
|
+
_log.log.info('[Flow] BACK_EXIT received from SSE', {
|
|
788
|
+
step: maybeBackExit.step
|
|
789
|
+
});
|
|
790
|
+
if (this.backExitResolve) {
|
|
791
|
+
const resolve = this.backExitResolve;
|
|
792
|
+
this.backExitResolve = null;
|
|
793
|
+
resolve(maybeBackExit.step);
|
|
794
|
+
} else {
|
|
795
|
+
this.queuedBackExitStep = {
|
|
796
|
+
step: maybeBackExit.step
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const maybeNext = this.extractNextStepCommand(event);
|
|
802
|
+
if (maybeNext) {
|
|
803
|
+
_log.log.info('[Flow] ROUTING_COMMAND received from SSE', {
|
|
804
|
+
step: maybeNext.step,
|
|
805
|
+
hasStepConfig: maybeNext.stepConfig !== undefined,
|
|
806
|
+
eventType: event.event_type,
|
|
807
|
+
action: event.action
|
|
808
|
+
});
|
|
809
|
+
if (this.sseNextStepResolve) {
|
|
810
|
+
const resolve = this.sseNextStepResolve;
|
|
811
|
+
this.sseNextStepResolve = null;
|
|
812
|
+
resolve(maybeNext);
|
|
813
|
+
} else {
|
|
814
|
+
this.queuedNextStepCommand = maybeNext;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
if (this.sseTerminalResolve && isTerminal) {
|
|
818
|
+
_log.log.info('[Flow] Terminal event received from SSE', {
|
|
819
|
+
eventType: event.event_type
|
|
820
|
+
});
|
|
821
|
+
const resolve = this.sseTerminalResolve;
|
|
822
|
+
this.sseTerminalResolve = null;
|
|
823
|
+
resolve(event);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
extractNextStepCommand(event) {
|
|
827
|
+
if (event.event_type !== 'ROUTING_COMMAND') return null;
|
|
828
|
+
const action = event.action;
|
|
829
|
+
if (action !== 'NEXT_STEP' && action !== 'RETRY_STEP') return null;
|
|
830
|
+
const step = event.step_code;
|
|
831
|
+
if (!step) return null;
|
|
832
|
+
return {
|
|
833
|
+
step,
|
|
834
|
+
action,
|
|
835
|
+
...(event.step_config !== undefined && {
|
|
836
|
+
stepConfig: event.step_config
|
|
837
|
+
}),
|
|
838
|
+
...(typeof event.can_go_back === 'boolean' && {
|
|
839
|
+
canGoBack: event.can_go_back
|
|
840
|
+
})
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Fire-and-forget reverse navigation. POSTs `/sessions/:id/back`; the actual
|
|
846
|
+
* step transition arrives via SSE (`PREVIOUS_STEP`). A `400` (session not
|
|
847
|
+
* IN_PROGRESS) or any other failure is swallowed — the user keeps editing the
|
|
848
|
+
* current step. De-duplicated so rapid taps don't stack requests.
|
|
849
|
+
*/
|
|
850
|
+
requestBackNavigation(fromStep) {
|
|
851
|
+
if (this.status === 'DESTROYED' || this.sessionEnded) return;
|
|
852
|
+
if (this.backRequestInFlight) return;
|
|
853
|
+
this.backRequestInFlight = true;
|
|
854
|
+
_log.log.info('[Flow] Requesting reverse navigation', {
|
|
855
|
+
fromStep
|
|
856
|
+
});
|
|
857
|
+
void this.api.post(`/sessions/${this.config.sessionId}/back`, {
|
|
858
|
+
from_step: fromStep
|
|
859
|
+
}).catch(err => {
|
|
860
|
+
_log.log.warn('[Flow] Back navigation request failed (ignored)', err);
|
|
861
|
+
}).finally(() => {
|
|
862
|
+
this.backRequestInFlight = false;
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Derives `can_go_back` for a step from the cached workflow reversibility map.
|
|
868
|
+
* Matches the backend's barrier model: a step can go back when any earlier
|
|
869
|
+
* step is reversible (navigate) or the step itself is the first reversible one
|
|
870
|
+
* (back exits). Fallback only — an explicit `can_go_back` from the backend
|
|
871
|
+
* (GET, or a ROUTING_COMMAND that carries it) always wins.
|
|
872
|
+
*/
|
|
873
|
+
resolveCanGoBack(explicit, step) {
|
|
874
|
+
return typeof explicit === 'boolean' ? explicit : (0, _sessionStateMapper.deriveCanGoBack)(step, this.stepReversibility);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// ── Wait helpers ──────────────────────────────────────────────────────────
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Wait for the next ROUTING_COMMAND. The orchestrator races this with a 30 s
|
|
881
|
+
* timeout that, on fire, falls back to a fresh GET /sessions/:id to recover
|
|
882
|
+
* if SSE was missed.
|
|
883
|
+
*/
|
|
884
|
+
resolveNextStepAfterCompletion() {
|
|
885
|
+
if (this.queuedNextStepCommand) {
|
|
886
|
+
const next = this.queuedNextStepCommand;
|
|
887
|
+
this.queuedNextStepCommand = null;
|
|
888
|
+
return Promise.resolve(next);
|
|
889
|
+
}
|
|
890
|
+
return new Promise(resolve => {
|
|
891
|
+
const timeout = setTimeout(async () => {
|
|
892
|
+
if (this.sseNextStepResolve) {
|
|
893
|
+
this.sseNextStepResolve = null;
|
|
894
|
+
}
|
|
895
|
+
_log.log.warn('[Flow] No ROUTING_COMMAND within 30 s — falling back to GET /sessions for next step');
|
|
896
|
+
try {
|
|
897
|
+
const dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
|
|
898
|
+
extraHeaders: {
|
|
899
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate'
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
|
|
903
|
+
resolve(null);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const state = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
|
|
907
|
+
if (state.currentStep) {
|
|
908
|
+
resolve({
|
|
909
|
+
step: state.currentStep,
|
|
910
|
+
action: 'NEXT_STEP',
|
|
911
|
+
...(state.currentStepConfig !== undefined && {
|
|
912
|
+
stepConfig: state.currentStepConfig
|
|
913
|
+
}),
|
|
914
|
+
...(state.canGoBack !== undefined && {
|
|
915
|
+
canGoBack: state.canGoBack
|
|
916
|
+
})
|
|
917
|
+
});
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
resolve(null);
|
|
921
|
+
} catch (err) {
|
|
922
|
+
_log.log.error('[Flow] Fallback GET /sessions failed', err);
|
|
923
|
+
resolve(null);
|
|
924
|
+
}
|
|
925
|
+
}, 30_000);
|
|
926
|
+
this.sseNextStepResolve = cmd => {
|
|
927
|
+
clearTimeout(timeout);
|
|
928
|
+
resolve(cmd);
|
|
929
|
+
};
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
waitForRoutingAfterBackendOnlyStep() {
|
|
933
|
+
return this.resolveNextStepAfterCompletion();
|
|
934
|
+
}
|
|
935
|
+
waitForTerminalSseEvent(timeoutMs) {
|
|
936
|
+
if (this.pendingTerminalEvent) {
|
|
937
|
+
const ev = this.pendingTerminalEvent;
|
|
938
|
+
return Promise.resolve(ev);
|
|
939
|
+
}
|
|
940
|
+
return new Promise(resolve => {
|
|
941
|
+
const timeout = setTimeout(() => {
|
|
942
|
+
if (this.sseTerminalResolve) {
|
|
943
|
+
this.sseTerminalResolve = null;
|
|
944
|
+
resolve(null);
|
|
945
|
+
}
|
|
946
|
+
}, timeoutMs);
|
|
947
|
+
this.sseTerminalResolve = event => {
|
|
948
|
+
clearTimeout(timeout);
|
|
949
|
+
resolve(event);
|
|
950
|
+
};
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Drain a pending terminal event (e.g. SESSION_APPROVED arrived while the
|
|
956
|
+
* orchestrator was busy mid-step). Returns true when the flow has been ended
|
|
957
|
+
* by the consumed event.
|
|
958
|
+
*/
|
|
959
|
+
async consumePendingTerminalEvent() {
|
|
960
|
+
const event = this.pendingTerminalEvent;
|
|
961
|
+
if (!event) return false;
|
|
962
|
+
this.pendingTerminalEvent = null;
|
|
963
|
+
if (event.event_type === 'SESSION_DECLINED') {
|
|
964
|
+
this.endFlowWithSessionDeclined(event);
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
await this.finalizeSessionWithTerminalEvent(event);
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Runs the active step, resolving on the first of:
|
|
973
|
+
* - `completed` — the module's `run()` resolved (user advanced),
|
|
974
|
+
* - `declined` — SESSION_DECLINED arrived mid-step,
|
|
975
|
+
* - `back` — a PREVIOUS_STEP routing command arrived (user tapped back),
|
|
976
|
+
* - `exit` — a BACK_EXIT routing command arrived (back on the first
|
|
977
|
+
* reversible step → leave the flow).
|
|
978
|
+
*
|
|
979
|
+
* Rejects only if `run()` itself throws. Used in place of the plain decline
|
|
980
|
+
* race for the step loop so reverse navigation can interrupt an active form.
|
|
981
|
+
*/
|
|
982
|
+
awaitModuleOutcome(run) {
|
|
983
|
+
if (this.queuedPreviousStepCommand) {
|
|
984
|
+
const command = this.queuedPreviousStepCommand;
|
|
985
|
+
this.queuedPreviousStepCommand = null;
|
|
986
|
+
return Promise.resolve({
|
|
987
|
+
kind: 'back',
|
|
988
|
+
command
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
if (this.queuedBackExitStep) {
|
|
992
|
+
const {
|
|
993
|
+
step
|
|
994
|
+
} = this.queuedBackExitStep;
|
|
995
|
+
this.queuedBackExitStep = null;
|
|
996
|
+
return Promise.resolve({
|
|
997
|
+
kind: 'exit',
|
|
998
|
+
step
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
return new Promise((resolve, reject) => {
|
|
1002
|
+
let settled = false;
|
|
1003
|
+
const cleanup = () => {
|
|
1004
|
+
this.sessionDeclineHandler = null;
|
|
1005
|
+
this.previousStepResolve = null;
|
|
1006
|
+
this.backExitResolve = null;
|
|
1007
|
+
};
|
|
1008
|
+
const settle = run2 => {
|
|
1009
|
+
if (settled) return;
|
|
1010
|
+
settled = true;
|
|
1011
|
+
cleanup();
|
|
1012
|
+
run2();
|
|
1013
|
+
};
|
|
1014
|
+
this.sessionDeclineHandler = event => settle(() => resolve({
|
|
1015
|
+
kind: 'declined',
|
|
1016
|
+
event
|
|
1017
|
+
}));
|
|
1018
|
+
this.previousStepResolve = command => settle(() => resolve({
|
|
1019
|
+
kind: 'back',
|
|
1020
|
+
command
|
|
1021
|
+
}));
|
|
1022
|
+
this.backExitResolve = step => settle(() => resolve({
|
|
1023
|
+
kind: 'exit',
|
|
1024
|
+
step
|
|
1025
|
+
}));
|
|
1026
|
+
run.then(() => settle(() => resolve({
|
|
1027
|
+
kind: 'completed'
|
|
1028
|
+
}))).catch(err => settle(() => reject(err)));
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Race a step's promise against SESSION_DECLINED. If decline arrives first,
|
|
1034
|
+
* `declined` is true so the caller can short-circuit cleanup.
|
|
1035
|
+
*/
|
|
1036
|
+
withSessionDeclineRace(promise) {
|
|
1037
|
+
return new Promise((resolve, reject) => {
|
|
1038
|
+
let settled = false;
|
|
1039
|
+
const declineHandler = event => {
|
|
1040
|
+
if (settled) return;
|
|
1041
|
+
settled = true;
|
|
1042
|
+
this.sessionDeclineHandler = null;
|
|
1043
|
+
resolve({
|
|
1044
|
+
declined: true,
|
|
1045
|
+
event
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1048
|
+
this.sessionDeclineHandler = declineHandler;
|
|
1049
|
+
promise.then(value => {
|
|
1050
|
+
if (settled) return;
|
|
1051
|
+
settled = true;
|
|
1052
|
+
this.sessionDeclineHandler = null;
|
|
1053
|
+
resolve({
|
|
1054
|
+
declined: false,
|
|
1055
|
+
value
|
|
1056
|
+
});
|
|
1057
|
+
}).catch(err => {
|
|
1058
|
+
if (settled) return;
|
|
1059
|
+
settled = true;
|
|
1060
|
+
this.sessionDeclineHandler = null;
|
|
1061
|
+
reject(err);
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
1067
|
+
|
|
1068
|
+
wireExternalCallbacks() {
|
|
1069
|
+
const cb = this.config;
|
|
1070
|
+
if (cb.onError) this.emitter.on('error', cb.onError);
|
|
1071
|
+
if (cb.onSuccess) this.emitter.on('flow:complete', cb.onSuccess);
|
|
1072
|
+
if (cb.onExit) this.emitter.on('flow:exit', cb.onExit);
|
|
1073
|
+
if (cb.onStepChange) {
|
|
1074
|
+
this.emitter.on('step:change', ({
|
|
1075
|
+
step,
|
|
1076
|
+
index
|
|
1077
|
+
}) => cb.onStepChange?.(step, index));
|
|
1078
|
+
}
|
|
1079
|
+
if (cb.onStepComplete) {
|
|
1080
|
+
this.emitter.on('step:complete', ({
|
|
1081
|
+
step
|
|
1082
|
+
}) => cb.onStepComplete?.(step));
|
|
1083
|
+
}
|
|
1084
|
+
// session:loaded has no public callback — internal only.
|
|
1085
|
+
}
|
|
1086
|
+
setStatus(next) {
|
|
1087
|
+
this.status = next;
|
|
1088
|
+
this.emitter.emit('status:change', next);
|
|
1089
|
+
}
|
|
1090
|
+
emitError(err) {
|
|
1091
|
+
if (this.status === 'DESTROYED') return;
|
|
1092
|
+
this.setStatus('ERROR');
|
|
1093
|
+
this.view.setError?.(err);
|
|
1094
|
+
this.emitter.emit('error', err);
|
|
1095
|
+
}
|
|
1096
|
+
isEnglish() {
|
|
1097
|
+
return (this.config.locale ?? 'es').toLowerCase().startsWith('en');
|
|
1098
|
+
}
|
|
1099
|
+
localizedLoadingMsg() {
|
|
1100
|
+
return this.isEnglish() ? 'Loading…' : 'Cargando…';
|
|
1101
|
+
}
|
|
1102
|
+
localizedProcessingMsg() {
|
|
1103
|
+
return this.isEnglish() ? 'Processing your verification…' : 'Procesando tu verificación…';
|
|
1104
|
+
}
|
|
1105
|
+
localizedFinalizingMsg() {
|
|
1106
|
+
return this.isEnglish() ? 'Processing your information…' : 'Procesando tu información…';
|
|
1107
|
+
}
|
|
1108
|
+
showLoading(text) {
|
|
1109
|
+
this.view.setLoading?.(text);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
exports.VelionOnboarding = VelionOnboarding;
|
|
1113
|
+
//# sourceMappingURL=VelionOnboarding.js.map
|