@smileid/usesmileid 12.0.0-beta01 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +701 -89
- package/dist/camera/camera_defaults.d.ts +14 -9
- package/dist/camera/camera_defaults.d.ts.map +1 -1
- package/dist/camera/camera_defaults.js +11 -9
- package/dist/camera/camera_defaults.js.map +1 -1
- package/dist/camera/orientation_degrees.d.ts +5 -6
- package/dist/camera/orientation_degrees.d.ts.map +1 -1
- package/dist/camera/orientation_degrees.js +5 -6
- package/dist/camera/orientation_degrees.js.map +1 -1
- package/dist/core/models/document_capture_mode.d.ts +8 -0
- package/dist/core/models/document_capture_mode.d.ts.map +1 -1
- package/dist/core/models/document_capture_mode.js +24 -0
- package/dist/core/models/document_capture_mode.js.map +1 -1
- package/dist/core/models/document_type.d.ts +2 -2
- package/dist/core/models/document_type.d.ts.map +1 -1
- package/dist/core/models/document_type.js +6 -4
- package/dist/core/models/document_type.js.map +1 -1
- package/dist/core/models/result.d.ts +9 -8
- package/dist/core/models/result.d.ts.map +1 -1
- package/dist/core/models/result.js +5 -6
- package/dist/core/models/result.js.map +1 -1
- package/dist/data/api/interceptors/smile_auth_interceptor.js +1 -1
- package/dist/data/api/interceptors/smile_auth_interceptor.js.map +1 -1
- package/dist/data/api/interceptors/smile_integrity_interceptor.d.ts +11 -0
- package/dist/data/api/interceptors/smile_integrity_interceptor.d.ts.map +1 -1
- package/dist/data/api/interceptors/smile_integrity_interceptor.js +13 -0
- package/dist/data/api/interceptors/smile_integrity_interceptor.js.map +1 -1
- package/dist/data/api/interceptors/smile_request_mac_interceptor.d.ts +8 -0
- package/dist/data/api/interceptors/smile_request_mac_interceptor.d.ts.map +1 -1
- package/dist/data/api/interceptors/smile_request_mac_interceptor.js +11 -0
- package/dist/data/api/interceptors/smile_request_mac_interceptor.js.map +1 -1
- package/dist/data/compression/compressible_asset.d.ts +41 -0
- package/dist/data/compression/compressible_asset.d.ts.map +1 -0
- package/dist/data/compression/compressible_asset.js +34 -0
- package/dist/data/compression/compressible_asset.js.map +1 -0
- package/dist/data/compression/payload_compression_config.d.ts +36 -0
- package/dist/data/compression/payload_compression_config.d.ts.map +1 -0
- package/dist/data/compression/payload_compression_config.js +52 -0
- package/dist/data/compression/payload_compression_config.js.map +1 -0
- package/dist/data/compression/payload_compression_runner.d.ts +29 -0
- package/dist/data/compression/payload_compression_runner.d.ts.map +1 -0
- package/dist/data/compression/payload_compression_runner.js +55 -0
- package/dist/data/compression/payload_compression_runner.js.map +1 -0
- package/dist/data/compression/payload_compressor.d.ts +40 -0
- package/dist/data/compression/payload_compressor.d.ts.map +1 -0
- package/dist/data/compression/payload_compressor.js +126 -0
- package/dist/data/compression/payload_compressor.js.map +1 -0
- package/dist/data/compression/uri_compressible_asset.d.ts +23 -0
- package/dist/data/compression/uri_compressible_asset.d.ts.map +1 -0
- package/dist/data/compression/uri_compressible_asset.js +77 -0
- package/dist/data/compression/uri_compressible_asset.js.map +1 -0
- package/dist/data/dsl/builder/cache_config_builder.d.ts +2 -1
- package/dist/data/dsl/builder/cache_config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/cache_config_builder.js +2 -1
- package/dist/data/dsl/builder/cache_config_builder.js.map +1 -1
- package/dist/data/dsl/builder/config_builder.d.ts +40 -14
- package/dist/data/dsl/builder/config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/config_builder.js +40 -14
- package/dist/data/dsl/builder/config_builder.js.map +1 -1
- package/dist/data/dsl/builder/interceptor_config_builder.d.ts +9 -7
- package/dist/data/dsl/builder/interceptor_config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/interceptor_config_builder.js +9 -7
- package/dist/data/dsl/builder/interceptor_config_builder.js.map +1 -1
- package/dist/data/dsl/builder/retry_config_builder.d.ts +16 -1
- package/dist/data/dsl/builder/retry_config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/retry_config_builder.js +16 -1
- package/dist/data/dsl/builder/retry_config_builder.js.map +1 -1
- package/dist/data/dsl/builder/timeout_config_builder.d.ts +4 -0
- package/dist/data/dsl/builder/timeout_config_builder.d.ts.map +1 -1
- package/dist/data/dsl/builder/timeout_config_builder.js +4 -0
- package/dist/data/dsl/builder/timeout_config_builder.js.map +1 -1
- package/dist/data/dsl/use_smile_id_network_builder.d.ts +17 -0
- package/dist/data/dsl/use_smile_id_network_builder.d.ts.map +1 -1
- package/dist/data/dsl/use_smile_id_network_builder.js +17 -0
- package/dist/data/dsl/use_smile_id_network_builder.js.map +1 -1
- package/dist/data/factory/networking_factory.d.ts.map +1 -1
- package/dist/data/factory/networking_factory.js +11 -1
- package/dist/data/factory/networking_factory.js.map +1 -1
- package/dist/data/repository/use_smile_id_repository_impl.d.ts +6 -0
- package/dist/data/repository/use_smile_id_repository_impl.d.ts.map +1 -1
- package/dist/data/repository/use_smile_id_repository_impl.js +82 -8
- package/dist/data/repository/use_smile_id_repository_impl.js.map +1 -1
- package/dist/data/security/request_canonicalizer.d.ts.map +1 -1
- package/dist/data/security/request_canonicalizer.js +14 -2
- package/dist/data/security/request_canonicalizer.js.map +1 -1
- package/dist/data/security/security_policy.d.ts +43 -0
- package/dist/data/security/security_policy.d.ts.map +1 -0
- package/dist/data/security/security_policy.js +61 -0
- package/dist/data/security/security_policy.js.map +1 -0
- 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 +2 -1
- package/dist/data/util/retry_util.js.map +1 -1
- package/dist/data/util/use_smile_id_token_decoder.d.ts +22 -0
- package/dist/data/util/use_smile_id_token_decoder.d.ts.map +1 -1
- package/dist/data/util/use_smile_id_token_decoder.js +58 -24
- package/dist/data/util/use_smile_id_token_decoder.js.map +1 -1
- package/dist/l10n/strings_en.d.ts +2 -1
- package/dist/l10n/strings_en.d.ts.map +1 -1
- package/dist/l10n/strings_en.js +2 -1
- package/dist/l10n/strings_en.js.map +1 -1
- package/dist/l10n/use_smile_id_localizations.d.ts +1 -0
- package/dist/l10n/use_smile_id_localizations.d.ts.map +1 -1
- package/dist/l10n/use_smile_id_localizations.js +3 -0
- package/dist/l10n/use_smile_id_localizations.js.map +1 -1
- package/dist/metadata/builder_configuration.d.ts +39 -0
- package/dist/metadata/builder_configuration.d.ts.map +1 -0
- package/dist/metadata/builder_configuration.js +34 -0
- package/dist/metadata/builder_configuration.js.map +1 -0
- package/dist/metadata/captured_image_properties.d.ts +11 -0
- package/dist/metadata/captured_image_properties.d.ts.map +1 -0
- package/dist/metadata/captured_image_properties.js +11 -0
- package/dist/metadata/captured_image_properties.js.map +1 -0
- package/dist/metadata/device_orientation_collector.d.ts +17 -0
- package/dist/metadata/device_orientation_collector.d.ts.map +1 -0
- package/dist/metadata/device_orientation_collector.js +66 -0
- package/dist/metadata/device_orientation_collector.js.map +1 -0
- package/dist/metadata/geolocation.d.ts +20 -0
- package/dist/metadata/geolocation.d.ts.map +1 -0
- package/dist/metadata/geolocation.js +40 -0
- package/dist/metadata/geolocation.js.map +1 -0
- package/dist/metadata/metadata_configuration_mappers.d.ts +48 -0
- package/dist/metadata/metadata_configuration_mappers.d.ts.map +1 -0
- package/dist/metadata/metadata_configuration_mappers.js +171 -0
- package/dist/metadata/metadata_configuration_mappers.js.map +1 -0
- package/dist/metadata/model_configuration.d.ts +41 -0
- package/dist/metadata/model_configuration.d.ts.map +1 -0
- package/dist/metadata/model_configuration.js +44 -0
- package/dist/metadata/model_configuration.js.map +1 -0
- package/dist/metadata/optional_native_modules.d.ts +79 -3
- package/dist/metadata/optional_native_modules.d.ts.map +1 -1
- package/dist/metadata/optional_native_modules.js +108 -3
- package/dist/metadata/optional_native_modules.js.map +1 -1
- package/dist/metadata/use_smile_id_metadata.d.ts +45 -7
- package/dist/metadata/use_smile_id_metadata.d.ts.map +1 -1
- package/dist/metadata/use_smile_id_metadata.js +85 -13
- package/dist/metadata/use_smile_id_metadata.js.map +1 -1
- package/dist/metadata/use_smile_id_metadata_factory.d.ts +37 -0
- package/dist/metadata/use_smile_id_metadata_factory.d.ts.map +1 -1
- package/dist/metadata/use_smile_id_metadata_factory.js +184 -12
- package/dist/metadata/use_smile_id_metadata_factory.js.map +1 -1
- package/dist/presentation/assets/svg/document_shimmer_strings.d.ts +14 -0
- package/dist/presentation/assets/svg/document_shimmer_strings.d.ts.map +1 -0
- package/dist/presentation/assets/svg/document_shimmer_strings.js +14 -0
- package/dist/presentation/assets/svg/document_shimmer_strings.js.map +1 -0
- package/dist/presentation/assets/svg/instruction_svg_strings.d.ts +12 -4
- package/dist/presentation/assets/svg/instruction_svg_strings.d.ts.map +1 -1
- package/dist/presentation/assets/svg/instruction_svg_strings.js +19 -8
- package/dist/presentation/assets/svg/instruction_svg_strings.js.map +1 -1
- package/dist/presentation/components/helpers/enhanced_smart_selfie_animation_frames.d.ts +0 -5
- package/dist/presentation/components/helpers/enhanced_smart_selfie_animation_frames.d.ts.map +1 -1
- package/dist/presentation/components/helpers/enhanced_smart_selfie_animation_frames.js +0 -5
- package/dist/presentation/components/helpers/enhanced_smart_selfie_animation_frames.js.map +1 -1
- package/dist/presentation/components/icons/index.d.ts +24 -8
- package/dist/presentation/components/icons/index.d.ts.map +1 -1
- package/dist/presentation/components/icons/index.js +31 -11
- package/dist/presentation/components/icons/index.js.map +1 -1
- package/dist/presentation/components/use_smile_id_attribution.d.ts +1 -1
- package/dist/presentation/components/use_smile_id_button.d.ts +2 -2
- package/dist/presentation/components/use_smile_id_button.js +4 -4
- package/dist/presentation/components/use_smile_id_button.js.map +1 -1
- package/dist/presentation/components/use_smile_id_capture_content.d.ts +13 -0
- package/dist/presentation/components/use_smile_id_capture_content.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_capture_content.js +15 -9
- package/dist/presentation/components/use_smile_id_capture_content.js.map +1 -1
- package/dist/presentation/components/use_smile_id_captured_document_image.d.ts +2 -3
- package/dist/presentation/components/use_smile_id_captured_document_image.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_captured_document_image.js +1 -3
- package/dist/presentation/components/use_smile_id_captured_document_image.js.map +1 -1
- package/dist/presentation/components/use_smile_id_document_capture_controls.d.ts +12 -6
- package/dist/presentation/components/use_smile_id_document_capture_controls.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_document_capture_controls.js +59 -16
- package/dist/presentation/components/use_smile_id_document_capture_controls.js.map +1 -1
- package/dist/presentation/components/use_smile_id_document_overlay.d.ts +22 -5
- package/dist/presentation/components/use_smile_id_document_overlay.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_document_overlay.js +80 -40
- package/dist/presentation/components/use_smile_id_document_overlay.js.map +1 -1
- package/dist/presentation/components/use_smile_id_document_shimmer.d.ts +15 -0
- package/dist/presentation/components/use_smile_id_document_shimmer.d.ts.map +1 -0
- package/dist/presentation/components/use_smile_id_document_shimmer.js +23 -0
- package/dist/presentation/components/use_smile_id_document_shimmer.js.map +1 -0
- 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 +1 -3
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_clip.js.map +1 -1
- package/dist/presentation/components/use_smile_id_guideline_thumbnail.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_guideline_thumbnail.js +84 -1
- package/dist/presentation/components/use_smile_id_guideline_thumbnail.js.map +1 -1
- package/dist/presentation/components/use_smile_id_instructions_hero.d.ts +3 -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 +18 -3
- package/dist/presentation/components/use_smile_id_instructions_hero.js.map +1 -1
- package/dist/presentation/components/use_smile_id_oval_border_palette.d.ts.map +1 -1
- package/dist/presentation/components/use_smile_id_oval_border_palette.js +7 -3
- package/dist/presentation/components/use_smile_id_oval_border_palette.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/config_builder.d.ts +12 -0
- package/dist/presentation/flow/dsl/builder/config_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/config_builder.js +12 -0
- package/dist/presentation/flow/dsl/builder/config_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/ml_builder.d.ts +13 -4
- package/dist/presentation/flow/dsl/builder/ml_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/ml_builder.js +3 -2
- package/dist/presentation/flow/dsl/builder/ml_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/screens_builder.d.ts +111 -10
- package/dist/presentation/flow/dsl/builder/screens_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/screens_builder.js +111 -10
- package/dist/presentation/flow/dsl/builder/screens_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/builder/theme_builder.d.ts +15 -2
- package/dist/presentation/flow/dsl/builder/theme_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/builder/theme_builder.js +15 -2
- package/dist/presentation/flow/dsl/builder/theme_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/use_smile_id_builder.d.ts +6 -4
- package/dist/presentation/flow/dsl/use_smile_id_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/use_smile_id_builder.js.map +1 -1
- package/dist/presentation/flow/dsl/use_smile_id_flow_builder.d.ts +62 -36
- package/dist/presentation/flow/dsl/use_smile_id_flow_builder.d.ts.map +1 -1
- package/dist/presentation/flow/dsl/use_smile_id_flow_builder.js +62 -36
- package/dist/presentation/flow/dsl/use_smile_id_flow_builder.js.map +1 -1
- package/dist/presentation/flow/flow_navigation_manager.d.ts +39 -4
- package/dist/presentation/flow/flow_navigation_manager.d.ts.map +1 -1
- package/dist/presentation/flow/flow_navigation_manager.js +141 -10
- package/dist/presentation/flow/flow_navigation_manager.js.map +1 -1
- package/dist/presentation/flow/model/instruction_guideline.d.ts +9 -0
- package/dist/presentation/flow/model/instruction_guideline.d.ts.map +1 -1
- package/dist/presentation/flow/model/instructions_defaults.d.ts +11 -2
- package/dist/presentation/flow/model/instructions_defaults.d.ts.map +1 -1
- package/dist/presentation/flow/model/instructions_defaults.js +73 -25
- 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 +36 -12
- package/dist/presentation/flow/screen/orchestrated_capture_screen.js.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_instructions_screen.js +1 -1
- package/dist/presentation/flow/screen/orchestrated_instructions_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 +3 -1
- package/dist/presentation/flow/screen/orchestrated_preview_screen.js.map +1 -1
- package/dist/presentation/flow/screen/orchestrated_processing_screen.js +3 -3
- package/dist/presentation/flow/screen/orchestrated_processing_screen.js.map +1 -1
- package/dist/presentation/flow/validation/job_type_validator.d.ts.map +1 -1
- package/dist/presentation/flow/validation/job_type_validator.js +14 -0
- package/dist/presentation/flow/validation/job_type_validator.js.map +1 -1
- package/dist/presentation/screen/helpers/capture_screen_helpers.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/capture_screen_helpers.js +1 -0
- package/dist/presentation/screen/helpers/capture_screen_helpers.js.map +1 -1
- package/dist/presentation/screen/helpers/instructions_screen_helpers.d.ts +1 -0
- package/dist/presentation/screen/helpers/instructions_screen_helpers.d.ts.map +1 -1
- package/dist/presentation/screen/helpers/instructions_screen_helpers.js +6 -2
- package/dist/presentation/screen/helpers/instructions_screen_helpers.js.map +1 -1
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.js +3 -0
- package/dist/presentation/screen/helpers/scan_state_to_overlay_state.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_capture_screen.d.ts +17 -1
- package/dist/presentation/screen/use_smile_id_capture_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_capture_screen.js +153 -18
- package/dist/presentation/screen/use_smile_id_capture_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_document_preview_screen.d.ts +2 -3
- package/dist/presentation/screen/use_smile_id_document_preview_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_document_preview_screen.js +16 -11
- package/dist/presentation/screen/use_smile_id_document_preview_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_instructions_screen.d.ts +2 -0
- package/dist/presentation/screen/use_smile_id_instructions_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_instructions_screen.js +2 -1
- package/dist/presentation/screen/use_smile_id_instructions_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_preview_screen.d.ts +7 -6
- package/dist/presentation/screen/use_smile_id_preview_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_preview_screen.js +9 -8
- package/dist/presentation/screen/use_smile_id_preview_screen.js.map +1 -1
- package/dist/presentation/screen/use_smile_id_processing_screen.d.ts +2 -3
- package/dist/presentation/screen/use_smile_id_processing_screen.d.ts.map +1 -1
- package/dist/presentation/screen/use_smile_id_processing_screen.js +3 -2
- package/dist/presentation/screen/use_smile_id_processing_screen.js.map +1 -1
- package/dist/presentation/theme/theme.d.ts +1 -1
- package/dist/presentation/theme/theme.d.ts.map +1 -1
- package/dist/presentation/theme/theme.js +20 -18
- package/dist/presentation/theme/theme.js.map +1 -1
- package/dist/presentation/utils/force_max_brightness.d.ts +4 -4
- package/package.json +26 -6
- package/src/__tests__/react_native_mock.tsx +8 -0
- package/src/camera/camera_defaults.ts +11 -9
- package/src/camera/orientation_degrees.ts +5 -6
- package/src/core/models/__tests__/document_type.test.ts +6 -4
- package/src/core/models/document_capture_mode.ts +27 -0
- package/src/core/models/document_type.ts +6 -4
- package/src/core/models/result.ts +9 -8
- package/src/data/api/interceptors/__tests__/smile_integrity_interceptor.test.ts +37 -1
- package/src/data/api/interceptors/__tests__/smile_request_mac_interceptor.test.ts +59 -1
- package/src/data/api/interceptors/smile_auth_interceptor.ts +1 -1
- package/src/data/api/interceptors/smile_integrity_interceptor.ts +20 -0
- package/src/data/api/interceptors/smile_request_mac_interceptor.ts +13 -0
- package/src/data/compression/__tests__/payload_compressor.test.ts +200 -0
- package/src/data/compression/__tests__/payload_compressor_real_jpeg.test.ts +222 -0
- package/src/data/compression/compressible_asset.ts +62 -0
- package/src/data/compression/payload_compression_config.ts +53 -0
- package/src/data/compression/payload_compression_runner.ts +102 -0
- package/src/data/compression/payload_compressor.ts +164 -0
- package/src/data/compression/uri_compressible_asset.ts +85 -0
- package/src/data/dsl/builder/cache_config_builder.ts +3 -1
- package/src/data/dsl/builder/config_builder.ts +45 -14
- package/src/data/dsl/builder/interceptor_config_builder.ts +9 -7
- package/src/data/dsl/builder/retry_config_builder.ts +22 -1
- package/src/data/dsl/builder/timeout_config_builder.ts +7 -0
- package/src/data/dsl/use_smile_id_network_builder.ts +17 -0
- package/src/data/factory/networking_factory.ts +14 -1
- package/src/data/repository/__tests__/network_retries.test.ts +117 -0
- package/src/data/repository/use_smile_id_repository_impl.ts +96 -9
- package/src/data/security/__tests__/security_policy.test.ts +96 -0
- package/src/data/security/__tests__/smile_id_crypto_manager.test.ts +18 -0
- package/src/data/security/request_canonicalizer.ts +15 -2
- package/src/data/security/security_policy.ts +70 -0
- package/src/data/util/__tests__/use_smile_id_token_decoder.test.ts +57 -1
- package/src/data/util/retry_util.ts +3 -2
- package/src/data/util/use_smile_id_token_decoder.ts +76 -28
- package/src/l10n/strings_en.ts +2 -1
- package/src/l10n/use_smile_id_localizations.ts +3 -0
- package/src/metadata/__tests__/device_orientation_collector.test.ts +15 -0
- package/src/metadata/__tests__/metadata_configuration_mappers.test.ts +215 -0
- package/src/metadata/__tests__/metadata_configuration_objects.test.ts +85 -0
- package/src/metadata/__tests__/metadata_device_context.test.ts +147 -0
- package/src/metadata/__tests__/metadata_golden_fixture.json +13 -0
- package/src/metadata/__tests__/metadata_payload_golden.test.ts +193 -0
- package/src/metadata/__tests__/use_smile_id_metadata.test.ts +18 -24
- package/src/metadata/builder_configuration.ts +63 -0
- package/src/metadata/captured_image_properties.ts +10 -0
- package/src/metadata/device_orientation_collector.ts +75 -0
- package/src/metadata/geolocation.ts +46 -0
- package/src/metadata/metadata_configuration_mappers.ts +234 -0
- package/src/metadata/model_configuration.ts +68 -0
- package/src/metadata/optional_native_modules.ts +157 -3
- package/src/metadata/use_smile_id_metadata.ts +140 -17
- package/src/metadata/use_smile_id_metadata_factory.ts +195 -11
- package/src/presentation/assets/si_ess_animation_all_directions.json +1300 -286
- package/src/presentation/assets/svg/document_shimmer_strings.ts +17 -0
- package/src/presentation/assets/svg/instruction_svg_strings.ts +34 -12
- package/src/presentation/components/__tests__/enhanced_smart_selfie_animation_frames.test.ts +1 -3
- package/src/presentation/components/__tests__/use_smile_id_enhanced_smart_selfie_clip.test.tsx +3 -4
- package/src/presentation/components/__tests__/use_smile_id_guideline_thumbnail.test.tsx +34 -1
- package/src/presentation/components/__tests__/use_smile_id_instructions_hero.test.tsx +27 -0
- package/src/presentation/components/__tests__/use_smile_id_oval_border_palette.test.ts +7 -5
- package/src/presentation/components/helpers/enhanced_smart_selfie_animation_frames.ts +0 -6
- package/src/presentation/components/icons/index.tsx +65 -18
- package/src/presentation/components/use_smile_id_attribution.tsx +1 -1
- package/src/presentation/components/use_smile_id_button.tsx +4 -4
- package/src/presentation/components/use_smile_id_capture_content.tsx +36 -12
- package/src/presentation/components/use_smile_id_captured_document_image.tsx +3 -8
- package/src/presentation/components/use_smile_id_document_capture_controls.tsx +103 -39
- package/src/presentation/components/use_smile_id_document_overlay.tsx +134 -44
- package/src/presentation/components/use_smile_id_document_shimmer.tsx +51 -0
- package/src/presentation/components/use_smile_id_enhanced_smart_selfie_clip.tsx +0 -3
- package/src/presentation/components/use_smile_id_guideline_thumbnail.tsx +131 -2
- package/src/presentation/components/use_smile_id_instructions_hero.tsx +100 -59
- package/src/presentation/components/use_smile_id_oval_border_palette.ts +7 -3
- package/src/presentation/flow/__tests__/document_flow_navigation.test.ts +200 -1
- package/src/presentation/flow/dsl/builder/config_builder.ts +14 -0
- package/src/presentation/flow/dsl/builder/ml_builder.ts +13 -4
- package/src/presentation/flow/dsl/builder/screens_builder.ts +111 -10
- package/src/presentation/flow/dsl/builder/theme_builder.ts +19 -2
- package/src/presentation/flow/dsl/use_smile_id_builder.tsx +6 -4
- package/src/presentation/flow/dsl/use_smile_id_flow_builder.ts +62 -36
- package/src/presentation/flow/flow_navigation_manager.ts +179 -13
- package/src/presentation/flow/model/instruction_guideline.ts +6 -0
- package/src/presentation/flow/model/instructions_defaults.ts +103 -25
- package/src/presentation/flow/screen/orchestrated_capture_screen.tsx +43 -10
- package/src/presentation/flow/screen/orchestrated_instructions_screen.tsx +1 -0
- package/src/presentation/flow/screen/orchestrated_preview_screen.tsx +4 -2
- package/src/presentation/flow/screen/orchestrated_processing_screen.tsx +3 -3
- package/src/presentation/flow/validation/__tests__/job_type_validator.test.ts +64 -0
- package/src/presentation/flow/validation/job_type_validator.ts +24 -0
- package/src/presentation/screen/__tests__/instructions_screen_helpers.test.ts +15 -3
- package/src/presentation/screen/__tests__/use_smile_id_capture_screen.test.tsx +6 -4
- package/src/presentation/screen/helpers/capture_screen_helpers.ts +1 -0
- package/src/presentation/screen/helpers/instructions_screen_helpers.ts +7 -2
- package/src/presentation/screen/helpers/scan_state_to_overlay_state.ts +3 -0
- package/src/presentation/screen/use_smile_id_capture_screen.tsx +234 -36
- package/src/presentation/screen/use_smile_id_document_preview_screen.tsx +32 -22
- package/src/presentation/screen/use_smile_id_instructions_screen.tsx +4 -0
- package/src/presentation/screen/use_smile_id_preview_screen.tsx +9 -9
- package/src/presentation/screen/use_smile_id_processing_screen.tsx +7 -7
- package/src/presentation/theme/theme.ts +21 -19
- package/src/presentation/utils/force_max_brightness.tsx +4 -4
- package/dist/camera/frame_processor_plugin.d.ts +0 -28
- package/dist/camera/frame_processor_plugin.d.ts.map +0 -1
- package/dist/camera/frame_processor_plugin.js +0 -21
- package/dist/camera/frame_processor_plugin.js.map +0 -1
- package/dist/camera/use_smile_id_frame_processor.d.ts +0 -38
- package/dist/camera/use_smile_id_frame_processor.d.ts.map +0 -1
- package/dist/camera/use_smile_id_frame_processor.js +0 -2
- package/dist/camera/use_smile_id_frame_processor.js.map +0 -1
- package/dist/presentation/components/use_smile_id_document_frame_glyph.d.ts +0 -17
- package/dist/presentation/components/use_smile_id_document_frame_glyph.d.ts.map +0 -1
- package/dist/presentation/components/use_smile_id_document_frame_glyph.js +0 -17
- package/dist/presentation/components/use_smile_id_document_frame_glyph.js.map +0 -1
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_animation.d.ts +0 -24
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_animation.d.ts.map +0 -1
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_animation.js +0 -91
- package/dist/presentation/components/use_smile_id_enhanced_smart_selfie_animation.js.map +0 -1
- package/dist/presentation/components/use_smile_id_instruction_card.d.ts +0 -31
- package/dist/presentation/components/use_smile_id_instruction_card.d.ts.map +0 -1
- package/dist/presentation/components/use_smile_id_instruction_card.js +0 -43
- package/dist/presentation/components/use_smile_id_instruction_card.js.map +0 -1
- package/dist/presentation/screen/helpers/use_document_orientation_lock.d.ts +0 -24
- package/dist/presentation/screen/helpers/use_document_orientation_lock.d.ts.map +0 -1
- package/dist/presentation/screen/helpers/use_document_orientation_lock.js +0 -47
- package/dist/presentation/screen/helpers/use_document_orientation_lock.js.map +0 -1
- package/src/presentation/components/use_smile_id_document_frame_glyph.tsx +0 -162
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import * as jpeg from "jpeg-js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Integration tests that drive the compressor through `UriCompressibleAsset` with real
|
|
6
|
+
* JPEG bytes — the actual preserve-source / re-encode / rewrite-in-place path — instead
|
|
7
|
+
* of the linear in-memory fake used by the unit suite. The native seams are replaced by
|
|
8
|
+
* stateful mocks backed by an in-memory file store and the pure-JS `jpeg-js` codec, so
|
|
9
|
+
* the quality→size curve is a real JPEG curve (the on-device encoder is
|
|
10
|
+
* `expo-image-manipulator`, which cannot run under Node). Deterministic RGB noise is the
|
|
11
|
+
* JPEG worst case (no spatial redundancy), so it inflates the bundle well past the caps
|
|
12
|
+
* at capture quality and exercises the full quality-step loop.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// In-memory file store shared by the expo-file-system and expo-image-manipulator mocks.
|
|
16
|
+
const fileStore = new Map<string, Buffer>();
|
|
17
|
+
let renderCounter = 0;
|
|
18
|
+
|
|
19
|
+
vi.mock("expo-file-system", () => {
|
|
20
|
+
class File {
|
|
21
|
+
constructor(readonly uri: string) {}
|
|
22
|
+
get exists(): boolean {
|
|
23
|
+
return fileStore.has(this.uri);
|
|
24
|
+
}
|
|
25
|
+
get size(): number {
|
|
26
|
+
return fileStore.get(this.uri)?.length ?? 0;
|
|
27
|
+
}
|
|
28
|
+
copy(destination: File): void {
|
|
29
|
+
const bytes = fileStore.get(this.uri);
|
|
30
|
+
if (!bytes) throw new Error(`copy: missing ${this.uri}`);
|
|
31
|
+
fileStore.set(destination.uri, bytes);
|
|
32
|
+
}
|
|
33
|
+
delete(): void {
|
|
34
|
+
fileStore.delete(this.uri);
|
|
35
|
+
}
|
|
36
|
+
move(destination: File): void {
|
|
37
|
+
const bytes = fileStore.get(this.uri);
|
|
38
|
+
if (!bytes) throw new Error(`move: missing ${this.uri}`);
|
|
39
|
+
fileStore.set(destination.uri, bytes);
|
|
40
|
+
fileStore.delete(this.uri);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { __esModule: true, File };
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
vi.mock("expo-image-manipulator", () => ({
|
|
47
|
+
__esModule: true,
|
|
48
|
+
SaveFormat: { JPEG: "jpeg" },
|
|
49
|
+
ImageManipulator: {
|
|
50
|
+
manipulate: (uri: string) => ({
|
|
51
|
+
renderAsync: async () => ({
|
|
52
|
+
saveAsync: async (options: { compress: number }) => {
|
|
53
|
+
const source = fileStore.get(uri);
|
|
54
|
+
if (!source) throw new Error(`manipulate: missing ${uri}`);
|
|
55
|
+
const decoded = jpeg.decode(source, { useTArray: true });
|
|
56
|
+
const quality = Math.max(1, Math.round(options.compress * 100));
|
|
57
|
+
const encoded = jpeg.encode(
|
|
58
|
+
{
|
|
59
|
+
data: decoded.data,
|
|
60
|
+
width: decoded.width,
|
|
61
|
+
height: decoded.height,
|
|
62
|
+
},
|
|
63
|
+
quality,
|
|
64
|
+
);
|
|
65
|
+
const outUri = `file:///render/${renderCounter++}.jpg`;
|
|
66
|
+
fileStore.set(outUri, Buffer.from(encoded.data));
|
|
67
|
+
return { uri: outUri };
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
vi.mock("@smileid/usesmileid_bridge/src/exif/smile_exif_tagger", () => ({
|
|
75
|
+
__esModule: true,
|
|
76
|
+
SmileExifTagger: { finalize: vi.fn(async () => undefined) },
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
import { ImageType } from "@smileid/usesmileid_bridge";
|
|
80
|
+
|
|
81
|
+
import { CompressibleAssets } from "../compressible_asset";
|
|
82
|
+
import {
|
|
83
|
+
base64Len,
|
|
84
|
+
PayloadCompressionConfig,
|
|
85
|
+
} from "../payload_compression_config";
|
|
86
|
+
import { PayloadCompressionRunner } from "../payload_compression_runner";
|
|
87
|
+
import { PayloadCompressor } from "../payload_compressor";
|
|
88
|
+
import { UriCompressibleAsset } from "../uri_compressible_asset";
|
|
89
|
+
|
|
90
|
+
/** Deterministic RGBA noise encoded as a real JPEG at `quality`, stored at `uri`. */
|
|
91
|
+
function writeNoiseJpeg(
|
|
92
|
+
uri: string,
|
|
93
|
+
width: number,
|
|
94
|
+
height: number,
|
|
95
|
+
quality: number,
|
|
96
|
+
): void {
|
|
97
|
+
let state = 42n;
|
|
98
|
+
const data = Buffer.alloc(width * height * 4);
|
|
99
|
+
for (let index = 0; index < data.length; index += 1) {
|
|
100
|
+
state =
|
|
101
|
+
(state * 6364136223846793005n + 1442695040888963407n) &
|
|
102
|
+
0xffffffffffffffffn;
|
|
103
|
+
data[index] = (index + 1) % 4 === 0 ? 255 : Number((state >> 33n) & 0xffn);
|
|
104
|
+
}
|
|
105
|
+
const encoded = jpeg.encode({ data, width, height }, quality);
|
|
106
|
+
fileStore.set(uri, Buffer.from(encoded.data));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function storedSize(uri: string): number {
|
|
110
|
+
return fileStore.get(uri)?.length ?? 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function decodable(uri: string): { width: number; height: number } {
|
|
114
|
+
const bytes = fileStore.get(uri);
|
|
115
|
+
if (!bytes) throw new Error(`missing ${uri}`);
|
|
116
|
+
const decoded = jpeg.decode(bytes, { useTArray: true });
|
|
117
|
+
return { width: decoded.width, height: decoded.height };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
describe("PayloadCompressor with real JPEG bytes", () => {
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
fileStore.clear();
|
|
123
|
+
renderCounter = 0;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it(
|
|
127
|
+
"compresses an inflated selfie+liveness bundle under the caps and keeps files decodable",
|
|
128
|
+
{ timeout: 120_000 },
|
|
129
|
+
async () => {
|
|
130
|
+
const selfieUri = "file:///capture/selfie.jpg";
|
|
131
|
+
const livenessUri = "file:///capture/liveness.jpg";
|
|
132
|
+
writeNoiseJpeg(selfieUri, 1800, 1350, 95);
|
|
133
|
+
writeNoiseJpeg(livenessUri, 1400, 1050, 95);
|
|
134
|
+
const metadataBytes = 200 * 1024;
|
|
135
|
+
|
|
136
|
+
const initialRaw =
|
|
137
|
+
storedSize(selfieUri) + storedSize(livenessUri) + metadataBytes;
|
|
138
|
+
// Precondition: the bundle genuinely exceeds the 4.0 MiB target (the ticket's
|
|
139
|
+
// artificially inflated payload).
|
|
140
|
+
expect(initialRaw).toBeGreaterThan(PayloadCompressionConfig.rawTarget);
|
|
141
|
+
|
|
142
|
+
const sizes = await PayloadCompressionRunner.compress({
|
|
143
|
+
selfieImage: selfieUri,
|
|
144
|
+
livenessImages: [livenessUri],
|
|
145
|
+
metadataBytes,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const finalRaw =
|
|
149
|
+
storedSize(selfieUri) + storedSize(livenessUri) + metadataBytes;
|
|
150
|
+
const finalProjected =
|
|
151
|
+
base64Len(storedSize(selfieUri)) +
|
|
152
|
+
base64Len(storedSize(livenessUri)) +
|
|
153
|
+
metadataBytes +
|
|
154
|
+
PayloadCompressionConfig.structuralOverheadBytes;
|
|
155
|
+
|
|
156
|
+
expect(finalRaw).toBeLessThanOrEqual(PayloadCompressionConfig.rawTarget);
|
|
157
|
+
expect(finalProjected).toBeLessThanOrEqual(
|
|
158
|
+
PayloadCompressionConfig.hardEncodedCap,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// The rewritten bytes are still valid JPEGs at the original dimensions
|
|
162
|
+
// (quality-only re-encode, no resample).
|
|
163
|
+
expect(decodable(selfieUri)).toEqual({ width: 1800, height: 1350 });
|
|
164
|
+
expect(decodable(livenessUri)).toEqual({ width: 1400, height: 1050 });
|
|
165
|
+
|
|
166
|
+
// Reported size metadata reflects the shrink.
|
|
167
|
+
expect(sizes.selfieOriginalMb).toBeDefined();
|
|
168
|
+
expect(sizes.selfieFinalMb).toBeDefined();
|
|
169
|
+
expect(sizes.selfieFinalMb!).toBeLessThan(sizes.selfieOriginalMb!);
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
it(
|
|
174
|
+
"compresses a document-heavy bundle back-first and lands under the guarantee caps",
|
|
175
|
+
{ timeout: 120_000 },
|
|
176
|
+
async () => {
|
|
177
|
+
const frontUri = "file:///capture/front.jpg";
|
|
178
|
+
const backUri = "file:///capture/back.jpg";
|
|
179
|
+
writeNoiseJpeg(frontUri, 1900, 1425, 95);
|
|
180
|
+
writeNoiseJpeg(backUri, 1900, 1425, 95);
|
|
181
|
+
const metadataBytes = 100 * 1024;
|
|
182
|
+
|
|
183
|
+
const front = new UriCompressibleAsset(
|
|
184
|
+
ImageType.DocumentFront,
|
|
185
|
+
frontUri,
|
|
186
|
+
0.95,
|
|
187
|
+
);
|
|
188
|
+
const back = new UriCompressibleAsset(
|
|
189
|
+
ImageType.DocumentBack,
|
|
190
|
+
backUri,
|
|
191
|
+
0.95,
|
|
192
|
+
);
|
|
193
|
+
const assets = new CompressibleAssets({
|
|
194
|
+
documentFront: front,
|
|
195
|
+
documentBack: back,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Precondition: combined documents exceed the 4 MiB Rule-A trigger.
|
|
199
|
+
expect(assets.documentCombinedSize()).toBeGreaterThan(
|
|
200
|
+
PayloadCompressionConfig.docCombinedTrigger,
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
await PayloadCompressor.prepareBundleForTransmission(
|
|
204
|
+
assets,
|
|
205
|
+
metadataBytes,
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// Back is compressed before front, so it never ends at a higher quality.
|
|
209
|
+
expect(back.quality()).toBeLessThanOrEqual(front.quality());
|
|
210
|
+
expect(
|
|
211
|
+
PayloadCompressor.rawBundleSize(assets, metadataBytes),
|
|
212
|
+
).toBeLessThanOrEqual(PayloadCompressionConfig.rawFallback);
|
|
213
|
+
expect(
|
|
214
|
+
PayloadCompressor.projectedEncodedSize(assets, metadataBytes),
|
|
215
|
+
).toBeLessThanOrEqual(PayloadCompressionConfig.hardEncodedCap);
|
|
216
|
+
|
|
217
|
+
// Both documents survive as decodable JPEGs.
|
|
218
|
+
expect(decodable(frontUri)).toEqual({ width: 1900, height: 1425 });
|
|
219
|
+
expect(decodable(backUri)).toEqual({ width: 1900, height: 1425 });
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ImageTypeId } from "@smileid/usesmileid_bridge";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single compressible image, abstracted so the orchestration logic (`PayloadCompressor`) is
|
|
5
|
+
* pure and unit-testable with in-memory fakes — the real implementation re-encodes the JPEG via
|
|
6
|
+
* a native module and re-stamps the Smile EXIF `image_digest` the backend validates.
|
|
7
|
+
*
|
|
8
|
+
* Contract: `recompress` **must re-encode from the retained source pixels**, never from the
|
|
9
|
+
* already-compressed bytes, so repeated steps don't stack generational loss and retries are
|
|
10
|
+
* deterministic. It is asynchronous because the encode/re-stamp delegates to native code.
|
|
11
|
+
*/
|
|
12
|
+
export interface CompressibleAsset {
|
|
13
|
+
/** The image's wire type — also the EXIF re-stamp's `image_type_id`. */
|
|
14
|
+
readonly imageType: ImageTypeId;
|
|
15
|
+
/** Current encoded JPEG size in bytes. */
|
|
16
|
+
encodedSize(): number;
|
|
17
|
+
/** Current re-encode quality in `[0, 1]`. Reports the capture quality before any recompress. */
|
|
18
|
+
quality(): number;
|
|
19
|
+
/** Re-encode from the retained source at `quality` (caller clamps to the floor). */
|
|
20
|
+
recompress(quality: number): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The full set of images in one submission. Any role may be absent (e.g. SmartSelfie has no
|
|
25
|
+
* documents; Enhanced KYC has no images at all → the compressor is a no-op).
|
|
26
|
+
*/
|
|
27
|
+
export class CompressibleAssets {
|
|
28
|
+
readonly selfie: CompressibleAsset | undefined;
|
|
29
|
+
readonly liveness: readonly CompressibleAsset[];
|
|
30
|
+
readonly documentFront: CompressibleAsset | undefined;
|
|
31
|
+
readonly documentBack: CompressibleAsset | undefined;
|
|
32
|
+
|
|
33
|
+
constructor(args: {
|
|
34
|
+
selfie?: CompressibleAsset | undefined;
|
|
35
|
+
liveness?: readonly CompressibleAsset[] | undefined;
|
|
36
|
+
documentFront?: CompressibleAsset | undefined;
|
|
37
|
+
documentBack?: CompressibleAsset | undefined;
|
|
38
|
+
}) {
|
|
39
|
+
this.selfie = args.selfie;
|
|
40
|
+
this.liveness = args.liveness ?? [];
|
|
41
|
+
this.documentFront = args.documentFront;
|
|
42
|
+
this.documentBack = args.documentBack;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** All present assets, in submission order. */
|
|
46
|
+
all(): CompressibleAsset[] {
|
|
47
|
+
const result: CompressibleAsset[] = [];
|
|
48
|
+
if (this.selfie) result.push(this.selfie);
|
|
49
|
+
result.push(...this.liveness);
|
|
50
|
+
if (this.documentFront) result.push(this.documentFront);
|
|
51
|
+
if (this.documentBack) result.push(this.documentBack);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Combined size of the front + back document images (0 when neither is present). */
|
|
56
|
+
documentCombinedSize(): number {
|
|
57
|
+
return (
|
|
58
|
+
(this.documentFront?.encodedSize() ?? 0) +
|
|
59
|
+
(this.documentBack?.encodedSize() ?? 0)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared byte-size guardrails and adaptive JPEG-compression constants for keeping a v3
|
|
3
|
+
* form-data submission under AWS Lambda's 6 MB synchronous payload limit.
|
|
4
|
+
*
|
|
5
|
+
* **Cross-SDK source of truth** — the same thresholds, order, floors, and {@link base64Len}
|
|
6
|
+
* formula are mirrored byte-for-byte in the Android, iOS, and Flutter SDKs. Do not diverge any
|
|
7
|
+
* value without updating all four platforms.
|
|
8
|
+
*
|
|
9
|
+
* Lambda sees the **base64-encoded** body forwarded by API Gateway (base64 expands binary by
|
|
10
|
+
* ~33%), so the real guardrail is `PayloadCompressor.projectedEncodedSize` against
|
|
11
|
+
* `hardEncodedCap` — not raw bytes. Units are **binary MB (MiB, 1 << 20)**, locked across all
|
|
12
|
+
* four SDKs.
|
|
13
|
+
*/
|
|
14
|
+
const BYTES_PER_MB = 1 << 20;
|
|
15
|
+
|
|
16
|
+
export const PayloadCompressionConfig = {
|
|
17
|
+
/** 1 MiB. Binary MB is the locked cross-SDK unit. */
|
|
18
|
+
bytesPerMB: BYTES_PER_MB,
|
|
19
|
+
/** Primary compression goal for the raw bundle. */
|
|
20
|
+
rawTarget: 4 * BYTES_PER_MB,
|
|
21
|
+
/** Relaxed raw ceiling, accepted only if the projected encoded size still fits the cap. */
|
|
22
|
+
rawFallback: 4 * BYTES_PER_MB + BYTES_PER_MB / 2, // 4.5 MiB
|
|
23
|
+
/** The real guardrail: projected base64-encoded body must stay under this (margin under 6 MB). */
|
|
24
|
+
hardEncodedCap: Math.floor((57 * BYTES_PER_MB) / 10), // 5.7 MiB
|
|
25
|
+
/** Rule A trigger: combined document images larger than this start the document sub-pass. */
|
|
26
|
+
docCombinedTrigger: 4 * BYTES_PER_MB,
|
|
27
|
+
/** Rule A sub-target: pull the combined documents under this (back first, then front). */
|
|
28
|
+
docCombinedTarget: 3 * BYTES_PER_MB,
|
|
29
|
+
/** Rule B trigger: a selfie larger than this marks a face-heavy job (faces compressed first). */
|
|
30
|
+
selfieTrigger: 1 * BYTES_PER_MB,
|
|
31
|
+
/** Minimum JPEG quality for face images (selfie + liveness) — higher penalty. Pending DS sign-off. */
|
|
32
|
+
faceMinQ: 0.45,
|
|
33
|
+
/** Minimum JPEG quality for document images — preserves OCR / MRZ. Pending DS sign-off. */
|
|
34
|
+
docMinQ: 0.7,
|
|
35
|
+
/**
|
|
36
|
+
* Absolute JPEG-quality floor for the hard-guarantee pass. When a bundle is still over
|
|
37
|
+
* `rawFallback` after every image has hit its per-type floor (`faceMinQ` / `docMinQ`), the
|
|
38
|
+
* guarantee pass keeps stepping quality down to this value — below the per-type floors — so an
|
|
39
|
+
* oversized capture never fails submission on size. Matches v11's quality-10 floor.
|
|
40
|
+
*/
|
|
41
|
+
absoluteMinQ: 0.1,
|
|
42
|
+
/** Quality decrement per re-encode step. */
|
|
43
|
+
qualityStep: 0.05,
|
|
44
|
+
/** Nominal re-encode start point; each asset steps down from its own capture quality. */
|
|
45
|
+
startQ: 0.9,
|
|
46
|
+
/** Fixed allowance for multipart field names + part framing not counted in image/metadata totals. */
|
|
47
|
+
structuralOverheadBytes: 2048,
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
/** base64 length of `n` raw bytes: `ceil(n / 3) * 4`. */
|
|
51
|
+
export function base64Len(n: number): number {
|
|
52
|
+
return Math.ceil(n / 3) * 4;
|
|
53
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { File } from "expo-file-system";
|
|
2
|
+
import { ImageType } from "@smileid/usesmileid_bridge";
|
|
3
|
+
|
|
4
|
+
import { CameraDefaults } from "../../camera/camera_defaults";
|
|
5
|
+
import { CompressibleAssets } from "./compressible_asset";
|
|
6
|
+
import { PayloadCompressor } from "./payload_compressor";
|
|
7
|
+
import { UriCompressibleAsset } from "./uri_compressible_asset";
|
|
8
|
+
|
|
9
|
+
// RN `CameraDefaults` only exposes the document JPEG quality; selfie/liveness capture quality
|
|
10
|
+
// match the cross-SDK values. These seed only the recompress start, which steps DOWN from here
|
|
11
|
+
// (never re-encoding above the capture quality, which would inflate).
|
|
12
|
+
const SELFIE_CAPTURE_QUALITY = 0.95;
|
|
13
|
+
const LIVENESS_CAPTURE_QUALITY = 0.8;
|
|
14
|
+
|
|
15
|
+
const BYTES_PER_MB = 1024 * 1024;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Per-role JPEG sizes in MB, measured before compression (`*Original`) and after (`*Final`); equal
|
|
19
|
+
* when the image was not compressed, `undefined` for an absent role. Stamped into the submission
|
|
20
|
+
* metadata so the backend sees each file's original size and its compressed size.
|
|
21
|
+
*/
|
|
22
|
+
export interface PayloadCompressionSizes {
|
|
23
|
+
readonly selfieOriginalMb?: number | undefined;
|
|
24
|
+
readonly selfieFinalMb?: number | undefined;
|
|
25
|
+
readonly frontOriginalMb?: number | undefined;
|
|
26
|
+
readonly frontFinalMb?: number | undefined;
|
|
27
|
+
readonly backOriginalMb?: number | undefined;
|
|
28
|
+
readonly backFinalMb?: number | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sizeInMb(uri: string | undefined): number | undefined {
|
|
32
|
+
if (uri === undefined) return undefined;
|
|
33
|
+
const bytes = new File(uri).size ?? 0;
|
|
34
|
+
return bytes > 0 ? bytes / BYTES_PER_MB : undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Builds `CompressibleAssets` from a submission's captured JPEG URIs and runs `PayloadCompressor`
|
|
39
|
+
* to bring the bundle under the transmission cap, re-stamping the Smile EXIF `image_digest` (and
|
|
40
|
+
* re-encoding natively) per step. Best-effort: it compresses each image down to its quality floor
|
|
41
|
+
* and resolves — it never throws on size, so submission is never blocked.
|
|
42
|
+
*/
|
|
43
|
+
export const PayloadCompressionRunner = {
|
|
44
|
+
async compress(args: {
|
|
45
|
+
selfieImage?: string | undefined;
|
|
46
|
+
livenessImages?: readonly string[] | undefined;
|
|
47
|
+
frontDocument?: string | undefined;
|
|
48
|
+
backDocument?: string | undefined;
|
|
49
|
+
metadataBytes: number;
|
|
50
|
+
}): Promise<PayloadCompressionSizes> {
|
|
51
|
+
// Original JPEG sizes, measured before the compressor rewrites the files in place.
|
|
52
|
+
const selfieOriginalMb = sizeInMb(args.selfieImage);
|
|
53
|
+
const frontOriginalMb = sizeInMb(args.frontDocument);
|
|
54
|
+
const backOriginalMb = sizeInMb(args.backDocument);
|
|
55
|
+
|
|
56
|
+
const assets = new CompressibleAssets({
|
|
57
|
+
selfie: args.selfieImage
|
|
58
|
+
? new UriCompressibleAsset(
|
|
59
|
+
ImageType.Selfie,
|
|
60
|
+
args.selfieImage,
|
|
61
|
+
SELFIE_CAPTURE_QUALITY,
|
|
62
|
+
)
|
|
63
|
+
: undefined,
|
|
64
|
+
liveness: (args.livenessImages ?? []).map(
|
|
65
|
+
(uri) =>
|
|
66
|
+
new UriCompressibleAsset(
|
|
67
|
+
ImageType.Liveness,
|
|
68
|
+
uri,
|
|
69
|
+
LIVENESS_CAPTURE_QUALITY,
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
documentFront: args.frontDocument
|
|
73
|
+
? new UriCompressibleAsset(
|
|
74
|
+
ImageType.DocumentFront,
|
|
75
|
+
args.frontDocument,
|
|
76
|
+
CameraDefaults.documentJpegQuality,
|
|
77
|
+
)
|
|
78
|
+
: undefined,
|
|
79
|
+
documentBack: args.backDocument
|
|
80
|
+
? new UriCompressibleAsset(
|
|
81
|
+
ImageType.DocumentBack,
|
|
82
|
+
args.backDocument,
|
|
83
|
+
CameraDefaults.documentJpegQuality,
|
|
84
|
+
)
|
|
85
|
+
: undefined,
|
|
86
|
+
});
|
|
87
|
+
await PayloadCompressor.prepareBundleForTransmission(
|
|
88
|
+
assets,
|
|
89
|
+
args.metadataBytes,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Final JPEG sizes, measured after compression (equal to the originals when not compressed).
|
|
93
|
+
return {
|
|
94
|
+
selfieOriginalMb,
|
|
95
|
+
selfieFinalMb: sizeInMb(args.selfieImage),
|
|
96
|
+
frontOriginalMb,
|
|
97
|
+
frontFinalMb: sizeInMb(args.frontDocument),
|
|
98
|
+
backOriginalMb,
|
|
99
|
+
backFinalMb: sizeInMb(args.backDocument),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CompressibleAsset,
|
|
3
|
+
CompressibleAssets,
|
|
4
|
+
} from "./compressible_asset";
|
|
5
|
+
import {
|
|
6
|
+
base64Len,
|
|
7
|
+
PayloadCompressionConfig as C,
|
|
8
|
+
} from "./payload_compression_config";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adaptive image-compression orchestrator that keeps a v3 submission under the Lambda payload
|
|
12
|
+
* cap. Pure decision logic over `CompressibleAssets` — the native JPEG encode + EXIF re-stamp
|
|
13
|
+
* lives behind `CompressibleAsset.recompress`.
|
|
14
|
+
*
|
|
15
|
+
* **Cross-SDK source of truth.** The size formulas, plan order, sub-rules, and loop here are
|
|
16
|
+
* mirrored byte-for-byte with the Android / iOS / Flutter SDKs. See `PayloadCompressionConfig`.
|
|
17
|
+
*
|
|
18
|
+
* Scope: image compression only. Metadata is **measured** (it counts toward the bundle and the
|
|
19
|
+
* projected encoded size) but never modified.
|
|
20
|
+
*/
|
|
21
|
+
export const PayloadCompressor = {
|
|
22
|
+
/** Raw bundle size: sum of current image bytes + serialized metadata JSON bytes. */
|
|
23
|
+
rawBundleSize(assets: CompressibleAssets, metadataBytes: number): number {
|
|
24
|
+
return (
|
|
25
|
+
assets.all().reduce((sum, asset) => sum + asset.encodedSize(), 0) +
|
|
26
|
+
metadataBytes
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Projected size of the base64-encoded body API Gateway forwards to Lambda: images are
|
|
32
|
+
* base64-expanded, metadata JSON is counted raw, plus a fixed structural allowance. The real
|
|
33
|
+
* guardrail.
|
|
34
|
+
*/
|
|
35
|
+
projectedEncodedSize(
|
|
36
|
+
assets: CompressibleAssets,
|
|
37
|
+
metadataBytes: number,
|
|
38
|
+
): number {
|
|
39
|
+
return (
|
|
40
|
+
assets
|
|
41
|
+
.all()
|
|
42
|
+
.reduce((sum, asset) => sum + base64Len(asset.encodedSize()), 0) +
|
|
43
|
+
metadataBytes +
|
|
44
|
+
C.structuralOverheadBytes
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Ordered (asset, minQuality) plan. Faces take the higher penalty (lower floor); documents are
|
|
50
|
+
* preserved. Rule B (selfie > 1 MB → faces first), Rule A (documents > 4 MB → back, front,
|
|
51
|
+
* faces last), else generic (faces first).
|
|
52
|
+
*/
|
|
53
|
+
buildCompressionPlan(
|
|
54
|
+
assets: CompressibleAssets,
|
|
55
|
+
): Array<[CompressibleAsset, number]> {
|
|
56
|
+
const plan: Array<[CompressibleAsset, number]> = [];
|
|
57
|
+
const selfieSize = assets.selfie?.encodedSize() ?? 0;
|
|
58
|
+
const docCombined = assets.documentCombinedSize();
|
|
59
|
+
|
|
60
|
+
if (assets.selfie && selfieSize > C.selfieTrigger) {
|
|
61
|
+
plan.push([assets.selfie, C.faceMinQ]);
|
|
62
|
+
for (const frame of assets.liveness) plan.push([frame, C.faceMinQ]);
|
|
63
|
+
if (assets.documentBack) plan.push([assets.documentBack, C.docMinQ]);
|
|
64
|
+
if (assets.documentFront) plan.push([assets.documentFront, C.docMinQ]);
|
|
65
|
+
} else if (docCombined > C.docCombinedTrigger) {
|
|
66
|
+
if (assets.documentBack) plan.push([assets.documentBack, C.docMinQ]);
|
|
67
|
+
if (assets.documentFront) plan.push([assets.documentFront, C.docMinQ]);
|
|
68
|
+
if (assets.selfie) plan.push([assets.selfie, C.faceMinQ]);
|
|
69
|
+
for (const frame of assets.liveness) plan.push([frame, C.faceMinQ]);
|
|
70
|
+
} else {
|
|
71
|
+
if (assets.selfie) plan.push([assets.selfie, C.faceMinQ]);
|
|
72
|
+
for (const frame of assets.liveness) plan.push([frame, C.faceMinQ]);
|
|
73
|
+
if (assets.documentBack) plan.push([assets.documentBack, C.docMinQ]);
|
|
74
|
+
if (assets.documentFront) plan.push([assets.documentFront, C.docMinQ]);
|
|
75
|
+
}
|
|
76
|
+
return plan;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Compress `assets` in place until the bundle is guaranteed to ship. Steps: early-out → Rule A
|
|
81
|
+
* document sub-target → walk the global plan to the per-type floors → hard-guarantee pass that
|
|
82
|
+
* drops past the floors (down to `absoluteMinQ`) until the bundle fits both caps. Never throws;
|
|
83
|
+
* a job never fails submission purely on payload size.
|
|
84
|
+
*/
|
|
85
|
+
async prepareBundleForTransmission(
|
|
86
|
+
assets: CompressibleAssets,
|
|
87
|
+
metadataBytes: number,
|
|
88
|
+
): Promise<void> {
|
|
89
|
+
// Step 0: already within both guardrails.
|
|
90
|
+
if (
|
|
91
|
+
this.projectedEncodedSize(assets, metadataBytes) <= C.hardEncodedCap &&
|
|
92
|
+
this.rawBundleSize(assets, metadataBytes) <= C.rawTarget
|
|
93
|
+
) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Step 1 (Rule A): pull the documents under the combined sub-target first (back, then front).
|
|
98
|
+
if (assets.documentCombinedSize() > C.docCombinedTrigger) {
|
|
99
|
+
const group = [assets.documentBack, assets.documentFront].filter(
|
|
100
|
+
(a): a is CompressibleAsset => a !== undefined,
|
|
101
|
+
);
|
|
102
|
+
await this._compressGroupToTarget(
|
|
103
|
+
group,
|
|
104
|
+
C.docMinQ,
|
|
105
|
+
C.docCombinedTarget,
|
|
106
|
+
() => assets.documentCombinedSize(),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Step 2: walk the global plan, re-measuring after each decrement, down to the per-type floors.
|
|
111
|
+
for (const [asset, minQuality] of this.buildCompressionPlan(assets)) {
|
|
112
|
+
while (
|
|
113
|
+
this.rawBundleSize(assets, metadataBytes) > C.rawTarget &&
|
|
114
|
+
asset.quality() > minQuality
|
|
115
|
+
) {
|
|
116
|
+
await asset.recompress(
|
|
117
|
+
Math.max(minQuality, asset.quality() - C.qualityStep),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (this.rawBundleSize(assets, metadataBytes) <= C.rawTarget) return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Step 3 (hard guarantee): if the bundle is still over the relaxed raw ceiling or the encoded
|
|
124
|
+
// cap after every image hit its per-type floor, keep stepping quality down past the floors to
|
|
125
|
+
// `absoluteMinQ` — faces first per the plan order — so the bundle always ships under the cap
|
|
126
|
+
// regardless of any per-type quality floor.
|
|
127
|
+
for (const [asset] of this.buildCompressionPlan(assets)) {
|
|
128
|
+
while (
|
|
129
|
+
this._overRelaxedCap(assets, metadataBytes) &&
|
|
130
|
+
asset.quality() > C.absoluteMinQ
|
|
131
|
+
) {
|
|
132
|
+
await asset.recompress(
|
|
133
|
+
Math.max(C.absoluteMinQ, asset.quality() - C.qualityStep),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (!this._overRelaxedCap(assets, metadataBytes)) return;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/** True while the bundle exceeds the relaxed raw ceiling or the projected encoded cap. */
|
|
141
|
+
_overRelaxedCap(assets: CompressibleAssets, metadataBytes: number): boolean {
|
|
142
|
+
return (
|
|
143
|
+
this.rawBundleSize(assets, metadataBytes) > C.rawFallback ||
|
|
144
|
+
this.projectedEncodedSize(assets, metadataBytes) > C.hardEncodedCap
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/** Reduce each asset in `group` (order matters) toward `target` as measured by `measure`. */
|
|
149
|
+
async _compressGroupToTarget(
|
|
150
|
+
group: CompressibleAsset[],
|
|
151
|
+
minQuality: number,
|
|
152
|
+
target: number,
|
|
153
|
+
measure: () => number,
|
|
154
|
+
): Promise<void> {
|
|
155
|
+
for (const asset of group) {
|
|
156
|
+
while (measure() > target && asset.quality() > minQuality) {
|
|
157
|
+
await asset.recompress(
|
|
158
|
+
Math.max(minQuality, asset.quality() - C.qualityStep),
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (measure() <= target) return;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { File } from "expo-file-system";
|
|
2
|
+
import { ImageManipulator, SaveFormat } from "expo-image-manipulator";
|
|
3
|
+
import type { ImageTypeId } from "@smileid/usesmileid_bridge";
|
|
4
|
+
// SmileExifTagger is SDK-internal (not on the public barrel) — deep import, matching the capture screen.
|
|
5
|
+
import { SmileExifTagger } from "@smileid/usesmileid_bridge/src/exif/smile_exif_tagger";
|
|
6
|
+
|
|
7
|
+
import type { CompressibleAsset } from "./compressible_asset";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `CompressibleAsset` backed by a captured JPEG at `uri`.
|
|
11
|
+
*
|
|
12
|
+
* The re-encode is **native** (`expo-image-manipulator`, per the spec's "do not reimplement
|
|
13
|
+
* compression in JS" rule), and the Smile EXIF `image_digest` re-stamp is **native**
|
|
14
|
+
* (`SmileExifTagger.finalize`). The original bytes are preserved once on the first `recompress`
|
|
15
|
+
* so every step re-encodes from source (no generational stacking; deterministic retries).
|
|
16
|
+
*/
|
|
17
|
+
export class UriCompressibleAsset implements CompressibleAsset {
|
|
18
|
+
private _quality: number;
|
|
19
|
+
private _size: number;
|
|
20
|
+
private _sourceUri: string | undefined;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
readonly imageType: ImageTypeId,
|
|
24
|
+
private readonly uri: string,
|
|
25
|
+
captureQuality: number,
|
|
26
|
+
) {
|
|
27
|
+
this._quality = Math.min(Math.max(captureQuality, 0), 1);
|
|
28
|
+
this._size = UriCompressibleAsset._fileSize(uri);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
encodedSize(): number {
|
|
32
|
+
return this._size;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
quality(): number {
|
|
36
|
+
return this._quality;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async recompress(quality: number): Promise<void> {
|
|
40
|
+
const target = new File(this.uri);
|
|
41
|
+
if (!target.exists) return;
|
|
42
|
+
|
|
43
|
+
// Preserve the source once so each step re-encodes from the original (no generational loss).
|
|
44
|
+
if (this._sourceUri === undefined) {
|
|
45
|
+
const originalUri = `${this.uri}.orig`;
|
|
46
|
+
try {
|
|
47
|
+
target.copy(new File(originalUri));
|
|
48
|
+
this._sourceUri = originalUri;
|
|
49
|
+
} catch {
|
|
50
|
+
// Copy failed — fall back to re-encoding in place (still functional, mild generational loss).
|
|
51
|
+
this._sourceUri = this.uri;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const clamped = Math.min(Math.max(quality, 0), 1);
|
|
56
|
+
const context = ImageManipulator.manipulate(this._sourceUri);
|
|
57
|
+
const rendered = await context.renderAsync();
|
|
58
|
+
const result = await rendered.saveAsync({
|
|
59
|
+
compress: clamped,
|
|
60
|
+
format: SaveFormat.JPEG,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Overwrite the request's path with the re-encoded bytes.
|
|
64
|
+
try {
|
|
65
|
+
if (target.exists) target.delete();
|
|
66
|
+
new File(result.uri).move(target);
|
|
67
|
+
} catch {
|
|
68
|
+
// Move failed — leave the request pointing at its original path; best effort.
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Re-stamp the Smile EXIF image_digest over the new bytes (native; context set at capture).
|
|
72
|
+
await SmileExifTagger.finalize(this.uri, this.imageType);
|
|
73
|
+
|
|
74
|
+
this._quality = quality;
|
|
75
|
+
this._size = UriCompressibleAsset._fileSize(this.uri);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private static _fileSize(uri: string): number {
|
|
79
|
+
try {
|
|
80
|
+
return new File(uri).size ?? 0;
|
|
81
|
+
} catch {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|