@smileid/usesmileid 12.1.0 → 12.2.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +28 -17
  3. package/dist/camera/document_image_pipeline.d.ts +1 -1
  4. package/dist/camera/document_image_pipeline.js +1 -1
  5. package/dist/camera/use_smile_id_frame_stream.js +1 -1
  6. package/dist/camera/use_smile_id_kamera_camera_system.d.ts +6 -0
  7. package/dist/camera/use_smile_id_kamera_camera_system.js +1 -1
  8. package/dist/core/exception/invalid_job_type_screen_config_exception.js +1 -1
  9. package/dist/core/exception/missing_partner_config_exception.d.ts +2 -0
  10. package/dist/core/exception/missing_partner_config_exception.js +1 -1
  11. package/dist/core/exception/unused_job_params_exception.js +1 -1
  12. package/dist/core/exception/use_smile_id_error_code.d.ts +1 -0
  13. package/dist/core/exception/use_smile_id_error_code.js +1 -1
  14. package/dist/core/exception/use_smile_id_network_exception.d.ts +2 -1
  15. package/dist/core/exception/use_smile_id_network_exception.js +1 -1
  16. package/dist/core/models/document_type.d.ts +1 -1
  17. package/dist/core/models/job_type.d.ts +5 -0
  18. package/dist/core/models/job_type.js +1 -1
  19. package/dist/core/models/network_config.d.ts +2 -3
  20. package/dist/core/models/params.d.ts +18 -0
  21. package/dist/core/models/params.js +1 -1
  22. package/dist/data/api/interceptors/smile_auth_interceptor.js +1 -1
  23. package/dist/data/api/smile_id_api.d.ts +6 -12
  24. package/dist/data/api/smile_id_api.js +1 -1
  25. package/dist/data/compression/compressible_asset.d.ts +9 -1
  26. package/dist/data/compression/compressible_asset.js +1 -1
  27. package/dist/data/compression/payload_compression_runner.d.ts +3 -0
  28. package/dist/data/compression/payload_compression_runner.js +1 -1
  29. package/dist/data/compression/payload_compressor.js +1 -1
  30. package/dist/data/factory/networking_factory.d.ts +2 -0
  31. package/dist/data/factory/networking_factory.js +1 -1
  32. package/dist/data/model/job_request.d.ts +20 -1
  33. package/dist/data/model/token_payload.d.ts +17 -1
  34. package/dist/data/model/token_payload.js +1 -1
  35. package/dist/data/repository/use_smile_id_repository_impl.js +1 -1
  36. package/dist/debug/capture_debug_geometry.d.ts +29 -0
  37. package/dist/debug/capture_debug_geometry.js +1 -0
  38. package/dist/debug/document_preview_debug_geometry.d.ts +36 -0
  39. package/dist/debug/document_preview_debug_geometry.js +1 -0
  40. package/dist/debug/preview_debug_drawing.d.ts +51 -0
  41. package/dist/debug/preview_debug_drawing.js +1 -0
  42. package/dist/debug/selfie_preview_debug_geometry.d.ts +55 -0
  43. package/dist/debug/selfie_preview_debug_geometry.js +1 -0
  44. package/dist/debug/use_smile_id_debug.d.ts +61 -0
  45. package/dist/debug/use_smile_id_debug.js +1 -0
  46. package/dist/debug/use_smile_id_debug_tap.d.ts +25 -0
  47. package/dist/debug/use_smile_id_debug_tap.js +1 -0
  48. package/dist/debug/use_smile_id_document_capture_debug_overlay.d.ts +56 -0
  49. package/dist/debug/use_smile_id_document_capture_debug_overlay.js +1 -0
  50. package/dist/debug/use_smile_id_document_preview_debug_overlay.d.ts +32 -0
  51. package/dist/debug/use_smile_id_document_preview_debug_overlay.js +1 -0
  52. package/dist/debug/use_smile_id_selfie_capture_debug_overlay.d.ts +27 -0
  53. package/dist/debug/use_smile_id_selfie_capture_debug_overlay.js +1 -0
  54. package/dist/debug/use_smile_id_selfie_preview_debug_overlay.d.ts +60 -0
  55. package/dist/debug/use_smile_id_selfie_preview_debug_overlay.js +1 -0
  56. package/dist/index.d.ts +8 -1
  57. package/dist/index.js +1 -1
  58. package/dist/l10n/strings_en.d.ts +2 -1
  59. package/dist/l10n/strings_en.js +2 -2
  60. package/dist/l10n/use_smile_id_localizations.d.ts +1 -0
  61. package/dist/l10n/use_smile_id_localizations.js +1 -1
  62. package/dist/metadata/document_image_origin.d.ts +1 -0
  63. package/dist/metadata/document_image_origin.js +1 -1
  64. package/dist/metadata/metadata_configuration_mappers.js +1 -1
  65. package/dist/metadata/use_smile_id_metadata_factory.d.ts +4 -4
  66. package/dist/metadata/use_smile_id_metadata_factory.js +1 -1
  67. package/dist/presentation/assets/si_document_visa_hero_animation.json +1 -0
  68. package/dist/presentation/components/helpers/document_interior_crop.d.ts +54 -0
  69. package/dist/presentation/components/helpers/document_interior_crop.js +1 -0
  70. package/dist/presentation/components/helpers/selfie_interior_crop.d.ts +60 -0
  71. package/dist/presentation/components/helpers/selfie_interior_crop.js +1 -0
  72. package/dist/presentation/components/use_smile_id_capture_content.d.ts +7 -1
  73. package/dist/presentation/components/use_smile_id_capture_content.js +1 -1
  74. package/dist/presentation/components/use_smile_id_captured_document_image.d.ts +16 -0
  75. package/dist/presentation/components/use_smile_id_captured_document_image.js +1 -1
  76. package/dist/presentation/components/use_smile_id_captured_image_oval.d.ts +12 -4
  77. package/dist/presentation/components/use_smile_id_captured_image_oval.js +1 -1
  78. package/dist/presentation/components/use_smile_id_document_overlay.d.ts +12 -1
  79. package/dist/presentation/components/use_smile_id_document_overlay.js +1 -1
  80. package/dist/presentation/components/use_smile_id_document_shimmer.d.ts +10 -5
  81. package/dist/presentation/components/use_smile_id_document_shimmer.js +1 -1
  82. package/dist/presentation/flow/analytics/use_smile_id_analytics_event.d.ts +4 -1
  83. package/dist/presentation/flow/analytics/use_smile_id_analytics_event.js +1 -1
  84. package/dist/presentation/flow/analytics/use_smile_id_analytics_event_kind.d.ts +89 -0
  85. package/dist/presentation/flow/analytics/use_smile_id_analytics_event_kind.js +1 -0
  86. package/dist/presentation/flow/dsl/builder/screens_builder.d.ts +4 -2
  87. package/dist/presentation/flow/dsl/builder/screens_builder.js +1 -1
  88. package/dist/presentation/flow/dsl/use_smile_id_flow_builder.d.ts +17 -13
  89. package/dist/presentation/flow/dsl/use_smile_id_flow_builder.js +1 -1
  90. package/dist/presentation/flow/flow_navigation_manager.d.ts +52 -6
  91. package/dist/presentation/flow/flow_navigation_manager.js +1 -1
  92. package/dist/presentation/flow/model/instructions_defaults.d.ts +1 -0
  93. package/dist/presentation/flow/model/instructions_defaults.js +1 -1
  94. package/dist/presentation/flow/screen/helpers/always_enabled_slot.d.ts +8 -0
  95. package/dist/presentation/flow/screen/helpers/always_enabled_slot.js +1 -0
  96. package/dist/presentation/flow/screen/orchestrated_capture_screen.js +1 -1
  97. package/dist/presentation/flow/screen/orchestrated_consent_screen.js +1 -1
  98. package/dist/presentation/flow/screen/orchestrated_instructions_screen.js +1 -1
  99. package/dist/presentation/flow/screen/orchestrated_preview_screen.js +1 -1
  100. package/dist/presentation/flow/screen/orchestrated_processing_screen.js +1 -1
  101. package/dist/presentation/flow/validation/flow_validator.d.ts +13 -12
  102. package/dist/presentation/flow/validation/flow_validator.js +1 -1
  103. package/dist/presentation/flow/validation/job_type_validator.d.ts +9 -1
  104. package/dist/presentation/flow/validation/job_type_validator.js +1 -1
  105. package/dist/presentation/screen/use_smile_id_capture_screen.d.ts +6 -1
  106. package/dist/presentation/screen/use_smile_id_capture_screen.js +1 -1
  107. package/dist/presentation/screen/use_smile_id_document_back_instructions.js +1 -1
  108. package/dist/presentation/screen/use_smile_id_document_preview_screen.d.ts +5 -0
  109. package/dist/presentation/screen/use_smile_id_document_preview_screen.js +1 -1
  110. package/dist/presentation/screen/use_smile_id_preview_screen.js +1 -1
  111. package/dist/presentation/screen/use_smile_id_processing_screen.d.ts +5 -0
  112. package/dist/presentation/screen/use_smile_id_processing_screen.js +1 -1
  113. package/package.json +15 -15
@@ -1 +1 @@
1
- "use strict";import{jsx as I,Fragment as Ge,jsxs as Se}from"react/jsx-runtime";import{useCallback as R,useEffect as d,useMemo as K,useRef as u,useState as f}from"react";import{StatusBar as We,StyleSheet as ge,View as He}from"react-native";import*as we from"expo-image-picker";import{CaptureReadyEventKind as Ce,DocumentSide as Te,UseSmileIDScanStateType as y}from"@smileid/usesmileid_bridge";import{CaptureType as De}from"../../core/models/ml_config";import{resampleImportedDocument as ve}from"../../camera/document_image_pipeline";import{defaultLightTheme as Ve}from"../theme/theme";import{UseSmileIDThemeProvider as ze}from"../theme/theme_context";import{UseSmileIDCaptureContent as je}from"../components/use_smile_id_capture_content";import{DEFAULT_DOCUMENT_ASPECT as qe,documentGuideRect as Ne}from"../components/use_smile_id_document_overlay";import{UseSmileIDCrashReporting as C}from"@smileid/usesmileid_bridge";import{ForceMaxBrightness as Ye}from"../utils/force_max_brightness";import{CameraDefaults as ke}from"../../camera/camera_defaults";import{DocumentImageOrigin as J}from"../../metadata/document_image_origin";import{DeviceOrientationCollector as $e}from"../../metadata/device_orientation_collector";import{useSmileIDFrameStream as Je}from"../../camera/use_smile_id_frame_stream";import{CameraLens as B}from"../../camera/camera_lens";import{UseSmileIDKameraCameraSystem as Qe}from"../../camera/use_smile_id_kamera_camera_system";import{UseSmileIDKameraPreview as Xe}from"../../camera/use_smile_id_kamera_preview";import{useDeviceTiltDegrees as Ze,useLockedInterfaceOrientationDegrees as et}from"../../camera/use_kamera_orientation";import{useKameraCameraPermission as tt}from"../../camera/use_kamera_camera_permission";import{isTerminalKameraError as rt}from"../../camera/kamera_error_mapping";import{isSessionBoundary as nt,mapCaptureUiState as at,preCaptureUiState as it}from"./helpers/capture_ui_state";import{useDebouncedFeedbackKey as ot}from"./helpers/use_debounced_feedback_key";import{essTurnHaptic as ct,triggerEssTurnHaptic as st}from"./helpers/ess_turn_haptics";const ut=33;export function UseSmileIDCaptureScreen(t){const A=t.theme??Ve,Ee=t.showAttribution??!0,_=t.enableEnhancedLiveness??!1,Me=t.allowAgentMode??!1,L=t.captureType===De.selfie&&!Me?"front":"back",{hasPermission:T,requestPermission:Q}=tt(),h=K(()=>new Qe(L==="front"?B.front:B.back,t.createCameraSession),[]),X=u(!1);d(()=>{!T&&!X.current&&(X.current=!0,Q())},[T,Q]);const Z=t.onCameraError;d(()=>{if(!T)return;const e=h.addEventListener(r=>{r.type==="error"&&rt(r.code)&&Z?.(r.code,r.message)});return h.configure({captureType:t.captureType,lens:L==="front"?B.front:B.back}),h.start().catch(r=>{C.captureException(r instanceof Error?r:new Error(String(r)))}),()=>{e(),h.release()}},[T,h,L,t.captureType,Z]);const[ee,te]=f({type:y.Initial}),[i,s]=f(!1),[be,re]=f(0),[D,ne]=f(!1),[Ie,Re]=f(!1),[O,G]=f(!1),S=u(!1),[ae,W]=f(!1),[Ae,g]=f(!1),[P,H]=f(null);d(()=>{if(P===null)return;const e=setTimeout(()=>H(null),3e3);return()=>clearTimeout(e)},[P]);const v=u([]),n=u(!1),V=u(null),k=u(null),z=u(0),j=u(!1),F=u(new $e),q=R(()=>({durationMs:k.current===null?0:Date.now()-k.current,retries:z.current,devicePositions:F.current.devicePositions,deviceMovementDetected:F.current.deviceMovementDetected}),[]),ie=t.onStartCapture,N=R(()=>{if(i||n.current)return;ie?.(),re(r=>r+1),V.current=null;const e=S.current;S.current=!1,G(!1),W(!1),te({type:y.Initial}),ne(!1),v.current=[],e?t.analyzer.reset().catch(r=>C.captureException(r)).finally(()=>{n.current||s(!0)}):s(!0)},[i,ie,t.analyzer]),U=t.analyzer,E=t.onCaptureComplete,M=t.onDocumentOrigin,Y=t.onCaptureTimeout,x=t.captureMode,_e=t.allowGalleryUpload??!1,w=t.documentSide??Te.Front,m=t.captureType===De.document;d(()=>{k.current=null,z.current=0,j.current=!1},[w]),d(()=>(i&&F.current.start(),()=>F.current.stop()),[i]);const $=x?.kind==="autoCaptureWithManualFallback"?x.activateManualAfterMs:null;d(()=>{if(!i||$===null)return;const e=setTimeout(()=>{Re(!0)},$);return()=>clearTimeout(e)},[i,$]);const Pe=R(()=>{n.current||(n.current=!0,s(!1),g(!0),(async()=>{try{const e=await h.capture(),r=e.filePath.startsWith("file://")?e.filePath:`file://${e.filePath}`,o=await ve({uri:r,width:e.width,height:e.height},w);M?.(J.CameraManualCapture),E?.([{kind:Ce.Document,captureIndex:0,url:o}],q())}catch(e){C.captureException(e instanceof Error?e:new Error(String(e))),n.current=!1,g(!1),s(!0)}})())},[E,M,w]),Fe=R(()=>{n.current||(s(!1),g(!0),(async()=>{try{if(!(await we.requestMediaLibraryPermissionsAsync()).granted){g(!1),n.current||s(!0);return}const r=await we.launchImageLibraryAsync({mediaTypes:["images"],allowsMultipleSelection:!1,quality:1}),o=r.canceled?void 0:r.assets[0];if(o===void 0){g(!1),n.current||s(!0);return}if(o.width!==void 0&&o.height!==void 0&&Math.min(o.width,o.height)<ke.minGalleryDocumentDimensionPx){H("si_document_gallery_image_too_small"),g(!1),n.current||s(!0);return}if(n.current)return;n.current=!0;const a=await ve({uri:o.uri,width:o.width,height:o.height},w);M?.(J.Gallery),E?.([{kind:Ce.Document,captureIndex:0,url:a}],q())}catch(e){C.captureException(e instanceof Error?e:new Error(String(e))),H("si_document_gallery_image_failed"),n.current=!1,g(!1),s(!0)}})())},[E,M,w]),oe=u(!1),ce=u(N);ce.current=N,d(()=>{!m||oe.current||n.current||(oe.current=!0,ce.current())},[m]);const Ue=Je(i?U:null,e=>{const r=V.current;if(r!==null&&nt(r,e.state)&&re(a=>a+1),r!==null){const a=ct(r,e.state);a!==null&&st(a)}V.current=e.state,k.current===null&&(k.current=Date.now());const o=e.state.type===y.Unsatisfied;if(o&&!j.current&&(z.current+=1),j.current=o,e.state.type===y.Unsatisfied?v.current=[]:e.capturedEvents.length>0&&(v.current=[...v.current,...e.capturedEvents]),te(a=>a.type===e.state.type&&a.feedback===e.state.feedback&&a.reason===e.state.reason&&a.currentDirection===e.state.currentDirection&&(a.poseMatched??!1)===(e.state.poseMatched??!1)&&Math.round((a.captureProgress??0)*100)===Math.round((e.state.captureProgress??0)*100)?a:e.state),ne(!0),e.state.type===y.Finished){if(n.current||S.current)return;n.current=!0,s(!1),U.flush().catch(a=>{C.captureException(a)}).finally(()=>{M?.(J.CameraAutoCapture),E?.(v.current,q())})}else if(e.state.type===y.Timeout){if(n.current||S.current)return;s(!1),S.current=!0,G(!0),Y?.(e.state)}},{onError:e=>{C.captureException(e)}}),p=D?at(ee,t.captureType,_):it(t.captureType,_),se=ot(p.feedbackKey,be),ue=(ee.type===y.Initial&&!i||O)&&!m,xe=!i&&!n.current,le=T,me=u(Y);me.current=Y,d(()=>{if(!i||D)return;const e=setTimeout(()=>{n.current||S.current||(S.current=!0,W(!0),G(!0),s(!1),me.current?.({type:y.Timeout}))},ke.firstFrameTimeoutMs);return()=>clearTimeout(e)},[i,D]),d(()=>{D&&W(!1)},[D]);const de=Ue.onFrameResult,fe=Ze({retainWhenFlat:m}),he=et(),[l,Ke]=f({width:0,height:0}),Be=R(e=>{Ke(r=>r.width===e.width&&r.height===e.height?r:e)},[]),c=K(()=>{if(!m||l.width<=0||l.height<=0)return;const e=t.knownIdAspectRatio??qe,r=Ne(e,l.width,l.height);return{left:r.left/l.width,top:r.top/l.height,width:r.width/l.width,height:r.height/l.height,viewportWidthPx:Math.round(l.width),viewportHeightPx:Math.round(l.height)}},[m,l,t.knownIdAspectRatio]);d(()=>{if(!i)return;let e=!1,r=!1;const a=setInterval(()=>{e||r||(e=!0,U.analyzeKameraFrame({rotation:fe,viewportOrientation:he,cropLeft:c?c.left:0,cropTop:c?c.top:0,cropWidth:c?c.width:0,cropHeight:c?c.height:0,cropViewportWidth:c?c.viewportWidthPx:0,cropViewportHeight:c?c.viewportHeightPx:0}).then(b=>{r||de(b)}).catch(b=>{C.captureException(b instanceof Error?b:new Error(String(b)))}).finally(()=>{e=!1}))},ut);return()=>{r=!0,clearInterval(a)}},[i,U,de,fe,he,c]);const pe=m&&(O||i&&(x?.kind==="manualCapture"||x?.kind==="autoCaptureWithManualFallback"&&Ie)),ye=m&&(i||O)&&_e,Le=K(()=>({captureType:t.captureType,overlayState:p.overlayState,enableEnhancedLiveness:_,animationDirection:p.animationDirection,poseMatched:p.poseMatched,feedbackKey:ae?"si_capture_camera_unavailable":P??se,showCaptureButton:ue,showManualShutter:pe,showGalleryUpload:ye,isBackSide:w===Te.Back,...t.knownIdAspectRatio!==void 0?{knownIdAspectRatio:t.knownIdAspectRatio}:{},...t.documentTypeKind!==void 0?{documentTypeKind:t.documentTypeKind}:{}}),[t.captureType,p.overlayState,_,p.animationDirection,p.poseMatched,se,P,ae,ue,m,pe,ye,w,t.knownIdAspectRatio,t.documentTypeKind]),Oe=K(()=>Se(Ge,{children:[I(Ye,{}),le?I(Xe,{cameraSystem:h,style:ge.absoluteFill,testID:"si_capture_camera_preview"}):I(He,{style:[ge.absoluteFill,{backgroundColor:A.colors.offBlack}],testID:"si_capture_camera_placeholder"})]}),[le,h,A.colors.offBlack]);return Se(ze,{value:A,children:[I(We,{translucent:!0,backgroundColor:"transparent",barStyle:"dark-content"}),I(je,{state:Le,captureProgress:p.captureProgress,cameraPreview:Oe,onStartCapture:N,startCaptureEnabled:xe,onBack:t.onBack,showAttribution:Ee,startButton:t.startButton,onViewportLayout:Be,...m?{onManualShutter:Pe,onGalleryUpload:Fe,documentControlsEnabled:!Ae,...t.onClose?{onClose:t.onClose}:{}}:{},theme:A})]})}
1
+ "use strict";import{jsx as v,Fragment as qe,jsxs as ve}from"react/jsx-runtime";import{useCallback as B,useEffect as f,useMemo as V,useRef as s,useState as h}from"react";import{Platform as Ee,StatusBar as ze,StyleSheet as ke,View as Ne}from"react-native";import*as Me from"expo-image-picker";import{CaptureReadyEventKind as K,DocumentSide as Ye,UseSmileIDScanStateType as y}from"@smileid/usesmileid_bridge";import{CaptureType as te}from"../../core/models/ml_config";import{resampleImportedDocument as be}from"../../camera/document_image_pipeline";import{defaultLightTheme as $e}from"../theme/theme";import{UseSmileIDThemeProvider as Je}from"../theme/theme_context";import{UseSmileIDCaptureContent as Qe}from"../components/use_smile_id_capture_content";import{DEFAULT_DOCUMENT_ASPECT as Xe,documentGuideRect as Ze}from"../components/use_smile_id_document_overlay";import{UseSmileIDCrashReporting as E}from"@smileid/usesmileid_bridge";import{ForceMaxBrightness as et}from"../utils/force_max_brightness";import{captureDebugBoxesMirrored as Ae}from"../../debug/capture_debug_geometry";import{DocumentCaptureDebugOverlayHost as tt}from"../../debug/use_smile_id_document_capture_debug_overlay";import{SelfieCaptureDebugOverlayHost as rt}from"../../debug/use_smile_id_selfie_capture_debug_overlay";import{CameraDefaults as Re}from"../../camera/camera_defaults";import{DocumentImageOrigin as re}from"../../metadata/document_image_origin";import{DeviceOrientationCollector as nt}from"../../metadata/device_orientation_collector";import{useSmileIDFrameStream as at}from"../../camera/use_smile_id_frame_stream";import{CameraLens as j}from"../../camera/camera_lens";import{UseSmileIDKameraCameraSystem as it}from"../../camera/use_smile_id_kamera_camera_system";import{UseSmileIDKameraPreview as ot}from"../../camera/use_smile_id_kamera_preview";import{useDeviceTiltDegrees as ct,useLockedInterfaceOrientationDegrees as st}from"../../camera/use_kamera_orientation";import{useKameraCameraPermission as ut}from"../../camera/use_kamera_camera_permission";import{isTerminalKameraError as lt}from"../../camera/kamera_error_mapping";import{isSessionBoundary as mt,mapCaptureUiState as dt,preCaptureUiState as ft}from"./helpers/capture_ui_state";import{useDebouncedFeedbackKey as ht}from"./helpers/use_debounced_feedback_key";import{essTurnHaptic as pt,triggerEssTurnHaptic as yt}from"./helpers/ess_turn_haptics";const St=33;export function UseSmileIDCaptureScreen(t){const k=t.theme??$e,L=t.showAttribution??!0,S=t.enableEnhancedLiveness??!1,b=t.allowAgentMode??!1,A=t.captureType===te.selfie&&!b?"front":"back",{hasPermission:R,requestPermission:ne}=ut(),d=V(()=>new it(A==="front"?j.front:j.back,t.createCameraSession),[]),ae=s(!1);f(()=>{!R&&!ae.current&&(ae.current=!0,ne())},[R,ne]);const ie=t.onCameraError;f(()=>{if(!R)return;const e=d.addEventListener(r=>{r.type==="error"&&lt(r.code)&&ie?.(r.code,r.message)});return d.configure({captureType:t.captureType,lens:A==="front"?j.front:j.back}),d.start().catch(r=>{E.captureException(r instanceof Error?r:new Error(String(r)))}),()=>{e(),d.release()}},[R,d,A,t.captureType,ie]);const[oe,ce]=h({type:y.Initial}),[i,u]=h(!1),[Ie,se]=h(0),[I,ue]=h(!1),[_e,Pe]=h(!1),[q,z]=h(!1),w=s(!1),[le,N]=h(!1),[Fe,g]=h(!1),[G,Y]=h(null);f(()=>{if(G===null)return;const e=setTimeout(()=>Y(null),3e3);return()=>clearTimeout(e)},[G]);const D=s([]),a=s(!1),$=s(null),_=s(null),J=s(0),P=s(!1),F=s(null),H=s(new nt),Q=B(()=>({durationMs:_.current===null?0:Date.now()-_.current,retries:J.current,devicePositions:H.current.devicePositions,deviceMovementDetected:H.current.deviceMovementDetected}),[]),me=t.onStartCapture,X=B(()=>{if(i||a.current)return;me?.(),se(r=>r+1),$.current=null;const e=w.current;w.current=!1,z(!1),N(!1),ce({type:y.Initial}),ue(!1),D.current=[],P.current=!1,F.current=null,e?t.analyzer.reset().catch(r=>E.captureException(r)).finally(()=>{a.current||u(!0)}):u(!0)},[i,me,t.analyzer]),U=t.analyzer,x=t.onCaptureComplete,O=t.onDocumentOrigin,Z=t.onCaptureTimeout,Ue=t.onAnalyticsEvent,W=t.captureMode,xe=t.allowGalleryUpload??!1,C=t.documentSide??Ye.Front,l=t.captureType===te.document;f(()=>{_.current=null,J.current=0,P.current=!1,F.current=null},[C]),f(()=>(i&&H.current.start(),()=>H.current.stop()),[i]);const ee=W?.kind==="autoCaptureWithManualFallback"?W.activateManualAfterMs:null;f(()=>{if(!i||ee===null)return;const e=setTimeout(()=>{Pe(!0)},ee);return()=>clearTimeout(e)},[i,ee]);const Oe=B(()=>{a.current||(a.current=!0,u(!1),g(!0),(async()=>{try{const e=await d.capture(),r=e.filePath.startsWith("file://")?e.filePath:`file://${e.filePath}`,o=await be({uri:r,width:e.width,height:e.height},C);O?.(re.CameraManualCapture),x?.([{kind:K.Document,captureIndex:0,url:o}],Q())}catch(e){E.captureException(e instanceof Error?e:new Error(String(e))),a.current=!1,g(!1),u(!0)}})())},[x,O,C]),Be=B(()=>{a.current||(u(!1),g(!0),(async()=>{try{if(!(await Me.requestMediaLibraryPermissionsAsync()).granted){g(!1),a.current||u(!0);return}const r=await Me.launchImageLibraryAsync({mediaTypes:["images"],allowsMultipleSelection:!1,quality:1}),o=r.canceled?void 0:r.assets[0];if(o===void 0){g(!1),a.current||u(!0);return}if(o.width!==void 0&&o.height!==void 0&&Math.min(o.width,o.height)<Re.minGalleryDocumentDimensionPx){Y("si_document_gallery_image_too_small"),g(!1),a.current||u(!0);return}if(a.current)return;a.current=!0;const M=await be({uri:o.uri,width:o.width,height:o.height},C);O?.(re.Gallery),x?.([{kind:K.Document,captureIndex:0,url:M}],Q())}catch(e){E.captureException(e instanceof Error?e:new Error(String(e))),Y("si_document_gallery_image_failed"),a.current=!1,g(!1),u(!0)}})())},[x,O,C]),de=s(!1),fe=s(X);fe.current=X,f(()=>{!l||de.current||a.current||(de.current=!0,fe.current())},[l]);const Ke=at(i?U:null,e=>{const r=$.current;if(r!==null&&mt(r,e.state)&&se(n=>n+1),r!==null){const n=pt(r,e.state);n!==null&&yt(n)}$.current=e.state,_.current===null&&(_.current=Date.now()),F.current??=Date.now();const o=e.state.type===y.Unsatisfied,M=o&&!P.current,T=D.current.filter(n=>n.kind===K.Selfie||n.kind===K.Liveness).length,je=F.current;if(M?J.current+=1:!o&&P.current&&(F.current=Date.now()),P.current=o,e.state.type===y.Unsatisfied?D.current=[]:e.capturedEvents.length>0&&(D.current=[...D.current,...e.capturedEvents]),M&&!l&&Ue?.({kind:"selfieSessionRestarted",reason:e.state.reason??"unknown",framesDiscarded:T,durationMs:Date.now()-je}),ce(n=>n.type===e.state.type&&n.feedback===e.state.feedback&&n.reason===e.state.reason&&n.currentDirection===e.state.currentDirection&&(n.poseMatched??!1)===(e.state.poseMatched??!1)&&Math.round((n.captureProgress??0)*100)===Math.round((e.state.captureProgress??0)*100)?n:e.state),ue(!0),e.state.type===y.Finished){if(a.current||w.current)return;a.current=!0,u(!1),U.flush().catch(n=>{E.captureException(n)}).then(()=>wt(U,D.current)).then(n=>{O?.(re.CameraAutoCapture),x?.(D.current,Q(),n)})}else if(e.state.type===y.Timeout){if(a.current||w.current)return;u(!1),w.current=!0,z(!0),Z?.(e.state)}},{onError:e=>{E.captureException(e)}}),p=I?dt(oe,t.captureType,S):ft(t.captureType,S),he=ht(p.feedbackKey,Ie),pe=(oe.type===y.Initial&&!i||q)&&!l,Le=!i&&!a.current,ye=R,Se=s(Z);Se.current=Z,f(()=>{if(!i||I)return;const e=setTimeout(()=>{a.current||w.current||(w.current=!0,N(!0),z(!0),u(!1),Se.current?.({type:y.Timeout}))},Re.firstFrameTimeoutMs);return()=>clearTimeout(e)},[i,I]),f(()=>{I&&N(!1)},[I]);const we=Ke.onFrameResult,ge=ct({retainWhenFlat:l}),De=st(),[m,Ge]=h({width:0,height:0}),He=B(e=>{Ge(r=>r.width===e.width&&r.height===e.height?r:e)},[]),c=V(()=>{if(!l||m.width<=0||m.height<=0)return;const e=t.knownIdAspectRatio??Xe,r=Ze(e,m.width,m.height);return{left:r.left/m.width,top:r.top/m.height,width:r.width/m.width,height:r.height/m.height,viewportWidthPx:Math.round(m.width),viewportHeightPx:Math.round(m.height)}},[l,m,t.knownIdAspectRatio]);f(()=>{if(!i)return;let e=!1,r=!1;const M=setInterval(()=>{e||r||(e=!0,U.analyzeKameraFrame({rotation:ge,viewportOrientation:De,cropLeft:c?c.left:0,cropTop:c?c.top:0,cropWidth:c?c.width:0,cropHeight:c?c.height:0,cropViewportWidth:c?c.viewportWidthPx:0,cropViewportHeight:c?c.viewportHeightPx:0}).then(T=>{r||we(T)}).catch(T=>{E.captureException(T instanceof Error?T:new Error(String(T)))}).finally(()=>{e=!1}))},St);return()=>{r=!0,clearInterval(M)}},[i,U,we,ge,De,c]);const Ce=l&&(q||i&&(W?.kind==="manualCapture"||W?.kind==="autoCaptureWithManualFallback"&&_e)),Te=l&&(i||q)&&xe,We=V(()=>({captureType:t.captureType,overlayState:p.overlayState,enableEnhancedLiveness:S,animationDirection:p.animationDirection,poseMatched:p.poseMatched,feedbackKey:le?"si_capture_camera_unavailable":G??he,showCaptureButton:pe,showManualShutter:Ce,showGalleryUpload:Te,documentSide:C,...t.knownIdAspectRatio!==void 0?{knownIdAspectRatio:t.knownIdAspectRatio}:{},...t.documentTypeKind!==void 0?{documentTypeKind:t.documentTypeKind}:{}}),[t.captureType,p.overlayState,S,p.animationDirection,p.poseMatched,he,G,le,pe,l,Ce,Te,C,t.knownIdAspectRatio,t.documentTypeKind]),Ve=V(()=>ve(qe,{children:[v(et,{}),ye?v(ot,{cameraSystem:d,style:ke.absoluteFill,testID:"si_capture_camera_preview"}):v(Ne,{style:[ke.absoluteFill,{backgroundColor:k.colors.offBlack}],testID:"si_capture_camera_placeholder"})]}),[ye,d,k.colors.offBlack]);return ve(Je,{value:k,children:[v(ze,{translucent:!0,backgroundColor:"transparent",barStyle:"dark-content"}),v(Qe,{state:We,captureProgress:p.captureProgress,cameraPreview:Ve,onStartCapture:X,startCaptureEnabled:Le,onBack:t.onBack,showAttribution:L,startButton:t.startButton,onViewportLayout:He,...l?{onManualShutter:Oe,onGalleryUpload:Be,documentControlsEnabled:!Fe,...t.onClose?{onClose:t.onClose}:{}}:{},theme:k}),t.captureType===te.selfie?v(rt,{frameAspect:d.uprightPreviewAspect,mirrorBoxes:Ae(A==="front",Ee.OS==="android")}):l?v(tt,{streamAspect:d.uprightPreviewAspect,mirrorBoxes:Ae(A==="front",Ee.OS==="android")}):null]})}async function wt(t,k){if(t.kind!=="document"||!t.documentBorderFraction)return 0;const L=k.find(b=>b.kind===K.Document);if(!L)return 0;let S;try{return await Promise.race([t.documentBorderFraction(L.url),new Promise(b=>{S=setTimeout(()=>b(0),gt)})])}catch{return 0}finally{clearTimeout(S)}}const gt=1e3;
@@ -1 +1 @@
1
- "use strict";import{jsx as e,Fragment as _,jsxs as s}from"react/jsx-runtime";import{StyleSheet as d,Text as g,View as i}from"react-native";import{SafeAreaView as k}from"react-native-safe-area-context";import{useUseSmileIDTheme as I}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as p,UseSmileIDAttribution as D}from"../components/use_smile_id_attribution";import{UseSmileIDBackButton as b}from"../components/use_smile_id_back_button";import{UseSmileIDButton as a}from"../components/use_smile_id_button";import{UseSmileIDInstructionsHero as S}from"../components/use_smile_id_instructions_hero";import{DOCUMENT_HERO_BACK_ANIMATION as f}from"../flow/model/instructions_defaults";import{useUseSmileIDLocalizations as y}from"../../l10n/use_smile_id_localizations_provider";export function UseSmileIDDocumentBackInstructions(o){const c=I(),t=o.theme??c,n=y(),r=o.allowSkip??!1,m=o.onSkip??(()=>{}),u=o.heroSource??f,h=o.showAttribution??!0;return s(k,{style:[l.root,{backgroundColor:t.colors.background,paddingHorizontal:t.spacing.medium,paddingVertical:t.spacing.medium}],testID:"si_document_back_instructions",children:[o.onBack?e(b,{onClick:o.onBack,theme:t,testID:"si_back_button"}):null,e(i,{style:{height:t.spacing.medium}}),e(g,{accessibilityRole:"header",style:{...t.typography.pageHeading,fontWeight:"800",color:t.colors.titleText,textAlign:"center"},testID:"si_document_back_instructions_title",children:n.siDocumentFlipTitle(o.documentTypeDisplayName)}),e(i,{style:{height:t.spacing.medium}}),e(i,{style:l.hero,testID:"si_document_back_instructions_hero",children:e(S,{source:u,showOval:!1,showOvalProgress:!1,theme:t})}),s(i,{style:[l.bottom,{paddingHorizontal:t.spacing.extraSmall}],children:[e(a,{label:n.siDocumentCaptureBack,onClick:o.onCaptureBack,variant:"primary",theme:t,testID:"si_document_capture_back_button"}),r?s(_,{children:[e(i,{style:{height:t.spacing.small}}),e(a,{label:n.siDocumentSkipBack,onClick:m,variant:"secondary",theme:t,testID:"si_document_skip_back_button"})]}):null,e(i,{style:{height:t.spacing.small}}),h?e(D,{theme:t,testID:p}):null]})]})}const l=d.create({root:{flex:1},hero:{flex:1},bottom:{alignItems:"center"}});
1
+ "use strict";import{jsx as e,Fragment as _,jsxs as s}from"react/jsx-runtime";import{StyleSheet as d,Text as g,View as i}from"react-native";import{SafeAreaView as k}from"react-native-safe-area-context";import{useUseSmileIDTheme as I}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as p,UseSmileIDAttribution as D}from"../components/use_smile_id_attribution";import{UseSmileIDBackButton as b}from"../components/use_smile_id_back_button";import{UseSmileIDButton as l}from"../components/use_smile_id_button";import{UseSmileIDInstructionsHero as S}from"../components/use_smile_id_instructions_hero";import{DOCUMENT_HERO_BACK_ANIMATION as f}from"../flow/model/instructions_defaults";import{useUseSmileIDLocalizations as y}from"../../l10n/use_smile_id_localizations_provider";export function UseSmileIDDocumentBackInstructions(o){const a=I(),t=o.theme??a,n=y(),r=o.allowSkip??!1,m=o.onSkip??(()=>{}),u=o.heroSource??f,h=o.showAttribution??!0;return s(k,{style:[c.root,{backgroundColor:t.colors.background,paddingHorizontal:t.spacing.medium,paddingVertical:t.spacing.medium}],testID:"si_document_back_instructions_screen",children:[o.onBack?e(b,{onClick:o.onBack,theme:t,testID:"si_back_button"}):null,e(i,{style:{height:t.spacing.medium}}),e(g,{accessibilityRole:"header",style:{...t.typography.pageHeading,fontWeight:"800",color:t.colors.titleText,textAlign:"center"},testID:"si_document_back_instructions_title",children:n.siDocumentFlipTitle(o.documentTypeDisplayName)}),e(i,{style:{height:t.spacing.medium}}),e(i,{style:c.hero,testID:"si_document_back_instructions_hero",children:e(S,{source:u,showOval:!1,showOvalProgress:!1,theme:t})}),s(i,{style:[c.bottom,{paddingHorizontal:t.spacing.extraSmall}],children:[e(l,{label:n.siDocumentCaptureBack,onClick:o.onCaptureBack,variant:"primary",theme:t,testID:"si_document_capture_back_button"}),r?s(_,{children:[e(i,{style:{height:t.spacing.small}}),e(l,{label:n.siDocumentSkipBack,onClick:m,variant:"secondary",theme:t,testID:"si_document_skip_back_button"})]}):null,e(i,{style:{height:t.spacing.small}}),h?e(D,{theme:t,testID:p}):null]})]})}const c=d.create({root:{flex:1},hero:{flex:1},bottom:{alignItems:"center"}});
@@ -2,6 +2,11 @@ import type { UseSmileIDTheme } from "../theme/theme";
2
2
  export type UseSmileIDDocumentPreviewScreenProps = {
3
3
  /** Local file URI of the captured side being reviewed (front, then back). */
4
4
  readonly capturedDocumentPath?: string;
5
+ /**
6
+ * The hidden border {@link capturedDocumentPath} was saved with, as a fraction of its short side
7
+ * on every edge. The card hides exactly this much; 0 or unset shows the image whole.
8
+ */
9
+ readonly capturedDocumentBorderFraction?: number;
5
10
  /** Capture-frame aspect ratio (width / height) — drives the document image aspect. */
6
11
  readonly documentAspectRatio: number;
7
12
  readonly showAttribution?: boolean;
@@ -1 +1 @@
1
- "use strict";import{jsx as t,jsxs as c}from"react/jsx-runtime";import{Pressable as g,StyleSheet as h,Text as l,View as n}from"react-native";import{SafeAreaView as p,useSafeAreaInsets as f}from"react-native-safe-area-context";import{useUseSmileIDTheme as b}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as y,UseSmileIDAttribution as I}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedDocumentImage as S}from"../components/use_smile_id_captured_document_image";import{UseSmileIDCardSurface as _}from"../components/use_smile_id_card_surface";import{UseSmileIDConfirmationButtons as D}from"../components/use_smile_id_confirmation_buttons";import{SiOutlineClose as w}from"../components/icons";import{useUseSmileIDLocalizations as C}from"../../l10n/use_smile_id_localizations_provider";export function UseSmileIDDocumentPreviewScreen(i){const a=b(),e=i.theme??a,o=C(),m=i.showAttribution??!0,d=f();return c(p,{edges:["left","right","bottom"],style:[r.root,{backgroundColor:e.colors.background}],testID:"si_document_preview_screen",children:[i.onClose?t(n,{style:[r.closeRow,{paddingHorizontal:e.spacing.medium,paddingTop:d.top+e.spacing.small}],children:t(g,{onPress:i.onClose,accessibilityRole:"button",accessibilityLabel:o.siCdClose,testID:"si_document_preview_close",style:({pressed:u})=>[r.closeButton,{opacity:u?.7:1}],children:t(w,{size:20,color:"#FFFFFF"})})}):null,t(n,{style:[r.imageRegion,{paddingVertical:e.spacing.medium}],children:t(S,{aspectRatio:i.documentAspectRatio,...i.capturedDocumentPath?{uri:i.capturedDocumentPath}:{},imageTestID:"si_document_preview_image",imageAccessibilityLabel:o.siPreviewAccessibilityImage,theme:e})}),c(_,{theme:e,style:r.card,children:[t(l,{accessibilityRole:"header",style:{...e.typography.cardHeading,color:e.colors.primary,textAlign:"center",letterSpacing:-.425},children:o.siDocumentPreviewTitle}),t(l,{style:{...e.typography.cardCaption,color:e.colors.cardText,textAlign:"center",marginTop:e.spacing.extraSmall/2},children:o.siDocumentPreviewSubtitle}),t(n,{style:{marginTop:e.spacing.medium},children:t(D,{onAccept:()=>i.onAccept?.(),onReject:()=>i.onReject?.(),acceptLabel:o.siPreviewConfirm,rejectLabel:o.siPreviewRetake,theme:e,testID:"si_document_preview_confirmation_buttons"})})]}),m?t(I,{theme:e,testID:y}):null]})}const s=40,T="#848282",r=h.create({root:{flex:1,overflow:"hidden"},imageRegion:{flex:1},closeRow:{flexDirection:"row",justifyContent:"flex-end"},closeButton:{width:s,height:s,borderRadius:s/2,backgroundColor:T,borderWidth:1,borderColor:"rgba(255,255,255,0.1)",alignItems:"center",justifyContent:"center"},card:{alignItems:"center"}});
1
+ "use strict";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useState as b}from"react";import{Pressable as S,StyleSheet as y,Text as u,View as n}from"react-native";import{SafeAreaView as p,useSafeAreaInsets as I}from"react-native-safe-area-context";import{useUseSmileIDTheme as w}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as _,UseSmileIDAttribution as C}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedDocumentImage as v}from"../components/use_smile_id_captured_document_image";import{UseSmileIDCardSurface as T}from"../components/use_smile_id_card_surface";import{UseSmileIDConfirmationButtons as x}from"../components/use_smile_id_confirmation_buttons";import{SiOutlineClose as P}from"../components/icons";import{useUseSmileIDLocalizations as A}from"../../l10n/use_smile_id_localizations_provider";import{useDocumentPreviewOverlayEnabled as F}from"../../debug/use_smile_id_debug";import{UseSmileIDDocumentPreviewDebugOverlay as R}from"../../debug/use_smile_id_document_preview_debug_overlay";import{useImageSize as U}from"../components/helpers/selfie_interior_crop";export function UseSmileIDDocumentPreviewScreen(e){const d=w(),t=e.theme??d,o=A(),g=e.showAttribution??!0,h=I(),[a,f]=b(null),s=F(),l=U(s?e.capturedDocumentPath:void 0);return m(p,{edges:["left","right","bottom"],style:[r.root,{backgroundColor:t.colors.background}],testID:"si_document_preview_screen",children:[e.onClose?i(n,{style:[r.closeRow,{paddingHorizontal:t.spacing.medium,paddingTop:h.top+t.spacing.small}],children:i(S,{onPress:e.onClose,accessibilityRole:"button",accessibilityLabel:o.siCdClose,testID:"si_document_preview_close",style:({pressed:D})=>[r.closeButton,{opacity:D?.7:1}],children:i(P,{size:20,color:"#FFFFFF"})})}):null,i(n,{style:[r.imageRegion,{paddingVertical:t.spacing.medium}],children:i(v,{aspectRatio:e.documentAspectRatio,...e.capturedDocumentPath?{uri:e.capturedDocumentPath}:{},...e.capturedDocumentBorderFraction!==void 0?{borderFraction:e.capturedDocumentBorderFraction}:{},showDebugOverlay:!0,onCardLayout:f,imageTestID:"si_document_preview_image",imageAccessibilityLabel:o.siPreviewAccessibilityImage,theme:t})}),m(T,{theme:t,style:r.card,children:[i(u,{accessibilityRole:"header",style:{...t.typography.cardHeading,color:t.colors.primary,textAlign:"center",letterSpacing:-.425},children:o.siDocumentPreviewTitle}),i(u,{style:{...t.typography.cardCaption,color:t.colors.cardText,textAlign:"center",marginTop:t.spacing.extraSmall/2},children:o.siDocumentPreviewSubtitle}),i(n,{style:{marginTop:t.spacing.medium},children:i(x,{onAccept:()=>e.onAccept?.(),onReject:()=>e.onReject?.(),acceptLabel:o.siPreviewConfirm,rejectLabel:o.siPreviewRetake,theme:t,testID:"si_document_preview_confirmation_buttons"})})]}),g?i(C,{theme:t,testID:_}):null,s&&e.capturedDocumentPath&&a?i(R,{uri:e.capturedDocumentPath,imageSize:l.kind==="read"?l.size:null,cardSize:a,borderFraction:e.capturedDocumentBorderFraction??0}):null]})}const c=40,z="#848282",r=y.create({root:{flex:1,overflow:"hidden"},imageRegion:{flex:1},closeRow:{flexDirection:"row",justifyContent:"flex-end"},closeButton:{width:c,height:c,borderRadius:c/2,backgroundColor:z,borderWidth:1,borderColor:"rgba(255,255,255,0.1)",alignItems:"center",justifyContent:"center"},card:{alignItems:"center"}});
@@ -1 +1 @@
1
- "use strict";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{useState as w}from"react";import{StyleSheet as y,Text as n,View as I}from"react-native";import{SafeAreaView as v}from"react-native-safe-area-context";import{useUseSmileIDTheme as b}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as x,UseSmileIDAttribution as A}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedImageOval as D}from"../components/use_smile_id_captured_image_oval";import{UseSmileIDCardSurface as T}from"../components/use_smile_id_card_surface";import{UseSmileIDConfirmationButtons as _}from"../components/use_smile_id_confirmation_buttons";import{useUseSmileIDLocalizations as P}from"../../l10n/use_smile_id_localizations_provider";import{resolvePreviewState as j}from"./helpers/preview_screen_helpers";export function UseSmileIDPreviewScreen(t){const m=b(),e=t.theme??m,r=P(),l=t.showAttribution??!0,o=j(t),[c,h]=w({width:0,height:0}),d=f=>{const{width:S,height:p}=f.nativeEvent.layout;h({width:S,height:p})},g=()=>{t.onAccept?.()},u=()=>{o.canRetake&&t.onReject?.()};return s(v,{edges:["left","right","bottom"],style:[a.root,{backgroundColor:e.colors.background}],testID:"si_preview_screen",onLayout:d,children:[i(D,{screenWidth:c.width,screenHeight:c.height,...o.hasImage&&t.capturedSelfiePath?{uri:t.capturedSelfiePath}:{},imageTestID:"si_preview_image",imageAccessibilityLabel:r.siPreviewAccessibilityImage,theme:e}),s(T,{theme:e,style:a.card,children:[i(n,{accessibilityRole:"header",style:{...e.typography.cardHeading,color:e.colors.primary,textAlign:"center",letterSpacing:-.425},children:r.siPreviewTitle}),i(n,{style:{...e.typography.cardCaption,color:e.colors.cardText,textAlign:"center",marginTop:e.spacing.extraSmall/2},children:r.siPreviewSubtitle}),i(I,{style:{marginTop:e.spacing.medium},children:i(_,{onAccept:g,onReject:u,acceptLabel:r.siPreviewConfirm,rejectLabel:r.siPreviewRetake,theme:e,testID:"si_preview_confirmation_buttons"})})]}),l?i(A,{theme:e,testID:x}):null]})}const a=y.create({root:{flex:1,overflow:"hidden"},card:{alignItems:"center"}});
1
+ "use strict";import{jsx as i,jsxs as c}from"react/jsx-runtime";import{useState as w}from"react";import{StyleSheet as y,Text as n,View as I}from"react-native";import{SafeAreaView as v}from"react-native-safe-area-context";import{useUseSmileIDTheme as b}from"../theme/theme_context";import{ATTRIBUTION_TEST_ID as D,UseSmileIDAttribution as x}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedImageOval as A}from"../components/use_smile_id_captured_image_oval";import{UseSmileIDCardSurface as T}from"../components/use_smile_id_card_surface";import{UseSmileIDConfirmationButtons as _}from"../components/use_smile_id_confirmation_buttons";import{useUseSmileIDLocalizations as P}from"../../l10n/use_smile_id_localizations_provider";import{resolvePreviewState as j}from"./helpers/preview_screen_helpers";export function UseSmileIDPreviewScreen(t){const l=b(),e=t.theme??l,r=P(),m=t.showAttribution??!0,o=j(t),[s,h]=w({width:0,height:0}),d=f=>{const{width:S,height:p}=f.nativeEvent.layout;h({width:S,height:p})},g=()=>{t.onAccept?.()},u=()=>{o.canRetake&&t.onReject?.()};return c(v,{edges:["left","right","bottom"],style:[a.root,{backgroundColor:e.colors.background}],testID:"si_preview_screen",onLayout:d,children:[i(A,{screenWidth:s.width,screenHeight:s.height,...o.hasImage&&t.capturedSelfiePath?{uri:t.capturedSelfiePath}:{},imageTestID:"si_preview_image",imageAccessibilityLabel:r.siPreviewAccessibilityImage,showDebugOverlay:!0,theme:e}),c(T,{theme:e,style:a.card,children:[i(n,{accessibilityRole:"header",style:{...e.typography.cardHeading,color:e.colors.primary,textAlign:"center",letterSpacing:-.425},children:r.siPreviewTitle}),i(n,{style:{...e.typography.cardCaption,color:e.colors.cardText,textAlign:"center",marginTop:e.spacing.extraSmall/2},children:r.siPreviewSubtitle}),i(I,{style:{marginTop:e.spacing.medium},children:i(_,{onAccept:g,onReject:u,acceptLabel:r.siPreviewConfirm,rejectLabel:r.siPreviewRetake,theme:e,testID:"si_preview_confirmation_buttons"})})]}),m?i(x,{theme:e,testID:D}):null]})}const a=y.create({root:{flex:1,overflow:"hidden"},card:{alignItems:"center"}});
@@ -19,6 +19,11 @@ export type UseSmileIDProcessingScreenProps = {
19
19
  readonly documentImageUri?: string;
20
20
  /** Capture-frame aspect ratio (width / height) for {@link documentImageUri}. Defaults to landscape. */
21
21
  readonly documentAspectRatio?: number;
22
+ /**
23
+ * The hidden border {@link documentImageUri} was saved with, as a fraction of its short side on
24
+ * every edge. The card hides exactly this much; 0 or unset shows the image whole.
25
+ */
26
+ readonly documentBorderFraction?: number;
22
27
  readonly showProgressPercentage?: boolean;
23
28
  readonly showAttribution?: boolean;
24
29
  readonly onContinue?: () => void;
@@ -1 +1 @@
1
- "use strict";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useState as y}from"react";import{StyleSheet as U,View as h}from"react-native";import{SafeAreaView as k}from"react-native-safe-area-context";import{useUseSmileIDTheme as x}from"../theme/theme_context";import{defaultFrameAspectRatio as v}from"../../core/models/document_type";import{ATTRIBUTION_TEST_ID as w,UseSmileIDAttribution as R}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedDocumentImage as b}from"../components/use_smile_id_captured_document_image";import{UseSmileIDCapturedImageOval as A}from"../components/use_smile_id_captured_image_oval";import{UseSmileIDCardSurface as E}from"../components/use_smile_id_card_surface";import{UseSmileIDFailedContent as T}from"../components/use_smile_id_failed_content";import{UseSmileIDLoadingContent as L}from"../components/use_smile_id_loading_content";import{UseSmileIDStatusIndicator as m}from"../components/use_smile_id_status_indicator";import{UseSmileIDSuccessContent as F}from"../components/use_smile_id_success_content";import{useUseSmileIDLocalizations as O}from"../../l10n/use_smile_id_localizations_provider";function l(e){switch(e){case"loading":return"loading";case"success":return"success";case"failed":return"failure"}}export function UseSmileIDProcessingScreen(e){const f=x(),t=e.theme??f,a=O(),I=e.showAttribution??!0,_=e.showFaceOval??!0,[u,S]=y({width:0,height:0}),D=g=>{S({width:g.nativeEvent.layout.width,height:g.nativeEvent.layout.height})},C=typeof e.capturedSelfiePath=="string"&&e.capturedSelfiePath.length>0,d=typeof e.documentImageUri=="string"&&e.documentImageUri.length>0,c=e.continueButton,i=e.retryButton,s=e.exitButton;return r(k,{style:[o.root,{backgroundColor:t.colors.background}],testID:"si_processing_screen",onLayout:D,children:[d?n(b,{aspectRatio:e.documentAspectRatio??v("Landscape"),...e.documentImageUri?{uri:e.documentImageUri}:{},imageTestID:"si_processing_document_image",imageAccessibilityLabel:a.siCdCapturedImage,overlayChild:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"}),theme:t}):_?n(A,{screenWidth:u.width,screenHeight:u.height,...C&&e.capturedSelfiePath?{uri:e.capturedSelfiePath}:{},imageTestID:"si_processing_image",imageAccessibilityLabel:a.siCdCapturedImage,overlayChild:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"}),theme:t}):n(h,{style:o.noOvalRegion,testID:"si_processing_no_oval_region",children:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"})}),r(E,{theme:t,style:o.card,children:[e.state.kind==="loading"?n(L,{theme:t,testID:"si_processing_loading_content"}):null,e.state.kind==="success"?n(F,{theme:t,...d?{title:a.siDocumentProcessingComplete}:{},...e.state.message!==void 0?{message:e.state.message}:{},...e.onContinue&&!c?{onContinue:e.onContinue}:{},testID:"si_processing_success_content"}):null,e.state.kind==="failed"?n(T,{theme:t,...e.state.errorMessage!==void 0?{errorMessage:e.state.errorMessage}:{},...e.onRetry&&!i?{onRetry:e.onRetry}:{},...e.onExit&&!s?{onExit:e.onExit}:{},testID:"si_processing_failed_content"}):null,e.state.kind==="success"&&c&&e.onContinue?c({onClick:e.onContinue}):null,e.state.kind==="failed"&&(i||s)?r(h,{style:[o.actionStack,{gap:t.spacing.small}],children:[i&&e.onRetry?i({onClick:e.onRetry}):null,s&&e.onExit?s({onClick:e.onExit}):null]}):null]}),I?n(R,{theme:t,testID:w}):null]})}const o=U.create({root:{flex:1,overflow:"hidden"},noOvalRegion:{flex:1,alignItems:"center",justifyContent:"center"},card:{alignItems:"center"},actionStack:{alignSelf:"stretch"}});
1
+ "use strict";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useState as y}from"react";import{StyleSheet as U,View as h}from"react-native";import{SafeAreaView as k}from"react-native-safe-area-context";import{useUseSmileIDTheme as x}from"../theme/theme_context";import{defaultFrameAspectRatio as v}from"../../core/models/document_type";import{ATTRIBUTION_TEST_ID as w,UseSmileIDAttribution as R}from"../components/use_smile_id_attribution";import{UseSmileIDCapturedDocumentImage as b}from"../components/use_smile_id_captured_document_image";import{UseSmileIDCapturedImageOval as A}from"../components/use_smile_id_captured_image_oval";import{UseSmileIDCardSurface as E}from"../components/use_smile_id_card_surface";import{UseSmileIDFailedContent as F}from"../components/use_smile_id_failed_content";import{UseSmileIDLoadingContent as T}from"../components/use_smile_id_loading_content";import{UseSmileIDStatusIndicator as m}from"../components/use_smile_id_status_indicator";import{UseSmileIDSuccessContent as L}from"../components/use_smile_id_success_content";import{useUseSmileIDLocalizations as B}from"../../l10n/use_smile_id_localizations_provider";function l(e){switch(e){case"loading":return"loading";case"success":return"success";case"failed":return"failure"}}export function UseSmileIDProcessingScreen(e){const f=x(),t=e.theme??f,a=B(),I=e.showAttribution??!0,_=e.showFaceOval??!0,[u,S]=y({width:0,height:0}),D=g=>{S({width:g.nativeEvent.layout.width,height:g.nativeEvent.layout.height})},C=typeof e.capturedSelfiePath=="string"&&e.capturedSelfiePath.length>0,d=typeof e.documentImageUri=="string"&&e.documentImageUri.length>0,c=e.continueButton,i=e.retryButton,o=e.exitButton;return r(k,{style:[s.root,{backgroundColor:t.colors.background}],testID:"si_processing_screen",onLayout:D,children:[d?n(b,{aspectRatio:e.documentAspectRatio??v("Landscape"),...e.documentImageUri?{uri:e.documentImageUri}:{},...e.documentBorderFraction!==void 0?{borderFraction:e.documentBorderFraction}:{},imageTestID:"si_processing_document_image",imageAccessibilityLabel:a.siCdCapturedImage,overlayChild:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"}),theme:t}):_?n(A,{screenWidth:u.width,screenHeight:u.height,...C&&e.capturedSelfiePath?{uri:e.capturedSelfiePath}:{},imageTestID:"si_processing_image",imageAccessibilityLabel:a.siCdCapturedImage,overlayChild:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"}),theme:t}):n(h,{style:s.noOvalRegion,testID:"si_processing_no_oval_region",children:n(m,{state:l(e.state.kind),theme:t,testID:"si_processing_center_indicator"})}),r(E,{theme:t,style:s.card,children:[e.state.kind==="loading"?n(T,{theme:t,testID:"si_processing_loading_content"}):null,e.state.kind==="success"?n(L,{theme:t,...d?{title:a.siDocumentProcessingComplete}:{},...e.state.message!==void 0?{message:e.state.message}:{},...e.onContinue&&!c?{onContinue:e.onContinue}:{},testID:"si_processing_success_content"}):null,e.state.kind==="failed"?n(F,{theme:t,...e.state.errorMessage!==void 0?{errorMessage:e.state.errorMessage}:{},...e.onRetry&&!i?{onRetry:e.onRetry}:{},...e.onExit&&!o?{onExit:e.onExit}:{},testID:"si_processing_failed_content"}):null,e.state.kind==="success"&&c&&e.onContinue?c({onClick:e.onContinue}):null,e.state.kind==="failed"&&(i||o)?r(h,{style:[s.actionStack,{gap:t.spacing.small}],children:[i&&e.onRetry?i({onClick:e.onRetry}):null,o&&e.onExit?o({onClick:e.onExit}):null]}):null]}),I?n(R,{theme:t,testID:w}):null]})}const s=U.create({root:{flex:1,overflow:"hidden"},noOvalRegion:{flex:1,alignItems:"center",justifyContent:"center"},card:{alignItems:"center"},actionStack:{alignSelf:"stretch"}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smileid/usesmileid",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "Official Smile ID React Native (Expo) SDK for identity verification: selfie capture, liveness checks, and document verification powered by on-device ML.",
5
5
  "homepage": "https://usesmileid.com",
6
6
  "repository": {
@@ -48,11 +48,11 @@
48
48
  "CHANGELOG.md"
49
49
  ],
50
50
  "dependencies": {
51
- "@smileid/kamera": "^1.0.5",
51
+ "@smileid/kamera": "1.1.0",
52
52
  "axios": "^1.20.0",
53
- "zod": "^4.5.4",
54
- "@smileid/usesmileid_bridge": "12.1.0",
55
- "@smileid/usesmileid_platform_interface": "12.1.0"
53
+ "zod": "^4.6.5",
54
+ "@smileid/usesmileid_bridge": "12.2.0",
55
+ "@smileid/usesmileid_platform_interface": "12.2.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@react-native-async-storage/async-storage": ">=1.21.0",
@@ -105,17 +105,17 @@
105
105
  }
106
106
  },
107
107
  "devDependencies": {
108
- "@smileid/kamera-testing": "1.0.5",
108
+ "@smileid/kamera-testing": "1.1.0",
109
109
  "@types/react": "^19.2.18",
110
- "expo": "~57.0.20",
111
- "expo-brightness": "~57.0.1",
112
- "expo-file-system": "~57.0.6",
113
- "expo-font": "~57.0.3",
114
- "expo-haptics": "~57.0.2",
115
- "expo-image-manipulator": "~57.0.16",
116
- "expo-image-picker": "~57.0.16",
117
- "expo-keep-awake": "~57.0.1",
118
- "expo-modules-core": "^57.0.16",
110
+ "expo": "~57.0.25",
111
+ "expo-brightness": "~57.0.2",
112
+ "expo-file-system": "~57.0.7",
113
+ "expo-font": "~57.0.4",
114
+ "expo-haptics": "~57.0.3",
115
+ "expo-image-manipulator": "~57.0.20",
116
+ "expo-image-picker": "~57.0.20",
117
+ "expo-keep-awake": "~57.0.2",
118
+ "expo-modules-core": "^57.0.19",
119
119
  "expo-screen-orientation": "~57.0.2",
120
120
  "jpeg-js": "^0.4.4",
121
121
  "lottie-react-native": "~7.5.0",