@velion-la/onboarding-sdk-react-native 1.4.0-beta.1 → 1.4.0-beta.3
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 +18 -0
- package/README.md +33 -1
- package/lib/commonjs/camera/AddressSearchBar.js +9 -7
- package/lib/commonjs/camera/AddressSearchBar.js.map +1 -1
- package/lib/commonjs/camera/DocumentCapture.js +7 -6
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
- package/lib/commonjs/camera/LivenessCamera.js +6 -5
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
- package/lib/commonjs/camera/MapAddressPicker.js +2 -1
- package/lib/commonjs/camera/MapAddressPicker.js.map +1 -1
- package/lib/commonjs/core/VelionOnboarding.js +123 -6
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/core/sessionCancelledCopy.js +25 -0
- package/lib/commonjs/core/sessionCancelledCopy.js.map +1 -0
- package/lib/commonjs/core/sessionStateMapper.js +17 -4
- package/lib/commonjs/core/sessionStateMapper.js.map +1 -1
- package/lib/commonjs/core/sseReasonMessages.js +19 -1
- package/lib/commonjs/core/sseReasonMessages.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +5 -1
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +5 -1
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/steps/AddressInfoStep.js +4 -3
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +4 -3
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/EconomicActivityStep.js +3 -2
- package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -1
- package/lib/commonjs/steps/EmailOtpStep.js +2 -1
- package/lib/commonjs/steps/EmailOtpStep.js.map +1 -1
- package/lib/commonjs/steps/FaceMatchStep.js +3 -2
- package/lib/commonjs/steps/FaceMatchStep.js.map +1 -1
- package/lib/commonjs/steps/LivenessMatchStep.js +3 -2
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneOtpStep.js +2 -1
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -1
- package/lib/commonjs/steps/TermsAndConditionsStep.js +3 -2
- package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/commonjs/transport/api.js +18 -1
- package/lib/commonjs/transport/api.js.map +1 -1
- package/lib/commonjs/transport/sse.js +2 -2
- package/lib/commonjs/transport/sse.js.map +1 -1
- package/lib/commonjs/types/index.js +18 -6
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/ui/StepShell.js +3 -2
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/VelionOnboardingScreen.js +5 -4
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/commonjs/ui/icons/StepIcon.js +2 -2
- package/lib/commonjs/ui/icons/StepIcon.js.map +1 -1
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js +3 -2
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js.map +1 -1
- package/lib/commonjs/ui/overlays/LoadingOverlay.js +2 -1
- package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -1
- package/lib/commonjs/ui/overlays/RetryDialog.js +4 -3
- package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -1
- package/lib/commonjs/ui/primitives/BackButton.js +2 -1
- package/lib/commonjs/ui/primitives/BackButton.js.map +1 -1
- package/lib/commonjs/ui/primitives/Banner.js +3 -2
- package/lib/commonjs/ui/primitives/Banner.js.map +1 -1
- package/lib/commonjs/ui/primitives/Button.js +8 -5
- package/lib/commonjs/ui/primitives/Button.js.map +1 -1
- package/lib/commonjs/ui/primitives/Checkbox.js +5 -4
- package/lib/commonjs/ui/primitives/Checkbox.js.map +1 -1
- package/lib/commonjs/ui/primitives/CountrySelect.js +16 -13
- package/lib/commonjs/ui/primitives/CountrySelect.js.map +1 -1
- package/lib/commonjs/ui/primitives/DatePicker.js +4 -3
- package/lib/commonjs/ui/primitives/DatePicker.js.map +1 -1
- package/lib/commonjs/ui/primitives/Input.js +9 -7
- package/lib/commonjs/ui/primitives/Input.js.map +1 -1
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +8 -6
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -1
- package/lib/commonjs/ui/primitives/Select.js +11 -9
- package/lib/commonjs/ui/primitives/Select.js.map +1 -1
- package/lib/commonjs/ui/primitives/Text.js +67 -0
- package/lib/commonjs/ui/primitives/Text.js.map +1 -0
- package/lib/commonjs/ui/primitives/index.js +13 -0
- package/lib/commonjs/ui/primitives/index.js.map +1 -1
- package/lib/commonjs/ui/theme/ThemeProvider.js +14 -1
- package/lib/commonjs/ui/theme/ThemeProvider.js.map +1 -1
- package/lib/commonjs/ui/theme/fontLoader.js +77 -0
- package/lib/commonjs/ui/theme/fontLoader.js.map +1 -0
- package/lib/commonjs/ui/theme/fonts.js +200 -0
- package/lib/commonjs/ui/theme/fonts.js.map +1 -0
- package/lib/commonjs/ui/theme/index.js +31 -0
- package/lib/commonjs/ui/theme/index.js.map +1 -1
- package/lib/commonjs/ui/theme/tokens.js +32 -9
- package/lib/commonjs/ui/theme/tokens.js.map +1 -1
- package/lib/module/camera/AddressSearchBar.js +5 -3
- package/lib/module/camera/AddressSearchBar.js.map +1 -1
- package/lib/module/camera/DocumentCapture.js +2 -1
- package/lib/module/camera/DocumentCapture.js.map +1 -1
- package/lib/module/camera/LivenessCamera.js +2 -1
- package/lib/module/camera/LivenessCamera.js.map +1 -1
- package/lib/module/camera/MapAddressPicker.js +2 -1
- package/lib/module/camera/MapAddressPicker.js.map +1 -1
- package/lib/module/core/VelionOnboarding.js +124 -7
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/core/sessionCancelledCopy.js +21 -0
- package/lib/module/core/sessionCancelledCopy.js.map +1 -0
- package/lib/module/core/sessionStateMapper.js +16 -4
- package/lib/module/core/sessionStateMapper.js.map +1 -1
- package/lib/module/core/sseReasonMessages.js +18 -0
- package/lib/module/core/sseReasonMessages.js.map +1 -1
- package/lib/module/i18n/strings/en.js +5 -1
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +5 -1
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/steps/AddressInfoStep.js +2 -1
- package/lib/module/steps/AddressInfoStep.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +2 -1
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/EconomicActivityStep.js +2 -1
- package/lib/module/steps/EconomicActivityStep.js.map +1 -1
- package/lib/module/steps/EmailOtpStep.js +2 -1
- package/lib/module/steps/EmailOtpStep.js.map +1 -1
- package/lib/module/steps/FaceMatchStep.js +2 -1
- package/lib/module/steps/FaceMatchStep.js.map +1 -1
- package/lib/module/steps/LivenessMatchStep.js +2 -1
- package/lib/module/steps/LivenessMatchStep.js.map +1 -1
- package/lib/module/steps/PhoneOtpStep.js +2 -1
- package/lib/module/steps/PhoneOtpStep.js.map +1 -1
- package/lib/module/steps/TermsAndConditionsStep.js +2 -1
- package/lib/module/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/module/transport/api.js +18 -1
- package/lib/module/transport/api.js.map +1 -1
- package/lib/module/transport/sse.js +2 -2
- package/lib/module/transport/sse.js.map +1 -1
- package/lib/module/types/index.js +18 -6
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/ui/StepShell.js +2 -1
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/VelionOnboardingScreen.js +2 -1
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/module/ui/icons/StepIcon.js +1 -1
- package/lib/module/ui/icons/StepIcon.js.map +1 -1
- package/lib/module/ui/overlays/AnalyzingOverlay.js +2 -1
- package/lib/module/ui/overlays/AnalyzingOverlay.js.map +1 -1
- package/lib/module/ui/overlays/LoadingOverlay.js +2 -1
- package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -1
- package/lib/module/ui/overlays/RetryDialog.js +2 -1
- package/lib/module/ui/overlays/RetryDialog.js.map +1 -1
- package/lib/module/ui/primitives/BackButton.js +2 -1
- package/lib/module/ui/primitives/BackButton.js.map +1 -1
- package/lib/module/ui/primitives/Banner.js +2 -1
- package/lib/module/ui/primitives/Banner.js.map +1 -1
- package/lib/module/ui/primitives/Button.js +7 -4
- package/lib/module/ui/primitives/Button.js.map +1 -1
- package/lib/module/ui/primitives/Checkbox.js +2 -1
- package/lib/module/ui/primitives/Checkbox.js.map +1 -1
- package/lib/module/ui/primitives/CountrySelect.js +8 -5
- package/lib/module/ui/primitives/CountrySelect.js.map +1 -1
- package/lib/module/ui/primitives/DatePicker.js +2 -1
- package/lib/module/ui/primitives/DatePicker.js.map +1 -1
- package/lib/module/ui/primitives/Input.js +6 -4
- package/lib/module/ui/primitives/Input.js.map +1 -1
- package/lib/module/ui/primitives/SearchableSingleSelectList.js +5 -3
- package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -1
- package/lib/module/ui/primitives/Select.js +5 -3
- package/lib/module/ui/primitives/Select.js.map +1 -1
- package/lib/module/ui/primitives/Text.js +65 -0
- package/lib/module/ui/primitives/Text.js.map +1 -0
- package/lib/module/ui/primitives/index.js +1 -0
- package/lib/module/ui/primitives/index.js.map +1 -1
- package/lib/module/ui/theme/ThemeProvider.js +13 -1
- package/lib/module/ui/theme/ThemeProvider.js.map +1 -1
- package/lib/module/ui/theme/fontLoader.js +70 -0
- package/lib/module/ui/theme/fontLoader.js.map +1 -0
- package/lib/module/ui/theme/fonts.js +191 -0
- package/lib/module/ui/theme/fonts.js.map +1 -0
- package/lib/module/ui/theme/index.js +3 -2
- package/lib/module/ui/theme/index.js.map +1 -1
- package/lib/module/ui/theme/tokens.js +31 -9
- package/lib/module/ui/theme/tokens.js.map +1 -1
- package/lib/typescript/camera/AddressSearchBar.d.ts.map +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts +24 -0
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/core/sessionCancelledCopy.d.ts +14 -0
- package/lib/typescript/core/sessionCancelledCopy.d.ts.map +1 -0
- package/lib/typescript/core/sessionStateMapper.d.ts +11 -3
- package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -1
- package/lib/typescript/core/sseReasonMessages.d.ts +6 -0
- package/lib/typescript/core/sseReasonMessages.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +2 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -1
- package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -1
- package/lib/typescript/transport/api.d.ts +1 -0
- package/lib/typescript/transport/api.d.ts.map +1 -1
- package/lib/typescript/transport/sse.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +58 -12
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
- package/lib/typescript/ui/overlays/LoadingOverlay.d.ts.map +1 -1
- package/lib/typescript/ui/overlays/RetryDialog.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/BackButton.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Banner.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Button.d.ts +2 -1
- package/lib/typescript/ui/primitives/Button.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Checkbox.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/CountrySelect.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/DatePicker.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Input.d.ts +3 -3
- package/lib/typescript/ui/primitives/Input.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Select.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Text.d.ts +19 -0
- package/lib/typescript/ui/primitives/Text.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/index.d.ts +1 -0
- package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
- package/lib/typescript/ui/theme/ThemeProvider.d.ts +7 -0
- package/lib/typescript/ui/theme/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/ui/theme/fontLoader.d.ts +28 -0
- package/lib/typescript/ui/theme/fontLoader.d.ts.map +1 -0
- package/lib/typescript/ui/theme/fonts.d.ts +157 -0
- package/lib/typescript/ui/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/ui/theme/index.d.ts +3 -2
- package/lib/typescript/ui/theme/index.d.ts.map +1 -1
- package/lib/typescript/ui/theme/tokens.d.ts +25 -2
- package/lib/typescript/ui/theme/tokens.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/camera/AddressSearchBar.tsx +3 -4
- package/src/camera/DocumentCapture.tsx +1 -1
- package/src/camera/LivenessCamera.tsx +1 -1
- package/src/camera/MapAddressPicker.tsx +1 -1
- package/src/core/VelionOnboarding.ts +118 -5
- package/src/core/sessionCancelledCopy.ts +29 -0
- package/src/core/sessionStateMapper.ts +18 -5
- package/src/core/sseReasonMessages.ts +20 -0
- package/src/i18n/strings/en.ts +5 -0
- package/src/i18n/strings/es.ts +5 -0
- package/src/index.ts +2 -0
- package/src/steps/AddressInfoStep.tsx +6 -1
- package/src/steps/DocumentsOcrStep.tsx +1 -1
- package/src/steps/EconomicActivityStep.tsx +6 -1
- package/src/steps/EmailOtpStep.tsx +6 -1
- package/src/steps/FaceMatchStep.tsx +6 -1
- package/src/steps/LivenessMatchStep.tsx +7 -1
- package/src/steps/PhoneOtpStep.tsx +6 -1
- package/src/steps/TermsAndConditionsStep.tsx +7 -1
- package/src/transport/api.ts +17 -1
- package/src/transport/sse.ts +2 -0
- package/src/types/index.ts +58 -12
- package/src/ui/StepShell.tsx +6 -1
- package/src/ui/VelionOnboardingScreen.tsx +5 -1
- package/src/ui/icons/StepIcon.tsx +1 -1
- package/src/ui/overlays/AnalyzingOverlay.tsx +1 -1
- package/src/ui/overlays/LoadingOverlay.tsx +7 -1
- package/src/ui/overlays/RetryDialog.tsx +5 -1
- package/src/ui/primitives/BackButton.tsx +5 -1
- package/src/ui/primitives/Banner.tsx +5 -1
- package/src/ui/primitives/Button.tsx +5 -4
- package/src/ui/primitives/Checkbox.tsx +5 -1
- package/src/ui/primitives/CountrySelect.tsx +5 -6
- package/src/ui/primitives/DatePicker.tsx +7 -1
- package/src/ui/primitives/Input.tsx +6 -6
- package/src/ui/primitives/SearchableSingleSelectList.tsx +3 -4
- package/src/ui/primitives/Select.tsx +3 -3
- package/src/ui/primitives/Text.tsx +66 -0
- package/src/ui/primitives/index.ts +1 -0
- package/src/ui/theme/ThemeProvider.tsx +15 -2
- package/src/ui/theme/fontLoader.ts +92 -0
- package/src/ui/theme/fonts.ts +220 -0
- package/src/ui/theme/index.ts +9 -0
- package/src/ui/theme/tokens.ts +44 -6
|
@@ -39,10 +39,10 @@ import {
|
|
|
39
39
|
Easing,
|
|
40
40
|
Platform,
|
|
41
41
|
StyleSheet,
|
|
42
|
-
Text,
|
|
43
42
|
useWindowDimensions,
|
|
44
43
|
View,
|
|
45
44
|
} from 'react-native';
|
|
45
|
+
import { Text } from '../ui/primitives/Text';
|
|
46
46
|
import Svg, { Defs, Ellipse, Mask, Rect } from 'react-native-svg';
|
|
47
47
|
import {
|
|
48
48
|
Camera,
|
|
@@ -34,9 +34,9 @@ import {
|
|
|
34
34
|
Keyboard,
|
|
35
35
|
Platform,
|
|
36
36
|
StyleSheet,
|
|
37
|
-
Text,
|
|
38
37
|
View,
|
|
39
38
|
} from 'react-native';
|
|
39
|
+
import { Text } from '../ui/primitives/Text';
|
|
40
40
|
import * as Location from 'expo-location';
|
|
41
41
|
import { Button } from '../ui/primitives/Button';
|
|
42
42
|
import { Banner } from '../ui/primitives/Banner';
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* once the retry quota is exhausted the backend emits SESSION_DECLINED instead
|
|
15
15
|
* - 45 s watchdog for terminal SSE event after final step → fallback GET
|
|
16
16
|
* - SESSION_DECLINED handling races with module.run()
|
|
17
|
+
* - SESSION_CANCELLED rides the same channel as SESSION_DECLINED (it can land
|
|
18
|
+
* mid-step too) but never triggers a GET: the backend revokes the session
|
|
19
|
+
* token with the cancellation, so the SDK closes SSE and stops calling out
|
|
17
20
|
*/
|
|
18
21
|
|
|
19
22
|
import { TypedEventEmitter } from '../utils/EventEmitter';
|
|
@@ -25,11 +28,13 @@ import {
|
|
|
25
28
|
mapOnboardingDtoToResult,
|
|
26
29
|
mapOnboardingDtoToResultWithStatus,
|
|
27
30
|
isTerminalSessionStatusFromDto,
|
|
31
|
+
isCancelledSessionStatus,
|
|
28
32
|
requiresCurrentStepForSessionStatus,
|
|
29
33
|
deriveCanGoBack,
|
|
30
34
|
} from './sessionStateMapper';
|
|
31
35
|
import { createSessionEventSource } from '../transport/sse';
|
|
32
36
|
import { resolveSessionDeclinedCopy } from './sessionDeclinedCopy';
|
|
37
|
+
import { resolveSessionCancelledCopy } from './sessionCancelledCopy';
|
|
33
38
|
import { resolveRetryStepCopy } from './retryStepCopy';
|
|
34
39
|
import {
|
|
35
40
|
parseBackExitCommand,
|
|
@@ -132,10 +137,21 @@ function isTerminalSessionEvent(event: OnboardingSessionEvent): boolean {
|
|
|
132
137
|
t === 'SESSION_APPROVED' ||
|
|
133
138
|
t === 'SESSION_MANUAL_REVIEW' ||
|
|
134
139
|
t === 'SESSION_DECLINED' ||
|
|
140
|
+
t === 'SESSION_CANCELLED' ||
|
|
135
141
|
t === 'SESSION_TERMINATED'
|
|
136
142
|
);
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Terminal events that end the flow on their own, without a GET for the final
|
|
147
|
+
* result: they can arrive mid-step and race the active module. SESSION_CANCELLED
|
|
148
|
+
* is here because its token is already revoked when it arrives.
|
|
149
|
+
*/
|
|
150
|
+
function isSessionEndingEvent(event: OnboardingSessionEvent): boolean {
|
|
151
|
+
const t = event.event_type;
|
|
152
|
+
return t === 'SESSION_DECLINED' || t === 'SESSION_CANCELLED';
|
|
153
|
+
}
|
|
154
|
+
|
|
139
155
|
function terminalEventTypeToStatus(
|
|
140
156
|
eventType: string | undefined,
|
|
141
157
|
): OnboardingResult['status'] | undefined {
|
|
@@ -153,6 +169,11 @@ function terminalEventTypeToStatus(
|
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
|
|
172
|
+
/** GET reported `CANCELLED`; its DTO carries no reason, so the event has none. */
|
|
173
|
+
function cancelledEventFromDto(): OnboardingSessionEvent {
|
|
174
|
+
return { event_type: 'SESSION_CANCELLED', session_status: 'CANCELLED' };
|
|
175
|
+
}
|
|
176
|
+
|
|
156
177
|
function isSessionTokenAuthSdkError(err: unknown): err is SdkError {
|
|
157
178
|
return (
|
|
158
179
|
err != null &&
|
|
@@ -378,9 +399,13 @@ export class VelionOnboarding {
|
|
|
378
399
|
this.stepReversibility = sessionState.stepReversibility ?? [];
|
|
379
400
|
this.emitter.emit('session:loaded', sessionState);
|
|
380
401
|
|
|
402
|
+
if (isCancelledSessionStatus(dto.status)) {
|
|
403
|
+
this.showLoading(null);
|
|
404
|
+
this.endFlowWithSessionCancelled(cancelledEventFromDto());
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
381
407
|
if (isTerminalSessionStatusFromDto(dto.status)) {
|
|
382
|
-
|
|
383
|
-
this.completeFlow(result);
|
|
408
|
+
this.completeFlow(this.resultFromDtoOrThrow(dto));
|
|
384
409
|
return;
|
|
385
410
|
}
|
|
386
411
|
|
|
@@ -707,6 +732,10 @@ export class VelionOnboarding {
|
|
|
707
732
|
private async finalizeSessionWithTerminalEvent(
|
|
708
733
|
event: OnboardingSessionEvent,
|
|
709
734
|
): Promise<void> {
|
|
735
|
+
if (isSessionEndingEvent(event)) {
|
|
736
|
+
this.endFlowWithSessionDeclined(event);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
710
739
|
const status = terminalEventTypeToStatus(event.event_type);
|
|
711
740
|
if (!status) {
|
|
712
741
|
await this.finalizeSessionSingleGet();
|
|
@@ -747,8 +776,25 @@ export class VelionOnboarding {
|
|
|
747
776
|
cause: err,
|
|
748
777
|
} satisfies SdkError;
|
|
749
778
|
}
|
|
779
|
+
if (isCancelledSessionStatus(dto.status)) {
|
|
780
|
+
this.endFlowWithSessionCancelled(cancelledEventFromDto());
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
this.completeFlow(this.resultFromDtoOrThrow(dto));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Maps a terminal GET to the host result. A status this SDK does not know is
|
|
788
|
+
* an error, not a verdict: reporting it as MANUAL_REVIEW (the old default)
|
|
789
|
+
* would tell the host something the backend never said.
|
|
790
|
+
*/
|
|
791
|
+
private resultFromDtoOrThrow(dto: OnboardingDtoResponse): OnboardingResult {
|
|
750
792
|
const result = mapOnboardingDtoToResult(dto, this.config.sessionId);
|
|
751
|
-
|
|
793
|
+
if (result) return result;
|
|
794
|
+
throw {
|
|
795
|
+
code: SdkErrorCode.API_ERROR,
|
|
796
|
+
message: `Session ${this.config.sessionId} reports an unknown status "${String(dto.status)}".`,
|
|
797
|
+
} satisfies SdkError;
|
|
752
798
|
}
|
|
753
799
|
|
|
754
800
|
private completeFlow(result: OnboardingResult): void {
|
|
@@ -827,7 +873,16 @@ export class VelionOnboarding {
|
|
|
827
873
|
});
|
|
828
874
|
}
|
|
829
875
|
|
|
876
|
+
/**
|
|
877
|
+
* Ends the flow on an SSE event that carries its own outcome. Dispatches
|
|
878
|
+
* SESSION_CANCELLED to {@link endFlowWithSessionCancelled}; everything else
|
|
879
|
+
* routed here is SESSION_DECLINED.
|
|
880
|
+
*/
|
|
830
881
|
private endFlowWithSessionDeclined(event: OnboardingSessionEvent): void {
|
|
882
|
+
if (event.event_type === 'SESSION_CANCELLED') {
|
|
883
|
+
this.endFlowWithSessionCancelled(event);
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
831
886
|
if (this.sessionEnded) return;
|
|
832
887
|
this.sessionEnded = true;
|
|
833
888
|
log.info('[Flow] Session finalized', {
|
|
@@ -853,6 +908,55 @@ export class VelionOnboarding {
|
|
|
853
908
|
this.emitError(err);
|
|
854
909
|
}
|
|
855
910
|
|
|
911
|
+
/**
|
|
912
|
+
* SESSION_CANCELLED: the backend retired the session and revoked its token.
|
|
913
|
+
* Also reached when GET reports `status: CANCELLED`. Closes SSE (so it does
|
|
914
|
+
* not reconnect into 401s) and the API caller, drops any active module, and
|
|
915
|
+
* emits `onError` with `SESSION_CANCELLED` — the same channel as
|
|
916
|
+
* SESSION_DECLINED — carrying the localized cancelled copy.
|
|
917
|
+
*/
|
|
918
|
+
private endFlowWithSessionCancelled(event: OnboardingSessionEvent): void {
|
|
919
|
+
if (this.sessionEnded) return;
|
|
920
|
+
this.sessionEnded = true;
|
|
921
|
+
this.stopTalkingToBackend();
|
|
922
|
+
log.info('[Flow] Session finalized', {
|
|
923
|
+
sessionId: this.config.sessionId,
|
|
924
|
+
status: 'CANCELLED',
|
|
925
|
+
terminalReason: event.reason,
|
|
926
|
+
stepCode: event.step_code,
|
|
927
|
+
});
|
|
928
|
+
const copy = resolveSessionCancelledCopy(
|
|
929
|
+
this.config.locale,
|
|
930
|
+
this.config.finalResultScreenTexts,
|
|
931
|
+
event.reason,
|
|
932
|
+
);
|
|
933
|
+
const err: SdkError = {
|
|
934
|
+
code: SdkErrorCode.SESSION_CANCELLED,
|
|
935
|
+
message: copy.message,
|
|
936
|
+
...(event.reason !== undefined && { cancelReason: event.reason }),
|
|
937
|
+
...(event.step_code !== undefined && { stepCode: event.step_code }),
|
|
938
|
+
declineTitle: copy.title,
|
|
939
|
+
declineMessage: copy.message,
|
|
940
|
+
};
|
|
941
|
+
this.emitError(err);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/** Closes SSE and the API caller, and tears down the active step. */
|
|
945
|
+
private stopTalkingToBackend(): void {
|
|
946
|
+
this.api.close();
|
|
947
|
+
this.sseCleanup?.();
|
|
948
|
+
this.sseCleanup = null;
|
|
949
|
+
this.sseAbortController.abort();
|
|
950
|
+
this.activeModule?.destroy();
|
|
951
|
+
this.activeModule = null;
|
|
952
|
+
this.retryDialogResolve?.('cancel');
|
|
953
|
+
this.retryDialogResolve = null;
|
|
954
|
+
// Release a pending routing wait now instead of at its 30 s timeout.
|
|
955
|
+
const resolveNext = this.sseNextStepResolve;
|
|
956
|
+
this.sseNextStepResolve = null;
|
|
957
|
+
resolveNext?.(null);
|
|
958
|
+
}
|
|
959
|
+
|
|
856
960
|
// ── SSE plumbing ──────────────────────────────────────────────────────────
|
|
857
961
|
|
|
858
962
|
private openSseStream(sessionToken: string): void {
|
|
@@ -896,10 +1000,15 @@ export class VelionOnboarding {
|
|
|
896
1000
|
this.config.onSessionEvent?.(event);
|
|
897
1001
|
const isTerminal = isTerminalSessionEvent(event);
|
|
898
1002
|
|
|
899
|
-
if (event
|
|
1003
|
+
if (isSessionEndingEvent(event)) {
|
|
900
1004
|
this.pendingTerminalEvent = event;
|
|
901
1005
|
if (this.sessionDeclineHandler) {
|
|
902
1006
|
this.sessionDeclineHandler(event);
|
|
1007
|
+
} else if (event.event_type === 'SESSION_CANCELLED' && this.retryDialogResolve) {
|
|
1008
|
+
// The retry dialog waits on the user, not on SSE: a cancelled session
|
|
1009
|
+
// must not sit behind it, since retrying would only hit a revoked token.
|
|
1010
|
+
this.pendingTerminalEvent = null;
|
|
1011
|
+
this.endFlowWithSessionCancelled(event);
|
|
903
1012
|
} else {
|
|
904
1013
|
this.pendingSessionDeclined = event;
|
|
905
1014
|
}
|
|
@@ -1140,6 +1249,10 @@ export class VelionOnboarding {
|
|
|
1140
1249
|
Math.min(ROUTING_SSE_WAIT_MS, budgetMs),
|
|
1141
1250
|
);
|
|
1142
1251
|
if (sseNext) return { kind: 'routed', command: sseNext };
|
|
1252
|
+
// The flow ended while this cycle waited (e.g. SESSION_CANCELLED won the
|
|
1253
|
+
// decline race): nobody consumes the result, and the fallback GET would only
|
|
1254
|
+
// hit a revoked token.
|
|
1255
|
+
if (this.sessionEnded || this.status === 'DESTROYED') return { kind: 'unresolved' };
|
|
1143
1256
|
// A terminal event interrupted the wait: the caller consumes it.
|
|
1144
1257
|
if (this.pendingTerminalEvent) return { kind: 'terminal' };
|
|
1145
1258
|
const afterWait = this.consumeQueuedNextStepCommand();
|
|
@@ -1252,7 +1365,7 @@ export class VelionOnboarding {
|
|
|
1252
1365
|
const event = this.pendingTerminalEvent;
|
|
1253
1366
|
if (!event) return false;
|
|
1254
1367
|
this.pendingTerminalEvent = null;
|
|
1255
|
-
if (event
|
|
1368
|
+
if (isSessionEndingEvent(event)) {
|
|
1256
1369
|
this.endFlowWithSessionDeclined(event);
|
|
1257
1370
|
return true;
|
|
1258
1371
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Copy for a cancelled session (SSE SESSION_CANCELLED or GET
|
|
3
|
+
* `status: CANCELLED`). A cancellation is not a verdict on the person: the
|
|
4
|
+
* backend closed the session. Precedence: `finalResultScreenTexts.cancelled`,
|
|
5
|
+
* then the built-in copy for the backend `reason`, then the generic copy.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getStrings, resolveLocale } from '../i18n';
|
|
9
|
+
import type { VelionFinalResultScreenTexts } from '../types';
|
|
10
|
+
import { SESSION_CANCELLED_REASON_MESSAGES } from './sseReasonMessages';
|
|
11
|
+
|
|
12
|
+
export interface ResolvedSessionCancelledCopy {
|
|
13
|
+
title: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Resolves the title and body shown when the session was cancelled. */
|
|
18
|
+
export function resolveSessionCancelledCopy(
|
|
19
|
+
locale: string | undefined,
|
|
20
|
+
texts: VelionFinalResultScreenTexts | undefined,
|
|
21
|
+
reason?: string,
|
|
22
|
+
): ResolvedSessionCancelledCopy {
|
|
23
|
+
const generic = getStrings(locale).result;
|
|
24
|
+
const byReason = SESSION_CANCELLED_REASON_MESSAGES[reason?.trim() ?? '']?.[resolveLocale(locale)];
|
|
25
|
+
return {
|
|
26
|
+
title: texts?.cancelled?.title ?? byReason?.title ?? generic.cancelledTitle,
|
|
27
|
+
message: texts?.cancelled?.message ?? byReason?.message ?? generic.cancelledBody,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -155,17 +155,28 @@ function resolveCurrentStepFromLegacySteps(
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Maps GET /sessions `status` to {@link OnboardingResult.status}.
|
|
158
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* `INITIATED` / `IN_PROGRESS` map to `MANUAL_REVIEW`: they only reach this
|
|
160
|
+
* mapper when the SDK gave up waiting for the verdict, which the backend will
|
|
161
|
+
* still produce asynchronously. Any other value returns `null`: a status this
|
|
162
|
+
* SDK does not know (`CANCELLED` before OSDKR-44 was one) must not be reported
|
|
163
|
+
* to the host as a verdict it never was.
|
|
159
164
|
*/
|
|
160
165
|
export function mapSessionDtoStatusToResultStatus(
|
|
161
166
|
raw: string | undefined,
|
|
162
|
-
): OnboardingResult['status'] {
|
|
167
|
+
): OnboardingResult['status'] | null {
|
|
163
168
|
const s = typeof raw === 'string' ? raw.trim().toUpperCase() : '';
|
|
164
169
|
if (s === 'APPROVED') return 'APPROVED';
|
|
165
170
|
if (s === 'MANUAL_REVIEW' || s === 'IN_REVIEW') return 'MANUAL_REVIEW';
|
|
166
171
|
if (s === 'REJECTED') return 'REJECTED';
|
|
167
172
|
if (s === 'DECLINED') return 'DECLINED';
|
|
168
|
-
return 'MANUAL_REVIEW';
|
|
173
|
+
if (s === 'INITIATED' || s === 'IN_PROGRESS') return 'MANUAL_REVIEW';
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** True when GET session reports a session cancelled by the backend (not a verdict). */
|
|
178
|
+
export function isCancelledSessionStatus(raw: string | undefined): boolean {
|
|
179
|
+
return typeof raw === 'string' && raw.trim().toUpperCase() === 'CANCELLED';
|
|
169
180
|
}
|
|
170
181
|
|
|
171
182
|
/**
|
|
@@ -179,6 +190,7 @@ export function isTerminalSessionStatusFromDto(raw: string | undefined): boolean
|
|
|
179
190
|
s === 'MANUAL_REVIEW' ||
|
|
180
191
|
s === 'REJECTED' ||
|
|
181
192
|
s === 'DECLINED' ||
|
|
193
|
+
s === 'CANCELLED' ||
|
|
182
194
|
s === 'IN_REVIEW'
|
|
183
195
|
);
|
|
184
196
|
}
|
|
@@ -193,13 +205,14 @@ export function requiresCurrentStepForSessionStatus(raw: string | undefined): bo
|
|
|
193
205
|
|
|
194
206
|
/**
|
|
195
207
|
* Builds OnboardingResult from the same onboarding DTO when status is terminal.
|
|
208
|
+
* Returns `null` when the status is not one {@link mapSessionDtoStatusToResultStatus} knows.
|
|
196
209
|
*/
|
|
197
210
|
export function mapOnboardingDtoToResult(
|
|
198
211
|
dto: OnboardingDtoResponse,
|
|
199
212
|
sessionId: string,
|
|
200
|
-
): OnboardingResult {
|
|
213
|
+
): OnboardingResult | null {
|
|
201
214
|
const terminal = mapSessionDtoStatusToResultStatus(dto.status);
|
|
202
|
-
return buildResultFromDto(dto, sessionId, terminal);
|
|
215
|
+
return terminal === null ? null : buildResultFromDto(dto, sessionId, terminal);
|
|
203
216
|
}
|
|
204
217
|
|
|
205
218
|
/**
|
|
@@ -529,3 +529,23 @@ export const SESSION_MANUAL_REVIEW_REASON_MESSAGES: Record<string, LocalizedPair
|
|
|
529
529
|
},
|
|
530
530
|
},
|
|
531
531
|
};
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Reasons on SESSION_CANCELLED. A cancellation is not a verdict on the person:
|
|
535
|
+
* the backend closed the session (e.g. a new workflow version was published
|
|
536
|
+
* forcing it). Unknown reasons fall back to the generic cancelled copy.
|
|
537
|
+
*/
|
|
538
|
+
export const SESSION_CANCELLED_REASON_MESSAGES: Record<string, LocalizedPair> = {
|
|
539
|
+
WORKFLOW_VERSION_RETIRED: {
|
|
540
|
+
en: {
|
|
541
|
+
title: 'The verification process was updated',
|
|
542
|
+
message:
|
|
543
|
+
'We closed this session because the process changed. Start the verification again to continue with the current version.',
|
|
544
|
+
},
|
|
545
|
+
es: {
|
|
546
|
+
title: 'El proceso de verificación se actualizó',
|
|
547
|
+
message:
|
|
548
|
+
'Cerramos esta sesión porque el proceso cambió. Volvé a iniciar la verificación para continuar con la versión actual.',
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
};
|
package/src/i18n/strings/en.ts
CHANGED
|
@@ -304,6 +304,11 @@ export const EN: StringsTable = {
|
|
|
304
304
|
rejectedTitle: 'Verification rejected',
|
|
305
305
|
rejectedBody: 'This session could not be completed.',
|
|
306
306
|
declineHeadline: 'We could not continue',
|
|
307
|
+
// Session cancelled by the backend (SESSION_CANCELLED / GET status CANCELLED),
|
|
308
|
+
// e.g. its workflow version was retired. Not a verdict on the user.
|
|
309
|
+
cancelledTitle: 'This session was closed',
|
|
310
|
+
cancelledBody:
|
|
311
|
+
'This session is no longer active and cannot be continued. Start the verification again to begin a new one.',
|
|
307
312
|
},
|
|
308
313
|
// Retry dialog shown when the backend asks the SDK to re-present a failed step
|
|
309
314
|
// (ROUTING_COMMAND / RETRY_STEP). Copy is derived from the step, not the
|
package/src/i18n/strings/es.ts
CHANGED
|
@@ -304,6 +304,11 @@ export const ES = {
|
|
|
304
304
|
rejectedTitle: 'Verificación rechazada',
|
|
305
305
|
rejectedBody: 'No se pudo completar esta sesión.',
|
|
306
306
|
declineHeadline: 'No pudimos continuar',
|
|
307
|
+
// Session cancelled by the backend (SESSION_CANCELLED / GET status CANCELLED),
|
|
308
|
+
// e.g. its workflow version was retired. Not a verdict on the user.
|
|
309
|
+
cancelledTitle: 'Esta sesión se cerró',
|
|
310
|
+
cancelledBody:
|
|
311
|
+
'La sesión ya no está activa y no podés continuarla. Volvé a iniciar la verificación para empezar de nuevo.',
|
|
307
312
|
},
|
|
308
313
|
// Retry dialog shown when the backend asks the SDK to re-present a failed step
|
|
309
314
|
// (ROUTING_COMMAND / RETRY_STEP). Copy is derived from the step, not the
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,12 @@ import {
|
|
|
28
28
|
type Dispatch,
|
|
29
29
|
type SetStateAction,
|
|
30
30
|
} from 'react';
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
Platform,
|
|
33
|
+
StyleSheet,
|
|
34
|
+
View,
|
|
35
|
+
} from 'react-native';
|
|
36
|
+
import { Text } from '../ui/primitives/Text';
|
|
32
37
|
import {
|
|
33
38
|
SdkErrorCode,
|
|
34
39
|
type AddressInfoPayload,
|
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { useCallback, useMemo, useState } from 'react';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
Keyboard,
|
|
23
|
+
StyleSheet,
|
|
24
|
+
View,
|
|
25
|
+
} from 'react-native';
|
|
26
|
+
import { Text } from '../ui/primitives/Text';
|
|
22
27
|
import {
|
|
23
28
|
SdkErrorCode,
|
|
24
29
|
type EconomicActivitySelectionPayload,
|
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { useCallback, useState } from 'react';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Pressable,
|
|
15
|
+
StyleSheet,
|
|
16
|
+
View,
|
|
17
|
+
} from 'react-native';
|
|
18
|
+
import { Text } from '../ui/primitives/Text';
|
|
14
19
|
import { SdkErrorCode, type SdkError } from '../types';
|
|
15
20
|
import { Banner } from '../ui/primitives/Banner';
|
|
16
21
|
import { Button } from '../ui/primitives/Button';
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { useEffect, useRef } from 'react';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
ActivityIndicator,
|
|
19
|
+
StyleSheet,
|
|
20
|
+
View,
|
|
21
|
+
} from 'react-native';
|
|
22
|
+
import { Text } from '../ui/primitives/Text';
|
|
18
23
|
import {
|
|
19
24
|
SdkErrorCode,
|
|
20
25
|
type OnboardingDtoResponse,
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
Image,
|
|
20
|
+
ScrollView,
|
|
21
|
+
StyleSheet,
|
|
22
|
+
View,
|
|
23
|
+
} from 'react-native';
|
|
24
|
+
import { Text } from '../ui/primitives/Text';
|
|
19
25
|
// `expo-file-system` v19's `File` class wraps a `file://` path with a Blob-
|
|
20
26
|
// compatible API (`arrayBuffer`, `size`, `delete`). We read the recorded mp4
|
|
21
27
|
// to bytes in JS and PUT them with the global `fetch`. For the typical
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { useCallback, useState } from 'react';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Pressable,
|
|
13
|
+
StyleSheet,
|
|
14
|
+
View,
|
|
15
|
+
} from 'react-native';
|
|
16
|
+
import { Text } from '../ui/primitives/Text';
|
|
12
17
|
import { SdkErrorCode, type SdkError } from '../types';
|
|
13
18
|
import { Banner } from '../ui/primitives/Banner';
|
|
14
19
|
import { Button } from '../ui/primitives/Button';
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Linking,
|
|
15
|
+
Pressable,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
View,
|
|
18
|
+
} from 'react-native';
|
|
19
|
+
import { Text } from '../ui/primitives/Text';
|
|
14
20
|
import {
|
|
15
21
|
SdkErrorCode,
|
|
16
22
|
type SdkError,
|
package/src/transport/api.ts
CHANGED
|
@@ -92,6 +92,7 @@ export function createApiCaller(
|
|
|
92
92
|
let currentToken = sessionToken;
|
|
93
93
|
let currentExpiresAt = expiresAt;
|
|
94
94
|
let clockSkewWarned = false;
|
|
95
|
+
let closed = false;
|
|
95
96
|
const appId = getAppId();
|
|
96
97
|
|
|
97
98
|
function ensureTokenValid(): void {
|
|
@@ -136,11 +137,26 @@ export function createApiCaller(
|
|
|
136
137
|
clockSkewWarned = false;
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Refuses every later request, which rejects with an `AbortError` like an
|
|
142
|
+
* aborted call. Used once the backend closed the session (SESSION_CANCELLED):
|
|
143
|
+
* the token is revoked, so any request would only earn a 401.
|
|
144
|
+
*/
|
|
145
|
+
function close(): void {
|
|
146
|
+
closed = true;
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
async function call<TResponse>(
|
|
140
150
|
endpoint: string,
|
|
141
151
|
init: RequestInit,
|
|
142
152
|
options: ApiCallOptions = {},
|
|
143
153
|
): Promise<TResponse> {
|
|
154
|
+
if (closed) {
|
|
155
|
+
// Hermes has no DOMException; an Error named AbortError is what callers check.
|
|
156
|
+
const aborted = new Error(`Session closed; request to "${endpoint}" not sent.`);
|
|
157
|
+
aborted.name = 'AbortError';
|
|
158
|
+
throw aborted;
|
|
159
|
+
}
|
|
144
160
|
ensureTokenValid();
|
|
145
161
|
const url = `${baseUrl}${endpoint}`;
|
|
146
162
|
|
|
@@ -267,7 +283,7 @@ export function createApiCaller(
|
|
|
267
283
|
);
|
|
268
284
|
}
|
|
269
285
|
|
|
270
|
-
return { get, post, postFormData, setSessionToken } as const;
|
|
286
|
+
return { get, post, postFormData, setSessionToken, close } as const;
|
|
271
287
|
}
|
|
272
288
|
|
|
273
289
|
/** The type of the object returned by `createApiCaller`. */
|
package/src/transport/sse.ts
CHANGED
|
@@ -57,6 +57,7 @@ const KNOWN_EVENT_TYPES = [
|
|
|
57
57
|
'SESSION_APPROVED',
|
|
58
58
|
'SESSION_MANUAL_REVIEW',
|
|
59
59
|
'SESSION_DECLINED',
|
|
60
|
+
'SESSION_CANCELLED',
|
|
60
61
|
'SESSION_TERMINATED',
|
|
61
62
|
// Legacy/domain-event names emitted by `SseDomainEventConsumer` in the
|
|
62
63
|
// Spring orchestrator. Listening to both lets the same SDK build talk to
|
|
@@ -66,6 +67,7 @@ const KNOWN_EVENT_TYPES = [
|
|
|
66
67
|
'SessionApprovedEvent',
|
|
67
68
|
'SessionManualReviewEvent',
|
|
68
69
|
'SessionDeclinedEvent',
|
|
70
|
+
'SessionCancelledEvent',
|
|
69
71
|
'SessionTerminatedEvent',
|
|
70
72
|
'OnboardingCreatedEvent',
|
|
71
73
|
] as const;
|