@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/OpenViduLogger-20ZYS-mT.esm.js +3 -0
- package/dist/{addEvent-W0ORK0jT.esm.js → addEvent-s2Za-pK3.esm.js} +1 -1
- package/dist/deepsightLoader-Bn2D0REl.esm.js +25 -0
- package/dist/email.d.ts +1 -1
- package/dist/email.esm.js +3 -3
- package/dist/{endpoints-BSTFaHYo.esm.js → endpoints-B0ltwtb5.esm.js} +633 -4
- package/dist/flow.d.ts +3 -3
- package/dist/flow.esm.js +2 -2
- package/dist/getBrowser-CLEzz0Hi.esm.js +8 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +3 -2
- package/dist/{lib-Bu9XGMBW.esm.js → lib-CykGFCEr.esm.js} +1 -1
- package/dist/{permissionServices-I6vX6DBy.esm.js → permissionServices-BhD0KxsO.esm.js} +2 -8
- package/dist/phone.d.ts +1 -1
- package/dist/phone.esm.js +3 -3
- package/dist/recordingsRepository-CTjaf-ER.esm.js +256 -0
- package/dist/selfie.d.ts +67 -5
- package/dist/selfie.esm.js +138 -46
- package/package.json +2 -2
- package/dist/OpenViduLogger-BdPfiZO6.esm.js +0 -3
- /package/dist/{Manager-BGfxEmyv.d.ts → Manager-Cy9-TMC9.d.ts} +0 -0
- /package/dist/{OpenViduLogger-CQyDxBvM.esm.js → OpenViduLogger-5b7KqNTo.esm.js} +0 -0
- /package/dist/{StateMachine-DRE1oH2B.d.ts → StateMachine-BqPpBhOz.d.ts} +0 -0
- /package/dist/{types-iZi2rawo.d.ts → types-Dif6MQmX.d.ts} +0 -0
- /package/dist/{warmup-CEJTfxQr.d.ts → warmup-Cijuyvoc.d.ts} +0 -0
- /package/dist/{xstate.esm-B_rda9yU.esm.js → xstate.esm-2T5fOCTq.esm.js} +0 -0
package/dist/selfie.esm.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
1
|
+
import { b as createManager, c as WasmUtilProvider, f as OpenViduRecordingProvider, g as StreamCanvasCapture, h as StreamCanvasProcessingSession, i as getToken, l as FaceDetectionProvider, n as api, t as endpoints, v as requestCameraAccess, y as stopCameraStream } from "./endpoints-B0ltwtb5.esm.js";
|
|
2
|
+
import "./getBrowser-CLEzz0Hi.esm.js";
|
|
3
|
+
import { n as requestPermission, r as getDeviceClass, t as checkPermission } from "./permissionServices-BhD0KxsO.esm.js";
|
|
4
|
+
import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-2T5fOCTq.esm.js";
|
|
5
|
+
import { t as addEvent } from "./addEvent-s2Za-pK3.esm.js";
|
|
6
|
+
import { n as startRecording, r as stopRecording$1, t as createRecordingSession } from "./recordingsRepository-CTjaf-ER.esm.js";
|
|
5
7
|
|
|
6
8
|
//#region src/modules/selfie/types.ts
|
|
7
9
|
const FACE_ERROR_CODES = {
|
|
@@ -55,25 +57,6 @@ const validateUploadResponse = ({ config, response }) => {
|
|
|
55
57
|
if (config.validateHeadCover && response.hasHeadCover) return FACE_ERROR_CODES.HEAD_COVER;
|
|
56
58
|
};
|
|
57
59
|
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/internal/recordings/recordingsRepository.ts
|
|
60
|
-
async function createRecordingSession(type) {
|
|
61
|
-
return (await api.post(endpoints.recordingCreateSessionV2, { type })).data;
|
|
62
|
-
}
|
|
63
|
-
async function startRecording(params) {
|
|
64
|
-
return (await api.post(endpoints.recordingStartV2, {
|
|
65
|
-
videoRecordingId: params.videoRecordingId,
|
|
66
|
-
frameRate: 30,
|
|
67
|
-
outputMode: "COMPOSED",
|
|
68
|
-
resolution: params.resolution,
|
|
69
|
-
type: params.type,
|
|
70
|
-
hasAudio: params.hasAudio ?? false
|
|
71
|
-
})).data;
|
|
72
|
-
}
|
|
73
|
-
async function stopRecording$1(videoRecordingId) {
|
|
74
|
-
return (await api.post(endpoints.recordingStopV2, { videoRecordingId })).data;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
60
|
//#endregion
|
|
78
61
|
//#region src/internal/recordings/streamingEvents.ts
|
|
79
62
|
const streamingEvents = {
|
|
@@ -92,16 +75,20 @@ const streamingEvents = {
|
|
|
92
75
|
/**
|
|
93
76
|
* Uploads a selfie image to the backend.
|
|
94
77
|
*/
|
|
95
|
-
async function uploadSelfie({ encryptedBase64Image, faceCoordinates, signal }) {
|
|
78
|
+
async function uploadSelfie({ encryptedBase64Image, faceCoordinates, signal, metadata, recordingId }) {
|
|
96
79
|
try {
|
|
97
|
-
const
|
|
80
|
+
const payload = {
|
|
98
81
|
base64Image: encryptedBase64Image,
|
|
99
82
|
faceCoordinates: faceCoordinates ?? void 0,
|
|
100
83
|
encrypted: true,
|
|
101
|
-
clientInfo: { deviceClass: getDeviceClass() }
|
|
102
|
-
|
|
84
|
+
clientInfo: { deviceClass: getDeviceClass() },
|
|
85
|
+
metadata: metadata ?? void 0
|
|
86
|
+
};
|
|
87
|
+
const query = { imageType: "selfie" };
|
|
88
|
+
if (recordingId) query.recordingId = recordingId;
|
|
89
|
+
const res = await api.post(endpoints.selfie, payload, {
|
|
103
90
|
signal,
|
|
104
|
-
query
|
|
91
|
+
query
|
|
105
92
|
});
|
|
106
93
|
if (!res.ok) throw new Error(`POST ${endpoints.selfie} failed: ${res.status} ${res.statusText}`);
|
|
107
94
|
return res.data;
|
|
@@ -249,6 +236,7 @@ function buildResolutionFromStream(stream) {
|
|
|
249
236
|
if (typeof width === "number" && typeof height === "number") return `${width}x${height}`;
|
|
250
237
|
}
|
|
251
238
|
async function startRecordingSession(params) {
|
|
239
|
+
if (params.config.deepsightLiveness === "VIDEOLIVENESS") return;
|
|
252
240
|
if (params.config.enableFaceRecording !== true) return;
|
|
253
241
|
if (params.existing) return params.existing;
|
|
254
242
|
const provider = params.config.recording?.capability ?? new OpenViduRecordingProvider();
|
|
@@ -371,6 +359,11 @@ function stopRecording(session) {
|
|
|
371
359
|
}
|
|
372
360
|
})();
|
|
373
361
|
}
|
|
362
|
+
async function initializeDeepsightSession(config) {
|
|
363
|
+
if (config.deepsightLiveness !== "VIDEOLIVENESS") return;
|
|
364
|
+
const { loadDeepsightSession } = await import("./deepsightLoader-Bn2D0REl.esm.js");
|
|
365
|
+
return loadDeepsightSession();
|
|
366
|
+
}
|
|
374
367
|
|
|
375
368
|
//#endregion
|
|
376
369
|
//#region src/modules/selfie/selfieStateMachine.ts
|
|
@@ -422,10 +415,26 @@ const _selfieMachine = setup({
|
|
|
422
415
|
});
|
|
423
416
|
return cleanup;
|
|
424
417
|
}),
|
|
418
|
+
initializeDeepsightSession: fromPromise(async ({ input }) => {
|
|
419
|
+
return await initializeDeepsightSession(input.config);
|
|
420
|
+
}),
|
|
425
421
|
uploadSelfie: fromPromise(async ({ input, signal }) => {
|
|
422
|
+
let metadata;
|
|
423
|
+
let recordingId = null;
|
|
424
|
+
if (input.deepsightService) {
|
|
425
|
+
const imageData = input.canvas.getImageData();
|
|
426
|
+
const sessionToken = getToken();
|
|
427
|
+
if (imageData && sessionToken) {
|
|
428
|
+
const result = await input.deepsightService.performCapture(sessionToken, imageData);
|
|
429
|
+
metadata = result.metadata;
|
|
430
|
+
recordingId = result.recordingId;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
426
433
|
return uploadSelfie({
|
|
427
434
|
encryptedBase64Image: await encryptSelfieImage({ canvas: input.canvas }),
|
|
428
435
|
faceCoordinates: input.faceCoordinates,
|
|
436
|
+
metadata,
|
|
437
|
+
recordingId,
|
|
429
438
|
signal
|
|
430
439
|
});
|
|
431
440
|
}),
|
|
@@ -484,7 +493,8 @@ const _selfieMachine = setup({
|
|
|
484
493
|
attemptsRemaining: context.config.captureAttempts,
|
|
485
494
|
uploadError: void 0,
|
|
486
495
|
permissionResult: void 0,
|
|
487
|
-
resetDetection: void 0
|
|
496
|
+
resetDetection: void 0,
|
|
497
|
+
deepsightService: void 0
|
|
488
498
|
})),
|
|
489
499
|
resetDetection: ({ context }) => {
|
|
490
500
|
context.resetDetection?.();
|
|
@@ -520,6 +530,20 @@ const _selfieMachine = setup({
|
|
|
520
530
|
} }),
|
|
521
531
|
stopRecordingStream: ({ context }) => {
|
|
522
532
|
if (context.recordingStream) stopStream(context.recordingStream);
|
|
533
|
+
},
|
|
534
|
+
startDeepsightRecording: ({ context }) => {
|
|
535
|
+
if (context.deepsightService && context.stream) context.deepsightService.startRecording(context.stream);
|
|
536
|
+
},
|
|
537
|
+
checkVirtualCamera: ({ context }) => {
|
|
538
|
+
(async () => {
|
|
539
|
+
if (context.deepsightService && context.stream) {
|
|
540
|
+
const videoTrack = context.stream.getVideoTracks()[0];
|
|
541
|
+
if (videoTrack) await context.deepsightService.checkVirtualCamera(videoTrack);
|
|
542
|
+
}
|
|
543
|
+
})();
|
|
544
|
+
},
|
|
545
|
+
cleanupDeepsight: ({ context }) => {
|
|
546
|
+
context.deepsightService?.cleanup();
|
|
523
547
|
}
|
|
524
548
|
},
|
|
525
549
|
guards: {
|
|
@@ -536,6 +560,7 @@ const _selfieMachine = setup({
|
|
|
536
560
|
return false;
|
|
537
561
|
},
|
|
538
562
|
hasStream: ({ context }) => context.stream !== void 0,
|
|
563
|
+
isCameraAndDeepsightReady: ({ context }) => context.stream !== void 0 && (context.config.deepsightLiveness !== "VIDEOLIVENESS" || context.deepsightService !== void 0),
|
|
539
564
|
hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
|
|
540
565
|
hasCapturedImage: ({ context }) => context.capturedImage !== void 0,
|
|
541
566
|
hasUploadValidationError: ({ context }) => validateUploadResponse({
|
|
@@ -562,7 +587,8 @@ const _selfieMachine = setup({
|
|
|
562
587
|
attemptsRemaining: input.config.captureAttempts,
|
|
563
588
|
uploadError: void 0,
|
|
564
589
|
permissionResult: void 0,
|
|
565
|
-
resetDetection: void 0
|
|
590
|
+
resetDetection: void 0,
|
|
591
|
+
deepsightService: void 0
|
|
566
592
|
}),
|
|
567
593
|
on: { QUIT: { target: "#selfie.closed" } },
|
|
568
594
|
states: {
|
|
@@ -570,7 +596,7 @@ const _selfieMachine = setup({
|
|
|
570
596
|
target: "tutorial",
|
|
571
597
|
guard: "hasShowTutorial"
|
|
572
598
|
}, { target: "loading" }] } },
|
|
573
|
-
loading: { invoke: {
|
|
599
|
+
loading: { invoke: [{
|
|
574
600
|
id: "checkPermissionLoading",
|
|
575
601
|
src: "checkPermission",
|
|
576
602
|
onDone: [{
|
|
@@ -581,7 +607,13 @@ const _selfieMachine = setup({
|
|
|
581
607
|
target: "permissions",
|
|
582
608
|
actions: assign({ permissionResult: ({ event }) => event.output })
|
|
583
609
|
}]
|
|
584
|
-
}
|
|
610
|
+
}, {
|
|
611
|
+
id: "loadingInitDeepsight",
|
|
612
|
+
src: "initializeDeepsightSession",
|
|
613
|
+
input: ({ context }) => ({ config: context.config }),
|
|
614
|
+
onDone: { actions: assign({ deepsightService: ({ event }) => event.output }) },
|
|
615
|
+
onError: { actions: () => void 0 }
|
|
616
|
+
}] },
|
|
585
617
|
tutorial: {
|
|
586
618
|
initial: "checkingPermission",
|
|
587
619
|
entry: "trackTutorialSelfie",
|
|
@@ -600,7 +632,7 @@ const _selfieMachine = setup({
|
|
|
600
632
|
} },
|
|
601
633
|
initializingCamera: {
|
|
602
634
|
initial: "booting",
|
|
603
|
-
invoke: {
|
|
635
|
+
invoke: [{
|
|
604
636
|
id: "tutorialInitCamera",
|
|
605
637
|
src: "initializeCamera",
|
|
606
638
|
input: ({ context }) => context.config,
|
|
@@ -613,12 +645,18 @@ const _selfieMachine = setup({
|
|
|
613
645
|
target: "ready",
|
|
614
646
|
actions: assign({ error: ({ event }) => String(event.error) })
|
|
615
647
|
}]
|
|
616
|
-
},
|
|
648
|
+
}, {
|
|
649
|
+
id: "tutorialInitDeepsight",
|
|
650
|
+
src: "initializeDeepsightSession",
|
|
651
|
+
input: ({ context }) => ({ config: context.config }),
|
|
652
|
+
onDone: { actions: assign({ deepsightService: ({ event }) => event.output }) },
|
|
653
|
+
onError: { actions: () => void 0 }
|
|
654
|
+
}],
|
|
617
655
|
states: {
|
|
618
656
|
booting: {
|
|
619
657
|
always: [{
|
|
620
658
|
target: "#tutorialCameraReady",
|
|
621
|
-
guard: "
|
|
659
|
+
guard: "isCameraAndDeepsightReady"
|
|
622
660
|
}],
|
|
623
661
|
on: { NEXT_STEP: {
|
|
624
662
|
target: "waitingForStream",
|
|
@@ -627,7 +665,7 @@ const _selfieMachine = setup({
|
|
|
627
665
|
},
|
|
628
666
|
waitingForStream: { always: [{
|
|
629
667
|
target: "#selfie.capture",
|
|
630
|
-
guard: "
|
|
668
|
+
guard: "isCameraAndDeepsightReady"
|
|
631
669
|
}] }
|
|
632
670
|
}
|
|
633
671
|
},
|
|
@@ -638,10 +676,29 @@ const _selfieMachine = setup({
|
|
|
638
676
|
actions: "trackContinue"
|
|
639
677
|
} }
|
|
640
678
|
},
|
|
641
|
-
ready: {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
679
|
+
ready: {
|
|
680
|
+
initial: "idle",
|
|
681
|
+
states: {
|
|
682
|
+
idle: { always: [{
|
|
683
|
+
target: "initializingDeepsight",
|
|
684
|
+
guard: ({ context }) => context.config.deepsightLiveness === "VIDEOLIVENESS"
|
|
685
|
+
}, { target: "readyForNext" }] },
|
|
686
|
+
initializingDeepsight: { invoke: {
|
|
687
|
+
id: "initializeDeepsightTutorial",
|
|
688
|
+
src: "initializeDeepsightSession",
|
|
689
|
+
input: ({ context }) => ({ config: context.config }),
|
|
690
|
+
onDone: {
|
|
691
|
+
target: "readyForNext",
|
|
692
|
+
actions: assign({ deepsightService: ({ event }) => event.output })
|
|
693
|
+
},
|
|
694
|
+
onError: { target: "readyForNext" }
|
|
695
|
+
} },
|
|
696
|
+
readyForNext: { on: { NEXT_STEP: {
|
|
697
|
+
target: "#selfie.tutorial.waitingForPermission",
|
|
698
|
+
actions: "trackContinue"
|
|
699
|
+
} } }
|
|
700
|
+
}
|
|
701
|
+
},
|
|
645
702
|
waitingForPermission: { invoke: {
|
|
646
703
|
id: "checkPermissionWaiting",
|
|
647
704
|
src: "checkPermission",
|
|
@@ -657,8 +714,22 @@ const _selfieMachine = setup({
|
|
|
657
714
|
}
|
|
658
715
|
},
|
|
659
716
|
permissions: {
|
|
660
|
-
initial: "
|
|
717
|
+
initial: "checkingDeepsight",
|
|
661
718
|
states: {
|
|
719
|
+
checkingDeepsight: { always: [{
|
|
720
|
+
target: "initializingDeepsight",
|
|
721
|
+
guard: ({ context }) => context.config.deepsightLiveness === "VIDEOLIVENESS" && context.deepsightService === void 0
|
|
722
|
+
}, { target: "idle" }] },
|
|
723
|
+
initializingDeepsight: { invoke: {
|
|
724
|
+
id: "initializeDeepsightPerms",
|
|
725
|
+
src: "initializeDeepsightSession",
|
|
726
|
+
input: ({ context }) => ({ config: context.config }),
|
|
727
|
+
onDone: {
|
|
728
|
+
target: "idle",
|
|
729
|
+
actions: assign({ deepsightService: ({ event }) => event.output })
|
|
730
|
+
},
|
|
731
|
+
onError: { target: "idle" }
|
|
732
|
+
} },
|
|
662
733
|
idle: {
|
|
663
734
|
invoke: {
|
|
664
735
|
id: "checkPermissionIdle",
|
|
@@ -707,14 +778,29 @@ const _selfieMachine = setup({
|
|
|
707
778
|
}
|
|
708
779
|
},
|
|
709
780
|
capture: {
|
|
710
|
-
initial: "
|
|
781
|
+
initial: "checkingDeepsight",
|
|
711
782
|
exit: [
|
|
712
783
|
"stopMediaRecording",
|
|
713
784
|
"stopRecordingStream",
|
|
714
785
|
"clearRecordingSession",
|
|
715
|
-
"stopMediaStream"
|
|
786
|
+
"stopMediaStream",
|
|
787
|
+
"cleanupDeepsight"
|
|
716
788
|
],
|
|
717
789
|
states: {
|
|
790
|
+
checkingDeepsight: { always: [{
|
|
791
|
+
target: "initializingDeepsight",
|
|
792
|
+
guard: ({ context }) => context.config.deepsightLiveness === "VIDEOLIVENESS" && context.deepsightService === void 0
|
|
793
|
+
}, { target: "checkingStream" }] },
|
|
794
|
+
initializingDeepsight: { invoke: {
|
|
795
|
+
id: "initializeDeepsightCapture",
|
|
796
|
+
src: "initializeDeepsightSession",
|
|
797
|
+
input: ({ context }) => ({ config: context.config }),
|
|
798
|
+
onDone: {
|
|
799
|
+
target: "checkingStream",
|
|
800
|
+
actions: [assign({ deepsightService: ({ event }) => event.output })]
|
|
801
|
+
},
|
|
802
|
+
onError: { target: "checkingStream" }
|
|
803
|
+
} },
|
|
718
804
|
checkingStream: { always: [{
|
|
719
805
|
target: "detecting",
|
|
720
806
|
guard: "hasStream"
|
|
@@ -725,7 +811,7 @@ const _selfieMachine = setup({
|
|
|
725
811
|
input: ({ context }) => context.config,
|
|
726
812
|
onDone: {
|
|
727
813
|
target: "detecting",
|
|
728
|
-
actions: "setStreamAndCapturer"
|
|
814
|
+
actions: ["setStreamAndCapturer"]
|
|
729
815
|
},
|
|
730
816
|
onError: [{
|
|
731
817
|
target: "#selfie.permissions",
|
|
@@ -737,7 +823,12 @@ const _selfieMachine = setup({
|
|
|
737
823
|
}]
|
|
738
824
|
} },
|
|
739
825
|
detecting: {
|
|
740
|
-
entry: [
|
|
826
|
+
entry: [
|
|
827
|
+
assign({ detectionStatus: () => "detecting" }),
|
|
828
|
+
"createRecordingStream",
|
|
829
|
+
"checkVirtualCamera",
|
|
830
|
+
"startDeepsightRecording"
|
|
831
|
+
],
|
|
741
832
|
invoke: [{
|
|
742
833
|
id: "startRecording",
|
|
743
834
|
src: "startRecording",
|
|
@@ -807,7 +898,8 @@ const _selfieMachine = setup({
|
|
|
807
898
|
if (!canvas) throw new Error(FACE_ERROR_CODES.SERVER);
|
|
808
899
|
return {
|
|
809
900
|
canvas,
|
|
810
|
-
faceCoordinates: context.faceCoordinates
|
|
901
|
+
faceCoordinates: context.faceCoordinates,
|
|
902
|
+
deepsightService: context.deepsightService
|
|
811
903
|
};
|
|
812
904
|
},
|
|
813
905
|
onDone: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incodetech/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.esm.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
41
|
"vitest": "^4.0.13",
|
|
42
42
|
"@incodetech/config": "1.0.0",
|
|
43
|
-
"@incodetech/infra": "1.0.
|
|
43
|
+
"@incodetech/infra": "1.1.0-alpha.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsdown -c tsdown.config.ts",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|