@incodetech/core 0.0.0-dev-20260402-682edb5 → 0.0.0-dev-20260402-7cf9db4

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 (91) hide show
  1. package/dist/Actor-phIcsUhv.d.ts +2 -0
  2. package/dist/BaseWasmProvider-BFXU7jj8.esm.js +1536 -0
  3. package/dist/BrowserEnvironmentProvider-DApG6lNu.esm.js +89 -0
  4. package/dist/BrowserTimerProvider-CRhCvln7.esm.js +22 -0
  5. package/dist/Manager-BndLda4_.d.ts +19 -0
  6. package/dist/{events-Cc1xUUgF.esm.js → Manager-D_DMzMWz.esm.js} +114 -11
  7. package/dist/{warmup-CzfSiaMj.d.ts → StateMachine-CGAi8x_b.d.ts} +4 -1
  8. package/dist/StreamCanvasCapture-9VAzOfOv.esm.js +410 -0
  9. package/dist/WasmUtilProvider-DctESPCy.esm.js +114 -0
  10. package/dist/{addressSearch-DzOdaNEA.esm.js → addressSearch-CYGzuJJ3.esm.js} +3 -3
  11. package/dist/authentication.d.ts +9 -7
  12. package/dist/authentication.esm.js +12 -10
  13. package/dist/{authenticationManager-TaI12wf3.d.ts → authenticationManager-B5Yv9bDw.d.ts} +2 -2
  14. package/dist/{authenticationManager-CBSPCdJc.esm.js → authenticationManager-C9iQ1d2a.esm.js} +5 -5
  15. package/dist/{backCameraStream-BGAbuvw1.esm.js → backCameraStream-BJwEXNl4.esm.js} +2 -1
  16. package/dist/camera-D-MPXRbZ.esm.js +22 -0
  17. package/dist/camera-Dv2WEhGe.d.ts +4 -0
  18. package/dist/consent.d.ts +55 -54
  19. package/dist/consent.esm.js +2 -3
  20. package/dist/curp-validation.d.ts +5 -3
  21. package/dist/curp-validation.esm.js +2 -3
  22. package/dist/deepsightLoader-D2MKmB5z.esm.js +48 -0
  23. package/dist/{deepsightService-DxA--87N.d.ts → deepsightService-CWnhwXLw.d.ts} +223 -17
  24. package/dist/document-capture.d.ts +58 -56
  25. package/dist/document-capture.esm.js +5 -4
  26. package/dist/document-upload.d.ts +47 -45
  27. package/dist/document-upload.esm.js +5 -4
  28. package/dist/ekyb.d.ts +3 -2
  29. package/dist/ekyb.esm.js +8 -7
  30. package/dist/ekyc.d.ts +3 -2
  31. package/dist/ekyc.esm.js +133 -123
  32. package/dist/email.d.ts +3 -2
  33. package/dist/email.esm.js +4 -4
  34. package/dist/{emailManager-DN_q_zxy.d.ts → emailManager-BIq6pJa8.d.ts} +11 -4
  35. package/dist/{emailManager-DSR9gQLX.esm.js → emailManager-C5GCSw78.esm.js} +43 -23
  36. package/dist/extensibility.d.ts +45 -43
  37. package/dist/extensibility.esm.js +26 -15
  38. package/dist/face-match.d.ts +1 -1
  39. package/dist/face-match.esm.js +2 -3
  40. package/dist/{faceCaptureManagerFactory-CGpkO_S3.d.ts → faceCaptureManagerFactory-CN5-GRxP.d.ts} +89 -142
  41. package/dist/{faceCaptureSetup-Rr7LUbBm.esm.js → faceCaptureSetup-DYRykM5Y.esm.js} +413 -7
  42. package/dist/flow.d.ts +6 -5
  43. package/dist/flow.esm.js +7 -7
  44. package/dist/{flowCompletionService-Bkaerugt.esm.js → flowCompletionService-CBvXiMKa.esm.js} +1 -1
  45. package/dist/{flowServices-Bt6lMLUI.esm.js → flowServices-CQ3rTJLE.esm.js} +2 -2
  46. package/dist/geolocation.d.ts +2 -1
  47. package/dist/geolocation.esm.js +16 -3
  48. package/dist/government-validation.d.ts +2 -1
  49. package/dist/government-validation.esm.js +3 -3
  50. package/dist/id.d.ts +9 -6
  51. package/dist/id.esm.js +14 -11
  52. package/dist/{idCaptureManager-Dc2NJMy_.d.ts → idCaptureManager-B1RWflj0.d.ts} +15 -12
  53. package/dist/{idCaptureManager-QyM4nIKM.esm.js → idCaptureManager-D5rjCu9r.esm.js} +178 -8
  54. package/dist/index.d.ts +68 -21
  55. package/dist/index.esm.js +440 -11
  56. package/dist/mandatory-consent.d.ts +58 -56
  57. package/dist/mandatory-consent.esm.js +2 -3
  58. package/dist/phone.d.ts +3 -2
  59. package/dist/phone.esm.js +4 -4
  60. package/dist/{phoneManager-D2A0hXXq.d.ts → phoneManager-Ba66ysK2.d.ts} +9 -2
  61. package/dist/{phoneManager-D2nZtu-b.esm.js → phoneManager-CQJim-Ky.esm.js} +32 -21
  62. package/dist/platform-B3nGssGZ.esm.js +83 -0
  63. package/dist/redirect-to-mobile.d.ts +2 -1
  64. package/dist/redirect-to-mobile.esm.js +3 -3
  65. package/dist/selfie.d.ts +9 -7
  66. package/dist/selfie.esm.js +12 -10
  67. package/dist/{selfieManager-B4Nnp7ws.d.ts → selfieManager-BnfnTPcx.d.ts} +2 -2
  68. package/dist/{selfieManager-CvE35L72.esm.js → selfieManager-DYW1C2GP.esm.js} +4 -3
  69. package/dist/session-TBPhHmyy.esm.js +3130 -0
  70. package/dist/session.d.ts +1 -1
  71. package/dist/session.esm.js +2 -2
  72. package/dist/signature.d.ts +3 -3
  73. package/dist/signature.esm.js +3 -4
  74. package/dist/{stats-D0m3TvIg.esm.js → stats-D4C7iDy1.esm.js} +1 -1
  75. package/dist/stats.esm.js +2 -2
  76. package/dist/{types-oveF7RrS.d.ts → types-BWGxcjiZ.d.ts} +1 -1
  77. package/dist/{types-mQLzH6uw.d.ts → types-BX1ZlbSR.d.ts} +1 -1
  78. package/package.json +1 -1
  79. package/dist/deepsightLoader-B93Oa9pS.esm.js +0 -24
  80. package/dist/deepsightService-CLUMQ5ee.esm.js +0 -235
  81. package/dist/index-BTaLQSj9.d.ts +0 -219
  82. package/dist/recordingsRepository-Djt_In2b.esm.js +0 -122
  83. package/dist/session-CUy9-Yzi.esm.js +0 -250
  84. package/dist/src-8rn6DoH7.esm.js +0 -6554
  85. /package/dist/{api-G4JA8CXK.esm.js → api-3fZO5bmj.esm.js} +0 -0
  86. /package/dist/{browserSimulation-C8gNnn5p.esm.js → browserSimulation-zWJAZ1vA.esm.js} +0 -0
  87. /package/dist/{displayErrors-BgtBHbfb.d.ts → displayErrors-DzzB3fcR.d.ts} +0 -0
  88. /package/dist/{flowCompletionService-De8JDo87.d.ts → flowCompletionService-C_CShl_d.d.ts} +0 -0
  89. /package/dist/{id-B30uqGbp.esm.js → id-Dv0it9CY.esm.js} +0 -0
  90. /package/dist/{index-LKrIp3Oo.d.ts → index-CuY8tqBC.d.ts} +0 -0
  91. /package/dist/{lib-qeMam2F_.esm.js → lib-B5byelWf.esm.js} +0 -0
@@ -0,0 +1,89 @@
1
+ //#region ../infra/src/providers/browser/BrowserEnvironmentProvider.ts
2
+ var BrowserEnvironmentProvider = class {
3
+ getScreenDimensions() {
4
+ if (typeof screen === "undefined") return {
5
+ width: 0,
6
+ height: 0
7
+ };
8
+ return {
9
+ width: screen.width,
10
+ height: screen.height
11
+ };
12
+ }
13
+ generateCanvasFingerprint() {
14
+ try {
15
+ if (typeof document === "undefined") return "";
16
+ const canvas = document.createElement("canvas");
17
+ const ctx = canvas.getContext("2d");
18
+ if (!ctx) return "";
19
+ ctx.textBaseline = "top";
20
+ ctx.font = "14px Arial";
21
+ ctx.fillText("fingerprint", 2, 2);
22
+ return canvas.toDataURL().slice(-50);
23
+ } catch {
24
+ return "";
25
+ }
26
+ }
27
+ getWebGLRenderer() {
28
+ try {
29
+ if (typeof document === "undefined") return "";
30
+ const canvas = document.createElement("canvas");
31
+ const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
32
+ if (!gl) return "";
33
+ const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
34
+ if (!debugInfo) return "";
35
+ return gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) || "";
36
+ } catch {
37
+ return "";
38
+ }
39
+ }
40
+ getWindowProperty(prop) {
41
+ if (typeof window === "undefined") return;
42
+ return window[prop];
43
+ }
44
+ getNavigatorProperty(prop) {
45
+ if (typeof navigator === "undefined") return;
46
+ return navigator[prop];
47
+ }
48
+ getNavigatorPrefixes() {
49
+ if (typeof navigator === "undefined") return {
50
+ webkit: false,
51
+ moz: false,
52
+ o: false,
53
+ ms: false
54
+ };
55
+ const nav = navigator;
56
+ return {
57
+ webkit: nav.webkitGetUserMedia !== void 0,
58
+ moz: nav.mozGetUserMedia !== void 0,
59
+ o: nav.oGetUserMedia !== void 0,
60
+ ms: nav.msGetUserMedia !== void 0
61
+ };
62
+ }
63
+ async fetchJson(url, timeoutMs = 3e3) {
64
+ try {
65
+ if (typeof fetch === "undefined") return null;
66
+ const controller = new AbortController();
67
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
68
+ const response = await fetch(url, { signal: controller.signal });
69
+ clearTimeout(timeoutId);
70
+ return await response.json();
71
+ } catch {
72
+ return null;
73
+ }
74
+ }
75
+ async enumerateVideoDeviceLabels() {
76
+ try {
77
+ if (typeof navigator === "undefined" || !navigator.mediaDevices?.enumerateDevices) return [];
78
+ return (await navigator.mediaDevices.enumerateDevices()).filter((device) => device.kind === "videoinput").map((device) => device.label);
79
+ } catch {
80
+ return [];
81
+ }
82
+ }
83
+ getTimestamp() {
84
+ return Date.now();
85
+ }
86
+ };
87
+
88
+ //#endregion
89
+ export { BrowserEnvironmentProvider as t };
@@ -0,0 +1,22 @@
1
+ //#region ../infra/src/providers/browser/BrowserTimerProvider.ts
2
+ var BrowserTimerProvider = class BrowserTimerProvider {
3
+ static getInstance() {
4
+ if (!BrowserTimerProvider.instance) BrowserTimerProvider.instance = new BrowserTimerProvider();
5
+ return BrowserTimerProvider.instance;
6
+ }
7
+ setTimeout(callback, delayMs) {
8
+ return setTimeout(callback, delayMs);
9
+ }
10
+ setInterval(callback, delayMs) {
11
+ return setInterval(callback, delayMs);
12
+ }
13
+ clearTimeout(handle) {
14
+ clearTimeout(handle);
15
+ }
16
+ clearInterval(handle) {
17
+ clearInterval(handle);
18
+ }
19
+ };
20
+
21
+ //#endregion
22
+ export { BrowserTimerProvider as t };
@@ -0,0 +1,19 @@
1
+ //#region ../infra/src/manager/Manager.d.ts
2
+ /**
3
+ * Base manager interface providing state access, subscriptions, and lifecycle control.
4
+ * @template TPublicState - The public state type exposed to consumers
5
+ */
6
+ type Manager<TPublicState> = {
7
+ /** Returns the current mapped public state */
8
+ getState(): TPublicState;
9
+ /**
10
+ * Subscribes to state changes.
11
+ * @param listener - Callback invoked on every state change
12
+ * @returns Unsubscribe function to stop receiving updates
13
+ */
14
+ subscribe(listener: (state: TPublicState) => void): () => void;
15
+ /** Stops the underlying actor and cleans up resources */
16
+ stop(): void;
17
+ };
18
+ //#endregion
19
+ export { Manager as t };
@@ -1,15 +1,6 @@
1
- import { i as isApiConfigured, r as getToken, t as api } from "./api-G4JA8CXK.esm.js";
1
+ import { i as isApiConfigured, r as getToken, t as api } from "./api-3fZO5bmj.esm.js";
2
2
  import { t as endpoints } from "./endpoints-CCuj1KZH.esm.js";
3
3
 
4
- //#region ../infra/src/capabilities/IBrowserEnvironmentCapability.ts
5
- function getTimestamp() {
6
- return Date.now();
7
- }
8
- function revokeObjectURL(url) {
9
- URL.revokeObjectURL(url);
10
- }
11
-
12
- //#endregion
13
4
  //#region ../../node_modules/.pnpm/xstate@5.24.0/node_modules/xstate/dev/dist/xstate-dev.esm.js
14
5
  function getGlobal() {
15
6
  if (typeof globalThis !== "undefined") return globalThis;
@@ -3269,6 +3260,15 @@ function setup({ schemas, actors, actions, guards, delays }) {
3269
3260
  };
3270
3261
  }
3271
3262
 
3263
+ //#endregion
3264
+ //#region ../infra/src/capabilities/IBrowserEnvironmentCapability.ts
3265
+ function getTimestamp() {
3266
+ return Date.now();
3267
+ }
3268
+ function revokeObjectURL(url) {
3269
+ URL.revokeObjectURL(url);
3270
+ }
3271
+
3272
3272
  //#endregion
3273
3273
  //#region src/internal/events/addEvent.ts
3274
3274
  const eventsQueue = [];
@@ -3649,4 +3649,107 @@ const cameraScreenNamesMapper = {
3649
3649
  };
3650
3650
 
3651
3651
  //#endregion
3652
- export { revokeObjectURL as C, createActor as S, subscribeEvent as _, videoSelfieEvents as a, fromCallback as b, captureAttemptFinished as c, moduleOpened as d, screenClosed as f, flushEventQueue as g, addEvent as h, tutorialScreenNamesMapper as i, elementClicked as l, screenOpened as m, eventModuleNames as n, createManagerInstrumentation as o, screenEvent as p, eventScreenNames as r, getDefaultManagerScreenName as s, cameraScreenNamesMapper as t, moduleClosed as u, setup as v, fromPromise as x, assign as y };
3652
+ //#region ../infra/src/manager/Manager.ts
3653
+ /**
3654
+ * Creates a manager that wraps a state machine actor with a clean public API.
3655
+ *
3656
+ * The manager provides:
3657
+ * - `getState()` - Returns the mapped public state
3658
+ * - `subscribe()` - Listen to state changes
3659
+ * - `stop()` - Stop the actor
3660
+ * - Plus any custom API methods from `createApi`
3661
+ *
3662
+ * @template TMachine - The state machine type
3663
+ * @template TMapState - Function type that maps raw snapshot to public state
3664
+ * @template TCreateApi - Function type that creates the custom API
3665
+ *
3666
+ * @param options - Configuration options
3667
+ * @param options.actor - The started actor instance
3668
+ * @param options.mapState - Function to transform raw snapshot into public state
3669
+ * @param options.createApi - Factory function to create custom API methods
3670
+ *
3671
+ * @returns Combined manager with base methods and custom API
3672
+ *
3673
+ * @example
3674
+ * ```ts
3675
+ * const manager = createManager({
3676
+ * actor: createActor(myMachine).start(),
3677
+ * mapState: (snapshot) => ({ status: snapshot.value }),
3678
+ * createApi: ({ actor }) => ({
3679
+ * doSomething() { actor.send({ type: 'DO_IT' }); }
3680
+ * }),
3681
+ * });
3682
+ * ```
3683
+ */
3684
+ function createManager(options) {
3685
+ const { actor, mapState, createApi, instrumentation } = options;
3686
+ function getSnapshot() {
3687
+ return actor.getSnapshot();
3688
+ }
3689
+ function getState() {
3690
+ return mapState(getSnapshot());
3691
+ }
3692
+ function subscribe(listener) {
3693
+ const subscription = actor.subscribe(() => {
3694
+ listener(getState());
3695
+ });
3696
+ return () => subscription.unsubscribe();
3697
+ }
3698
+ let currentScreenName = instrumentation.getScreenName(getSnapshot());
3699
+ let currentErrorName = instrumentation.getErrorName(getSnapshot());
3700
+ let currentErrorPayload = instrumentation.getErrorPayload(getSnapshot());
3701
+ const api$1 = createApi({
3702
+ actor,
3703
+ getSnapshot,
3704
+ trackElementClicked: (elementName, payload) => {
3705
+ instrumentation.onElementClicked?.(instrumentation.moduleName, currentScreenName, {
3706
+ element: elementName,
3707
+ action: payload?.action,
3708
+ metadata: payload?.metadata
3709
+ });
3710
+ },
3711
+ trackCaptureAttemptFinished: (payload) => {
3712
+ instrumentation.onCaptureAttemptFinished?.(instrumentation.moduleName, currentScreenName, { logs: payload.logs });
3713
+ }
3714
+ });
3715
+ instrumentation.onModuleOpened(instrumentation.moduleName);
3716
+ if (currentScreenName !== void 0) instrumentation.onScreenOpened(instrumentation.moduleName, currentScreenName);
3717
+ if (currentErrorName !== void 0) instrumentation.onErrorTriggered(instrumentation.moduleName, currentErrorName, currentErrorPayload);
3718
+ const actorSubscription = actor.subscribe((snapshot) => {
3719
+ const nextScreenName = instrumentation.getScreenName(snapshot);
3720
+ const nextErrorName = instrumentation.getErrorName(snapshot);
3721
+ const nextErrorPayload = instrumentation.getErrorPayload(snapshot);
3722
+ if (currentScreenName === nextScreenName) {
3723
+ if (nextErrorName !== void 0 && nextErrorName !== currentErrorName) instrumentation.onErrorTriggered(instrumentation.moduleName, nextErrorName, nextErrorPayload);
3724
+ currentErrorName = nextErrorName;
3725
+ currentErrorPayload = nextErrorPayload;
3726
+ return;
3727
+ }
3728
+ if (currentScreenName !== void 0) instrumentation.onScreenClosed(instrumentation.moduleName, currentScreenName);
3729
+ if (nextScreenName !== void 0) instrumentation.onScreenOpened(instrumentation.moduleName, nextScreenName);
3730
+ currentScreenName = nextScreenName;
3731
+ if (nextErrorName !== void 0 && nextErrorName !== currentErrorName) instrumentation.onErrorTriggered(instrumentation.moduleName, nextErrorName, nextErrorPayload);
3732
+ currentErrorName = nextErrorName;
3733
+ currentErrorPayload = nextErrorPayload;
3734
+ });
3735
+ let isStopped = false;
3736
+ const base = {
3737
+ getState,
3738
+ subscribe,
3739
+ stop() {
3740
+ if (isStopped) return;
3741
+ isStopped = true;
3742
+ actorSubscription.unsubscribe();
3743
+ if (currentScreenName !== void 0) instrumentation.onScreenClosed(instrumentation.moduleName, currentScreenName);
3744
+ currentScreenName = void 0;
3745
+ currentErrorName = void 0;
3746
+ currentErrorPayload = void 0;
3747
+ instrumentation.onModuleClosed(instrumentation.moduleName);
3748
+ actor.stop();
3749
+ }
3750
+ };
3751
+ return Object.defineProperties(base, Object.getOwnPropertyDescriptors(api$1));
3752
+ }
3753
+
3754
+ //#endregion
3755
+ export { fromPromise as C, fromCallback as S, flushEventQueue as _, tutorialScreenNamesMapper as a, setup as b, getDefaultManagerScreenName as c, moduleClosed as d, moduleOpened as f, addEvent as g, screenOpened as h, eventScreenNames as i, captureAttemptFinished as l, screenEvent as m, cameraScreenNamesMapper as n, videoSelfieEvents as o, screenClosed as p, eventModuleNames as r, createManagerInstrumentation as s, createManager as t, elementClicked as u, subscribeEvent as v, createActor as w, assign as x, revokeObjectURL as y };
@@ -1,4 +1,7 @@
1
+ import { AnyStateMachine, StateMachine, fromPromise } from "xstate";
2
+
1
3
  //#region ../infra/src/wasm/warmup.d.ts
4
+
2
5
  /**
3
6
  * All available ML pipelines in the SDK.
4
7
  * - 'selfie' - Face detection for selfie capture
@@ -52,4 +55,4 @@ interface WarmupConfig {
52
55
  */
53
56
  declare function warmupWasm(config: WarmupConfig): Promise<void>;
54
57
  //#endregion
55
- export { WasmPipeline as n, warmupWasm as r, WarmupConfig as t };
58
+ export { WasmPipeline as a, WarmupConfig as i, StateMachine as n, warmupWasm as o, fromPromise as r, AnyStateMachine as t };
@@ -0,0 +1,410 @@
1
+ import { a as __toDynamicImportESM } from "./chunk-Boje8faD.esm.js";
2
+ import { a as getDeviceInfo, i as IncodeCanvas, n as MotionSensorProvider } from "./BaseWasmProvider-BFXU7jj8.esm.js";
3
+ import { t as api } from "./api-3fZO5bmj.esm.js";
4
+ import { t as endpoints } from "./endpoints-CCuj1KZH.esm.js";
5
+ import { i as stopCameraStream, r as requestCameraAccess } from "./camera-D-MPXRbZ.esm.js";
6
+
7
+ //#region src/internal/device/getDeviceClass.ts
8
+ function getDeviceClass() {
9
+ const { userAgent, platform, maxTouchPoints } = getDeviceInfo();
10
+ if (!userAgent) return "desktop";
11
+ const ua = userAgent.toLowerCase();
12
+ if (/iphone|ipad|ipod/.test(ua) || platform === "MacIntel" && maxTouchPoints > 1) return "ios";
13
+ if (/android/.test(ua)) return "android";
14
+ return "desktop";
15
+ }
16
+
17
+ //#endregion
18
+ //#region ../infra/src/providers/browser/BrowserStorageProvider.ts
19
+ /**
20
+ * Browser-based storage provider wrapping localStorage.
21
+ * Handles JSON serialization/deserialization automatically.
22
+ */
23
+ var BrowserStorageProvider = class {
24
+ /**
25
+ * Retrieves a value from localStorage.
26
+ * @param key - The storage key
27
+ * @returns The stored value or null if not found
28
+ * @throws Error if stored value is invalid JSON
29
+ */
30
+ async get(key) {
31
+ try {
32
+ const item = localStorage.getItem(key);
33
+ if (item === null) return null;
34
+ return JSON.parse(item);
35
+ } catch (error) {
36
+ if (error instanceof SyntaxError) throw new Error(`Invalid JSON stored at key "${key}": ${error.message}`);
37
+ throw error;
38
+ }
39
+ }
40
+ /**
41
+ * Stores a value in localStorage.
42
+ * @param key - The storage key
43
+ * @param value - The value to store (will be serialized as JSON)
44
+ * @throws Error if value cannot be serialized or quota is exceeded
45
+ */
46
+ async set(key, value) {
47
+ try {
48
+ const serialized = JSON.stringify(value);
49
+ localStorage.setItem(key, serialized);
50
+ } catch (error) {
51
+ if ((error instanceof DOMException || error.name === "QuotaExceededError") && error.name === "QuotaExceededError") throw new Error(`Storage quota exceeded for key "${key}"`);
52
+ if (error instanceof TypeError) throw new Error(`Failed to serialize value for key "${key}": ${error.message}`);
53
+ throw error;
54
+ }
55
+ }
56
+ /**
57
+ * Removes a value from localStorage.
58
+ * @param key - The storage key to remove
59
+ */
60
+ async remove(key) {
61
+ localStorage.removeItem(key);
62
+ }
63
+ /**
64
+ * Clears all values from localStorage.
65
+ */
66
+ async clear() {
67
+ localStorage.clear();
68
+ }
69
+ };
70
+
71
+ //#endregion
72
+ //#region src/internal/manualReview/manualReviewService.ts
73
+ async function flagFaceManualReview() {
74
+ try {
75
+ await api.put(endpoints.updateSession, { manualSelfieCheckNeeded: true });
76
+ } catch {}
77
+ }
78
+ async function flagIdManualReview() {
79
+ try {
80
+ await api.put(endpoints.updateSession, { manualIdCheckNeeded: true });
81
+ } catch {}
82
+ }
83
+
84
+ //#endregion
85
+ //#region ../infra/src/media/StreamCanvasProcessingSession.ts
86
+ var StreamCanvasProcessingSession = class {
87
+ /**
88
+ * Creates a processing session that reacts to `StreamCanvasCapture` frame events
89
+ * and drives a provider's `processFrame()` method with backpressure.
90
+ */
91
+ constructor(params) {
92
+ this.disposed = false;
93
+ this.isProcessing = false;
94
+ this.onFrameEvent = () => {
95
+ if (this.disposed || this.isProcessing) return;
96
+ const frame = this.capturer.getLatestFrame();
97
+ if (!frame) return;
98
+ this.onFrame?.(frame);
99
+ this.isProcessing = true;
100
+ this.provider.processFrame(frame).catch(() => {}).finally(() => {
101
+ this.isProcessing = false;
102
+ });
103
+ };
104
+ this.capturer = params.capturer;
105
+ this.provider = params.provider;
106
+ this.onFrame = params.onFrame;
107
+ this.capturer.addEventListener("frame", this.onFrameEvent);
108
+ }
109
+ /**
110
+ * Unsubscribes from frame events and resets the provider.
111
+ */
112
+ dispose() {
113
+ if (this.disposed) return;
114
+ this.disposed = true;
115
+ this.capturer.removeEventListener("frame", this.onFrameEvent);
116
+ this.provider.reset();
117
+ }
118
+ /**
119
+ * Returns whether the session has been disposed.
120
+ */
121
+ isDisposed() {
122
+ return this.disposed;
123
+ }
124
+ };
125
+
126
+ //#endregion
127
+ //#region ../infra/src/media/permissions.ts
128
+ async function queryPermission(name) {
129
+ try {
130
+ if (typeof navigator === "undefined" || !navigator.permissions) return "prompt";
131
+ return (await navigator.permissions.query({ name })).state;
132
+ } catch {
133
+ return "prompt";
134
+ }
135
+ }
136
+ async function queryCameraPermission() {
137
+ return queryPermission("camera");
138
+ }
139
+
140
+ //#endregion
141
+ //#region src/internal/permissions/permissionServices.ts
142
+ /**
143
+ * Checks the current camera permission state without prompting the user.
144
+ */
145
+ async function checkPermission() {
146
+ return queryCameraPermission();
147
+ }
148
+ /**
149
+ * Requests motion sensor permission. Must be called during a user gesture on iOS.
150
+ * Returns the permission result.
151
+ */
152
+ async function requestMotionPermission() {
153
+ return new MotionSensorProvider().requestPermission();
154
+ }
155
+ /**
156
+ * Requests camera permission by attempting to access the camera, then immediately
157
+ * stops the obtained stream. Also requests motion sensor permission (required on iOS
158
+ * to be called during a user gesture). This function does not keep or return the stream.
159
+ */
160
+ async function requestPermission() {
161
+ try {
162
+ await requestMotionPermission();
163
+ stopCameraStream(await requestCameraAccess({ video: true }));
164
+ return "granted";
165
+ } catch (error) {
166
+ const name = error instanceof Error ? error.name : void 0;
167
+ if (name === "NotAllowedError" || name === "PermissionDeniedError") return "denied";
168
+ return "prompt";
169
+ }
170
+ }
171
+
172
+ //#endregion
173
+ //#region ../infra/src/providers/browser/openviduLazy.ts
174
+ let openViduImport;
175
+ async function loadOpenVidu() {
176
+ if (openViduImport) return openViduImport;
177
+ openViduImport = import("./lib-B5byelWf.esm.js").then(__toDynamicImportESM(1));
178
+ return openViduImport;
179
+ }
180
+
181
+ //#endregion
182
+ //#region ../infra/src/providers/browser/OpenViduRecordingProvider.ts
183
+ function createHiddenContainer() {
184
+ const id = `inc_rec_${Math.random().toString(36).slice(2)}`;
185
+ const existing = document.getElementById(id);
186
+ if (existing) return {
187
+ id,
188
+ element: existing
189
+ };
190
+ const div = document.createElement("div");
191
+ div.id = id;
192
+ div.style.display = "none";
193
+ document.body.appendChild(div);
194
+ return {
195
+ id,
196
+ element: div
197
+ };
198
+ }
199
+ var OpenViduRecordingProvider = class {
200
+ async connect(params) {
201
+ const { OpenVidu } = await loadOpenVidu();
202
+ const container = createHiddenContainer();
203
+ const ov = new OpenVidu();
204
+ const session = ov.initSession();
205
+ const videoTrack = params.stream.getVideoTracks()[0];
206
+ const audioTrack = params.stream.getAudioTracks()[0];
207
+ const hasAudio = audioTrack !== void 0;
208
+ const publisher = ov.initPublisher(container.id, {
209
+ publishAudio: hasAudio,
210
+ audioSource: hasAudio ? audioTrack : false,
211
+ videoSource: videoTrack ?? false,
212
+ frameRate: 30
213
+ });
214
+ session.on("exception", (event) => {
215
+ const e = event;
216
+ params.events?.onSessionException?.({
217
+ name: e?.name,
218
+ message: e?.message,
219
+ sessionId: session.sessionId
220
+ });
221
+ });
222
+ publisher.on("streamCreated", () => {
223
+ params.events?.onPublisherCreated?.({
224
+ sessionId: session.sessionId,
225
+ streamId: publisher.stream?.streamId
226
+ });
227
+ });
228
+ await session.connect(params.sessionToken);
229
+ params.events?.onSessionConnected?.(session.sessionId);
230
+ try {
231
+ await session.publish(publisher);
232
+ } catch (error) {
233
+ const message = error instanceof Error ? error.message : String(error);
234
+ params.events?.onPublisherError?.({
235
+ message,
236
+ sessionId: session.sessionId,
237
+ streamId: publisher.stream?.streamId
238
+ });
239
+ throw error;
240
+ }
241
+ return {
242
+ sessionId: session.sessionId,
243
+ publisher: {
244
+ getStreamId: () => publisher.stream?.streamId,
245
+ replaceVideoTrack: async (track) => {
246
+ await publisher.replaceTrack(track);
247
+ },
248
+ destroy: () => {}
249
+ },
250
+ disconnect: async () => {
251
+ try {
252
+ session.disconnect();
253
+ params.stream.getTracks().forEach((t) => {
254
+ t.stop();
255
+ });
256
+ } finally {
257
+ params.events?.onSessionDisconnected?.(session.sessionId);
258
+ if (container.element.parentNode) container.element.parentNode.removeChild(container.element);
259
+ }
260
+ }
261
+ };
262
+ }
263
+ };
264
+
265
+ //#endregion
266
+ //#region src/internal/recordings/recordingsRepository.ts
267
+ async function createRecordingSession(type) {
268
+ return (await api.post(endpoints.recordingCreateSessionV2, { type })).data;
269
+ }
270
+ async function startRecording(params) {
271
+ return (await api.post(endpoints.recordingStartV2, {
272
+ videoRecordingId: params.videoRecordingId,
273
+ frameRate: 30,
274
+ outputMode: "COMPOSED",
275
+ resolution: params.resolution,
276
+ type: params.type,
277
+ hasAudio: params.hasAudio ?? false
278
+ })).data;
279
+ }
280
+ async function stopRecording(videoRecordingId) {
281
+ return (await api.post(endpoints.recordingStopV2, { videoRecordingId })).data;
282
+ }
283
+ async function uploadDeepsightVideo(encryptedVideo, token) {
284
+ try {
285
+ return (await api.post(endpoints.deepsightVideoImport, {
286
+ video: encryptedVideo,
287
+ type: "selfie"
288
+ }, { headers: { "X-Incode-Hardware-Id": token } })).data.recordingId ?? "";
289
+ } catch {
290
+ return "";
291
+ }
292
+ }
293
+
294
+ //#endregion
295
+ //#region ../infra/src/media/StreamCanvasCapture.ts
296
+ var StreamCanvasCapture = class {
297
+ constructor(stream, options) {
298
+ this.hasFrame = false;
299
+ this.disposed = false;
300
+ this.eventTarget = new EventTarget();
301
+ this.video = document.createElement("video");
302
+ this.video.srcObject = stream;
303
+ this.video.autoplay = true;
304
+ this.video.playsInline = true;
305
+ this.video.muted = true;
306
+ const settings = stream.getVideoTracks()[0]?.getSettings();
307
+ const initialWidth = options?.width ?? settings?.width ?? 1280;
308
+ const initialHeight = options?.height ?? settings?.height ?? 720;
309
+ this.canvas = document.createElement("canvas");
310
+ this.canvas.width = initialWidth;
311
+ this.canvas.height = initialHeight;
312
+ this.ctx = this.canvas.getContext("2d", { willReadFrequently: true });
313
+ const fps = options?.fps ?? 10;
314
+ const intervalMs = fps > 0 ? Math.max(16, Math.floor(1e3 / fps)) : 0;
315
+ this.video.addEventListener("loadedmetadata", () => {
316
+ if (this.video.videoWidth > 0 && this.video.videoHeight > 0) {
317
+ this.canvas.width = this.video.videoWidth;
318
+ this.canvas.height = this.video.videoHeight;
319
+ }
320
+ });
321
+ try {
322
+ this.video.play();
323
+ } catch {}
324
+ this.rafLoop(intervalMs);
325
+ }
326
+ addEventListener(type, listener, options) {
327
+ this.eventTarget.addEventListener(type, listener, options);
328
+ }
329
+ removeEventListener(type, listener, options) {
330
+ this.eventTarget.removeEventListener(type, listener, options);
331
+ }
332
+ /**
333
+ * Returns the latest cached frame as an {@link IncodeCanvas}.
334
+ */
335
+ getLatestCanvas() {
336
+ if (!this.hasFrame) this.tick();
337
+ if (!this.hasFrame) return null;
338
+ return new IncodeCanvas(this.canvas);
339
+ }
340
+ /**
341
+ * Returns the latest cached frame as raw {@link ImageData}.
342
+ */
343
+ getLatestFrame() {
344
+ if (!this.ctx) return null;
345
+ if (!this.hasFrame) this.tick();
346
+ if (!this.hasFrame) return null;
347
+ try {
348
+ return this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
349
+ } catch {
350
+ return null;
351
+ }
352
+ }
353
+ /**
354
+ * Disposes internal resources and stops the capture loop.
355
+ */
356
+ dispose() {
357
+ if (this.disposed) return;
358
+ this.disposed = true;
359
+ if (this.rafId !== void 0) {
360
+ window.cancelAnimationFrame(this.rafId);
361
+ this.rafId = void 0;
362
+ }
363
+ this.video.srcObject = null;
364
+ this.canvas.width = 0;
365
+ this.canvas.height = 0;
366
+ this.hasFrame = false;
367
+ }
368
+ rafLoop(intervalMs) {
369
+ const loop = (timeMs) => {
370
+ if (this.disposed) return;
371
+ if (intervalMs <= 0 || this.lastTickTimeMs === void 0 || timeMs - this.lastTickTimeMs >= intervalMs) {
372
+ this.lastTickTimeMs = timeMs;
373
+ const previousFrameTimeSeconds = this.lastFrameTimeSeconds;
374
+ this.tick();
375
+ const currentFrameTimeSeconds = this.video.currentTime;
376
+ if (previousFrameTimeSeconds === void 0) {
377
+ if (this.hasFrame) {
378
+ this.lastFrameTimeSeconds = currentFrameTimeSeconds;
379
+ this.eventTarget.dispatchEvent(new Event("frame"));
380
+ }
381
+ } else if (this.hasFrame && currentFrameTimeSeconds !== previousFrameTimeSeconds) {
382
+ this.lastFrameTimeSeconds = currentFrameTimeSeconds;
383
+ this.eventTarget.dispatchEvent(new Event("frame"));
384
+ }
385
+ }
386
+ this.rafId = window.requestAnimationFrame(loop);
387
+ };
388
+ this.rafId = window.requestAnimationFrame(loop);
389
+ }
390
+ tick() {
391
+ if (!this.ctx) return;
392
+ if (this.video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) return;
393
+ const videoWidth = this.video.videoWidth;
394
+ const videoHeight = this.video.videoHeight;
395
+ if (videoWidth === 0 || videoHeight === 0) return;
396
+ if (this.canvas.width !== videoWidth || this.canvas.height !== videoHeight) {
397
+ this.canvas.width = videoWidth;
398
+ this.canvas.height = videoHeight;
399
+ }
400
+ try {
401
+ this.ctx.drawImage(this.video, 0, 0);
402
+ this.hasFrame = true;
403
+ } catch {
404
+ this.hasFrame = false;
405
+ }
406
+ }
407
+ };
408
+
409
+ //#endregion
410
+ export { uploadDeepsightVideo as a, requestPermission as c, flagIdManualReview as d, BrowserStorageProvider as f, stopRecording as i, StreamCanvasProcessingSession as l, createRecordingSession as n, OpenViduRecordingProvider as o, getDeviceClass as p, startRecording as r, checkPermission as s, StreamCanvasCapture as t, flagFaceManualReview as u };