@incodetech/core 2.0.1 → 2.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BrowserStorageProvider-CuOW1Er2.esm.js → BrowserStorageProvider-BpJM-gIl.esm.js} +8 -1
- package/dist/{IpifyProvider-D7jx52AL.esm.js → IpifyProvider-D4LWD15E.esm.js} +28 -0
- package/dist/{MotionSensorProvider-4v7xkqAp.esm.js → MotionSensorProvider-Bx7Mpzt0.esm.js} +63 -13
- package/dist/{OpenViduRecordingProvider-CMu6XVdc.esm.js → OpenViduRecordingProvider-O4GjBseO.esm.js} +1 -1
- package/dist/StateMachine-BC_nGvrc.d.ts +2 -0
- package/dist/StreamCanvasCapture-ImiDQdVA.esm.js +118 -0
- package/dist/StreamCanvasCapture-yyl20qd9.d.ts +152 -0
- package/dist/{BaseWasmProvider-C_DLEI40.esm.js → WasmUtilProvider-CiEN7Gjn.esm.js} +183 -11
- package/dist/{addressSearch-BpTbTWCa.esm.js → addressSearch-DvmWXKZg.esm.js} +63 -57
- package/dist/{ae-signature-DDDZmWXj.esm.js → ae-signature-BFZta3TZ.esm.js} +1 -1
- package/dist/ae-signature.d.ts +3 -3
- package/dist/ae-signature.esm.js +6 -5
- package/dist/antifraud.d.ts +5 -46
- package/dist/antifraud.esm.js +6 -43
- package/dist/antifraudManager-CkV4u-LE.esm.js +55 -0
- package/dist/antifraudManager-CznnhyvD.d.ts +63 -0
- package/dist/{antifraudStateMachine-O0TMf6yc.esm.js → antifraudStateMachine-Ccrb-Jxc.esm.js} +2 -2
- package/dist/apiError-B-j-gyDx.esm.js +51 -0
- package/dist/authentication.d.ts +13 -11
- package/dist/authentication.esm.js +26 -22
- package/dist/{authenticationManager-C83GNIhl.d.ts → authenticationManager-CIVY80H9.d.ts} +4 -4
- package/dist/{authenticationManager-5M-fKzXx.esm.js → authenticationManager-ZNotsWnC.esm.js} +6 -6
- package/dist/{authenticationStateMachine-BMZqatiF.esm.js → authenticationStateMachine-DksVbF_H.esm.js} +21 -9
- package/dist/{backCameraStream-DMdMeGk2.esm.js → backCameraStream-D7Wo4Nbx.esm.js} +95 -7
- package/dist/{session-CrkWAs-q.esm.js → browserSimulation-B1dWiXp7.esm.js} +61 -476
- package/dist/camera.d.ts +4 -3
- package/dist/camera.esm.js +4 -3
- package/dist/canvas-SKcRBxsk.esm.js +230 -0
- package/dist/consent.d.ts +4 -398
- package/dist/consent.esm.js +6 -77
- package/dist/consentManager-BLd51QiW.d.ts +419 -0
- package/dist/consentManager-BYo9Nu1r.esm.js +90 -0
- package/dist/{consentStateMachine-CCT-B60O.esm.js → consentStateMachine-BG3yL8aC.esm.js} +9 -6
- package/dist/cpf-ocr.d.ts +4 -199
- package/dist/cpf-ocr.esm.js +8 -177
- package/dist/cpfOcrManager-BnieFXuG.d.ts +216 -0
- package/dist/cpfOcrManager-sSKegxox.esm.js +190 -0
- package/dist/cross-document-data-match.d.ts +1 -1
- package/dist/cross-document-data-match.esm.js +4 -4
- package/dist/curp-validation.d.ts +8 -158
- package/dist/curp-validation.esm.js +6 -108
- package/dist/curpValidationManager-CFem6zP9.esm.js +122 -0
- package/dist/curpValidationManager-RttixpIc.d.ts +184 -0
- package/dist/{curpValidationStateMachine-CitWLr2c.esm.js → curpValidationStateMachine-B7V_qp66.esm.js} +20 -13
- package/dist/custom-fields.d.ts +2 -2
- package/dist/custom-fields.esm.js +4 -4
- package/dist/custom-watchlist.d.ts +1 -1
- package/dist/custom-watchlist.esm.js +4 -41
- package/dist/customWatchlistStateMachine-HmFybXLX.esm.js +50 -0
- package/dist/{deepsightLoader-Cm4JIT_z.esm.js → deepsightLoader-65k1Appi.esm.js} +19 -10
- package/dist/{deepsightService-CEVxzehb.d.ts → deepsightService-B7ShOkWL.d.ts} +8 -160
- package/dist/deepsightService-CrHmvx8X.esm.js +276 -0
- package/dist/device.esm.js +4 -3
- package/dist/document-capture.d.ts +995 -86
- package/dist/document-capture.esm.js +34 -8
- package/dist/document-upload.d.ts +47 -47
- package/dist/document-upload.esm.js +7 -7
- package/dist/{documentCaptureStateMachine-BqzTDy9k.esm.js → documentCaptureStateMachine-WYV1r9le.esm.js} +90 -6
- package/dist/dynamic-forms.d.ts +20 -5
- package/dist/dynamic-forms.esm.js +150 -61
- package/dist/ekyb.d.ts +32 -13
- package/dist/ekyb.esm.js +25 -15
- package/dist/{ekybStateMachine-CyMx_kg-.esm.js → ekybStateMachine-aYixw2sL.esm.js} +319 -207
- package/dist/ekyc.d.ts +10 -78
- package/dist/ekyc.esm.js +17 -12
- package/dist/{ekycStateMachine-oeO0Iekd.esm.js → ekycStateMachine-CXbpaJJn.esm.js} +201 -113
- package/dist/electronic-signature.d.ts +3 -3
- package/dist/electronic-signature.esm.js +5 -4
- package/dist/{electronicSignatureManager-D9OHzTpG.esm.js → electronicSignatureManager-BaECdJ1u.esm.js} +91 -23
- package/dist/email.d.ts +4 -3
- package/dist/email.esm.js +6 -5
- package/dist/{emailManager-wAV0LE-H.esm.js → emailManager--D5G3ChB.esm.js} +30 -7
- package/dist/{emailManager-DIfnS5g1.d.ts → emailManager-lAzDoQOs.d.ts} +66 -8
- package/dist/{emailStateMachine-DOf4j58N.esm.js → emailStateMachine-CxTOMAjC.esm.js} +46 -11
- package/dist/{endpoints-CnN3SyDa.esm.js → endpoints-BeTK0Mlt.esm.js} +6 -3
- package/dist/{events-D6-e4vok.esm.js → events-Dvvriq9l.esm.js} +3 -1
- package/dist/events.d.ts +2 -0
- package/dist/events.esm.js +1 -1
- package/dist/extensibility.d.ts +32 -16
- package/dist/extensibility.esm.js +55 -33
- package/dist/face-match.d.ts +32 -2
- package/dist/face-match.esm.js +5 -5
- package/dist/{faceCaptureManagerFactory-yqtpxjnN.d.ts → faceCaptureManagerFactory-C_hRHx8a.d.ts} +35 -11
- package/dist/{faceCaptureManagerFactory-Dh2PdGlF.esm.js → faceCaptureManagerFactory-kqbUqtrr.esm.js} +21 -5
- package/dist/{faceCaptureSetup-B3faSpYA.esm.js → faceCaptureSetup-CtvHWd3x.esm.js} +68 -183
- package/dist/{faceMatchStateMachine-DNFrxTFS.esm.js → faceMatchStateMachine-DdGXUBnx.esm.js} +60 -6
- package/dist/field-comparison.d.ts +4 -0
- package/dist/field-comparison.esm.js +7 -0
- package/dist/fieldComparisonManager-Bu5TaSr3.d.ts +76 -0
- package/dist/fieldComparisonManager-COGI2ARD.esm.js +162 -0
- package/dist/fiscal-qr.d.ts +59 -0
- package/dist/fiscal-qr.esm.js +323 -0
- package/dist/flow-events.d.ts +6 -5
- package/dist/flow.d.ts +23 -15
- package/dist/flow.esm.js +63 -17
- package/dist/flowCompletionService-BdR2cGgB.d.ts +19 -0
- package/dist/flowCompletionService-DdGojV9K.esm.js +20 -0
- package/dist/{flowServices-PiNsxLfK.esm.js → flowServices-BTuHLHVr.esm.js} +10 -5
- package/dist/geolocation.d.ts +4 -4
- package/dist/geolocation.esm.js +6 -6
- package/dist/{geolocationStateMachine-asasuHY2.esm.js → geolocationStateMachine-Dvh7X0wF.esm.js} +5 -5
- package/dist/getBrowser-C8DP7oTB.esm.js +8 -0
- package/dist/{getBrowser-BSXUTWXw.esm.js → getDeviceClass-C0olyNFS.esm.js} +1 -8
- package/dist/{getDeviceClass-BSntT9_j.esm.js → getDeviceClass-C8Do2qYu.esm.js} +1 -1
- package/dist/government-validation.d.ts +28 -8
- package/dist/government-validation.esm.js +19 -8
- package/dist/{governmentValidationStateMachine-BDDYrJTo.esm.js → governmentValidationStateMachine-DcJ-BfsC.esm.js} +35 -77
- package/dist/home.d.ts +15 -14
- package/dist/home.esm.js +2 -2
- package/dist/http-Cai3IoLS.esm.js +0 -0
- package/dist/http.esm.js +1 -0
- package/dist/id-ocr.d.ts +54 -54
- package/dist/id-ocr.esm.js +5 -5
- package/dist/id-verification.d.ts +27 -27
- package/dist/id-verification.esm.js +4 -4
- package/dist/id.d.ts +12 -10
- package/dist/id.esm.js +36 -26
- package/dist/{idCaptureManager-Fyd0eam-.d.ts → idCaptureManager-D-QYESvF.d.ts} +28 -14
- package/dist/{idCaptureManager-D0ktk7Hh.esm.js → idCaptureManager-DGVv5l1_.esm.js} +22 -7
- package/dist/{idCaptureStateMachine-dwlBUjbC.esm.js → idCaptureStateMachine-DHi7HydI.esm.js} +172 -123
- package/dist/{idOcrStateMachine-YbjjC_Gg.esm.js → idOcrStateMachine-CDQ5d_VM.esm.js} +4 -4
- package/dist/{idVerificationStateMachine-xbw9HP1Z.esm.js → idVerificationStateMachine-kRxwImzO.esm.js} +2 -2
- package/dist/identity-reuse.d.ts +4 -530
- package/dist/identity-reuse.esm.js +8 -274
- package/dist/identityReuseManager-C6n_97dw.esm.js +95 -0
- package/dist/identityReuseManager-DwLtVzUn.d.ts +428 -0
- package/dist/identityReuseStateMachine-BfE5YiEr.esm.js +148 -0
- package/dist/{index-BcRG8rtJ.d.ts → index-B5hPA0Bg.d.ts} +2 -2
- package/dist/{index-ChHWNH48.d.ts → index-B9NysVDB.d.ts} +469 -195
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +10 -8
- package/dist/{invokeOnCaptureCallback-rc6kBHo5.esm.js → invokeOnCaptureCallback-ygByVdnn.esm.js} +1 -1
- package/dist/{lib-BB0B_qQX.esm.js → lib-BY67lgbq.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +8 -412
- package/dist/mandatory-consent.esm.js +6 -76
- package/dist/mandatoryConsentManager-H6D18cZB.esm.js +89 -0
- package/dist/mandatoryConsentManager-KfIlURRY.d.ts +429 -0
- package/dist/{mandatoryConsentStateMachine-Cnco1jvn.esm.js → mandatoryConsentStateMachine-DtQNW1ji.esm.js} +6 -6
- package/dist/openviduLazy-B8L--0oe.esm.js +3 -0
- package/dist/{openviduLazy-Cok70ZSg.esm.js → openviduLazy-Dh14JNJc.esm.js} +2 -2
- package/dist/otp-CGMdUzBC.esm.js +33 -0
- package/dist/otp-DF5A0sFx.d.ts +8 -0
- package/dist/permissionGuards-C1ispV96.esm.js +23 -0
- package/dist/permissionServices-CG3bMSfG.esm.js +130 -0
- package/dist/phone.d.ts +4 -3
- package/dist/phone.esm.js +6 -5
- package/dist/{phoneManager-DAJbGhlY.esm.js → phoneManager-BmF-0Ez4.esm.js} +30 -7
- package/dist/{phoneManager-B6M30hKE.d.ts → phoneManager-fPmIBYQK.d.ts} +65 -7
- package/dist/{phoneStateMachine-CuPARRaT.esm.js → phoneStateMachine-BiV0yoEx.esm.js} +46 -11
- package/dist/{qe-signature-DFo_Cc-I.esm.js → qe-signature-CUYPcHVo.esm.js} +1 -1
- package/dist/qe-signature.d.ts +3 -3
- package/dist/qe-signature.esm.js +6 -5
- package/dist/{recordingService-Ig2UgbLv.esm.js → recordingService-Bn9EdCmz.esm.js} +197 -179
- package/dist/redirect-to-mobile.d.ts +6 -104
- package/dist/redirect-to-mobile.esm.js +6 -99
- package/dist/redirectToMobileManager-BNe3IzC_.d.ts +178 -0
- package/dist/redirectToMobileManager-Dy3t7o0C.esm.js +159 -0
- package/dist/{redirectToMobileStateMachine-BOEqe46A.esm.js → redirectToMobileStateMachine-DyAdRxfP.esm.js} +28 -19
- package/dist/{runChildModule-CqqwqAkW.esm.js → runChildModule-CuoHZ1cx.esm.js} +35 -3
- package/dist/selfie.d.ts +13 -11
- package/dist/selfie.esm.js +27 -23
- package/dist/{selfieManager-Duisl7qN.esm.js → selfieManager-BjCoKRy0.esm.js} +6 -6
- package/dist/{selfieManager-D0lSgd-J.d.ts → selfieManager-dUbKRzOh.d.ts} +4 -4
- package/dist/{selfieStateMachine-D76whWEf.esm.js → selfieStateMachine-b4F2q9zw.esm.js} +5 -3
- package/dist/session-DoVb-OcB.esm.js +152 -0
- package/dist/session.d.ts +37 -5
- package/dist/session.esm.js +12 -7
- package/dist/sessionInitializer-B8H5MsXM.esm.js +366 -0
- package/dist/{setup-C5AITV8m.d.ts → setup-BbkprdVv.d.ts} +57 -6
- package/dist/{setup-DPPAxmXf.esm.js → setup-BqEfrdja.esm.js} +162 -24
- package/dist/signature.d.ts +2 -2
- package/dist/signature.esm.js +4 -4
- package/dist/{signatureStateMachine-B5-QVUve.esm.js → signatureStateMachine-C5qqYLRz.esm.js} +3 -3
- package/dist/stats-BMNUG1AU.esm.js +41 -0
- package/dist/stats.d.ts +13 -2
- package/dist/stats.esm.js +3 -2
- package/dist/trust-graph.d.ts +33 -4
- package/dist/trust-graph.esm.js +21 -15
- package/dist/{types-CFV9G_7j.d.ts → types-Bj9hdFjU.d.ts} +1 -1
- package/dist/{types-BP1m8VRw.d.ts → types-DOUhndhT.d.ts} +14 -2
- package/dist/types-DsnEVMhr.esm.js +34 -0
- package/dist/types-DvGZI7BF.d.ts +131 -0
- package/dist/{types-B06Ypu2F.d.ts → types-NuT8ftBV.d.ts} +1 -1
- package/dist/types-ya0LN_MX.d.ts +5 -0
- package/dist/{warmup-CEcppFiS.d.ts → warmup-Dg8Lh-50.d.ts} +8 -0
- package/dist/wasm.d.ts +6 -4
- package/dist/wasm.esm.js +11 -9
- package/dist/watchlist-for-business.d.ts +1 -1
- package/dist/watchlist-for-business.esm.js +5 -73
- package/dist/watchlist.d.ts +1 -1
- package/dist/watchlist.esm.js +4 -41
- package/dist/watchlistForBusinessStateMachine-DMl8j2Ov.esm.js +74 -0
- package/dist/watchlistStateMachine-DmQlqI6L.esm.js +50 -0
- package/dist/workflow.d.ts +150 -97
- package/dist/workflow.esm.js +156 -80
- package/package.json +19 -1
- package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
- package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
- package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
- package/dist/deepsightService-O74l4Y__.esm.js +0 -489
- package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
- package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
- package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
- package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
- package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
- package/dist/stats-CIfiPzb1.esm.js +0 -16
- package/dist/types-CAD4va6a.d.ts +0 -5
- package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
- /package/dist/{Actor-CI32dTbG.d.ts → Actor-Y0_Fj-KL.d.ts} +0 -0
- /package/dist/{ITimerCapability-C67ZRskg.esm.js → ITimerCapability-CB0I1Uf2.esm.js} +0 -0
- /package/dist/{Manager-C8PrhBOx.d.ts → Manager-BHn8wH8K.d.ts} +0 -0
- /package/dist/{camera-PA2Ljri3.esm.js → camera-DJWm3V4g.esm.js} +0 -0
- /package/dist/{camera-DBSxa6ML.d.ts → camera-SRBpPq2X.d.ts} +0 -0
- /package/dist/{chunk-CRF6K_H_.esm.js → chunk-CMUKZ2uL.esm.js} +0 -0
- /package/dist/{cpf-PPz2Njto.esm.js → cpf-BRzggV8G.esm.js} +0 -0
- /package/dist/{dateUtils-UoN5xswP.esm.js → dateUtils-AksLQmgV.esm.js} +0 -0
- /package/dist/{platform-CfrjKhmi.esm.js → platform-SKvEfCBh.esm.js} +0 -0
- /package/dist/{xstate.esm-B70JrNqo.esm.js → xstate.esm-C9wncMQa.esm.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Manager } from "./Manager-
|
|
2
|
-
import { c as SelfieActor, n as FaceCaptureManagerState, s as CreateSelfieActorOptions, t as FaceCaptureManager } from "./faceCaptureManagerFactory-
|
|
1
|
+
import { t as Manager } from "./Manager-BHn8wH8K.js";
|
|
2
|
+
import { c as SelfieActor, n as FaceCaptureManagerState, s as CreateSelfieActorOptions, t as FaceCaptureManager } from "./faceCaptureManagerFactory-C_hRHx8a.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/selfie/selfieUploadService.d.ts
|
|
5
5
|
type ProcessFaceImageType = 'selfie' | 'videoSelfie';
|
|
@@ -14,7 +14,7 @@ declare function processFace(imageType?: ProcessFaceImageType, signal?: AbortSig
|
|
|
14
14
|
type SelfieState = FaceCaptureManagerState;
|
|
15
15
|
declare function createSelfieManagerFromActor(actor: SelfieActor): Manager<FaceCaptureManagerState> & {
|
|
16
16
|
load(): void;
|
|
17
|
-
nextStep(): void
|
|
17
|
+
nextStep(): Promise<void>;
|
|
18
18
|
requestPermission(): void;
|
|
19
19
|
goToLearnMore(): void;
|
|
20
20
|
back(): void;
|
|
@@ -54,7 +54,7 @@ declare function createSelfieManagerFromActor(actor: SelfieActor): Manager<FaceC
|
|
|
54
54
|
*/
|
|
55
55
|
declare function createSelfieManager(options: CreateSelfieActorOptions): Manager<FaceCaptureManagerState> & {
|
|
56
56
|
load(): void;
|
|
57
|
-
nextStep(): void
|
|
57
|
+
nextStep(): Promise<void>;
|
|
58
58
|
requestPermission(): void;
|
|
59
59
|
goToLearnMore(): void;
|
|
60
60
|
back(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as fromPromise, r as assign } from "./xstate.esm-
|
|
2
|
-
import { a as prepareOnDeviceFaceUpload,
|
|
3
|
-
import {
|
|
1
|
+
import { a as fromPromise, r as assign } from "./xstate.esm-C9wncMQa.esm.js";
|
|
2
|
+
import { a as defaultPrepareFaceUpload, c as prepareOnDeviceFaceUpload, h as uploadSelfie, m as processFace, o as isOnDeviceMode, s as postOnDeviceFaceResults } from "./recordingService-Bn9EdCmz.esm.js";
|
|
3
|
+
import { t as FACE_ERROR_CODES } from "./types-DsnEVMhr.esm.js";
|
|
4
|
+
import { t as faceCaptureMachine } from "./faceCaptureSetup-CtvHWd3x.esm.js";
|
|
4
5
|
|
|
5
6
|
//#region src/modules/selfie/selfieErrorUtils.ts
|
|
6
7
|
const FACE_ERROR_CODE_VALUES = Object.values(FACE_ERROR_CODES);
|
|
@@ -30,6 +31,7 @@ const _selfieMachine = faceCaptureMachine.provide({
|
|
|
30
31
|
faceCoordinates: ctx.faceCoordinates,
|
|
31
32
|
metadata: ctx.deepsightService?.getMetadata(),
|
|
32
33
|
recordingId: ctx.uploadRecordingId,
|
|
34
|
+
deepsightService: ctx.deepsightService ?? void 0,
|
|
33
35
|
signal
|
|
34
36
|
});
|
|
35
37
|
}),
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { n as getApi } from "./api-CESGtpbH.esm.js";
|
|
2
|
+
import { t as endpoints } from "./endpoints-BeTK0Mlt.esm.js";
|
|
3
|
+
import { n as toIncodeApiError } from "./apiError-B-j-gyDx.esm.js";
|
|
4
|
+
|
|
5
|
+
//#region src/internal/session/sessionService.ts
|
|
6
|
+
/**
|
|
7
|
+
* HTTP status codes the QR validation endpoint emits, keyed by their semantic
|
|
8
|
+
* name. Hosts switch on these to render distinct messaging — `invalidQRuuid`
|
|
9
|
+
* for an unknown/expired link, `onboardingUrlAlreadyUsed` for a one-time link
|
|
10
|
+
* that has already been consumed.
|
|
11
|
+
*/
|
|
12
|
+
const QR_VALIDATION_ERROR_CODES = {
|
|
13
|
+
expiredUUID: 4026,
|
|
14
|
+
invalidQRuuid: 4081,
|
|
15
|
+
onboardingUrlAlreadyUsed: 4083
|
|
16
|
+
};
|
|
17
|
+
var QrValidationError = class extends Error {
|
|
18
|
+
constructor(status, statusText) {
|
|
19
|
+
super(`POST ${endpoints.qrValidateUuid} failed: ${status} ${statusText}`);
|
|
20
|
+
this.name = "QrValidationError";
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.statusText = statusText;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new onboarding session.
|
|
27
|
+
*
|
|
28
|
+
* @param apiKey - The API key from the Incode dashboard
|
|
29
|
+
* @param options - Session creation options
|
|
30
|
+
* @param signal - Optional AbortSignal for request cancellation
|
|
31
|
+
* @returns The created session with token
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const session = await createSession('your-api-key', {
|
|
36
|
+
* configurationId: 'your-flow-id',
|
|
37
|
+
* language: 'en-US',
|
|
38
|
+
* });
|
|
39
|
+
* console.log(session.token); // Use this token for subsequent API calls
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
async function createSession(apiKey, options, signal) {
|
|
43
|
+
try {
|
|
44
|
+
return (await getApi().post(endpoints.createSession, {
|
|
45
|
+
configurationId: options.configurationId,
|
|
46
|
+
externalId: options.externalId,
|
|
47
|
+
externalCustomerId: options.externalCustomerId,
|
|
48
|
+
language: options.language ?? "en-US",
|
|
49
|
+
customFields: options.customFields,
|
|
50
|
+
uuid: options.uuid ?? null,
|
|
51
|
+
urlUuid: options.urlUuid ?? null,
|
|
52
|
+
interviewId: options.interviewId ?? null,
|
|
53
|
+
...options.loginHint != null && options.loginHint !== "" ? { loginHint: options.loginHint } : {}
|
|
54
|
+
}, {
|
|
55
|
+
headers: {
|
|
56
|
+
"x-api-key": apiKey,
|
|
57
|
+
"api-version": "1.0"
|
|
58
|
+
},
|
|
59
|
+
signal
|
|
60
|
+
})).data;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
toIncodeApiError(endpoints.createSession, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates and rotates a QR anti-phishing URL UUID before creating a session.
|
|
67
|
+
*
|
|
68
|
+
* This call is unauthenticated; the `{ onboardingId, urlUuid }` pair itself
|
|
69
|
+
* acts as the credential. The server burns the incoming `urlUuid` and returns
|
|
70
|
+
* a freshly minted one that must be used in the subsequent `createSession`
|
|
71
|
+
* call.
|
|
72
|
+
*
|
|
73
|
+
* @param options - `{ onboardingId, urlUuid }` from the incoming URL
|
|
74
|
+
* @param signal - Optional AbortSignal for request cancellation
|
|
75
|
+
* @returns The refreshed `urlUuid` to use for the session
|
|
76
|
+
* @throws {QrValidationError} When the server rejects the validation request.
|
|
77
|
+
*/
|
|
78
|
+
async function validateQrUuid(options, signal) {
|
|
79
|
+
try {
|
|
80
|
+
return (await getApi().post(endpoints.qrValidateUuid, {
|
|
81
|
+
onboardingId: options.onboardingId,
|
|
82
|
+
urlUuid: options.urlUuid
|
|
83
|
+
}, {
|
|
84
|
+
headers: { "api-version": "1.0" },
|
|
85
|
+
signal
|
|
86
|
+
})).data;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const httpError = error;
|
|
89
|
+
throw new QrValidationError(httpError.data?.status ?? httpError.status, httpError.statusText);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* One-shot QR phishing-resistance helper.
|
|
94
|
+
*
|
|
95
|
+
* When `urlUuid` is a non-empty string, burns the stale value via
|
|
96
|
+
* `validateQrUuid`, invokes `onRefreshed` with the fresh value, and returns
|
|
97
|
+
* it so callers can forward it into `createSession`. When `urlUuid` is
|
|
98
|
+
* absent, returns `undefined` without making any network call.
|
|
99
|
+
*
|
|
100
|
+
* Consolidates the rotation + callback logic shared by Flow self-loading and
|
|
101
|
+
* Workflow token-mode bootstraps.
|
|
102
|
+
*
|
|
103
|
+
* @throws {QrValidationError} When the server rejects the validation request.
|
|
104
|
+
*/
|
|
105
|
+
async function refreshQrUrlUuid(options, signal) {
|
|
106
|
+
if (typeof options.urlUuid !== "string" || options.urlUuid.length === 0) return;
|
|
107
|
+
const result = await validateQrUuid({
|
|
108
|
+
onboardingId: options.onboardingId ?? null,
|
|
109
|
+
urlUuid: options.urlUuid
|
|
110
|
+
}, signal);
|
|
111
|
+
options.onRefreshed?.(result.urlUuid);
|
|
112
|
+
return result.urlUuid;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validates and rotates a QR anti-phishing `urlUuid` (when present), then
|
|
116
|
+
* creates a session bound to the refreshed value. When `urlUuid` is absent,
|
|
117
|
+
* behaves identically to {@link createSession}.
|
|
118
|
+
*
|
|
119
|
+
* Use this when the host owns session creation and wants the SDK to handle
|
|
120
|
+
* phishing-resistance rotation in a single call. For raw control, compose
|
|
121
|
+
* `refreshQrUrlUuid` and `createSession` directly.
|
|
122
|
+
*
|
|
123
|
+
* @throws {QrValidationError} When the server rejects the QR validation step.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const session = await bootstrapSession(apiKey, {
|
|
128
|
+
* configurationId,
|
|
129
|
+
* urlUuid,
|
|
130
|
+
* onUrlUuidRefreshed: (refreshed) => {
|
|
131
|
+
* const url = new URL(window.location.href);
|
|
132
|
+
* url.searchParams.set('url_uuid', refreshed);
|
|
133
|
+
* window.history.replaceState({}, '', url);
|
|
134
|
+
* },
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
async function bootstrapSession(apiKey, options, signal) {
|
|
139
|
+
const { onUrlUuidRefreshed, ...createSessionOptions } = options;
|
|
140
|
+
const refreshedUrlUuid = await refreshQrUrlUuid({
|
|
141
|
+
urlUuid: options.urlUuid,
|
|
142
|
+
onboardingId: options.uuid ?? null,
|
|
143
|
+
onRefreshed: onUrlUuidRefreshed
|
|
144
|
+
}, signal);
|
|
145
|
+
return createSession(apiKey, {
|
|
146
|
+
...createSessionOptions,
|
|
147
|
+
urlUuid: refreshedUrlUuid
|
|
148
|
+
}, signal);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
export { refreshQrUrlUuid as a, createSession as i, QrValidationError as n, validateQrUuid as o, bootstrapSession as r, QR_VALIDATION_ERROR_CODES as t };
|
package/dist/session.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./camera-
|
|
2
|
-
import "./types-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import "./camera-SRBpPq2X.js";
|
|
2
|
+
import "./types-Bj9hdFjU.js";
|
|
3
|
+
import "./types-DvGZI7BF.js";
|
|
4
|
+
import { a as RegulationTypes } from "./types-DOUhndhT.js";
|
|
5
|
+
import { n as GetFinishStatusFn, r as getFinishStatus, t as FinishStatus } from "./flowCompletionService-BdR2cGgB.js";
|
|
5
6
|
|
|
6
7
|
//#region src/internal/fingerprint/types.d.ts
|
|
7
8
|
|
|
@@ -39,6 +40,8 @@ type Session = {
|
|
|
39
40
|
uuid?: string;
|
|
40
41
|
regulationType?: string;
|
|
41
42
|
showMandatoryConsent?: boolean;
|
|
43
|
+
endScreenTitle?: string;
|
|
44
|
+
endScreenText?: string;
|
|
42
45
|
};
|
|
43
46
|
type ValidateQrUuidOptions = {
|
|
44
47
|
onboardingId: string | null;
|
|
@@ -149,6 +152,35 @@ declare function refreshQrUrlUuid(options: RefreshQrUrlUuidOptions, signal?: Abo
|
|
|
149
152
|
*/
|
|
150
153
|
declare function bootstrapSession(apiKey: string, options: BootstrapSessionOptions, signal?: AbortSignal): Promise<Session>;
|
|
151
154
|
//#endregion
|
|
155
|
+
//#region src/internal/http/apiError.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* Incode API error.
|
|
158
|
+
*
|
|
159
|
+
* Wraps an HTTP failure so callers can branch on the Incode-specific status
|
|
160
|
+
* code (e.g. `4028` for "Flow is not activated") and surface the server's
|
|
161
|
+
* human-readable message to the user. The Incode backend returns these on
|
|
162
|
+
* HTTP `400` responses with a body shaped:
|
|
163
|
+
*
|
|
164
|
+
* ```json
|
|
165
|
+
* { "status": 4028, "error": "Flow is not activated.", "message": "...", "path": "/0/omni/start" }
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* - `status` — prefers the body's Incode status code, falls back to the HTTP
|
|
169
|
+
* status when the body doesn't carry one.
|
|
170
|
+
* - `httpStatus` — always the underlying HTTP status.
|
|
171
|
+
* - `cause` — the original `HttpError` (typically `FetchHttpError`) is
|
|
172
|
+
* preserved on the standard ES `Error.cause` slot, so core consumers that
|
|
173
|
+
* need `url` / `method` / `headers` / raw `data` can read them via
|
|
174
|
+
* `err.cause`.
|
|
175
|
+
*/
|
|
176
|
+
declare class IncodeApiError extends Error {
|
|
177
|
+
readonly status: number;
|
|
178
|
+
readonly httpStatus: number;
|
|
179
|
+
readonly endpoint: string;
|
|
180
|
+
readonly cause?: unknown;
|
|
181
|
+
constructor(endpoint: string, status: number, httpStatus: number, message: string, cause?: unknown);
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
152
184
|
//#region src/internal/featureConfig/types.d.ts
|
|
153
185
|
type FeatureName = 'VIDEO_SELFIE_V2' | 'USE_CLIENT_GLARE' | 'USE_OPEN_VIDU' | 'DISABLE_IPIFY';
|
|
154
186
|
type FeatureConfig = {
|
|
@@ -214,4 +246,4 @@ type SessionInitResult = {
|
|
|
214
246
|
*/
|
|
215
247
|
declare function initializeSession(options?: SessionInitOptions): Promise<SessionInitResult>;
|
|
216
248
|
//#endregion
|
|
217
|
-
export { type BootstrapSessionOptions, type CreateSessionOptions, type FinishStatus, type GetFinishStatusFn, QR_VALIDATION_ERROR_CODES, QrValidationError, type QrValidationErrorCode, type QrValidationResult, type RefreshQrUrlUuidOptions, type Session, type SessionInitOptions, type SessionInitResult, type ValidateQrUuidOptions, bootstrapSession, createSession, getFinishStatus, initializeSession, refreshQrUrlUuid, validateQrUuid };
|
|
249
|
+
export { type BootstrapSessionOptions, type CreateSessionOptions, type FinishStatus, type GetFinishStatusFn, IncodeApiError, QR_VALIDATION_ERROR_CODES, QrValidationError, type QrValidationErrorCode, type QrValidationResult, type RefreshQrUrlUuidOptions, type Session, type SessionInitOptions, type SessionInitResult, type ValidateQrUuidOptions, bootstrapSession, createSession, getFinishStatus, initializeSession, refreshQrUrlUuid, validateQrUuid };
|
package/dist/session.esm.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import "./api-CESGtpbH.esm.js";
|
|
2
|
-
import "./events-
|
|
3
|
-
import "./endpoints-
|
|
4
|
-
import
|
|
5
|
-
import "./IpifyProvider-
|
|
6
|
-
import "./browserSimulation-
|
|
7
|
-
import {
|
|
2
|
+
import "./events-Dvvriq9l.esm.js";
|
|
3
|
+
import "./endpoints-BeTK0Mlt.esm.js";
|
|
4
|
+
import "./stats-BMNUG1AU.esm.js";
|
|
5
|
+
import "./IpifyProvider-D4LWD15E.esm.js";
|
|
6
|
+
import "./browserSimulation-B1dWiXp7.esm.js";
|
|
7
|
+
import { r as initializeSession } from "./sessionInitializer-B8H5MsXM.esm.js";
|
|
8
|
+
import "./platform-SKvEfCBh.esm.js";
|
|
9
|
+
import "./getBrowser-C8DP7oTB.esm.js";
|
|
10
|
+
import { t as IncodeApiError } from "./apiError-B-j-gyDx.esm.js";
|
|
11
|
+
import { a as refreshQrUrlUuid, i as createSession, n as QrValidationError, o as validateQrUuid, r as bootstrapSession, t as QR_VALIDATION_ERROR_CODES } from "./session-DoVb-OcB.esm.js";
|
|
12
|
+
import { t as getFinishStatus } from "./flowCompletionService-DdGojV9K.esm.js";
|
|
8
13
|
|
|
9
|
-
export { QR_VALIDATION_ERROR_CODES, QrValidationError, bootstrapSession, createSession, getFinishStatus, initializeSession, refreshQrUrlUuid, validateQrUuid };
|
|
14
|
+
export { IncodeApiError, QR_VALIDATION_ERROR_CODES, QrValidationError, bootstrapSession, createSession, getFinishStatus, initializeSession, refreshQrUrlUuid, validateQrUuid };
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { r as getToken, s as setToken, t as api } from "./api-CESGtpbH.esm.js";
|
|
2
|
+
import { g as getAnalyticsBatcher, h as addEvent } from "./events-Dvvriq9l.esm.js";
|
|
3
|
+
import { t as endpoints } from "./endpoints-BeTK0Mlt.esm.js";
|
|
4
|
+
import { n as flushDeviceStatsQueue, r as resetDeviceStatsQueue } from "./stats-BMNUG1AU.esm.js";
|
|
5
|
+
import { n as resetIpifyCache, r as BrowserEnvironmentProvider, t as IpifyProvider } from "./IpifyProvider-D4LWD15E.esm.js";
|
|
6
|
+
import { i as UAParser, n as getThumbmarkId, r as getParsedUserAgent, t as isBrowserSimulation } from "./browserSimulation-B1dWiXp7.esm.js";
|
|
7
|
+
|
|
8
|
+
//#region ../infra/src/providers/browser/BrowserInfoProvider.ts
|
|
9
|
+
var BrowserInfoProvider = class {
|
|
10
|
+
checkWebRtcSupport() {
|
|
11
|
+
if (typeof window === "undefined") return false;
|
|
12
|
+
const hasRTCPeerConnection = "RTCPeerConnection" in window || "webkitRTCPeerConnection" in window || "mozRTCPeerConnection" in window;
|
|
13
|
+
const hasGetUserMedia = typeof navigator !== "undefined" && navigator.mediaDevices?.getUserMedia !== void 0;
|
|
14
|
+
return hasRTCPeerConnection && hasGetUserMedia;
|
|
15
|
+
}
|
|
16
|
+
getBrowserInfo() {
|
|
17
|
+
const userAgent = typeof navigator !== "undefined" ? navigator.userAgent : "";
|
|
18
|
+
const result = new UAParser(userAgent).getResult();
|
|
19
|
+
return {
|
|
20
|
+
userAgent,
|
|
21
|
+
isWebRtcSupported: this.checkWebRtcSupport(),
|
|
22
|
+
browser: {
|
|
23
|
+
name: result.browser.name,
|
|
24
|
+
version: result.browser.version
|
|
25
|
+
},
|
|
26
|
+
os: {
|
|
27
|
+
name: result.os.name,
|
|
28
|
+
version: result.os.version
|
|
29
|
+
},
|
|
30
|
+
device: {
|
|
31
|
+
model: result.device.model,
|
|
32
|
+
type: result.device.type,
|
|
33
|
+
vendor: result.device.vendor
|
|
34
|
+
},
|
|
35
|
+
engine: {
|
|
36
|
+
name: result.engine.name,
|
|
37
|
+
version: result.engine.version
|
|
38
|
+
},
|
|
39
|
+
cpu: { architecture: result.cpu.architecture }
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../infra/src/device/getDeviceData.ts
|
|
46
|
+
const HIGH_ENTROPY_HINTS = new Set([
|
|
47
|
+
"model",
|
|
48
|
+
"platformVersion",
|
|
49
|
+
"fullVersionList",
|
|
50
|
+
"brands",
|
|
51
|
+
"platform"
|
|
52
|
+
]);
|
|
53
|
+
function getFallbackDeviceInfo() {
|
|
54
|
+
const parsed = getParsedUserAgent();
|
|
55
|
+
return {
|
|
56
|
+
device: { model: parsed.device.model },
|
|
57
|
+
os: {
|
|
58
|
+
name: parsed.os.name,
|
|
59
|
+
version: parsed.os.version
|
|
60
|
+
},
|
|
61
|
+
browser: {
|
|
62
|
+
name: parsed.browser.name,
|
|
63
|
+
version: parsed.browser.version
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function sanitizeString(value) {
|
|
68
|
+
return value?.trim() || void 0;
|
|
69
|
+
}
|
|
70
|
+
function extractPrimaryBrandInfo(fullVersionList, brands) {
|
|
71
|
+
const primaryBrand = fullVersionList?.[0] || brands?.[0];
|
|
72
|
+
return {
|
|
73
|
+
name: sanitizeString(primaryBrand?.brand),
|
|
74
|
+
version: sanitizeString(primaryBrand?.version)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function getHighEntropyDeviceInfo(userAgentData) {
|
|
78
|
+
const highEntropyValues = await userAgentData.getHighEntropyValues(Array.from(HIGH_ENTROPY_HINTS));
|
|
79
|
+
const { name: browserName, version: browserVersion } = extractPrimaryBrandInfo(highEntropyValues.fullVersionList, userAgentData.brands);
|
|
80
|
+
return {
|
|
81
|
+
device: { model: sanitizeString(highEntropyValues.model) },
|
|
82
|
+
os: {
|
|
83
|
+
name: sanitizeString(highEntropyValues.platform),
|
|
84
|
+
version: sanitizeString(highEntropyValues.platformVersion)
|
|
85
|
+
},
|
|
86
|
+
browser: {
|
|
87
|
+
name: browserName,
|
|
88
|
+
version: browserVersion
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const checkForUnbrandedBrowser = (browser) => {
|
|
93
|
+
const userAgent = typeof navigator !== "undefined" ? navigator.userAgent : "";
|
|
94
|
+
const fallback = getFallbackDeviceInfo();
|
|
95
|
+
if (!userAgent) return browser;
|
|
96
|
+
try {
|
|
97
|
+
return {
|
|
98
|
+
...browser,
|
|
99
|
+
name: fallback.browser.name,
|
|
100
|
+
version: fallback.browser.version
|
|
101
|
+
};
|
|
102
|
+
} catch {
|
|
103
|
+
return {
|
|
104
|
+
...browser,
|
|
105
|
+
name: "Unknown",
|
|
106
|
+
version: "Unknown"
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function mergeDeviceInfo(fallback, enhanced) {
|
|
111
|
+
return {
|
|
112
|
+
device: { model: enhanced.device?.model || fallback.device.model },
|
|
113
|
+
os: {
|
|
114
|
+
name: enhanced.os?.name || fallback.os.name,
|
|
115
|
+
version: enhanced.os?.version || fallback.os.version
|
|
116
|
+
},
|
|
117
|
+
browser: checkForUnbrandedBrowser({
|
|
118
|
+
name: enhanced.browser?.name || fallback.browser.name,
|
|
119
|
+
version: enhanced.browser?.version || fallback.browser.version
|
|
120
|
+
})
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function isUserAgentClientHintsSupported(navigator$1) {
|
|
124
|
+
return Boolean(navigator$1.userAgentData?.getHighEntropyValues && typeof navigator$1.userAgentData.getHighEntropyValues === "function");
|
|
125
|
+
}
|
|
126
|
+
async function getDeviceFingerprintInfo() {
|
|
127
|
+
if (typeof navigator === "undefined") return {
|
|
128
|
+
device: {},
|
|
129
|
+
os: {},
|
|
130
|
+
browser: {}
|
|
131
|
+
};
|
|
132
|
+
const customNavigator = navigator;
|
|
133
|
+
const fallbackInfo = getFallbackDeviceInfo();
|
|
134
|
+
if (!isUserAgentClientHintsSupported(customNavigator)) return fallbackInfo;
|
|
135
|
+
try {
|
|
136
|
+
return mergeDeviceInfo(fallbackInfo, await getHighEntropyDeviceInfo(customNavigator.userAgentData));
|
|
137
|
+
} catch {
|
|
138
|
+
return fallbackInfo;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region ../infra/src/providers/browser/FingerprintProvider.ts
|
|
144
|
+
var FingerprintProvider = class {
|
|
145
|
+
constructor(ipLookup) {
|
|
146
|
+
this.ipLookup = ipLookup;
|
|
147
|
+
}
|
|
148
|
+
async getFingerprint(disableIpify = false) {
|
|
149
|
+
const visitorId = await getThumbmarkId();
|
|
150
|
+
const [deviceInfo, ip] = await Promise.all([getDeviceFingerprintInfo(), disableIpify ? Promise.resolve("") : this.ipLookup.getIp()]);
|
|
151
|
+
return {
|
|
152
|
+
visitorId,
|
|
153
|
+
ip,
|
|
154
|
+
deviceInfo
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/internal/featureConfig/featureConfigService.ts
|
|
161
|
+
let cachedFeatures$1 = null;
|
|
162
|
+
/**
|
|
163
|
+
* Checks if a feature is enabled in the feature config.
|
|
164
|
+
*/
|
|
165
|
+
function isFeatureEnabled(feature, features) {
|
|
166
|
+
return features?.find((f) => f.feature === feature)?.enabled ?? false;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Fetches feature configuration from the backend.
|
|
170
|
+
* Results are cached for the session lifetime.
|
|
171
|
+
*/
|
|
172
|
+
async function fetchFeatureConfig(signal) {
|
|
173
|
+
if (cachedFeatures$1) return cachedFeatures$1;
|
|
174
|
+
const response = await api.get(endpoints.featureConfig, { signal });
|
|
175
|
+
if (!response.ok) throw new Error(`Failed to fetch feature config: ${response.status} ${response.statusText}`);
|
|
176
|
+
cachedFeatures$1 = response.data;
|
|
177
|
+
return cachedFeatures$1;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Resets the cached feature config (useful for testing).
|
|
181
|
+
*/
|
|
182
|
+
function resetFeatureConfigCache() {
|
|
183
|
+
cachedFeatures$1 = null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/internal/version/sdkVersion.ts
|
|
188
|
+
const SDK_VERSION = "2.1.0-rc.0";
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/internal/fingerprint/fingerprintService.ts
|
|
192
|
+
function formatOsVersion(os) {
|
|
193
|
+
return `${os.name || "Unknown"} ${os.version || ""}`.trim();
|
|
194
|
+
}
|
|
195
|
+
function formatBrowser(browser) {
|
|
196
|
+
if (!browser.name || !browser.version) return "Unknown";
|
|
197
|
+
return `${browser.name} ${browser.version}`;
|
|
198
|
+
}
|
|
199
|
+
async function submitDeviceFingerprint(options = {}, dependencies) {
|
|
200
|
+
const { disableIpify = false, hostingApp, signal } = options;
|
|
201
|
+
const fingerprint = await dependencies.fingerprintProvider.getFingerprint(disableIpify);
|
|
202
|
+
const hasLiedBrowser = isBrowserSimulation(dependencies.browserEnv);
|
|
203
|
+
const payload = {
|
|
204
|
+
hash: fingerprint.visitorId || "",
|
|
205
|
+
ip: fingerprint.ip || "",
|
|
206
|
+
deviceType: "WEBAPP",
|
|
207
|
+
data: JSON.stringify(fingerprint),
|
|
208
|
+
osVersion: formatOsVersion(fingerprint.deviceInfo.os),
|
|
209
|
+
deviceModel: fingerprint.deviceInfo.device.model || "",
|
|
210
|
+
browser: formatBrowser(fingerprint.deviceInfo.browser),
|
|
211
|
+
hasLiedBrowser,
|
|
212
|
+
sdkVersion: SDK_VERSION,
|
|
213
|
+
hostingApp: hostingApp ?? "Web SDK"
|
|
214
|
+
};
|
|
215
|
+
const response = await api.post(endpoints.deviceFingerprint, payload, { signal });
|
|
216
|
+
if (!response.ok) throw new Error(`Failed to submit fingerprint: ${response.status} ${response.statusText}`);
|
|
217
|
+
return response.data;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/internal/session/sessionInitializer.ts
|
|
222
|
+
let sessionInitialized = false;
|
|
223
|
+
let cachedFeatures = null;
|
|
224
|
+
let cachedDisableIpify = false;
|
|
225
|
+
let clientIpLookupEnabled = true;
|
|
226
|
+
function setClientIpLookupEnabled(enabled) {
|
|
227
|
+
clientIpLookupEnabled = enabled;
|
|
228
|
+
}
|
|
229
|
+
function resolveDisableIpify(serverDisableIpify) {
|
|
230
|
+
return !clientIpLookupEnabled || serverDisableIpify;
|
|
231
|
+
}
|
|
232
|
+
let cachedFingerprintSuccess = false;
|
|
233
|
+
let cachedFingerprintResult;
|
|
234
|
+
let sessionInitPromise = null;
|
|
235
|
+
/**
|
|
236
|
+
* Activates a session by setting the auth token on the HTTP client and
|
|
237
|
+
* preloading session-scoped state.
|
|
238
|
+
*
|
|
239
|
+
* Performs:
|
|
240
|
+
* 1. Sets the token (and clears stale session-init cache if the token changed)
|
|
241
|
+
* 2. Fetches feature configuration from backend
|
|
242
|
+
* 3. Submits device fingerprint
|
|
243
|
+
* 4. Starts the analytics batcher so buffered events are flushed
|
|
244
|
+
*
|
|
245
|
+
* Results are cached per token. Calling again with the same token returns the
|
|
246
|
+
* cached result; calling with a different token re-initializes from scratch.
|
|
247
|
+
*
|
|
248
|
+
* @param options - Session activation options (`token` required)
|
|
249
|
+
* @returns Session initialization result with feature config
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* await setup({ apiURL: 'https://api.incode.com' });
|
|
254
|
+
* const session = await createSession('api-key', options);
|
|
255
|
+
* const { features } = await initializeSession({ token: session.token });
|
|
256
|
+
*
|
|
257
|
+
* // Check feature flags
|
|
258
|
+
* if (isFeatureEnabled('DISABLE_IPIFY', features.features)) {
|
|
259
|
+
* // Handle disabled ipify
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
async function initializeSession(options = {}) {
|
|
264
|
+
const { token, hostingApp, signal } = options;
|
|
265
|
+
if (token !== void 0 && token !== getToken()) {
|
|
266
|
+
setToken(token);
|
|
267
|
+
resetSessionInit();
|
|
268
|
+
}
|
|
269
|
+
if (sessionInitialized && cachedFeatures) return {
|
|
270
|
+
features: cachedFeatures,
|
|
271
|
+
disableIpify: cachedDisableIpify,
|
|
272
|
+
fingerprintSuccess: cachedFingerprintSuccess,
|
|
273
|
+
fingerprintResult: cachedFingerprintResult
|
|
274
|
+
};
|
|
275
|
+
if (sessionInitPromise) return sessionInitPromise;
|
|
276
|
+
sessionInitPromise = (async () => {
|
|
277
|
+
let features;
|
|
278
|
+
let serverDisableIpify = false;
|
|
279
|
+
try {
|
|
280
|
+
features = await fetchFeatureConfig(signal);
|
|
281
|
+
serverDisableIpify = isFeatureEnabled("DISABLE_IPIFY", features.features);
|
|
282
|
+
} catch {
|
|
283
|
+
features = { sessionIdentifier: "" };
|
|
284
|
+
}
|
|
285
|
+
const disableIpify = resolveDisableIpify(serverDisableIpify);
|
|
286
|
+
let fingerprintSuccess = false;
|
|
287
|
+
let fingerprintResult;
|
|
288
|
+
try {
|
|
289
|
+
const fingerprintProvider = new FingerprintProvider(new IpifyProvider());
|
|
290
|
+
const browserEnv = new BrowserEnvironmentProvider();
|
|
291
|
+
fingerprintResult = await submitDeviceFingerprint({
|
|
292
|
+
disableIpify,
|
|
293
|
+
hostingApp,
|
|
294
|
+
signal
|
|
295
|
+
}, {
|
|
296
|
+
fingerprintProvider,
|
|
297
|
+
browserEnv
|
|
298
|
+
});
|
|
299
|
+
fingerprintSuccess = true;
|
|
300
|
+
flushDeviceStatsQueue();
|
|
301
|
+
} catch (error) {
|
|
302
|
+
console.warn("Failed to submit device fingerprint:", error);
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
const browserInfo = new BrowserInfoProvider().getBrowserInfo();
|
|
306
|
+
addEvent({
|
|
307
|
+
code: "browser",
|
|
308
|
+
payload: {
|
|
309
|
+
userAgent: browserInfo.userAgent,
|
|
310
|
+
isWebRtcSupported: browserInfo.isWebRtcSupported,
|
|
311
|
+
browser: browserInfo.browser,
|
|
312
|
+
os: browserInfo.os,
|
|
313
|
+
device: browserInfo.device,
|
|
314
|
+
engine: browserInfo.engine,
|
|
315
|
+
cpu: browserInfo.cpu
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.warn("Failed to send browser info event:", error);
|
|
320
|
+
}
|
|
321
|
+
sessionInitialized = true;
|
|
322
|
+
cachedFeatures = features;
|
|
323
|
+
cachedDisableIpify = disableIpify;
|
|
324
|
+
cachedFingerprintSuccess = fingerprintSuccess;
|
|
325
|
+
cachedFingerprintResult = fingerprintResult;
|
|
326
|
+
return {
|
|
327
|
+
features,
|
|
328
|
+
disableIpify,
|
|
329
|
+
fingerprintSuccess,
|
|
330
|
+
fingerprintResult
|
|
331
|
+
};
|
|
332
|
+
})().finally(() => {
|
|
333
|
+
sessionInitPromise = null;
|
|
334
|
+
getAnalyticsBatcher()?.start();
|
|
335
|
+
});
|
|
336
|
+
return sessionInitPromise;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Gets the cached disableIpify flag.
|
|
340
|
+
* Returns false if session hasn't been initialized.
|
|
341
|
+
*/
|
|
342
|
+
function getDisableIpify() {
|
|
343
|
+
if (!clientIpLookupEnabled) return true;
|
|
344
|
+
return cachedDisableIpify;
|
|
345
|
+
}
|
|
346
|
+
function getSessionFingerprintResult() {
|
|
347
|
+
return cachedFingerprintResult;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Resets session initialization state.
|
|
351
|
+
* Useful for testing or when starting a new session.
|
|
352
|
+
*/
|
|
353
|
+
function resetSessionInit() {
|
|
354
|
+
sessionInitialized = false;
|
|
355
|
+
cachedFeatures = null;
|
|
356
|
+
cachedDisableIpify = false;
|
|
357
|
+
cachedFingerprintSuccess = false;
|
|
358
|
+
cachedFingerprintResult = void 0;
|
|
359
|
+
sessionInitPromise = null;
|
|
360
|
+
resetFeatureConfigCache();
|
|
361
|
+
resetIpifyCache();
|
|
362
|
+
resetDeviceStatsQueue();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
export { setClientIpLookupEnabled as a, resetSessionInit as i, getSessionFingerprintResult as n, FingerprintProvider as o, initializeSession as r, getDeviceFingerprintInfo as s, getDisableIpify as t };
|