@incodetech/core 2.1.0-rc.2 → 2.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3dAvatarProvider-ChciZmjE.esm.js +28214 -0
- package/dist/{BrowserStorageProvider-D5xc7Lqo.esm.js → BrowserStorageProvider-CrrN540a.esm.js} +1 -25
- package/dist/BrowserVisibilityObserverProvider-rim9Jrz-.esm.js +25 -0
- package/dist/Face2DProvider-BeLlYBbB.esm.js +824 -0
- package/dist/FaceDetectionProvider-B78455D4.d.ts +119 -0
- package/dist/IVisibilityObserverCapability-BbWjgpiF.d.ts +12 -0
- package/dist/IWasmUtilCapability-d2XvzaCk.d.ts +145 -0
- package/dist/IpifyProvider-BRW14_uo.esm.js +51 -0
- package/dist/{Manager-B2OEDYqf.d.ts → Manager-CJ3G2zqi.d.ts} +1 -4
- package/dist/{OpenViduRecordingProvider-DF7A4ZNJ.esm.js → OpenViduRecordingProvider-B_0GKkzc.esm.js} +1 -1
- package/dist/PrivacyLensProvider-hDzaDzZ6.esm.js +339 -0
- package/dist/StateMachine-C_AY4cs7.d.ts +2 -0
- package/dist/{StreamCanvasCapture-Dr5n_iK1.esm.js → StreamCanvasCapture-Bz17q4FP.esm.js} +1 -1
- package/dist/StreamCanvasCapture-DS1TOoiH.d.ts +42 -0
- package/dist/{WasmUtilProvider-CIu373BZ.esm.js → WasmUtilProvider-ADG54T6M.esm.js} +16 -1
- package/dist/{addressSearch-BH96a3fq.esm.js → addressSearch-DJyNTg5S.esm.js} +4 -4
- package/dist/{ae-signature-CDEN8y-w.esm.js → ae-signature-DlElqFrZ.esm.js} +1 -1
- package/dist/ae-signature.d.ts +4 -3
- package/dist/ae-signature.esm.js +10 -9
- package/dist/antifraud.d.ts +4 -3
- package/dist/antifraud.esm.js +7 -6
- package/dist/{antifraudManager-DZifA5zX.esm.js → antifraudManager-BKdQoMFf.esm.js} +4 -3
- package/dist/{antifraudManager-B7WQTIdu.d.ts → antifraudManager-DpIvbrZP.d.ts} +2 -2
- package/dist/{antifraudStateMachine-DlKrK2hL.esm.js → antifraudStateMachine-C0NGnP9W.esm.js} +3 -3
- package/dist/{api-DUZwyz0o.esm.js → api-DsbUi7TO.esm.js} +21 -2
- package/dist/authentication.d.ts +19 -12
- package/dist/authentication.esm.js +33 -27
- package/dist/{authenticationManager-Dve7mGLe.d.ts → authenticationManager-CdPbNS2H.d.ts} +3 -3
- package/dist/{authenticationManager-BM4LzyV7.esm.js → authenticationManager-Dtl1vcET.esm.js} +6 -6
- package/dist/{authenticationStateMachine-Chx3ySdT.esm.js → authenticationStateMachine-D-hOlg8p.esm.js} +8 -8
- package/dist/avatar.d.ts +3 -0
- package/dist/avatar.esm.js +3 -0
- package/dist/{backCameraStream-iftkf3rd.esm.js → backCameraStream-ZyqrFyjO.esm.js} +3 -3
- package/dist/{browser-DlFgHpoC-7tbRR1aR.esm.js → browser-DlFgHpoC-qLKs75Qp.esm.js} +1 -1
- package/dist/{browserSimulation-CGjpdNA1.esm.js → browserSimulation-TsSoavQv.esm.js} +153 -1216
- package/dist/camera-DUkgmYMo.esm.js +79 -0
- package/dist/camera.d.ts +7 -1
- package/dist/camera.esm.js +4 -4
- package/dist/{StreamCanvasCapture-Ctgyx-oD.d.ts → canvas-CJUmoXSD.d.ts} +1 -41
- package/dist/certificate-issuance.d.ts +31 -30
- package/dist/certificate-issuance.esm.js +8 -7
- package/dist/{certificateIssuanceStateMachine-CLNXtXaC.esm.js → certificateIssuanceStateMachine-C07m7qtP.esm.js} +4 -4
- package/dist/clientLifecycle-Ct7h9uxx.esm.js +534 -0
- package/dist/consent.d.ts +4 -3
- package/dist/consent.esm.js +7 -6
- package/dist/{consentManager-psDCeJ0E.esm.js → consentManager-BtnPZUW4.esm.js} +4 -3
- package/dist/{consentManager-BqUGU_YD.d.ts → consentManager-DufVo9D9.d.ts} +52 -52
- package/dist/{consentStateMachine-DRsFFSHE.esm.js → consentStateMachine-DO2JqoZW.esm.js} +3 -3
- package/dist/cpf-ocr.d.ts +4 -3
- package/dist/cpf-ocr.esm.js +7 -6
- package/dist/{cpfOcrManager-BxcgxvgO.esm.js → cpfOcrManager-C4rLgKsu.esm.js} +6 -5
- package/dist/{cpfOcrManager-B2u9hMzd.d.ts → cpfOcrManager-DqZZ94Gt.d.ts} +19 -19
- package/dist/createFaceAvatar-B8pFpy6o.d.ts +401 -0
- package/dist/createFaceAvatar-BOHDKQRq.esm.js +46 -0
- package/dist/cross-document-data-match.d.ts +2 -1
- package/dist/cross-document-data-match.esm.js +6 -5
- package/dist/curp-validation.d.ts +10 -7
- package/dist/curp-validation.esm.js +7 -6
- package/dist/{curpValidationManager-BgLDw0Ub.esm.js → curpValidationManager-BafobPXC.esm.js} +4 -3
- package/dist/{curpValidationManager-Bt6CVD8b.d.ts → curpValidationManager-Co6LZAHT.d.ts} +3 -3
- package/dist/{curpValidationStateMachine-BK_wJ48C.esm.js → curpValidationStateMachine-DXTPK6vI.esm.js} +3 -3
- package/dist/custom-fields.d.ts +3 -2
- package/dist/custom-fields.esm.js +6 -5
- package/dist/custom-watchlist.d.ts +2 -1
- package/dist/custom-watchlist.esm.js +6 -5
- package/dist/{customWatchlistStateMachine-Bi4P59HM.esm.js → customWatchlistStateMachine-B4G3Chkx.esm.js} +3 -3
- package/dist/{deepsightLoader-BMmvk0X6.esm.js → deepsightLoader-DHSVD776.esm.js} +14 -13
- package/dist/{deepsightService-CEZrdiW0.esm.js → deepsightService-CDahSjGP.esm.js} +9 -38
- package/dist/deepsightService-CMB9XjES.d.ts +69 -0
- package/dist/device.d.ts +9 -1
- package/dist/device.esm.js +5 -5
- package/dist/document-capture.d.ts +175 -174
- package/dist/document-capture.esm.js +14 -13
- package/dist/document-upload.d.ts +48 -47
- package/dist/document-upload.esm.js +9 -8
- package/dist/{documentCaptureStateMachine-MpwpJO7t.esm.js → documentCaptureStateMachine-DSOX2epf.esm.js} +7 -7
- package/dist/dynamic-forms.d.ts +4 -192
- package/dist/dynamic-forms.esm.js +8 -160
- package/dist/dynamicFormsManager-BOefZbyF.esm.js +168 -0
- package/dist/dynamicFormsManager-CUYLOj9g.d.ts +239 -0
- package/dist/{dynamicFormsStateMachine-Do84A4uU.esm.js → dynamicFormsStateMachine-BXHcaocI.esm.js} +4 -4
- package/dist/ekyb.d.ts +9 -6
- package/dist/ekyb.esm.js +20 -17
- package/dist/{ekybStateMachine-nsuPOw3f.esm.js → ekybStateMachine-CCSeqjCt.esm.js} +5 -5
- package/dist/ekyc.d.ts +4 -3
- package/dist/ekyc.esm.js +9 -8
- package/dist/{ekycStateMachine-DcynX0rj.esm.js → ekycStateMachine-DkLVTOyA.esm.js} +5 -5
- package/dist/electronic-signature.d.ts +4 -3
- package/dist/electronic-signature.esm.js +9 -8
- package/dist/{electronicSignatureManager-B63aAuI5.esm.js → electronicSignatureManager-DjzUzqZj.esm.js} +50 -87
- package/dist/email.d.ts +5 -4
- package/dist/email.esm.js +9 -8
- package/dist/{emailManager-DxHjAe5u.esm.js → emailManager-B_XzEsXH.esm.js} +5 -4
- package/dist/{emailManager-C6D2u4mQ.d.ts → emailManager-fHASH6uo.d.ts} +3 -3
- package/dist/{emailStateMachine-758f34gg.esm.js → emailStateMachine-fqJ42b19.esm.js} +5 -5
- package/dist/{endpoints-BM2_j_IE.esm.js → endpoints-BzMJFAPV.esm.js} +13 -0
- package/dist/{events-DN-u67gb.esm.js → events-CqGY1yMq.esm.js} +2 -188
- package/dist/events.d.ts +2 -0
- package/dist/events.esm.js +3 -2
- package/dist/extensibility.d.ts +37 -26
- package/dist/extensibility.esm.js +74 -59
- package/dist/{externalFetch-crimxkN9.esm.js → externalFetch-CyhBfD-n.esm.js} +1 -1
- package/dist/face-match.d.ts +2 -2
- package/dist/face-match.esm.js +6 -5
- package/dist/{faceCaptureManagerFactory-BNXZchWX.esm.js → faceCaptureManagerFactory-2brKTzMb.esm.js} +25 -16
- package/dist/faceCaptureManagerFactory-CGKbf7zt.d.ts +400 -0
- package/dist/{faceCaptureSetup-Dqb09D24.esm.js → faceCaptureSetup-CDUVU1nl.esm.js} +97 -13
- package/dist/{faceMatchStateMachine-FikRaUZH.esm.js → faceMatchStateMachine-DUeUjEPx.esm.js} +3 -3
- package/dist/field-comparison.d.ts +4 -3
- package/dist/field-comparison.esm.js +6 -5
- package/dist/{fieldComparisonManager-Dic0DVgl.esm.js → fieldComparisonManager-B9W0a9A5.esm.js} +5 -4
- package/dist/{fieldComparisonManager-BXc6-DJv.d.ts → fieldComparisonManager-DdLqDeB2.d.ts} +2 -2
- package/dist/fiscal-qr.d.ts +5 -3
- package/dist/fiscal-qr.esm.js +13 -12
- package/dist/flow-events.d.ts +8 -6
- package/dist/flow.d.ts +21 -13
- package/dist/flow.esm.js +28 -19
- package/dist/{flowCompletionService-CdGDKv0z.d.ts → flowCompletionService-BIqSTZcd.d.ts} +2 -1
- package/dist/{flowCompletionService-D_CsiDZM.esm.js → flowCompletionService-qEqh_g14.esm.js} +3 -3
- package/dist/{flowServices-ar5DXv71.esm.js → flowServices-C4piblgx.esm.js} +24 -9
- package/dist/geolocation.d.ts +4 -127
- package/dist/geolocation.esm.js +8 -115
- package/dist/geolocationManager-BP2Do9O-.esm.js +123 -0
- package/dist/geolocationManager-Cs50eRlC.d.ts +156 -0
- package/dist/{geolocationStateMachine-BWjrMGS_.esm.js → geolocationStateMachine-BYfOOOG0.esm.js} +4 -4
- package/dist/{getDeviceClass-rXKlXywy.esm.js → getDeviceClass-DGGzzfqm.esm.js} +1 -1
- package/dist/getDeviceData-TrKM8NPh.esm.js +101 -0
- package/dist/government-validation.d.ts +4 -3
- package/dist/government-validation.esm.js +8 -7
- package/dist/{governmentValidationStateMachine-BoF7U1of.esm.js → governmentValidationStateMachine-CwoPPO8b.esm.js} +5 -5
- package/dist/home.d.ts +18 -15
- package/dist/home.esm.js +4 -3
- package/dist/http.esm.js +2 -2
- package/dist/id-ocr.d.ts +4 -625
- package/dist/id-ocr.esm.js +8 -84
- package/dist/id-verification.d.ts +28 -27
- package/dist/id-verification.esm.js +6 -5
- package/dist/id.d.ts +16 -11
- package/dist/id.esm.js +39 -32
- package/dist/idCaptureDefaults-DNJON8Xo.esm.js +188 -0
- package/dist/{idCaptureManager-BvGUSN2e.d.ts → idCaptureManager-BVdvfJys.d.ts} +40 -10
- package/dist/{idCaptureManager-Bm6Wm6Qv.esm.js → idCaptureManager-Bo9DCQSU.esm.js} +14 -11
- package/dist/{idCaptureStateMachine-D1YhOj6n.esm.js → idCaptureStateMachine-BeDidMLU.esm.js} +395 -382
- package/dist/idOcrManager-BkRDrpZu.esm.js +92 -0
- package/dist/idOcrManager-CJzrmM91.d.ts +641 -0
- package/dist/{idOcrStateMachine-YMCDGplq.esm.js → idOcrStateMachine-DRZc4FBl.esm.js} +5 -5
- package/dist/{idVerificationStateMachine-Bo1IYuZH.esm.js → idVerificationStateMachine-oqiERKpg.esm.js} +3 -3
- package/dist/identity-reuse.d.ts +4 -3
- package/dist/identity-reuse.esm.js +7 -6
- package/dist/{identityReuseManager-D0knIrOy.esm.js → identityReuseManager-Bu62LToE.esm.js} +4 -3
- package/dist/{identityReuseManager-DcWSvC-A.d.ts → identityReuseManager-TWKbXuvY.d.ts} +33 -33
- package/dist/{identityReuseStateMachine-CSQfZOqD.esm.js → identityReuseStateMachine-BmONeF6B.esm.js} +3 -3
- package/dist/{index-BgxYUYuD.d.ts → index-DtUlD-bz.d.ts} +2 -2
- package/dist/{index-DV134v62.d.ts → index-Icld-cKW.d.ts} +175 -295
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +16 -13
- package/dist/{invokeOnCaptureCallback-Dzemudhk.esm.js → invokeOnCaptureCallback-v_PV_IJz.esm.js} +1 -1
- package/dist/{lib-7ZQ9BdKH.esm.js → lib-B050WTth.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +10 -7
- package/dist/mandatory-consent.esm.js +7 -6
- package/dist/{mandatoryConsentManager-Tzl5Qd35.d.ts → mandatoryConsentManager-Bmdjo14S.d.ts} +50 -50
- package/dist/{mandatoryConsentManager-Lon46nPQ.esm.js → mandatoryConsentManager-CQ3jirlZ.esm.js} +4 -3
- package/dist/{mandatoryConsentStateMachine-D_dZ7IF6.esm.js → mandatoryConsentStateMachine-DkJJLHqC.esm.js} +3 -3
- package/dist/mediaRecorderOptions-C3NAkVgK.esm.js +42 -0
- package/dist/mediapipeShared-CRAKVElv.esm.js +67 -0
- package/dist/{recordingService-CxMJP4tQ.esm.js → onDeviceFaceResults-DVBggeq8.esm.js} +71 -389
- package/dist/{openviduLazy-oAXXI9w_.esm.js → openviduLazy-BTOIauGP.esm.js} +2 -2
- package/dist/openviduLazy-Dov8oKfL.esm.js +3 -0
- package/dist/{permissionGuards-D-Z-lgNj.esm.js → permissionGuards-BR2oN573.esm.js} +1 -1
- package/dist/{permissionServices-CPDboRoE.esm.js → permissionServices-BJhGL13R.esm.js} +7 -4
- package/dist/personhood.d.ts +534 -0
- package/dist/personhood.esm.js +1494 -0
- package/dist/phone.d.ts +5 -4
- package/dist/phone.esm.js +9 -8
- package/dist/{phoneManager-TSq1Ief6.d.ts → phoneManager-BOTcjXgs.d.ts} +3 -3
- package/dist/{phoneManager-Blt4Oc2P.esm.js → phoneManager-BWlxqbyD.esm.js} +5 -4
- package/dist/{phoneStateMachine-W3c6Z8sj.esm.js → phoneStateMachine-B_V9nODs.esm.js} +5 -5
- package/dist/{qe-signature-CQLK6LKE.esm.js → qe-signature-BhFnI9pT.esm.js} +1 -1
- package/dist/qe-signature.d.ts +4 -3
- package/dist/qe-signature.esm.js +10 -9
- package/dist/recordingService-m_1xCthr.esm.js +347 -0
- package/dist/redirect-to-mobile.d.ts +4 -3
- package/dist/redirect-to-mobile.esm.js +9 -8
- package/dist/{redirectToMobileManager-DCvpKdkD.esm.js → redirectToMobileManager-BaAo9rgi.esm.js} +5 -4
- package/dist/{redirectToMobileManager-yOHAmwg-.d.ts → redirectToMobileManager-Br0KZK1G.d.ts} +2 -2
- package/dist/{redirectToMobileStateMachine-DC9z4Vfu.esm.js → redirectToMobileStateMachine-DoAnf2ql.esm.js} +10 -12
- package/dist/{runChildModule-C9G0wfVC.esm.js → runChildModule-0nQfjVVo.esm.js} +3 -3
- package/dist/selfie.d.ts +19 -12
- package/dist/selfie.esm.js +34 -28
- package/dist/{selfieManager-BRL6c_Oc.esm.js → selfieManager-D_ZFERsE.esm.js} +6 -6
- package/dist/{selfieManager-imY2dAcH.d.ts → selfieManager-R0Jw5sjb.d.ts} +3 -3
- package/dist/{selfieStateMachine-D2Q0uwDK.esm.js → selfieStateMachine-CIgeeiN9.esm.js} +4 -4
- package/dist/{session-Be_IA1e0.esm.js → session-9jIfKFCc.esm.js} +3 -3
- package/dist/session.d.ts +7 -5
- package/dist/session.esm.js +16 -14
- package/dist/{sessionInitializer-CaiGA8GP.esm.js → sessionInitializer-C_TYIgyk.esm.js} +11 -107
- package/dist/{setup-BJZAkajt.d.ts → setup-CpRnXxn8.d.ts} +16 -3
- package/dist/setup-DHc6OaHm.esm.js +562 -0
- package/dist/signature.d.ts +3 -2
- package/dist/signature.esm.js +6 -5
- package/dist/{signatureStateMachine-DAxXmMrk.esm.js → signatureStateMachine-DtoiPzys.esm.js} +3 -3
- package/dist/{stats-DntyIiGr.esm.js → stats-CYcScXcO.esm.js} +2 -2
- package/dist/stats.esm.js +3 -3
- package/dist/thumbmarkAdapter-fHBUDlAP.esm.js +1194 -0
- package/dist/{tri-CtxWthxz.esm.js → tri-BG1iJsr4.esm.js} +12 -2
- package/dist/tri.d.ts +1 -1
- package/dist/{tri.esm-CrWAulDi.esm.js → tri.esm-DUC01NgO.esm.js} +27 -23
- package/dist/tri.esm.js +2 -2
- package/dist/trust-graph.d.ts +4 -3
- package/dist/trust-graph.esm.js +4 -3
- package/dist/{types-DpTWgfKY.d.ts → types-BklZ_Wne.d.ts} +1 -1
- package/dist/{types-Dv-9WPJX.d.ts → types-BsYXnC5s.d.ts} +39 -3
- package/dist/types-CxW2e0Ar.d.ts +132 -0
- package/dist/{types-Z9wv19v2.d.ts → types-DgGlgyZT.d.ts} +1 -1
- package/dist/types-ElOJAGaM.esm.js +189 -0
- package/dist/video-C2WIj6TS.esm.js +36 -0
- package/dist/video-selfie.d.ts +351 -0
- package/dist/video-selfie.esm.js +1509 -0
- package/dist/videoSelfieSteps-7M5vxKn-.esm.js +58 -0
- package/dist/{warmup--6HA3yUR.d.ts → warmup-BJZPQIiX.d.ts} +5 -1
- package/dist/wasm.d.ts +4 -4
- package/dist/wasm.esm.js +17 -14
- package/dist/watchlist-for-business.d.ts +2 -1
- package/dist/watchlist-for-business.esm.js +6 -5
- package/dist/watchlist.d.ts +2 -1
- package/dist/watchlist.esm.js +6 -5
- package/dist/{watchlistForBusinessStateMachine-DtefJb-D.esm.js → watchlistForBusinessStateMachine-DvEunDxs.esm.js} +3 -3
- package/dist/{watchlistStateMachine-B0aIS2_n.esm.js → watchlistStateMachine-AHXVf-TB.esm.js} +3 -3
- package/dist/workflow.d.ts +230 -98
- package/dist/workflow.esm.js +123 -79
- package/dist/{xstate.esm-Dkm1jy5u.esm.js → xstate.esm-Bomq1a0z.esm.js} +41 -1
- package/package.json +16 -1
- package/dist/IpifyProvider-oZf7Ke1O.esm.js +0 -167
- package/dist/camera-x4LjGTjZ.esm.js +0 -22
- package/dist/deepsightService-ByNKY5Jv.d.ts +0 -276
- package/dist/faceCaptureManagerFactory-CL-7T_vH.d.ts +0 -731
- package/dist/getBrowser-Dv8LZyHE.esm.js +0 -8
- package/dist/openviduLazy-B_s6jnEk.esm.js +0 -3
- package/dist/setup-C7tintPc.esm.js +0 -1064
- /package/dist/{Actor-fIPLXfoi.d.ts → Actor-CGEelYtQ.d.ts} +0 -0
- /package/dist/{BrowserTimerProvider-BVgutW_b.esm.js → BrowserTimerProvider-CHloo0eQ.esm.js} +0 -0
- /package/dist/{ITimerCapability-BvH0pDwp.esm.js → ITimerCapability-pltuG1E8.esm.js} +0 -0
- /package/dist/{MotionSensorProvider-C9fPAJdS.esm.js → MotionSensorProvider-DCbId4De.esm.js} +0 -0
- /package/dist/{apiError-D-GTvFrH.esm.js → apiError-DNS2OCEX.esm.js} +0 -0
- /package/dist/{camera-biGPWlmx.d.ts → camera-CNVUo-bC.d.ts} +0 -0
- /package/dist/{canvas-7uX2izHb.esm.js → canvas-_I95hkPg.esm.js} +0 -0
- /package/dist/{chunk-BK1xu56N.esm.js → chunk-CIKcdghV.esm.js} +0 -0
- /package/dist/{cpf-xBg-DFNn.esm.js → cpf-BKaho0j_.esm.js} +0 -0
- /package/dist/{dateUtils-8dCcuArE.esm.js → dateUtils-7-tQYRNN.esm.js} +0 -0
- /package/dist/{getDeviceClass-C0zrM97a.esm.js → getDeviceClass-DavNdcxh.esm.js} +0 -0
- /package/dist/{http-CfVTgMfU.esm.js → http-BkiUT7EB.esm.js} +0 -0
- /package/dist/{index-52_qi4bd.d.ts → index-XTtxaahe.d.ts} +0 -0
- /package/dist/{otp-D87RTwrx.esm.js → otp-Bfnzf7I3.esm.js} +0 -0
- /package/dist/{otp-BHJnjEEc.d.ts → otp-M4iy57XY.d.ts} +0 -0
- /package/dist/{platform-BfoqeM61.esm.js → platform-uIVQUnJP.esm.js} +0 -0
- /package/dist/{types-BdVOWGGW.esm.js → types-CMcxlSmH.esm.js} +0 -0
- /package/dist/{types-DYZja-k9.d.ts → types-D_IceWxT.d.ts} +0 -0
- /package/dist/{types-F0IXbaCB.d.ts → types-Duy2rDxF.d.ts} +0 -0
- /package/dist/{urlUtils-8RNHyW3x.esm.js → urlUtils-BZqFU9rR.esm.js} +0 -0
|
@@ -1,1064 +0,0 @@
|
|
|
1
|
-
import { a as WasmWebClientError, c as setWebApiHttpTransport, f as deriveSiblingJsPath, l as setupWasmConnection, o as executeWasmRequest, r as warmupWasm, s as initializeWasmWebClient, t as WasmUtilProvider } from "./WasmUtilProvider-CIu373BZ.esm.js";
|
|
2
|
-
import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BVgutW_b.esm.js";
|
|
3
|
-
import { a as resetApi, i as isApiConfigured, n as getApi, o as setClient, r as getToken, t as api } from "./api-DUZwyz0o.esm.js";
|
|
4
|
-
import { _ as getAnalyticsBatcher, h as createAnalyticsBatchingService, v as resetAnalyticsBatcher, y as setAnalyticsBatcher } from "./events-DN-u67gb.esm.js";
|
|
5
|
-
import { t as endpoints } from "./endpoints-BM2_j_IE.esm.js";
|
|
6
|
-
import { r as resetDeviceStatsQueue, t as addDeviceStats } from "./stats-DntyIiGr.esm.js";
|
|
7
|
-
import { a as setClientIpLookupEnabled, i as resetSessionInit, r as initializeSession } from "./sessionInitializer-CaiGA8GP.esm.js";
|
|
8
|
-
import { a as resetTRI, n as initializeTRI, o as resetTRIProviderInstance } from "./tri-CtxWthxz.esm.js";
|
|
9
|
-
|
|
10
|
-
//#region ../infra/src/wasm/wasmDefaults.ts
|
|
11
|
-
const WASM_CDN_BASE_URL = "https://cdn.incodesmile.com/ml-wasm-kit-release";
|
|
12
|
-
/** The WASM version bundled and tested with this SDK release. */
|
|
13
|
-
const DEFAULT_WASM_VERSION = "v2.14.07-post7";
|
|
14
|
-
const PATH_KEYS = [
|
|
15
|
-
"wasmPath",
|
|
16
|
-
"wasmSimdPath",
|
|
17
|
-
"glueCodePath",
|
|
18
|
-
"glueCodeSimdPath",
|
|
19
|
-
"modelsBasePath"
|
|
20
|
-
];
|
|
21
|
-
function isBlank(value) {
|
|
22
|
-
return value.trim() === "";
|
|
23
|
-
}
|
|
24
|
-
function hasDisallowedControlChars(value) {
|
|
25
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
26
|
-
const code = value.charCodeAt(i);
|
|
27
|
-
if (code < 32 || code === 127) return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
function isMalformedPath(value) {
|
|
32
|
-
const trimmed = value.trim();
|
|
33
|
-
if (trimmed === "") return false;
|
|
34
|
-
if (hasDisallowedControlChars(trimmed)) return true;
|
|
35
|
-
if (/^https?:\/\//i.test(trimmed)) try {
|
|
36
|
-
new URL(trimmed);
|
|
37
|
-
return false;
|
|
38
|
-
} catch {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
function warnInvalidWasmPath(field, reason) {
|
|
44
|
-
if (reason === "empty") {
|
|
45
|
-
console.warn(`[Incode SDK] wasm.${field} is empty. Falling back to CDN default.`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
console.warn(`[Incode SDK] wasm.${field} appears malformed. Falling back to CDN default.`);
|
|
49
|
-
}
|
|
50
|
-
function warnMalformedWasmPath(field) {
|
|
51
|
-
console.warn(`[Incode SDK] wasm.${field} appears malformed. Check the URL or path.`);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Validates merged WASM path strings. When overrides contained blank path
|
|
55
|
-
* values, callers should have already fallen back to defaults before this runs.
|
|
56
|
-
*/
|
|
57
|
-
function validateWasmPaths(config) {
|
|
58
|
-
for (const key of PATH_KEYS) {
|
|
59
|
-
const value = config[key];
|
|
60
|
-
if (typeof value === "string" && isMalformedPath(value)) warnMalformedWasmPath(key);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function pickPath(key, overrides, defaultValue) {
|
|
64
|
-
if (!overrides || !(key in overrides)) return defaultValue;
|
|
65
|
-
const raw = overrides[key];
|
|
66
|
-
if (raw === void 0) return defaultValue;
|
|
67
|
-
if (typeof raw !== "string") return defaultValue;
|
|
68
|
-
if (isBlank(raw)) {
|
|
69
|
-
warnInvalidWasmPath(key, "empty");
|
|
70
|
-
return defaultValue;
|
|
71
|
-
}
|
|
72
|
-
if (isMalformedPath(raw)) {
|
|
73
|
-
warnInvalidWasmPath(key, "malformed");
|
|
74
|
-
return defaultValue;
|
|
75
|
-
}
|
|
76
|
-
return raw.trim();
|
|
77
|
-
}
|
|
78
|
-
/** Builds a WarmupConfig from a directory that mirrors the ml-wasm-kit CDN layout. */
|
|
79
|
-
function buildWasmConfigFromBasePath(basePath) {
|
|
80
|
-
const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
|
|
81
|
-
return {
|
|
82
|
-
wasmPath: `${base}/webLib.wasm`,
|
|
83
|
-
wasmSimdPath: `${base}/webLibSimd.wasm`,
|
|
84
|
-
glueCodePath: `${base}/webLib.js`,
|
|
85
|
-
glueCodeSimdPath: `${base}/webLibSimd.js`,
|
|
86
|
-
modelsBasePath: `${base}/models`
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/** Builds the standard WarmupConfig from the Incode CDN. */
|
|
90
|
-
function buildDefaultWasmConfig() {
|
|
91
|
-
return buildWasmConfigFromBasePath(`${WASM_CDN_BASE_URL}/${DEFAULT_WASM_VERSION}`);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Merges optional WASM path overrides with CDN defaults. Explicit non-blank
|
|
95
|
-
* paths take precedence. Blank override strings log a warning and fall back to defaults.
|
|
96
|
-
*/
|
|
97
|
-
function resolveWasmConfig(overrides) {
|
|
98
|
-
if (!overrides) return buildDefaultWasmConfig();
|
|
99
|
-
const defaults = buildWasmConfigFromBasePath(pickPath("basePath", overrides, `${WASM_CDN_BASE_URL}/${DEFAULT_WASM_VERSION}`));
|
|
100
|
-
const simdDefault = defaults.wasmSimdPath ?? defaults.wasmPath;
|
|
101
|
-
const modelsDefault = defaults.modelsBasePath ?? (() => {
|
|
102
|
-
const lastSlash = defaults.wasmPath.lastIndexOf("/");
|
|
103
|
-
return lastSlash === -1 ? "models" : `${defaults.wasmPath.substring(0, lastSlash)}/models`;
|
|
104
|
-
})();
|
|
105
|
-
const resolvedWasmSimdPath = pickPath("wasmSimdPath", overrides, simdDefault);
|
|
106
|
-
const glueCodeSimdDefault = deriveSiblingJsPath(resolvedWasmSimdPath);
|
|
107
|
-
const merged = {
|
|
108
|
-
wasmPath: pickPath("wasmPath", overrides, defaults.wasmPath),
|
|
109
|
-
wasmSimdPath: resolvedWasmSimdPath,
|
|
110
|
-
glueCodePath: pickPath("glueCodePath", overrides, defaults.glueCodePath),
|
|
111
|
-
glueCodeSimdPath: pickPath("glueCodeSimdPath", overrides, glueCodeSimdDefault),
|
|
112
|
-
modelsBasePath: pickPath("modelsBasePath", overrides, modelsDefault),
|
|
113
|
-
useSimd: overrides.useSimd,
|
|
114
|
-
pipelines: overrides.pipelines,
|
|
115
|
-
pipelineModels: overrides.pipelineModels
|
|
116
|
-
};
|
|
117
|
-
validateWasmPaths(merged);
|
|
118
|
-
return merged;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region ../infra/src/providers/browser/BrowserPageLifecycleProvider.ts
|
|
123
|
-
var BrowserPageLifecycleProvider = class {
|
|
124
|
-
sendBeacon(url, body, contentType = "application/json") {
|
|
125
|
-
if (typeof navigator === "undefined" || typeof navigator.sendBeacon !== "function") return false;
|
|
126
|
-
const blob = new Blob([body], { type: contentType });
|
|
127
|
-
return navigator.sendBeacon(url, blob);
|
|
128
|
-
}
|
|
129
|
-
onPageHide(listener) {
|
|
130
|
-
const onVisibilityChange = () => {
|
|
131
|
-
if (document.visibilityState === "hidden") listener();
|
|
132
|
-
};
|
|
133
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
134
|
-
window.addEventListener("pagehide", listener);
|
|
135
|
-
window.addEventListener("beforeunload", listener);
|
|
136
|
-
return () => {
|
|
137
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
138
|
-
window.removeEventListener("pagehide", listener);
|
|
139
|
-
window.removeEventListener("beforeunload", listener);
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region ../infra/src/http/createApi.ts
|
|
146
|
-
var FetchHttpError = class extends Error {
|
|
147
|
-
constructor(status, statusText, url, method, headers, data) {
|
|
148
|
-
super(`HTTP ${status} ${statusText}`);
|
|
149
|
-
this.ok = false;
|
|
150
|
-
this.status = status;
|
|
151
|
-
this.statusText = statusText;
|
|
152
|
-
this.url = url;
|
|
153
|
-
this.method = method;
|
|
154
|
-
this.headers = headers;
|
|
155
|
-
this.data = data;
|
|
156
|
-
this.name = "FetchHttpError";
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const buildQueryString$1 = (query) => {
|
|
160
|
-
if (!query) return "";
|
|
161
|
-
const params = new URLSearchParams();
|
|
162
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
163
|
-
if (value !== void 0 && value !== null) params.append(key, String(value));
|
|
164
|
-
});
|
|
165
|
-
const str = params.toString();
|
|
166
|
-
return str ? `?${str}` : "";
|
|
167
|
-
};
|
|
168
|
-
const buildUrl$1 = (baseURL, url, query) => {
|
|
169
|
-
const queryString = buildQueryString$1(query);
|
|
170
|
-
if (url.startsWith("http://") || url.startsWith("https://")) return `${url}${queryString}`;
|
|
171
|
-
return `${baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL}${url.startsWith("/") ? url : `/${url}`}${queryString}`;
|
|
172
|
-
};
|
|
173
|
-
const prepareBody$1 = (body) => {
|
|
174
|
-
if (body === null || body === void 0) return null;
|
|
175
|
-
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer) return body;
|
|
176
|
-
if (typeof body === "object") return JSON.stringify(body);
|
|
177
|
-
return String(body);
|
|
178
|
-
};
|
|
179
|
-
const parseResponse = async (response, parseType) => {
|
|
180
|
-
if (parseType === "response") return response;
|
|
181
|
-
if (parseType === "blob") return await response.blob();
|
|
182
|
-
if (parseType === "arrayBuffer") return await response.arrayBuffer();
|
|
183
|
-
if (parseType === "text") return await response.text();
|
|
184
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
185
|
-
if (parseType === "json" || contentType.includes("application/json")) try {
|
|
186
|
-
return await response.json();
|
|
187
|
-
} catch {
|
|
188
|
-
return await response.text();
|
|
189
|
-
}
|
|
190
|
-
return await response.text();
|
|
191
|
-
};
|
|
192
|
-
const DEFAULT_TIMEOUT$1 = 3e4;
|
|
193
|
-
const requestWithXHR = (fullUrl, method, mergedHeaders, requestBody, timeout, signal, onUploadProgress) => {
|
|
194
|
-
return new Promise((resolve, reject) => {
|
|
195
|
-
const xhr = new XMLHttpRequest();
|
|
196
|
-
xhr.open(method, fullUrl, true);
|
|
197
|
-
Object.entries(mergedHeaders).forEach(([key, value]) => {
|
|
198
|
-
xhr.setRequestHeader(key, value);
|
|
199
|
-
});
|
|
200
|
-
xhr.timeout = timeout;
|
|
201
|
-
xhr.upload.onprogress = (event) => {
|
|
202
|
-
if (event.lengthComputable) {
|
|
203
|
-
const percentComplete = event.loaded / event.total * 100;
|
|
204
|
-
onUploadProgress(Math.round(percentComplete));
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
xhr.onload = () => {
|
|
208
|
-
const responseHeaders = {};
|
|
209
|
-
xhr.getAllResponseHeaders().split("\r\n").forEach((line) => {
|
|
210
|
-
const parts = line.split(": ");
|
|
211
|
-
if (parts.length === 2) responseHeaders[parts[0].toLowerCase()] = parts[1];
|
|
212
|
-
});
|
|
213
|
-
let data;
|
|
214
|
-
try {
|
|
215
|
-
if ((xhr.getResponseHeader("content-type") ?? "").includes("application/json")) data = JSON.parse(xhr.responseText);
|
|
216
|
-
else data = xhr.responseText;
|
|
217
|
-
} catch {
|
|
218
|
-
data = xhr.responseText;
|
|
219
|
-
}
|
|
220
|
-
if (xhr.status >= 200 && xhr.status < 300) resolve({
|
|
221
|
-
ok: true,
|
|
222
|
-
status: xhr.status,
|
|
223
|
-
statusText: xhr.statusText,
|
|
224
|
-
url: fullUrl,
|
|
225
|
-
headers: responseHeaders,
|
|
226
|
-
data
|
|
227
|
-
});
|
|
228
|
-
else reject(new FetchHttpError(xhr.status, xhr.statusText, fullUrl, method, responseHeaders, data));
|
|
229
|
-
};
|
|
230
|
-
xhr.onerror = () => {
|
|
231
|
-
reject(new FetchHttpError(0, "Network Error", fullUrl, method, {}, null));
|
|
232
|
-
};
|
|
233
|
-
xhr.ontimeout = () => {
|
|
234
|
-
reject(new FetchHttpError(0, "Request timeout", fullUrl, method, {}, null));
|
|
235
|
-
};
|
|
236
|
-
if (signal) signal.addEventListener("abort", () => {
|
|
237
|
-
xhr.abort();
|
|
238
|
-
reject(new FetchHttpError(0, "Request aborted", fullUrl, method, {}, null));
|
|
239
|
-
});
|
|
240
|
-
xhr.send(requestBody);
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
const createApi = (config) => {
|
|
244
|
-
const headers = {
|
|
245
|
-
"Content-Type": "application/json",
|
|
246
|
-
Accept: "application/json",
|
|
247
|
-
"api-version": "1.0",
|
|
248
|
-
...config.customHeaders ?? {}
|
|
249
|
-
};
|
|
250
|
-
const defaults = {
|
|
251
|
-
baseURL: config.apiURL,
|
|
252
|
-
headers
|
|
253
|
-
};
|
|
254
|
-
const client = {
|
|
255
|
-
defaults,
|
|
256
|
-
async request(requestConfig) {
|
|
257
|
-
const { method = "GET", url, headers: headers$1 = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT$1, parse, onUploadProgress, keepalive } = requestConfig;
|
|
258
|
-
const fullUrl = buildUrl$1(defaults.baseURL, url, params ?? query);
|
|
259
|
-
const mergedHeaders = {
|
|
260
|
-
...defaults.headers,
|
|
261
|
-
...headers$1
|
|
262
|
-
};
|
|
263
|
-
const requestBody = prepareBody$1(body);
|
|
264
|
-
let finalHeaders = mergedHeaders;
|
|
265
|
-
if (requestBody === null && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
266
|
-
const { "Content-Type": _, ...headersWithoutContentType } = mergedHeaders;
|
|
267
|
-
finalHeaders = headersWithoutContentType;
|
|
268
|
-
}
|
|
269
|
-
if (onUploadProgress) {
|
|
270
|
-
if (requestBody !== null && typeof ReadableStream !== "undefined" && requestBody instanceof ReadableStream) throw new Error("Upload progress tracking is not supported for ReadableStream bodies");
|
|
271
|
-
return requestWithXHR(fullUrl, method, finalHeaders, requestBody, timeout, signal, onUploadProgress);
|
|
272
|
-
}
|
|
273
|
-
const controller = new AbortController();
|
|
274
|
-
const abortSignal = signal ?? controller.signal;
|
|
275
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
276
|
-
try {
|
|
277
|
-
const response = await fetch(fullUrl, {
|
|
278
|
-
method,
|
|
279
|
-
headers: finalHeaders,
|
|
280
|
-
body: requestBody,
|
|
281
|
-
signal: abortSignal,
|
|
282
|
-
keepalive
|
|
283
|
-
});
|
|
284
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
285
|
-
const responseHeaders = {};
|
|
286
|
-
response.headers.forEach((value, key) => {
|
|
287
|
-
responseHeaders[key] = value;
|
|
288
|
-
});
|
|
289
|
-
const data = await parseResponse(response, parse);
|
|
290
|
-
if (!response.ok) throw new FetchHttpError(response.status, response.statusText, fullUrl, method, responseHeaders, data);
|
|
291
|
-
return {
|
|
292
|
-
ok: true,
|
|
293
|
-
status: response.status,
|
|
294
|
-
statusText: response.statusText,
|
|
295
|
-
url: fullUrl,
|
|
296
|
-
headers: responseHeaders,
|
|
297
|
-
data
|
|
298
|
-
};
|
|
299
|
-
} catch (error) {
|
|
300
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
301
|
-
if (error instanceof FetchHttpError) throw error;
|
|
302
|
-
if (error instanceof Error && error.name === "AbortError") throw new FetchHttpError(0, "Request timeout", fullUrl, method, {}, null);
|
|
303
|
-
throw error;
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
get(url, config$1) {
|
|
307
|
-
return client.request({
|
|
308
|
-
...config$1,
|
|
309
|
-
url,
|
|
310
|
-
method: "GET"
|
|
311
|
-
});
|
|
312
|
-
},
|
|
313
|
-
post(url, body, config$1) {
|
|
314
|
-
return client.request({
|
|
315
|
-
...config$1,
|
|
316
|
-
url,
|
|
317
|
-
body,
|
|
318
|
-
method: "POST"
|
|
319
|
-
});
|
|
320
|
-
},
|
|
321
|
-
put(url, body, config$1) {
|
|
322
|
-
return client.request({
|
|
323
|
-
...config$1,
|
|
324
|
-
url,
|
|
325
|
-
body,
|
|
326
|
-
method: "PUT"
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
patch(url, body, config$1) {
|
|
330
|
-
return client.request({
|
|
331
|
-
...config$1,
|
|
332
|
-
url,
|
|
333
|
-
body,
|
|
334
|
-
method: "PATCH"
|
|
335
|
-
});
|
|
336
|
-
},
|
|
337
|
-
delete(url, config$1) {
|
|
338
|
-
return client.request({
|
|
339
|
-
...config$1,
|
|
340
|
-
url,
|
|
341
|
-
method: "DELETE"
|
|
342
|
-
});
|
|
343
|
-
},
|
|
344
|
-
head(url, config$1) {
|
|
345
|
-
return client.request({
|
|
346
|
-
...config$1,
|
|
347
|
-
url,
|
|
348
|
-
method: "HEAD"
|
|
349
|
-
});
|
|
350
|
-
},
|
|
351
|
-
options(url, config$1) {
|
|
352
|
-
return client.request({
|
|
353
|
-
...config$1,
|
|
354
|
-
url,
|
|
355
|
-
method: "OPTIONS"
|
|
356
|
-
});
|
|
357
|
-
},
|
|
358
|
-
setHeader(name, value) {
|
|
359
|
-
defaults.headers[name] = value;
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
return client;
|
|
363
|
-
};
|
|
364
|
-
var createApi_default = createApi;
|
|
365
|
-
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region ../infra/src/http/createWasmApi.ts
|
|
368
|
-
const RSA_OAEP_SHA256_SCHEME = "RSA/NONE/OAEPWITHSHA-256ANDMGF1PADDING";
|
|
369
|
-
/**
|
|
370
|
-
* Builds the base set of HTTP headers that the WASM WebClient sends on every
|
|
371
|
-
* request (including the internal `/e2ee/key/v2` and `/e2ee/key` handshake
|
|
372
|
-
* calls).
|
|
373
|
-
*/
|
|
374
|
-
function buildWasmDefaultHeaders(customHeaders) {
|
|
375
|
-
return {
|
|
376
|
-
"Content-Type": "application/json",
|
|
377
|
-
Accept: "application/json",
|
|
378
|
-
"api-version": "1.0",
|
|
379
|
-
...customHeaders ?? {}
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
var WasmHttpError = class extends Error {
|
|
383
|
-
constructor(status, statusText, url, method, headers, data) {
|
|
384
|
-
super(`HTTP ${status} ${statusText}`);
|
|
385
|
-
this.ok = false;
|
|
386
|
-
this.status = status;
|
|
387
|
-
this.statusText = statusText;
|
|
388
|
-
this.url = url;
|
|
389
|
-
this.method = method;
|
|
390
|
-
this.headers = headers;
|
|
391
|
-
this.data = data;
|
|
392
|
-
this.name = "WasmHttpError";
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
const DEFAULT_TIMEOUT = 3e4;
|
|
396
|
-
const HTTP_METHODS = new Set([
|
|
397
|
-
"GET",
|
|
398
|
-
"POST",
|
|
399
|
-
"PUT",
|
|
400
|
-
"PATCH",
|
|
401
|
-
"DELETE"
|
|
402
|
-
]);
|
|
403
|
-
const buildQueryString = (query) => {
|
|
404
|
-
if (!query) return "";
|
|
405
|
-
const params = new URLSearchParams();
|
|
406
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
407
|
-
if (value !== void 0 && value !== null) params.append(key, String(value));
|
|
408
|
-
});
|
|
409
|
-
const str = params.toString();
|
|
410
|
-
return str ? `?${str}` : "";
|
|
411
|
-
};
|
|
412
|
-
const buildUrl = (baseURL, url, query) => {
|
|
413
|
-
const queryString = buildQueryString(query);
|
|
414
|
-
if (url.startsWith("http://") || url.startsWith("https://")) return `${url}${queryString}`;
|
|
415
|
-
return `${baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL}${url.startsWith("/") ? url : `/${url}`}${queryString}`;
|
|
416
|
-
};
|
|
417
|
-
const prepareBody = (body) => {
|
|
418
|
-
if (body === null || body === void 0) return void 0;
|
|
419
|
-
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof Uint8Array || typeof body === "string") return body;
|
|
420
|
-
if (typeof body === "object") return body;
|
|
421
|
-
return String(body);
|
|
422
|
-
};
|
|
423
|
-
const normalizeMethod = (method) => {
|
|
424
|
-
const upper = method.toUpperCase();
|
|
425
|
-
if (!HTTP_METHODS.has(upper)) throw new Error(`Unsupported HTTP method for WASM client: ${method}`);
|
|
426
|
-
return upper;
|
|
427
|
-
};
|
|
428
|
-
const getErrorStatus = (error) => {
|
|
429
|
-
if (error instanceof WasmWebClientError) return error.statusCode;
|
|
430
|
-
if (typeof error === "object" && error !== null) {
|
|
431
|
-
const record = error;
|
|
432
|
-
if (typeof record.statusCode === "number") return record.statusCode;
|
|
433
|
-
if (typeof record.status === "number") return record.status;
|
|
434
|
-
}
|
|
435
|
-
return 0;
|
|
436
|
-
};
|
|
437
|
-
const getErrorData = (error) => {
|
|
438
|
-
if (error instanceof WasmWebClientError) return error.response?.data ?? null;
|
|
439
|
-
return null;
|
|
440
|
-
};
|
|
441
|
-
const getErrorMessage = (error) => {
|
|
442
|
-
if (error instanceof Error) return error.message;
|
|
443
|
-
return "WasmWebClient request failed";
|
|
444
|
-
};
|
|
445
|
-
const withAbortSignal = async (promise, signal, error) => {
|
|
446
|
-
if (!signal) return await promise;
|
|
447
|
-
if (signal.aborted) throw error;
|
|
448
|
-
return await new Promise((resolve, reject) => {
|
|
449
|
-
const onAbort = () => reject(error);
|
|
450
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
451
|
-
promise.then(resolve, reject).finally(() => {
|
|
452
|
-
signal.removeEventListener("abort", onAbort);
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
};
|
|
456
|
-
const createWasmApi = async (config) => {
|
|
457
|
-
const headers = buildWasmDefaultHeaders(config.customHeaders);
|
|
458
|
-
const isEncryptionEnabled = config.isEncryptionEnabled ?? (() => false);
|
|
459
|
-
const useSha256 = config.mgf1 === "sha256";
|
|
460
|
-
await initializeWasmWebClient(config.wasm.wasmPath, config.wasm.wasmSimdPath ?? config.wasm.wasmPath, config.wasm.glueCodePath, config.wasm.glueCodeSimdPath ?? "", config.wasm.useSimd ?? true);
|
|
461
|
-
await setupWasmConnection(config.apiURL, "", config.encryptionEnabled ?? false, headers, useSha256);
|
|
462
|
-
const defaults = {
|
|
463
|
-
baseURL: config.apiURL,
|
|
464
|
-
headers
|
|
465
|
-
};
|
|
466
|
-
const client = {
|
|
467
|
-
defaults,
|
|
468
|
-
async request(requestConfig) {
|
|
469
|
-
const { method = "GET", url, headers: requestHeaders = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT, onUploadProgress, ie = false } = requestConfig;
|
|
470
|
-
const upperMethod = normalizeMethod(method);
|
|
471
|
-
const requestParams = params ?? query;
|
|
472
|
-
const fullUrl = buildUrl(defaults.baseURL, url, requestParams);
|
|
473
|
-
const needsSchemeHeader = ie || useSha256 && isEncryptionEnabled();
|
|
474
|
-
const mergedHeaders = {
|
|
475
|
-
...defaults.headers,
|
|
476
|
-
...needsSchemeHeader ? { "X-RSA-Encryption-Scheme": RSA_OAEP_SHA256_SCHEME } : {},
|
|
477
|
-
...requestHeaders
|
|
478
|
-
};
|
|
479
|
-
const requestBody = prepareBody(body);
|
|
480
|
-
const wasmProgress = onUploadProgress ? (progress) => {
|
|
481
|
-
if (progress.total > 0) onUploadProgress(Math.round(progress.loaded / progress.total * 100));
|
|
482
|
-
} : void 0;
|
|
483
|
-
const abortError = new WasmHttpError(0, "Request aborted", fullUrl, upperMethod, {}, null);
|
|
484
|
-
if (signal?.aborted) throw abortError;
|
|
485
|
-
try {
|
|
486
|
-
const response = await withAbortSignal(executeWasmRequest(upperMethod, url, requestBody, mergedHeaders, requestParams, timeout, wasmProgress, ie), signal, abortError);
|
|
487
|
-
if (response.status < 200 || response.status >= 300) throw new WasmHttpError(response.status, "", fullUrl, upperMethod, {}, response.data);
|
|
488
|
-
return {
|
|
489
|
-
ok: true,
|
|
490
|
-
status: response.status,
|
|
491
|
-
statusText: "",
|
|
492
|
-
url: fullUrl,
|
|
493
|
-
headers: {},
|
|
494
|
-
data: response.data
|
|
495
|
-
};
|
|
496
|
-
} catch (error) {
|
|
497
|
-
if (error instanceof WasmHttpError) throw error;
|
|
498
|
-
throw new WasmHttpError(getErrorStatus(error), getErrorMessage(error), fullUrl, upperMethod, {}, getErrorData(error));
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
get(url, requestConfig) {
|
|
502
|
-
return client.request({
|
|
503
|
-
...requestConfig,
|
|
504
|
-
url,
|
|
505
|
-
method: "GET"
|
|
506
|
-
});
|
|
507
|
-
},
|
|
508
|
-
post(url, body, requestConfig) {
|
|
509
|
-
return client.request({
|
|
510
|
-
...requestConfig,
|
|
511
|
-
url,
|
|
512
|
-
body,
|
|
513
|
-
method: "POST"
|
|
514
|
-
});
|
|
515
|
-
},
|
|
516
|
-
put(url, body, requestConfig) {
|
|
517
|
-
return client.request({
|
|
518
|
-
...requestConfig,
|
|
519
|
-
url,
|
|
520
|
-
body,
|
|
521
|
-
method: "PUT"
|
|
522
|
-
});
|
|
523
|
-
},
|
|
524
|
-
patch(url, body, requestConfig) {
|
|
525
|
-
return client.request({
|
|
526
|
-
...requestConfig,
|
|
527
|
-
url,
|
|
528
|
-
body,
|
|
529
|
-
method: "PATCH"
|
|
530
|
-
});
|
|
531
|
-
},
|
|
532
|
-
delete(url, requestConfig) {
|
|
533
|
-
return client.request({
|
|
534
|
-
...requestConfig,
|
|
535
|
-
url,
|
|
536
|
-
method: "DELETE"
|
|
537
|
-
});
|
|
538
|
-
},
|
|
539
|
-
head() {
|
|
540
|
-
return Promise.reject(/* @__PURE__ */ new Error("HEAD is not supported by the WASM HTTP client"));
|
|
541
|
-
},
|
|
542
|
-
options() {
|
|
543
|
-
return Promise.reject(/* @__PURE__ */ new Error("OPTIONS is not supported by the WASM HTTP client"));
|
|
544
|
-
},
|
|
545
|
-
setHeader(name, value) {
|
|
546
|
-
defaults.headers[name] = value;
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
return client;
|
|
550
|
-
};
|
|
551
|
-
var createWasmApi_default = createWasmApi;
|
|
552
|
-
|
|
553
|
-
//#endregion
|
|
554
|
-
//#region src/internal/http/clientLifecycle.ts
|
|
555
|
-
/**
|
|
556
|
-
* Wraps the active HttpClient as a transport for the C++ `WebApi` host
|
|
557
|
-
* adapter. Lets the on-device face-results POST flow through the same
|
|
558
|
-
* `httpClient.request()` pipeline as every other endpoint — header
|
|
559
|
-
* injection, encryption-state handling, default headers, timeout — instead
|
|
560
|
-
* of bypassing it via `executeWasmRequest` directly.
|
|
561
|
-
*/
|
|
562
|
-
function bindWebApiTransport(client) {
|
|
563
|
-
return async (url, body, config) => {
|
|
564
|
-
const response = await client.request({
|
|
565
|
-
method: "POST",
|
|
566
|
-
url,
|
|
567
|
-
body,
|
|
568
|
-
headers: config.headers,
|
|
569
|
-
params: config.params,
|
|
570
|
-
timeout: config.timeout,
|
|
571
|
-
ie: config.ie
|
|
572
|
-
});
|
|
573
|
-
return {
|
|
574
|
-
data: response.data,
|
|
575
|
-
status: response.status
|
|
576
|
-
};
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
function installClient(client) {
|
|
580
|
-
setClient(client);
|
|
581
|
-
setWebApiHttpTransport(bindWebApiTransport(client));
|
|
582
|
-
}
|
|
583
|
-
let storedHttpConfig;
|
|
584
|
-
/** Reads the current HTTP-client config (or `undefined` if none installed). */
|
|
585
|
-
function getStoredHttpConfig() {
|
|
586
|
-
return storedHttpConfig;
|
|
587
|
-
}
|
|
588
|
-
/** Whether encryption is currently active on the installed HTTP client. */
|
|
589
|
-
function isHttpEncrypted() {
|
|
590
|
-
return storedHttpConfig?.encryption.enabled ?? false;
|
|
591
|
-
}
|
|
592
|
-
/** Clears all HTTP-client state. Called by `reset()`. */
|
|
593
|
-
function resetHttpClientState() {
|
|
594
|
-
storedHttpConfig = void 0;
|
|
595
|
-
setWebApiHttpTransport(null);
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Builds (or replaces) the HTTP client when `setup()` receives an `apiURL`.
|
|
599
|
-
* Picks `createWasmApi` when `effectiveWasm` is set, otherwise plain
|
|
600
|
-
* `createApi`. Wraps the call in handshake-failure context when encryption
|
|
601
|
-
* is requested.
|
|
602
|
-
*/
|
|
603
|
-
async function installFreshHttpClient(apiURL, options, effectiveWasm, encryption) {
|
|
604
|
-
installClient(effectiveWasm ? await withHandshakeFailureContext(encryption.enabled, () => createWasmApi_default({
|
|
605
|
-
apiURL,
|
|
606
|
-
customHeaders: options.customHeaders,
|
|
607
|
-
timeout: options.timeout,
|
|
608
|
-
wasm: effectiveWasm,
|
|
609
|
-
encryptionEnabled: encryption.enabled,
|
|
610
|
-
mgf1: encryption.mgf1,
|
|
611
|
-
isEncryptionEnabled: isHttpEncrypted
|
|
612
|
-
})) : createApi_default({
|
|
613
|
-
apiURL,
|
|
614
|
-
customHeaders: options.customHeaders,
|
|
615
|
-
timeout: options.timeout
|
|
616
|
-
}));
|
|
617
|
-
storedHttpConfig = {
|
|
618
|
-
apiURL,
|
|
619
|
-
customHeaders: options.customHeaders,
|
|
620
|
-
timeout: options.timeout,
|
|
621
|
-
isWasm: Boolean(effectiveWasm),
|
|
622
|
-
encryption
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Replaces the active HTTP client with the WASM-backed one. Used internally
|
|
627
|
-
* by lazy-loading UI components (`<incode-flow>`, `<incode-workflow>`) when
|
|
628
|
-
* WASM finishes warming up.
|
|
629
|
-
*
|
|
630
|
-
* No-op when no apiURL was previously configured, or when the active client
|
|
631
|
-
* is already WASM-backed. The encryption state (enabled + MGF1 scheme) is
|
|
632
|
-
* preserved across the swap — this is *not* a user-facing encryption change.
|
|
633
|
-
*
|
|
634
|
-
* @internal NOT a public API. Application code should use
|
|
635
|
-
* `setup({ wasm: {...} })` instead.
|
|
636
|
-
*/
|
|
637
|
-
async function upgradeToWasmHttpClient(resolved) {
|
|
638
|
-
const stored = storedHttpConfig;
|
|
639
|
-
if (!stored || stored.isWasm) return;
|
|
640
|
-
installClient(await createWasmApi_default({
|
|
641
|
-
apiURL: stored.apiURL,
|
|
642
|
-
customHeaders: stored.customHeaders,
|
|
643
|
-
timeout: stored.timeout,
|
|
644
|
-
wasm: resolved,
|
|
645
|
-
encryptionEnabled: stored.encryption.enabled,
|
|
646
|
-
mgf1: stored.encryption.mgf1,
|
|
647
|
-
isEncryptionEnabled: isHttpEncrypted
|
|
648
|
-
}));
|
|
649
|
-
storedHttpConfig = {
|
|
650
|
-
...stored,
|
|
651
|
-
isWasm: true
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* When `wantsEncryption` is true, wraps a call that triggers the in-binary
|
|
656
|
-
* RSA/AES handshake so its rejection surfaces as a single, descriptive error
|
|
657
|
-
* with the original error preserved as `cause`. Pass-through otherwise.
|
|
658
|
-
*/
|
|
659
|
-
async function withHandshakeFailureContext(wantsEncryption, fn) {
|
|
660
|
-
if (!wantsEncryption) return fn();
|
|
661
|
-
try {
|
|
662
|
-
return await fn();
|
|
663
|
-
} catch (cause) {
|
|
664
|
-
const error = /* @__PURE__ */ new Error("Failed to establish encrypted transport. The /e2ee/key handshake did not complete. Verify the apiURL is reachable and that the environment supports E2EE.");
|
|
665
|
-
error.cause = cause;
|
|
666
|
-
throw error;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
//#endregion
|
|
671
|
-
//#region ../infra/src/providers/browser/DevtoolsDetectorProvider.ts
|
|
672
|
-
var DevtoolsDetectorProvider = class {
|
|
673
|
-
constructor() {
|
|
674
|
-
this.detectorPaused = true;
|
|
675
|
-
this.isDevtoolsOpen = false;
|
|
676
|
-
}
|
|
677
|
-
start(options) {
|
|
678
|
-
if (!this.canUseDevtoolsDetector() || this.heart) return;
|
|
679
|
-
this.startDetector({
|
|
680
|
-
pollingIntervalSeconds: .25,
|
|
681
|
-
maxMillisBeforeAckWhenClosed: 100,
|
|
682
|
-
moreAnnoyingDebuggerStatements: 1,
|
|
683
|
-
onDetectOpen: options.onInspectorOpened,
|
|
684
|
-
onDetectClose: void 0,
|
|
685
|
-
startup: "asap"
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
stop() {
|
|
689
|
-
this.clearNextPulse();
|
|
690
|
-
this.resolveVerdict?.(null);
|
|
691
|
-
this.resolveVerdict = void 0;
|
|
692
|
-
this.heart?.terminate();
|
|
693
|
-
this.heart = void 0;
|
|
694
|
-
this.detectorPaused = true;
|
|
695
|
-
this.isDevtoolsOpen = false;
|
|
696
|
-
}
|
|
697
|
-
canUseDevtoolsDetector() {
|
|
698
|
-
return typeof globalThis !== "undefined" && typeof Worker !== "undefined" && typeof URL !== "undefined" && typeof URL.createObjectURL === "function" && typeof Blob !== "undefined";
|
|
699
|
-
}
|
|
700
|
-
createDetectorWorker() {
|
|
701
|
-
return new Worker(URL.createObjectURL(new Blob([`"use strict";
|
|
702
|
-
onmessage = (ev) => { postMessage({isOpenBeat:true});
|
|
703
|
-
debugger; for (let i = 0; i < ev.data.moreDebugs; i++) { debugger; }
|
|
704
|
-
postMessage({isOpenBeat:false});
|
|
705
|
-
};`], { type: "text/javascript" })));
|
|
706
|
-
}
|
|
707
|
-
clearNextPulse() {
|
|
708
|
-
if (this.nextPulseTimeout !== void 0) {
|
|
709
|
-
clearTimeout(this.nextPulseTimeout);
|
|
710
|
-
this.nextPulseTimeout = void 0;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
doOnePulse(moreDebugs) {
|
|
714
|
-
this.heart?.postMessage({ moreDebugs });
|
|
715
|
-
}
|
|
716
|
-
startDetector(config) {
|
|
717
|
-
this.heart = this.createDetectorWorker();
|
|
718
|
-
const onHeartMsg = (msg) => {
|
|
719
|
-
if (msg.data.isOpenBeat) new Promise((resolve) => {
|
|
720
|
-
this.resolveVerdict = resolve;
|
|
721
|
-
setTimeout(() => {
|
|
722
|
-
this.resolveVerdict?.(true);
|
|
723
|
-
}, config.maxMillisBeforeAckWhenClosed + 1);
|
|
724
|
-
}).then((verdict) => {
|
|
725
|
-
if (verdict === null) return;
|
|
726
|
-
if (verdict !== this.isDevtoolsOpen) {
|
|
727
|
-
this.isDevtoolsOpen = verdict;
|
|
728
|
-
if (verdict) config.onDetectOpen();
|
|
729
|
-
else if (config.onDetectClose) config.onDetectClose();
|
|
730
|
-
}
|
|
731
|
-
this.clearNextPulse();
|
|
732
|
-
this.nextPulseTimeout = setTimeout(() => {
|
|
733
|
-
this.nextPulseTimeout = void 0;
|
|
734
|
-
this.doOnePulse(config.moreAnnoyingDebuggerStatements);
|
|
735
|
-
}, config.pollingIntervalSeconds * 1e3);
|
|
736
|
-
});
|
|
737
|
-
else this.resolveVerdict?.(false);
|
|
738
|
-
};
|
|
739
|
-
this.heart.addEventListener("message", onHeartMsg);
|
|
740
|
-
const resume = () => {
|
|
741
|
-
if (!this.detectorPaused) return;
|
|
742
|
-
this.detectorPaused = false;
|
|
743
|
-
this.doOnePulse(config.moreAnnoyingDebuggerStatements);
|
|
744
|
-
};
|
|
745
|
-
switch (config.startup) {
|
|
746
|
-
case "manual": break;
|
|
747
|
-
case "asap":
|
|
748
|
-
resume();
|
|
749
|
-
break;
|
|
750
|
-
case "domContentLoaded":
|
|
751
|
-
if (typeof document !== "undefined" && document.readyState !== "loading") resume();
|
|
752
|
-
else if (typeof document !== "undefined") document.addEventListener("DOMContentLoaded", resume, { once: true });
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
//#endregion
|
|
759
|
-
//#region src/internal/device/devtoolsDetectorBridge.ts
|
|
760
|
-
const devtoolsDetector = new DevtoolsDetectorProvider();
|
|
761
|
-
async function reportInspectorOpened() {
|
|
762
|
-
try {
|
|
763
|
-
(await WasmUtilProvider.getInstance()).setInspectorOpened(true);
|
|
764
|
-
} catch {
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
addDeviceStats({ inspectorOpened: true });
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* Starts the devtools inspector detector (ported from legacy welcome `setupFiles`).
|
|
771
|
-
*/
|
|
772
|
-
function startDevtoolsDetector() {
|
|
773
|
-
devtoolsDetector.start({ onInspectorOpened: () => {
|
|
774
|
-
reportInspectorOpened();
|
|
775
|
-
} });
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Stops the devtools detector. Invoked from {@link reset}.
|
|
779
|
-
*/
|
|
780
|
-
function stopDevtoolsDetector() {
|
|
781
|
-
devtoolsDetector.stop();
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
//#endregion
|
|
785
|
-
//#region src/setup.ts
|
|
786
|
-
let wasmConfig;
|
|
787
|
-
/**
|
|
788
|
-
* Legacy Java backend default for OAEP MGF1 padding compatibility.
|
|
789
|
-
* Most existing Incode E2EE environments expect this.
|
|
790
|
-
*/
|
|
791
|
-
const DEFAULT_MGF1 = "sha1";
|
|
792
|
-
/**
|
|
793
|
-
* Normalizes the public `encryption` option into the internal shape used by
|
|
794
|
-
* the HTTP client lifecycle. Returns `undefined` when the caller did not
|
|
795
|
-
* specify `encryption` at all (so callers can distinguish "preserve stored
|
|
796
|
-
* value" from "explicitly off").
|
|
797
|
-
*/
|
|
798
|
-
function normalizeEncryption(input) {
|
|
799
|
-
if (input === void 0) return void 0;
|
|
800
|
-
if (input === false) return {
|
|
801
|
-
enabled: false,
|
|
802
|
-
mgf1: DEFAULT_MGF1
|
|
803
|
-
};
|
|
804
|
-
if (input === true) return {
|
|
805
|
-
enabled: true,
|
|
806
|
-
mgf1: DEFAULT_MGF1
|
|
807
|
-
};
|
|
808
|
-
return {
|
|
809
|
-
enabled: true,
|
|
810
|
-
mgf1: input.mgf1 ?? DEFAULT_MGF1
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
let configured = false;
|
|
814
|
-
/**
|
|
815
|
-
* Initializes the SDK with the provided configuration.
|
|
816
|
-
* Must be called before using any SDK functionality.
|
|
817
|
-
*
|
|
818
|
-
* WASM loads only when `options.wasm` is provided as an object.
|
|
819
|
-
*
|
|
820
|
-
* `setup` is boot — it provisions the HTTP client, the optional E2EE
|
|
821
|
-
* handshake, WASM warmup, and the analytics batcher. The session token is a
|
|
822
|
-
* separate concern: hand it off via `initializeSession({ token })` from
|
|
823
|
-
* `@incodetech/core/session`, or pass it inline as `setup({ apiURL, token })`
|
|
824
|
-
* (a convenience that delegates to `initializeSession` for you).
|
|
825
|
-
*
|
|
826
|
-
* @param options - Configuration options for the SDK
|
|
827
|
-
*
|
|
828
|
-
* @example Boot first, activate the session later (preferred)
|
|
829
|
-
* ```ts
|
|
830
|
-
* import { setup } from '@incodetech/core';
|
|
831
|
-
* import { createSession, initializeSession } from '@incodetech/core/session';
|
|
832
|
-
*
|
|
833
|
-
* await setup({ apiURL: 'https://api.incode.com' });
|
|
834
|
-
* const session = await createSession(apiKey, { configurationId });
|
|
835
|
-
* await initializeSession({ token: session.token });
|
|
836
|
-
* ```
|
|
837
|
-
*
|
|
838
|
-
* @example One-shot convenience
|
|
839
|
-
* ```ts
|
|
840
|
-
* await setup({ apiURL: 'https://api.incode.com', token: 'session-token' });
|
|
841
|
-
* ```
|
|
842
|
-
*
|
|
843
|
-
* @example Explicitly disable WASM
|
|
844
|
-
* ```ts
|
|
845
|
-
* await setup({ apiURL: 'https://api.incode.com', wasm: false });
|
|
846
|
-
* ```
|
|
847
|
-
*
|
|
848
|
-
* @example Use CDN defaults for paths and preload only one pipeline
|
|
849
|
-
* ```ts
|
|
850
|
-
* await setup({
|
|
851
|
-
* apiURL: 'https://api.incode.com',
|
|
852
|
-
* wasm: { pipelines: ['selfie'] },
|
|
853
|
-
* });
|
|
854
|
-
* ```
|
|
855
|
-
*
|
|
856
|
-
* @example Self-hosted WASM (pin a version folder on your CDN)
|
|
857
|
-
* ```ts
|
|
858
|
-
* await setup({
|
|
859
|
-
* apiURL: 'https://api.incode.com',
|
|
860
|
-
* wasm: {
|
|
861
|
-
* basePath: 'https://my-cdn.example.com/ml-wasm-kit-release/v2.13.21',
|
|
862
|
-
* },
|
|
863
|
-
* });
|
|
864
|
-
* ```
|
|
865
|
-
*
|
|
866
|
-
* @example Partial override: only models path, rest from CDN
|
|
867
|
-
* ```ts
|
|
868
|
-
* await setup({
|
|
869
|
-
* apiURL: 'https://api.incode.com',
|
|
870
|
-
* wasm: { modelsBasePath: 'https://my-cdn/models' },
|
|
871
|
-
* });
|
|
872
|
-
* ```
|
|
873
|
-
*
|
|
874
|
-
* @example Sessionless setup (all API actors overridden via .provide())
|
|
875
|
-
* ```ts
|
|
876
|
-
* await setup({
|
|
877
|
-
* wasm: {
|
|
878
|
-
* wasmPath: '/wasm/ml-wasm.wasm',
|
|
879
|
-
* glueCodePath: '/wasm/ml-wasm.js',
|
|
880
|
-
* pipelines: ['selfie'],
|
|
881
|
-
* },
|
|
882
|
-
* });
|
|
883
|
-
* ```
|
|
884
|
-
*
|
|
885
|
-
* @example Enable end-to-end encryption at boot (defaults to MGF1 = SHA-1)
|
|
886
|
-
* ```ts
|
|
887
|
-
* // `/0` lets the server read the API key from the session JWT.
|
|
888
|
-
* await setup({
|
|
889
|
-
* apiURL: 'https://your-e2ee-api.incodesmile.com/0',
|
|
890
|
-
* encryption: true,
|
|
891
|
-
* });
|
|
892
|
-
* ```
|
|
893
|
-
*
|
|
894
|
-
* @example Enable encryption with the SHA-256 MGF1 padding
|
|
895
|
-
* ```ts
|
|
896
|
-
* await setup({
|
|
897
|
-
* apiURL: 'https://your-e2ee-api.incodesmile.com/0',
|
|
898
|
-
* encryption: { mgf1: 'sha256' },
|
|
899
|
-
* });
|
|
900
|
-
* ```
|
|
901
|
-
*
|
|
902
|
-
* @example E2EE without the `/0` suffix — pass the API key explicitly
|
|
903
|
-
* ```ts
|
|
904
|
-
* await setup({
|
|
905
|
-
* apiURL: 'https://your-e2ee-api.incodesmile.com',
|
|
906
|
-
* encryption: true,
|
|
907
|
-
* customHeaders: { 'x-api-key': process.env.INCODE_API_KEY },
|
|
908
|
-
* });
|
|
909
|
-
* ```
|
|
910
|
-
* @example Disable third-party IP lookup
|
|
911
|
-
* ```ts
|
|
912
|
-
* await setup({
|
|
913
|
-
* apiURL: 'https://api.incode.com',
|
|
914
|
-
* ipLookup: false,
|
|
915
|
-
* });
|
|
916
|
-
* ```
|
|
917
|
-
*
|
|
918
|
-
* @example Local development: silence the devtools detector and surface WASM logs
|
|
919
|
-
* ```ts
|
|
920
|
-
* await setup({
|
|
921
|
-
* apiURL: 'https://api.incode.com',
|
|
922
|
-
* wasm: { showLogs: true }, // WASM logs are off by default
|
|
923
|
-
* devMode: true, // skip the devtools detector (don't ship this in prod)
|
|
924
|
-
* });
|
|
925
|
-
* ```
|
|
926
|
-
* @example Enable TRI — exchange the API key for an SDK token first, then pass it to setup
|
|
927
|
-
* ```ts
|
|
928
|
-
* const session = await createTRISession(process.env.INCODE_API_KEY, {
|
|
929
|
-
* apiURL: process.env.INCODE_TRI_API_URL,
|
|
930
|
-
* });
|
|
931
|
-
*
|
|
932
|
-
* await setup({
|
|
933
|
-
* apiURL: 'https://api.incode.com',
|
|
934
|
-
* tri: { token: session.token, apiURL: process.env.INCODE_TRI_API_URL },
|
|
935
|
-
* });
|
|
936
|
-
* ```
|
|
937
|
-
*
|
|
938
|
-
* @example Defer TRI collection until after a consent gate
|
|
939
|
-
* ```ts
|
|
940
|
-
* // Boot without starting collectors:
|
|
941
|
-
* await setup({
|
|
942
|
-
* apiURL: 'https://api.incode.com',
|
|
943
|
-
* tri: { token: session.token, apiURL: process.env.INCODE_TRI_API_URL, autostart: false },
|
|
944
|
-
* });
|
|
945
|
-
*
|
|
946
|
-
* // somewhere else in the code
|
|
947
|
-
* await startTRI();
|
|
948
|
-
* ```
|
|
949
|
-
*/
|
|
950
|
-
async function setup(options) {
|
|
951
|
-
if (options.ipLookup !== void 0) setClientIpLookupEnabled(options.ipLookup);
|
|
952
|
-
if (!getAnalyticsBatcher()) setAnalyticsBatcher(createAnalyticsBatchingService({
|
|
953
|
-
endpoint: endpoints.events,
|
|
954
|
-
authToken: () => getToken(),
|
|
955
|
-
apiBaseUrl: () => getApi().defaults.baseURL,
|
|
956
|
-
apiClient: api,
|
|
957
|
-
pageLifecycle: new BrowserPageLifecycleProvider(),
|
|
958
|
-
timer: BrowserTimerProvider.getInstance()
|
|
959
|
-
}));
|
|
960
|
-
const requestedEncryption = normalizeEncryption(options.encryption);
|
|
961
|
-
const stored = getStoredHttpConfig();
|
|
962
|
-
if (requestedEncryption && stored) {
|
|
963
|
-
if (requestedEncryption.enabled !== stored.encryption.enabled || requestedEncryption.enabled && requestedEncryption.mgf1 !== stored.encryption.mgf1) throw new Error("Encryption is locked at the first setup() call and cannot be changed at runtime. Call reset() to fully reinitialize the SDK if you need a different encryption configuration.");
|
|
964
|
-
}
|
|
965
|
-
if (requestedEncryption?.enabled && options.wasm === false) throw new Error("Encryption is incompatible with `wasm: false`. Either remove `wasm: false` or omit `encryption`.");
|
|
966
|
-
const effectiveEncryption = requestedEncryption ?? stored?.encryption ?? {
|
|
967
|
-
enabled: false,
|
|
968
|
-
mgf1: "sha1"
|
|
969
|
-
};
|
|
970
|
-
const effectiveWasm = options.wasm || requestedEncryption?.enabled ? resolveWasmConfig(options.wasm || {}) : void 0;
|
|
971
|
-
if (options.apiURL) await installFreshHttpClient(options.apiURL, options, effectiveWasm, effectiveEncryption);
|
|
972
|
-
if (options.token && isApiConfigured()) initializeSession({
|
|
973
|
-
token: options.token,
|
|
974
|
-
hostingApp: options.hostingApp
|
|
975
|
-
}).catch((error) => {
|
|
976
|
-
console.warn("Session initialization failed:", error);
|
|
977
|
-
});
|
|
978
|
-
configured = true;
|
|
979
|
-
if (effectiveWasm) {
|
|
980
|
-
await warmupWasm(effectiveWasm);
|
|
981
|
-
const provider = await WasmUtilProvider.getInstance();
|
|
982
|
-
await provider.initialize({
|
|
983
|
-
...effectiveWasm,
|
|
984
|
-
pipelines: effectiveWasm.pipelines ? [...effectiveWasm.pipelines] : void 0
|
|
985
|
-
});
|
|
986
|
-
const showWasmLogs = typeof options.wasm === "object" && options.wasm.showLogs === true;
|
|
987
|
-
await provider.setProductionMode(!showWasmLogs);
|
|
988
|
-
if (!options.devMode) startDevtoolsDetector();
|
|
989
|
-
}
|
|
990
|
-
if (options.tri) await initializeTRI(options.tri, { sessionToken: options.token });
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Sets the WASM configuration without performing warmup.
|
|
994
|
-
* Useful when WASM warmup is handled separately (e.g., conditionally based on flow).
|
|
995
|
-
*
|
|
996
|
-
* @param config - WASM configuration to store
|
|
997
|
-
*/
|
|
998
|
-
function setWasmConfig(config) {
|
|
999
|
-
wasmConfig = config;
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Initializes WasmUtilProvider with the stored WASM configuration.
|
|
1003
|
-
* Should be called after warmupWasm() completes when using conditional warmup.
|
|
1004
|
-
* This ensures image encryption works properly.
|
|
1005
|
-
*
|
|
1006
|
-
* @param config - Optional WASM configuration. If not provided, uses the stored config from setWasmConfig().
|
|
1007
|
-
* @throws Error if no config is provided and none is stored
|
|
1008
|
-
*/
|
|
1009
|
-
async function initializeWasmUtil(config) {
|
|
1010
|
-
const wasmConfigToUse = config ?? wasmConfig;
|
|
1011
|
-
if (!wasmConfigToUse) throw new Error("WASM config is required. Provide config parameter or call setWasmConfig() first.");
|
|
1012
|
-
const resolved = resolveWasmConfig(wasmConfigToUse);
|
|
1013
|
-
await (await WasmUtilProvider.getInstance()).initialize({
|
|
1014
|
-
...resolved,
|
|
1015
|
-
pipelines: resolved.pipelines ? [...resolved.pipelines] : void 0
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Replaces the active HTTP client with the WASM-backed one. Used internally
|
|
1020
|
-
* by lazy-loading UI components (`<incode-flow>`, `<incode-workflow>`) when
|
|
1021
|
-
* WASM finishes warming up.
|
|
1022
|
-
*
|
|
1023
|
-
* No-op when no apiURL was originally configured, or when the active client is
|
|
1024
|
-
* already the WASM one.
|
|
1025
|
-
*
|
|
1026
|
-
* @internal NOT a public API. Application code should use
|
|
1027
|
-
* `setup({ wasm: {...} })` instead — that path is the supported way to opt
|
|
1028
|
-
* into the WASM HTTP client.
|
|
1029
|
-
*
|
|
1030
|
-
* @param config - Optional WASM configuration. Defaults to the config stored via `setWasmConfig`.
|
|
1031
|
-
*/
|
|
1032
|
-
async function upgradeToWasmHttpClient$1(config) {
|
|
1033
|
-
const configToUse = config ?? wasmConfig;
|
|
1034
|
-
if (!configToUse) return;
|
|
1035
|
-
await upgradeToWasmHttpClient(resolveWasmConfig(configToUse));
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Checks if the SDK has been configured.
|
|
1039
|
-
*
|
|
1040
|
-
* @returns true if setup() has been called, false otherwise
|
|
1041
|
-
*/
|
|
1042
|
-
function isConfigured() {
|
|
1043
|
-
return configured;
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Resets the SDK configuration. Useful for testing.
|
|
1047
|
-
*/
|
|
1048
|
-
function reset() {
|
|
1049
|
-
stopDevtoolsDetector();
|
|
1050
|
-
resetDeviceStatsQueue();
|
|
1051
|
-
resetApi();
|
|
1052
|
-
resetSessionInit();
|
|
1053
|
-
setClientIpLookupEnabled(true);
|
|
1054
|
-
resetAnalyticsBatcher();
|
|
1055
|
-
resetHttpClientState();
|
|
1056
|
-
resetTRI();
|
|
1057
|
-
configured = false;
|
|
1058
|
-
wasmConfig = void 0;
|
|
1059
|
-
WasmUtilProvider.resetInstance();
|
|
1060
|
-
resetTRIProviderInstance();
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
//#endregion
|
|
1064
|
-
export { setup as a, buildDefaultWasmConfig as c, setWasmConfig as i, buildWasmConfigFromBasePath as l, isConfigured as n, upgradeToWasmHttpClient$1 as o, reset as r, DEFAULT_WASM_VERSION as s, initializeWasmUtil as t, resolveWasmConfig as u };
|