@realeyes/verifeye-sdk 1.0.1
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +44 -0
- package/dist/faceDetectionService-D37MewxK.js +96 -0
- package/dist/index-Bfh2zolf.js +2258 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +6 -0
- package/dist/livenessCheckDialog-D7nIgy_n.js +82 -0
- package/dist/livenessCheckDialog.css +1 -0
- package/dist/videoRecorderService-eqEwhEav.js +165 -0
- package/package.json +48 -0
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.face-icon-container{margin:2rem 0}.face-icon{width:130px;height:auto;padding-top:10px;padding-bottom:10px}.realeyes-btn{background:#263235!important;color:#fff!important;border:none!important;border-radius:50px!important;padding:1rem 3.2rem!important;font-size:1.125rem!important;font-weight:700!important;cursor:pointer!important;display:flex!important;align-items:center!important;gap:.75rem!important;transition:all .3s ease!important}.realeyes-btn:hover{background:#000!important}.realeyes-btn:active{transform:scale(.98)!important}.realeyes-btn:focus{outline:none!important}.realeyes-btn--rounded{border-radius:12px!important}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare interface Config {
|
|
4
|
+
getCurrentEnvironment(): Environment;
|
|
5
|
+
getApiBaseUrl(): string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare const ConsentSkipMode: {
|
|
9
|
+
readonly SkipIfCameraGranted: "1";
|
|
10
|
+
readonly AlwaysSkip: "2";
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare type ConsentSkipMode = (typeof ConsentSkipMode)[keyof typeof ConsentSkipMode];
|
|
14
|
+
|
|
15
|
+
export declare type Environment = "production" | "development" | "local";
|
|
16
|
+
|
|
17
|
+
export declare interface HeadlessCallbacks {
|
|
18
|
+
onVerificationStarting?: () => void;
|
|
19
|
+
onBeforeCameraAccess?: () => void;
|
|
20
|
+
onAfterCameraAccess?: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare type Region = (typeof REGIONS)[number];
|
|
24
|
+
|
|
25
|
+
export declare const REGIONS: readonly ["eu", "us"];
|
|
26
|
+
|
|
27
|
+
export declare type VerifyServiceOperation = "init-session" | "capture-image" | "verify" | "unknown";
|
|
28
|
+
|
|
29
|
+
export declare const VerifyVerifier: default_2.FC<VerifyVerifierProps>;
|
|
30
|
+
|
|
31
|
+
export declare interface VerifyVerifierProps {
|
|
32
|
+
sessionId: string;
|
|
33
|
+
accessToken: string;
|
|
34
|
+
onVerificationCompleted: (sessionId: string) => void;
|
|
35
|
+
onServiceError?: (operation: VerifyServiceOperation) => void;
|
|
36
|
+
consentSkipMode?: ConsentSkipMode;
|
|
37
|
+
headless?: boolean;
|
|
38
|
+
headlessCallbacks?: HeadlessCallbacks;
|
|
39
|
+
showVerificationSessionId?: boolean;
|
|
40
|
+
region: Region;
|
|
41
|
+
createConfig?: (region: Region) => Config;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import m from "@mui/material/DialogContent";
|
|
3
|
+
import a from "@mui/material/IconButton";
|
|
4
|
+
import { R as p, C as f, D as g } from "./index-Bfh2zolf.js";
|
|
5
|
+
import { Box as u, Stack as x } from "@mui/material";
|
|
6
|
+
import { FaceLivenessDetector as d } from "@aws-amplify/ui-react-liveness";
|
|
7
|
+
import "@aws-amplify/ui-react/styles.css";
|
|
8
|
+
import './livenessCheckDialog.css';const v = ({
|
|
9
|
+
isOpen: o,
|
|
10
|
+
uniqueId: e,
|
|
11
|
+
livenessSessionId: n,
|
|
12
|
+
livenessRegion: r,
|
|
13
|
+
onLivenessComplete: i,
|
|
14
|
+
onLivenessError: s,
|
|
15
|
+
onClose: c
|
|
16
|
+
}) => {
|
|
17
|
+
if (o)
|
|
18
|
+
return /* @__PURE__ */ t(p, { open: o, children: /* @__PURE__ */ l(
|
|
19
|
+
m,
|
|
20
|
+
{
|
|
21
|
+
sx: {
|
|
22
|
+
textAlign: "center !important",
|
|
23
|
+
justifyContent: "center !important",
|
|
24
|
+
alignItems: "center !important"
|
|
25
|
+
},
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ t(
|
|
28
|
+
a,
|
|
29
|
+
{
|
|
30
|
+
sx: {
|
|
31
|
+
position: "absolute",
|
|
32
|
+
right: 10,
|
|
33
|
+
top: 10,
|
|
34
|
+
color: "#b0b0b0",
|
|
35
|
+
"&:hover": {
|
|
36
|
+
color: "#263235"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onClick: c,
|
|
40
|
+
children: /* @__PURE__ */ t(f, { size: 30 })
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ t(
|
|
44
|
+
u,
|
|
45
|
+
{
|
|
46
|
+
sx: {
|
|
47
|
+
minHeight: 600,
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
justifyContent: "center !important"
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ t(
|
|
53
|
+
d,
|
|
54
|
+
{
|
|
55
|
+
sessionId: n,
|
|
56
|
+
region: r,
|
|
57
|
+
disableStartScreen: !0,
|
|
58
|
+
onAnalysisComplete: i,
|
|
59
|
+
onError: s
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
|
+
x,
|
|
66
|
+
{
|
|
67
|
+
direction: "column",
|
|
68
|
+
sx: {
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
gap: 2
|
|
72
|
+
},
|
|
73
|
+
children: /* @__PURE__ */ t(g, { uniqueId: e })
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
) });
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
v as default
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.amplify-liveness-freshness-canvas[style*="display: block;"]{display:block!important}.amplify-liveness-freshness-canvas[style*="display: none;"]{display:none!important}:root{--realeyes-brand: #2DC0A2}[data-amplify-theme]{--amplify-colors-primary-80: var(--realeyes-brand) !important;--amplify-colors-primary-10: var(--realeyes-brand) !important;--amplify-colors-primary-90: var(--realeyes-brand) !important;--amplify-colors-primary-100: var(--realeyes-brand) !important;--amplify-components-button-primary-hover-background-color: var(--realeyes-brand) !important}.amplify-liveness-cancel-container{background-color:#0000!important;display:none!important}.amplify-liveness-cancel-button{background-color:#0000!important}.amplify-button.amplify-field-group__control.amplify-button--link.amplify-button--large.amplify-liveness-cancel-button,.amplify-liveness-recording-icon-container,.amplify-icon,.amplify-flex.amplify-alert.amplify-liveness-start-screen-warning{display:none!important}.amplify-liveness-camera-module{border-width:0px!important}div.amplify-flex.amplify-liveness-oval-canvas>canvas{border-width:2px;border-color:#fff}.amplify-liveness-toast--primary{background-color:var(--realeyes-brand)!important}.amplify-liveness-match-indicator__bar:after{background-color:var(--realeyes-brand)!important}.MuiModal-backdrop{background-color:#0000!important}@media(min-width:768px){.amplify-liveness-oval-canvas{width:100%!important;max-width:450px!important}div.amplify-flex.amplify-liveness-oval-canvas>canvas{width:100%!important;height:auto!important}.liveness-detector-check{display:flex!important;flex-direction:column!important}.amplify-liveness-hint{order:1!important;margin-bottom:.5rem!important}.amplify-liveness-match-indicator{order:2!important;margin-bottom:1rem!important}.amplify-liveness-camera-module{order:3!important}.amplify-liveness-overlay{position:static!important;flex-direction:column!important;align-items:center!important}}@media((max-width:767px)and (orientation:portrait))or ((max-height:767px)and (orientation:landscape)){.amplify-flex:has(>.amplify-liveness-landscape-error-modal){position:relative!important}}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { FilesetResolver as _, FaceDetector as x } from "@mediapipe/tasks-vision";
|
|
2
|
+
const p = 640, g = 480, C = 500 * 1024, $ = 500, A = 8e5, z = 100, c = 2, M = 200;
|
|
3
|
+
class b {
|
|
4
|
+
faceDetector = null;
|
|
5
|
+
isInitialized = !1;
|
|
6
|
+
mediaRecorder = null;
|
|
7
|
+
recordedChunks = [];
|
|
8
|
+
cryptoChain = [];
|
|
9
|
+
previousHash = "";
|
|
10
|
+
canvas = null;
|
|
11
|
+
ctx = null;
|
|
12
|
+
async initialize() {
|
|
13
|
+
if (!(this.isInitialized && this.faceDetector))
|
|
14
|
+
try {
|
|
15
|
+
const t = await _.forVisionTasks(
|
|
16
|
+
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
|
|
17
|
+
);
|
|
18
|
+
this.faceDetector = await x.createFromOptions(t, {
|
|
19
|
+
baseOptions: {
|
|
20
|
+
modelAssetPath: "https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite",
|
|
21
|
+
delegate: "GPU"
|
|
22
|
+
},
|
|
23
|
+
runningMode: "VIDEO",
|
|
24
|
+
minDetectionConfidence: 0.5,
|
|
25
|
+
minSuppressionThreshold: 0.3
|
|
26
|
+
}), this.isInitialized = !0, this.canvas = document.createElement("canvas"), this.canvas.width = p, this.canvas.height = g, this.ctx = this.canvas.getContext("2d");
|
|
27
|
+
} catch (t) {
|
|
28
|
+
throw console.error("Failed to initialize video recorder service:", t), t;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async computeFrameHash(t, r) {
|
|
32
|
+
const o = new Uint8Array([
|
|
33
|
+
...new TextEncoder().encode(this.previousHash),
|
|
34
|
+
...new TextEncoder().encode(r.toString()),
|
|
35
|
+
...t.data
|
|
36
|
+
]), s = await crypto.subtle.digest("SHA-256", o);
|
|
37
|
+
return Array.from(new Uint8Array(s)).map((h) => h.toString(16).padStart(2, "0")).join("");
|
|
38
|
+
}
|
|
39
|
+
async generateHash(t, r) {
|
|
40
|
+
if (!this.canvas || !this.ctx) return;
|
|
41
|
+
this.canvas.width = p, this.canvas.height = g, this.ctx.drawImage(t, 0, 0, p, g);
|
|
42
|
+
const o = this.ctx.getImageData(0, 0, p, g), s = await this.computeFrameHash(o, r);
|
|
43
|
+
this.cryptoChain.push({ timestamp: r, hash: s }), this.previousHash = s, console.log(`Hash generated at ${r.toFixed(0)}ms, total: ${this.cryptoChain.length}`);
|
|
44
|
+
}
|
|
45
|
+
async recordVideo(t, r = $, o) {
|
|
46
|
+
if (!this.isInitialized || !this.faceDetector || !this.canvas || !this.ctx)
|
|
47
|
+
throw new Error("VideoRecorderService not initialized");
|
|
48
|
+
return new Promise((s, i) => {
|
|
49
|
+
this.recordedChunks = [], this.cryptoChain = [], this.previousHash = "genesis";
|
|
50
|
+
let u = !1, h = 0;
|
|
51
|
+
const T = 2;
|
|
52
|
+
let f = !1;
|
|
53
|
+
const v = t.srcObject;
|
|
54
|
+
if (!v) {
|
|
55
|
+
i(new Error("No video stream available"));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const R = v.getVideoTracks();
|
|
59
|
+
if (R.length === 0) {
|
|
60
|
+
i(new Error("No video tracks available"));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const E = new MediaStream(R), d = R[0]?.getSettings();
|
|
64
|
+
console.log(`Recording video: ${d?.width}x${d?.height}@${d?.frameRate}fps, facingMode: ${d?.facingMode}`);
|
|
65
|
+
const H = [
|
|
66
|
+
"video/webm;codecs=vp9",
|
|
67
|
+
"video/webm;codecs=vp8",
|
|
68
|
+
"video/webm",
|
|
69
|
+
"video/mp4"
|
|
70
|
+
];
|
|
71
|
+
let a = "";
|
|
72
|
+
for (const e of H)
|
|
73
|
+
if (MediaRecorder.isTypeSupported(e)) {
|
|
74
|
+
a = e, console.log(`Selected video format: ${a}`);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (!a) {
|
|
78
|
+
i(new Error("No supported video format found"));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
this.mediaRecorder = new MediaRecorder(E, {
|
|
83
|
+
mimeType: a,
|
|
84
|
+
videoBitsPerSecond: A
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error("Failed to create MediaRecorder:", e), i(e);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.mediaRecorder.ondataavailable = (e) => {
|
|
91
|
+
e.data && e.data.size > 0 && (console.log(`Recorded chunk: ${(e.data.size / 1024).toFixed(2)} KB`), this.recordedChunks.push(e.data));
|
|
92
|
+
}, this.mediaRecorder.onstop = () => {
|
|
93
|
+
if (console.log(`Total chunks recorded: ${this.recordedChunks.length}`), console.log(`Total crypto chain length: ${this.cryptoChain.length}`), this.cryptoChain.length < c) {
|
|
94
|
+
i(new Error(`Insufficient crypto chain hashes: ${this.cryptoChain.length}, minimum required: ${c}`));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const e = new Blob(this.recordedChunks, { type: a });
|
|
98
|
+
if (console.log(`Video recorded: ${(e.size / 1024).toFixed(2)} KB, crypto chain length: ${this.cryptoChain.length}`), e.size === 0) {
|
|
99
|
+
i(new Error("Recorded video is empty"));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
e.size > C && console.warn(`Video size (${(e.size / 1024).toFixed(2)} KB) exceeds target (${C / 1024} KB)`), s({
|
|
103
|
+
videoBlob: e,
|
|
104
|
+
cryptoChain: this.cryptoChain.map((y) => y.hash),
|
|
105
|
+
hasFaceDetected: u && h >= T,
|
|
106
|
+
mimeType: a
|
|
107
|
+
});
|
|
108
|
+
}, this.mediaRecorder.onerror = (e) => {
|
|
109
|
+
console.error("MediaRecorder error:", e), i(new Error(`MediaRecorder error: ${e}`));
|
|
110
|
+
};
|
|
111
|
+
const I = Date.now();
|
|
112
|
+
let n, w = 0, S = 0;
|
|
113
|
+
const D = () => {
|
|
114
|
+
if (!f) {
|
|
115
|
+
if (f = !0, cancelAnimationFrame(n), this.cryptoChain.length < c) {
|
|
116
|
+
console.warn(`Only ${this.cryptoChain.length} hashes generated, need at least ${c}. Extending recording...`), f = !1, n = requestAnimationFrame(l);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.mediaRecorder && this.mediaRecorder.state === "recording" && (console.log(`Stopping MediaRecorder with ${this.cryptoChain.length} hashes`), this.mediaRecorder.requestData(), setTimeout(() => {
|
|
120
|
+
this.mediaRecorder && this.mediaRecorder.state === "recording" && this.mediaRecorder.stop();
|
|
121
|
+
}, 100));
|
|
122
|
+
}
|
|
123
|
+
}, l = async () => {
|
|
124
|
+
const e = Date.now() - I, y = Math.min(e / r, 1);
|
|
125
|
+
if (o && o(y), e >= r && this.cryptoChain.length >= c) {
|
|
126
|
+
D();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (e >= r + M) {
|
|
130
|
+
console.warn(`Recording timeout reached. Hashes: ${this.cryptoChain.length}`), D();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (t.videoWidth === 0 || t.videoHeight === 0) {
|
|
134
|
+
n = requestAnimationFrame(l);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const F = performance.now();
|
|
138
|
+
try {
|
|
139
|
+
this.faceDetector.detectForVideo(t, F).detections.length > 0 && (u = !0, h++);
|
|
140
|
+
} catch (m) {
|
|
141
|
+
console.error("Face detection error:", m);
|
|
142
|
+
}
|
|
143
|
+
if (e >= w)
|
|
144
|
+
try {
|
|
145
|
+
await this.generateHash(t, F), S++, w = e + z;
|
|
146
|
+
} catch (m) {
|
|
147
|
+
console.error("Hash generation error:", m);
|
|
148
|
+
}
|
|
149
|
+
n = requestAnimationFrame(l);
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
this.mediaRecorder.start(100), console.log("MediaRecorder started"), n = requestAnimationFrame(l);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.error("Failed to start MediaRecorder:", e), i(e);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
dispose() {
|
|
159
|
+
this.faceDetector && (this.faceDetector.close(), this.faceDetector = null, this.isInitialized = !1), this.mediaRecorder && this.mediaRecorder.state === "recording" && this.mediaRecorder.stop(), this.mediaRecorder = null, this.recordedChunks = [], this.cryptoChain = [], this.canvas && (this.canvas = null, this.ctx = null);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const O = new b();
|
|
163
|
+
export {
|
|
164
|
+
O as videoRecorderService
|
|
165
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@realeyes/verifeye-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "React component library for embedding the VerifEye identity-verification flow into your web application.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"verifeye",
|
|
7
|
+
"realeyes",
|
|
8
|
+
"identity-verification",
|
|
9
|
+
"face-verification",
|
|
10
|
+
"liveness"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://verifeye-docs.realeyes.ai/cloud-apis-web-sdks/web-sdk/",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": "./dist/index.css",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"NOTICE"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "restricted"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@aws-amplify/ui-react": "^6.15.2",
|
|
35
|
+
"@aws-amplify/ui-react-liveness": "^3.6.3",
|
|
36
|
+
"@aws-sdk/client-kinesis": "^3.709.0",
|
|
37
|
+
"@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
|
|
38
|
+
"aws-amplify": "^6.15.9"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@emotion/react": "^11.14.0",
|
|
42
|
+
"@emotion/styled": "^11.14.1",
|
|
43
|
+
"@mui/icons-material": "^7.3.11",
|
|
44
|
+
"@mui/material": "^7.3.11",
|
|
45
|
+
"react": ">=18",
|
|
46
|
+
"react-dom": ">=18"
|
|
47
|
+
}
|
|
48
|
+
}
|