@incodetech/core 0.0.0-dev-20260313-2675d26 → 0.0.0-dev-20260313-486e658

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/authentication.d.ts +9 -9
  2. package/dist/authentication.esm.js +10 -10
  3. package/dist/{backCameraStream-DXS4n4yS.esm.js → backCameraStream-B57NWDGu.esm.js} +1 -1
  4. package/dist/curp-validation.d.ts +4 -4
  5. package/dist/curp-validation.esm.js +5 -5
  6. package/dist/{deepsightLoader-CCuD-pzB.esm.js → deepsightLoader-BXTRzhYx.esm.js} +4 -4
  7. package/dist/{deepsightService-D2rnPj53.esm.js → deepsightService-CTK55DG8.esm.js} +3 -3
  8. package/dist/{deepsightService-Dv1ILk27.d.ts → deepsightService-CYCDsan2.d.ts} +1 -1
  9. package/dist/document-capture.d.ts +49 -49
  10. package/dist/document-capture.esm.js +6 -6
  11. package/dist/document-upload.d.ts +49 -49
  12. package/dist/document-upload.esm.js +5 -5
  13. package/dist/ekyb.d.ts +2 -2
  14. package/dist/ekyb.esm.js +6 -6
  15. package/dist/ekyc.d.ts +2 -2
  16. package/dist/ekyc.esm.js +6 -6
  17. package/dist/email.d.ts +1 -1
  18. package/dist/email.esm.js +5 -5
  19. package/dist/{endpoints-PMCuQkqs.esm.js → endpoints-5sPFFmaB.esm.js} +4 -1
  20. package/dist/{events-Bf73PAdv.esm.js → events-b4_xvENs.esm.js} +2 -2
  21. package/dist/face-match.d.ts +1 -1
  22. package/dist/face-match.esm.js +5 -5
  23. package/dist/{faceCaptureManagerFactory-FEuTMK4j.d.ts → faceCaptureManagerFactory-D1NUo68Z.d.ts} +5 -5
  24. package/dist/{faceCaptureSetup-pxm6Cjua.esm.js → faceCaptureSetup-10lCb_yE.esm.js} +9 -9
  25. package/dist/flow.d.ts +14 -7
  26. package/dist/flow.esm.js +9 -5
  27. package/dist/{flowCompletionService-C2Cjw8WY.esm.js → flowCompletionService-DHXqHOAk.esm.js} +2 -2
  28. package/dist/geolocation.d.ts +1 -1
  29. package/dist/geolocation.esm.js +5 -5
  30. package/dist/government-validation.d.ts +1 -1
  31. package/dist/government-validation.esm.js +4 -4
  32. package/dist/{id-aQ6PcfVo.esm.js → id-TUJyOPso.esm.js} +14 -12
  33. package/dist/id.d.ts +9 -9
  34. package/dist/id.esm.js +10 -10
  35. package/dist/{index-C_QjKcTy.d.ts → index-5ZEjz-8I.d.ts} +8 -7
  36. package/dist/index.d.ts +32 -27
  37. package/dist/index.esm.js +23 -42
  38. package/dist/{lib-DVaeY7hq.esm.js → lib-V3Lo-Jit.esm.js} +1 -1
  39. package/dist/phone.d.ts +1 -1
  40. package/dist/phone.esm.js +5 -5
  41. package/dist/redirect-to-mobile.d.ts +106 -0
  42. package/dist/redirect-to-mobile.esm.js +338 -0
  43. package/dist/selfie.d.ts +9 -9
  44. package/dist/selfie.esm.js +10 -10
  45. package/dist/session.d.ts +1 -1
  46. package/dist/session.esm.js +3 -3
  47. package/dist/{src-BJhTmsja.esm.js → src-D3v6I2la.esm.js} +22 -6
  48. package/dist/{stats-De--Z9N5.esm.js → stats-D76Thmqp.esm.js} +1 -1
  49. package/dist/stats.esm.js +2 -2
  50. package/dist/{streamingEvents-t3E89TmG.esm.js → streamingEvents-CQq5fJCL.esm.js} +3 -3
  51. package/dist/{types-DrdrHHxZ.d.ts → types-Bn54lmeM.d.ts} +1 -1
  52. package/dist/{types-B_l5fu_D.d.ts → types-DnrAr9fb.d.ts} +1 -1
  53. package/dist/{warmup-CO10kO5G.d.ts → warmup-Da5qDIWZ.d.ts} +1 -1
  54. package/package.json +5 -1
  55. /package/dist/{Actor-SKZvDOCc.d.ts → Actor-B6Lr-x6S.d.ts} +0 -0
  56. /package/dist/{Manager-CVog-etk.d.ts → Manager-CG5CQ1kY.d.ts} +0 -0
  57. /package/dist/{StateMachine-Coiuk0UD.d.ts → StateMachine-WHeQE3lC.d.ts} +0 -0
  58. /package/dist/{api-CdJjfxTX.esm.js → api-3fZO5bmj.esm.js} +0 -0
  59. /package/dist/{camera-HI2fNiV5.d.ts → camera-D7zu0Mls.d.ts} +0 -0
  60. /package/dist/{chunk-3Wl3T5mL.esm.js → chunk-B1Ox1Owh.esm.js} +0 -0
  61. /package/dist/{flowCompletionService-DtL1jOz4.d.ts → flowCompletionService-DeWKduBI.d.ts} +0 -0
  62. /package/dist/{types-dSdX5z-n.d.ts → types-B4KNFqC4.d.ts} +0 -0
  63. /package/dist/{types-WhAUdEJw.d.ts → types-BYYaKde4.d.ts} +0 -0
  64. /package/dist/{usStates-IoVg25OV.esm.js → usStates-D4SmlpeT.esm.js} +0 -0
  65. /package/dist/{xstate.esm-yA5caGbx.esm.js → xstate.esm-07M59Cte.esm.js} +0 -0
package/dist/index.esm.js CHANGED
@@ -1,13 +1,13 @@
1
- import { a as videoSelfieEvents, c as screenClosed, d as addEvent, f as flushEventQueue, i as tutorialScreenNamesMapper, l as screenEvent, n as eventModuleNames, o as moduleClosed, p as subscribeEvent, r as eventScreenNames, s as moduleOpened, t as cameraScreenNamesMapper, u as screenOpened } from "./events-Bf73PAdv.esm.js";
2
- import "./backCameraStream-DXS4n4yS.esm.js";
3
- import { I as isIPad, c as ScreenOrientationProvider, k as createApi_default, o as warmupWasm, r as WasmUtilProvider } from "./src-BJhTmsja.esm.js";
4
- import "./xstate.esm-yA5caGbx.esm.js";
5
- import { c as createScreenOrientationObserver, l as getDeviceClass, o as checkPermission, s as requestPermission, u as getBrowser } from "./streamingEvents-t3E89TmG.esm.js";
6
- import "./deepsightService-D2rnPj53.esm.js";
7
- import { a as resetApi, n as getApi, o as setClient, s as setToken, t as api } from "./api-CdJjfxTX.esm.js";
8
- import "./endpoints-PMCuQkqs.esm.js";
9
- import { _ as createSession, a as processId, c as stopStream, d as ID_ERROR_CODES, f as getDisableIpify, g as resetSessionInit, h as isSessionInitialized, i as initializeIdCapture, l as uploadIdImage, m as initializeSession, n as createIdCaptureActor, o as startRecordingSession, p as getSessionFeatures, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-aQ6PcfVo.esm.js";
10
- import "./stats-De--Z9N5.esm.js";
1
+ import { a as videoSelfieEvents, c as screenClosed, d as addEvent, f as flushEventQueue, i as tutorialScreenNamesMapper, l as screenEvent, n as eventModuleNames, o as moduleClosed, p as subscribeEvent, r as eventScreenNames, s as moduleOpened, t as cameraScreenNamesMapper, u as screenOpened } from "./events-b4_xvENs.esm.js";
2
+ import "./backCameraStream-B57NWDGu.esm.js";
3
+ import { R as isIPad, a as WasmUtilProvider, c as warmupWasm, j as createApi_default, n as buildDefaultWasmConfig, t as DEFAULT_WASM_VERSION, u as ScreenOrientationProvider } from "./src-D3v6I2la.esm.js";
4
+ import "./xstate.esm-07M59Cte.esm.js";
5
+ import { c as createScreenOrientationObserver, l as getDeviceClass, o as checkPermission, s as requestPermission, u as getBrowser } from "./streamingEvents-CQq5fJCL.esm.js";
6
+ import "./deepsightService-CTK55DG8.esm.js";
7
+ import { a as resetApi, n as getApi, o as setClient, s as setToken, t as api } from "./api-3fZO5bmj.esm.js";
8
+ import "./endpoints-5sPFFmaB.esm.js";
9
+ import { _ as createSession, a as processId, c as stopStream, d as ID_ERROR_CODES, f as getDisableIpify, g as resetSessionInit, h as isSessionInitialized, i as initializeIdCapture, l as uploadIdImage, m as initializeSession, n as createIdCaptureActor, o as startRecordingSession, p as getSessionFeatures, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-TUJyOPso.esm.js";
10
+ import "./stats-D76Thmqp.esm.js";
11
11
 
12
12
  //#region src/setup.ts
13
13
  let wasmConfig;
@@ -16,8 +16,7 @@ let configured = false;
16
16
  * Initializes the SDK with the provided configuration.
17
17
  * Must be called before using any SDK functionality.
18
18
  *
19
- * If `wasm` config is provided, this function becomes async and will
20
- * preload WASM binary and ML models. Otherwise, it's synchronous.
19
+ * WASM loads automatically from the Incode CDN unless explicitly disabled or overridden.
21
20
  *
22
21
  * @param options - Configuration options for the SDK
23
22
  *
@@ -25,24 +24,19 @@ let configured = false;
25
24
  * ```ts
26
25
  * import { setup, createSession } from '@incodetech/core';
27
26
  *
28
- * // Setup with API URL first (for session creation)
29
- * await setup({ apiURL: 'https://api.incode.com' });
30
- * const session = await createSession('api-key', { configurationId: 'flow-id' });
27
+ * // Zero-config: WASM loads automatically from CDN
28
+ * await setup({ apiURL: 'https://api.incode.com', token: 'session-token' });
31
29
  *
32
- * // Basic setup with token
33
- * await setup({
34
- * apiURL: 'https://api.incode.com',
35
- * token: 'session-token',
36
- * });
30
+ * // Opt out of WASM
31
+ * await setup({ apiURL: 'https://api.incode.com', token: 'session-token', wasm: false });
37
32
  *
38
- * // Setup with WASM warmup
33
+ * // Self-hosted / custom version
39
34
  * await setup({
40
35
  * apiURL: 'https://api.incode.com',
41
36
  * token: 'session-token',
42
37
  * wasm: {
43
- * wasmPath: '/wasm/ml-wasm.wasm',
44
- * glueCodePath: '/wasm/ml-wasm.js',
45
- * pipelines: ['selfie', 'idCapture'],
38
+ * wasmPath: '/my-cdn/webLib.wasm',
39
+ * glueCodePath: '/my-cdn/webLib.js',
46
40
  * },
47
41
  * });
48
42
  * ```
@@ -61,23 +55,10 @@ async function setup(options) {
61
55
  });
62
56
  }
63
57
  configured = true;
64
- if (options.wasm) {
65
- await warmupWasm({
66
- wasmPath: options.wasm.wasmPath,
67
- wasmSimdPath: options.wasm.wasmSimdPath,
68
- glueCodePath: options.wasm.glueCodePath,
69
- useSimd: options.wasm.useSimd,
70
- pipelines: options.wasm.pipelines,
71
- modelsBasePath: options.wasm.modelsBasePath
72
- });
73
- await (await WasmUtilProvider.getInstance()).initialize({
74
- wasmPath: options.wasm.wasmPath,
75
- wasmSimdPath: options.wasm.wasmSimdPath,
76
- glueCodePath: options.wasm.glueCodePath,
77
- useSimd: options.wasm.useSimd,
78
- pipelines: options.wasm.pipelines,
79
- modelsBasePath: options.wasm.modelsBasePath
80
- });
58
+ const effectiveWasm = options.wasm === false ? void 0 : options.wasm ?? buildDefaultWasmConfig();
59
+ if (effectiveWasm) {
60
+ await warmupWasm({ ...effectiveWasm });
61
+ await (await WasmUtilProvider.getInstance()).initialize({ ...effectiveWasm });
81
62
  }
82
63
  }
83
64
  /**
@@ -128,4 +109,4 @@ function reset() {
128
109
  }
129
110
 
130
111
  //#endregion
131
- export { ID_ERROR_CODES, ScreenOrientationProvider, addEvent, api, cameraScreenNamesMapper, checkPermission as checkCameraPermission, createApi_default as createApi, createIdCaptureActor, createIdCaptureManager, createScreenOrientationObserver, createSession, eventModuleNames, eventScreenNames, flushEventQueue, getApi, getBrowser, getDeviceClass, getDisableIpify, getSessionFeatures, idCaptureMachine, initializeIdCapture, initializeSession, initializeWasmUtil, isConfigured, isIPad, isSessionInitialized, moduleClosed, moduleOpened, processId, requestPermission as requestCameraPermission, reset, resetSessionInit, screenClosed, screenEvent, screenOpened, setWasmConfig, setup, startRecordingSession, stopRecording, stopStream, subscribeEvent, tutorialScreenNamesMapper, uploadIdImage, validateUploadResponse, videoSelfieEvents, warmupWasm };
112
+ export { DEFAULT_WASM_VERSION, ID_ERROR_CODES, ScreenOrientationProvider, addEvent, api, buildDefaultWasmConfig, cameraScreenNamesMapper, checkPermission as checkCameraPermission, createApi_default as createApi, createIdCaptureActor, createIdCaptureManager, createScreenOrientationObserver, createSession, eventModuleNames, eventScreenNames, flushEventQueue, getApi, getBrowser, getDeviceClass, getDisableIpify, getSessionFeatures, idCaptureMachine, initializeIdCapture, initializeSession, initializeWasmUtil, isConfigured, isIPad, isSessionInitialized, moduleClosed, moduleOpened, processId, requestPermission as requestCameraPermission, reset, resetSessionInit, screenClosed, screenEvent, screenOpened, setWasmConfig, setup, startRecordingSession, stopRecording, stopStream, subscribeEvent, tutorialScreenNamesMapper, uploadIdImage, validateUploadResponse, videoSelfieEvents, warmupWasm };
@@ -1,4 +1,4 @@
1
- import { i as __toCommonJS, n as __esm, r as __export, t as __commonJS } from "./chunk-3Wl3T5mL.esm.js";
1
+ import { i as __toCommonJS, n as __esm, r as __export, t as __commonJS } from "./chunk-B1Ox1Owh.esm.js";
2
2
 
3
3
  //#region ../../node_modules/.pnpm/jsnlog@2.30.0/node_modules/jsnlog/jsnlog.js
4
4
  var require_jsnlog = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/jsnlog@2.30.0/node_modules/jsnlog/jsnlog.js": ((exports) => {
package/dist/phone.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Manager } from "./Manager-CVog-etk.js";
1
+ import { t as Manager } from "./Manager-CG5CQ1kY.js";
2
2
 
3
3
  //#region src/modules/phone/types.d.ts
4
4
 
package/dist/phone.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-Bf73PAdv.esm.js";
2
- import { O as createManager, m as BrowserTimerProvider } from "./src-BJhTmsja.esm.js";
3
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-yA5caGbx.esm.js";
4
- import { t as api } from "./api-CdJjfxTX.esm.js";
5
- import { t as endpoints } from "./endpoints-PMCuQkqs.esm.js";
1
+ import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-b4_xvENs.esm.js";
2
+ import { A as createManager, g as BrowserTimerProvider } from "./src-D3v6I2la.esm.js";
3
+ import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-07M59Cte.esm.js";
4
+ import { t as api } from "./api-3fZO5bmj.esm.js";
5
+ import { t as endpoints } from "./endpoints-5sPFFmaB.esm.js";
6
6
 
7
7
  //#region src/modules/phone/phoneServices.ts
8
8
  async function fetchPhone(signal) {
@@ -0,0 +1,106 @@
1
+ import { t as Manager } from "./Manager-CG5CQ1kY.js";
2
+
3
+ //#region src/modules/redirect-to-mobile/types.d.ts
4
+ type RedirectToMobileConfig = {
5
+ flowId?: string;
6
+ url?: string;
7
+ disableSmsOption?: boolean;
8
+ addContinueToDesktop?: boolean;
9
+ qrPhishingResistance?: boolean;
10
+ authHint?: string;
11
+ externalId?: string;
12
+ lang?: string;
13
+ };
14
+ //#endregion
15
+ //#region src/modules/redirect-to-mobile/redirectToMobileStateMachine.d.ts
16
+
17
+ declare const redirectToMobileMachine: any;
18
+ //#endregion
19
+ //#region src/modules/redirect-to-mobile/redirectToMobileActor.d.ts
20
+ type CreateRedirectToMobileActorOptions = {
21
+ config: RedirectToMobileConfig;
22
+ };
23
+ //#endregion
24
+ //#region src/modules/redirect-to-mobile/redirectToMobileManager.d.ts
25
+ type RedirectToMobileIdleState = {
26
+ status: 'idle';
27
+ };
28
+ type RedirectToMobileLoadingState = {
29
+ status: 'loading';
30
+ };
31
+ type RedirectToMobileRedirectingState = {
32
+ status: 'redirecting';
33
+ redirectUrl: string;
34
+ phonePrefix: string;
35
+ smsSent: boolean;
36
+ error: string | undefined;
37
+ };
38
+ type RedirectToMobileFinishedState = {
39
+ status: 'finished';
40
+ };
41
+ type RedirectToMobileClosedState = {
42
+ status: 'closed';
43
+ };
44
+ type RedirectToMobileErrorState = {
45
+ status: 'error';
46
+ error: string;
47
+ };
48
+ type RedirectToMobileState = RedirectToMobileIdleState | RedirectToMobileLoadingState | RedirectToMobileRedirectingState | RedirectToMobileFinishedState | RedirectToMobileClosedState | RedirectToMobileErrorState;
49
+ /**
50
+ * Creates a redirect-to-mobile manager for cross-device onboarding flows.
51
+ *
52
+ * On desktop, displays a QR code (and optional SMS input) so the user can
53
+ * continue on their mobile device. Polls the backend until the mobile
54
+ * session completes, then transitions to `finished`.
55
+ *
56
+ * @param options - Configuration for the redirect module
57
+ * @returns A manager instance with state subscription and API methods
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const manager = createRedirectToMobileManager({
62
+ * config: { disableSmsOption: false, addContinueToDesktop: true },
63
+ * });
64
+ *
65
+ * manager.subscribe((state) => {
66
+ * if (state.status === 'redirecting') {
67
+ * renderQrCode(state.redirectUrl);
68
+ * }
69
+ * if (state.status === 'finished') {
70
+ * console.log('Mobile onboarding complete');
71
+ * }
72
+ * });
73
+ *
74
+ * manager.load();
75
+ * ```
76
+ */
77
+ declare function createRedirectToMobileManager(options: CreateRedirectToMobileActorOptions): Manager<RedirectToMobileState> & {
78
+ /**
79
+ * Starts the redirect-to-mobile flow by fetching the redirect URL.
80
+ */
81
+ load(): void;
82
+ /**
83
+ * Sends an SMS with the redirect link to the given phone number.
84
+ * @param phone - Full phone number with country code
85
+ */
86
+ sendSms(phone: string): void;
87
+ /**
88
+ * Skips the redirect and allows the user to continue on desktop.
89
+ */
90
+ continueOnDesktop(): void;
91
+ /**
92
+ * Resets the SMS state so the user can re-enter their phone number.
93
+ */
94
+ resetSms(): void;
95
+ /**
96
+ * Closes/dismisses the redirect screen.
97
+ */
98
+ close(): void;
99
+ /**
100
+ * Retries generating the redirect URL after an error.
101
+ */
102
+ retry(): void;
103
+ };
104
+ type RedirectToMobileManager = ReturnType<typeof createRedirectToMobileManager>;
105
+ //#endregion
106
+ export { type RedirectToMobileConfig, type RedirectToMobileManager, type RedirectToMobileState, createRedirectToMobileManager, redirectToMobileMachine };
@@ -0,0 +1,338 @@
1
+ import { A as createManager, g as BrowserTimerProvider } from "./src-D3v6I2la.esm.js";
2
+ import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-07M59Cte.esm.js";
3
+ import { t as api } from "./api-3fZO5bmj.esm.js";
4
+ import { t as endpoints } from "./endpoints-5sPFFmaB.esm.js";
5
+
6
+ //#region ../infra/src/url/urlUtils.ts
7
+ function getUrlSearchParam(url, param) {
8
+ try {
9
+ return new URL(url).searchParams.get(param);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ function buildUrlWithSearchParams(baseUrl, params) {
15
+ const url = new URL(baseUrl);
16
+ for (const [key, value] of Object.entries(params)) if (value !== void 0) url.searchParams.set(key, value);
17
+ return url.href;
18
+ }
19
+
20
+ //#endregion
21
+ //#region src/modules/redirect-to-mobile/redirectToMobileServices.ts
22
+ async function fetchRedirectUrl(signal) {
23
+ const res = await api.get(endpoints.onboardingUrl, { signal });
24
+ if (!res.ok) throw new Error(`GET ${endpoints.onboardingUrl} failed: ${res.status} ${res.statusText}`);
25
+ return res.data;
26
+ }
27
+ async function fetchOnboardingStatus(signal) {
28
+ const res = await api.get(endpoints.onboardingStatus, { signal });
29
+ if (!res.ok) throw new Error(`GET ${endpoints.onboardingStatus} failed: ${res.status} ${res.statusText}`);
30
+ return res.data;
31
+ }
32
+ async function sendRedirectSms(params, signal) {
33
+ const res = await api.post(endpoints.sendRedirectSms, params, { signal });
34
+ if (!res.ok) throw new Error(`POST ${endpoints.sendRedirectSms} failed: ${res.status} ${res.statusText}`);
35
+ }
36
+ async function addPhoneForRedirect(phone, signal) {
37
+ const res = await api.post(endpoints.phone, { phone }, { signal });
38
+ if (!res.ok) throw new Error(`POST ${endpoints.phone} failed: ${res.status} ${res.statusText}`);
39
+ }
40
+ async function refreshQrUuid(onboardingId, signal) {
41
+ const res = await api.post(endpoints.qrRefreshUuid, { onboardingId }, { signal });
42
+ if (!res.ok) throw new Error(`POST ${endpoints.qrRefreshUuid} failed: ${res.status} ${res.statusText}`);
43
+ return res.data;
44
+ }
45
+ async function fetchStartInfo(signal) {
46
+ const res = await api.get(endpoints.startInfo, { signal });
47
+ if (!res.ok) throw new Error(`GET ${endpoints.startInfo} failed: ${res.status} ${res.statusText}`);
48
+ return res.data;
49
+ }
50
+
51
+ //#endregion
52
+ //#region src/modules/redirect-to-mobile/redirectToMobileStateMachine.ts
53
+ const POLL_INTERVAL_MS = 5e3;
54
+ const QR_REFRESH_INTERVAL_MS = 5e3;
55
+ function buildRedirectUrl(baseUrl, customUrl, config, urlUuid) {
56
+ const uuid = getUrlSearchParam(baseUrl, "uuid") ?? "";
57
+ return buildUrlWithSearchParams(customUrl ?? baseUrl, {
58
+ uuid,
59
+ isRedirect: "true",
60
+ lang: config.lang,
61
+ externalId: config.externalId,
62
+ auth_hint: config.authHint,
63
+ url_uuid: urlUuid || void 0
64
+ });
65
+ }
66
+ function extractUuidFromUrl(url) {
67
+ return getUrlSearchParam(url, "uuid") ?? "";
68
+ }
69
+ const redirectToMobileMachine = setup({
70
+ types: {
71
+ context: {},
72
+ events: {},
73
+ input: {}
74
+ },
75
+ actors: {
76
+ fetchRedirectUrl: fromPromise(async ({ signal }) => {
77
+ return fetchRedirectUrl(signal);
78
+ }),
79
+ fetchStartInfo: fromPromise(async ({ signal }) => {
80
+ return fetchStartInfo(signal);
81
+ }),
82
+ pollOnboardingStatus: fromCallback(({ sendBack }) => {
83
+ const timer = BrowserTimerProvider.getInstance();
84
+ const interval = timer.setInterval(async () => {
85
+ try {
86
+ if ((await fetchOnboardingStatus()).onboardingStatus === "ONBOARDING_FINISHED") sendBack({ type: "POLL_TICK" });
87
+ } catch {}
88
+ }, POLL_INTERVAL_MS);
89
+ return () => timer.clearInterval(interval);
90
+ }),
91
+ refreshQrUuid: fromCallback(({ sendBack, input }) => {
92
+ const timer = BrowserTimerProvider.getInstance();
93
+ const interval = timer.setInterval(async () => {
94
+ try {
95
+ const res = await refreshQrUuid(input.uuid);
96
+ if (res.urlUuid) sendBack({
97
+ type: "QR_REFRESHED",
98
+ urlUuid: res.urlUuid
99
+ });
100
+ } catch {}
101
+ }, QR_REFRESH_INTERVAL_MS);
102
+ return () => timer.clearInterval(interval);
103
+ }),
104
+ sendSms: fromPromise(async ({ input, signal }) => {
105
+ await addPhoneForRedirect(input.phone, signal);
106
+ const params = input.lang ? [`lang=${input.lang}`] : [];
107
+ await sendRedirectSms({
108
+ smsType: "DESKTOP_ONBOARDING",
109
+ uuid: input.uuid,
110
+ params
111
+ }, signal);
112
+ })
113
+ },
114
+ actions: {
115
+ setBaseUrl: assign(({ context, event }) => {
116
+ const baseUrl = event.output.url;
117
+ return {
118
+ fetchedBaseUrl: baseUrl,
119
+ uuid: extractUuidFromUrl(baseUrl),
120
+ redirectUrl: buildRedirectUrl(baseUrl, context.config.url, context.config, context.urlUuid)
121
+ };
122
+ }),
123
+ setStartInfo: assign(({ event }) => {
124
+ return { phonePrefix: event.output.phonePrefix };
125
+ }),
126
+ setError: assign(({ event }) => ({ error: String(event.error) })),
127
+ setSmsSent: assign({ smsSent: () => true }),
128
+ resetSmsSent: assign({
129
+ smsSent: () => false,
130
+ error: () => void 0
131
+ }),
132
+ setSmsError: assign(({ event }) => ({ error: String(event.error) })),
133
+ updateQrUrl: assign(({ context, event }) => {
134
+ const { urlUuid } = event;
135
+ return {
136
+ urlUuid,
137
+ redirectUrl: buildRedirectUrl(context.fetchedBaseUrl, context.config.url, context.config, urlUuid)
138
+ };
139
+ })
140
+ },
141
+ guards: { hasPhishingResistance: ({ context }) => context.config.qrPhishingResistance === true }
142
+ }).createMachine({
143
+ id: "redirectToMobile",
144
+ initial: "idle",
145
+ context: ({ input }) => ({
146
+ config: input.config,
147
+ redirectUrl: "",
148
+ fetchedBaseUrl: "",
149
+ uuid: "",
150
+ urlUuid: "",
151
+ phonePrefix: "",
152
+ smsSent: false,
153
+ error: void 0
154
+ }),
155
+ states: {
156
+ idle: { on: { LOAD: "generatingUrl" } },
157
+ generatingUrl: { invoke: {
158
+ id: "fetchRedirectUrl",
159
+ src: "fetchRedirectUrl",
160
+ onDone: {
161
+ target: "loadingStartInfo",
162
+ actions: "setBaseUrl"
163
+ },
164
+ onError: {
165
+ target: "error",
166
+ actions: "setError"
167
+ }
168
+ } },
169
+ loadingStartInfo: { invoke: {
170
+ id: "fetchStartInfo",
171
+ src: "fetchStartInfo",
172
+ onDone: {
173
+ target: "showingQr",
174
+ actions: "setStartInfo"
175
+ },
176
+ onError: { target: "showingQr" }
177
+ } },
178
+ showingQr: {
179
+ type: "parallel",
180
+ states: {
181
+ polling: {
182
+ invoke: {
183
+ id: "pollOnboardingStatus",
184
+ src: "pollOnboardingStatus"
185
+ },
186
+ on: { POLL_TICK: { target: "#redirectToMobile.finished" } }
187
+ },
188
+ qrRefresh: {
189
+ initial: "checking",
190
+ states: {
191
+ checking: { always: [{
192
+ target: "refreshing",
193
+ guard: "hasPhishingResistance"
194
+ }, { target: "inactive" }] },
195
+ refreshing: {
196
+ invoke: {
197
+ id: "refreshQrUuid",
198
+ src: "refreshQrUuid",
199
+ input: ({ context }) => ({ uuid: context.uuid })
200
+ },
201
+ on: { QR_REFRESHED: { actions: "updateQrUrl" } }
202
+ },
203
+ inactive: { type: "final" }
204
+ }
205
+ },
206
+ sms: {
207
+ initial: "idle",
208
+ states: {
209
+ idle: { on: { SEND_SMS: "sending" } },
210
+ sending: { invoke: {
211
+ id: "sendSms",
212
+ src: "sendSms",
213
+ input: ({ context, event }) => ({
214
+ phone: event.phone,
215
+ uuid: context.uuid,
216
+ lang: context.config.lang
217
+ }),
218
+ onDone: {
219
+ target: "sent",
220
+ actions: "setSmsSent"
221
+ },
222
+ onError: {
223
+ target: "idle",
224
+ actions: "setSmsError"
225
+ }
226
+ } },
227
+ sent: { on: {
228
+ SEND_SMS: "sending",
229
+ RESET_SMS: {
230
+ target: "idle",
231
+ actions: "resetSmsSent"
232
+ }
233
+ } }
234
+ }
235
+ }
236
+ },
237
+ on: {
238
+ CONTINUE_ON_DESKTOP: "closed",
239
+ CLOSE: "closed"
240
+ }
241
+ },
242
+ finished: { type: "final" },
243
+ closed: { type: "final" },
244
+ error: { on: { RETRY: "generatingUrl" } }
245
+ }
246
+ });
247
+
248
+ //#endregion
249
+ //#region src/modules/redirect-to-mobile/redirectToMobileActor.ts
250
+ function createRedirectToMobileActor(options) {
251
+ return createActor(redirectToMobileMachine, { input: { config: options.config } }).start();
252
+ }
253
+
254
+ //#endregion
255
+ //#region src/modules/redirect-to-mobile/redirectToMobileManager.ts
256
+ function mapState(snapshot) {
257
+ const typedSnapshot = snapshot;
258
+ const { context } = typedSnapshot;
259
+ if (typedSnapshot.matches("idle")) return { status: "idle" };
260
+ if (typedSnapshot.matches("generatingUrl") || typedSnapshot.matches("loadingStartInfo")) return { status: "loading" };
261
+ if (typedSnapshot.matches("showingQr")) return {
262
+ status: "redirecting",
263
+ redirectUrl: context.redirectUrl,
264
+ phonePrefix: context.phonePrefix,
265
+ smsSent: context.smsSent,
266
+ error: context.error
267
+ };
268
+ if (typedSnapshot.matches("finished")) return { status: "finished" };
269
+ if (typedSnapshot.matches("closed")) return { status: "closed" };
270
+ if (typedSnapshot.matches("error")) return {
271
+ status: "error",
272
+ error: context.error ?? "An error occurred"
273
+ };
274
+ return { status: "idle" };
275
+ }
276
+ function createApi({ actor }) {
277
+ return {
278
+ load() {
279
+ actor.send({ type: "LOAD" });
280
+ },
281
+ sendSms(phone) {
282
+ actor.send({
283
+ type: "SEND_SMS",
284
+ phone
285
+ });
286
+ },
287
+ continueOnDesktop() {
288
+ actor.send({ type: "CONTINUE_ON_DESKTOP" });
289
+ },
290
+ resetSms() {
291
+ actor.send({ type: "RESET_SMS" });
292
+ },
293
+ close() {
294
+ actor.send({ type: "CLOSE" });
295
+ },
296
+ retry() {
297
+ actor.send({ type: "RETRY" });
298
+ }
299
+ };
300
+ }
301
+ /**
302
+ * Creates a redirect-to-mobile manager for cross-device onboarding flows.
303
+ *
304
+ * On desktop, displays a QR code (and optional SMS input) so the user can
305
+ * continue on their mobile device. Polls the backend until the mobile
306
+ * session completes, then transitions to `finished`.
307
+ *
308
+ * @param options - Configuration for the redirect module
309
+ * @returns A manager instance with state subscription and API methods
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * const manager = createRedirectToMobileManager({
314
+ * config: { disableSmsOption: false, addContinueToDesktop: true },
315
+ * });
316
+ *
317
+ * manager.subscribe((state) => {
318
+ * if (state.status === 'redirecting') {
319
+ * renderQrCode(state.redirectUrl);
320
+ * }
321
+ * if (state.status === 'finished') {
322
+ * console.log('Mobile onboarding complete');
323
+ * }
324
+ * });
325
+ *
326
+ * manager.load();
327
+ * ```
328
+ */
329
+ function createRedirectToMobileManager(options) {
330
+ return createManager({
331
+ actor: createRedirectToMobileActor(options),
332
+ mapState,
333
+ createApi
334
+ });
335
+ }
336
+
337
+ //#endregion
338
+ export { createRedirectToMobileManager, redirectToMobileMachine };
package/dist/selfie.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { i as IncodeCanvas, n as StreamCanvasCapture, t as DeepsightService } from "./deepsightService-Dv1ILk27.js";
2
- import { n as PermissionStatus, o as IMLProviderCapability, s as MLProviderConfig, t as PermissionResult } from "./types-dSdX5z-n.js";
3
- import { t as WasmPipeline } from "./warmup-CO10kO5G.js";
4
- import { a as FaceCaptureDependencies, i as DetectionStatus, n as FaceCaptureManagerState, o as FaceErrorCode, r as BaseFaceCaptureConfig, t as FaceCaptureManager } from "./faceCaptureManagerFactory-FEuTMK4j.js";
5
- import { t as Manager } from "./Manager-CVog-etk.js";
6
- import { t as CameraStream } from "./camera-HI2fNiV5.js";
7
- import { n as StateMachine, t as AnyStateMachine } from "./StateMachine-Coiuk0UD.js";
8
- import "./types-B_l5fu_D.js";
9
- import { r as FlowModuleConfig } from "./types-DrdrHHxZ.js";
1
+ import { i as IncodeCanvas, n as StreamCanvasCapture, t as DeepsightService } from "./deepsightService-CYCDsan2.js";
2
+ import { n as PermissionStatus, o as IMLProviderCapability, s as MLProviderConfig, t as PermissionResult } from "./types-B4KNFqC4.js";
3
+ import { n as WasmPipeline } from "./warmup-Da5qDIWZ.js";
4
+ import { a as FaceCaptureDependencies, i as DetectionStatus, n as FaceCaptureManagerState, o as FaceErrorCode, r as BaseFaceCaptureConfig, t as FaceCaptureManager } from "./faceCaptureManagerFactory-D1NUo68Z.js";
5
+ import { t as Manager } from "./Manager-CG5CQ1kY.js";
6
+ import { t as CameraStream } from "./camera-D7zu0Mls.js";
7
+ import { n as StateMachine, t as AnyStateMachine } from "./StateMachine-WHeQE3lC.js";
8
+ import "./types-DnrAr9fb.js";
9
+ import { r as FlowModuleConfig } from "./types-Bn54lmeM.js";
10
10
 
11
11
  //#region ../infra/src/capabilities/IFaceDetectionCapability.d.ts
12
12
  /**
@@ -1,13 +1,13 @@
1
- import { d as addEvent, n as eventModuleNames } from "./events-Bf73PAdv.esm.js";
2
- import "./backCameraStream-DXS4n4yS.esm.js";
3
- import { h as BrowserStorageProvider, r as WasmUtilProvider } from "./src-BJhTmsja.esm.js";
4
- import { a as createActor, i as fromPromise, n as assign } from "./xstate.esm-yA5caGbx.esm.js";
5
- import "./streamingEvents-t3E89TmG.esm.js";
6
- import "./deepsightService-D2rnPj53.esm.js";
7
- import "./api-CdJjfxTX.esm.js";
8
- import "./endpoints-PMCuQkqs.esm.js";
9
- import "./stats-De--Z9N5.esm.js";
10
- import { a as FACE_ERROR_CODES, i as uploadSelfie, n as faceCaptureMachine, o as createFaceCaptureManager, r as processFace, t as FACE_CAPTURE_EVENT_CODES } from "./faceCaptureSetup-pxm6Cjua.esm.js";
1
+ import { d as addEvent, n as eventModuleNames } from "./events-b4_xvENs.esm.js";
2
+ import "./backCameraStream-B57NWDGu.esm.js";
3
+ import { _ as BrowserStorageProvider, a as WasmUtilProvider } from "./src-D3v6I2la.esm.js";
4
+ import { a as createActor, i as fromPromise, n as assign } from "./xstate.esm-07M59Cte.esm.js";
5
+ import "./streamingEvents-CQq5fJCL.esm.js";
6
+ import "./deepsightService-CTK55DG8.esm.js";
7
+ import "./api-3fZO5bmj.esm.js";
8
+ import "./endpoints-5sPFFmaB.esm.js";
9
+ import "./stats-D76Thmqp.esm.js";
10
+ import { a as FACE_ERROR_CODES, i as uploadSelfie, n as faceCaptureMachine, o as createFaceCaptureManager, r as processFace, t as FACE_CAPTURE_EVENT_CODES } from "./faceCaptureSetup-10lCb_yE.esm.js";
11
11
 
12
12
  //#region src/modules/selfie/selfieErrorUtils.ts
13
13
  const FACE_ERROR_CODE_VALUES = Object.values(FACE_ERROR_CODES);
package/dist/session.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as GetFinishStatusFn, r as getFinishStatus, t as FinishStatus } from "./flowCompletionService-DtL1jOz4.js";
1
+ import { n as GetFinishStatusFn, r as getFinishStatus, t as FinishStatus } from "./flowCompletionService-DeWKduBI.js";
2
2
  export { type FinishStatus, type GetFinishStatusFn, getFinishStatus };
@@ -1,5 +1,5 @@
1
- import "./api-CdJjfxTX.esm.js";
2
- import "./endpoints-PMCuQkqs.esm.js";
3
- import { t as getFinishStatus } from "./flowCompletionService-C2Cjw8WY.esm.js";
1
+ import "./api-3fZO5bmj.esm.js";
2
+ import "./endpoints-5sPFFmaB.esm.js";
3
+ import { t as getFinishStatus } from "./flowCompletionService-DHXqHOAk.esm.js";
4
4
 
5
5
  export { getFinishStatus };