@voltom.io/sdk 1.0.5 → 1.0.6
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/sdk/{PoseSilhouette-Bbwmry4Z.js → PoseSilhouette-V9BxuMwo.js} +1 -1
- package/dist/sdk/{PoseSuccess-C3aBF88E.js → PoseSuccess-DDx23oJD.js} +1 -1
- package/dist/sdk/eyeLevelCamera-aDRPs63K.js +65 -0
- package/dist/sdk/facegate/global.d.ts +1 -1
- package/dist/sdk/facegate.d.ts +23 -6
- package/dist/sdk/facegate.dist.js +5 -5
- package/dist/sdk/facegate.js +1 -1
- package/dist/sdk/facekey.browser-bs8vp3ON.js +2 -0
- package/dist/sdk/facekey.d.ts +37 -23
- package/dist/sdk/facekey.dist.js +6 -6
- package/dist/sdk/facekey.js +1 -1
- package/dist/sdk/media-Cejmtltt.js +2 -0
- package/dist/sdk/{presentation-BsnbDv0i.js → presentation-B4P1537m.js} +1 -1
- package/dist/sdk/presentation-Cg1Ec60l.js +8 -0
- package/dist/sdk/verify.d.ts +23 -6
- package/dist/sdk/verify.dist.js +18 -18
- package/dist/sdk/verify.js +1 -1
- package/dist/sdk/view-DTvcOVnH.js +3 -0
- package/dist/sdk/view-ObOGpVdZ.js +3 -0
- package/dist/sdk/view-iMF-mWfw.js +2 -0
- package/package.json +5 -4
- package/dist/sdk/eyeLevelCamera-DY4onSBz.js +0 -65
- package/dist/sdk/facekey.browser-CVJiBw1f.js +0 -2
- package/dist/sdk/media-BRKPXpu3.js +0 -2
- package/dist/sdk/presentation-B-TOKUZ3.js +0 -8
- package/dist/sdk/view-Bfg8u_hZ.js +0 -2
- package/dist/sdk/view-CHSkN6gO.js +0 -3
- package/dist/sdk/view-DmGKdc3M.js +0 -3
package/dist/sdk/facegate.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
-
import{
|
|
2
|
+
import{E as e,Q as t,et as n,l as r,n as i,q as a,r as o,t as s}from"./eyeLevelCamera-aDRPs63K.js";import{O as c,_ as l,a as u,c as d,f,g as p,i as m,m as h,s as g,t as _,u as v}from"./media-Cejmtltt.js";import{n as y}from"./facekey.browser-bs8vp3ON.js";var b=()=>({active:n(!1),phase:n(`idle`),prompt:n(``),completed:n(0),total:n(1),outcome:n(null),captures:n([])}),x=e=>{if(typeof e.clientKey!=`string`||e.clientKey.length<8||e.requireEyeLevelCamera!==void 0&&typeof e.requireEyeLevelCamera!=`boolean`)throw Error(p.INVALID_OPTIONS);return{...e,requireEyeLevelCamera:e.requireEyeLevelCamera??!1}},S=e=>{if(typeof e.action!=`string`||e.action.length<1||e.action.length>255||typeof e.authorize!=`function`||typeof e.onPass!=`function`||typeof e.onReject!=`function`)throw Error(p.INVALID_OPTIONS);return e},C=e=>{if(typeof e!=`string`||e.length<32||e.length>128)throw Error(p.INVALID_SERVICE_RESPONSE);return e},{detectPictureFaces:w,loadFaceDetector:T}=y,E=3e4,D=e=>new Promise(t=>setTimeout(t,e)),O=async({frame:t,neutral:n,pose:a,requireEyeLevelCamera:c})=>{let l=await w(t,{blendshapes:!0}),u=l.length===1?l[0]:null;if(!u)return{alignment:null,code:null,prompt:`faceNotFound`,ready:!1};let d={pitch:u.pitch,yaw:u.yaw,roll:u.roll},f=u.boundingRect.height/Math.min(t.width,t.height),p=u.boundingRect.x+u.boundingRect.width/2,m=u.boundingRect.y+u.boundingRect.height/2,h=Math.hypot(p-t.width/2,m-t.height/2)<=Math.min(t.width,t.height)*.12;if(f<.5)return{alignment:d,code:null,prompt:`faceTooSmall`,ready:!1};if(!h)return{alignment:d,code:null,prompt:`centerFace`,ready:!1};let g=i({pitch:u.pitch,pose:a,requireEyeLevelCamera:c,options:e});if(g)return{alignment:d,code:g,prompt:s(),ready:!1};let _=o({alignment:d,blendshapes:u.blendshapes,neutral:n,pose:a,options:e});if(_.code){let e=r({pose:a,code:_.code});return{alignment:d,code:_.code,prompt:e.corrective??e.primary,ready:!1}}return{alignment:d,code:null,prompt:r({pose:a,code:null}).primary,ready:!0}},k=class{options;display=b();handles=new Set;controller=null;view=null;preparing=null;prepared=!1;running=!1;disposed=!1;constructor(e){let{prepare:t=!0,...n}=e;this.options=Object.freeze(x(n)),t&&this.prepare().catch(e=>console.error(e))}async caniuse(){return await _()}async prepare(){if(this.disposed)throw Error(p.SDK_NOT_READY);if(this.prepared)return;if(this.preparing)return this.preparing;let e=(async()=>{if(await h({language:this.options.language}),await a({filenames:[`fd.ort`,`fe.ort`,`fl.ort`,`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`]}),this.disposed)throw Error(p.SDK_NOT_READY);if(await T({faceDetector:`standard`}),!this.view){let{createFaceGateView:e}=await import(`./view-iMF-mWfw.js`);if(this.disposed)throw Error(p.SDK_NOT_READY);this.view=e({options:this.options,display:this.display,onCancel:()=>this.stop()})}if(this.disposed)throw Error(p.SDK_NOT_READY);this.prepared=!0})();this.preparing=e;try{await e}finally{this.preparing===e&&(this.preparing=null)}}arm(e,t){if(this.disposed)throw Error(p.SDK_NOT_READY);let n=S(t),r,i=()=>{this.runGate(r)};return r={control:e,options:n,detach:()=>e.removeEventListener(`click`,i)},e.addEventListener(`click`,i),this.handles.add(r),r}disarm(e){e.detach(),this.handles.delete(e)}async request({path:e,body:t,signal:n}){let r=await fetch(`${(this.options.apiUrl??`https://api.voltom.io`).replace(/\/$/,``)}/facegate/${e}`,{method:`POST`,headers:{authorization:`Bearer ${this.options.clientKey}`,"content-type":`application/json`},body:JSON.stringify(t),signal:n}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(typeof i?.code==`string`?i.code:p.INVALID_SERVICE_RESPONSE);return i}async capture({video:e,poses:n,signal:i}){let{translate:a}=f({language:this.options.language}),o=[],s=null;for(let[c,l]of n.entries()){let n=0;for(t(()=>{this.display.phase.value=`capturing`,this.display.completed.value=c,this.display.prompt.value=a(r({pose:l,code:null}).primary)});n<3;){await v({video:e,signal:i}),i.throwIfAborted();let t=await createImageBitmap(e);try{let e=await O({frame:t,neutral:s,pose:l,requireEyeLevelCamera:this.options.requireEyeLevelCamera??!1});if(i.throwIfAborted(),n=e.ready?n+1:0,this.display.prompt.value=a(e.prompt),l===`faceStraight`&&e.ready&&(s=e.alignment),n>=3){let e=await m({frame:t});o.push(await u({image:e}))}}finally{t.close()}}this.display.completed.value=c+1}return o}async runGate(e){if(this.disposed||this.running)return;this.running=!0;let n=e.options;try{await this.prepare()}catch(e){this.running=!1;let t=l({error:e,fallback:p.SERVICE_UNAVAILABLE});n.onReject({outcome:`error`,reason:t});return}let r=new AbortController;this.controller=r;let i=r.signal,a=()=>r.abort(new DOMException(p.FACEGATE_ABORTED,`AbortError`)),o=setTimeout(()=>r.abort(new DOMException(p.FACEGATE_TIMEOUT,`TimeoutError`)),E);n.signal?.addEventListener(`abort`,a,{once:!0}),n.signal?.aborted&&r.abort(),t(()=>{this.display.active.value=!0,this.display.phase.value=`capturing`,this.display.outcome.value=null,this.display.completed.value=0,this.display.total.value=1,this.display.prompt.value=``}),this.view?.open();try{let e=this.view?.video;if(!e)throw Error(p.INVALID_OPTIONS);await g({facingMode:`user`,video:e,signal:i}),i.throwIfAborted();let t=await Promise.all([n.subjectId?.(),n.metadata?.()]),r=await n.authorize({action:n.action,subjectId:t[0],metadata:t[1]});if(!r.poses?.length)throw Error(p.INVALID_OPTIONS);C(r.token),this.display.total.value=r.poses.length;let a=await this.capture({video:e,poses:r.poses,signal:i});i.throwIfAborted(),this.display.phase.value=`checking`,this.display.prompt.value=f({language:this.options.language}).translate(`checkingFaceMatch`);let o=await this.request({path:`verify`,body:{token:r.token,poses:r.poses,faces:a},signal:i});this.display.outcome.value=o.outcome,this.display.phase.value=o.outcome===`pass`?`pass`:`reject`,this.display.prompt.value=``,await D(950),this.view?.close(),o.outcome===`pass`?await n.onPass({resultId:o.resultId}):n.onReject({outcome:o.outcome,reason:o.reason})}catch(e){let t=i.aborted?l({error:i.reason,fallback:p.FACEGATE_ABORTED}):l({error:e,fallback:p.SERVICE_UNAVAILABLE});t!==p.FACEGATE_ABORTED&&(this.display.outcome.value=`error`,this.display.phase.value=`reject`,this.display.prompt.value=``,await D(950)),this.view?.close(),n.onReject({outcome:`error`,reason:t})}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,a);let e=this.view?.video;e&&d({video:e}),this.display.active.value=!1,this.controller=null,this.running=!1}}stop(){this.controller&&this.controller.abort(new DOMException(p.FACEGATE_ABORTED,`AbortError`))}dispose(){if(!this.disposed){this.disposed=!0,this.stop();for(let e of this.handles)e.detach();this.handles.clear(),this.view?.close()}}getState(){return{active:this.display.active.value,phase:this.display.phase.value,prompt:this.display.prompt.value,completed:this.display.completed.value,total:this.display.total.value,outcome:this.display.outcome.value}}};c({moduleUrl:import.meta.url});var A=k;export{k as VoltomFaceGate,A as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
+
import{L as e,g as t,h as n,m as r,p as i,z as a}from"./eyeLevelCamera-aDRPs63K.js";var o=a({runtime:e}),s=r({runtime:e}),c=t({runtime:e}),l=n({runtime:e,imageFromImageBitmap:o}),u=i({runtime:e,...s,...c,...l,faceDetection:l});export{l as n,u as r,c as t};
|
package/dist/sdk/facekey.d.ts
CHANGED
|
@@ -1,49 +1,63 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type Language = "ar" | "ch" | "de" | "en" | "es" | "fr" | "it" | "ja" | "pt" | "ru" | "zh";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type Theme = "light" | "dark";
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type VoltomBrowserSupport = { supported: boolean; unsupportedFeatures: string[] };
|
|
6
6
|
|
|
7
|
-
export type
|
|
8
|
-
userId: string;
|
|
9
|
-
matched: boolean;
|
|
10
|
-
matches: { pose: FaceKeyPose; matched: boolean; score: number }[];
|
|
11
|
-
reason: string | null;
|
|
12
|
-
};
|
|
7
|
+
export type FaceKeyOperation = "enroll" | "unlock";
|
|
13
8
|
|
|
14
9
|
export type FaceKeyCapability = FaceKeyOperation;
|
|
15
10
|
|
|
16
|
-
export type
|
|
11
|
+
export type FaceKeyPose = "faceStraight" | "faceUp" | "faceLeft" | "faceRight" | "faceSmile";
|
|
17
12
|
|
|
18
13
|
export type FaceKeyOperationOptions = { signal?: AbortSignal; debug?: boolean };
|
|
19
14
|
|
|
20
15
|
export type VoltomFaceKeyOptions = {
|
|
21
16
|
clientKey: string;
|
|
17
|
+
prepare?: boolean;
|
|
22
18
|
requireEyeLevelCamera?: boolean;
|
|
23
19
|
apiUrl?: string;
|
|
24
20
|
debug?: boolean;
|
|
25
|
-
language?:
|
|
21
|
+
language?: Language;
|
|
22
|
+
theme?: Theme;
|
|
26
23
|
capabilities?: FaceKeyCapability[];
|
|
27
|
-
ui?: boolean;
|
|
28
|
-
video?: HTMLVideoElement;
|
|
29
24
|
};
|
|
30
25
|
|
|
31
|
-
export type
|
|
26
|
+
export type FaceKeyIntent = {
|
|
27
|
+
resultId: string;
|
|
28
|
+
token: string;
|
|
29
|
+
action: FaceKeyOperation;
|
|
30
|
+
subjectId: string;
|
|
31
|
+
poses: FaceKeyPose[];
|
|
32
|
+
expiresAt: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type FaceKeyInput = FaceKeyIntent;
|
|
36
|
+
|
|
37
|
+
export type FaceKeyIdentity = { subjectId: string };
|
|
38
|
+
|
|
39
|
+
export type FaceKeyUnlock = {
|
|
40
|
+
subjectId: string;
|
|
41
|
+
matched: boolean;
|
|
42
|
+
matches: { pose: FaceKeyPose; matched: boolean; score: number }[];
|
|
43
|
+
reason: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type FaceKeyFramingRejection =
|
|
47
|
+
| "FACE_NOT_DETECTED"
|
|
48
|
+
| "FACE_IN_POLYGON"
|
|
49
|
+
| "FACE_TOO_SMALL"
|
|
50
|
+
| "FACE_NOT_CENTERED"
|
|
51
|
+
| "FACE_CAMERA_ALIGNMENT_REQUIRED";
|
|
32
52
|
|
|
33
53
|
export type FaceKeyInstruction = {
|
|
34
|
-
framing:
|
|
35
|
-
| "FACE_NOT_DETECTED"
|
|
36
|
-
| "FACE_IN_POLYGON"
|
|
37
|
-
| "FACE_TOO_SMALL"
|
|
38
|
-
| "FACE_NOT_CENTERED"
|
|
39
|
-
| "FACE_CAMERA_ALIGNMENT_REQUIRED"
|
|
40
|
-
| null;
|
|
54
|
+
framing: FaceKeyFramingRejection | null;
|
|
41
55
|
retry: string | null;
|
|
42
56
|
};
|
|
43
57
|
|
|
44
58
|
export type VoltomFaceKeyState = {
|
|
45
59
|
operation: FaceKeyOperation;
|
|
46
|
-
phase: "loading" | "capturing" | "
|
|
60
|
+
phase: "loading" | "capturing" | "processing" | "success" | "failure";
|
|
47
61
|
instruction: FaceKeyInstruction | null;
|
|
48
62
|
progress: { completed: number; total: number };
|
|
49
63
|
feedback: { matched: boolean; animating: boolean } | null;
|
|
@@ -58,7 +72,7 @@ export declare class VoltomFaceKey {
|
|
|
58
72
|
prepare(): Promise<void>;
|
|
59
73
|
caniuse(): Promise<VoltomBrowserSupport>;
|
|
60
74
|
faceEnroll(input: FaceKeyInput, options?: FaceKeyOperationOptions): Promise<FaceKeyIdentity>;
|
|
61
|
-
faceUnlock(input: FaceKeyInput & {
|
|
75
|
+
faceUnlock(input: FaceKeyInput & { subjectId: string }, options?: FaceKeyOperationOptions): Promise<FaceKeyUnlock>;
|
|
62
76
|
stop(): void;
|
|
63
77
|
dispose(): void;
|
|
64
78
|
getState(): VoltomFaceKeyState;
|