@incodetech/core 2.0.0-alpha.13 → 2.0.0-alpha.15

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 (39) hide show
  1. package/dist/{OpenViduLogger-CRbRNZA7.esm.js → OpenViduLogger-BLxxXoyF.esm.js} +1 -1
  2. package/dist/OpenViduLogger-DyqID_-7.esm.js +3 -0
  3. package/dist/api-DfRLAneb.esm.js +53 -0
  4. package/dist/deepsightLoader-Ct3HSIhk.esm.js +24 -0
  5. package/dist/deepsightService-B8c8aZje.esm.js +236 -0
  6. package/dist/email.d.ts +5 -5
  7. package/dist/email.esm.js +16 -17
  8. package/dist/{xstate.esm-2hDiAXvZ.esm.js → endpoints-BUsSVoJV.esm.js} +28 -1
  9. package/dist/events-B8ZkhAZo.esm.js +285 -0
  10. package/dist/flow.d.ts +2 -3
  11. package/dist/flow.esm.js +18 -7
  12. package/dist/getDeviceClass-DkfbtsIJ.esm.js +41 -0
  13. package/dist/{id-DHVSW_wJ.esm.js → id-GPFS1Wo_.esm.js} +38 -36
  14. package/dist/id.d.ts +4 -5
  15. package/dist/id.esm.js +7 -6
  16. package/dist/{index-CbF_uI-x.d.ts → index-CJMK8K5u.d.ts} +3 -7
  17. package/dist/index.d.ts +220 -6
  18. package/dist/index.esm.js +12 -8
  19. package/dist/{lib-BJoLTN_W.esm.js → lib-CbAibJlt.esm.js} +2 -2
  20. package/dist/phone.d.ts +5 -5
  21. package/dist/phone.esm.js +16 -14
  22. package/dist/selfie.d.ts +119 -46
  23. package/dist/selfie.esm.js +284 -161
  24. package/dist/{endpoints-D9TGnxRK.esm.js → src-XSoNGEQW.esm.js} +242 -112
  25. package/dist/stats-DnU4uUFv.esm.js +16 -0
  26. package/dist/stats.d.ts +12 -0
  27. package/dist/stats.esm.js +4 -0
  28. package/dist/{streamingEvents-B3hNanPl.esm.js → streamingEvents-J6ffKmJL.esm.js} +35 -36
  29. package/dist/{types-BpCrZLU6.d.ts → types-CMR6NkxW.d.ts} +58 -1
  30. package/dist/{types-DZbrbPgj.d.ts → types-CRVSv38Q.d.ts} +10 -1
  31. package/package.json +2 -2
  32. package/dist/OpenViduLogger-Dy5P806a.esm.js +0 -3
  33. package/dist/StateMachine-pi8byl8C.d.ts +0 -58
  34. package/dist/addEvent-BGKc_lHF.esm.js +0 -16
  35. package/dist/deepsightLoader-B36_XZ7r.esm.js +0 -25
  36. package/dist/deepsightService-BWxcc4OC.esm.js +0 -225
  37. package/dist/recordingsRepository-D5MURoVB.esm.js +0 -40
  38. /package/dist/{Manager-BZUZTRPx.d.ts → Manager-Co-PsiG9.d.ts} +0 -0
  39. /package/dist/{chunk-FbsBJI8u.esm.js → chunk-V5DOKNPJ.esm.js} +0 -0
@@ -0,0 +1,285 @@
1
+ import { t as endpoints } from "./endpoints-BUsSVoJV.esm.js";
2
+ import { i as isApiConfigured, r as getToken, t as api } from "./api-DfRLAneb.esm.js";
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
+ //#region src/internal/events/addEvent.ts
14
+ const eventsQueue = [];
15
+ const eventSubscribers = [];
16
+ /**
17
+ * Subscribes to all SDK events for logging, debugging, or custom analytics.
18
+ * Returns an unsubscribe function.
19
+ *
20
+ * @param listener - Callback function that receives each event
21
+ * @returns Unsubscribe function to remove the listener
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const unsubscribe = subscribeEvent((event) => {
26
+ * console.log('[Event]', event.code, event.module);
27
+ * });
28
+ *
29
+ * // Later
30
+ * unsubscribe();
31
+ * ```
32
+ */
33
+ function subscribeEvent(listener) {
34
+ eventSubscribers.push(listener);
35
+ return () => {
36
+ const index = eventSubscribers.indexOf(listener);
37
+ if (index > -1) eventSubscribers.splice(index, 1);
38
+ };
39
+ }
40
+ function notifySubscribers(event) {
41
+ eventSubscribers.forEach((listener) => {
42
+ try {
43
+ listener(event);
44
+ } catch (_error) {}
45
+ });
46
+ }
47
+ /**
48
+ * Sends an event to the dashboard for tracking.
49
+ * Fire-and-forget: never blocks, never throws.
50
+ * Events are queued if SDK is not configured yet.
51
+ */
52
+ function addEvent(event) {
53
+ notifySubscribers(event);
54
+ const token = getToken();
55
+ if (!isApiConfigured() || !token) {
56
+ eventsQueue.push(event);
57
+ return;
58
+ }
59
+ api.post(endpoints.events, [{
60
+ code: event.code,
61
+ module: event.module,
62
+ screen: event.screen,
63
+ clientTimestamp: event.clientTimestamp ?? getTimestamp(),
64
+ payload: event.payload ?? {}
65
+ }]).catch(() => {});
66
+ }
67
+ /**
68
+ * Flushes any queued events that were sent before SDK was configured.
69
+ * Called automatically by setup() after token is set.
70
+ */
71
+ function flushEventQueue() {
72
+ if (!isApiConfigured() || !getToken()) return;
73
+ const queuedEvents = [...eventsQueue];
74
+ eventsQueue.length = 0;
75
+ for (const event of queuedEvents) addEvent(event);
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/internal/events/helpers.ts
80
+ function screenEvent(params) {
81
+ addEvent({
82
+ code: params.code,
83
+ module: params.module,
84
+ screen: params.screen,
85
+ clientTimestamp: getTimestamp(),
86
+ payload: params.payload
87
+ });
88
+ }
89
+ function moduleOpened(module, screen, payload) {
90
+ screenEvent({
91
+ module,
92
+ screen,
93
+ code: "moduleOpened",
94
+ payload
95
+ });
96
+ }
97
+ function moduleClosed(module, screen, payload) {
98
+ screenEvent({
99
+ module,
100
+ screen,
101
+ code: "moduleClosed",
102
+ payload
103
+ });
104
+ }
105
+ function screenOpened(module, screen, payload) {
106
+ screenEvent({
107
+ module,
108
+ screen,
109
+ code: "screenOpened",
110
+ payload
111
+ });
112
+ }
113
+ function screenClosed(module, screen, payload) {
114
+ screenEvent({
115
+ module,
116
+ screen,
117
+ code: "screenClosed",
118
+ payload
119
+ });
120
+ }
121
+
122
+ //#endregion
123
+ //#region src/internal/events/types.ts
124
+ const eventModuleNames = {
125
+ selfie: "SELFIE",
126
+ authFace: "AUTH_FACE",
127
+ mlConsent: "ML_CONSENT",
128
+ combinedConsent: "COMBINED_CONSENT",
129
+ curpValidation: "CURP_VALIDATION",
130
+ faceMatch: "FACE_MATCH",
131
+ qr: "QR",
132
+ videoSelfie: "VIDEO_ONBOARDING",
133
+ passport: "ID",
134
+ front: "ID",
135
+ back: "ID",
136
+ id: "ID",
137
+ document: "DOCUMENT_CAPTURE",
138
+ creditCard: "CREDIT_CARD_FRONT",
139
+ creditCardBack: "CREDIT_CARD_BACK",
140
+ conference: "CONFERENCE",
141
+ otp: "OTP",
142
+ signature: "SIGNATURE",
143
+ ekyc: "EXTERNAL_VERIFICATION",
144
+ globalWatchList: "GLOBAL_WATCHLIST",
145
+ customWatchList: "CUSTOM_WATCHLIST",
146
+ email: "EMAIL",
147
+ phone: "PHONE",
148
+ instantVerifyEmail: "INSTANT_VERIFY_EMAIL",
149
+ instantVerifyConsent: "INSTANT_VERIFY_CONSENT",
150
+ forms: "FORMS",
151
+ customModule: "CUSTOM_MODULE"
152
+ };
153
+ const eventScreenNames = {
154
+ faceMatch: "FACE_MATCH",
155
+ faceCaptureTutorial: "SELFIE_CAPTURE_TUTORIAL",
156
+ faceCaptureCamera: "SELFIE_CAMERA_CAPTURE",
157
+ faceCaptureError: "SELFIE_ATTEMPT_FAILED",
158
+ faceCaptureSuccess: "SELFIE_UPLOAD_SUCCEEDED",
159
+ faceCaptureUpload: "SELFIE_UPLOAD_PROGRESS",
160
+ mlConsent: "MACHINE_LEARNING_CONSENT",
161
+ combinedConsent: "COMBINED_CONSENT",
162
+ curpEnter: "ENTER_CURP",
163
+ curpValidate: "VALIDATE_CURP",
164
+ curpGenerate: "GENERATE_CURP",
165
+ curpValidation: "CURP_VALIDATION_PROGRESS",
166
+ curpValidationFailed: "CURP_VALIDATION_FAILED",
167
+ curpValidationSuccess: "CURP_VALIDATION_SUCCEEDED",
168
+ qrTutorial: "QR_TUTORIAL",
169
+ qrScan: "QR_SCAN",
170
+ smsOtp: "OTP",
171
+ simpleOTP: "OTP",
172
+ signatureInput: "SIGNATURE_INPUT",
173
+ frontTutorial: "FRONT_ID_CAPTURE_TUTORIAL",
174
+ frontCameraCapture: "FRONT_ID_CAMERA_CAPTURE",
175
+ frontHelp: "FRONT_ID_HELP",
176
+ frontReviewPhoto: "FRONT_ID_REVIEW_PHOTO",
177
+ frontUploadProgress: "FRONT_ID_UPLOAD_PROGRESS",
178
+ frontAttemptFailed: "FRONT_ID_ATTEMPT_FAILED",
179
+ frontUploadSuccess: "FRONT_ID_UPLOAD_SUCCEEDED",
180
+ backTutorial: "BACK_ID_CAPTURE_TUTORIAL",
181
+ backCameraCapture: "BACK_ID_CAMERA_CAPTURE",
182
+ backReviewPhoto: "BACK_ID_REVIEW_PHOTO",
183
+ backUploadProgress: "BACK_ID_UPLOAD_PROGRESS",
184
+ backAttemptFailed: "BACK_ID_ATTEMPT_FAILED",
185
+ backUploadSuccess: "BACK_ID_UPLOAD_SUCCEEDED",
186
+ backHelp: "BACK_ID_HELP",
187
+ passportTutorial: "TUTORIAL_PASSPORT",
188
+ documentTutorial: "DOCUMENT_CAPTURE_TUTORIAL",
189
+ documentCameraCapture: "DOCUMENT_CAMERA_CAPTURE",
190
+ documentHelp: "DOCUMENT_HELP",
191
+ documentReviewPhoto: "DOCUMENT_REVIEW_PHOTO",
192
+ documentUploadProgress: "DOCUMENT_UPLOAD_IN_PROGRESS",
193
+ documentAttemptFailed: "DOCUMENT_ATTEMPT_FAILED",
194
+ documentUploadSuccess: "DOCUMENT_UPLOAD_SUCCEEDED",
195
+ conferenceWait: "CONFERENCE_WAIT",
196
+ conferenceVideoChat: "CONFERENCE_VIDEO_CHAT",
197
+ conferenceMessageChat: "CONFERENCE_MESSAGE_CHAT",
198
+ videoSelfieTutorial: "VIDEO_SELFIE_TUTORIAL",
199
+ videoSelfie: "VIDEO_SELFIE",
200
+ videoSelfieFaceCapture: "VIDEO_SELFIE_FACE_CAPTURE",
201
+ videoSelfieFaceUploadProgress: "VIDEO_SELFIE_FACE_UPLOAD_PROGRESS",
202
+ videoSelfieFaceAttemptFailed: "VIDEO_SELFIE_FACE_ATTEMPT_FAILED",
203
+ videoSelfieFaceUploadSucceeded: "VIDEO_SELFIE_FACE_UPLOAD_SUCCEEDED",
204
+ videoSelfieFrontIdCapture: "VIDEO_SELFIE_FRONT_ID_CAPTURE",
205
+ videoSelfieFrontIdUploadProgress: "VIDEO_SELFIE_FRONT_ID_UPLOAD_PROGRESS",
206
+ videoSelfieFrontIdAttemptFailed: "VIDEO_SELFIE_FRONT_ID_ATTEMPT_FAILED",
207
+ videoSelfieFrontIdUploadSucceeded: "VIDEO_SELFIE_FRONT_ID_UPLOAD_SUCCEEDED",
208
+ videoSelfieBackIdCapture: "VIDEO_SELFIE_BACK_ID_CAPTURE",
209
+ videoSelfieBackIdUploadProgress: "VIDEO_SELFIE_BACK_ID_UPLOAD_PROGRESS",
210
+ videoSelfieBackIdAttemptFailed: "VIDEO_SELFIE_BACK_ID_ATTEMPT_FAILED",
211
+ videoSelfieBackIdUploadSucceeded: "VIDEO_SELFIE_BACK_ID_UPLOAD_SUCCEEDED",
212
+ videoSelfieDocumentCapture: "VIDEO_SELFIE_DOCUMENT_CAPTURE",
213
+ videoSelfieVoiceQuestion: "VIDEO_SELFIE_VOICE_QUESTION",
214
+ videoSelfieVoiceFinalQuestion: "VIDEO_SELFIE_VOICE_FINAL_QUESTION",
215
+ videoSelfieVideoUpload: "VIDEO SELFIE VIDEO UPLOAD",
216
+ ekycInput: "EKYC_INPUT",
217
+ ekycProgress: "EKYC_PROGRESS",
218
+ ekycSucceeded: "EKYC_SUCCEEDED",
219
+ ekycFailed: "EKYC_FAILED",
220
+ forms: "FORMS",
221
+ globalWatchListInput: "GLOBAL_WATCHLIST_INPUT",
222
+ globalWatchListProgress: "GLOBAL_WATCHLIST_PROGRESS",
223
+ globalWatchListSuccess: "GLOBAL_WATCHLIST_SUCCEEDED",
224
+ globalWatchListFailed: "GLOBAL_WATCHLIST_FAILED",
225
+ customWatchListInput: "CUSTOM_WATCHLIST_INPUT",
226
+ customWatchListProgress: "CUSTOM_WATCHLIST_PROGRESS",
227
+ customWatchListSuccess: "CUSTOM_WATCHLIST_SUCCEEDED",
228
+ customWatchListFailed: "CUSTOM_WATCHLIST_FAILED",
229
+ emailInput: "EMAIL_INPUT",
230
+ phoneInput: "PHONE_INPUT",
231
+ instantVerify: "INSTANT_VERIFY",
232
+ authFace: "AUTH_FACE",
233
+ authFaceError: "AUTH_FACE_ATTEMPT_FAILED",
234
+ authFaceUpload: "AUTH_FACE_UPLOAD_PROGRESS",
235
+ authFaceUploadSuccess: "AUTH_FACE_UPLOAD_SUCCEEDED",
236
+ authFaceUploadFailed: "AUTH_FACE_UPLOAD_FAILED",
237
+ customModuleCallback: "CUSTOM_MODULE_CALLBACK",
238
+ customModuleProcessing: "CUSTOM_MODULE_PROCESSING",
239
+ digitalIdFileSelection: "DIGITAL_ID_FILE_SELECTION",
240
+ digitalIdFileReview: "DIGITAL_ID_FILE_REVIEW",
241
+ digitalIdUploadProgress: "DIGITAL_ID_UPLOAD_PROGRESS",
242
+ digitalIdUploadSuccess: "DIGITAL_ID_UPLOAD_SUCCEEDED",
243
+ digitalIdUploadFailed: "DIGITAL_ID_UPLOAD_FAILED",
244
+ digitalIdAnalysisProgress: "DIGITAL_ID_ANALYSIS_PROGRESS",
245
+ digitalIdVerificationSuccess: "DIGITAL_ID_VERIFICATION_SUCCESS",
246
+ digitalIdVerificationFailed: "DIGITAL_ID_VERIFICATION_FAILED"
247
+ };
248
+ const videoSelfieEvents = {
249
+ imageTooBlurry: "imageTooBlurry",
250
+ fillFrame: "fillFrame",
251
+ checkCameraOrLighting: "checkCameraOrLighting",
252
+ frontIdCaptureStarted: "frontIdCaptureStarted",
253
+ lookAtCamera: "lookAtCamera",
254
+ moveCloser: "moveCloser",
255
+ lookingForFrontId: "lookingForFrontId",
256
+ lookingForBackId: "lookingForBackId",
257
+ cameraSwitchToBack: "cameraSwitchToBack",
258
+ cameraSwitchToFront: "cameraSwitchToFront",
259
+ audioStreamOpened: "audioStreamOpened",
260
+ audioStreamClosed: "audioStreamClosed",
261
+ videoSelfieVideoUploadInProgress: "videoSelfieVideoUploadInProgress",
262
+ videoSelfieTosNotAccepted: "videoSelfieTosNotAccepted",
263
+ videoSelfieTosAccepted: "videoSelfieTosAccepted",
264
+ videoSelfieStreamCreated: "videoSelfieStreamCreated",
265
+ videoSelfieStreamDestroyed: "videoSelfieStreamDestroyed",
266
+ videoSelfieReconnecting: "videoSelfieReconnecting",
267
+ videoSelfieReconnected: "videoSelfieReconnected"
268
+ };
269
+ const tutorialScreenNamesMapper = {
270
+ passport: eventScreenNames.passportTutorial,
271
+ front: eventScreenNames.frontTutorial,
272
+ back: eventScreenNames.backTutorial,
273
+ selfie: eventScreenNames.faceCaptureTutorial
274
+ };
275
+ const cameraScreenNamesMapper = {
276
+ front: "front",
277
+ back: "back",
278
+ passport: "passport",
279
+ creditCard: "front",
280
+ creditCardBack: "back",
281
+ document: "document"
282
+ };
283
+
284
+ //#endregion
285
+ export { videoSelfieEvents as a, screenClosed as c, addEvent as d, flushEventQueue as f, tutorialScreenNamesMapper as i, screenEvent as l, revokeObjectURL as m, eventModuleNames as n, moduleClosed as o, subscribeEvent as p, eventScreenNames as r, moduleOpened as s, cameraScreenNamesMapper as t, screenOpened as u };
package/dist/flow.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { r as WasmPipeline, t as AnyStateMachine } from "./StateMachine-pi8byl8C.js";
2
- import { t as Manager } from "./Manager-BZUZTRPx.js";
3
- import { n as FlowModule, r as FlowModuleConfig, t as Flow } from "./types-BpCrZLU6.js";
1
+ import { a as AnyStateMachine, n as FlowModule, r as FlowModuleConfig, s as WasmPipeline, t as Flow } from "./types-CMR6NkxW.js";
2
+ import { t as Manager } from "./Manager-Co-PsiG9.js";
4
3
 
5
4
  //#region src/modules/flow/flowAnalyzer.d.ts
6
5
 
package/dist/flow.esm.js CHANGED
@@ -1,5 +1,6 @@
1
- import { E as createManager, n as api, t as endpoints } from "./endpoints-D9TGnxRK.esm.js";
2
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-2hDiAXvZ.esm.js";
1
+ import { C as createManager } from "./src-XSoNGEQW.esm.js";
2
+ import { a as fromPromise, i as fromCallback, n as setup, o as createActor, r as assign, t as endpoints } from "./endpoints-BUsSVoJV.esm.js";
3
+ import { t as api } from "./api-DfRLAneb.esm.js";
3
4
 
4
5
  //#region src/modules/flow/flowAnalyzer.ts
5
6
  const WASM_MODULE_PIPELINES = {
@@ -379,22 +380,32 @@ const orchestratedFlowMachine = setup({
379
380
  })),
380
381
  setFlowData: assign(({ event }) => {
381
382
  const flow = event.output;
383
+ const flowModules = flow.flowModules ?? [];
384
+ const firstModule = flowModules[0];
385
+ const config = {
386
+ ...firstModule?.configuration,
387
+ ds: flow.ds
388
+ };
382
389
  return {
383
390
  flow,
384
- steps: (flow.flowModules ?? []).map((m) => m.key),
385
- currentStepIndex: (flow.flowModules ?? []).length > 0 ? 0 : -1,
386
- currentStep: flow.flowModules?.[0]?.key,
387
- config: flow.flowModules?.[0]?.configuration
391
+ steps: Object.keys(flowModules),
392
+ currentStepIndex: flowModules.length > 0 ? 0 : -1,
393
+ currentStep: firstModule?.key,
394
+ config
388
395
  };
389
396
  }),
390
397
  setError: assign(({ event }) => ({ error: String(event.error) })),
391
398
  incrementStep: assign(({ context }) => {
392
399
  const nextIndex = context.currentStepIndex + 1;
393
400
  const module = context.flow?.flowModules?.[nextIndex];
401
+ const config = {
402
+ ...module?.configuration,
403
+ ds: context.flow?.ds
404
+ };
394
405
  return {
395
406
  currentStepIndex: nextIndex,
396
407
  currentStep: module?.key,
397
- config: module?.configuration
408
+ config
398
409
  };
399
410
  }),
400
411
  setFinishStatus: assign(({ event }) => ({ finishStatus: event.output }))
@@ -0,0 +1,41 @@
1
+ //#region ../infra/src/device/getBrowser.ts
2
+ function getUserAgent() {
3
+ if (typeof navigator === "undefined") return "";
4
+ return navigator.userAgent;
5
+ }
6
+
7
+ //#endregion
8
+ //#region ../infra/src/device/getDeviceClass.ts
9
+ function getDeviceInfo() {
10
+ if (typeof navigator === "undefined") return {
11
+ userAgent: "",
12
+ platform: "",
13
+ maxTouchPoints: 0
14
+ };
15
+ return {
16
+ userAgent: navigator.userAgent,
17
+ platform: navigator.platform,
18
+ maxTouchPoints: navigator.maxTouchPoints
19
+ };
20
+ }
21
+ /**
22
+ * Gets the current window dimensions.
23
+ * Returns default values (1280x720) in non-browser environments.
24
+ */
25
+ function getWindowDimensions(defaultWidth = 1280, defaultHeight = 720) {
26
+ if (typeof window === "undefined") return {
27
+ outerWidth: defaultWidth,
28
+ outerHeight: defaultHeight,
29
+ innerWidth: defaultWidth,
30
+ innerHeight: defaultHeight
31
+ };
32
+ return {
33
+ outerWidth: window.outerWidth,
34
+ outerHeight: window.outerHeight,
35
+ innerWidth: window.innerWidth,
36
+ innerHeight: window.innerHeight
37
+ };
38
+ }
39
+
40
+ //#endregion
41
+ export { getWindowDimensions as n, getUserAgent as r, getDeviceInfo as t };
@@ -1,9 +1,16 @@
1
- import { A as isIOS, C as enumerateVideoDevices, E as createManager, M as isSafari, O as isAndroid, S as applyTrackConstraints, T as stopCameraStream, c as DEFAULT_ID_CAPTURE_MODEL_VERSION, h as OpenViduRecordingProvider, j as isIPhone14OrHigher, k as isDesktop, l as DEFAULT_ID_CAPTURE_THRESHOLDS, n as api, t as endpoints, v as StreamCanvasProcessingSession, w as requestCameraAccess, x as IncodeCanvas, y as StreamCanvasCapture } from "./endpoints-D9TGnxRK.esm.js";
2
- import { n as startRecording, r as stopRecording$1, t as createRecordingSession } from "./recordingsRepository-D5MURoVB.esm.js";
3
- import { i as getDeviceClass, n as checkPermission, o as getWindowDimensions, r as requestPermission, t as streamingEvents } from "./streamingEvents-B3hNanPl.esm.js";
4
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-2hDiAXvZ.esm.js";
5
- import { t as addEvent } from "./addEvent-BGKc_lHF.esm.js";
1
+ import { d as addEvent, m as revokeObjectURL, n as eventModuleNames } from "./events-B8ZkhAZo.esm.js";
2
+ import { C as createManager, D as isIOS, E as isDesktop, O as isIPhone14OrHigher, S as stopCameraStream, T as isAndroid, b as enumerateVideoDevices, c as OpenViduRecordingProvider, d as BrowserTimerProvider, h as StreamCanvasCapture, k as isSafari, m as StreamCanvasProcessingSession, n as DEFAULT_ID_CAPTURE_THRESHOLDS, t as DEFAULT_ID_CAPTURE_MODEL_VERSION, v as IncodeCanvas, x as requestCameraAccess, y as applyTrackConstraints } from "./src-XSoNGEQW.esm.js";
3
+ import { n as getWindowDimensions } from "./getDeviceClass-DkfbtsIJ.esm.js";
4
+ import { a as fromPromise, i as fromCallback, n as setup, o as createActor, r as assign, t as endpoints } from "./endpoints-BUsSVoJV.esm.js";
5
+ import { c as getDeviceClass, i as stopRecording$1, n as createRecordingSession, o as checkPermission, r as startRecording, s as requestPermission, t as streamingEvents } from "./streamingEvents-J6ffKmJL.esm.js";
6
+ import { t as api } from "./api-DfRLAneb.esm.js";
6
7
 
8
+ //#region ../infra/src/capabilities/ITimerCapability.ts
9
+ function sleep(ms) {
10
+ return new Promise((resolve) => setTimeout(resolve, ms));
11
+ }
12
+
13
+ //#endregion
7
14
  //#region src/modules/id/idCameraStream.ts
8
15
  const BACK_CAMERA_KEYWORDS = [
9
16
  "rear",
@@ -151,9 +158,6 @@ function getAndroidVideoConstraints(level) {
151
158
  default: return {};
152
159
  }
153
160
  }
154
- function delay(ms) {
155
- return new Promise((resolve) => setTimeout(resolve, ms));
156
- }
157
161
  async function getAndroidBackCameraStream(fallbackLevel = 0) {
158
162
  if (fallbackLevel > 4) throw new Error("Failed to get camera after all fallback attempts");
159
163
  try {
@@ -180,11 +184,11 @@ async function getAndroidBackCameraStream(fallbackLevel = 0) {
180
184
  const errorName = error instanceof Error ? error.name : "UnknownError";
181
185
  const nextLevel = Math.min(fallbackLevel + 1, 4);
182
186
  if (errorName === "NotReadableError") {
183
- await delay(300);
187
+ await sleep(300);
184
188
  return getAndroidBackCameraStream(nextLevel);
185
189
  }
186
190
  if (errorName === "AbortError") {
187
- await delay(300);
191
+ await sleep(300);
188
192
  return getAndroidBackCameraStream(fallbackLevel);
189
193
  }
190
194
  return getAndroidBackCameraStream(nextLevel);
@@ -352,7 +356,7 @@ async function uploadIdImage(params) {
352
356
  const { type, image, onProgress, signal, metadata, ageAssurance, glare, sharpness, shouldSkipGlareBack } = params;
353
357
  addEvent({
354
358
  code: "captureAttemptFinished",
355
- module: "ID",
359
+ module: eventModuleNames.id,
356
360
  payload: { logs: [] }
357
361
  });
358
362
  const endpoint = type === "front" ? endpoints.frontId : endpoints.backId;
@@ -428,6 +432,7 @@ async function startRecordingSession(params) {
428
432
  onSessionConnected: (sessionId) => {
429
433
  addEvent({
430
434
  code: streamingEvents.strSessionDidConnect,
435
+ module: eventModuleNames.id,
431
436
  payload: {
432
437
  message: "Recording session connected",
433
438
  sessionId
@@ -437,6 +442,7 @@ async function startRecordingSession(params) {
437
442
  onSessionDisconnected: (sessionId) => {
438
443
  addEvent({
439
444
  code: streamingEvents.strSessionDidDisconnect,
445
+ module: eventModuleNames.id,
440
446
  payload: {
441
447
  message: "Recording session disconnected",
442
448
  sessionId
@@ -446,6 +452,7 @@ async function startRecordingSession(params) {
446
452
  onSessionException: (event) => {
447
453
  addEvent({
448
454
  code: streamingEvents.strSessionDidFailWithError,
455
+ module: eventModuleNames.id,
449
456
  payload: {
450
457
  message: "Recording session failed due to an error",
451
458
  eventName: event.name,
@@ -458,6 +465,7 @@ async function startRecordingSession(params) {
458
465
  onPublisherCreated: (p) => {
459
466
  addEvent({
460
467
  code: streamingEvents.strStreamPublisherCreated,
468
+ module: eventModuleNames.id,
461
469
  payload: {
462
470
  message: "Recording publisher created",
463
471
  sessionId: p.sessionId,
@@ -468,6 +476,7 @@ async function startRecordingSession(params) {
468
476
  onPublisherError: (p) => {
469
477
  addEvent({
470
478
  code: streamingEvents.strStreamPublisherDidFailWithError,
479
+ module: eventModuleNames.id,
471
480
  payload: {
472
481
  message: "Recording publisher failed due to an error",
473
482
  sessionId: p.sessionId,
@@ -486,6 +495,7 @@ async function startRecordingSession(params) {
486
495
  });
487
496
  addEvent({
488
497
  code: streamingEvents.strStreamVideoCaptureStart,
498
+ module: eventModuleNames.id,
489
499
  payload: {
490
500
  message: "Recording capture started",
491
501
  resolution,
@@ -508,6 +518,7 @@ function stopRecording(session) {
508
518
  try {
509
519
  addEvent({
510
520
  code: streamingEvents.strStreamVideoCaptureStop,
521
+ module: eventModuleNames.id,
511
522
  payload: {
512
523
  message: "Recording capture stopped",
513
524
  videoRecordingId: session.videoRecordingId,
@@ -518,6 +529,7 @@ function stopRecording(session) {
518
529
  await stopRecording$1(session.videoRecordingId);
519
530
  addEvent({
520
531
  code: streamingEvents.strStreamPublisherDestroyed,
532
+ module: eventModuleNames.id,
521
533
  payload: {
522
534
  message: "Recording publisher destroyed",
523
535
  sessionId: session.sessionId,
@@ -528,6 +540,7 @@ function stopRecording(session) {
528
540
  await session.connection.disconnect();
529
541
  addEvent({
530
542
  code: streamingEvents.strSessionDidDisconnect,
543
+ module: eventModuleNames.id,
531
544
  payload: {
532
545
  message: "Recording session disconnected",
533
546
  sessionId: session.sessionId
@@ -547,7 +560,7 @@ async function processId(isSecondId = false, queueName = "", signal) {
547
560
  function getIdErrorCodeFromUnknown(error) {
548
561
  if (error instanceof Error) {
549
562
  const message = error.message;
550
- for (const [, value] of Object.entries(ID_ERROR_CODES)) if (message.includes(value)) return value;
563
+ return Object.values(ID_ERROR_CODES).find((value) => message.includes(value));
551
564
  }
552
565
  }
553
566
  const _idCaptureMachine = setup({
@@ -580,25 +593,26 @@ const _idCaptureMachine = setup({
580
593
  let bestCanvas = null;
581
594
  let storedQualityElements = {};
582
595
  let isCapturing = false;
596
+ const timer = BrowserTimerProvider.getInstance();
583
597
  let notificationTimeout = null;
584
598
  let currentNotificationStatus = null;
585
599
  const NOTIFICATION_DURATION_MS = 500;
586
600
  const clearNotificationTimeout = () => {
587
601
  if (notificationTimeout) {
588
- clearTimeout(notificationTimeout);
602
+ timer.clearTimeout(notificationTimeout);
589
603
  notificationTimeout = null;
590
604
  currentNotificationStatus = null;
591
605
  }
592
606
  };
593
607
  const sendNotification = (status) => {
594
608
  if (notificationTimeout && currentNotificationStatus !== status) return;
595
- if (notificationTimeout && currentNotificationStatus === status) clearTimeout(notificationTimeout);
609
+ if (notificationTimeout && currentNotificationStatus === status) timer.clearTimeout(notificationTimeout);
596
610
  currentNotificationStatus = status;
597
611
  sendBack({
598
612
  type: "DETECTION_UPDATE",
599
613
  status
600
614
  });
601
- notificationTimeout = setTimeout(() => {
615
+ notificationTimeout = timer.setTimeout(() => {
602
616
  notificationTimeout = null;
603
617
  currentNotificationStatus = null;
604
618
  sendBack({
@@ -753,7 +767,7 @@ const _idCaptureMachine = setup({
753
767
  },
754
768
  reset: () => {
755
769
  if (notificationTimeout) {
756
- clearTimeout(notificationTimeout);
770
+ timer.clearTimeout(notificationTimeout);
757
771
  notificationTimeout = null;
758
772
  currentNotificationStatus = null;
759
773
  }
@@ -815,13 +829,14 @@ const _idCaptureMachine = setup({
815
829
  });
816
830
  return () => {};
817
831
  }
818
- const interval = setInterval(() => {
832
+ const timer = BrowserTimerProvider.getInstance();
833
+ const interval = timer.setInterval(() => {
819
834
  sendBack({
820
835
  type: "MOTION_STATUS",
821
836
  status: input.motionProvider.check()
822
837
  });
823
838
  }, 500);
824
- return () => clearInterval(interval);
839
+ return () => timer.clearInterval(interval);
825
840
  })
826
841
  },
827
842
  actions: {
@@ -889,6 +904,7 @@ const _idCaptureMachine = setup({
889
904
  trackTutorialId: () => {
890
905
  addEvent({
891
906
  code: "tutorialVideoStarted",
907
+ module: eventModuleNames.id,
892
908
  payload: { tutorialFrontID: true }
893
909
  });
894
910
  },
@@ -935,9 +951,8 @@ const _idCaptureMachine = setup({
935
951
  if (!canvasWidth || !canvasHeight) return;
936
952
  const originalCanvas = canvas;
937
953
  let frameRect;
954
+ const { innerWidth: viewportWidth, innerHeight: viewportHeight } = getWindowDimensions();
938
955
  if (context.detectionArea) {
939
- const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 1280;
940
- const viewportHeight = typeof window !== "undefined" ? window.innerHeight : 720;
941
956
  const scaleX = viewportWidth / canvasWidth;
942
957
  const scaleY = viewportHeight / canvasHeight;
943
958
  const scale = Math.max(scaleX, scaleY);
@@ -952,8 +967,6 @@ const _idCaptureMachine = setup({
952
967
  h: context.detectionArea.height / scale
953
968
  };
954
969
  } else if (context.frameRect) {
955
- const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 1280;
956
- const viewportHeight = typeof window !== "undefined" ? window.innerHeight : 720;
957
970
  const scaleX = viewportWidth / canvasWidth;
958
971
  const scaleY = viewportHeight / canvasHeight;
959
972
  const scale = Math.max(scaleX, scaleY);
@@ -987,8 +1000,6 @@ const _idCaptureMachine = setup({
987
1000
  h: maxY - minY
988
1001
  };
989
1002
  } else {
990
- const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 1280;
991
- const viewportHeight = typeof window !== "undefined" ? window.innerHeight : 720;
992
1003
  const frameViewportWidth = Math.min(387, viewportWidth * .9);
993
1004
  const frameViewportHeight = frameViewportWidth / (35 / 22);
994
1005
  const frameViewportX = (viewportWidth - frameViewportWidth) / 2;
@@ -1011,7 +1022,7 @@ const _idCaptureMachine = setup({
1011
1022
  uploadError: () => void 0,
1012
1023
  detectionStatus: () => "idle",
1013
1024
  previewImageUrl: ({ context }) => {
1014
- if (context.previewImageUrl) URL.revokeObjectURL(context.previewImageUrl);
1025
+ if (context.previewImageUrl) revokeObjectURL(context.previewImageUrl);
1015
1026
  },
1016
1027
  uploadProgress: () => void 0
1017
1028
  }),
@@ -1044,12 +1055,7 @@ const _idCaptureMachine = setup({
1044
1055
  const transformedImage = (context.provider?.getCapturedCanvas())?.getBase64Image(1, true);
1045
1056
  let fallbackImage = "";
1046
1057
  if ("output" in event) fallbackImage = event.output.originalImage ?? "";
1047
- const imageData = {
1048
- imageBase64: transformedImage ?? fallbackImage,
1049
- blob: new Blob(),
1050
- url: "",
1051
- metadata: ""
1052
- };
1058
+ const imageData = { imageBase64: transformedImage ?? fallbackImage };
1053
1059
  if (context.currentMode === "front" || context.currentMode === "passport") return {
1054
1060
  ...context.capturedImages,
1055
1061
  front: imageData
@@ -1603,11 +1609,7 @@ const _idCaptureMachine = setup({
1603
1609
  "stopMediaStream",
1604
1610
  "disposeProvider"
1605
1611
  ],
1606
- type: "final",
1607
- on: { RESET: {
1608
- target: "idle",
1609
- actions: "resetContext"
1610
- } }
1612
+ type: "final"
1611
1613
  },
1612
1614
  closed: {
1613
1615
  entry: ["stopMediaStream", "disposeProvider"],
package/dist/id.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { a as CameraStream, n as PermissionStatus, t as PermissionResult } from "./types-DZbrbPgj.js";
2
- import { A as IdCaptureMode, B as IIdCaptureCapability, C as CaptureIdResponse, D as ID_ERROR_CODES, E as DetectionStatus, F as IdFlowStep, I as RecordingSession, L as UploadIdResponse, M as IdDocumentType, N as IdError, O as IdCaptureConfig, P as IdErrorCode, R as IdCaptureProvider, S as validateUploadResponse, T as DetectionArea, V as IdCaptureSettings, _ as processId, a as IdCaptureActor, b as stopStream, c as IdCaptureEvent, d as idCaptureMachine, f as IdCaptureInitResult, g as initializeIdCapture, h as ValidationError, i as CreateIdCaptureActorOptions, j as IdCaptureThresholds, k as IdCaptureGeometry, l as IdCaptureInput, m as UploadIdImageParams, n as IdCaptureState, o as createIdCaptureActor, p as StartRecordingParams, r as createIdCaptureManager, s as IdCaptureContext, t as IdCaptureManager, u as IdCaptureMachine, v as startRecordingSession, w as CapturedImage, x as uploadIdImage, y as stopRecording, z as DetectionOrientation } from "./index-CbF_uI-x.js";
3
- import "./StateMachine-pi8byl8C.js";
4
- import "./Manager-BZUZTRPx.js";
5
- import "./types-BpCrZLU6.js";
1
+ import { a as CameraStream, n as PermissionStatus, t as PermissionResult } from "./types-CRVSv38Q.js";
2
+ import { A as IdCaptureMode, B as IIdCaptureCapability, C as CaptureIdResponse, D as ID_ERROR_CODES, E as DetectionStatus, F as IdFlowStep, I as RecordingSession, L as UploadIdResponse, M as IdDocumentType, N as IdError, O as IdCaptureConfig, P as IdErrorCode, R as IdCaptureProvider, S as validateUploadResponse, T as DetectionArea, V as IdCaptureSettings, _ as processId, a as IdCaptureActor, b as stopStream, c as IdCaptureEvent, d as idCaptureMachine, f as IdCaptureInitResult, g as initializeIdCapture, h as ValidationError, i as CreateIdCaptureActorOptions, j as IdCaptureThresholds, k as IdCaptureGeometry, l as IdCaptureInput, m as UploadIdImageParams, n as IdCaptureState, o as createIdCaptureActor, p as StartRecordingParams, r as createIdCaptureManager, s as IdCaptureContext, t as IdCaptureManager, u as IdCaptureMachine, v as startRecordingSession, w as CapturedImage, x as uploadIdImage, y as stopRecording, z as DetectionOrientation } from "./index-CJMK8K5u.js";
3
+ import "./types-CMR6NkxW.js";
4
+ import "./Manager-Co-PsiG9.js";
6
5
  export { CameraStream, CaptureIdResponse, CapturedImage, CreateIdCaptureActorOptions, DetectionArea, DetectionOrientation, DetectionStatus, ID_ERROR_CODES, IIdCaptureCapability, IdCaptureActor, IdCaptureConfig, IdCaptureContext, IdCaptureEvent, IdCaptureGeometry, IdCaptureInitResult, IdCaptureInput, IdCaptureMachine, IdCaptureManager, IdCaptureMode, IdCaptureProvider, IdCaptureSettings, IdCaptureState, IdCaptureThresholds, IdDocumentType, IdError, IdErrorCode, IdFlowStep, PermissionResult, PermissionStatus, RecordingSession, StartRecordingParams, UploadIdImageParams, UploadIdResponse, ValidationError, createIdCaptureActor, createIdCaptureManager, idCaptureMachine, initializeIdCapture, processId, startRecordingSession, stopRecording, stopStream, uploadIdImage, validateUploadResponse };
package/dist/id.esm.js CHANGED
@@ -1,8 +1,9 @@
1
- import { d as IdCaptureProvider } from "./endpoints-D9TGnxRK.esm.js";
2
- import "./recordingsRepository-D5MURoVB.esm.js";
3
- import "./streamingEvents-B3hNanPl.esm.js";
4
- import "./xstate.esm-2hDiAXvZ.esm.js";
5
- import "./addEvent-BGKc_lHF.esm.js";
6
- import { a as processId, c as stopStream, d as ID_ERROR_CODES, i as initializeIdCapture, l as uploadIdImage, n as createIdCaptureActor, o as startRecordingSession, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-DHVSW_wJ.esm.js";
1
+ import "./events-B8ZkhAZo.esm.js";
2
+ import { a as processId, c as stopStream, d as ID_ERROR_CODES, i as initializeIdCapture, l as uploadIdImage, n as createIdCaptureActor, o as startRecordingSession, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-GPFS1Wo_.esm.js";
3
+ import { i as IdCaptureProvider } from "./src-XSoNGEQW.esm.js";
4
+ import "./getDeviceClass-DkfbtsIJ.esm.js";
5
+ import "./endpoints-BUsSVoJV.esm.js";
6
+ import "./streamingEvents-J6ffKmJL.esm.js";
7
+ import "./api-DfRLAneb.esm.js";
7
8
 
8
9
  export { ID_ERROR_CODES, IdCaptureProvider, createIdCaptureActor, createIdCaptureManager, idCaptureMachine, initializeIdCapture, processId, startRecordingSession, stopRecording, stopStream, uploadIdImage, validateUploadResponse };