@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,234 @@
|
|
|
1
|
+
import { AnalyzerFactoryKey } from "@smileid/usesmileid_bridge";
|
|
2
|
+
|
|
3
|
+
import { CaptureType } from "../core/models/ml_config";
|
|
4
|
+
import { autoCaptureWireValue } from "../core/models/document_capture_mode";
|
|
5
|
+
import type { FlowConfiguration } from "../presentation/flow/config/flow_configuration";
|
|
6
|
+
import type {
|
|
7
|
+
CaptureConfigBuilder,
|
|
8
|
+
ConsentConfigBuilder,
|
|
9
|
+
} from "../presentation/flow/dsl/builder/screens_builder";
|
|
10
|
+
import {
|
|
11
|
+
type BuilderConfiguration,
|
|
12
|
+
builderConfigurationToJson,
|
|
13
|
+
} from "./builder_configuration";
|
|
14
|
+
import {
|
|
15
|
+
MODEL_DESCRIPTOR_UNKNOWN,
|
|
16
|
+
type ModelConfiguration,
|
|
17
|
+
type ModelDescriptor,
|
|
18
|
+
ModelProvider,
|
|
19
|
+
modelConfigurationToJson,
|
|
20
|
+
} from "./model_configuration";
|
|
21
|
+
import type { MetadataEntry } from "./use_smile_id_metadata";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Projects the resolved [FlowConfiguration] into the request-metadata
|
|
25
|
+
* configuration objects, so the telemetry layer never needs a parallel copy of
|
|
26
|
+
* the partner's choices.
|
|
27
|
+
*
|
|
28
|
+
* Fields that do not apply to the assembled flow report their accurate "absent"
|
|
29
|
+
* value (`false`, or `autocapture_default` for the capture mode) rather than
|
|
30
|
+
* being omitted, so the object always carries the full schema.
|
|
31
|
+
* `consent_icon_dimensions` is always `null`: the consent icon is a `ReactNode`
|
|
32
|
+
* with no measurable pixel size at configuration time.
|
|
33
|
+
*/
|
|
34
|
+
export function flowConfigurationToBuilderConfiguration(
|
|
35
|
+
configuration: FlowConfiguration,
|
|
36
|
+
): BuilderConfiguration {
|
|
37
|
+
const steps = configuration.screens.steps;
|
|
38
|
+
|
|
39
|
+
let consent: ConsentConfigBuilder | undefined;
|
|
40
|
+
const captures: CaptureConfigBuilder[] = [];
|
|
41
|
+
let instructionsUsed = false;
|
|
42
|
+
let previewUsed = false;
|
|
43
|
+
let processingUsed = false;
|
|
44
|
+
for (const step of steps) {
|
|
45
|
+
switch (step.kind) {
|
|
46
|
+
case "consent":
|
|
47
|
+
consent = step.config;
|
|
48
|
+
break;
|
|
49
|
+
case "instructions":
|
|
50
|
+
instructionsUsed = true;
|
|
51
|
+
break;
|
|
52
|
+
case "capture":
|
|
53
|
+
captures.push(step.config);
|
|
54
|
+
break;
|
|
55
|
+
case "preview":
|
|
56
|
+
previewUsed = true;
|
|
57
|
+
break;
|
|
58
|
+
case "processing":
|
|
59
|
+
processingUsed = true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const selfie = captures.find((capture) => capture.selfieConfig)?.selfieConfig;
|
|
65
|
+
const document = captures.find(
|
|
66
|
+
(capture) => capture.documentConfig,
|
|
67
|
+
)?.documentConfig;
|
|
68
|
+
const hasSelfieCapture =
|
|
69
|
+
selfie !== undefined ||
|
|
70
|
+
captures.some((capture) => capture.captureType === CaptureType.selfie);
|
|
71
|
+
const hasDocumentCapture =
|
|
72
|
+
document !== undefined ||
|
|
73
|
+
captures.some((capture) => capture.captureType === CaptureType.document);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
consentScreenUsed: consent !== undefined,
|
|
77
|
+
consentIconProvided: consent?.partnerIcon != null,
|
|
78
|
+
// A React Native consent icon is a ReactNode with no measurable pixel size.
|
|
79
|
+
consentIconDimensions: null,
|
|
80
|
+
consentAttributionShown: consent?.showAttribution ?? false,
|
|
81
|
+
instructionsScreenUsed: instructionsUsed,
|
|
82
|
+
selfiePreviewEnabled: previewUsed && hasSelfieCapture,
|
|
83
|
+
documentPreviewEnabled: previewUsed && hasDocumentCapture,
|
|
84
|
+
// No processing screen means the flow captures without submitting to the API.
|
|
85
|
+
submissionSkipped: !processingUsed,
|
|
86
|
+
allowAgentMode: selfie?.allowAgentMode ?? false,
|
|
87
|
+
enhancedLivenessEnabled: selfie?.enableEnhancedLiveness ?? false,
|
|
88
|
+
autoCaptureEnabled: autoCaptureWireValue(document?.captureMode),
|
|
89
|
+
allowGalleryUpload: document?.allowGalleryUpload ?? false,
|
|
90
|
+
captureBothSides: document?.captureBothSides ?? false,
|
|
91
|
+
allowSkipBack: document?.allowSkipBack ?? false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Describes the face and document models backing this flow.
|
|
97
|
+
*
|
|
98
|
+
* The face model is resolved from the registered selfie analyzer factory key;
|
|
99
|
+
* the document model reports the native no-op fallback, since the React Native
|
|
100
|
+
* document detector is not selectable from JS.
|
|
101
|
+
*/
|
|
102
|
+
export function flowConfigurationToModelConfiguration(
|
|
103
|
+
configuration: FlowConfiguration,
|
|
104
|
+
): ModelConfiguration {
|
|
105
|
+
const faceKey = configuration.ml?.analyzers.selfieConfig?.analyzerFactoryKey;
|
|
106
|
+
return {
|
|
107
|
+
faceModel: faceDescriptorOf(faceKey),
|
|
108
|
+
documentModel: NOOP_DOCUMENT_DESCRIPTOR,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The `builder_configuration_object` + `model_configuration_object` wire
|
|
114
|
+
* entries, encoded as JSON-string values so the metadata payload stays a flat
|
|
115
|
+
* `{name, value}` array.
|
|
116
|
+
*/
|
|
117
|
+
export function configurationMetadataEntries(
|
|
118
|
+
configuration: FlowConfiguration,
|
|
119
|
+
): MetadataEntry[] {
|
|
120
|
+
const entries: MetadataEntry[] = [
|
|
121
|
+
{
|
|
122
|
+
name: "builder_configuration_object",
|
|
123
|
+
value: JSON.stringify(
|
|
124
|
+
builderConfigurationToJson(
|
|
125
|
+
flowConfigurationToBuilderConfiguration(configuration),
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "model_configuration_object",
|
|
131
|
+
value: JSON.stringify(
|
|
132
|
+
modelConfigurationToJson(
|
|
133
|
+
flowConfigurationToModelConfiguration(configuration),
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
// Flow-derived selfie liveness telemetry — appended only for selfie flows.
|
|
140
|
+
const liveness = flowConfigurationToSelfieLivenessTelemetry(configuration);
|
|
141
|
+
if (liveness.activeLivenessType !== null) {
|
|
142
|
+
entries.push(
|
|
143
|
+
{ name: "active_liveness_type", value: liveness.activeLivenessType },
|
|
144
|
+
{
|
|
145
|
+
name: "active_liveness_version",
|
|
146
|
+
value: liveness.activeLivenessVersion,
|
|
147
|
+
},
|
|
148
|
+
{ name: "selfie_image_origin", value: liveness.selfieImageOrigin },
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return entries;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
type SelfieLivenessTelemetry =
|
|
155
|
+
| {
|
|
156
|
+
readonly activeLivenessType: string;
|
|
157
|
+
readonly activeLivenessVersion: string;
|
|
158
|
+
readonly selfieImageOrigin: string;
|
|
159
|
+
}
|
|
160
|
+
| {
|
|
161
|
+
readonly activeLivenessType: null;
|
|
162
|
+
readonly activeLivenessVersion: null;
|
|
163
|
+
readonly selfieImageOrigin: null;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Flow-derived selfie liveness telemetry. All-`null` for flows without a selfie
|
|
168
|
+
* capture; otherwise the active-liveness check (`head_pose` when enhanced
|
|
169
|
+
* liveness is on, else `smile`), the version, and the selfie origin (always
|
|
170
|
+
* `front_camera` — the selfie SDK has no gallery path).
|
|
171
|
+
*/
|
|
172
|
+
export function flowConfigurationToSelfieLivenessTelemetry(
|
|
173
|
+
configuration: FlowConfiguration,
|
|
174
|
+
): SelfieLivenessTelemetry {
|
|
175
|
+
let selfie: { enableEnhancedLiveness: boolean } | undefined;
|
|
176
|
+
let hasSelfieCapture = false;
|
|
177
|
+
for (const step of configuration.screens.steps) {
|
|
178
|
+
if (step.kind === "capture") {
|
|
179
|
+
selfie ??= step.config.selfieConfig;
|
|
180
|
+
if (step.config.captureType === CaptureType.selfie) {
|
|
181
|
+
hasSelfieCapture = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (!hasSelfieCapture && selfie === undefined) {
|
|
186
|
+
return {
|
|
187
|
+
activeLivenessType: null,
|
|
188
|
+
activeLivenessVersion: null,
|
|
189
|
+
selfieImageOrigin: null,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
activeLivenessType: selfie?.enableEnhancedLiveness ? "head_pose" : "smile",
|
|
194
|
+
activeLivenessVersion: "2.0.0",
|
|
195
|
+
selfieImageOrigin: "front_camera",
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function faceDescriptorOf(
|
|
200
|
+
key: AnalyzerFactoryKey | undefined,
|
|
201
|
+
): ModelDescriptor {
|
|
202
|
+
switch (key) {
|
|
203
|
+
case AnalyzerFactoryKey.MLKitFace:
|
|
204
|
+
return {
|
|
205
|
+
provider: ModelProvider.Google,
|
|
206
|
+
name: "play-services-mlkit-face-detection",
|
|
207
|
+
version: "17.1.0",
|
|
208
|
+
bundled: false,
|
|
209
|
+
};
|
|
210
|
+
case AnalyzerFactoryKey.HuaweiFace:
|
|
211
|
+
return {
|
|
212
|
+
provider: ModelProvider.Huawei,
|
|
213
|
+
name: "ml-computer-vision-face",
|
|
214
|
+
version: "3.18.1.300",
|
|
215
|
+
bundled: false,
|
|
216
|
+
};
|
|
217
|
+
case AnalyzerFactoryKey.VisionFace:
|
|
218
|
+
return {
|
|
219
|
+
provider: ModelProvider.Apple,
|
|
220
|
+
name: "vision_face_detector",
|
|
221
|
+
version: "system",
|
|
222
|
+
bundled: true,
|
|
223
|
+
};
|
|
224
|
+
default:
|
|
225
|
+
return MODEL_DESCRIPTOR_UNKNOWN;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const NOOP_DOCUMENT_DESCRIPTOR: ModelDescriptor = {
|
|
230
|
+
provider: ModelProvider.Smile,
|
|
231
|
+
name: "noop_document_detector",
|
|
232
|
+
version: "12.0.0",
|
|
233
|
+
bundled: true,
|
|
234
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side detection-model metadata appended to a job request as the
|
|
3
|
+
* `model_configuration_object` entry, so the server can attribute face /
|
|
4
|
+
* document detection behaviour to a concrete component and version during
|
|
5
|
+
* fraud analysis.
|
|
6
|
+
*
|
|
7
|
+
* `ModelProvider` is a stable lowercase wire token; `apple` covers detectors
|
|
8
|
+
* backed by Apple's Vision framework on iOS. New providers are additive.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const ModelProvider = {
|
|
12
|
+
Google: "google",
|
|
13
|
+
Huawei: "huawei",
|
|
14
|
+
Smile: "smile",
|
|
15
|
+
Apple: "apple",
|
|
16
|
+
Custom: "custom",
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export type ModelProvider = (typeof ModelProvider)[keyof typeof ModelProvider];
|
|
20
|
+
|
|
21
|
+
export type ModelDescriptor = {
|
|
22
|
+
readonly provider: ModelProvider;
|
|
23
|
+
/** Human-readable model identifier (e.g. the native artefact id). */
|
|
24
|
+
readonly name: string;
|
|
25
|
+
/** The model / framework version in use on the device. */
|
|
26
|
+
readonly version: string;
|
|
27
|
+
/** `true` when the model ships with the app / OS, `false` when downloaded on demand. */
|
|
28
|
+
readonly bundled: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Placeholder used when the active model for a capture type cannot be
|
|
33
|
+
* resolved, so the `model_configuration_object` always carries both
|
|
34
|
+
* `face_model` and `document_model` rather than omitting a side.
|
|
35
|
+
*/
|
|
36
|
+
export const MODEL_DESCRIPTOR_UNKNOWN: ModelDescriptor = Object.freeze({
|
|
37
|
+
provider: ModelProvider.Custom,
|
|
38
|
+
name: "unknown",
|
|
39
|
+
version: "unknown",
|
|
40
|
+
bundled: false,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export type ModelConfiguration = {
|
|
44
|
+
readonly faceModel: ModelDescriptor;
|
|
45
|
+
readonly documentModel: ModelDescriptor;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Serialises a [ModelDescriptor] to its snake_case wire object. */
|
|
49
|
+
export function modelDescriptorToJson(
|
|
50
|
+
descriptor: ModelDescriptor,
|
|
51
|
+
): Record<string, unknown> {
|
|
52
|
+
return {
|
|
53
|
+
provider: descriptor.provider,
|
|
54
|
+
name: descriptor.name,
|
|
55
|
+
version: descriptor.version,
|
|
56
|
+
bundled: descriptor.bundled,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Serialises a [ModelConfiguration] to its snake_case wire object. */
|
|
61
|
+
export function modelConfigurationToJson(
|
|
62
|
+
configuration: ModelConfiguration,
|
|
63
|
+
): Record<string, unknown> {
|
|
64
|
+
return {
|
|
65
|
+
face_model: modelDescriptorToJson(configuration.faceModel),
|
|
66
|
+
document_model: modelDescriptorToJson(configuration.documentModel),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lazy bridges to optional `expo-device` / `expo-network`
|
|
3
|
-
*
|
|
4
|
-
* partners who don't need richer metadata don't pay
|
|
2
|
+
* Lazy bridges to optional `expo-device` / `expo-network` / `expo-battery` /
|
|
3
|
+
* `expo-cellular` peer deps. All are declared `optional: true` in
|
|
4
|
+
* `peerDependenciesMeta` so partners who don't need richer metadata don't pay
|
|
5
|
+
* the install cost.
|
|
5
6
|
*
|
|
6
7
|
* **Pattern:** dynamic `require()` wrapped in `try/catch`. Metro
|
|
7
8
|
* tolerates the missing-module case without failing the build —
|
|
@@ -19,6 +20,14 @@ type DeviceModule = {
|
|
|
19
20
|
readonly brand?: string | null;
|
|
20
21
|
readonly supportedCpuArchitectures?: readonly string[] | null;
|
|
21
22
|
readonly totalMemory?: number | null;
|
|
23
|
+
// Android `Build.DEVICE`; iOS leaves this null (use `modelId` instead).
|
|
24
|
+
readonly designName?: string | null;
|
|
25
|
+
// Android `Build.PRODUCT`.
|
|
26
|
+
readonly productName?: string | null;
|
|
27
|
+
// Android `Build.FINGERPRINT`.
|
|
28
|
+
readonly osBuildFingerprint?: string | null;
|
|
29
|
+
// iOS hardware identifier (e.g. `iPhone16,2`).
|
|
30
|
+
readonly modelId?: string | null;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
type NetworkModule = {
|
|
@@ -30,8 +39,53 @@ type NetworkModule = {
|
|
|
30
39
|
getIpAddressAsync?(): Promise<string>;
|
|
31
40
|
};
|
|
32
41
|
|
|
42
|
+
type BatteryModule = {
|
|
43
|
+
// expo-battery `BatteryState`: 0 unknown, 1 unplugged, 2 charging, 3 full.
|
|
44
|
+
getBatteryStateAsync(): Promise<number>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type CellularModule = {
|
|
48
|
+
// Carrier name constant (may be null on Wi-Fi-only / dual-SIM devices).
|
|
49
|
+
readonly carrier?: string | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type AsyncStorageModule = {
|
|
53
|
+
getItem(key: string): Promise<string | null>;
|
|
54
|
+
setItem(key: string, value: string): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Subscription returned by `Accelerometer.addListener`. */
|
|
58
|
+
export type AccelerometerSubscription = { remove(): void };
|
|
59
|
+
|
|
60
|
+
/** Minimal `expo-sensors` surface used for device_positions / device_movement_detected. */
|
|
61
|
+
type SensorsModule = {
|
|
62
|
+
Accelerometer: {
|
|
63
|
+
setUpdateInterval(intervalMs: number): void;
|
|
64
|
+
addListener(
|
|
65
|
+
listener: (data: { x: number; y: number; z: number }) => void,
|
|
66
|
+
): AccelerometerSubscription;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Minimal `expo-location` surface used for the geolocation metadata. */
|
|
71
|
+
type LocationModule = {
|
|
72
|
+
getForegroundPermissionsAsync(): Promise<{ granted: boolean }>;
|
|
73
|
+
getLastKnownPositionAsync(): Promise<{
|
|
74
|
+
coords: {
|
|
75
|
+
latitude: number;
|
|
76
|
+
longitude: number;
|
|
77
|
+
accuracy: number | null;
|
|
78
|
+
};
|
|
79
|
+
} | null>;
|
|
80
|
+
};
|
|
81
|
+
|
|
33
82
|
let _device: DeviceModule | null | undefined;
|
|
34
83
|
let _network: NetworkModule | null | undefined;
|
|
84
|
+
let _battery: BatteryModule | null | undefined;
|
|
85
|
+
let _cellular: CellularModule | null | undefined;
|
|
86
|
+
let _asyncStorage: AsyncStorageModule | null | undefined;
|
|
87
|
+
let _sensors: SensorsModule | null | undefined;
|
|
88
|
+
let _location: LocationModule | null | undefined;
|
|
35
89
|
|
|
36
90
|
/**
|
|
37
91
|
* Load `expo-device`'s native module once, cached for the process
|
|
@@ -113,8 +167,108 @@ export function loadExpoNetwork(): NetworkModule | null {
|
|
|
113
167
|
return _network;
|
|
114
168
|
}
|
|
115
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Load `expo-battery`'s native module once, cached for the process lifetime.
|
|
172
|
+
* Returns `null` when the native module isn't linked (graceful degradation).
|
|
173
|
+
* Mirrors [loadExpoDevice] — pulls the raw `ExpoBattery` native module via
|
|
174
|
+
* `expo-modules-core`'s non-throwing `requireOptionalNativeModule`.
|
|
175
|
+
*/
|
|
176
|
+
export function loadExpoBattery(): BatteryModule | null {
|
|
177
|
+
if (_battery !== undefined) return _battery;
|
|
178
|
+
try {
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
180
|
+
const core = require("expo-modules-core") as {
|
|
181
|
+
requireOptionalNativeModule?: <T>(name: string) => T | null;
|
|
182
|
+
};
|
|
183
|
+
_battery =
|
|
184
|
+
core.requireOptionalNativeModule?.<BatteryModule>("ExpoBattery") ?? null;
|
|
185
|
+
} catch {
|
|
186
|
+
_battery = null;
|
|
187
|
+
}
|
|
188
|
+
return _battery;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Load `expo-cellular`'s native module once, cached for the process lifetime.
|
|
193
|
+
* Returns `null` when the native module isn't linked (graceful degradation).
|
|
194
|
+
* The raw `ExpoCellular` module exposes the `carrier` name constant directly.
|
|
195
|
+
*/
|
|
196
|
+
export function loadExpoCellular(): CellularModule | null {
|
|
197
|
+
if (_cellular !== undefined) return _cellular;
|
|
198
|
+
try {
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
200
|
+
const core = require("expo-modules-core") as {
|
|
201
|
+
requireOptionalNativeModule?: <T>(name: string) => T | null;
|
|
202
|
+
};
|
|
203
|
+
_cellular =
|
|
204
|
+
core.requireOptionalNativeModule?.<CellularModule>("ExpoCellular") ??
|
|
205
|
+
null;
|
|
206
|
+
} catch {
|
|
207
|
+
_cellular = null;
|
|
208
|
+
}
|
|
209
|
+
return _cellular;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Load `@react-native-async-storage/async-storage` once, cached for the process
|
|
214
|
+
* lifetime. Returns `null` when the package isn't installed (graceful
|
|
215
|
+
* degradation). Unlike the expo modules, async-storage's JS entry does not throw
|
|
216
|
+
* at import when the native side is missing, so a plain `require` (wrapped in
|
|
217
|
+
* try/catch for the not-installed case) is sufficient; per-call native errors
|
|
218
|
+
* are handled by the caller. Backed by Android `SharedPreferences` /
|
|
219
|
+
* iOS `NSUserDefaults`.
|
|
220
|
+
*/
|
|
221
|
+
export function loadAsyncStorage(): AsyncStorageModule | null {
|
|
222
|
+
if (_asyncStorage !== undefined) return _asyncStorage;
|
|
223
|
+
try {
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
225
|
+
const module = require("@react-native-async-storage/async-storage") as {
|
|
226
|
+
default?: AsyncStorageModule;
|
|
227
|
+
} & AsyncStorageModule;
|
|
228
|
+
_asyncStorage = module.default ?? module;
|
|
229
|
+
} catch {
|
|
230
|
+
_asyncStorage = null;
|
|
231
|
+
}
|
|
232
|
+
return _asyncStorage;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Load `expo-sensors` for accelerometer sampling. Returns `null` when the peer
|
|
237
|
+
* dep isn't installed/linked (graceful degradation — device_positions omitted).
|
|
238
|
+
*/
|
|
239
|
+
export function loadExpoSensors(): SensorsModule | null {
|
|
240
|
+
if (_sensors !== undefined) return _sensors;
|
|
241
|
+
try {
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
243
|
+
_sensors = require("expo-sensors") as SensorsModule;
|
|
244
|
+
} catch {
|
|
245
|
+
_sensors = null;
|
|
246
|
+
}
|
|
247
|
+
return _sensors;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Load `expo-location` for the geolocation metadata. Returns `null` when the
|
|
252
|
+
* peer dep isn't installed/linked (graceful degradation — geolocation omitted).
|
|
253
|
+
*/
|
|
254
|
+
export function loadExpoLocation(): LocationModule | null {
|
|
255
|
+
if (_location !== undefined) return _location;
|
|
256
|
+
try {
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
258
|
+
_location = require("expo-location") as LocationModule;
|
|
259
|
+
} catch {
|
|
260
|
+
_location = null;
|
|
261
|
+
}
|
|
262
|
+
return _location;
|
|
263
|
+
}
|
|
264
|
+
|
|
116
265
|
/** Test-only seam — clears the module cache so tests can re-evaluate. */
|
|
117
266
|
export function _resetOptionalModulesForTesting(): void {
|
|
118
267
|
_device = undefined;
|
|
119
268
|
_network = undefined;
|
|
269
|
+
_battery = undefined;
|
|
270
|
+
_cellular = undefined;
|
|
271
|
+
_asyncStorage = undefined;
|
|
272
|
+
_sensors = undefined;
|
|
273
|
+
_location = undefined;
|
|
120
274
|
}
|