@velion-la/onboarding-sdk-react-native 1.0.0-beta.2
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 +803 -0
- package/lib/commonjs/camera/AddressSearchBar.js +304 -0
- package/lib/commonjs/camera/AddressSearchBar.js.map +1 -0
- package/lib/commonjs/camera/DocumentCapture.js +505 -0
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -0
- package/lib/commonjs/camera/LivenessCamera.js +534 -0
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -0
- package/lib/commonjs/camera/MapAddressPicker.js +341 -0
- package/lib/commonjs/camera/MapAddressPicker.js.map +1 -0
- package/lib/commonjs/core/VelionOnboarding.js +815 -0
- package/lib/commonjs/core/VelionOnboarding.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 +137 -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 +261 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -0
- package/lib/commonjs/i18n/strings/es.js +266 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -0
- package/lib/commonjs/index.js +213 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/steps/AddressInfoStep.js +650 -0
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -0
- package/lib/commonjs/steps/DocumentsOcrStep.js +397 -0
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -0
- package/lib/commonjs/steps/EmailContactStep.js +145 -0
- package/lib/commonjs/steps/EmailContactStep.js.map +1 -0
- package/lib/commonjs/steps/EmailOtpStep.js +220 -0
- package/lib/commonjs/steps/EmailOtpStep.js.map +1 -0
- package/lib/commonjs/steps/FaceMatchStep.js +166 -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 +243 -0
- package/lib/commonjs/steps/HumanBasicInfoStep.js.map +1 -0
- package/lib/commonjs/steps/HumanExtendedInfoStep.js +268 -0
- package/lib/commonjs/steps/HumanExtendedInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LegalBasicInfoStep.js +188 -0
- package/lib/commonjs/steps/LegalBasicInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LegalExtendedInfoStep.js +166 -0
- package/lib/commonjs/steps/LegalExtendedInfoStep.js.map +1 -0
- package/lib/commonjs/steps/LivenessMatchStep.js +707 -0
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -0
- package/lib/commonjs/steps/PhoneContactStep.js +146 -0
- package/lib/commonjs/steps/PhoneContactStep.js.map +1 -0
- package/lib/commonjs/steps/PhoneOtpStep.js +219 -0
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -0
- package/lib/commonjs/steps/SwornDeclarationStep.js +196 -0
- package/lib/commonjs/steps/SwornDeclarationStep.js.map +1 -0
- package/lib/commonjs/steps/TaxInfoStep.js +244 -0
- package/lib/commonjs/steps/TaxInfoStep.js.map +1 -0
- package/lib/commonjs/steps/TermsAndConditionsStep.js +238 -0
- package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -0
- package/lib/commonjs/steps/_shared.js +40 -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 +391 -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 +118 -0
- package/lib/commonjs/ui/StepShell.js.map +1 -0
- package/lib/commonjs/ui/VelionOnboardingScreen.js +217 -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 +95 -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/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/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 +69 -0
- package/lib/commonjs/ui/primitives/index.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 +77 -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/module/camera/AddressSearchBar.js +299 -0
- package/lib/module/camera/AddressSearchBar.js.map +1 -0
- package/lib/module/camera/DocumentCapture.js +500 -0
- package/lib/module/camera/DocumentCapture.js.map +1 -0
- package/lib/module/camera/LivenessCamera.js +529 -0
- package/lib/module/camera/LivenessCamera.js.map +1 -0
- package/lib/module/camera/MapAddressPicker.js +337 -0
- package/lib/module/camera/MapAddressPicker.js.map +1 -0
- package/lib/module/core/VelionOnboarding.js +811 -0
- package/lib/module/core/VelionOnboarding.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 +128 -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 +257 -0
- package/lib/module/i18n/strings/en.js.map +1 -0
- package/lib/module/i18n/strings/es.js +262 -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 +646 -0
- package/lib/module/steps/AddressInfoStep.js.map +1 -0
- package/lib/module/steps/DocumentsOcrStep.js +391 -0
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -0
- package/lib/module/steps/EmailContactStep.js +140 -0
- package/lib/module/steps/EmailContactStep.js.map +1 -0
- package/lib/module/steps/EmailOtpStep.js +215 -0
- package/lib/module/steps/EmailOtpStep.js.map +1 -0
- package/lib/module/steps/FaceMatchStep.js +161 -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 +238 -0
- package/lib/module/steps/HumanBasicInfoStep.js.map +1 -0
- package/lib/module/steps/HumanExtendedInfoStep.js +263 -0
- package/lib/module/steps/HumanExtendedInfoStep.js.map +1 -0
- package/lib/module/steps/LegalBasicInfoStep.js +183 -0
- package/lib/module/steps/LegalBasicInfoStep.js.map +1 -0
- package/lib/module/steps/LegalExtendedInfoStep.js +161 -0
- package/lib/module/steps/LegalExtendedInfoStep.js.map +1 -0
- package/lib/module/steps/LivenessMatchStep.js +701 -0
- package/lib/module/steps/LivenessMatchStep.js.map +1 -0
- package/lib/module/steps/PhoneContactStep.js +141 -0
- package/lib/module/steps/PhoneContactStep.js.map +1 -0
- package/lib/module/steps/PhoneOtpStep.js +214 -0
- package/lib/module/steps/PhoneOtpStep.js.map +1 -0
- package/lib/module/steps/SwornDeclarationStep.js +191 -0
- package/lib/module/steps/SwornDeclarationStep.js.map +1 -0
- package/lib/module/steps/TaxInfoStep.js +239 -0
- package/lib/module/steps/TaxInfoStep.js.map +1 -0
- package/lib/module/steps/TermsAndConditionsStep.js +233 -0
- package/lib/module/steps/TermsAndConditionsStep.js.map +1 -0
- package/lib/module/steps/_shared.js +33 -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 +457 -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 +114 -0
- package/lib/module/ui/StepShell.js.map +1 -0
- package/lib/module/ui/VelionOnboardingScreen.js +212 -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 +90 -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/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/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 +12 -0
- package/lib/module/ui/primitives/index.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 +73 -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/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 +50 -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 +115 -0
- package/lib/typescript/core/VelionOnboarding.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 +33 -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 +260 -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/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 +11 -0
- package/lib/typescript/steps/_shared.d.ts.map +1 -0
- package/lib/typescript/steps/types.d.ts +68 -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 +1010 -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 +19 -0
- package/lib/typescript/ui/StepShell.d.ts.map +1 -0
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts +19 -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 +26 -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/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/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 +10 -0
- package/lib/typescript/ui/primitives/index.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 +44 -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/package.json +99 -0
- package/src/camera/AddressSearchBar.tsx +363 -0
- package/src/camera/DocumentCapture.tsx +505 -0
- package/src/camera/LivenessCamera.tsx +602 -0
- package/src/camera/MapAddressPicker.tsx +397 -0
- package/src/core/VelionOnboarding.ts +974 -0
- package/src/core/sessionDeclinedCopy.ts +76 -0
- package/src/core/sessionStateMapper.ts +167 -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 +289 -0
- package/src/i18n/strings/es.ts +291 -0
- package/src/index.ts +137 -0
- package/src/steps/AddressInfoStep.tsx +726 -0
- package/src/steps/DocumentsOcrStep.tsx +472 -0
- package/src/steps/EmailContactStep.tsx +159 -0
- package/src/steps/EmailOtpStep.tsx +250 -0
- package/src/steps/FaceMatchStep.tsx +177 -0
- package/src/steps/FingerprintStep.tsx +99 -0
- package/src/steps/HumanBasicInfoStep.tsx +274 -0
- package/src/steps/HumanExtendedInfoStep.tsx +353 -0
- package/src/steps/LegalBasicInfoStep.tsx +205 -0
- package/src/steps/LegalExtendedInfoStep.tsx +171 -0
- package/src/steps/LivenessMatchStep.tsx +846 -0
- package/src/steps/PhoneContactStep.tsx +160 -0
- package/src/steps/PhoneOtpStep.tsx +249 -0
- package/src/steps/SwornDeclarationStep.tsx +220 -0
- package/src/steps/TaxInfoStep.tsx +277 -0
- package/src/steps/TermsAndConditionsStep.tsx +261 -0
- package/src/steps/_shared.ts +44 -0
- package/src/steps/types.ts +72 -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 +1198 -0
- package/src/ui/MapFallbackBoundary.tsx +46 -0
- package/src/ui/StepShell.tsx +137 -0
- package/src/ui/VelionOnboardingScreen.tsx +223 -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 +77 -0
- package/src/ui/overlays/AnalyzingOverlay.tsx +323 -0
- package/src/ui/overlays/LoadingOverlay.tsx +115 -0
- package/src/ui/overlays/ProgressBar.tsx +99 -0
- package/src/ui/overlays/RetryDialog.tsx +128 -0
- package/src/ui/overlays/index.ts +3 -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/Select.tsx +259 -0
- package/src/ui/primitives/Spinner.tsx +17 -0
- package/src/ui/primitives/index.ts +9 -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 +72 -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
|
@@ -0,0 +1,815 @@
|
|
|
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 _sessionStateMapper = require("./sessionStateMapper");
|
|
11
|
+
var _sse = require("../transport/sse");
|
|
12
|
+
var _sessionDeclinedCopy = require("./sessionDeclinedCopy");
|
|
13
|
+
var _FingerprintStep = require("../steps/FingerprintStep");
|
|
14
|
+
var _HumanBasicInfoStep = require("../steps/HumanBasicInfoStep");
|
|
15
|
+
var _EmailContactStep = require("../steps/EmailContactStep");
|
|
16
|
+
var _PhoneContactStep = require("../steps/PhoneContactStep");
|
|
17
|
+
var _EmailOtpStep = require("../steps/EmailOtpStep");
|
|
18
|
+
var _PhoneOtpStep = require("../steps/PhoneOtpStep");
|
|
19
|
+
var _TaxInfoStep = require("../steps/TaxInfoStep");
|
|
20
|
+
var _SwornDeclarationStep = require("../steps/SwornDeclarationStep");
|
|
21
|
+
var _TermsAndConditionsStep = require("../steps/TermsAndConditionsStep");
|
|
22
|
+
var _LegalBasicInfoStep = require("../steps/LegalBasicInfoStep");
|
|
23
|
+
var _HumanExtendedInfoStep = require("../steps/HumanExtendedInfoStep");
|
|
24
|
+
var _LegalExtendedInfoStep = require("../steps/LegalExtendedInfoStep");
|
|
25
|
+
var _AddressInfoStep = require("../steps/AddressInfoStep");
|
|
26
|
+
var _DocumentsOcrStep = require("../steps/DocumentsOcrStep");
|
|
27
|
+
var _LivenessMatchStep = require("../steps/LivenessMatchStep");
|
|
28
|
+
var _FaceMatchStep = require("../steps/FaceMatchStep");
|
|
29
|
+
var _types = require("../types");
|
|
30
|
+
/**
|
|
31
|
+
* @fileoverview VelionOnboarding — orchestrator for the React Native SDK.
|
|
32
|
+
*
|
|
33
|
+
* Platform-agnostic dynamic state machine: deals with HTTP, SSE, dedupe and
|
|
34
|
+
* step-module orchestration. UI mounting is delegated to a React component
|
|
35
|
+
* (`VelionOnboardingScreen`) instead of direct DOM manipulation.
|
|
36
|
+
*
|
|
37
|
+
* Invariants:
|
|
38
|
+
* - SSE dedupe by `event_id` (monotonic)
|
|
39
|
+
* - Suppress duplicate `NEXT_STEP` for the just-completed step
|
|
40
|
+
* - 45 s watchdog for terminal SSE event after final step → fallback GET
|
|
41
|
+
* - SESSION_DECLINED handling races with module.run()
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
// PUBLIC CONFIG (RN flavor)
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* RN-specific config. Drops web-only fields (`containerId`, `allowEmbedded`,
|
|
50
|
+
* `iframeParentOrigin`) and keeps everything else identical to
|
|
51
|
+
* `WebVelionConfig`, including `fingerprintEndpoint` and `fingerprintApiKey`
|
|
52
|
+
* — both are honoured by the native Fingerprint Pro SDK on mobile too.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
56
|
+
// INTERNAL CONTRACTS
|
|
57
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
const BACKEND_ONLY_ORCHESTRATED_STEPS = new Set(['FACE_MATCH', 'AML_SCREENING']);
|
|
60
|
+
const DEFAULT_API_URL = 'https://sdk.velion.la/onboarding';
|
|
61
|
+
function isBackendOnlyOrchestratedStep(step) {
|
|
62
|
+
if (typeof step !== 'string' || step.trim() === '') return false;
|
|
63
|
+
return BACKEND_ONLY_ORCHESTRATED_STEPS.has(step.trim().toUpperCase());
|
|
64
|
+
}
|
|
65
|
+
function isTerminalSessionEvent(event) {
|
|
66
|
+
const t = event.event_type;
|
|
67
|
+
return t === 'SESSION_APPROVED' || t === 'SESSION_MANUAL_REVIEW' || t === 'SESSION_DECLINED' || t === 'SESSION_TERMINATED';
|
|
68
|
+
}
|
|
69
|
+
function terminalEventTypeToStatus(eventType) {
|
|
70
|
+
switch (eventType) {
|
|
71
|
+
case 'SESSION_APPROVED':
|
|
72
|
+
return 'APPROVED';
|
|
73
|
+
case 'SESSION_MANUAL_REVIEW':
|
|
74
|
+
return 'MANUAL_REVIEW';
|
|
75
|
+
case 'SESSION_DECLINED':
|
|
76
|
+
return 'DECLINED';
|
|
77
|
+
case 'SESSION_TERMINATED':
|
|
78
|
+
return 'REJECTED';
|
|
79
|
+
default:
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function isSessionTokenAuthSdkError(err) {
|
|
84
|
+
return err != null && typeof err === 'object' && err.code === _types.SdkErrorCode.SESSION_EXPIRED;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
88
|
+
// PUBLIC: ORCHESTRATOR
|
|
89
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Optional view bridge given to the orchestrator by `VelionOnboardingScreen`.
|
|
93
|
+
*
|
|
94
|
+
* The orchestrator never reads from this — it only writes:
|
|
95
|
+
* - `setLoading(text)` to display a status message between steps
|
|
96
|
+
* - `setStepNode(node)` to mount the active step's UI
|
|
97
|
+
* - `setError(err)` to surface a fatal error
|
|
98
|
+
* - `setResult(result)` on flow completion (host may show their own result)
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Top-level entry point. Instantiate once per session, call `start()`, and
|
|
103
|
+
* `destroy()` from the host's unmount path.
|
|
104
|
+
*/
|
|
105
|
+
class VelionOnboarding {
|
|
106
|
+
emitter = new _EventEmitter.TypedEventEmitter();
|
|
107
|
+
status = 'IDLE';
|
|
108
|
+
activeModule = null;
|
|
109
|
+
view = {};
|
|
110
|
+
uiHandle = {
|
|
111
|
+
setNode: node => this.view.setStepNode?.(node)
|
|
112
|
+
};
|
|
113
|
+
initAbortController = new AbortController();
|
|
114
|
+
sseAbortController = new AbortController();
|
|
115
|
+
sseCleanup = null;
|
|
116
|
+
sseTerminalResolve = null;
|
|
117
|
+
sseNextStepResolve = null;
|
|
118
|
+
queuedNextStepCommand = null;
|
|
119
|
+
lastSseEventId = '0';
|
|
120
|
+
sessionDeclineHandler = null;
|
|
121
|
+
pendingSessionDeclined = null;
|
|
122
|
+
pendingTerminalEvent = null;
|
|
123
|
+
sessionEnded = false;
|
|
124
|
+
constructor(config) {
|
|
125
|
+
const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
|
|
126
|
+
this.config = Object.freeze({
|
|
127
|
+
...config,
|
|
128
|
+
apiUrl
|
|
129
|
+
});
|
|
130
|
+
if (this.config.debug === true) (0, _log.setDebugEnabled)(true);
|
|
131
|
+
let api;
|
|
132
|
+
let constructionError = null;
|
|
133
|
+
try {
|
|
134
|
+
api = (0, _api.createApiCaller)(apiUrl, config.sessionToken, config.expiresAt);
|
|
135
|
+
} catch (err) {
|
|
136
|
+
constructionError = err;
|
|
137
|
+
// Provide a safe-but-unused caller so typed code paths don't crash.
|
|
138
|
+
api = (0, _api.createApiCaller)('https://invalid.velion.invalid', config.sessionToken, config.expiresAt);
|
|
139
|
+
}
|
|
140
|
+
this.api = api;
|
|
141
|
+
this.constructionError = constructionError;
|
|
142
|
+
this.wireExternalCallbacks();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Connects an `OrchestratorView` (typically `VelionOnboardingScreen`). */
|
|
146
|
+
attachView(view) {
|
|
147
|
+
this.view = view;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Detaches the active view (called from screen unmount). */
|
|
151
|
+
detachView() {
|
|
152
|
+
this.view = {};
|
|
153
|
+
}
|
|
154
|
+
on(event, listener) {
|
|
155
|
+
return this.emitter.on(event, listener);
|
|
156
|
+
}
|
|
157
|
+
getStatus() {
|
|
158
|
+
return this.status;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Hot-rotate the bearer token used by every subsequent backend call. The SSE
|
|
163
|
+
* stream is also reopened so the new token reaches the server-side authenticator.
|
|
164
|
+
*/
|
|
165
|
+
refreshSessionToken(token, expiresAt) {
|
|
166
|
+
if (this.status === 'DESTROYED') return;
|
|
167
|
+
this.api.setSessionToken(token, expiresAt);
|
|
168
|
+
if (this.sseCleanup) {
|
|
169
|
+
_log.log.info('[Flow] Reopening SSE after session token rotation');
|
|
170
|
+
this.sseCleanup();
|
|
171
|
+
this.sseAbortController.abort();
|
|
172
|
+
this.sseAbortController = new AbortController();
|
|
173
|
+
this.openSseStream(token);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async start() {
|
|
177
|
+
if (this.status === 'DESTROYED') {
|
|
178
|
+
this.emitError({
|
|
179
|
+
code: _types.SdkErrorCode.INSTANCE_DESTROYED,
|
|
180
|
+
message: 'This VelionOnboarding instance has been destroyed. Create a new instance to retry.'
|
|
181
|
+
});
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (this.status !== 'IDLE') {
|
|
185
|
+
this.emitError({
|
|
186
|
+
code: _types.SdkErrorCode.ALREADY_STARTED,
|
|
187
|
+
message: 'start() was called on an already-running SDK instance. Call destroy() before re-starting.'
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this.constructionError) {
|
|
192
|
+
this.emitError(this.constructionError);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
await this.initialize();
|
|
197
|
+
} catch (err) {
|
|
198
|
+
this.emitError(err);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
destroy() {
|
|
202
|
+
if (this.status === 'DESTROYED') return;
|
|
203
|
+
this.setStatus('DESTROYED');
|
|
204
|
+
this.initAbortController.abort();
|
|
205
|
+
this.sseCleanup?.();
|
|
206
|
+
this.sseAbortController.abort();
|
|
207
|
+
this.activeModule?.destroy();
|
|
208
|
+
this.activeModule = null;
|
|
209
|
+
this.view.setStepNode?.(null);
|
|
210
|
+
this.view.setLoading?.(null);
|
|
211
|
+
this.emitter.removeAllListeners();
|
|
212
|
+
this.sessionDeclineHandler = null;
|
|
213
|
+
this.pendingSessionDeclined = null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ── Initialization ────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
async initialize() {
|
|
219
|
+
this.setStatus('INITIALIZING');
|
|
220
|
+
this.showLoading(this.localizedLoadingMsg());
|
|
221
|
+
let dto;
|
|
222
|
+
try {
|
|
223
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
|
|
224
|
+
signal: this.initAbortController.signal,
|
|
225
|
+
extraHeaders: {
|
|
226
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
227
|
+
Pragma: 'no-cache'
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
} catch (err) {
|
|
231
|
+
this.showLoading(null);
|
|
232
|
+
if (isSessionTokenAuthSdkError(err)) {
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
throw {
|
|
236
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
237
|
+
message: `Failed to fetch session for sessionId="${this.config.sessionId}". Verify the apiUrl and sessionToken are correct.`,
|
|
238
|
+
cause: err
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const sessionState = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
|
|
242
|
+
this.emitter.emit('session:loaded', sessionState);
|
|
243
|
+
if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
|
|
244
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
|
|
245
|
+
this.completeFlow(result);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.validateSessionState(dto, sessionState);
|
|
249
|
+
this.sseAbortController = new AbortController();
|
|
250
|
+
this.openSseStream(this.config.sessionToken);
|
|
251
|
+
this.setStatus('RUNNING');
|
|
252
|
+
await this.runStepMachine(sessionState);
|
|
253
|
+
}
|
|
254
|
+
validateSessionState(dto, state) {
|
|
255
|
+
if ((0, _sessionStateMapper.requiresCurrentStepForSessionStatus)(dto.status) && !state.currentStep) {
|
|
256
|
+
throw {
|
|
257
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
258
|
+
message: `Session ${this.config.sessionId} reports status="${dto.status}" but no current_step. Backend payload is incomplete.`
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// ── Step Machine ──────────────────────────────────────────────────────────
|
|
264
|
+
|
|
265
|
+
async runStepMachine(sessionState) {
|
|
266
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
267
|
+
if (this.pendingSessionDeclined) {
|
|
268
|
+
const ev = this.pendingSessionDeclined;
|
|
269
|
+
this.pendingSessionDeclined = null;
|
|
270
|
+
this.endFlowWithSessionDeclined(ev);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
let index = 0;
|
|
274
|
+
let currentStep = sessionState.currentStep;
|
|
275
|
+
let currentStepConfig = sessionState.currentStepConfig;
|
|
276
|
+
const knownStepConfigs = {
|
|
277
|
+
...(sessionState.stepConfigs ?? {})
|
|
278
|
+
};
|
|
279
|
+
if (currentStep && isBackendOnlyOrchestratedStep(currentStep)) {
|
|
280
|
+
this.showLoading(this.localizedProcessingMsg());
|
|
281
|
+
try {
|
|
282
|
+
const outcome = await this.withSessionDeclineRace(this.waitForRoutingAfterBackendOnlyStep());
|
|
283
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
284
|
+
if (outcome.declined) {
|
|
285
|
+
this.endFlowWithSessionDeclined(outcome.event);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const routed = outcome.value;
|
|
289
|
+
if (!routed?.step) {
|
|
290
|
+
throw {
|
|
291
|
+
code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
|
|
292
|
+
message: `Timed out waiting for ROUTING_COMMAND while the session was on a backend-only step (${String(currentStep)}).`
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
currentStep = routed.step;
|
|
296
|
+
currentStepConfig = routed.stepConfig;
|
|
297
|
+
} finally {
|
|
298
|
+
this.showLoading(null);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
while (currentStep) {
|
|
302
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
303
|
+
if (this.pendingSessionDeclined) {
|
|
304
|
+
const ev = this.pendingSessionDeclined;
|
|
305
|
+
this.pendingSessionDeclined = null;
|
|
306
|
+
this.endFlowWithSessionDeclined(ev);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
this.setStatus('STEP_PROCESSING');
|
|
310
|
+
this.emitter.emit('step:change', {
|
|
311
|
+
step: currentStep,
|
|
312
|
+
index
|
|
313
|
+
});
|
|
314
|
+
if (currentStepConfig) {
|
|
315
|
+
knownStepConfigs[currentStep] = currentStepConfig;
|
|
316
|
+
}
|
|
317
|
+
const module = this.createModule(currentStep, currentStepConfig);
|
|
318
|
+
this.activeModule = module;
|
|
319
|
+
try {
|
|
320
|
+
const runOutcome = await this.withSessionDeclineRace(module.run());
|
|
321
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
322
|
+
module.destroy();
|
|
323
|
+
this.activeModule = null;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (runOutcome.declined) {
|
|
327
|
+
module.destroy();
|
|
328
|
+
this.activeModule = null;
|
|
329
|
+
this.endFlowWithSessionDeclined(runOutcome.event);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
} catch (err) {
|
|
333
|
+
module.destroy();
|
|
334
|
+
this.activeModule = null;
|
|
335
|
+
throw err;
|
|
336
|
+
}
|
|
337
|
+
module.destroy();
|
|
338
|
+
this.activeModule = null;
|
|
339
|
+
this.view.setStepNode?.(null);
|
|
340
|
+
this.emitter.emit('step:complete', {
|
|
341
|
+
step: currentStep
|
|
342
|
+
});
|
|
343
|
+
this.setStatus('RUNNING');
|
|
344
|
+
index += 1;
|
|
345
|
+
this.showLoading('');
|
|
346
|
+
let next;
|
|
347
|
+
try {
|
|
348
|
+
const nextOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
|
|
349
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
350
|
+
this.showLoading(null);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (nextOutcome.declined) {
|
|
354
|
+
this.endFlowWithSessionDeclined(nextOutcome.event);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
next = nextOutcome.value;
|
|
358
|
+
} catch (err) {
|
|
359
|
+
this.showLoading(null);
|
|
360
|
+
throw err;
|
|
361
|
+
}
|
|
362
|
+
while (next?.step && next.action === 'NEXT_STEP' && next.step === currentStep) {
|
|
363
|
+
_log.log.warn('[Flow] Dropping duplicate NEXT_STEP for just-completed step', {
|
|
364
|
+
step: currentStep
|
|
365
|
+
});
|
|
366
|
+
const retryOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
|
|
367
|
+
if (await this.consumePendingTerminalEvent()) {
|
|
368
|
+
this.showLoading(null);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (retryOutcome.declined) {
|
|
372
|
+
this.endFlowWithSessionDeclined(retryOutcome.event);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
next = retryOutcome.value;
|
|
376
|
+
}
|
|
377
|
+
if (next?.step) {
|
|
378
|
+
this.showLoading(null);
|
|
379
|
+
}
|
|
380
|
+
if (!next?.step) break;
|
|
381
|
+
currentStep = next.step;
|
|
382
|
+
currentStepConfig = next.stepConfig;
|
|
383
|
+
}
|
|
384
|
+
this.showLoading(this.localizedFinalizingMsg());
|
|
385
|
+
try {
|
|
386
|
+
if (this.pendingSessionDeclined) {
|
|
387
|
+
const ev = this.pendingSessionDeclined;
|
|
388
|
+
this.pendingSessionDeclined = null;
|
|
389
|
+
this.endFlowWithSessionDeclined(ev);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
393
|
+
const terminalOutcome = await this.withSessionDeclineRace(this.waitForTerminalSseEvent(45_000));
|
|
394
|
+
if (terminalOutcome.declined) {
|
|
395
|
+
this.endFlowWithSessionDeclined(terminalOutcome.event);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const terminalEvent = terminalOutcome.value;
|
|
399
|
+
if (terminalEvent) {
|
|
400
|
+
await this.finalizeSessionWithTerminalEvent(terminalEvent);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
await this.finalizeSessionSingleGet();
|
|
404
|
+
} finally {
|
|
405
|
+
this.showLoading(null);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
createModule(step, stepConfig) {
|
|
409
|
+
const deps = {
|
|
410
|
+
api: this.api,
|
|
411
|
+
sessionId: this.config.sessionId,
|
|
412
|
+
locale: this.config.locale ?? 'es',
|
|
413
|
+
colorMode: this.config.colorMode ?? 'light',
|
|
414
|
+
ui: this.uiHandle,
|
|
415
|
+
step,
|
|
416
|
+
...(stepConfig !== undefined && {
|
|
417
|
+
stepConfig
|
|
418
|
+
}),
|
|
419
|
+
...(this.config.googleMapsApiKey !== undefined && {
|
|
420
|
+
googleMapsApiKey: this.config.googleMapsApiKey
|
|
421
|
+
}),
|
|
422
|
+
...(this.config.fingerprintEndpoint !== undefined && {
|
|
423
|
+
fingerprintEndpoint: this.config.fingerprintEndpoint
|
|
424
|
+
}),
|
|
425
|
+
...(this.config.fingerprintApiKey !== undefined && {
|
|
426
|
+
fingerprintApiKey: this.config.fingerprintApiKey
|
|
427
|
+
}),
|
|
428
|
+
...(this.config.fingerprintTimeoutMs !== undefined && {
|
|
429
|
+
fingerprintTimeoutMs: this.config.fingerprintTimeoutMs
|
|
430
|
+
}),
|
|
431
|
+
...(this.config.livenessCalibrationLabel !== undefined && {
|
|
432
|
+
livenessCalibrationLabel: this.config.livenessCalibrationLabel
|
|
433
|
+
})
|
|
434
|
+
};
|
|
435
|
+
switch (step) {
|
|
436
|
+
case 'DEVICE_FINGERPRINT':
|
|
437
|
+
return new _FingerprintStep.FingerprintStep(deps);
|
|
438
|
+
case 'HUMAN_BASIC_INFO':
|
|
439
|
+
return new _HumanBasicInfoStep.HumanBasicInfoStep(deps);
|
|
440
|
+
case 'EMAIL_CONTACT':
|
|
441
|
+
return new _EmailContactStep.EmailContactStep(deps);
|
|
442
|
+
case 'PHONE_CONTACT':
|
|
443
|
+
return new _PhoneContactStep.PhoneContactStep(deps);
|
|
444
|
+
case 'EMAIL_OTP':
|
|
445
|
+
return new _EmailOtpStep.EmailOtpStep(deps);
|
|
446
|
+
case 'PHONE_OTP':
|
|
447
|
+
return new _PhoneOtpStep.PhoneOtpStep(deps);
|
|
448
|
+
case 'TAX_INFO':
|
|
449
|
+
return new _TaxInfoStep.TaxInfoStep(deps);
|
|
450
|
+
case 'SWORN_DECLARATION':
|
|
451
|
+
return new _SwornDeclarationStep.SwornDeclarationStep(deps);
|
|
452
|
+
case 'TERMS_AND_CONDITIONS':
|
|
453
|
+
return new _TermsAndConditionsStep.TermsAndConditionsStep(deps);
|
|
454
|
+
case 'LEGAL_BASIC_INFO':
|
|
455
|
+
return new _LegalBasicInfoStep.LegalBasicInfoStep(deps);
|
|
456
|
+
case 'HUMAN_EXTENDED_INFO':
|
|
457
|
+
return new _HumanExtendedInfoStep.HumanExtendedInfoStep(deps);
|
|
458
|
+
case 'LEGAL_EXTENDED_INFO':
|
|
459
|
+
return new _LegalExtendedInfoStep.LegalExtendedInfoStep(deps);
|
|
460
|
+
case 'ADDRESS_INFO':
|
|
461
|
+
return new _AddressInfoStep.AddressInfoStep(deps);
|
|
462
|
+
case 'DOCUMENTS_OCR':
|
|
463
|
+
return new _DocumentsOcrStep.DocumentsOcrStep(deps);
|
|
464
|
+
case 'LIVENESS_MATCH':
|
|
465
|
+
return new _LivenessMatchStep.LivenessMatchStep(deps);
|
|
466
|
+
case 'FACE_MATCH':
|
|
467
|
+
return new _FaceMatchStep.FaceMatchStep(deps);
|
|
468
|
+
default:
|
|
469
|
+
throw {
|
|
470
|
+
code: _types.SdkErrorCode.UNKNOWN,
|
|
471
|
+
message: `Step "${String(step)}" is not implemented yet in the React Native SDK. ` + 'See the port roadmap in the repo README.'
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// ── Finalization ──────────────────────────────────────────────────────────
|
|
477
|
+
|
|
478
|
+
async finalizeSessionWithTerminalEvent(event) {
|
|
479
|
+
const status = terminalEventTypeToStatus(event.event_type);
|
|
480
|
+
if (!status) {
|
|
481
|
+
await this.finalizeSessionSingleGet();
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
let dto;
|
|
485
|
+
try {
|
|
486
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`);
|
|
487
|
+
} catch (err) {
|
|
488
|
+
throw {
|
|
489
|
+
code: _types.SdkErrorCode.API_ERROR,
|
|
490
|
+
message: 'All steps completed but failed to retrieve the final session result.',
|
|
491
|
+
cause: err
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResultWithStatus)(dto, this.config.sessionId, status, event.reason);
|
|
495
|
+
this.completeFlow(result);
|
|
496
|
+
}
|
|
497
|
+
async finalizeSessionSingleGet() {
|
|
498
|
+
let dto;
|
|
499
|
+
try {
|
|
500
|
+
dto = await this.api.get(`/sessions/${this.config.sessionId}`);
|
|
501
|
+
} catch (err) {
|
|
502
|
+
throw {
|
|
503
|
+
code: _types.SdkErrorCode.API_ERROR,
|
|
504
|
+
message: 'All steps completed but no terminal SSE event was received within the timeout, and the session fetch failed.',
|
|
505
|
+
cause: err
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
|
|
509
|
+
this.completeFlow(result);
|
|
510
|
+
}
|
|
511
|
+
completeFlow(result) {
|
|
512
|
+
this.sessionEnded = true;
|
|
513
|
+
this.setStatus('COMPLETED');
|
|
514
|
+
_log.log.info('[Flow] Session finalized', {
|
|
515
|
+
sessionId: result.sessionId,
|
|
516
|
+
status: result.status,
|
|
517
|
+
terminalReason: result.terminalReason,
|
|
518
|
+
referenceId: result.referenceId,
|
|
519
|
+
completedAt: result.completedAt
|
|
520
|
+
});
|
|
521
|
+
this.view.setResult?.(result);
|
|
522
|
+
this.emitter.emit('flow:complete', result);
|
|
523
|
+
}
|
|
524
|
+
endFlowWithSessionDeclined(event) {
|
|
525
|
+
if (this.sessionEnded) return;
|
|
526
|
+
this.sessionEnded = true;
|
|
527
|
+
_log.log.info('[Flow] Session finalized', {
|
|
528
|
+
sessionId: this.config.sessionId,
|
|
529
|
+
status: 'DECLINED',
|
|
530
|
+
terminalReason: event.reason,
|
|
531
|
+
stepCode: event.step_code
|
|
532
|
+
});
|
|
533
|
+
const copy = (0, _sessionDeclinedCopy.resolveSessionDeclinedCopy)(this.config.locale, this.config.sessionDeclinedReasonTexts, event.reason, this.config.finalResultScreenTexts?.dismissLabel);
|
|
534
|
+
const err = {
|
|
535
|
+
code: _types.SdkErrorCode.SESSION_DECLINED,
|
|
536
|
+
message: copy.message,
|
|
537
|
+
...(event.reason !== undefined && {
|
|
538
|
+
declineReason: event.reason
|
|
539
|
+
}),
|
|
540
|
+
...(event.step_code !== undefined && {
|
|
541
|
+
stepCode: event.step_code
|
|
542
|
+
}),
|
|
543
|
+
declineTitle: copy.title,
|
|
544
|
+
declineMessage: copy.message
|
|
545
|
+
};
|
|
546
|
+
this.emitError(err);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// ── SSE plumbing ──────────────────────────────────────────────────────────
|
|
550
|
+
|
|
551
|
+
openSseStream(sessionToken) {
|
|
552
|
+
this.sseCleanup = (0, _sse.createSessionEventSource)({
|
|
553
|
+
baseUrl: this.config.apiUrl,
|
|
554
|
+
sessionId: this.config.sessionId,
|
|
555
|
+
sessionToken,
|
|
556
|
+
lastEventId: this.lastSseEventId,
|
|
557
|
+
signal: this.sseAbortController.signal,
|
|
558
|
+
onEvent: event => this.handleSseEvent(event),
|
|
559
|
+
onError: err => {
|
|
560
|
+
_log.log.warn('[Flow] SSE onError callback invoked', err);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
handleSseEvent(event) {
|
|
565
|
+
if (this.sessionEnded) return;
|
|
566
|
+
if (event.event_id !== undefined) {
|
|
567
|
+
const incoming = Number(event.event_id);
|
|
568
|
+
const lastSeen = Number(this.lastSseEventId);
|
|
569
|
+
if (Number.isFinite(incoming) && Number.isFinite(lastSeen) && incoming <= lastSeen) {
|
|
570
|
+
_log.log.info('[SSE] Skipping replayed event', {
|
|
571
|
+
eventId: event.event_id,
|
|
572
|
+
lastSeen: this.lastSseEventId,
|
|
573
|
+
eventType: event.event_type,
|
|
574
|
+
action: event.action
|
|
575
|
+
});
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (Number.isFinite(incoming)) {
|
|
579
|
+
this.lastSseEventId = String(event.event_id);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
this.config.onSessionEvent?.(event);
|
|
583
|
+
const isTerminal = isTerminalSessionEvent(event);
|
|
584
|
+
if (event.event_type === 'SESSION_DECLINED') {
|
|
585
|
+
this.pendingTerminalEvent = event;
|
|
586
|
+
if (this.sessionDeclineHandler) {
|
|
587
|
+
this.sessionDeclineHandler(event);
|
|
588
|
+
} else {
|
|
589
|
+
this.pendingSessionDeclined = event;
|
|
590
|
+
}
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (isTerminal) {
|
|
594
|
+
this.pendingTerminalEvent = event;
|
|
595
|
+
if (this.sseNextStepResolve) {
|
|
596
|
+
_log.log.info('[Flow] Terminal event interrupted ROUTING_COMMAND wait', {
|
|
597
|
+
eventType: event.event_type
|
|
598
|
+
});
|
|
599
|
+
const resolveNext = this.sseNextStepResolve;
|
|
600
|
+
this.sseNextStepResolve = null;
|
|
601
|
+
resolveNext(null);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const maybeNext = this.extractNextStepCommand(event);
|
|
605
|
+
if (maybeNext) {
|
|
606
|
+
_log.log.info('[Flow] ROUTING_COMMAND received from SSE', {
|
|
607
|
+
step: maybeNext.step,
|
|
608
|
+
hasStepConfig: maybeNext.stepConfig !== undefined,
|
|
609
|
+
eventType: event.event_type,
|
|
610
|
+
action: event.action
|
|
611
|
+
});
|
|
612
|
+
if (this.sseNextStepResolve) {
|
|
613
|
+
const resolve = this.sseNextStepResolve;
|
|
614
|
+
this.sseNextStepResolve = null;
|
|
615
|
+
resolve(maybeNext);
|
|
616
|
+
} else {
|
|
617
|
+
this.queuedNextStepCommand = maybeNext;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (this.sseTerminalResolve && isTerminal) {
|
|
621
|
+
_log.log.info('[Flow] Terminal event received from SSE', {
|
|
622
|
+
eventType: event.event_type
|
|
623
|
+
});
|
|
624
|
+
const resolve = this.sseTerminalResolve;
|
|
625
|
+
this.sseTerminalResolve = null;
|
|
626
|
+
resolve(event);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
extractNextStepCommand(event) {
|
|
630
|
+
if (event.event_type !== 'ROUTING_COMMAND') return null;
|
|
631
|
+
const action = event.action;
|
|
632
|
+
if (action !== 'NEXT_STEP' && action !== 'RETRY_STEP') return null;
|
|
633
|
+
const step = event.step_code;
|
|
634
|
+
if (!step) return null;
|
|
635
|
+
return {
|
|
636
|
+
step,
|
|
637
|
+
action,
|
|
638
|
+
...(event.step_config !== undefined && {
|
|
639
|
+
stepConfig: event.step_config
|
|
640
|
+
})
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// ── Wait helpers ──────────────────────────────────────────────────────────
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Wait for the next ROUTING_COMMAND. The orchestrator races this with a 30 s
|
|
648
|
+
* timeout that, on fire, falls back to a fresh GET /sessions/:id to recover
|
|
649
|
+
* if SSE was missed.
|
|
650
|
+
*/
|
|
651
|
+
resolveNextStepAfterCompletion() {
|
|
652
|
+
if (this.queuedNextStepCommand) {
|
|
653
|
+
const next = this.queuedNextStepCommand;
|
|
654
|
+
this.queuedNextStepCommand = null;
|
|
655
|
+
return Promise.resolve(next);
|
|
656
|
+
}
|
|
657
|
+
return new Promise(resolve => {
|
|
658
|
+
const timeout = setTimeout(async () => {
|
|
659
|
+
if (this.sseNextStepResolve) {
|
|
660
|
+
this.sseNextStepResolve = null;
|
|
661
|
+
}
|
|
662
|
+
_log.log.warn('[Flow] No ROUTING_COMMAND within 30 s — falling back to GET /sessions for next step');
|
|
663
|
+
try {
|
|
664
|
+
const dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
|
|
665
|
+
extraHeaders: {
|
|
666
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate'
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
|
|
670
|
+
resolve(null);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const state = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
|
|
674
|
+
if (state.currentStep) {
|
|
675
|
+
resolve({
|
|
676
|
+
step: state.currentStep,
|
|
677
|
+
action: 'NEXT_STEP',
|
|
678
|
+
...(state.currentStepConfig !== undefined && {
|
|
679
|
+
stepConfig: state.currentStepConfig
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
resolve(null);
|
|
685
|
+
} catch (err) {
|
|
686
|
+
_log.log.error('[Flow] Fallback GET /sessions failed', err);
|
|
687
|
+
resolve(null);
|
|
688
|
+
}
|
|
689
|
+
}, 30_000);
|
|
690
|
+
this.sseNextStepResolve = cmd => {
|
|
691
|
+
clearTimeout(timeout);
|
|
692
|
+
resolve(cmd);
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
waitForRoutingAfterBackendOnlyStep() {
|
|
697
|
+
return this.resolveNextStepAfterCompletion();
|
|
698
|
+
}
|
|
699
|
+
waitForTerminalSseEvent(timeoutMs) {
|
|
700
|
+
if (this.pendingTerminalEvent) {
|
|
701
|
+
const ev = this.pendingTerminalEvent;
|
|
702
|
+
return Promise.resolve(ev);
|
|
703
|
+
}
|
|
704
|
+
return new Promise(resolve => {
|
|
705
|
+
const timeout = setTimeout(() => {
|
|
706
|
+
if (this.sseTerminalResolve) {
|
|
707
|
+
this.sseTerminalResolve = null;
|
|
708
|
+
resolve(null);
|
|
709
|
+
}
|
|
710
|
+
}, timeoutMs);
|
|
711
|
+
this.sseTerminalResolve = event => {
|
|
712
|
+
clearTimeout(timeout);
|
|
713
|
+
resolve(event);
|
|
714
|
+
};
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Drain a pending terminal event (e.g. SESSION_APPROVED arrived while the
|
|
720
|
+
* orchestrator was busy mid-step). Returns true when the flow has been ended
|
|
721
|
+
* by the consumed event.
|
|
722
|
+
*/
|
|
723
|
+
async consumePendingTerminalEvent() {
|
|
724
|
+
const event = this.pendingTerminalEvent;
|
|
725
|
+
if (!event) return false;
|
|
726
|
+
this.pendingTerminalEvent = null;
|
|
727
|
+
if (event.event_type === 'SESSION_DECLINED') {
|
|
728
|
+
this.endFlowWithSessionDeclined(event);
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
await this.finalizeSessionWithTerminalEvent(event);
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Race a step's promise against SESSION_DECLINED. If decline arrives first,
|
|
737
|
+
* `declined` is true so the caller can short-circuit cleanup.
|
|
738
|
+
*/
|
|
739
|
+
withSessionDeclineRace(promise) {
|
|
740
|
+
return new Promise((resolve, reject) => {
|
|
741
|
+
let settled = false;
|
|
742
|
+
const declineHandler = event => {
|
|
743
|
+
if (settled) return;
|
|
744
|
+
settled = true;
|
|
745
|
+
this.sessionDeclineHandler = null;
|
|
746
|
+
resolve({
|
|
747
|
+
declined: true,
|
|
748
|
+
event
|
|
749
|
+
});
|
|
750
|
+
};
|
|
751
|
+
this.sessionDeclineHandler = declineHandler;
|
|
752
|
+
promise.then(value => {
|
|
753
|
+
if (settled) return;
|
|
754
|
+
settled = true;
|
|
755
|
+
this.sessionDeclineHandler = null;
|
|
756
|
+
resolve({
|
|
757
|
+
declined: false,
|
|
758
|
+
value
|
|
759
|
+
});
|
|
760
|
+
}).catch(err => {
|
|
761
|
+
if (settled) return;
|
|
762
|
+
settled = true;
|
|
763
|
+
this.sessionDeclineHandler = null;
|
|
764
|
+
reject(err);
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
770
|
+
|
|
771
|
+
wireExternalCallbacks() {
|
|
772
|
+
const cb = this.config;
|
|
773
|
+
if (cb.onError) this.emitter.on('error', cb.onError);
|
|
774
|
+
if (cb.onSuccess) this.emitter.on('flow:complete', cb.onSuccess);
|
|
775
|
+
if (cb.onStepChange) {
|
|
776
|
+
this.emitter.on('step:change', ({
|
|
777
|
+
step,
|
|
778
|
+
index
|
|
779
|
+
}) => cb.onStepChange?.(step, index));
|
|
780
|
+
}
|
|
781
|
+
if (cb.onStepComplete) {
|
|
782
|
+
this.emitter.on('step:complete', ({
|
|
783
|
+
step
|
|
784
|
+
}) => cb.onStepComplete?.(step));
|
|
785
|
+
}
|
|
786
|
+
// session:loaded has no public callback — internal only.
|
|
787
|
+
}
|
|
788
|
+
setStatus(next) {
|
|
789
|
+
this.status = next;
|
|
790
|
+
this.emitter.emit('status:change', next);
|
|
791
|
+
}
|
|
792
|
+
emitError(err) {
|
|
793
|
+
if (this.status === 'DESTROYED') return;
|
|
794
|
+
this.setStatus('ERROR');
|
|
795
|
+
this.view.setError?.(err);
|
|
796
|
+
this.emitter.emit('error', err);
|
|
797
|
+
}
|
|
798
|
+
isEnglish() {
|
|
799
|
+
return (this.config.locale ?? 'es').toLowerCase().startsWith('en');
|
|
800
|
+
}
|
|
801
|
+
localizedLoadingMsg() {
|
|
802
|
+
return this.isEnglish() ? 'Loading…' : 'Cargando…';
|
|
803
|
+
}
|
|
804
|
+
localizedProcessingMsg() {
|
|
805
|
+
return this.isEnglish() ? 'Processing your verification…' : 'Procesando tu verificación…';
|
|
806
|
+
}
|
|
807
|
+
localizedFinalizingMsg() {
|
|
808
|
+
return this.isEnglish() ? 'Processing your information…' : 'Procesando tu información…';
|
|
809
|
+
}
|
|
810
|
+
showLoading(text) {
|
|
811
|
+
this.view.setLoading?.(text);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
exports.VelionOnboarding = VelionOnboarding;
|
|
815
|
+
//# sourceMappingURL=VelionOnboarding.js.map
|