@smileid/usesmileid 12.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/core/exception/agent_mode_with_enhanced_liveness_exception.d.ts +11 -0
- package/dist/core/exception/agent_mode_with_enhanced_liveness_exception.d.ts.map +1 -0
- package/dist/core/exception/agent_mode_with_enhanced_liveness_exception.js +17 -0
- package/dist/core/exception/agent_mode_with_enhanced_liveness_exception.js.map +1 -0
- package/dist/core/exception/capture_validation_exceptions.d.ts +1 -0
- package/dist/core/exception/capture_validation_exceptions.d.ts.map +1 -1
- package/dist/core/exception/capture_validation_exceptions.js +1 -0
- package/dist/core/exception/capture_validation_exceptions.js.map +1 -1
- package/dist/core/exception/index.d.ts +1 -0
- package/dist/core/exception/index.d.ts.map +1 -1
- package/dist/core/exception/index.js +1 -0
- package/dist/core/exception/index.js.map +1 -1
- package/dist/core/exception/use_smile_id_error_code.d.ts +1 -0
- package/dist/core/exception/use_smile_id_error_code.d.ts.map +1 -1
- package/dist/core/exception/use_smile_id_error_code.js +1 -0
- package/dist/core/exception/use_smile_id_error_code.js.map +1 -1
- package/dist/core/models/config.d.ts +19 -0
- package/dist/core/models/config.d.ts.map +1 -1
- package/dist/core/models/document_type.d.ts +1 -1
- package/dist/core/models/document_type.d.ts.map +1 -1
- package/dist/core/models/document_type.js +2 -2
- package/dist/core/models/document_type.js.map +1 -1
- package/dist/core/models/global_privacy_control.d.ts +36 -0
- package/dist/core/models/global_privacy_control.d.ts.map +1 -0
- package/dist/core/models/global_privacy_control.js +39 -0
- package/dist/core/models/global_privacy_control.js.map +1 -0
- package/dist/core/models/network_config.d.ts +2 -2
- package/dist/core/models/network_config.js +2 -2
- package/dist/data/api/interceptors/smile_auth_interceptor.d.ts.map +1 -1
- package/dist/data/api/interceptors/smile_auth_interceptor.js +3 -17
- package/dist/data/api/interceptors/smile_auth_interceptor.js.map +1 -1
- package/dist/data/api/smile_id_api.d.ts +1 -1
- package/dist/data/api/smile_id_api.d.ts.map +1 -1
- package/dist/data/dsl/builder/retry_config_builder.d.ts +4 -4
- package/dist/data/dsl/builder/retry_config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/retry_config_builder.js +6 -6
- package/dist/data/dsl/builder/retry_config_builder.js.map +1 -1
- package/dist/data/smile_id_urls.d.ts +1 -1
- package/dist/data/smile_id_urls.js +1 -1
- package/dist/data/smile_id_urls.js.map +1 -1
- package/dist/data/util/retry_util.d.ts +1 -1
- package/dist/data/util/retry_util.d.ts.map +1 -1
- package/dist/data/util/retry_util.js +5 -0
- package/dist/data/util/retry_util.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/metadata/builder_configuration.d.ts +5 -0
- package/dist/metadata/builder_configuration.d.ts.map +1 -1
- package/dist/metadata/builder_configuration.js +1 -0
- package/dist/metadata/builder_configuration.js.map +1 -1
- package/dist/metadata/metadata_configuration_mappers.d.ts +2 -3
- package/dist/metadata/metadata_configuration_mappers.d.ts.map +1 -1
- package/dist/metadata/metadata_configuration_mappers.js +13 -6
- package/dist/metadata/metadata_configuration_mappers.js.map +1 -1
- package/dist/metadata/use_smile_id_metadata_factory.d.ts.map +1 -1
- package/dist/metadata/use_smile_id_metadata_factory.js +14 -5
- package/dist/metadata/use_smile_id_metadata_factory.js.map +1 -1
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_clip.d.ts +5 -2
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_clip.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_clip.js +8 -3
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_clip.js.map +1 -1
- package/dist/presentation/components/use_smile_id_instructions_hero.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_instructions_hero.js +8 -3
- package/dist/presentation/components/use_smile_id_instructions_hero.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/config_builder.d.ts +16 -0
- package/dist/presentation/flow/dsl/builder/config_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/config_builder.js +18 -0
- package/dist/presentation/flow/dsl/builder/config_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/screens_builder.d.ts +3 -6
- package/dist/presentation/flow/dsl/builder/screens_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/screens_builder.js +3 -6
- package/dist/presentation/flow/dsl/builder/screens_builder.js.map +1 -1
- package/dist/presentation/flow/flow_navigation_manager.d.ts +5 -1
- package/dist/presentation/flow/flow_navigation_manager.d.ts.map +1 -1
- package/dist/presentation/flow/flow_navigation_manager.js +7 -1
- package/dist/presentation/flow/flow_navigation_manager.js.map +1 -1
- package/dist/presentation/flow/model/instructions_defaults.d.ts.map +1 -1
- package/dist/presentation/flow/model/instructions_defaults.js +1 -1
- package/dist/presentation/flow/model/instructions_defaults.js.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_capture_screen.d.ts.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_capture_screen.js +13 -3
- package/dist/presentation/flow/screen/orchestrated_capture_screen.js.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_consent_screen.d.ts.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_consent_screen.js +3 -1
- package/dist/presentation/flow/screen/orchestrated_consent_screen.js.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_preview_screen.d.ts.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_preview_screen.js +0 -8
- package/dist/presentation/flow/screen/orchestrated_preview_screen.js.map +1 -1
- package/dist/presentation/flow/use_smile_id_flow.d.ts.map +1 -1
- package/dist/presentation/flow/use_smile_id_flow.js +10 -4
- package/dist/presentation/flow/use_smile_id_flow.js.map +1 -1
- package/dist/presentation/flow/validation/flow_validator.d.ts.map +1 -1
- package/dist/presentation/flow/validation/flow_validator.js +42 -20
- package/dist/presentation/flow/validation/flow_validator.js.map +1 -1
- package/dist/presentation/screen/helpers/capture_ui_state.d.ts +6 -6
- package/dist/presentation/screen/helpers/capture_ui_state.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/capture_ui_state.js +19 -19
- package/dist/presentation/screen/helpers/capture_ui_state.js.map +1 -1
- package/dist/presentation/screen/helpers/ess_turn_haptics.d.ts +2 -2
- package/dist/presentation/screen/helpers/ess_turn_haptics.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/ess_turn_haptics.js +6 -6
- package/dist/presentation/screen/helpers/ess_turn_haptics.js.map +1 -1
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.d.ts +5 -5
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.js +11 -11
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.js.map +1 -1
- package/dist/presentation/screen/helpers/use_capture_orientation_lock.d.ts +13 -3
- package/dist/presentation/screen/helpers/use_capture_orientation_lock.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/use_capture_orientation_lock.js +48 -6
- package/dist/presentation/screen/helpers/use_capture_orientation_lock.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_capture_screen.d.ts +4 -2
- package/dist/presentation/screen/use_smile_id_capture_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_capture_screen.js +36 -15
- package/dist/presentation/screen/use_smile_id_capture_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_consent_screen.d.ts +7 -0
- package/dist/presentation/screen/use_smile_id_consent_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_consent_screen.js +6 -5
- package/dist/presentation/screen/use_smile_id_consent_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_document_back_instructions.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_document_back_instructions.js +5 -13
- package/dist/presentation/screen/use_smile_id_document_back_instructions.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_document_preview_screen.js +1 -1
- package/dist/presentation/screen/use_smile_id_document_preview_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_preview_screen.d.ts +1 -21
- package/dist/presentation/screen/use_smile_id_preview_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_preview_screen.js +3 -14
- package/dist/presentation/screen/use_smile_id_preview_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_processing_screen.js +1 -1
- package/dist/presentation/screen/use_smile_id_processing_screen.js.map +1 -1
- package/dist/presentation/utils/locale_utils.d.ts +10 -4
- package/dist/presentation/utils/locale_utils.d.ts.map +1 -1
- package/dist/presentation/utils/locale_utils.js +13 -5
- package/dist/presentation/utils/locale_utils.js.map +1 -1
- package/dist/testing/fake_face_analyzer.d.ts +43 -0
- package/dist/testing/fake_face_analyzer.d.ts.map +1 -0
- package/dist/testing/fake_face_analyzer.js +52 -0
- package/dist/testing/fake_face_analyzer.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/scenario_expectations.d.ts +28 -0
- package/dist/testing/scenario_expectations.d.ts.map +1 -0
- package/dist/testing/scenario_expectations.js +65 -0
- package/dist/testing/scenario_expectations.js.map +1 -0
- package/dist/testing/scenario_loader.d.ts +11 -0
- package/dist/testing/scenario_loader.d.ts.map +1 -0
- package/dist/testing/scenario_loader.js +64 -0
- package/dist/testing/scenario_loader.js.map +1 -0
- package/dist/testing/scripted_scan_results.d.ts +17 -0
- package/dist/testing/scripted_scan_results.d.ts.map +1 -0
- package/dist/testing/scripted_scan_results.js +52 -0
- package/dist/testing/scripted_scan_results.js.map +1 -0
- package/package.json +11 -4
- package/src/__tests__/dsl.test.ts +51 -1
- package/src/__tests__/setup_react_native.ts +17 -2
- package/src/__tests__/snapshots/__snapshots__/screens_structural.test.tsx.snap +5261 -0
- package/src/__tests__/snapshots/screens_structural.test.tsx +230 -0
- package/src/camera/__tests__/use_smile_id_camera_system.test.ts +103 -0
- package/src/core/exception/__tests__/builder_validation_exceptions.test.ts +67 -0
- package/src/core/exception/agent_mode_with_enhanced_liveness_exception.ts +20 -0
- package/src/core/exception/capture_validation_exceptions.ts +1 -0
- package/src/core/exception/index.ts +1 -0
- package/src/core/exception/use_smile_id_error_code.ts +1 -0
- package/src/core/models/__tests__/document_type.test.ts +2 -2
- package/src/core/models/__tests__/flow_models.test.ts +26 -0
- package/src/core/models/config.ts +22 -0
- package/src/core/models/document_type.ts +2 -2
- package/src/core/models/global_privacy_control.ts +45 -0
- package/src/core/models/network_config.ts +2 -2
- package/src/data/api/__tests__/smile_id_api.test.ts +1 -1
- package/src/data/api/interceptors/__tests__/gzip_interceptor.test.ts +83 -0
- package/src/data/api/interceptors/smile_auth_interceptor.ts +3 -18
- package/src/data/compression/__tests__/payload_compressor_real_jpeg.test.ts +6 -2
- package/src/data/dsl/builder/__tests__/config_builders.test.ts +62 -0
- package/src/data/dsl/builder/retry_config_builder.ts +6 -6
- package/src/data/factory/__tests__/retry_gzip_mac_composition.test.ts +163 -0
- package/src/data/factory/__tests__/signed_job_submission_headers.test.ts +1 -1
- package/src/data/repository/__tests__/network_retries.test.ts +1 -1
- package/src/data/repository/__tests__/use_smile_id_repository.test.ts +1 -1
- package/src/data/security/__tests__/request_canonicalizer.test.ts +132 -0
- package/src/data/smile_id_urls.ts +1 -1
- package/src/data/util/__tests__/retry_util.test.ts +25 -0
- package/src/data/util/retry_util.ts +9 -1
- package/src/index.ts +6 -4
- package/src/metadata/__tests__/metadata_configuration_mappers.test.ts +39 -0
- package/src/metadata/__tests__/metadata_configuration_objects.test.ts +2 -1
- package/src/metadata/__tests__/metadata_device_context.test.ts +3 -3
- package/src/metadata/__tests__/metadata_device_os_android.test.ts +18 -0
- package/src/metadata/__tests__/metadata_golden_fixture.json +1 -1
- package/src/metadata/__tests__/metadata_payload_golden.test.ts +4 -4
- package/src/metadata/__tests__/use_smile_id_metadata.test.ts +1 -1
- package/src/metadata/builder_configuration.ts +6 -0
- package/src/metadata/metadata_configuration_mappers.ts +21 -7
- package/src/metadata/use_smile_id_metadata_factory.ts +17 -6
- package/src/presentation/assets/si_document_green_book_hero_animation.json +1 -4668
- package/src/presentation/assets/si_document_hero_animation.json +1 -4799
- package/src/presentation/assets/si_document_hero_back_animation.json +1 -2039
- package/src/presentation/assets/si_document_passport_hero_animation.json +1 -14491
- package/src/presentation/assets/si_ess_all_directions_hero_animation.json +1 -0
- package/src/presentation/assets/si_ess_animation_all_directions.json +1 -6589
- package/src/presentation/assets/si_selfie_hero_animation.json +1 -1439
- package/src/presentation/assets/si_smile_to_capture_animation.json +1 -1439
- package/src/presentation/components/__tests__/use_smile_id_enhanced_smart_selfie_clip.test.tsx +9 -4
- package/src/presentation/components/__tests__/use_smile_id_instructions_hero.test.tsx +44 -0
- package/src/presentation/components/use_smile_id_enhanced_smart_selfie_clip.tsx +9 -3
- package/src/presentation/components/use_smile_id_instructions_hero.tsx +10 -0
- package/src/presentation/flow/__tests__/document_flow_navigation.test.ts +3 -3
- package/src/presentation/flow/__tests__/flow_navigation_manager.test.ts +49 -0
- package/src/presentation/flow/dsl/builder/__tests__/config_builder.test.ts +25 -0
- package/src/presentation/flow/dsl/builder/config_builder.ts +21 -0
- package/src/presentation/flow/dsl/builder/screens_builder.ts +3 -6
- package/src/presentation/flow/flow_navigation_manager.ts +6 -1
- package/src/presentation/flow/model/instructions_defaults.ts +1 -1
- package/src/presentation/flow/screen/orchestrated_capture_screen.tsx +18 -3
- package/src/presentation/flow/screen/orchestrated_consent_screen.tsx +5 -0
- package/src/presentation/flow/screen/orchestrated_preview_screen.tsx +0 -12
- package/src/presentation/flow/use_smile_id_flow.tsx +11 -4
- package/src/presentation/flow/validation/__tests__/flow_validator.test.ts +61 -1
- package/src/presentation/flow/validation/flow_validator.ts +55 -26
- package/src/presentation/screen/__tests__/capture_ui_state.test.ts +66 -47
- package/src/presentation/screen/__tests__/ess_turn_haptics.test.ts +15 -11
- package/src/presentation/screen/__tests__/scan_state_to_overlay_state.test.ts +47 -27
- package/src/presentation/screen/__tests__/use_smile_id_capture_screen.test.tsx +176 -14
- package/src/presentation/screen/__tests__/use_smile_id_document_back_instructions.test.tsx +1 -1
- package/src/presentation/screen/__tests__/use_smile_id_preview_screen.test.tsx +10 -40
- package/src/presentation/screen/helpers/__tests__/use_capture_orientation_lock.test.tsx +212 -0
- package/src/presentation/screen/helpers/capture_ui_state.ts +27 -27
- package/src/presentation/screen/helpers/ess_turn_haptics.ts +9 -9
- package/src/presentation/screen/helpers/scan_state_to_overlay_state.ts +13 -13
- package/src/presentation/screen/helpers/use_capture_orientation_lock.ts +69 -7
- package/src/presentation/screen/use_smile_id_capture_screen.tsx +47 -19
- package/src/presentation/screen/use_smile_id_consent_screen.tsx +16 -5
- package/src/presentation/screen/use_smile_id_document_back_instructions.tsx +14 -23
- package/src/presentation/screen/use_smile_id_document_preview_screen.tsx +1 -1
- package/src/presentation/screen/use_smile_id_preview_screen.tsx +13 -45
- package/src/presentation/screen/use_smile_id_processing_screen.tsx +1 -1
- package/src/presentation/utils/__tests__/locale_utils.test.ts +46 -5
- package/src/presentation/utils/locale_utils.ts +13 -4
- package/src/testing/__tests__/fake_face_analyzer.test.ts +42 -0
- package/src/testing/__tests__/scenario_expectations.test.ts +110 -0
- package/src/testing/__tests__/scenario_loader.test.ts +64 -0
- package/src/testing/fake_face_analyzer.ts +82 -0
- package/src/testing/index.ts +15 -0
- package/src/testing/scenario_expectations.ts +87 -0
- package/src/testing/scenario_loader.ts +83 -0
- package/src/testing/scripted_scan_results.ts +66 -0
- package/dist/presentation/components/use_smile_id_face_silhouette_overlay.d.ts +0 -15
- package/dist/presentation/components/use_smile_id_face_silhouette_overlay.d.ts.map +0 -1
- package/dist/presentation/components/use_smile_id_face_silhouette_overlay.js +0 -19
- package/dist/presentation/components/use_smile_id_face_silhouette_overlay.js.map +0 -1
- package/src/presentation/components/use_smile_id_face_silhouette_overlay.tsx +0 -27
|
@@ -47,7 +47,7 @@ export function UseSmileIDDocumentPreviewScreen(
|
|
|
47
47
|
edges={["left", "right", "bottom"]}
|
|
48
48
|
style={[
|
|
49
49
|
styles.root,
|
|
50
|
-
{ backgroundColor: theme.colors.
|
|
50
|
+
{ backgroundColor: theme.colors.background },
|
|
51
51
|
]}
|
|
52
52
|
testID="si_document_preview_screen"
|
|
53
53
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState
|
|
1
|
+
import { useState } from "react";
|
|
2
2
|
import { StyleSheet, Text, View, type LayoutChangeEvent } from "react-native";
|
|
3
3
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
4
|
import type { UseSmileIDTheme } from "../theme/theme";
|
|
@@ -16,28 +16,13 @@ export type UseSmileIDPreviewScreenProps = {
|
|
|
16
16
|
readonly showAttribution?: boolean;
|
|
17
17
|
readonly onAccept?: () => void;
|
|
18
18
|
readonly onReject?: () => void;
|
|
19
|
-
/**
|
|
20
|
-
* Render the Accept button via a partner-supplied slot.
|
|
21
|
-
*
|
|
22
|
-
* **Slot contract:** providing *any* slot (continue or cancel)
|
|
23
|
-
* replaces the *entire* default confirmation row. If you supply
|
|
24
|
-
* `continueButton` and want a Retake control too, supply
|
|
25
|
-
* `cancelButton` as well — the default Retake tile does not
|
|
26
|
-
* fall through.
|
|
27
|
-
*/
|
|
28
|
-
readonly continueButton?: (props: { onClick: () => void }) => ReactNode;
|
|
29
|
-
/**
|
|
30
|
-
* Render the Reject (retake) button via a partner-supplied slot.
|
|
31
|
-
* See the slot contract note on `continueButton`.
|
|
32
|
-
*/
|
|
33
|
-
readonly cancelButton?: (props: { onClick: () => void }) => ReactNode;
|
|
34
19
|
readonly theme?: UseSmileIDTheme;
|
|
35
20
|
};
|
|
36
21
|
|
|
37
22
|
/**
|
|
38
23
|
* Preview screen — confirms the captured selfie before submission.
|
|
39
24
|
*
|
|
40
|
-
* - Uniform page (`
|
|
25
|
+
* - Uniform page (`background`, theme-following) with the
|
|
41
26
|
* captured image clipped to the face oval. The oval scales to the
|
|
42
27
|
* leftover height above the card so the two never overlap; no scrim
|
|
43
28
|
* is painted.
|
|
@@ -74,16 +59,12 @@ export function UseSmileIDPreviewScreen(props: UseSmileIDPreviewScreenProps) {
|
|
|
74
59
|
if (state.canRetake) props.onReject?.();
|
|
75
60
|
};
|
|
76
61
|
|
|
77
|
-
const customContinue = props.continueButton;
|
|
78
|
-
const customCancel = props.cancelButton;
|
|
79
|
-
const hasSlots = Boolean(customContinue || customCancel);
|
|
80
|
-
|
|
81
62
|
return (
|
|
82
63
|
<SafeAreaView
|
|
83
64
|
edges={["left", "right", "bottom"]}
|
|
84
65
|
style={[
|
|
85
66
|
styles.root,
|
|
86
|
-
{ backgroundColor: theme.colors.
|
|
67
|
+
{ backgroundColor: theme.colors.background },
|
|
87
68
|
]}
|
|
88
69
|
testID="si_preview_screen"
|
|
89
70
|
onLayout={onScreenLayout}
|
|
@@ -122,23 +103,16 @@ export function UseSmileIDPreviewScreen(props: UseSmileIDPreviewScreenProps) {
|
|
|
122
103
|
{loc.siPreviewSubtitle}
|
|
123
104
|
</Text>
|
|
124
105
|
<View style={{ marginTop: theme.spacing.medium }}>
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onReject={handleReject}
|
|
136
|
-
acceptLabel={loc.siPreviewConfirm}
|
|
137
|
-
rejectLabel={loc.siPreviewRetake}
|
|
138
|
-
theme={theme}
|
|
139
|
-
testID="si_preview_confirmation_buttons"
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
106
|
+
{/* The confirm/retake buttons are the fixed icon pair and are not
|
|
107
|
+
customisable. */}
|
|
108
|
+
<UseSmileIDConfirmationButtons
|
|
109
|
+
onAccept={handleAccept}
|
|
110
|
+
onReject={handleReject}
|
|
111
|
+
acceptLabel={loc.siPreviewConfirm}
|
|
112
|
+
rejectLabel={loc.siPreviewRetake}
|
|
113
|
+
theme={theme}
|
|
114
|
+
testID="si_preview_confirmation_buttons"
|
|
115
|
+
/>
|
|
142
116
|
</View>
|
|
143
117
|
</UseSmileIDCardSurface>
|
|
144
118
|
|
|
@@ -150,10 +124,4 @@ export function UseSmileIDPreviewScreen(props: UseSmileIDPreviewScreenProps) {
|
|
|
150
124
|
const styles = StyleSheet.create({
|
|
151
125
|
root: { flex: 1, overflow: "hidden" },
|
|
152
126
|
card: { alignItems: "center" },
|
|
153
|
-
buttonRow: {
|
|
154
|
-
flexDirection: "row",
|
|
155
|
-
alignSelf: "stretch",
|
|
156
|
-
justifyContent: "space-between",
|
|
157
|
-
alignItems: "center",
|
|
158
|
-
},
|
|
159
127
|
});
|
|
@@ -110,7 +110,7 @@ export function UseSmileIDProcessingScreen(
|
|
|
110
110
|
<SafeAreaView
|
|
111
111
|
style={[
|
|
112
112
|
styles.root,
|
|
113
|
-
{ backgroundColor: theme.colors.
|
|
113
|
+
{ backgroundColor: theme.colors.background },
|
|
114
114
|
]}
|
|
115
115
|
testID="si_processing_screen"
|
|
116
116
|
onLayout={onScreenLayout}
|
|
@@ -1,37 +1,78 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
GlobalPrivacyControl,
|
|
5
|
+
globalPrivacyControlFromWire,
|
|
6
|
+
GLOBAL_PRIVACY_CONTROL_WIRE_KEY,
|
|
7
|
+
} from "../../../core/models/global_privacy_control";
|
|
3
8
|
import { getDefaultConsentState, isDeviceLocaleInEU } from "../locale_utils";
|
|
4
9
|
|
|
5
10
|
describe("locale_utils", () => {
|
|
6
11
|
it("EU locale (de-DE) is recognised as EU and default consent is false", () => {
|
|
7
12
|
expect(isDeviceLocaleInEU("de-DE")).toBe(true);
|
|
8
|
-
expect(getDefaultConsentState("de-DE")).toBe(
|
|
13
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptIn, "de-DE")).toBe(
|
|
14
|
+
false,
|
|
15
|
+
);
|
|
9
16
|
});
|
|
10
17
|
|
|
11
18
|
it("non-EU locale (en-US) is not EU and default consent is true", () => {
|
|
12
19
|
expect(isDeviceLocaleInEU("en-US")).toBe(false);
|
|
13
|
-
expect(getDefaultConsentState("en-US")).toBe(
|
|
20
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptIn, "en-US")).toBe(
|
|
21
|
+
true,
|
|
22
|
+
);
|
|
14
23
|
});
|
|
15
24
|
|
|
16
25
|
it("EU locale (fr-FR) is recognised as EU and default consent is false", () => {
|
|
17
26
|
expect(isDeviceLocaleInEU("fr-FR")).toBe(true);
|
|
18
|
-
expect(getDefaultConsentState("fr-FR")).toBe(
|
|
27
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptIn, "fr-FR")).toBe(
|
|
28
|
+
false,
|
|
29
|
+
);
|
|
19
30
|
});
|
|
20
31
|
|
|
21
32
|
it("non-EU locale (en-NG) is not EU and default consent is true", () => {
|
|
22
33
|
expect(isDeviceLocaleInEU("en-NG")).toBe(false);
|
|
23
|
-
expect(getDefaultConsentState("en-NG")).toBe(
|
|
34
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptIn, "en-NG")).toBe(
|
|
35
|
+
true,
|
|
36
|
+
);
|
|
24
37
|
});
|
|
25
38
|
|
|
26
39
|
it("bare language tag with no region falls back to non-EU", () => {
|
|
27
40
|
// `"fr"` has no region segment — the BCP-47 split returns
|
|
28
41
|
// undefined for the country, which never matches the EU set.
|
|
29
42
|
expect(isDeviceLocaleInEU("fr")).toBe(false);
|
|
30
|
-
expect(getDefaultConsentState("fr")).toBe(true);
|
|
43
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptIn, "fr")).toBe(true);
|
|
31
44
|
});
|
|
32
45
|
|
|
33
46
|
it("empty locale string falls back to non-EU", () => {
|
|
34
47
|
expect(isDeviceLocaleInEU("")).toBe(false);
|
|
35
48
|
expect(getDefaultConsentState("")).toBe(true);
|
|
36
49
|
});
|
|
50
|
+
|
|
51
|
+
describe("global privacy control", () => {
|
|
52
|
+
it("default posture forces opt-out even for EU locales", () => {
|
|
53
|
+
expect(getDefaultConsentState()).toBe(true);
|
|
54
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptOut, "de-DE")).toBe(
|
|
55
|
+
true,
|
|
56
|
+
);
|
|
57
|
+
expect(getDefaultConsentState(GlobalPrivacyControl.OptOut, "en-NG")).toBe(
|
|
58
|
+
true,
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("parses wire values and defaults unknowns to opt-out", () => {
|
|
63
|
+
expect(globalPrivacyControlFromWire("opt-out")).toBe(
|
|
64
|
+
GlobalPrivacyControl.OptOut,
|
|
65
|
+
);
|
|
66
|
+
expect(globalPrivacyControlFromWire("opt-in")).toBe(
|
|
67
|
+
GlobalPrivacyControl.OptIn,
|
|
68
|
+
);
|
|
69
|
+
expect(globalPrivacyControlFromWire(null)).toBe(
|
|
70
|
+
GlobalPrivacyControl.OptOut,
|
|
71
|
+
);
|
|
72
|
+
expect(globalPrivacyControlFromWire("user_settings")).toBe(
|
|
73
|
+
GlobalPrivacyControl.OptOut,
|
|
74
|
+
);
|
|
75
|
+
expect(GLOBAL_PRIVACY_CONTROL_WIRE_KEY).toBe("global_privacy_control");
|
|
76
|
+
});
|
|
77
|
+
});
|
|
37
78
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GlobalPrivacyControl } from "../../core/models/global_privacy_control";
|
|
1
2
|
const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([
|
|
2
3
|
"AT",
|
|
3
4
|
"BE",
|
|
@@ -59,13 +60,21 @@ export function isDeviceLocaleInEU(
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
|
-
* Returns the default consent checkbox state
|
|
63
|
+
* Returns the default consent checkbox state for the partner-declared
|
|
64
|
+
* `GlobalPrivacyControl` posture.
|
|
63
65
|
*
|
|
64
|
-
* -
|
|
65
|
-
* -
|
|
66
|
+
* - `GlobalPrivacyControl.OptOut` (default): ticked (`true`) universally —
|
|
67
|
+
* the opt-out layout is enforced for every session and the device region
|
|
68
|
+
* is never consulted.
|
|
69
|
+
* - `GlobalPrivacyControl.OptIn`: legacy regional mechanics — EU locales
|
|
70
|
+
* start unticked (`false`, explicit opt-in per GDPR), everywhere else
|
|
71
|
+
* starts ticked (`true`).
|
|
66
72
|
*/
|
|
67
73
|
export function getDefaultConsentState(
|
|
74
|
+
globalPrivacyControl: GlobalPrivacyControl = GlobalPrivacyControl.OptOut,
|
|
68
75
|
locale: string = getDeviceLocale(),
|
|
69
76
|
): boolean {
|
|
70
|
-
return
|
|
77
|
+
return globalPrivacyControl === GlobalPrivacyControl.OptOut
|
|
78
|
+
? true
|
|
79
|
+
: !isDeviceLocaleInEU(locale);
|
|
71
80
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { makeFakeFaceAnalyzer } from "../fake_face_analyzer";
|
|
3
|
+
|
|
4
|
+
const scenario = {
|
|
5
|
+
name: "selfie-happy-path",
|
|
6
|
+
captureType: "selfie",
|
|
7
|
+
steps: [
|
|
8
|
+
{ emit: "noFace", holdFrames: 2 },
|
|
9
|
+
{ emit: "faceCentered", holdFrames: 3 },
|
|
10
|
+
{ emit: "satisfied" },
|
|
11
|
+
],
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
describe("FakeFaceAnalyzer", () => {
|
|
15
|
+
it("replays holdFrames per step and repeats the final step indefinitely", () => {
|
|
16
|
+
const fake = makeFakeFaceAnalyzer(scenario);
|
|
17
|
+
const emits = Array.from({ length: 9 }, () => fake.nextEmit());
|
|
18
|
+
expect(emits).toEqual([
|
|
19
|
+
"noFace",
|
|
20
|
+
"noFace",
|
|
21
|
+
"faceCentered",
|
|
22
|
+
"faceCentered",
|
|
23
|
+
"faceCentered",
|
|
24
|
+
"satisfied",
|
|
25
|
+
"satisfied",
|
|
26
|
+
"satisfied",
|
|
27
|
+
"satisfied",
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("records the JS lifecycle calls", async () => {
|
|
32
|
+
const fake = makeFakeFaceAnalyzer(scenario);
|
|
33
|
+
await fake.configure();
|
|
34
|
+
await fake.reset();
|
|
35
|
+
await fake.flush();
|
|
36
|
+
await fake.close();
|
|
37
|
+
expect(fake.configureCallCount).toBe(1);
|
|
38
|
+
expect(fake.resetCallCount).toBe(1);
|
|
39
|
+
expect(fake.flushCallCount).toBe(1);
|
|
40
|
+
expect(fake.closeCallCount).toBe(1);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import {
|
|
6
|
+
expectSubsetInOrder,
|
|
7
|
+
parseScenarioExpectations,
|
|
8
|
+
} from "../scenario_expectations";
|
|
9
|
+
|
|
10
|
+
// Read the canonical shared scenario at run time (see the capture-screen test
|
|
11
|
+
// for the same rationale) so a drift in the shared `expected` block is caught
|
|
12
|
+
// here per-PR rather than silently diverging.
|
|
13
|
+
const scenarioDir = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const selfieScenario = JSON.parse(
|
|
15
|
+
readFileSync(
|
|
16
|
+
join(scenarioDir, "../../../../e2e/scenarios/selfie-happy-path.json"),
|
|
17
|
+
"utf8",
|
|
18
|
+
),
|
|
19
|
+
) as unknown;
|
|
20
|
+
|
|
21
|
+
const agentModeScenario = JSON.parse(
|
|
22
|
+
readFileSync(
|
|
23
|
+
join(scenarioDir, "../../../../e2e/scenarios/selfie-agent-mode.json"),
|
|
24
|
+
"utf8",
|
|
25
|
+
),
|
|
26
|
+
) as unknown;
|
|
27
|
+
|
|
28
|
+
describe("parseScenarioExpectations", () => {
|
|
29
|
+
// Nothing is relaxed for the agent, so the shared script must carry the same
|
|
30
|
+
// terminal contract as the front-camera happy path.
|
|
31
|
+
it("gives the shared agent-mode scenario the same terminal contract as the happy path", () => {
|
|
32
|
+
const agentMode = parseScenarioExpectations(agentModeScenario);
|
|
33
|
+
const happyPath = parseScenarioExpectations(selfieScenario);
|
|
34
|
+
expect(agentMode.screens).toEqual(happyPath.screens);
|
|
35
|
+
expect(agentMode.events).toEqual(happyPath.events);
|
|
36
|
+
expect(agentMode.terminal).toBe("submitted");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("surfaces the shared selfie scenario's expected screens/events/terminal", () => {
|
|
40
|
+
const expected = parseScenarioExpectations(selfieScenario);
|
|
41
|
+
expect(expected.screens).toEqual([
|
|
42
|
+
"consent",
|
|
43
|
+
"instructions",
|
|
44
|
+
"capture",
|
|
45
|
+
"preview",
|
|
46
|
+
"processing",
|
|
47
|
+
]);
|
|
48
|
+
expect(expected.events).toEqual([
|
|
49
|
+
"flow_started",
|
|
50
|
+
"consent_captured",
|
|
51
|
+
"selfie_captured",
|
|
52
|
+
"job_submitted",
|
|
53
|
+
"flow_completed",
|
|
54
|
+
]);
|
|
55
|
+
expect(expected.terminal).toBe("submitted");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("defaults to empty arrays when the block is absent", () => {
|
|
59
|
+
const expected = parseScenarioExpectations({ name: "x" });
|
|
60
|
+
expect(expected.screens).toEqual([]);
|
|
61
|
+
expect(expected.events).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("rejects a malformed expected block", () => {
|
|
65
|
+
expect(() =>
|
|
66
|
+
parseScenarioExpectations({ expected: { screens: [1, 2] } }),
|
|
67
|
+
).toThrow(/must be an array of strings/);
|
|
68
|
+
expect(() =>
|
|
69
|
+
parseScenarioExpectations({ expected: { terminal: "exploded" } }),
|
|
70
|
+
).toThrow(/terminal must be one of/);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("expectSubsetInOrder", () => {
|
|
75
|
+
it("passes when every expected item appears in order (interleaving allowed)", () => {
|
|
76
|
+
const { screens, events } = parseScenarioExpectations(selfieScenario);
|
|
77
|
+
// Recorded stream may carry extra, unlisted events between the required
|
|
78
|
+
// ones — the contract is subset-in-order, not exact match.
|
|
79
|
+
const recordedEvents = [
|
|
80
|
+
"flow_started",
|
|
81
|
+
"screen_viewed",
|
|
82
|
+
"consent_captured",
|
|
83
|
+
"screen_viewed",
|
|
84
|
+
"selfie_captured",
|
|
85
|
+
"image_quality_ok",
|
|
86
|
+
"job_submitted",
|
|
87
|
+
"flow_completed",
|
|
88
|
+
];
|
|
89
|
+
expect(() => expectSubsetInOrder(recordedEvents, events)).not.toThrow();
|
|
90
|
+
expect(() => expectSubsetInOrder([...screens], screens)).not.toThrow();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("throws when an expected item is missing", () => {
|
|
94
|
+
expect(() =>
|
|
95
|
+
expectSubsetInOrder(
|
|
96
|
+
["flow_started", "flow_completed"],
|
|
97
|
+
["flow_started", "job_submitted", "flow_completed"],
|
|
98
|
+
),
|
|
99
|
+
).toThrow(/job_submitted/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("throws when expected items appear out of order", () => {
|
|
103
|
+
expect(() =>
|
|
104
|
+
expectSubsetInOrder(
|
|
105
|
+
["flow_completed", "flow_started"],
|
|
106
|
+
["flow_started", "flow_completed"],
|
|
107
|
+
),
|
|
108
|
+
).toThrow(/to appear in order/);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { parseScriptedScenario } from "../scenario_loader";
|
|
3
|
+
|
|
4
|
+
describe("parseScriptedScenario", () => {
|
|
5
|
+
const valid = {
|
|
6
|
+
name: "selfie-happy-path",
|
|
7
|
+
captureType: "selfie",
|
|
8
|
+
steps: [
|
|
9
|
+
{ emit: "noFace", holdFrames: 10 },
|
|
10
|
+
{ emit: "faceCentered", holdFrames: 20 },
|
|
11
|
+
{ emit: "satisfied" },
|
|
12
|
+
],
|
|
13
|
+
// An `expected` block may ride alongside; the loader ignores extra keys.
|
|
14
|
+
expected: { screens: [], events: [], terminal: "submitted" },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
it("returns the typed scenario for a valid shape", () => {
|
|
18
|
+
const scenario = parseScriptedScenario(valid);
|
|
19
|
+
expect(scenario.name).toBe("selfie-happy-path");
|
|
20
|
+
expect(scenario.captureType).toBe("selfie");
|
|
21
|
+
expect(scenario.steps).toHaveLength(3);
|
|
22
|
+
expect(scenario.steps[2]).toEqual({ emit: "satisfied" });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("rejects an unknown emit (vocabulary drift)", () => {
|
|
26
|
+
expect(() =>
|
|
27
|
+
parseScriptedScenario({
|
|
28
|
+
name: "x",
|
|
29
|
+
captureType: "selfie",
|
|
30
|
+
steps: [{ emit: "wink" }],
|
|
31
|
+
}),
|
|
32
|
+
).toThrow(/not a known emission/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("rejects an unknown captureType", () => {
|
|
36
|
+
expect(() =>
|
|
37
|
+
parseScriptedScenario({
|
|
38
|
+
name: "x",
|
|
39
|
+
captureType: "iris",
|
|
40
|
+
steps: [{ emit: "noFace" }],
|
|
41
|
+
}),
|
|
42
|
+
).toThrow(/captureType/);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("rejects empty steps", () => {
|
|
46
|
+
expect(() =>
|
|
47
|
+
parseScriptedScenario({ name: "x", captureType: "selfie", steps: [] }),
|
|
48
|
+
).toThrow(/non-empty/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("rejects a non-integer holdFrames", () => {
|
|
52
|
+
expect(() =>
|
|
53
|
+
parseScriptedScenario({
|
|
54
|
+
name: "x",
|
|
55
|
+
captureType: "selfie",
|
|
56
|
+
steps: [{ emit: "noFace", holdFrames: 1.5 }],
|
|
57
|
+
}),
|
|
58
|
+
).toThrow(/holdFrames/);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("rejects a non-object input", () => {
|
|
62
|
+
expect(() => parseScriptedScenario("nope")).toThrow(/JSON object/);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { FaceAnalyzer } from "@smileid/usesmileid_platform_interface";
|
|
2
|
+
import { AnalyzerFactoryKey } from "@smileid/usesmileid_bridge";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Deterministic fake face analyzer for scripted-scenario E2E runs. Exported
|
|
6
|
+
* only behind the `@smileid/usesmileid/testing` subpath so it cannot leak into
|
|
7
|
+
* partner production bundles.
|
|
8
|
+
*
|
|
9
|
+
* Per-frame detection runs in the provider's native frame-processor plugin
|
|
10
|
+
* (pixels never cross into JS), so `frameProcessorPluginName` points at a
|
|
11
|
+
* plugin that does not exist — the capture screen surfaces that as its
|
|
12
|
+
* camera-unavailable state. This fake covers the DSL registration seam and the
|
|
13
|
+
* capture-free flows; capture progression is driven via `onResult` instead.
|
|
14
|
+
*/
|
|
15
|
+
export interface ScriptedScenarioStep {
|
|
16
|
+
readonly emit: string;
|
|
17
|
+
readonly holdFrames?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ScriptedScenario {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly captureType: string;
|
|
23
|
+
readonly steps: readonly ScriptedScenarioStep[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class FakeFaceAnalyzer implements FaceAnalyzer {
|
|
27
|
+
readonly kind = "face" as const;
|
|
28
|
+
readonly key: AnalyzerFactoryKey = AnalyzerFactoryKey.MLKitFace;
|
|
29
|
+
readonly frameProcessorPluginName = "e2e-fake-face";
|
|
30
|
+
|
|
31
|
+
configureCallCount = 0;
|
|
32
|
+
resetCallCount = 0;
|
|
33
|
+
flushCallCount = 0;
|
|
34
|
+
closeCallCount = 0;
|
|
35
|
+
|
|
36
|
+
private stepIndex = 0;
|
|
37
|
+
private framesLeftInStep: number;
|
|
38
|
+
|
|
39
|
+
constructor(private readonly scenario: ScriptedScenario) {
|
|
40
|
+
this.framesLeftInStep = scenario.steps[0]?.holdFrames ?? 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Frame-by-frame cursor; the final step repeats indefinitely. */
|
|
44
|
+
nextEmit(): string {
|
|
45
|
+
const steps = this.scenario.steps;
|
|
46
|
+
const step = steps[this.stepIndex];
|
|
47
|
+
if (step === undefined) return "noFace";
|
|
48
|
+
if (this.stepIndex === steps.length - 1) return step.emit;
|
|
49
|
+
this.framesLeftInStep -= 1;
|
|
50
|
+
if (this.framesLeftInStep <= 0) {
|
|
51
|
+
this.stepIndex += 1;
|
|
52
|
+
this.framesLeftInStep = steps[this.stepIndex]?.holdFrames ?? 1;
|
|
53
|
+
}
|
|
54
|
+
return step.emit;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
configure(): Promise<void> {
|
|
58
|
+
this.configureCallCount += 1;
|
|
59
|
+
return Promise.resolve();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
reset(): Promise<void> {
|
|
63
|
+
this.resetCallCount += 1;
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
flush(): Promise<void> {
|
|
68
|
+
this.flushCallCount += 1;
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
close(): Promise<void> {
|
|
73
|
+
this.closeCallCount += 1;
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function makeFakeFaceAnalyzer(
|
|
79
|
+
scenario: ScriptedScenario,
|
|
80
|
+
): FakeFaceAnalyzer {
|
|
81
|
+
return new FakeFaceAnalyzer(scenario);
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Test-support entry — exported behind the `@smileid/usesmileid/testing`
|
|
2
|
+
// subpath only. Nothing here may be re-exported from the main index.
|
|
3
|
+
export {
|
|
4
|
+
FakeFaceAnalyzer,
|
|
5
|
+
makeFakeFaceAnalyzer,
|
|
6
|
+
type ScriptedScenario,
|
|
7
|
+
type ScriptedScenarioStep,
|
|
8
|
+
} from "./fake_face_analyzer";
|
|
9
|
+
export { scriptedFaceScanResults } from "./scripted_scan_results";
|
|
10
|
+
export { parseScriptedScenario } from "./scenario_loader";
|
|
11
|
+
export {
|
|
12
|
+
type ScenarioExpectations,
|
|
13
|
+
parseScenarioExpectations,
|
|
14
|
+
expectSubsetInOrder,
|
|
15
|
+
} from "./scenario_expectations";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture-scoped expectations from the shared `e2e-scenarios` schema's `expected`
|
|
3
|
+
* block (screen + analytics-event names, terminal state). Framework-agnostic (no
|
|
4
|
+
* vitest/jest import) so a partner app's own e2e runner can reuse it.
|
|
5
|
+
*/
|
|
6
|
+
export interface ScenarioExpectations {
|
|
7
|
+
/** Ordered `screen_viewed` sequence for the canonical consent-first flow. */
|
|
8
|
+
readonly screens: readonly string[];
|
|
9
|
+
/** Ordered analytics event types that must fire (subset-in-order). */
|
|
10
|
+
readonly events: readonly string[];
|
|
11
|
+
/** How the capture session ends. */
|
|
12
|
+
readonly terminal?: "submitted" | "timeout" | "unsatisfied";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const TERMINALS: ReadonlySet<string> = new Set([
|
|
16
|
+
"submitted",
|
|
17
|
+
"timeout",
|
|
18
|
+
"unsatisfied",
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extracts and validates the `expected` block from an already-parsed shared
|
|
23
|
+
* scenario JSON object. Returns empty screen/event arrays when the block is
|
|
24
|
+
* absent (older scenarios), and throws on a malformed block so drift fails
|
|
25
|
+
* loudly rather than silently weakening the contract.
|
|
26
|
+
*/
|
|
27
|
+
export function parseScenarioExpectations(raw: unknown): ScenarioExpectations {
|
|
28
|
+
if (typeof raw !== "object" || raw === null) {
|
|
29
|
+
throw new Error("scenario must be a JSON object");
|
|
30
|
+
}
|
|
31
|
+
const expected = (raw as Record<string, unknown>).expected;
|
|
32
|
+
if (expected === undefined) {
|
|
33
|
+
return { screens: [], events: [] };
|
|
34
|
+
}
|
|
35
|
+
if (typeof expected !== "object" || expected === null) {
|
|
36
|
+
throw new Error("scenario.expected must be an object when present");
|
|
37
|
+
}
|
|
38
|
+
const record = expected as Record<string, unknown>;
|
|
39
|
+
const screens = readStringArray(record.screens, "scenario.expected.screens");
|
|
40
|
+
const events = readStringArray(record.events, "scenario.expected.events");
|
|
41
|
+
const terminal = record.terminal;
|
|
42
|
+
if (terminal === undefined) {
|
|
43
|
+
return { screens, events };
|
|
44
|
+
}
|
|
45
|
+
if (typeof terminal !== "string" || !TERMINALS.has(terminal)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`scenario.expected.terminal must be one of ${[...TERMINALS].join(", ")}, got ${String(terminal)}`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
screens,
|
|
52
|
+
events,
|
|
53
|
+
terminal: terminal as "submitted" | "timeout" | "unsatisfied",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function readStringArray(value: unknown, label: string): readonly string[] {
|
|
58
|
+
if (value === undefined) return [];
|
|
59
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
60
|
+
throw new Error(`${label} must be an array of strings`);
|
|
61
|
+
}
|
|
62
|
+
return value as string[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Asserts that every element of [expected] appears in [recorded] in the same
|
|
67
|
+
* relative order (a minimal ordered-subset match — unlisted items may
|
|
68
|
+
* interleave, exact-match is deliberately NOT required). Throws a descriptive
|
|
69
|
+
* Error on failure so it works under any test runner.
|
|
70
|
+
*/
|
|
71
|
+
export function expectSubsetInOrder(
|
|
72
|
+
recorded: readonly string[],
|
|
73
|
+
expected: readonly string[],
|
|
74
|
+
label = "sequence",
|
|
75
|
+
): void {
|
|
76
|
+
let cursor = 0;
|
|
77
|
+
for (const item of recorded) {
|
|
78
|
+
if (cursor < expected.length && item === expected[cursor]) cursor += 1;
|
|
79
|
+
}
|
|
80
|
+
if (cursor !== expected.length) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`${label}: expected [${expected
|
|
83
|
+
.slice(cursor)
|
|
84
|
+
.join(", ")}] to appear in order within [${recorded.join(", ")}]`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|