@voltom.io/sdk 1.0.2 → 1.0.4
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/assets/locales/ar.json +121 -0
- package/dist/assets/locales/ch.json +121 -0
- package/dist/assets/locales/de.json +121 -0
- package/dist/assets/locales/en.json +121 -0
- package/dist/assets/locales/es.json +121 -0
- package/dist/assets/locales/fr.json +121 -0
- package/dist/assets/locales/it.json +121 -0
- package/dist/assets/locales/ja.json +121 -0
- package/dist/assets/locales/pt.json +121 -0
- package/dist/assets/locales/ru.json +121 -0
- package/dist/assets/locales/zh.json +121 -0
- package/dist/sdk/PoseSilhouette-CTZ5kqI_.js +2 -0
- package/dist/sdk/PoseSuccess-CxL2ugaZ.js +2 -0
- package/dist/sdk/facegate/global.d.ts +5 -0
- package/dist/sdk/facegate.d.ts +51 -0
- package/dist/sdk/facegate.dist.js +56 -0
- package/dist/sdk/facegate.js +2 -0
- package/dist/sdk/facekey/global.d.ts +0 -2
- package/dist/sdk/facekey.browser-D_vfob8H.js +2 -0
- package/dist/sdk/facekey.d.ts +2 -3
- package/dist/sdk/facekey.dist.js +3 -2
- package/dist/sdk/facekey.js +1 -1
- package/dist/sdk/media-KU3CWepq.js +2 -0
- package/dist/sdk/poseGuidance-DLg3Dm3T.js +65 -0
- package/dist/sdk/presentation-BCIQkuw0.js +2 -0
- package/dist/sdk/presentation-D9v4ITH0.js +8 -0
- package/dist/sdk/verify/global.d.ts +0 -2
- package/dist/sdk/verify.d.ts +2 -5
- package/dist/sdk/verify.dist.js +18 -18
- package/dist/sdk/verify.js +1 -1
- package/dist/sdk/view-CsOmx3ht.js +3 -0
- package/dist/sdk/view-Dgrm0mpZ.js +3 -0
- package/dist/sdk/view-WiNYUW9A.js +2 -0
- package/package.json +27 -9
- package/dist/sdk/DebugPanel-BJqGy2Dp.js +0 -2
- package/dist/sdk/faceMatch.shared-D6B1I2T0.js +0 -65
- package/dist/sdk/feedback-Cs09W_hs.js +0 -2
- package/dist/sdk/presentation-BrCGZT1u.js +0 -8
- package/dist/sdk/presentation-Jz2euuHa.js +0 -2
- package/dist/sdk/view-usv6rHIE.js +0 -3
- package/dist/sdk/view-vxhVZZc1.js +0 -2
package/dist/sdk/verify.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{$ as e,G as t,H as n,J as r,K as i,Q as a,U as o,W as s,X as c,Y as l,Z as u,a as d,ct as f,dt as p,et as m,nt as h,q as g,rt as _,tt as v,v as y,w as b}from"./faceMatch.shared-D6B1I2T0.js";import{_ as x,a as S,c as C,d as w,f as T,g as E,h as D,i as O,l as k,m as A,n as ee,o as j,p as M,s as N,t as P,u as F,v as I,y as L}from"./presentation-BrCGZT1u.js";var{analyzeDocumentFrame:R,hasValidDocumentSideData:z,validateDocumentBack:B}=A,te=({view:e,display:n,isActive:r,notifyCapturesChanged:i,getVerifyHardOptions:a})=>{let s=e.ref,u=async({frame:c,session:l,state:u,options:d})=>{let f=performance.now(),p=!!u.captures.documentFront,m=d.requiredDocumentStableFrames,h=null,g=null;try{h=await R({frame:c,prepareForMatch:p||u.documentStableFrames+1>=d.requiredDocumentStableFrames,options:{...a({configuration:d}),alignment:u.matchOptions.alignment,requiresFace:!p}});let{orientation:e,detection:f,face:_}=h;if(!r({flow:`document`,session:l,state:u}))return!1;let v=p?B({current:h,front:u.documentFrontSignature}):null;g=p?L({front:u.documentFrontSignature,current:h.signature}):null;let y=u.document?{...u.document,ocr:u.document.document_front}:void 0,b=z({analysis:h,isBack:p,front:y}),x=(p?v?.valid===!0:h.valid)&&b,S=e?e.rotation:null;S!==u.documentOrientation&&(u.documentStableFrames=0),u.documentOrientation=S,u.documentStableFrames=x?u.documentStableFrames+1:0,d.showDocumentOverlay?await N({documentFaceBoxColor:d.documentFaceBoxColor,documentFaceMeshColor:d.documentFaceMeshColor,documentBoxColor:d.documentBoxColor,element:s.mesh,detection:f,face:_,height:c.height,ocrLines:d.showTextOverlay?h.text.lines:[],ocrToSource:d.showTextOverlay?h.documentToSource:null,overlayColor:d.documentOverlayColor,textColor:d.textColor,width:c.width}):o({element:s.mesh});let C=U({analysis:h,dataValid:b,isBack:p,minFaceAreaRatio:d.minDocumentFaceAreaRatio,rejectionReasons:v?v.reasons:h.failureReasons,valid:x,stable:u.documentStableFrames>=m});if(n.feedback.value={flow:`document`,...C},u.documentStableFrames<m)return!1;let w=await t({frame:c});return r({flow:`document`,session:l,state:u})?p?(V({analysis:h,isBack:!0,state:u}),u.captures.documentBack=w,i({state:u}),!0):!h.embeddings||!h.images?!1:(V({analysis:h,isBack:!1,state:u}),u.documentFaceEmbeddings=h.embeddings,u.documentFrontSignature=h.signature,u.preparedCaptures.documentFront=h.images,u.captures.documentFront=w,i({state:u}),!0):!1}finally{h&&r({flow:`document`,session:l,state:u})&&e.collectDocumentDebug({analysis:h,sideComparison:g,isBack:p,processingTimeMilliseconds:performance.now()-f,state:u})}};return{runDocumentLoop:async({session:e,state:t,options:i})=>{for(;r({flow:`document`,session:e,state:t});){if(await c({video:s.video}),!r({flow:`document`,session:e,state:t}))return;let a=await createImageBitmap(s.video);try{let r=await l({frame:a});try{if(await u({frame:r,session:e,state:t,options:i})){t.flow=null,n.debug.value=[];return}}finally{r.close()}}finally{a.close()}}}}},V=({analysis:e,isBack:t,state:n})=>{if(!e.ocr)throw Error(m.CAPTURES_INCOMPLETE);let r={ocr:e.ocr,codes:e.codes};if(t){if(!n.document)throw Error(m.CAPTURES_INCOMPLETE);let t=b({classification:n.document,front:{ocr:n.document.document_front,codes:n.document.codes},back:r});n.document={...n.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw Error(m.DOCUMENT_NOT_RECOGNIZED);let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},i=b({classification:t,front:r});n.identity=e.identity,n.document={...t,...i,document_front:e.ocr,document_back:null}}n.documentCodes=n.document.codes},H=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,U=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:H({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(m.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(m.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},W=`https://api.voltom.io`,G=({apiUrl:e})=>{let t=e??W;return t.endsWith(`/`)?t.slice(0,-1):t},K=async({apiUrl:e,path:t,method:n=`POST`,body:r,clientKey:i,fallback:a=m.INVALID_SERVICE_RESPONSE,signal:o})=>{let s={};i&&(s.authorization=`Bearer ${i}`),r&&(s[`content-type`]=`application/json`);let c;try{c=await fetch(`${G({apiUrl:e})}${t}`,{method:n,headers:s,body:r,signal:o})}catch(e){throw o?.aborted?Error(m.VERIFICATION_CANCELLED,{cause:e}):Error(m.NETWORK_ERROR,{cause:e})}if(c.status===413)throw Error(m.REQUEST_TOO_LARGE);let l;try{l=await c.json()}catch(e){throw Error(c.status>=500?m.SERVICE_UNAVAILABLE:a,{cause:e})}if(!c.ok){let e=typeof l==`object`&&l&&`code`in l&&typeof l.code==`string`?l.code:c.status>=500?m.SERVICE_UNAVAILABLE:a;throw Error(e)}return l},q=async({clientKey:e,apiUrl:t,signal:n})=>{await K({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,fallback:m.INVALID_CLIENT_KEY,signal:n})},J=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${G({apiUrl:e})}/script-loads`)}catch{return}},ne=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:a,faces:o=[],options:s,picture:c,poses:l=[],sourceIds:u=[],threshold:d,signal:f})=>{if(!e)throw Error(m.CLIENT_KEY_REQUIRED);let p=JSON.stringify({documentFront:a?await i({image:a}):void 0,documentBack:r?await i({image:r}):void 0,picture:c?await i({image:c}):void 0,faces:await Promise.all(o.map(e=>i({image:e}))),options:s,poses:l.map(e=>k[e]),source_ids:u,threshold:d});return f?.throwIfAborted(),await K({apiUrl:t,path:n,body:p,clientKey:e,signal:f})},re=async({flow:e,startedAt:t,executionMs:n,outcome:r,result:a,error:o,captures:s,preparedCaptures:c,picture:l,clientKey:u,apiUrl:d,language:f,codes:p,signal:h})=>{let g=[...F.map(e=>({field:k[e],capture:s[e],prepared:c[e]})),{field:e===`document`||e===`match_id`?`document_front`:`picture`,capture:e===`document`||e===`match_id`?s.documentFront:l,prepared:e===`document`||e===`match_id`?c.documentFront:c.picture},...e===`document`||e===`match_id`?[{field:`document_back`,capture:s.documentBack,prepared:c.documentBack}]:[]].flatMap(e=>e.capture?[{field:e.field,capture:e.capture,prepared:e.prepared}]:[]);if(!g.length)throw Error(m.CAPTURES_INCOMPLETE);let _={};for(let{field:e,capture:t,prepared:n}of g){h?.throwIfAborted();let r=e;_[r]=await i({image:t}),n&&(_[`${r}_rgb`]=await i({image:n.rgb}),_[`${r}_greyscale`]=await i({image:n.greyscale}))}let y=JSON.stringify({language:f,started_at:t.toISOString(),execution_ms:n,outcome:r,match:a?.matched??null,score:a?.score??null,threshold:a?.threshold??null,error:o?v({error:o}):a?.reason??void 0,codes:p,captures:_}),b={human:`human`,document:`document`,match_id:`id`,match_picture:`picture`}[e];return await K({apiUrl:d,path:`/verification/${b}/fast`,clientKey:u,body:y,fallback:m.VERIFICATION_SAVE_FAILED,signal:h})},{loadDocumentBoxDetector:ie,detectDocumentOrientation:ae}=T,{detectPictureFaces:Y,loadFaceDetector:oe}=M,{loadFaceMatch:se,warmupFaceMatch:ce}=E,{loadTextDetector:X}=x,Z=({options:e,view:t,display:n})=>{let i=t.ref,s=[...w],c=({language:e})=>e??a(),l=()=>({identity:null,flow:null,session:0,faceSequence:[...s],faceCaptureConfiguration:null,documentCaptureConfiguration:null,poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,faceMatchOptions:null,hardHumanVerificationId:null,hardDocumentVerificationId:null,cameraActive:!1,cameraSize:n.cameraSize,cameraFacingMode:n.cameraFacingMode}),u=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,i.root.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},d=({state:e})=>{r({video:i.video}),u({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,n.feedback.value=null},f=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),p=({state:e})=>{let t=f({state:e});i.root.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},_=({state:t,options:n=e})=>{t.faceSequence=F({options:n}),t.poseIndex=0,t.poseStableFrames=0;let r=t.preparedCaptures.documentFront;t.preparedCaptures=r?{documentFront:r}:{},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.faceMatchOptions=null,t.hardHumanVerificationId=null,t.faceCaptureConfiguration=null;let{documentFront:i,documentBack:a}=t.captures;t.captures={...i?{documentFront:i}:{},...a?{documentBack:a}:{}}},b=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.hardDocumentVerificationId=null,e.documentCaptureConfiguration=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},x=({state:e})=>{e.session+=1,e.flow=null,d({state:e}),o({element:i.mesh}),n.debug.value=[]},k=({state:e})=>{x({state:e}),p({state:e}),n.error.value=null},A=({state:e})=>{let t=i.video.videoWidth,n=i.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},M=async({facingMode:e,state:t})=>{d({state:t});let n=t.session,a=await g({facingMode:e,video:i.video});if(t.session!==n)throw r({video:i.video}),$();t.cameraFacingMode.value=a,A({state:t}),u({active:!0,state:t})},N=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,P=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,F=({options:e})=>j({mode:e.mode,poses:e.poses,posesCount:e.posesCount,randomize:e.randomizeFaceSequence??!1}),L=({options:e})=>JSON.stringify({mode:e.mode,poses:e.poses,posesCount:e.posesCount,randomizeFaceSequence:e.randomizeFaceSequence,faceDetector:e.faceDetector,alignment:e.alignment,threshold:e.threshold,language:e.language,maxPitch:e.maxPitch,minPitch:e.minPitch,maxYaw:e.maxYaw,minYaw:e.minYaw,maxRoll:e.maxRoll,requiredFaceStableFrames:e.requiredFaceStableFrames}),R=({options:e})=>JSON.stringify({ocrEngine:e.ocrEngine,language:e.language,minDocumentFaceAreaRatio:e.minDocumentFaceAreaRatio,maxDocumentFaceAreaRatio:e.maxDocumentFaceAreaRatio,minDocumentFaceWidthRatio:e.minDocumentFaceWidthRatio,maxDocumentFaceWidthRatio:e.maxDocumentFaceWidthRatio,minDocumentFaceHeightRatio:e.minDocumentFaceHeightRatio,maxDocumentFaceHeightRatio:e.maxDocumentFaceHeightRatio,minDocumentBoxRatio:e.minDocumentBoxRatio,maxDocumentTextAngleDifference:e.maxDocumentTextAngleDifference,requiredDocumentStableFrames:e.requiredDocumentStableFrames}),z=({state:e,options:t})=>e.faceCaptureConfiguration===L({options:t})&&S({captures:e.captures,state:e}),B=({state:e,options:t})=>{let n=e.document,r=n!==void 0&&n.document!==`passport`,i=!(!e.captures.documentFront||r&&!e.captures.documentBack),a=e.documentCaptureConfiguration===R({options:t});return!!(n?.valid&&i&&a)},V=({configuration:e})=>{let t=Object.fromEntries(Object.keys(y).map(t=>[t,e[t]]));return t.language=c({language:e.language}),t},H=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=S({captures:n.captures,state:n})?O({captures:n.captures,state:n}):null;return await ne({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:V({configuration:e}),picture:r,poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},U=async t=>await re({...t,clientKey:e.clientKey,apiUrl:e.apiUrl,language:c({language:e.language}),signal:t.signal}),W={options:e,view:t,display:n,isActive:N,notifyCapturesChanged:p,getVerifyHardOptions:V},{runFaceLoop:G}=ee(W),{runDocumentLoop:K}=te(W),q=async({state:e,options:t})=>{x({state:e}),_({state:e,options:t}),e.faceCaptureConfiguration=L({options:t}),e.matchOptions={alignment:t.alignment,threshold:t.threshold},e.faceMatchOptions={...e.matchOptions},p({state:e});let r=e.session;e.flow=`face`;try{if(n.feedback.value={flow:`face`,pose:P({state:e}),code:null},await M({facingMode:`user`,state:e}),n.feedback.value={flow:`face`,pose:P({state:e}),code:null},await G({session:r,state:e,options:t}),e.session!==r)throw $();if(!S({captures:e.captures,state:e}))throw Error(m.CAPTURES_INCOMPLETE);let a={...e.captures};return d({state:e}),o({element:i.mesh}),a}finally{e.session===r&&(n.feedback.value=null)}},J=async({state:t,options:r=e})=>{x({state:t}),b({state:t}),t.documentCaptureConfiguration=R({options:r}),t.matchOptions={alignment:r.alignment,threshold:r.threshold},p({state:t});let a=t.session;t.flow=`document`;try{if(!N({flow:`document`,session:a,state:t})||(await M({facingMode:`environment`,state:t}),n.feedback.value={flow:`document`,code:null,target:`front`},await K({session:a,state:t,options:r}),t.session!==a))throw $();if(!t.captures.documentFront||!t.document)throw Error(m.CAPTURES_INCOMPLETE);if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,n.feedback.value={flow:`document`,code:null,target:`back`},await K({session:a,state:t,options:r}),t.session!==a))throw $();if(!t.document.valid)throw Error(m.DOCUMENT_VALIDATION_FAILED);let e={...t.captures};return d({state:t}),o({element:i.mesh}),e}finally{t.session===a&&(n.feedback.value=null,o({element:i.mesh}))}},Z=async({state:e,options:t,signal:r})=>{n.error.value=null,z({state:e,options:t})||await q({state:e,options:t}),r?.throwIfAborted(),B({state:e,options:t})||await J({state:e,options:t}),r?.throwIfAborted();let i=e.captures.documentFront;if(!i||!e.documentFaceEmbeddings)throw Error(m.CAPTURES_INCOMPLETE);let a=e.session;n.activity.value=`matching`;let o=O({captures:e.captures,state:e}),s=o.poses.indexOf(`faceStraight`);if(s<0)throw Error(m.INVALID_POSES);let c=await E.matchFaceWithDocument({document:i,documentFaceEmbeddings:e.documentFaceEmbeddings,referenceFaceEmbeddings:o.embeddings[s],options:t,reference:o.faces[s]});if(e.session!==a)throw $();return p({state:e}),{matched:c.matched,score:c.score,reason:c.matched?null:m.FACE_MISMATCH,threshold:t.threshold,...f({state:e})}},Q=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[ie(),oe({faceDetector:e.faceDetector}),se(),...t?[D(),X({engine:`tiny`,language:`latin`}),X({engine:e.ocrEngine,language:c({language:e.language})}),I()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[C()]:[]];await Promise.all(n);let r=document.createElement(`canvas`);r.width=640,r.height=480;let i=await createImageBitmap(r);try{let e=[Y(i),T.detectDocumentBox(i),ce()];t&&e.push(ae({frame:i,boundingRect:{x:0,y:0,width:i.width,height:i.height}})),await Promise.all(e)}finally{i.close()}},$=()=>new DOMException(m.VERIFICATION_CANCELLED,`AbortError`);return{createState:l,stop:k,syncCameraSize:A,captureResult:f,resetFaceFlow:_,resetDocumentFlow:b,hasCompatibleFaceCaptures:z,hasCompatibleDocumentCapture:B,notifyCapturesChanged:p,startFaceFlow:q,startDocumentFlow:J,startFlow:Z,startPictureFlow:async({picture:e,state:t,options:r,signal:i})=>{n.error.value=null,i?.throwIfAborted();let a=await E.imageBitmap({blob:e});try{let e=await Y(a,{forMatch:!0});if(i?.throwIfAborted(),!e.length)throw Error(m.NO_USABLE_CANDIDATES)}finally{a.close()}let o=t.faceCaptureConfiguration===L({options:r});z({state:t,options:r})&&o||await q({state:t,options:r}),i?.throwIfAborted();let s=O({captures:t.captures,state:t}),c=await E.imageBitmap({blob:e});try{let[e]=await Y(c,{forMatch:!0});i?.throwIfAborted();let n=e?E.prepareFace({alignment:r.alignment,face:e,frame:c}):null,a=n?await E.preparedFaceArtifacts({face:n}):null;i?.throwIfAborted(),a&&(t.preparedCaptures.picture=a.images)}finally{c.close()}let l=t.session;n.activity.value=`matching`;let u={...await E.matchPictureWithFaces({options:r,picture:e,references:s.faces,referenceFaceEmbeddings:s.embeddings}),threshold:r.threshold};if(i?.throwIfAborted(),t.session!==l)throw $();return{matched:u.matched,score:u.score,reason:u.matched?null:m.FACE_MISMATCH,threshold:u.threshold,...f({state:t})}},submitHardVerification:H,submitFastVerification:U,initializeModels:Q,showError:({error:e,state:t})=>{v({error:e})!==m.VERIFICATION_CANCELLED&&x({state:t}),h(()=>{n.activity.value=null,v({error:e})===m.VERIFICATION_CANCELLED?n.retry.value=null:n.error.value=e})}}},Q={...y,faceDetector:`standard`,apiUrl:`https://api.voltom.io`,language:void 0,clientKey:``,mode:`fast`,threshold:d,posesCount:5,randomizeFaceSequence:!1,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showDocumentOverlay:!0,showFaceOverlay:!0,showTextOverlay:!0,faceOverlayColor:`transparent`,faceMeshColor:`#22c55e`,documentOverlayColor:`transparent`,documentBoxColor:`#38bdf8`,documentFaceBoxColor:`#38bdf8`,documentFaceMeshColor:`#22c55e`,textColor:`#38bdf8`,debug:!1,capabilities:[`verifyHuman`,`verifyDocument`,`matchID`,`matchPicture`]},$=class{options;view;root;useUi;videoElement;resizeListener;display=P();translator;flows;state;lastPicture;preparation=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.root.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){let{root:t,video:n,ui:r,...i}=e,a=r??!!t;if(a&&!t||!a&&!n)throw Error(m.INVALID_OPTIONS);if(!i.clientKey)throw Error(m.CLIENT_KEY_REQUIRED);if(this.options=Object.freeze({...Q,...i,capabilities:Object.freeze([...i.capabilities??Q.capabilities]),poses:Array.isArray(i.poses)?Object.freeze([...i.poses]):i.poses}),this.root=t??document.createElement(`div`),this.useUi=a,this.videoElement=n??document.createElement(`video`),this.translator=u({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{}},this.flows=Z({options:this.options,view:this.view,display:this.display}),this.lastPicture=null,i.mode!==void 0&&i.mode!==`fast`&&i.mode!==`hard`)throw Error(m.INVALID_OPTIONS);this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener)}async prepare(){if(this.disposed)throw Error(m.SDK_NOT_READY);if(this.preparation)return this.preparation;let t=new AbortController;this.preparationController=t;let n=(async()=>{await e({language:this.options.language}),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await q({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:t.signal}),await J({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),t.signal.throwIfAborted(),this.disposed)throw Error(m.SDK_NOT_READY)},message:this.translator.translate(`preparingModels`)})})();this.preparation=n;try{await n,this.prepared=!0,this.preparationController===t&&(this.preparationController=null)}catch(e){throw this.preparation===n&&(this.preparation=null),this.preparationController===t&&(this.preparationController=null),e}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await import(`./view-usv6rHIE.js`);if(this.disposed)throw Error(m.SDK_NOT_READY);let t=e({root:this.root,options:this.options,display:this.display});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitHardVerification(e){let t=e.endpoint===`/verification/document/hard`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitHardVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async submitFastVerification(e){return await this.runWithSpinner({task:()=>this.flows.submitFastVerification({...e,signal:e.signal??this.operationController?.signal})})}async caniuse(){return await n()}async runOperation({retry:e,task:t,onError:n,capability:r,settings:i}){if(this.disposed||!this.prepared)throw Error(m.SDK_NOT_READY);if(!this.options.capabilities.includes(r))throw Error(m.SDK_CAPABILITY_NOT_CONFIGURED);if(this.operationController)throw Error(m.INVALID_OPTIONS);let{signal:a,...o}=i,s=Object.freeze({...this.options,...o,poses:Array.isArray(o.poses)?Object.freeze([...o.poses]):o.poses??this.options.poses}),c=new AbortController;this.operationController=c;let l=()=>c.abort();a?.addEventListener(`abort`,l,{once:!0}),a?.aborted&&l(),c.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),h(()=>{this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=s.debug,s.debug||(this.display.debug.value=[])});try{return c.signal.throwIfAborted(),await t({options:s,signal:c.signal})}catch(e){let t=c.signal.aborted?Error(m.VERIFICATION_CANCELLED,{cause:e}):e;throw n&&await n({error:t,options:s,signal:c.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.notifyStatus({status:`ready`}),a?.removeEventListener(`abort`,l),this.display.debugEnabled.value=this.options.debug,this.operationController===c&&(this.operationController=null)}}async verifyHuman(e={}){return await this.verifyCapture({flow:`human`,...e})}async verifyDocument(e={}){return await this.verifyCapture({flow:`document`,...e})}async verifyCapture({flow:e,...t}){let n=new Date,r=performance.now(),i=({options:t})=>{e===`human`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})};return await this.runOperation({capability:e===`human`?`verifyHuman`:`verifyDocument`,settings:t,retry:()=>this.verifyCapture({flow:e,...t,signal:void 0}),onError:async({error:t,options:n})=>{(e===`human`?this.state.faceCaptureConfiguration!==null:this.state.documentCaptureConfiguration!==null)&&v({error:t})!==m.VERIFICATION_CANCELLED&&i({options:n})},task:async({options:t,signal:a})=>{if(a.throwIfAborted(),await(e===`human`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),a.throwIfAborted(),t.mode===`hard`){let n=await this.submitHardVerification({configuration:t,endpoint:`/verification/${e}/hard`,state:this.state}),r=e===`human`?`hardHumanVerificationId`:`hardDocumentVerificationId`;return this.state[r]=n.verificationId,n.outcome!==`completed`||n.matched!==!0?(this.state[r]=null,i({options:t}),n):(this.display.retry.value=null,n)}let o=await this.recordFastVerification({flow:e,startedAt:n,performanceStartedAt:r,outcome:`completed`,result:{matched:!0,score:null,threshold:t.threshold},codes:e===`document`?this.state.documentCodes:[]});return this.display.retry.value=null,o}})}async ensureHumanVerification({options:e,signal:t}){if(t?.throwIfAborted(),this.flows.hasCompatibleFaceCaptures({state:this.state,options:e})||await this.flows.startFaceFlow({state:this.state,options:e}),t?.throwIfAborted(),this.state.hardHumanVerificationId)return null;let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/human/hard`,state:this.state}),r=n.outcome===`completed`&&n.matched===!0;return this.state.hardHumanVerificationId=r?n.verificationId:null,r?null:n}async recordFastVerification({performanceStartedAt:e,...t}){return await this.submitFastVerification({...t,executionMs:Math.round(performance.now()-e),captures:this.state.captures,preparedCaptures:this.state.preparedCaptures,signal:t.signal??this.operationController?.signal})}shouldRecordFailure({submissionStarted:e,options:t,error:n,signal:r}){let i=v({error:n});return!e&&!r?.aborted&&t.mode!==`hard`&&i!==m.VERIFICATION_CANCELLED&&i!==m.VERIFICATION_SAVE_FAILED}async matchID(e={}){let t=new Date,n=performance.now(),r=!1;return await this.runOperation({capability:`matchID`,settings:e,retry:()=>this.matchID({...e,signal:void 0}),task:async({options:e,signal:i})=>{if(i.throwIfAborted(),e.mode===`hard`){let t=await this.ensureHumanVerification({options:e,signal:i});if(t)return t;if(i.throwIfAborted(),this.flows.hasCompatibleDocumentCapture({state:this.state,options:e})||await this.flows.startDocumentFlow({state:this.state,options:e}),!this.state.hardDocumentVerificationId){i.throwIfAborted();let t=await this.submitHardVerification({configuration:e,endpoint:`/verification/document/hard`,state:this.state});if(this.state.hardDocumentVerificationId=t.verificationId,t.outcome!==`completed`||t.matched!==!0)return this.state.hardDocumentVerificationId=null,t}let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/id/hard`,state:this.state,sourceIds:[this.state.hardHumanVerificationId,this.state.hardDocumentVerificationId]});return n.outcome!==`completed`||n.matched!==!0||(this.display.retry.value=null),n}this.display.error.value=null;let a=await this.flows.startFlow({state:this.state,options:e,signal:i});i.throwIfAborted(),r=!0;let o=await this.recordFastVerification({flow:`match_id`,startedAt:t,performanceStartedAt:n,outcome:`completed`,result:a,codes:this.state.documentCodes});return this.display.retry.value=null,o},onError:async({error:e,options:i,signal:a})=>{if(this.shouldRecordFailure({submissionStarted:r,options:i,error:e,signal:a})){let r=await this.recordFastVerification({flow:`match_id`,startedAt:t,performanceStartedAt:n,outcome:`failed`,error:e,codes:this.state.documentCodes});e instanceof Error&&Object.assign(e,{verificationId:r.verificationId})}}})}async matchPicture(e,t={}){let n=new Date,r=performance.now(),i=!1,a;return this.lastPicture=e,await this.runOperation({capability:`matchPicture`,settings:t,retry:async()=>{this.lastPicture&&await this.matchPicture(this.lastPicture,{...t,signal:void 0})},task:async({options:t,signal:o})=>{if(o.throwIfAborted(),a=await s({blob:e}),o.throwIfAborted(),t.mode===`hard`&&!this.state.hardHumanVerificationId){let e=await this.ensureHumanVerification({options:t,signal:o});if(e)return e}let c=await this.flows.startPictureFlow({picture:a,state:this.state,options:t,signal:o});o.throwIfAborted();let l;if(t.mode===`hard`){if(l=await this.submitHardVerification({configuration:t,endpoint:`/verification/picture/hard`,state:this.state,picture:a,sourceIds:[this.state.hardHumanVerificationId]}),l.outcome!==`completed`||l.matched!==!0)return l}else i=!0,l=await this.recordFastVerification({flow:`match_picture`,startedAt:n,performanceStartedAt:r,outcome:`completed`,result:c,codes:[],picture:a});return this.display.retry.value=null,l},onError:async({error:e,options:t,signal:o})=>{this.shouldRecordFailure({submissionStarted:i,options:t,error:e,signal:o})&&await this.recordFastVerification({flow:`match_picture`,startedAt:n,performanceStartedAt:r,outcome:`failed`,error:e,codes:[],picture:a})}})}stop(){this.operationController?.abort(new DOMException(m.VERIFICATION_CANCELLED,`AbortError`)),this.flows.stop({state:this.state}),this.display.retry.value=null,this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),f(null,this.root),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.hardHumanVerificationId=null,this.state.hardDocumentVerificationId=null,this.state.faceCaptureConfiguration=null,this.state.documentCaptureConfiguration=null,delete this.state.document,this.lastPicture=null}}forgetHuman(){if(this.disposed)throw Error(m.SDK_NOT_READY);this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw Error(m.SDK_NOT_READY);this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(e){if(this.disposed)throw Error(m.SDK_NOT_READY);let t=_(()=>e(this.getState()));return this.subscriptions.add(t),()=>{t(),this.subscriptions.delete(t)}}};p({moduleUrl:import.meta.url});var le=$;export{le as default};
|
|
2
|
+
import{$ as e,E as t,M as n,Q as r,U as i,h as a,n as o,q as s,r as c}from"./poseGuidance-DLg3Dm3T.js";import{D as l,E as u,a as d,b as f,c as p,d as m,f as h,h as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./media-KU3CWepq.js";import{_ as D,a as O,b as k,d as A,f as ee,g as te,h as j,i as ne,l as M,m as N,n as re,o as ie,p as P,t as F,u as ae,v as I,x as L,y as oe}from"./presentation-D9v4ITH0.js";var{analyzeDocumentFrame:R,hasValidDocumentSideData:z,validateDocumentBack:B}=j,se=({view:e,display:t,isActive:n,notifyCapturesChanged:r,getVerifyHardOptions:i})=>{let a=e.ref,o=async()=>{t.success.value=!0,await S({milliseconds:400}),t.success.value=!1},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=!!l.captures.documentFront,p=u.requiredDocumentStableFrames,m=null,h=null;try{m=await R({frame:s,prepareForMatch:f||l.documentStableFrames+1>=u.requiredDocumentStableFrames,options:{...i({configuration:u}),alignment:l.matchOptions.alignment,requiresFace:!f}});let{orientation:e,detection:d,face:g}=m;if(!n({flow:`document`,session:c,state:l}))return!1;let v=f?B({current:m,front:l.documentFrontSignature}):null;h=f?k({front:l.documentFrontSignature,current:m.signature}):null;let y=l.document?{...l.document,ocr:l.document.document_front}:void 0,x=z({analysis:m,isBack:f,front:y}),S=(f?v?.valid===!0:m.valid)&&x,C=e?e.rotation:null;C!==l.documentOrientation&&(l.documentStableFrames=0),l.documentOrientation=C,l.documentStableFrames=S?l.documentStableFrames+1:0,u.showDocumentOverlay?await M({documentFaceBoxColor:u.documentFaceBoxColor,documentFaceMeshColor:u.documentFaceMeshColor,documentBoxColor:u.documentBoxColor,element:a.mesh,detection:d,face:g,height:s.height,ocrLines:u.showTextOverlay?m.text.lines:[],ocrToSource:u.showTextOverlay?m.documentToSource:null,overlayColor:u.documentOverlayColor,textColor:u.textColor,width:s.width}):b({element:a.mesh});let w=U({analysis:m,dataValid:x,isBack:f,minFaceAreaRatio:u.minDocumentFaceAreaRatio,rejectionReasons:v?v.reasons:m.failureReasons,valid:S,stable:l.documentStableFrames>=p});if(t.feedback.value={flow:`document`,...w},l.documentStableFrames<p)return!1;let T=await _({frame:s});return n({flow:`document`,session:c,state:l})?f?(V({analysis:m,isBack:!0,state:l}),l.captures.documentBack=T,r({state:l}),await o(),!0):!m.embeddings||!m.images?!1:(V({analysis:m,isBack:!1,state:l}),l.documentFaceEmbeddings=m.embeddings,l.documentFrontSignature=m.signature,l.preparedCaptures.documentFront=m.images,l.captures.documentFront=T,r({state:l}),await o(),!0):!1}finally{m&&n({flow:`document`,session:c,state:l})&&e.collectDocumentDebug({analysis:m,sideComparison:h,isBack:f,processingTimeMilliseconds:performance.now()-d,state:l})}};return{runDocumentLoop:async({session:e,state:r,options:i})=>{for(;n({flow:`document`,session:e,state:r});){if(await v({video:a.video}),!n({flow:`document`,session:e,state:r}))return;let o=await createImageBitmap(a.video);try{let n=await p({frame:o});try{if(await s({frame:n,session:e,state:r,options:i})){r.flow=null,t.debug.value=[];return}}finally{n.close()}}finally{o.close()}}}}},V=({analysis:e,isBack:t,state:r})=>{if(!e.ocr)throw Error(y.CAPTURES_INCOMPLETE);let i={ocr:e.ocr,codes:e.codes};if(t){if(!r.document)throw Error(y.CAPTURES_INCOMPLETE);let t=n({classification:r.document,front:{ocr:r.document.document_front,codes:r.document.codes},back:i});r.document={...r.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw Error(y.DOCUMENT_NOT_RECOGNIZED);let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},a=n({classification:t,front:i});r.identity=e.identity,r.document={...t,...a,document_front:e.ocr,document_back:null}}r.documentCodes=r.document.codes},H=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,U=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:H({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(y.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(y.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},W=`https://api.voltom.io`,G=({apiUrl:e})=>{let t=e??W;return t.endsWith(`/`)?t.slice(0,-1):t},K=async({apiUrl:e,path:t,method:n=`POST`,body:r,clientKey:i,fallback:a=y.INVALID_SERVICE_RESPONSE,signal:o})=>{let s={};i&&(s.authorization=`Bearer ${i}`),r&&(s[`content-type`]=`application/json`);let c;try{c=await fetch(`${G({apiUrl:e})}${t}`,{method:n,headers:s,body:r,signal:o})}catch(e){throw o?.aborted?Error(y.VERIFICATION_CANCELLED,{cause:e}):Error(y.NETWORK_ERROR,{cause:e})}if(c.status===413)throw Error(y.REQUEST_TOO_LARGE);let l;try{l=await c.json()}catch(e){throw Error(c.status>=500?y.SERVICE_UNAVAILABLE:a,{cause:e})}if(!c.ok){let e=typeof l==`object`&&l&&`code`in l&&typeof l.code==`string`?l.code:c.status>=500?y.SERVICE_UNAVAILABLE:a;throw Error(e)}return l},q=async({clientKey:e,apiUrl:t,signal:n})=>{await K({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,fallback:y.INVALID_CLIENT_KEY,signal:n})},J=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${G({apiUrl:e})}/script-loads`)}catch{return}},ce=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:i,faces:a=[],options:o,picture:s,poses:c=[],sourceIds:l=[],threshold:u,signal:f})=>{if(!e)throw Error(y.CLIENT_KEY_REQUIRED);let p=JSON.stringify({documentFront:i?await d({image:i}):void 0,documentBack:r?await d({image:r}):void 0,picture:s?await d({image:s}):void 0,faces:await Promise.all(a.map(e=>d({image:e}))),options:o,poses:c.map(e=>A[e]),source_ids:l,threshold:u});return f?.throwIfAborted(),await K({apiUrl:t,path:n,body:p,clientKey:e,signal:f})},{loadDocumentBoxDetector:le,detectDocumentOrientation:ue}=P,{detectPictureFaces:Y,loadFaceDetector:de}=N,{loadFaceMatch:fe,warmupFaceMatch:pe}=D,{loadTextDetector:X}=I,Z=({options:e,view:n,display:a})=>{let l=n.ref,u=[...ee],d=({language:e})=>e??m(),f=()=>({identity:null,flow:null,session:0,faceSequence:[...u],faceCaptureConfiguration:null,documentCaptureConfiguration:null,poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,neutralPose:null,guidanceCodeState:c(),correctiveState:o(),faceMatchOptions:null,hardHumanVerificationId:null,hardDocumentVerificationId:null,cameraActive:!1,cameraSize:a.cameraSize,cameraFacingMode:a.cameraFacingMode}),p=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,l.root.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},h=({state:e})=>{w({video:l.video}),p({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,a.feedback.value=null,a.guidance.value=null,a.corrective.value=null,a.success.value=!1},_=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),v=({state:e})=>{let t=_({state:e});l.root.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},S=({state:t,options:n=e})=>{t.faceSequence=N({options:n}),t.poseIndex=0,t.poseStableFrames=0;let r=t.preparedCaptures.documentFront;t.preparedCaptures=r?{documentFront:r}:{},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.neutralPose=null,t.guidanceCodeState=c(),t.correctiveState=o(),a.corrective.value=null,t.faceMatchOptions=null,t.hardHumanVerificationId=null,t.faceCaptureConfiguration=null;let{documentFront:i,documentBack:s}=t.captures;t.captures={...i?{documentFront:i}:{},...s?{documentBack:s}:{}}},C=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.hardDocumentVerificationId=null,e.documentCaptureConfiguration=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},T=({state:e})=>{e.session+=1,e.flow=null,h({state:e}),b({element:l.mesh}),a.debug.value=[]},E=({state:e})=>{T({state:e}),v({state:e}),a.error.value=null},k=({state:e})=>{let t=l.video.videoWidth,n=l.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},A=async({facingMode:e,state:t})=>{h({state:t});let n=t.session,r=await x({facingMode:e,video:l.video});if(t.session!==n)throw w({video:l.video}),Z();t.cameraFacingMode.value=r,k({state:t}),p({active:!0,state:t})},j=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,M=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,N=({options:e})=>ie({poses:e.poses,randomize:e.randomizeFaceSequence??!1}),F=({options:e})=>JSON.stringify({poses:e.poses,randomizeFaceSequence:e.randomizeFaceSequence,faceDetector:e.faceDetector,alignment:e.alignment,threshold:e.threshold,language:e.language,maxPitch:e.maxPitch,minPitch:e.minPitch,maxYaw:e.maxYaw,minYaw:e.minYaw,maxRoll:e.maxRoll,requiredFaceStableFrames:e.requiredFaceStableFrames}),I=({options:e})=>JSON.stringify({ocrEngine:e.ocrEngine,language:e.language,minDocumentFaceAreaRatio:e.minDocumentFaceAreaRatio,maxDocumentFaceAreaRatio:e.maxDocumentFaceAreaRatio,minDocumentFaceWidthRatio:e.minDocumentFaceWidthRatio,maxDocumentFaceWidthRatio:e.maxDocumentFaceWidthRatio,minDocumentFaceHeightRatio:e.minDocumentFaceHeightRatio,maxDocumentFaceHeightRatio:e.maxDocumentFaceHeightRatio,minDocumentBoxRatio:e.minDocumentBoxRatio,maxDocumentTextAngleDifference:e.maxDocumentTextAngleDifference,requiredDocumentStableFrames:e.requiredDocumentStableFrames}),R=({state:e,options:t})=>e.faceCaptureConfiguration===F({options:t})&&O({captures:e.captures,state:e}),z=({state:e,options:t})=>{let n=e.document,r=n!==void 0&&n.document!==`passport`,i=!(!e.captures.documentFront||r&&!e.captures.documentBack),a=e.documentCaptureConfiguration===I({options:t});return!!(n?.valid&&i&&a)},B=({configuration:e})=>{let n=Object.fromEntries(Object.keys(t).map(t=>[t,e[t]]));return n.language=d({language:e.language}),n},V=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=O({captures:n.captures,state:n})?ne({captures:n.captures,state:n}):null;return await ce({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:B({configuration:e}),picture:r,poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},H={options:e,view:n,display:a,isActive:j,notifyCapturesChanged:v,getVerifyHardOptions:B},{runFaceLoop:U}=re(H),{runDocumentLoop:W}=se(H),G=async({state:e,options:t})=>{T({state:e}),S({state:e,options:t}),a.progress.value={completed:0,total:e.faceSequence.length},e.faceCaptureConfiguration=F({options:t}),e.matchOptions={alignment:t.alignment,threshold:t.threshold},e.faceMatchOptions={...e.matchOptions},v({state:e});let n=e.session;e.flow=`face`;try{if(a.feedback.value={flow:`face`,pose:M({state:e}),code:null},await A({facingMode:`user`,state:e}),a.feedback.value={flow:`face`,pose:M({state:e}),code:null},await U({session:n,state:e,options:t}),e.session!==n)throw Z();if(!O({captures:e.captures,state:e}))throw Error(y.CAPTURES_INCOMPLETE);let r={...e.captures};return h({state:e}),b({element:l.mesh}),r}finally{e.session===n&&(a.feedback.value=null)}},K=async({state:t,options:n=e})=>{T({state:t}),C({state:t}),t.documentCaptureConfiguration=I({options:n}),t.matchOptions={alignment:n.alignment,threshold:n.threshold},v({state:t});let r=t.session;t.flow=`document`;try{if(!j({flow:`document`,session:r,state:t})||(await A({facingMode:`environment`,state:t}),a.feedback.value={flow:`document`,code:null,target:`front`},await W({session:r,state:t,options:n}),t.session!==r))throw Z();if(!t.captures.documentFront||!t.document)throw Error(y.CAPTURES_INCOMPLETE);if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,a.feedback.value={flow:`document`,code:null,target:`back`},await W({session:r,state:t,options:n}),t.session!==r))throw Z();if(!t.document.valid)throw Error(y.DOCUMENT_VALIDATION_FAILED);let e={...t.captures};return h({state:t}),b({element:l.mesh}),e}finally{t.session===r&&(a.feedback.value=null,b({element:l.mesh}))}},q=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[le(),de({faceDetector:e.faceDetector}),fe(),...t?[te(),X({engine:`tiny`,language:`latin`}),X({engine:e.ocrEngine,language:d({language:e.language})}),oe()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[ae()]:[]];await Promise.all(n);let r=document.createElement(`canvas`);r.width=640,r.height=480;let i=await createImageBitmap(r);try{let e=[Y(i),P.detectDocumentBox(i),pe()];t&&e.push(ue({frame:i,boundingRect:{x:0,y:0,width:i.width,height:i.height}})),await Promise.all(e)}finally{i.close()}},J=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[`dd.ort`,i[e.faceDetector],`fl.ort`,`fe.ort`,`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`,...t?[`do.ort`,`zxing-wasm/reader/index.js`,`zxing-wasm/share.js`,`zxing-wasm/reader/zxing_reader.wasm`]:[],...e.showFaceOverlay||e.showDocumentOverlay?[`faceMeshLines.json`]:[]],r=[s({filenames:n})];t&&(r.push(s({filenames:L({language:`latin`,engine:`tiny`})})),r.push(s({filenames:L({language:d({language:e.language}),engine:e.ocrEngine})}))),await Promise.all(r)},Z=()=>new DOMException(y.VERIFICATION_CANCELLED,`AbortError`);return{createState:f,stop:E,syncCameraSize:k,captureResult:_,resetFaceFlow:S,resetDocumentFlow:C,hasCompatibleFaceCaptures:R,hasCompatibleDocumentCapture:z,notifyCapturesChanged:v,startFaceFlow:G,startDocumentFlow:K,startPictureFlow:async({picture:e,state:t,options:n,signal:r})=>{a.error.value=null,r?.throwIfAborted();let i=await D.imageBitmap({blob:e});try{let e=await Y(i,{forMatch:!0});if(r?.throwIfAborted(),!e.length)throw Error(y.NO_USABLE_CANDIDATES)}finally{i.close()}let o=t.faceCaptureConfiguration===F({options:n});R({state:t,options:n})&&o||await G({state:t,options:n}),r?.throwIfAborted();let s=await D.imageBitmap({blob:e});try{let[e]=await Y(s,{forMatch:!0});r?.throwIfAborted();let i=e?D.prepareFace({alignment:n.alignment,face:e,frame:s}):null,a=i?await D.preparedFaceArtifacts({face:i}):null;r?.throwIfAborted(),a&&(t.preparedCaptures.picture=a.images)}finally{s.close()}v({state:t})},submitHardVerification:V,initializeModels:q,preloadModels:J,showError:({error:e,state:t})=>{g({error:e})!==y.VERIFICATION_CANCELLED&&T({state:t}),r(()=>{a.activity.value=null,g({error:e})===y.VERIFICATION_CANCELLED?a.retry.value=null:a.error.value=e})}}},Q,me=async()=>{try{Q??=import(l({filename:`pdf/pdf.mjs`}));let e=await Q;return e.GlobalWorkerOptions.workerSrc=l({filename:`pdf/pdf.worker.mjs`}),e}catch{throw Q=void 0,Error(y.PDF_LOAD_FAILED)}},he=async({blob:e,signal:t})=>{if(new TextDecoder().decode(await e.slice(0,5).arrayBuffer())!==`%PDF-`)return null;if(e.size>1e7)throw Error(y.REQUEST_TOO_LARGE);t.throwIfAborted();let n=await me();t.throwIfAborted();let r=new Uint8Array(await e.arrayBuffer()),i=n.getDocument({data:r,cMapUrl:l({filename:`pdf/cmaps/`}),cMapPacked:!0,standardFontDataUrl:l({filename:`pdf/standard_fonts/`}),wasmUrl:l({filename:`pdf/wasm/`})}),a=()=>{i.destroy()};t.addEventListener(`abort`,a,{once:!0});let o;try{let e=await i.promise;t.throwIfAborted();let n=await e.getPage(1),r=n.getViewport({scale:1}),a=n.getViewport({scale:Math.min(1,1200/Math.max(r.width,r.height))}),s=window.document.createElement(`canvas`);s.width=Math.ceil(a.width),s.height=Math.ceil(a.height),await n.render({canvas:s,viewport:a,background:`white`}).promise,t.throwIfAborted(),o=await createImageBitmap(s),s.width=0,s.height=0;let c=await N.detectPictureFaces(o,{forMatch:!0});t.throwIfAborted();let l=c[0];if(!l)throw Error(y.NO_USABLE_CANDIDATES);let u=l.boundingRect,d=Math.max(0,Math.floor(u.x-u.width*.25)),f=Math.max(0,Math.floor(u.y-u.height*.25)),p=Math.min(o.width-d,Math.ceil(u.width*1.5)),m=Math.min(o.height-f,Math.ceil(u.height*1.5)),h=new OffscreenCanvas(p,m),g=h.getContext(`2d`);if(!g)throw Error(y.IMAGE_PROCESSING_FAILED);g.drawImage(o,d,f,p,m,0,0,p,m);let _=await h.convertToBlob({type:`image/jpeg`,quality:.95});return t.throwIfAborted(),_}catch(e){throw t.throwIfAborted(),e instanceof Error&&Object.values(y).includes(e.message)?e:e instanceof Error&&e.name===`PasswordException`?Error(y.PDF_PASSWORD_REQUIRED):Error(y.INVALID_PDF)}finally{t.removeEventListener(`abort`,a),o?.close(),await i.destroy()}},$={...t,faceDetector:`standard`,apiUrl:`https://api.voltom.io`,language:void 0,clientKey:``,threshold:a,randomizeFaceSequence:!1,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showFaceOverlay:!1,showDocumentOverlay:!1,showTextOverlay:!1,faceOverlayColor:`transparent`,faceMeshColor:`#38efb0`,documentOverlayColor:`transparent`,documentBoxColor:`#22d3ee`,documentFaceBoxColor:`#22d3ee`,documentFaceMeshColor:`#38efb0`,textColor:`#22d3ee`,debug:!1,capabilities:[`verifyHuman`,`verifyDocument`,`matchID`,`matchPicture`]},ge=class{options;view;root;useUi;videoElement;resizeListener;display=F();translator;flows;state;lastPicture;preparation=null;preloading=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.root.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){let{root:t,video:n,ui:r,...i}=e,a=r??!!t;if(a&&!t||!a&&!n)throw Error(y.INVALID_OPTIONS);if(!i.clientKey)throw Error(y.CLIENT_KEY_REQUIRED);this.options=Object.freeze({...$,...i,capabilities:Object.freeze([...i.capabilities??$.capabilities]),poses:Array.isArray(i.poses)?Object.freeze([...i.poses]):i.poses}),this.root=t??document.createElement(`div`),this.useUi=a,this.videoElement=n??document.createElement(`video`),this.translator=E({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{}},this.flows=Z({options:this.options,view:this.view,display:this.display}),this.lastPicture=null,this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener)}async preload(){if(this.disposed)throw Error(y.SDK_NOT_READY);if(this.preloading)return this.preloading;let e=(async()=>{await h({language:this.options.language}),await this.flows.preloadModels()})();this.preloading=e;try{if(await e,this.disposed)throw Error(y.SDK_NOT_READY)}catch(t){throw this.preloading===e&&(this.preloading=null),t}}async prepare(){if(this.disposed)throw Error(y.SDK_NOT_READY);if(this.preparation)return this.preparation;let e=new AbortController;this.preparationController=e;let t=(async()=>{await this.preload(),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await q({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:e.signal}),await J({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),e.signal.throwIfAborted(),this.disposed)throw Error(y.SDK_NOT_READY)},message:this.translator.translate(`preparingModels`)})})();this.preparation=t;try{await t,this.prepared=!0,this.preparationController===e&&(this.preparationController=null)}catch(n){throw this.preparation===t&&(this.preparation=null),this.preparationController===e&&(this.preparationController=null),n}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await import(`./view-CsOmx3ht.js`);if(this.disposed)throw Error(y.SDK_NOT_READY);let t=e({root:this.root,options:this.options,display:this.display});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitHardVerification(e){let t=e.endpoint===`/verification/document`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitHardVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async caniuse(){return await T()}async runOperation({retry:e,task:t,onError:n,capability:i,settings:a}){if(this.disposed||!this.prepared)throw Error(y.SDK_NOT_READY);if(!this.options.capabilities.includes(i))throw Error(y.SDK_CAPABILITY_NOT_CONFIGURED);if(this.operationController)throw Error(y.INVALID_OPTIONS);let{signal:o,...s}=a,c=Object.freeze({...this.options,...s,poses:Array.isArray(s.poses)?Object.freeze([...s.poses]):s.poses??this.options.poses}),l=new AbortController;this.operationController=l;let u=()=>l.abort();o?.addEventListener(`abort`,u,{once:!0}),o?.aborted&&u(),l.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),r(()=>{this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=c.debug,c.debug||(this.display.debug.value=[])});try{return l.signal.throwIfAborted(),await t({options:c,signal:l.signal})}catch(e){let t=l.signal.aborted?Error(y.VERIFICATION_CANCELLED,{cause:e}):e;throw n&&await n({error:t,options:c,signal:l.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.notifyStatus({status:`ready`}),o?.removeEventListener(`abort`,u),this.display.debugEnabled.value=this.options.debug,this.operationController===l&&(this.operationController=null)}}async verifyHuman(e={}){return await this.verifyCapture({flow:`human`,...e})}async verifyDocument(e={}){return await this.verifyCapture({flow:`document`,...e})}async verifyCapture({flow:e,...t}){let n=({options:t})=>{e===`human`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})};return await this.runOperation({capability:e===`human`?`verifyHuman`:`verifyDocument`,settings:t,retry:()=>this.verifyCapture({flow:e,...t,signal:void 0}),onError:async({error:t,options:r})=>{(e===`human`?this.state.faceCaptureConfiguration!==null:this.state.documentCaptureConfiguration!==null)&&g({error:t})!==y.VERIFICATION_CANCELLED&&n({options:r})},task:async({options:t,signal:r})=>{r.throwIfAborted(),await(e===`human`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),r.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verification/${e}`,state:this.state}),a=e===`human`?`hardHumanVerificationId`:`hardDocumentVerificationId`;return this.state[a]=i.verificationId,i.outcome!==`pass`||i.matched!==!0?(this.state[a]=null,n({options:t}),i):(this.display.retry.value=null,i)}})}async ensureHumanVerification({options:e,signal:t}){if(t?.throwIfAborted(),this.flows.hasCompatibleFaceCaptures({state:this.state,options:e})||await this.flows.startFaceFlow({state:this.state,options:e}),t?.throwIfAborted(),this.state.hardHumanVerificationId)return null;let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/human`,state:this.state}),r=n.outcome===`pass`&&n.matched===!0;return this.state.hardHumanVerificationId=r?n.verificationId:null,r?null:n}async matchID(e={}){return await this.runOperation({capability:`matchID`,settings:e,retry:()=>this.matchID({...e,signal:void 0}),task:async({options:e,signal:t})=>{t.throwIfAborted();let n=await this.ensureHumanVerification({options:e,signal:t});if(n)return n;if(t.throwIfAborted(),this.flows.hasCompatibleDocumentCapture({state:this.state,options:e})||await this.flows.startDocumentFlow({state:this.state,options:e}),!this.state.hardDocumentVerificationId){t.throwIfAborted();let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/document`,state:this.state});if(this.state.hardDocumentVerificationId=n.verificationId,n.outcome!==`pass`||n.matched!==!0)return this.state.hardDocumentVerificationId=null,n}let r=await this.submitHardVerification({configuration:e,endpoint:`/verification/id`,state:this.state,sourceIds:[this.state.hardHumanVerificationId,this.state.hardDocumentVerificationId]});return r.outcome!==`pass`||r.matched!==!0||(this.display.retry.value=null),r}})}async matchPicture(e,t={}){return this.lastPicture=e,await this.runOperation({capability:`matchPicture`,settings:t,retry:async()=>{this.lastPicture&&await this.matchPicture(this.lastPicture,{...t,signal:void 0})},task:async({options:t,signal:n})=>{n.throwIfAborted();let r=await he({blob:e,signal:n})??await C({blob:e});if(n.throwIfAborted(),!this.state.hardHumanVerificationId){let e=await this.ensureHumanVerification({options:t,signal:n});if(e)return e}await this.flows.startPictureFlow({picture:r,state:this.state,options:t,signal:n}),n.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verification/picture`,state:this.state,picture:r,sourceIds:[this.state.hardHumanVerificationId]});return i.outcome!==`pass`||i.matched!==!0||(this.display.retry.value=null),i}})}stop(){this.operationController?.abort(new DOMException(y.VERIFICATION_CANCELLED,`AbortError`)),this.flows.stop({state:this.state}),this.display.retry.value=null,this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),f(null,this.root),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.hardHumanVerificationId=null,this.state.hardDocumentVerificationId=null,this.state.faceCaptureConfiguration=null,this.state.documentCaptureConfiguration=null,delete this.state.document,this.lastPicture=null}}forgetHuman(){if(this.disposed)throw Error(y.SDK_NOT_READY);this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw Error(y.SDK_NOT_READY);this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(t){if(this.disposed)throw Error(y.SDK_NOT_READY);let n=e(()=>t(this.getState()));return this.subscriptions.add(n),()=>{n(),this.subscriptions.delete(n)}}};u({moduleUrl:import.meta.url});var _e=ge;export{_e as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
+
import{V as e,o as t}from"./poseGuidance-DLg3Dm3T.js";import{_ as n,b as r,d as i,m as a,u as o,x as s,y as c}from"./media-KU3CWepq.js";import{c as l,r as u,s as d}from"./presentation-D9v4ITH0.js";import{n as f,r as p,t as m}from"./PoseSuccess-CxL2ugaZ.js";import{n as h,t as g}from"./PoseSilhouette-CTZ5kqI_.js";var _=`/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
3
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-border-style:solid;--tw-leading:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-font-weight:initial}}}[data-voltom-demo],[data-voltom-root],[data-facekey-root]{--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}[data-voltom-demo]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){[data-voltom-demo]{--lightningcss-light: ;--lightningcss-dark:initial}}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:4px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:4px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}@layer components{[data-voltom-root]{width:100%;min-height:0;max-width:var(--container-5xl,64rem);padding-block:env(safe-area-inset-top);color:var(--theme-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;flex-direction:column;gap:.75rem;margin-inline:auto;display:flex;position:relative;overflow:visible}[data-voltom-camera]{background-color:var(--theme-surface);width:100%;aspect-ratio:var(--voltom-camera-ratio,4 / 3);flex-shrink:0;margin-inline:auto;position:relative;overflow:hidden;container-type:size}[data-voltom-camera]>video,[data-voltom-mesh],[data-voltom-overlay]{object-fit:contain;width:100%;height:100%;position:absolute;inset:0}[data-voltom-mesh],[data-voltom-overlay]{object-fit:fill}[data-voltom-mesh]{color:var(--theme-canvas)}[data-voltom-mesh],[data-voltom-overlay],[data-voltom-guide],[data-voltom-ring],[data-voltom-direction],[data-voltom-challenge],[data-voltom-result],[data-voltom-spinner],[data-voltom-feedback]{pointer-events:none}[data-voltom-feedback]{z-index:10;text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:.75rem;padding-inline:1rem;display:flex;position:absolute;inset:0}[data-voltom-camera][data-mirrored]>video,[data-voltom-camera][data-mirrored] [data-voltom-mesh]{--tw-scale-x:calc(100% * -1);scale:var(--tw-scale-x) var(--tw-scale-y)}[data-voltom-guide-mode=document]{border-style:var(--tw-border-style);--tw-border-style:dashed;border-style:dashed;border-width:2px;border-color:var(--theme-border);height:90cqh;margin:auto;display:block;position:absolute;inset:0}[data-voltom-guide-mode=document][data-voltom-guide-orientation=landscape]{aspect-ratio:4/3}[data-voltom-guide-mode=document][data-voltom-guide-orientation=portrait]{aspect-ratio:3/4}[data-voltom-ring-wrap]{pointer-events:none;z-index:5;width:66cqh;height:66cqh;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}[data-voltom-ring-wrap]:not([data-voltom-ring-mode=face]){display:none}[data-voltom-ring-wrap] [data-pose-progress]{width:100%;height:100%}[data-voltom-direction]{width:36px;height:36px;color:var(--theme-mint);pointer-events:none;z-index:10;position:absolute;bottom:14cqh;left:50%;transform:translate(-50%)}[data-voltom-direction]:not([data-voltom-direction-pose]){display:none}[data-voltom-debug]{pointer-events:none;z-index:10;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem;width:200px;display:none;position:absolute;top:.75rem;left:.75rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{background-color:color-mix(in oklab, var(--theme-surface) 70%, transparent)}}[data-voltom-debug]{font-family:var(--font-mono,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);--tw-leading:calc(.25rem * 4);color:var(--theme-text-muted);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);padding-block:.25rem;padding-inline:.5rem;font-size:10px;line-height:1rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-debug]{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}[data-voltom-debug]:not(.hidden){display:block}[data-voltom-camera]>[data-pose-success]{z-index:30;transform-origin:50%;width:96px;height:96px;margin:auto;position:absolute;inset:0}[data-voltom-debug] [data-valid=true]{color:var(--theme-mint)}[data-voltom-debug] [data-valid=false]{color:var(--theme-danger)}[data-voltom-overlay][data-idle]{background-color:var(--theme-canvas);place-items:center;display:grid}@supports (color:color-mix(in lab, red, red)){[data-voltom-overlay][data-idle]{background-color:color-mix(in oklab, var(--theme-canvas) 70%, transparent)}}[data-voltom-overlay][data-idle]:before{background-color:var(--theme-surface);border-radius:.375rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-overlay][data-idle]:before{background-color:color-mix(in oklab, var(--theme-surface) 80%, transparent)}}[data-voltom-overlay][data-idle]:before{text-align:center;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));color:var(--theme-cyan);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);content:attr(data-voltom-overlay-label);padding-block:.75rem;padding-inline:1rem}[data-voltom-overlay][data-error]:before{content:none}[data-voltom-challenge]{z-index:10;background-color:var(--theme-surface);max-width:calc(100vw - 1.5rem);color:var(--theme-text);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);inset-inline:.75rem;border-radius:.625rem;justify-content:center;align-items:center;gap:.5rem;padding-block:.5rem;padding-inline:.75rem;display:flex;position:absolute;top:.75rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-challenge]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-challengeText]{text-align:center;font-size:1rem;line-height:var(--tw-leading,var(--text-base--line-height,calc(1.5 / 1)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);flex-direction:column;display:flex}[data-voltom-challengeReason]{font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-medium,500);font-weight:var(--font-weight-medium,500);color:var(--theme-warning)}[data-voltom-spinner]{z-index:20;background-color:var(--theme-canvas);flex-direction:column;justify-content:center;align-items:center;gap:.75rem;display:flex;position:absolute;inset:0}@supports (color:color-mix(in lab, red, red)){[data-voltom-spinner]{background-color:color-mix(in oklab, var(--theme-canvas) 90%, transparent)}}[data-voltom-spinner]{text-align:center;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);color:var(--theme-text);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}[data-voltom-spinner]:before{width:2rem;height:2rem;animation:var(--animate-spin,spin 1s linear infinite);border-style:var(--tw-border-style);border-width:4px;border-color:var(--theme-border);border-radius:2147483647px;display:block}@supports (color:color-mix(in lab, red, red)){[data-voltom-spinner]:before{border-color:color-mix(in oklab, var(--theme-border) 30%, transparent)}}[data-voltom-spinner]:before{border-top-color:var(--theme-cyan)}@media (prefers-reduced-motion:reduce){[data-voltom-spinner]:before{animation:none}}[data-voltom-spinner]:before{content:""}[data-voltom-result]{pointer-events:auto;width:fit-content;max-width:100%;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);border-radius:.375rem;padding-block:.5rem;padding-inline:1rem}[data-voltom-retry]{pointer-events:auto;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-retry]{background-color:color-mix(in oklab, var(--theme-surface) 90%, transparent)}}[data-voltom-retry]{font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-bold,700);font-weight:var(--font-weight-bold,700);color:var(--theme-text);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);padding-block:.75rem;padding-inline:1rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-retry]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-retry]{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function,cubic-bezier(.4, 0, .2, 1)));transition-duration:var(--tw-duration,var(--default-transition-duration,.15s))}@media (hover:hover){[data-voltom-retry]:hover{background-color:var(--theme-surface-subtle)}}[data-voltom-result].is-success{border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-success)}@supports (color:color-mix(in lab, red, red)){[data-voltom-result].is-success{border-color:color-mix(in oklab, var(--theme-success) 50%, transparent)}}[data-voltom-result].is-success{background-color:var(--theme-success-surface);color:var(--theme-success)}[data-voltom-result].is-failure{border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-danger)}@supports (color:color-mix(in lab, red, red)){[data-voltom-result].is-failure{border-color:color-mix(in oklab, var(--theme-danger) 50%, transparent)}}[data-voltom-result].is-failure{background-color:var(--theme-danger-surface);color:var(--theme-danger)}[data-voltom-root] .hidden{display:none}}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}`,v=({className:e,display:r,elements:i,options:a})=>{let[c,u]=n(!0),{translate:v,translateError:y}=o({language:a.language}),b=r.feedback.value,x=r.activity.value,S=x&&x!==`matching`?x.message:``,C=x===`matching`?v(`checkingFaceMatch`):S,w=r.error.value,T=r.cameraSize.value,E=b&&b.flow===`face`?b.pose:void 0;r.guidance.value;let D=r.progress.value,O=r.corrective.value,k=E?t({pose:E,corrective:O}):null,A=v(`lookStraight`),j=``;if(k&&(A=v(k.primary),j=k.corrective?v(k.corrective):``),b&&b.flow===`document`){let e=v(d({target:b.target}));A=(b.code?v(l({code:b.code})):``)||e}let M=T&&T.width<T.height?`portrait`:`landscape`;return p(s,{children:[p(`style`,{"data-voltom-styles":``,children:_}),p(`div`,{className:e,ref:i.camera,"data-voltom":``,"data-voltom-camera":``,"data-mirrored":r.cameraFacingMode.value===`user`?``:void 0,style:{"--voltom-camera-ratio":T?`${T.width} / ${T.height}`:void 0},children:[p(`video`,{ref:i.video,"data-voltom-video":``,playsInline:!0,muted:!0,autoPlay:!0,onPlaying:()=>u(!1),onEmptied:()=>u(!0)}),p(`canvas`,{ref:i.mesh,"data-voltom-mesh":``}),p(`div`,{"data-voltom-overlay":``,"data-voltom-overlay-label":v(`readyToStart`),"data-idle":c?``:void 0,"data-error":w?``:void 0}),p(`div`,{"data-voltom-guide":``,"aria-hidden":`true`,"data-voltom-guide-mode":b?.flow,"data-voltom-guide-orientation":b?.flow===`document`?M:void 0}),p(`div`,{"data-voltom-ring-wrap":``,"aria-hidden":`true`,"data-voltom-ring-mode":b?.flow??``,children:p(f,{completed:D.completed,total:D.total,variant:`ring`})}),!!E&&p(g,{"data-voltom-direction":``,"data-voltom-direction-pose":E,pose:E}),p(m,{visible:r.success.value}),p(h,{kind:`voltom`,entries:r.debug.value}),p(`div`,{"data-voltom-spinner":``,className:x?void 0:`hidden`,role:`status`,"aria-label":C,children:S}),p(`div`,{"data-voltom-challenge":E??(b?`document`:void 0),className:b?void 0:`hidden`,children:p(`span`,{"data-voltom-challengeText":``,role:`status`,"aria-live":`polite`,children:[p(`span`,{children:A}),!!j&&p(`span`,{"data-voltom-challengeReason":``,children:j})]})}),p(`div`,{"data-voltom-feedback":``,children:[p(`div`,{"data-voltom-result":``,className:w?`is-failure`:`hidden`,role:`status`,children:w?y({error:w}):``}),p(`button`,{"data-voltom-retry":``,className:w&&r.retry.value?void 0:`hidden`,type:`button`,"aria-label":v(`retry`),onClick:async()=>{let e=r.retry.value;if(r.error.value=null,e)try{await e()}catch{return}},children:v(`retry`)})]})]})]})},y=({root:t,options:n,display:o})=>{let s=({language:e})=>e??i(),l=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,d=0,f=({entries:e,state:t})=>{if(!o.debugEnabled.value||!t.flow)return;let n=performance.now();n-d<100||(d=n,o.debug.value=e)},m=()=>o.cameraSize.value?`${o.cameraSize.value.width}x${o.cameraSize.value.height}`:`—`,h=()=>{let t=e(),n=t.threading.startsWith(`multi`)?`multi`:`single`;return[{label:`Inference`,value:t.inference},{label:`Threading`,value:n}]},g=({face:e,faceInPolygon:t,processingTimeMilliseconds:r,state:i})=>{let a=e?e.pitch:null,c=e?e.yaw:null,d=e?e.roll:null,p=e?u({face:e,name:`mouthSmileLeft`}):0,g=e?u({face:e,name:`mouthSmileRight`}):0,_=e?u({face:e,name:`eyeBlinkLeft`}):0,v=e?u({face:e,name:`eyeBlinkRight`}):0,y=a!==null&&a>=n.minPitch&&a<=n.maxPitch,b=c!==null&&c>=n.minYaw&&c<=n.maxYaw,x=l({state:i}),S=d!==null&&(x===`faceTiltLeft`?d>n.maxRoll:x===`faceTiltRight`?d<-n.maxRoll:Math.abs(d)<=n.maxRoll),C=e=>e===null?`—`:e.toFixed(2),w=(e,t)=>`${e.toFixed(2)}|${t.toFixed(2)}`;f({state:i,entries:[{label:`Flow`,value:`FACE`},...h(),{label:`Face`,valid:!!e&&!t,value:e?t?`In polygon`:`Yes`:`No`},{label:`Pitch`,valid:y,value:C(a)},{label:`Yaw`,valid:b,value:C(c)},{label:`Roll`,valid:S,value:C(d)},{label:`Smile`,valid:p>=.5&&g>=.5,value:w(p,g)},{label:`Wink left`,valid:_>=.25&&v<=.35&&_>=v+.15,value:w(_,v)},{label:`Stable frames`,valid:i.poseStableFrames>0,value:`${i.poseStableFrames}/${n.requiredFaceStableFrames}`},{label:`Language`,value:s({language:n.language})},{label:`Camera`,value:m()},{label:`Facing mode`,value:o.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${r.toFixed(0)} ms`}]})},_=({analysis:e,sideComparison:t,isBack:r,processingTimeMilliseconds:i,state:a})=>{let{orientation:c,alignment:l,documentKind:u,face:d,faceContained:p,detection:g}=e,{diagnostics:_,isBlurry:v,sharpness:y}=e.documentAnalysis,b=e.text.text,x={label:`Stable frames`,valid:a.documentStableFrames>0,value:`${a.documentStableFrames}/${n.requiredDocumentStableFrames}`},S=_?Object.keys(_.rejected)[0]:void 0,C=[{label:`Sharpness`,valid:v===null?void 0:!v,value:y===null?`—`:String(Math.round(y))},{label:`Rectangle`,valid:g?!0:!S&&void 0,value:g?`yes`:S??`no`},{label:`Orientation`,value:c?`${c.rotation}°`:`—`}],w=[{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Document type`,value:u??``},{label:`Distinct from front`,valid:t?.distinct,value:t?t.distinct?`yes`:`no`:`—`}],T=[{label:`Face`,valid:!!d,value:d?`yes`:`no`},{label:`Face contained`,valid:p,value:p?`yes`:`no`},{label:`Face area`,valid:l.faceAreaValid,value:`${(l.faceAreaRatio*100).toFixed(2)}%`},{label:`Face size`,valid:l.faceDimensionsValid,value:l.faceDimensionsValid?`yes`:`no`},{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Text parallel`,valid:l.textParallel,value:l.textParallel?`yes`:`no`},{label:`Text beside face`,valid:l.faceAdjacentTextLineCount>=2,value:String(l.faceAdjacentTextLineCount)},{label:`Document type`,value:u??``}];f({state:a,entries:[{label:`Flow`,value:r?`DOCUMENT BACK`:`DOCUMENT FRONT`},...h(),...C,...r?w:T,x,{label:`Language`,value:s({language:n.language})},{label:`Camera`,value:m()},{label:`Facing mode`,value:o.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${i.toFixed(0)} ms`}]})},y={camera:c(),video:c(),mesh:c()};if(t.replaceChildren(),t.dataset.voltomRoot=``,r(p(v,{display:o,elements:y,options:n}),t),!y.camera.current||!y.video.current||!y.mesh.current)throw Error(a.UI_ELEMENT_NOT_FOUND);return{ref:{root:t,camera:y.camera.current,video:y.video.current,mesh:y.mesh.current},collectFaceDebug:g,collectDocumentDebug:_}};export{y as createVerificationView};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
+
import{C as e,S as t,s as n,w as r}from"./poseGuidance-DLg3Dm3T.js";import{b as i,g as a,m as o,s,u as c,x as l,y as u}from"./media-KU3CWepq.js";import"./presentation-BCIQkuw0.js";import{n as d,r as f,t as p}from"./PoseSuccess-CxL2ugaZ.js";import{n as m,t as h}from"./PoseSilhouette-CTZ5kqI_.js";var g=`/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
3
|
+
[data-voltom-demo],[data-voltom-root],[data-facekey-root]{--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}[data-voltom-demo]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){[data-voltom-demo]{--lightningcss-light: ;--lightningcss-dark:initial}}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:4px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:4px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}[data-facekey-dialog]{box-sizing:border-box;width:100%;max-width:none;height:100dvh;max-height:none;padding:max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));background:var(--theme-surface);color:var(--theme-text);border:0;margin:0;font-family:ui-sans-serif,system-ui,sans-serif;position:fixed;inset:0;overflow-y:auto}[data-facekey-dialog]::backdrop{background:var(--theme-text)}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog]::backdrop{background:color-mix(in srgb, var(--theme-text) 40%, transparent)}}[data-facekey-dialog][open]{flex-direction:column;justify-content:center;align-items:center;gap:24px;display:flex}[data-facekey-dialog] [data-facekey-title]{letter-spacing:-.7px;margin:0;font-size:28px;font-weight:600}[data-facekey-dialog] [data-facekey-camera]{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-facekey-dialog] [data-facekey-camera] video{object-fit:cover;background:var(--theme-surface-subtle);border-radius:2147483647px;width:100%;height:100%}[data-facekey-dialog] [data-facekey-camera][data-mirrored] video{transform:scaleX(-1)}[data-facekey-dialog] [data-facekey-camera]>[data-pose-progress]{width:calc(100% + 28px);height:calc(100% + 28px);position:absolute;inset:-14px;overflow:visible}[data-facekey-dialog] [data-facekey-debug]{top:max(8px, env(safe-area-inset-top));z-index:1;border:1px solid var(--theme-border);background:var(--theme-surface);border-radius:.375rem;width:min(220px,100% - 16px);padding:8px 10px;position:fixed;left:8px}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog] [data-facekey-debug]{background:color-mix(in srgb, var(--theme-surface) 75%, transparent)}}[data-facekey-dialog] [data-facekey-debug]{color:var(--theme-text-muted);pointer-events:none;box-shadow:0 4px 14px var(--theme-border);font:10px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog] [data-facekey-debug]{box-shadow:0 4px 14px color-mix(in srgb, var(--theme-border) 35%, transparent)}}[data-facekey-dialog] [data-facekey-debug]{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}[data-facekey-dialog] [data-facekey-debug].hidden{display:none}[data-facekey-dialog] [data-facekey-debug] [data-valid=true]{color:var(--theme-mint)}[data-facekey-dialog] [data-facekey-debug] [data-valid=false]{color:var(--theme-danger)}@media (width>=640px){[data-facekey-dialog] [data-facekey-debug]{font-size:12px}}[data-facekey-dialog] [data-facekey-camera]>[data-pose-success]{z-index:2;transform-origin:50%;width:112px;height:112px;margin:auto;position:absolute;inset:0}[data-facekey-dialog] [data-facekey-camera] [data-pose-arrow]{width:64px;height:64px;color:var(--theme-mint);position:absolute;bottom:4%;left:50%;transform:translate(-50%)}[data-facekey-dialog][data-state=processing] [data-pose-progress]{animation:1s ease-in-out infinite alternate facekey-pulse}[data-facekey-dialog][data-state=failure] [data-pose-progress] [data-pose-progress-step],[data-facekey-dialog] [data-facekey-camera][data-feedback=mismatch] [data-pose-progress] [data-pose-progress-step]{stroke:var(--theme-danger)}[data-facekey-dialog] [data-facekey-camera][data-shake]{animation:.42s ease-in-out facekey-shake}[data-facekey-dialog] [data-facekey-camera][data-feedback=match] video{opacity:.35}[data-facekey-dialog] [data-facekey-status]{text-align:center;flex-direction:column;align-items:center;max-width:320px;min-height:48px;margin:0;font-size:21px;line-height:1.4;display:flex}[data-facekey-dialog] [data-facekey-status-reason]{color:var(--theme-warning);font-size:16px;font-weight:600}[data-facekey-dialog] [data-facekey-cancel]{border:1px solid var(--theme-mint);color:var(--theme-mint);font:inherit;background:0 0;border-radius:.375rem;padding:12px 20px;font-size:16px}[data-facekey-dialog] [data-facekey-cancel]:focus-visible{outline:2px solid var(--theme-focus);outline-offset:2px}@keyframes facekey-shake{0%,to{transform:translate(0)}15%,45%{transform:translate(-12px)}30%,60%{transform:translate(12px)}75%{transform:translate(-6px)}90%{transform:translate(4px)}}@keyframes facekey-pulse{to{opacity:.35}}@media (width<=600px){[data-facekey-dialog] [data-facekey-camera]{width:min(82vw,325px)}}@media (prefers-reduced-motion:reduce){[data-facekey-dialog] *,[data-facekey-dialog] :before,[data-facekey-dialog] :after{transition:none;animation:none}}`,_=({value:e})=>e===null?`—`:e.toFixed(2),v=({className:t,display:i,dialogRef:u,videoRef:_,options:v,onStop:y})=>{let{translate:b,translateError:x}=c({language:v.language});a(()=>{let e=u.current,t=_.current;if(!e||!t)throw Error(o.UI_ELEMENT_NOT_FOUND);let n=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.body.style.overflow;return document.body.style.overflow=`hidden`,e.showModal(),()=>{s({video:t}),e.open&&e.close(),document.body.style.overflow=r,n&&n.focus()}},[]);let S=i.phase.value,C=i.operation.value,{completed:w,total:T}=i.progress.value,E=i.feedback.value,D;E&&(D=E.matched?`match`:`mismatch`);let O=i.instruction.value,k=i.guidance.value,A=b(`preparingCamera`),j=``;if((S===`checking`||S===`processing`)&&(A=b(`checkingFace`)),S===`success`&&(A=b(`done`)),S===`failure`){let e=i.error.value;A=e===null?b(`faceNotRecognized`):x({error:e})}if(S===`capturing`){let e={FACE_NOT_DETECTED:b(`faceNotFound`),FACE_IN_POLYGON:b(`faceInPolygon`),FACE_TOO_SMALL:b(`faceTooSmall`),FACE_NOT_CENTERED:b(`faceNotCentered`)},t=i.corrective.value;O?.framing?A=e[O.framing]??A:O?.retry?A=O.retry:k&&(A=b(n({pose:k.pose,code:k.code}).primary),j=t?b(t):``)}let M=[...i.debug.value],N=i.match.value;if(M.length&&N){let t=C===`enroll`?e:r,n=N.reason??`unavailable`;N.score!==null&&(n=`${N.score.toFixed(4)} / ${t}`),N.reference&&(n=`Reference`),M.push({label:C===`enroll`?`Similarity`:`Server score`,valid:N.accepted,value:n})}return f(l,{children:[f(`style`,{"data-facekey-styles":``,children:g}),f(`dialog`,{className:t,ref:u,"data-facekey-dialog":``,"data-state":S===`checking`?`capturing`:S,"aria-labelledby":`facekey-title`,"aria-describedby":`facekey-status`,onCancel:e=>{e.preventDefault(),y()},children:[f(`h2`,{id:`facekey-title`,"data-facekey-title":``,children:b(C===`enroll`?`setUpFaceKey`:`unlockWithFaceKey`)}),f(`div`,{"data-facekey-camera":``,"data-mirrored":i.facingMode.value===`user`?``:void 0,"data-feedback":D,"data-shake":E&&!E.matched&&E.animating&&i.failures.value%3==0?``:void 0,children:[f(`video`,{ref:_,playsInline:!0,muted:!0,autoPlay:!0,"aria-label":b(`cameraPreview`)}),f(d,{completed:w,label:b(`faceCaptureProgress`),total:T,variant:`ring`}),f(p,{visible:!!E?.matched}),!(S!==`capturing`||!k||O?.framing)&&f(h,{pose:k.pose}),f(m,{kind:`facekey`,entries:M})]}),f(`p`,{id:`facekey-status`,"data-facekey-status":``,role:`status`,"aria-live":`polite`,children:[f(`span`,{children:A}),!!j&&f(`span`,{"data-facekey-status-reason":``,children:j})]}),f(`button`,{type:`button`,"data-facekey-cancel":``,autoFocus:!0,onClick:y,children:b(`cancel`)})]})]})},y=({options:e,display:n,events:r,onStop:a})=>{let s=u(),c=u(),l=null,d=0;return{get dialog(){return s.current},requiredVideo:()=>{if(!c.current)throw Error(o.INVALID_OPTIONS);return c.current},open:()=>{if(l)throw Error(o.INVALID_OPTIONS);l=document.createElement(`div`),l.dataset.facekeyRoot=``,document.body.append(l),d=0,i(f(v,{display:n,dialogRef:s,videoRef:c,options:e,onStop:a}),l),r.dispatchEvent(new CustomEvent(`facekey:open`,{detail:s.current}))},close:()=>{l&&(i(null,l),l.remove(),l=null,r.dispatchEvent(new Event(`facekey:close`)))},collectCaptureDebug:({centered:e,face:r,faceInPolygon:i,faces:a,force:o=!1,frame:c,framing:l,operation:u,pose:f,poseRejection:p,reason:m,stable:h})=>{let g=r?r.boundingRect.height/Math.min(c.width,c.height):null,v=r?.blendshapes.mouthSmileLeft??null,y=r?.blendshapes.mouthSmileRight??null,b=!(!r||p),x=[{label:`Flow`,value:u.toUpperCase()},{label:`Pose`,value:f},{label:`Faces`,valid:a.length===1,value:String(a.length)},{label:`Human`,valid:!!r&&!i,value:r?i?`In polygon`:`Yes`:`No face`},{label:`Height`,valid:!l,value:g===null?`—`:`${(g*100).toFixed(0)}% / ${t*100}%`},{label:`Centered`,valid:e,value:e?`Yes`:`No`},{label:`Pitch`,value:_({value:r?.pitch??null})},{label:`Yaw`,value:_({value:r?.yaw??null})},{label:`Roll`,value:_({value:r?.roll??null})},{label:`Pose valid`,valid:b,value:p??`Yes`}];f===`faceSmile`&&x.push({label:`Smile`,valid:v!==null&&y!==null&&v>=.5&&y>=.5,value:`${_({value:v})}|${_({value:y})}`}),x.push({label:`Stable`,valid:h>0,value:`${h}/3`}),m&&x.push({label:`Reason`,valid:!1,value:m});let S=performance.now();!n.debugEnabled.value||!s.current?.open||!o&&S-d<100||(d=S,n.debug.value=x)}}};export{y as createFaceKeyView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
+
import{b as e,g as t,m as n,s as r,u as i,y as a}from"./media-KU3CWepq.js";import{n as o,r as s,t as c}from"./PoseSuccess-CxL2ugaZ.js";var l=`[data-voltom-demo],[data-voltom-root],[data-facekey-root]{--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}[data-voltom-demo]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){[data-voltom-demo]{--lightningcss-light: ;--lightningcss-dark:initial}}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:4px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:4px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}[data-facegate-gate]{z-index:60;background:color-mix(in srgb, var(--theme-canvas) 84%, transparent);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);place-items:center;padding:24px;font-family:ui-sans-serif,system-ui,sans-serif;display:grid;position:fixed;inset:0}[data-facegate-gate] .facegate-stage{place-items:center;display:grid;position:relative}[data-facegate-gate] .facegate-camera{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-facegate-gate] .facegate-camera video{object-fit:cover;background:var(--theme-surface-subtle);border-radius:999px;width:100%;height:100%}[data-facegate-gate] .facegate-camera[data-mirrored] video{transform:scaleX(-1)}[data-facegate-gate] .facegate-camera>[data-pose-progress]{width:calc(100% + 28px);height:calc(100% + 28px);position:absolute;inset:-14px;overflow:visible}[data-facegate-gate] .facegate-camera>[data-pose-success]{z-index:2;transform-origin:50%;width:112px;height:112px;margin:auto;position:absolute;inset:0}[data-facegate-gate] .facegate-camera[data-shake]{animation:.48s both facegate-shake}[data-facegate-gate] .facegate-spinner-host{z-index:3;background:color-mix(in srgb, var(--theme-canvas) 70%, transparent);border-radius:999px;place-items:center;display:grid;position:absolute;inset:0}[data-facegate-gate] .facegate-spinner{width:40px;height:40px;color:var(--theme-cocoa);animation:.9s linear infinite facegate-spin}[data-facegate-gate] .facegate-prompt{width:min(80vw,300px);color:var(--theme-text);text-align:center;margin:0;font-size:17px;font-weight:600;position:absolute;top:calc(100% + 30px);left:50%;transform:translate(-50%)}[data-facegate-gate][data-result=pass] [data-pose-progress-step]{stroke:var(--theme-mint)}[data-facegate-gate][data-result=reject] [data-pose-progress-step]{stroke:var(--theme-danger)}@keyframes facegate-shake{0%,to{transform:translate(0)rotate(0)}20%{transform:translate(-6px)rotate(-6deg)}40%{transform:translate(6px)rotate(6deg)}60%{transform:translate(-5px)rotate(-4deg)}80%{transform:translate(5px)rotate(4deg)}}@keyframes facegate-spin{to{transform:rotate(360deg)}}@media (width<=600px){[data-facegate-gate] .facegate-camera{width:min(82vw,300px)}}@media (prefers-reduced-motion:reduce){[data-facegate-gate] .facegate-camera[data-shake],[data-facegate-gate] .facegate-spinner{animation:none}}`,u=()=>s(`svg`,{className:`facegate-spinner`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:s(`path`,{d:`M12 3a9 9 0 1 0 9 9`})}),d=({display:e,videoRef:r,options:a,onCancel:d})=>{let{translate:f}=i({language:a.language});t(()=>{if(!r.current)throw Error(n.UI_ELEMENT_NOT_FOUND);let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[]);let p=e.outcome.value,m=e.phase.value===`checking`,h=e.completed.value,g=e.total.value;return s(`div`,{className:`facegate-gate`,"data-facegate-gate":``,"data-result":p===`pass`?`pass`:p?`reject`:``,onClick:e=>{e.target===e.currentTarget&&d()},children:[s(`style`,{"data-facegate-styles":``,children:l}),s(`div`,{className:`facegate-stage`,role:`dialog`,"aria-modal":`true`,"aria-label":`Liveness check`,children:[s(`div`,{className:`facegate-camera`,"data-mirrored":``,"data-shake":p===`fail`||p===`error`?``:void 0,children:[s(`video`,{ref:r,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":f(`cameraPreview`)}),s(o,{completed:h,label:f(`faceCaptureProgress`),total:g,variant:`ring`}),s(c,{visible:p===`pass`}),m?s(`div`,{className:`facegate-spinner-host`,children:s(u,{})}):null]}),p?null:s(`p`,{className:`facegate-prompt`,role:`status`,"aria-live":`polite`,children:e.prompt.value})]})]})},f=({options:t,display:i,onCancel:o})=>{let c=a(),l=null;return{get video(){return c.current},requiredVideo:()=>{if(!c.current)throw Error(n.INVALID_OPTIONS);return c.current},open:()=>{l||(l=document.createElement(`div`),l.dataset.facegateRoot=``,document.body.append(l),e(s(d,{display:i,videoRef:c,options:t,onCancel:o}),l))},close:()=>{if(!l)return;let t=c.current;t&&r({video:t}),e(null,l),l.remove(),l=null}}};export{f as createFaceGateView};
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltom.io/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"files": [
|
|
6
6
|
"LICENSE",
|
|
7
|
+
"dist/assets/locales/*.json",
|
|
7
8
|
"dist/sdk/*.js",
|
|
8
9
|
"dist/sdk/verify.d.ts",
|
|
9
10
|
"dist/sdk/facekey.d.ts",
|
|
11
|
+
"dist/sdk/facegate.d.ts",
|
|
10
12
|
"dist/sdk/verify/global.d.ts",
|
|
11
|
-
"dist/sdk/facekey/global.d.ts"
|
|
13
|
+
"dist/sdk/facekey/global.d.ts",
|
|
14
|
+
"dist/sdk/facegate/global.d.ts"
|
|
12
15
|
],
|
|
13
16
|
"type": "module",
|
|
14
17
|
"imports": {
|
|
@@ -28,22 +31,30 @@
|
|
|
28
31
|
"import": "./dist/sdk/facekey.js",
|
|
29
32
|
"default": "./dist/sdk/facekey.js"
|
|
30
33
|
},
|
|
34
|
+
"./facegate": {
|
|
35
|
+
"types": "./dist/sdk/facegate.d.ts",
|
|
36
|
+
"import": "./dist/sdk/facegate.js",
|
|
37
|
+
"default": "./dist/sdk/facegate.js"
|
|
38
|
+
},
|
|
31
39
|
"./verify/global": {
|
|
32
40
|
"types": "./dist/sdk/verify/global.d.ts"
|
|
33
41
|
},
|
|
34
42
|
"./facekey/global": {
|
|
35
43
|
"types": "./dist/sdk/facekey/global.d.ts"
|
|
44
|
+
},
|
|
45
|
+
"./facegate/global": {
|
|
46
|
+
"types": "./dist/sdk/facegate/global.d.ts"
|
|
36
47
|
}
|
|
37
48
|
},
|
|
38
49
|
"publishConfig": {
|
|
39
50
|
"access": "public"
|
|
40
51
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@fastify/static": "^10.1.8",
|
|
54
|
+
"@preact/signals": "^2.11.4",
|
|
55
|
+
"fastify": "^5.12.8",
|
|
56
|
+
"pdfjs-dist": "^6.5.438",
|
|
57
|
+
"preact": "^11.1.1"
|
|
47
58
|
},
|
|
48
59
|
"devDependencies": {
|
|
49
60
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -53,5 +64,12 @@
|
|
|
53
64
|
"vite": "^8.3.5",
|
|
54
65
|
"vite-plugin-compression2": "^2.5.3",
|
|
55
66
|
"vite-plugin-dts": "^5.1.2"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:ui": "HEADED=1 vitest run --ui",
|
|
71
|
+
"dev": "vite dev --logLevel silent",
|
|
72
|
+
"build": "vite build",
|
|
73
|
+
"start": "NODE_ENV=production node src/server.ts"
|
|
56
74
|
}
|
|
57
|
-
}
|
|
75
|
+
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
-
import{ut as e}from"./faceMatch.shared-D6B1I2T0.js";var t=Symbol.for(`pv`),n=0;Array.isArray;function r(r,i,a,o,s,c){i||={};var l,u,d=i;if(`ref`in d&&typeof r!=`function`)for(u in d={},i)u==`ref`?l=i[u]:d[u]=i[u];var f={type:r,props:d,key:a,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:t,__v:--n,__i:-1,__u:0};return(s||c)&&(f.__source=s,f.__self=c),e.vnode&&e.vnode(f),f}var i=({className:e,entries:t,kind:n})=>r(`div`,{className:t.length?e:`hidden`,[`data-${n}-debug`]:``,children:t.map(({label:e,valid:t,value:n})=>r(`div`,{children:[r(`span`,{children:[e,`: `]}),r(`span`,{"data-valid":t===void 0?void 0:String(t),children:n})]},e))});export{r as n,i as t};
|