@incodetech/core 2.0.0-alpha.10 → 2.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/flow.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { t as WasmPipeline } from "./warmup-CEJTfxQr.js";
2
- import { t as Manager } from "./Manager-BGfxEmyv.js";
3
- import { t as AnyStateMachine } from "./StateMachine-DRE1oH2B.js";
1
+ import { t as WasmPipeline } from "./warmup-Cijuyvoc.js";
2
+ import { t as Manager } from "./Manager-Cy9-TMC9.js";
3
+ import { t as AnyStateMachine } from "./StateMachine-BqPpBhOz.js";
4
4
 
5
5
  //#region src/modules/flow/types.d.ts
6
6
  type EmptyConfig = Record<string, never>;
package/dist/flow.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- import { g as createManager, n as api, t as endpoints } from "./endpoints-BSTFaHYo.esm.js";
2
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-B_rda9yU.esm.js";
1
+ import { b as createManager, n as api, t as endpoints } from "./endpoints-B0ltwtb5.esm.js";
2
+ import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-2T5fOCTq.esm.js";
3
3
 
4
4
  //#region src/modules/flow/flowAnalyzer.ts
5
5
  const WASM_MODULE_PIPELINES = {
@@ -0,0 +1,8 @@
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
+ export { getUserAgent as t };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as warmupWasm, t as WasmPipeline } from "./warmup-CEJTfxQr.js";
2
- import { n as PermissionStatus, t as PermissionResult } from "./types-iZi2rawo.js";
1
+ import { n as warmupWasm, t as WasmPipeline } from "./warmup-Cijuyvoc.js";
2
+ import { n as PermissionStatus, t as PermissionResult } from "./types-Dif6MQmX.js";
3
3
 
4
4
  //#region ../infra/src/http/types.d.ts
5
5
  type CreateApiConfig = {
package/dist/index.esm.js CHANGED
@@ -1,5 +1,6 @@
1
- import { i as getBrowser, n as requestPermission, r as getDeviceClass, t as checkPermission } from "./permissionServices-I6vX6DBy.esm.js";
2
- import { _ as createApi_default, a as setClient, i as resetApi, l as warmupWasm, n as api, o as setToken, r as getApi, s as WasmUtilProvider, t as endpoints } from "./endpoints-BSTFaHYo.esm.js";
1
+ import { a as resetApi, c as WasmUtilProvider, n as api, o as setClient, r as getApi, s as setToken, t as endpoints, u as warmupWasm, x as createApi_default } from "./endpoints-B0ltwtb5.esm.js";
2
+ import "./getBrowser-CLEzz0Hi.esm.js";
3
+ import { i as getBrowser, n as requestPermission, r as getDeviceClass, t as checkPermission } from "./permissionServices-BhD0KxsO.esm.js";
3
4
 
4
5
  //#region src/internal/session/sessionService.ts
5
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { i as __toCommonJS, n as __esm, r as __export, t as __commonJS } from "./chunk-C_Yo44FK.esm.js";
2
- import { n as require_jsnlog, t as require_OpenViduLogger } from "./OpenViduLogger-CQyDxBvM.esm.js";
2
+ import { n as require_jsnlog, t as require_OpenViduLogger } from "./OpenViduLogger-5b7KqNTo.esm.js";
3
3
 
4
4
  //#region ../../node_modules/.pnpm/openvidu-browser@2.32.1/node_modules/openvidu-browser/lib/OpenViduInternal/Enums/LocalRecorderState.js
5
5
  var require_LocalRecorderState = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/openvidu-browser@2.32.1/node_modules/openvidu-browser/lib/OpenViduInternal/Enums/LocalRecorderState.js": ((exports) => {
@@ -1,12 +1,6 @@
1
- import { h as stopCameraStream, m as requestCameraAccess, p as queryCameraPermission } from "./endpoints-BSTFaHYo.esm.js";
1
+ import { _ as queryCameraPermission, v as requestCameraAccess, y as stopCameraStream } from "./endpoints-B0ltwtb5.esm.js";
2
+ import { t as getUserAgent } from "./getBrowser-CLEzz0Hi.esm.js";
2
3
 
3
- //#region ../infra/src/device/getBrowser.ts
4
- function getUserAgent() {
5
- if (typeof navigator === "undefined") return "";
6
- return navigator.userAgent;
7
- }
8
-
9
- //#endregion
10
4
  //#region ../infra/src/device/getDeviceClass.ts
11
5
  function getDeviceInfo() {
12
6
  if (typeof navigator === "undefined") return {
package/dist/phone.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Manager } from "./Manager-BGfxEmyv.js";
1
+ import { t as Manager } from "./Manager-Cy9-TMC9.js";
2
2
 
3
3
  //#region src/modules/phone/types.d.ts
4
4
 
package/dist/phone.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { g as createManager, n as api, t as endpoints } from "./endpoints-BSTFaHYo.esm.js";
2
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-B_rda9yU.esm.js";
3
- import { t as addEvent } from "./addEvent-W0ORK0jT.esm.js";
1
+ import { b as createManager, n as api, t as endpoints } from "./endpoints-B0ltwtb5.esm.js";
2
+ import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-2T5fOCTq.esm.js";
3
+ import { t as addEvent } from "./addEvent-s2Za-pK3.esm.js";
4
4
 
5
5
  //#region src/modules/phone/phoneServices.ts
6
6
  async function fetchPhone(signal) {
@@ -0,0 +1,256 @@
1
+ import { n as api, t as endpoints } from "./endpoints-B0ltwtb5.esm.js";
2
+ import { t as getUserAgent } from "./getBrowser-CLEzz0Hi.esm.js";
3
+
4
+ //#region src/internal/deepsight/metadataService.ts
5
+ function getWebGLFingerprint() {
6
+ try {
7
+ const canvas = document.createElement("canvas");
8
+ const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
9
+ if (!gl) return "";
10
+ const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
11
+ if (!debugInfo) return "";
12
+ return gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) || "";
13
+ } catch {
14
+ return "";
15
+ }
16
+ }
17
+ function isBrowserSimulation() {
18
+ const win = window;
19
+ const nav = navigator;
20
+ return !!(win.callPhantom || win._phantom || win.phantom || win.__nightmare || nav.webdriver || win.domAutomation || win.domAutomationController);
21
+ }
22
+ async function getFingerPrint(disableIpify = false) {
23
+ let visitorId = "";
24
+ let ip = "";
25
+ try {
26
+ const canvas = document.createElement("canvas");
27
+ const ctx = canvas.getContext("2d");
28
+ if (ctx) {
29
+ ctx.textBaseline = "top";
30
+ ctx.font = "14px Arial";
31
+ ctx.fillText("fingerprint", 2, 2);
32
+ visitorId = canvas.toDataURL().slice(-50);
33
+ }
34
+ } catch {}
35
+ if (!disableIpify) try {
36
+ const controller = new AbortController();
37
+ const timeoutId = setTimeout(() => controller.abort(), 3e3);
38
+ const response = await fetch("https://api.ipify.org?format=json", { signal: controller.signal });
39
+ clearTimeout(timeoutId);
40
+ ip = (await response.json()).ip || "";
41
+ } catch {}
42
+ return {
43
+ visitorId,
44
+ ip
45
+ };
46
+ }
47
+ function createMetadataService(wasmUtil, visibility) {
48
+ return {
49
+ async initialize(sdkVersion, disableIpify = false) {
50
+ wasmUtil.setSdkPlatform("WEBAPP");
51
+ wasmUtil.setSdkVersion(sdkVersion);
52
+ const ua = getUserAgent();
53
+ const isMobile = /Android|iPhone|iPad|iPod/i.test(ua);
54
+ const fingerPrint = await getFingerPrint(disableIpify).catch(() => ({
55
+ visitorId: "",
56
+ ip: ""
57
+ }));
58
+ const deviceMetadata = {
59
+ kind: isMobile ? "mobile" : "desktop",
60
+ model: "",
61
+ os: void 0,
62
+ osVersion: void 0,
63
+ screenDimensions: {
64
+ width: screen.width,
65
+ height: screen.height
66
+ },
67
+ numTouchPoints: navigator.maxTouchPoints,
68
+ fingerprintHash: fingerPrint.visitorId || "",
69
+ ip: fingerPrint.ip || "",
70
+ backgroundMode: false
71
+ };
72
+ wasmUtil.setDeviceInfo(deviceMetadata);
73
+ const nav = navigator;
74
+ const browserInfo = {
75
+ userAgent: ua,
76
+ getUserMediaAvailability: {
77
+ webkit: nav.webkitGetUserMedia !== void 0,
78
+ moz: nav.mozGetUserMedia !== void 0,
79
+ o: nav.oGetUserMedia !== void 0,
80
+ ms: nav.msGetUserMedia !== void 0
81
+ },
82
+ webglFingerprint: getWebGLFingerprint(),
83
+ inspectorOpened: false,
84
+ isMockedBrowser: isBrowserSimulation()
85
+ };
86
+ wasmUtil.setBrowserInfo(browserInfo, false);
87
+ },
88
+ updateCameraInfo(videoTrack) {
89
+ const settings = videoTrack.getSettings();
90
+ const capabilities = videoTrack.getCapabilities?.() ?? {};
91
+ const labels = videoTrack.label ? [videoTrack.label] : [];
92
+ const cameraInfo = {
93
+ facingMode: settings.facingMode === "user" ? "frontal" : settings.facingMode === "environment" ? "back" : settings.facingMode || "unknown",
94
+ settings,
95
+ capabilities,
96
+ labels
97
+ };
98
+ wasmUtil.setCameraInfo(cameraInfo);
99
+ },
100
+ async checkForVirtualCameraByLabel(videoTrack = null) {
101
+ try {
102
+ if (!videoTrack) {
103
+ const devices = await navigator.mediaDevices.enumerateDevices();
104
+ for (const device of devices) if (device.kind === "videoinput" && wasmUtil.isVirtualCamera(device.label)) return true;
105
+ }
106
+ if (videoTrack && wasmUtil.isVirtualCamera(videoTrack.label)) return true;
107
+ return false;
108
+ } catch {
109
+ return false;
110
+ }
111
+ },
112
+ async analyzeFrame(imageData) {
113
+ await wasmUtil.analyzeFrame(imageData);
114
+ },
115
+ setMotionStatus(status) {
116
+ wasmUtil.setMotionStatus(status);
117
+ },
118
+ setBackgroundMode(backgroundMode) {
119
+ wasmUtil.setBackgroundMode(backgroundMode || visibility.wasBackgrounded);
120
+ visibility.reset();
121
+ },
122
+ estimatePerformance() {
123
+ return wasmUtil.estimatePerformance();
124
+ },
125
+ getMetadata() {
126
+ return wasmUtil.getMetadata();
127
+ },
128
+ getCheck() {
129
+ return wasmUtil.getCheck();
130
+ }
131
+ };
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/internal/deepsight/motionStatusService.ts
136
+ function createMotionStatusService(motionSensor) {
137
+ return {
138
+ async requestPermission() {
139
+ return motionSensor.requestPermission();
140
+ },
141
+ async start() {
142
+ await motionSensor.start();
143
+ },
144
+ stop() {
145
+ motionSensor.stop();
146
+ },
147
+ check() {
148
+ return motionSensor.check();
149
+ },
150
+ get isRunning() {
151
+ return motionSensor.isRunning;
152
+ },
153
+ get hasPermission() {
154
+ return motionSensor.hasPermission;
155
+ }
156
+ };
157
+ }
158
+
159
+ //#endregion
160
+ //#region src/internal/deepsight/deepsightService.ts
161
+ function createDeepsightService(config) {
162
+ const metadata = createMetadataService(config.wasmUtil, config.visibility);
163
+ const motion = createMotionStatusService(config.motionSensor);
164
+ return {
165
+ metadata,
166
+ motion,
167
+ recorder: config.recorder,
168
+ async initialize(disableIpify = false) {
169
+ await metadata.initialize(config.sdkVersion, disableIpify);
170
+ metadata.estimatePerformance();
171
+ },
172
+ async requestMotionPermission() {
173
+ return motion.requestPermission();
174
+ },
175
+ async startMotionSensors() {
176
+ await motion.start();
177
+ },
178
+ stopMotionSensors() {
179
+ motion.stop();
180
+ },
181
+ startRecording(stream) {
182
+ config.recorder.startRecording(stream);
183
+ },
184
+ async checkVirtualCamera(videoTrack) {
185
+ metadata.updateCameraInfo(videoTrack);
186
+ return metadata.checkForVirtualCameraByLabel(videoTrack);
187
+ },
188
+ async performVirtualCameraCheck() {
189
+ const output = {
190
+ canvas: null,
191
+ itr: null,
192
+ skipped: null
193
+ };
194
+ await config.wasmUtil.poc(output);
195
+ if (output?.skipped === false) config.wasmUtil.setZc(output?.itr === true ? "FAIL" : "PASS");
196
+ },
197
+ async performCapture(sessionToken, imageData) {
198
+ let recordingId = null;
199
+ if (config.recorder.isRecording) {
200
+ const result = await config.recorder.stopRecording(10, (base64) => config.wasmUtil.encryptImage(base64), (buffer) => config.wasmUtil.ckvcks(buffer));
201
+ try {
202
+ recordingId = await config.uploadVideo(result.encryptedVideo, sessionToken);
203
+ } catch (error) {
204
+ console.error("[DeepsightService] Failed to upload video:", error);
205
+ }
206
+ }
207
+ await this.performVirtualCameraCheck();
208
+ await metadata.analyzeFrame(imageData);
209
+ const motionStatus = motion.check();
210
+ metadata.setMotionStatus(motionStatus);
211
+ metadata.getCheck();
212
+ metadata.setBackgroundMode(false);
213
+ return {
214
+ metadata: metadata.getMetadata(),
215
+ recordingId
216
+ };
217
+ },
218
+ cleanup() {
219
+ motion.stop();
220
+ config.recorder.reset();
221
+ }
222
+ };
223
+ }
224
+
225
+ //#endregion
226
+ //#region src/internal/recordings/recordingsRepository.ts
227
+ async function createRecordingSession(type) {
228
+ return (await api.post(endpoints.recordingCreateSessionV2, { type })).data;
229
+ }
230
+ async function startRecording(params) {
231
+ return (await api.post(endpoints.recordingStartV2, {
232
+ videoRecordingId: params.videoRecordingId,
233
+ frameRate: 30,
234
+ outputMode: "COMPOSED",
235
+ resolution: params.resolution,
236
+ type: params.type,
237
+ hasAudio: params.hasAudio ?? false
238
+ })).data;
239
+ }
240
+ async function stopRecording(videoRecordingId) {
241
+ return (await api.post(endpoints.recordingStopV2, { videoRecordingId })).data;
242
+ }
243
+ async function uploadDeepsightVideo(encryptedVideo, token) {
244
+ try {
245
+ return (await api.post(endpoints.deepsightVideoImport, {
246
+ video: encryptedVideo,
247
+ type: "selfie"
248
+ }, { headers: { "X-Incode-Hardware-Id": token } })).data.recordingId ?? "";
249
+ } catch (error) {
250
+ console.error("Error uploading deepsight video:", error);
251
+ return "";
252
+ }
253
+ }
254
+
255
+ //#endregion
256
+ export { createDeepsightService as a, uploadDeepsightVideo as i, startRecording as n, stopRecording as r, createRecordingSession as t };
package/dist/selfie.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { t as WasmPipeline } from "./warmup-CEJTfxQr.js";
2
- import { t as Manager } from "./Manager-BGfxEmyv.js";
3
- import { n as StateMachine, t as AnyStateMachine } from "./StateMachine-DRE1oH2B.js";
4
- import { n as PermissionStatus, t as PermissionResult } from "./types-iZi2rawo.js";
1
+ import { t as WasmPipeline } from "./warmup-Cijuyvoc.js";
2
+ import { t as Manager } from "./Manager-Cy9-TMC9.js";
3
+ import { n as StateMachine, t as AnyStateMachine } from "./StateMachine-BqPpBhOz.js";
4
+ import { n as PermissionStatus, t as PermissionResult } from "./types-Dif6MQmX.js";
5
5
 
6
6
  //#region ../infra/src/media/canvas.d.ts
7
7
  /**
@@ -299,6 +299,24 @@ interface IFaceDetectionCapability extends IMLProviderCapability<FaceDetectionCo
299
299
  setVideoSelfieMode(enabled: boolean): void;
300
300
  }
301
301
  //#endregion
302
+ //#region ../infra/src/capabilities/IDeepsightRecordingCapability.d.ts
303
+ type DeepsightRecordingResult = {
304
+ trimmedBlob: Blob;
305
+ encryptedVideo: string;
306
+ };
307
+ type IDeepsightRecordingCapability = {
308
+ readonly isRecording: boolean;
309
+ readonly hasError: boolean;
310
+ readonly error: string | null;
311
+ startRecording(stream: MediaStream): void;
312
+ stopRecording(trimSeconds: number, encrypt: (base64: string) => string, generateChecksum: (buffer: ArrayBuffer) => void): Promise<DeepsightRecordingResult>;
313
+ reset(): void;
314
+ };
315
+ //#endregion
316
+ //#region ../infra/src/capabilities/IMotionSensorCapability.d.ts
317
+ type MotionStatus = 'PASS' | 'FAIL' | 'UNCLEAR';
318
+ type MotionPermissionState = 'granted' | 'denied' | 'not-required';
319
+ //#endregion
302
320
  //#region ../infra/src/capabilities/IRecordingCapability.d.ts
303
321
  type RecordingPublisher = {
304
322
  getStreamId: () => string | undefined;
@@ -480,6 +498,49 @@ declare class FaceDetectionProvider extends BaseWasmProvider implements IFaceDet
480
498
  private formatFaceCoordinates;
481
499
  }
482
500
  //#endregion
501
+ //#region src/internal/deepsight/metadataService.d.ts
502
+ type MetadataService = {
503
+ initialize(sdkVersion: string, disableIpify?: boolean): Promise<void>;
504
+ updateCameraInfo(videoTrack: MediaStreamTrack): void;
505
+ checkForVirtualCameraByLabel(videoTrack: MediaStreamTrack | null): Promise<boolean>;
506
+ analyzeFrame(imageData: ImageData): Promise<void>;
507
+ setMotionStatus(status: string): void;
508
+ setBackgroundMode(backgroundMode: boolean): void;
509
+ estimatePerformance(): string;
510
+ getMetadata(): string;
511
+ getCheck(): string;
512
+ };
513
+ //#endregion
514
+ //#region src/internal/deepsight/motionStatusService.d.ts
515
+ type MotionStatusService = {
516
+ requestPermission(): Promise<MotionPermissionState>;
517
+ start(): Promise<void>;
518
+ stop(): void;
519
+ check(): MotionStatus;
520
+ readonly isRunning: boolean;
521
+ readonly hasPermission: boolean;
522
+ };
523
+ //#endregion
524
+ //#region src/internal/deepsight/deepsightService.d.ts
525
+ type DeepsightCaptureResult = {
526
+ metadata: string;
527
+ recordingId: string | null;
528
+ };
529
+ type DeepsightService = {
530
+ readonly metadata: MetadataService;
531
+ readonly motion: MotionStatusService;
532
+ readonly recorder: IDeepsightRecordingCapability;
533
+ initialize(disableIpify?: boolean): Promise<void>;
534
+ requestMotionPermission(): Promise<'granted' | 'denied' | 'not-required'>;
535
+ startMotionSensors(): Promise<void>;
536
+ stopMotionSensors(): void;
537
+ startRecording(stream: MediaStream): void;
538
+ checkVirtualCamera(videoTrack: MediaStreamTrack): Promise<boolean>;
539
+ performVirtualCameraCheck(): Promise<void>;
540
+ performCapture(sessionToken: string, imageData: ImageData): Promise<DeepsightCaptureResult>;
541
+ cleanup(): void;
542
+ };
543
+ //#endregion
483
544
  //#region src/modules/selfie/types.d.ts
484
545
  type SelfieConfig = {
485
546
  showTutorial: boolean;
@@ -569,6 +630,7 @@ type SelfieContext = {
569
630
  uploadError: FaceErrorCode | undefined;
570
631
  permissionResult: PermissionResult | 'refresh' | undefined;
571
632
  resetDetection: (() => void) | undefined;
633
+ deepsightService: DeepsightService | undefined;
572
634
  };
573
635
  type SelfieEvent = {
574
636
  type: 'LOAD';
@@ -756,4 +818,4 @@ declare function createSelfieManager(options: CreateSelfieActorOptions): Manager
756
818
  };
757
819
  type SelfieManager = ReturnType<typeof createSelfieManager>;
758
820
  //#endregion
759
- export { type CameraStream, type DetectionStatus, type FaceErrorCode, type PermissionResult, type PermissionStatus, type SelfieConfig, type SelfieMachine, type SelfieManager, type SelfieState, createSelfieManager, selfieMachine };
821
+ export { type CameraStream, type DeepsightService, type DetectionStatus, type FaceErrorCode, type PermissionResult, type PermissionStatus, type SelfieConfig, type SelfieMachine, type SelfieManager, type SelfieState, createSelfieManager, selfieMachine };