@sekyro/web 0.1.0-rc.11 → 0.1.0-rc.13
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/CHANGELOG.md +12 -0
- package/dist/{capture-session-doc-DMQ7T3HC.js → capture-session-doc-7LQAOCHJ.js} +1 -1
- package/dist/{capture-session-v3-DYrhYJoM.d.ts → capture-session-v3-C5DRPBhM.d.ts} +1 -1
- package/dist/{capture-session-v3-CCHws1mz.d.cts → capture-session-v3-Db4n6d-k.d.cts} +1 -1
- package/dist/chunk-57VOMVKM.js +1 -0
- package/dist/{chunk-LUKTHL6K.js → chunk-5OIC5TZS.js} +1 -1
- package/dist/{chunk-JDGEZ542.js → chunk-H6H2RT6M.js} +1 -1
- package/dist/{chunk-HHCGQSD4.js → chunk-IBA5CPDV.js} +1 -1
- package/dist/{chunk-IJLHPX35.js → chunk-JRSIMNB5.js} +1 -1
- package/dist/chunk-UBDG5IAP.js +1 -0
- package/dist/{chunk-OWU22VXP.js → chunk-VJM76LUI.js} +1 -1
- package/dist/chunk-WTQE6IGL.js +1 -0
- package/dist/chunk-XBVSYVKA.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +5 -5
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- package/dist/{create-document-capture-FV4XGUKQ.js → create-document-capture-RTFDQSBC.js} +1 -1
- package/dist/{create-verification-CzLrQjeM.d.cts → create-verification-BV_T0-CR.d.cts} +39 -13
- package/dist/{create-verification-CmJzn7sq.d.ts → create-verification-P6i3tyce.d.ts} +39 -13
- package/dist/{icao-gate-BeznQECA.d.cts → icao-gate-B0GDH_JS.d.cts} +13 -5
- package/dist/{icao-gate-Bw5sQVlt.d.ts → icao-gate-BP11XO-h.d.ts} +13 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +36 -10
- package/dist/index.d.ts +36 -10
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +7 -6
- package/dist/internal/index.d.ts +7 -6
- package/dist/internal/index.js +1 -1
- package/dist/plan-runner-RVVF5DJV.js +1 -0
- package/dist/{types-BWyAHKt_.d.cts → types-DPWT_KMn.d.cts} +57 -14
- package/dist/{types-BWyAHKt_.d.ts → types-DPWT_KMn.d.ts} +57 -14
- package/package.json +1 -1
- package/sbom.cdx.json +7 -7
- package/dist/chunk-AHD4DA2V.js +0 -1
- package/dist/chunk-MXNZMTC2.js +0 -1
- package/dist/chunk-URUKV6NC.js +0 -1
- package/dist/chunk-V5K2JLC7.js +0 -1
- package/dist/plan-runner-ZVAY4FSB.js +0 -1
package/dist/core/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var st=Object.create;var V=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var dt=(r,e)=>()=>(r&&(e=r(r=0)),e);var be=(r,e)=>{for(var t in e)V(r,t,{get:e[t],enumerable:!0})},ve=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ct(e))!ut.call(r,i)&&i!==t&&V(r,i,{get:()=>e[i],enumerable:!(n=ot(e,i))||n.enumerable});return r};var mt=(r,e,t)=>(t=r!=null?st(lt(r)):{},ve(e||!r||!r.__esModule?V(t,"default",{value:r,enumerable:!0}):t,r)),pt=r=>ve(V({},"__esModule",{value:!0}),r);var je={};be(je,{RANK_CANDIDATES:()=>qt,RANK_TOLERANCE:()=>Z,RANK_WINDOW_MS:()=>Yt,ROLL_ZERO_DEG:()=>Qt,SHARPNESS_REPORT_MAX:()=>Ze,YAW_REPORT_MAX:()=>Ye,YAW_ZERO_IOD:()=>Zt,collectRankedKeyframes:()=>Qe,default:()=>$t,featuresOf:()=>Xe,frontalOf:()=>ze,rankKeyframes:()=>qe});function ze(r){let e=r.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let t=e.right.x-e.left.x,n=e.right.y-e.left.y,i=t*t+n*n;if(i===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(n,Math.abs(t))*180/Math.PI),s=Be(1-a/30),o=null,l=r.nose;if(l!==void 0){let d=(e.left.x+e.right.x)/2,c=(e.left.y+e.right.y)/2;o=Math.abs(((l.x-d)*t+(l.y-c)*n)/i),s*=Be(1-o/.5)}return{frontal:s,yaw:o,roll:a}}function Xe(r,e){return r===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...ze(r),eyes:null,score:r.score,sharpness:e}}function qe(r){let e=r.map((i,a)=>a),t=(i,a)=>{let s=Number.NEGATIVE_INFINITY;for(let o of e)s=Math.max(s,i(r[o]));e=e.filter(o=>i(r[o])>=s-a)};t(i=>i.frontal,Z.frontal),t(i=>i.eyes??1,Z.eyes),t(i=>i.score,Z.score);let n=-1;for(let i of e)(n===-1||r[i].sharpness>r[n].sharpness)&&(n=i);return n}function jt(r){return{face:r.face,frontal:O(r.frontal),...r.yaw!==null?{yaw:Math.min(O(r.yaw),Ye)}:{},...r.roll!==null?{roll:O(r.roll)}:{},...r.eyes!==null?{eyes:O(r.eyes)}:{},score:O(r.score),sharpness:Math.min(O(r.sharpness),Ze)}}async function Qe(r,e){let{options:t}=r,n=t.video,i=t.now??(()=>performance.now()),a=t.captureKeyframe??(m=>r.defaultKeyframe(m)),s=600/3,o=[],l=[],d=0;for(let m=0;m<4;m+=1){if(e!==r.attempt)return null;let f=r.detector,p=Promise.resolve(null),h,g=0;try{if(f!==null){let k=r.profiler?.profile.inputWidth??160,I=t.makeSnapshot?.(n,k)??r.defaultSnapshot(n,k);h=a(n).then(y=>(g=i(),y));let $=i();p=f.detect(I,n.videoWidth,n.videoHeight).then(y=>(d+=i()-$,y),()=>null)}else h=a(n).then(k=>(g=i(),k));let[v,_]=await Promise.all([h,p]);o.push(v),l.push(Xe(_,v.sharpness))}catch{h?.catch(()=>{})}let E=g>0?Math.max(0,i()-g):0;m<3&&await new Promise(v=>setTimeout(v,Math.max(0,s-E)))}if(e!==r.attempt)return null;let c=qe(l);if(c===-1)return null;let u=0;l.forEach((m,f)=>{m.sharpness>l[u].sharpness&&(u=f)});try{t.telemetry?.({type:"keyframe",tier:r.detector?.tier??null,chosen:c,sharpest:u,detectMs:Math.round(d),candidates:l.map(jt)})}catch{}return o[c]??null}var qt,Yt,Zt,Qt,Z,Be,O,Ye,Ze,$t,$e=dt(()=>{"use strict";qt=4,Yt=600,Zt=.5,Qt=30,Z={frontal:.1,eyes:.1,score:.05},Be=r=>r<0?0:r>1?1:r;O=r=>Number.isFinite(r)?Math.round(r*1e3)/1e3:0,Ye=99,Ze=999999;$t=Qe});var nr={};be(nr,{CENTERED_FACTOR:()=>Mt,CIRCLE_RADIUS_FACTOR:()=>Et,CLIP_MS:()=>Se,CaptureSessionV3:()=>ye,ClipError:()=>b,ClipRecorder:()=>P,DEFAULT_CLIP_MIME:()=>W,DEFAULT_TIER_ORDER:()=>xe,DEFAULT_V3_ASSET_BASE_URL:()=>Re,DEVICE_PROFILES:()=>Oe,DetectScheduler:()=>G,DetectorLadderError:()=>C,DeviceProfiler:()=>N,EXPOSURE_BAND:()=>L,FaceGateV3:()=>w,GATE_SNAPSHOT_MS:()=>tt,GateBlockStats:()=>D,HOLD_UPRIGHT_KEY:()=>Q,IN_CIRCLE_FACTOR:()=>St,KEYFRAME_CANDIDATES:()=>j,KEYFRAME_WINDOW_MS:()=>nt,MAX_CLIP_BYTES:()=>H,MIME_CANDIDATES:()=>Ee,PHONE_MAX_SHORT_SIDE:()=>ke,PROVENANCE_WAIT_MS:()=>it,SHARP_REF:()=>br,STOP_GRACE_MS:()=>_e,TIMESLICE_MS:()=>Me,UPRIGHT_WATCH_MS:()=>rt,V3_GATE_DEFAULTS:()=>De,VIDEO_BPS:()=>ie,blockReasonOf:()=>Ue,buildCaptureConstraints:()=>ae,buildLivenessV2FormData:()=>ht,cameraPreflight:()=>re,captureMirroredKeyframe:()=>ne,classifyDevice:()=>me,createDetector:()=>R,detectFormFactor:()=>K,detectIsMobile:()=>se,errorCopy:()=>gt,exposure:()=>le,extForMime:()=>J,intrinsicSize:()=>T,isClipTooLarge:()=>A,isMediaRecorderSupported:()=>ft,mapGetUserMediaError:()=>te,meanLuma:()=>X,pickMimeType:()=>ee,probeDevice:()=>de,sharpness:()=>q,toStreamPixels:()=>F,trackFacingMode:()=>oe,uiCopy:()=>yt});module.exports=pt(nr);var Ee=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function ee(){let r=globalThis.MediaRecorder;return!r||typeof r.isTypeSupported!="function"?"":Ee.find(e=>r.isTypeSupported(e))??""}var W="video/webm";function te(r){if(r instanceof TypeError)return"insecure";switch(r?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function re(){let r=globalThis;if(typeof r.window<"u"&&r.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=r.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function ft(){let r=globalThis.MediaRecorder;return typeof r<"u"&&typeof r.isTypeSupported=="function"}var H=8*1024*1024;function A(r){return r.size>H}function J(r){let e=(r||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function ht(r){let{token:e,clip:t,keyframe:n}=r,i=r.ts??Date.now(),a=t.type||W,s=n.type||"image/jpeg",o=new FormData;return o.append("token",e),o.append("clip",new File([t],`liveness-${i}.${J(a)}`,{type:a})),o.append("keyframe",new File([n],`keyframe-${i}.${J(s)}`,{type:s})),o}function ne(r,e,t=.92){return new Promise((n,i)=>{let a=r.videoWidth,s=r.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){i(new Error("no-2d-context"));return}e.width=a,e.height=s,o.scale(-1,1),o.drawImage(r,-a,0),e.toBlob(l=>l?n(l):i(new Error("empty-keyframe")),"image/jpeg",t)})}var gt={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},yt={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Se=2500,Me=1e3,_e=1500,ie=25e5,b=class extends Error{constructor(e,t){super(t??e),this.kind=e}},P=class{constructor(){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.settled=!1}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.hardStopTimer=null,this.graceTimer=null}record(e,t,n){if(this.recorder&&!this.settled)return Promise.reject(new b("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time"));this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e;let i=ee();return new Promise((a,s)=>{let o;try{o=new MediaRecorder(e,i?{mimeType:i,videoBitsPerSecond:ie}:{videoBitsPerSecond:ie})}catch{try{o=new MediaRecorder(e)}catch{s(new b("unsupported"));return}}this.recorder=o;let l=c=>{this.settled||(this.settled=!0,this.clearTimers(),c())},d=()=>l(()=>{let c=o.mimeType||i||W,u=new Blob(this.chunks,{type:c});if(u.size===0){s(new b("generic","empty clip"));return}if(A(u)){s(new b("cliptoolarge"));return}a({blob:u,mimeType:c})});if(o.ondataavailable=c=>{c.data&&c.data.size&&(this.chunks.push(c.data),this.bytes+=c.data.size,this.bytes>H&&l(()=>{try{o.state!=="inactive"&&o.stop()}catch{}s(new b("cliptoolarge"))}))},o.onstop=d,o.onerror=()=>l(()=>s(new b("generic"))),n!==void 0){let c=!1;o.onstart=()=>{if(!(c||this.settled)){c=!0;try{n()}catch{}}}}try{o.start(Me)}catch{l(()=>s(new b("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),o.state!=="inactive"){try{o.stop()}catch{d()}this.graceTimer=setTimeout(d,_e)}else d()},Se)})}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};function ae(r,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var ke=600;function K(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let r=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(r))return"phone";if(/iPad/i.test(r))return"tablet";if(/Android/i.test(r))return/Mobile/i.test(r)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(r))return"phone";if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(r))return"tablet";if(!vt())return"desktop";let t=bt();return t>0&&t<ke?"phone":"tablet"}function se(){return K()!=="desktop"}function bt(){try{let r=window.screen,e=Number(r?.width??0),t=Number(r?.height??0);return e>0&&t>0?Math.min(e,t):0}catch{return 0}}function oe(r){try{let t=r?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return t==="user"||t==="environment"?t:null}catch{return null}}function vt(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Et=.45,St=.9,Mt=.4;var Te=1e4,U=class r{constructor(e,t){this.tier="blaze";this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let n=await import("@mediapipe/tasks-vision"),i=await n.FilesetResolver.forVisionTasks(e),a=await n.FaceDetector.createFromOptions(i,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new r(a,t)}async detect(e,t,n){let i;try{i=this.inner.detect(e).detections}catch{return null}let a=_t(i);if(a?.boundingBox===void 0)return null;let s=T(e),o=kt(a.keypoints,s),l=a.keypoints?.[2],d={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...o!==void 0?{eyes:o}:{},...l!==void 0?{nose:{x:l.x*s.width,y:l.y*s.height}}:{},score:a.categories[0]?.score??0};return F(d,e,t,n)}destroy(){try{this.inner.close()}catch{}}};function _t(r){let e,t=-1;for(let n of r){let i=n.categories[0]?.score??0;i>t&&(e=n,t=i)}return e}function kt(r,e){let t=r?.[0],n=r?.[1];if(t===void 0||n===void 0)return;let i=o=>({x:o.x*e.width,y:o.y*e.height}),[a,s]=[i(t),i(n)];return a.x<=s.x?{left:a,right:s}:{left:s,right:a}}function Tt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let r=document.createElement("canvas");return r.width=2,r.height=2,r}async function Ce(){let r=globalThis.FaceDetector;if(typeof r!="function")return{ok:!1,reason:"unsupported"};try{let e=new r({fastMode:!0,maxDetectedFaces:1});return await e.detect(Tt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var B=class{constructor(e,t){this.tier="native";this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,n){let i;try{i=await this.inner.detect(e)}catch{return null}let a=i[0];if(a===void 0)return null;let s=Ct(a.landmarks),o={box:{x:a.boundingBox.x,y:a.boundingBox.y,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},score:1};return F(o,e,t,n)}destroy(){}};function Ct(r){if(r===void 0)return;let e=r.filter(i=>i.type==="eye").map(i=>i.locations[0]).filter(i=>i!==void 0),[t,n]=e;if(!(t===void 0||n===void 0))return t.x<=n.x?{left:t,right:n}:{left:n,right:t}}var Re="/models-v3",xe=["native","blaze"],C=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function T(r){let e=r;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,n=typeof e.height=="number"?e.height:0;return{width:t,height:n}}function F(r,e,t,n){let i=T(e),a=i.width>0?t/i.width:1,s=i.height>0?n/i.height:1,o=l=>({x:l.x*a,y:l.y*s});return{box:{x:r.box.x*a,y:r.box.y*s,width:r.box.width*a,height:r.box.height*s},...r.eyes!==void 0?{eyes:{left:o(r.eyes.left),right:o(r.eyes.right)}}:{},...r.nose!==void 0?{nose:o(r.nose)}:{},score:r.score}}function Rt(r){return r instanceof Error?r.message:String(r)}async function R(r){let e=r.preferred??xe,t=[];for(let n of e){if(n==="native"){let i=await Ce();if(i.ok)return new B(i.instance,ce(t));t.push(`native:${i.reason}`);continue}try{return await xt(U.create(r.v3AssetBaseUrl??Re,ce(t)),r.blazeInitTimeoutMs??Te)}catch(i){t.push(i instanceof z?"blaze:blaze_init_timeout":`blaze:${Rt(i)}`)}}throw new C(ce(t)??"no_tier_available")}function ce(r){return r.length>0?r.join("; "):void 0}var z=class extends Error{};function xt(r,e){return new Promise((t,n)=>{let i=setTimeout(()=>{n(new z(`init exceeded ${e}ms`)),r.then(a=>a.destroy(),()=>{})},e);r.then(a=>{clearTimeout(i),t(a)},a=>{clearTimeout(i),n(a)})})}var br=180,L=[100,190],wt=64;function we(r,e){return .299*(r[e]??0)+.587*(r[e+1]??0)+.114*(r[e+2]??0)}function X(r){let{data:e,width:t,height:n}=r,i=t*n;if(i===0)return 0;let a=0;for(let s=0;s<i;s+=1)a+=we(e,s*4);return a/i}function q(r){let{data:e,width:t,height:n}=r;if(t<3||n<3)return 0;let i=new Float32Array(t*n);for(let c=0;c<i.length;c+=1)i[c]=we(e,c*4);let a=0,s=0,o=0;for(let c=1;c<n-1;c+=1)for(let u=1;u<t-1;u+=1){let m=c*t+u,f=(i[m-t]??0)+(i[m-1]??0)+(i[m+1]??0)+(i[m+t]??0)-4*(i[m]??0);a+=f,s+=f*f,o+=1}if(o===0)return 0;let l=a/o,d=s/o-l*l;return Math.min(1,Math.max(0,d)/180)}function le(r){let e=X(r),[t,n]=L,i=e<t?t-e:e>n?e-n:0;return Math.max(0,1-i/wt)}var De=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),x=r=>Math.min(1,Math.max(0,r)),w=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...De,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:n,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,centering:0,size:0,pose:0,sharpness:x(n.sharpness),exposure:x(n.exposure),motion:1};if(t!==null){s.presence=1;let c=this.geometryOf(t,e);s.centering=c.centering,s.size=c.size,s.pose=c.pose,s.motion=this.motionOf(c.center,c.iod,i)}else this.lastCenter=null,this.velocityEma=0;let o=Math.min(s.presence,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=x(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*a),this.qWindow.push({at:i,q:o}),this.qWindow=this.qWindow.filter(c=>c.at>=i-this.t.READY_WINDOW_MS);let l=this.qWindow.map(c=>c.q);if(l.length>=3){let c=Math.min(...l),u=l.indexOf(c);l=l.filter((m,f)=>f!==u)}let d=this.p>=1&&l.every(c=>c>=this.t.Q_GOOD);return{at:i,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,n,o),ready:d,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:n,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),o=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:n.x+n.width/2,y:n.y+n.height/2-this.t.BOX_EYE_OFFSET_FACTOR*n.height},l=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*n.width,d=Math.hypot(o.x-a.x,o.y-a.y),c=l<=0?0:1-x(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*l)),u=s>0?l/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let f=1;if(i!==void 0){let p=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;f=1-x(p/this.t.ROLL_MAX_DEG)}return{center:o,iod:l,centering:c,size:m,pose:f}}motionOf(e,t,n){let i=this.lastCenter;if(this.lastCenter={...e,at:n},i===null||t<=0)return 1;let a=(n-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-x(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,n){if(e.presence<=0)return"fcv3.no_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(n<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let s of i)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(L[0]+L[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var Oe=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),Dt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function de(){let r=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(Dt)}catch{e=!1}return{cores:r?.hardwareConcurrency??2,memGB:r?.deviceMemory??null,simd:e}}function me(r){let e=r.memGB??4;return r.cores<4||e<3?"LOW":r.cores>=8&&e>=6?"HIGH":"MID"}var ue=["LOW","MID","HIGH"],N=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return Oe[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let t=this.samples.reduce((n,i)=>n+i,0)/this.samples.length;if(t>70)this.current="LOW";else if(t<25){let n=ue.indexOf(this.current);this.current=ue[Math.min(ue.length-1,n+1)]??this.current}return this.current}};var G=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,n)=>t+n,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var Ie="0.1.0-rc.11";var Ae="sekyro.did",Pe;function Fe(){let r=globalThis.crypto;try{if(typeof r?.randomUUID=="function")return r.randomUUID()}catch{}try{if(typeof r?.getRandomValues=="function"){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}}catch{}}function Ot(){try{let r=localStorage.getItem(Ae);if(r)return r;let e=Fe();return e!==void 0&&localStorage.setItem(Ae,e),e}catch{return Pe??(Pe=Fe()),Pe}}async function It(){let r=globalThis.crypto?.subtle;if(!r)return"";let e=navigator,t=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await r.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function At(r){let e=new TextEncoder().encode(r),t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Pt(r){let e,t;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{t??(t=It().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await t,a=Ot(),s={v:1,platform:"web",sdk:r.sdk.slice(0,64),ids:[...a?[{kind:"web_local",value:a.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return At(JSON.stringify(s))}catch{return}}}}var pe=Symbol.for("sekyro.web.clientContext"),fe=globalThis,Ft=fe[pe]??(fe[pe]=Pt({sdk:`@sekyro/web@${Ie}`}));function Le(r){try{let e=r.getVideoTracks?.()[0];e&&Ft.noteCameraLabel(e.label)}catch{}}var Lt=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],Nt=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function Gt(r){let e=(r??"").trim().toLowerCase();return e.length===0?"unknown":Lt.some(t=>e.includes(t))?"known_virtual":Nt.some(t=>t.test(e))?"platform":"unknown"}function Ne(r){if(typeof r!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(r))}catch{return!1}}function Vt(r=globalThis){return Ne(r.navigator?.mediaDevices?.getUserMedia)&&Ne(r.MediaStreamTrack?.prototype?.getSettings)}async function Wt(r,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let n=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(r)));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Ge(r,e=globalThis){let t={};try{t=typeof r.getSettings=="function"?r.getSettings()??{}:{}}catch{t={}}let n={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(n.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(n.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(n.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(n.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await Wt(t.deviceId,e);a!==void 0&&(n.deviceIdHash=a)}let i;try{i=r.label}catch{i=void 0}return{trackSettings:n,capabilitiesPresent:typeof r.getCapabilities=="function",labelClass:Gt(i),prototypesIntact:Vt(e)}}var he=r=>Math.round(r*100)/100;function Ve(r){let e=r,t=typeof e?.requestVideoFrameCallback=="function",n=null,i=null,a=0,s=0,o=0,l=0,d=0,c=0,u=()=>{!t||e?.requestVideoFrameCallback===void 0||(n=e.requestVideoFrameCallback((m,f)=>{if(n=null,!t)return;let p=f.presentationTime;if(i!==null){let h=p-i.presentationTimeMs;s+=1;let g=h-o;o+=g/s,l+=g*(h-o)}typeof f.captureTime=="number"&&Number.isFinite(f.captureTime)&&(d+=p-f.captureTime,c+=1),a+=1,i={mediaTimeMs:f.mediaTime*1e3,presentationTimeMs:p},u()}))};return u(),{latest:()=>i,stats:()=>({n:a,meanGapMs:s===0?0:he(o),stdGapMs:s<2?0:he(Math.sqrt(l/(s-1))),captureLatencyMs:c===0?null:he(d/c)}),stop:()=>{t&&(t=!1,n!==null&&e?.cancelVideoFrameCallback?.(n),n=null)}}}function We(r,e,t){return{...r,rvfc:e,rampPainter:t}}var Ht=["rose","peach","sand","mint","sky","lilac"];var Kt=4,Ut=4;function Bt(r){if(typeof r!="object"||r===null)return!1;let e=r;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length!==3||!e.colours.every(n=>Ht.includes(n))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==3)return!1;let t=-1;for(let n of e.onsetsMs){if(typeof n!="number"||!Number.isFinite(n)||n<=t||n>=2e3)return!1;t=n}return!0}function He(r,e){let t=e.now??(()=>performance.now()),n=Bt(r)?r:void 0,i=[],a=null,s=null,o=null,l=!1,d=null,c=p=>{d=p;try{e.paint(p)}catch{}},u=p=>{let h=e.frames?.()??null;return h!==null&&o!==null?h.mediaTimeMs+(p-h.presentationTimeMs)-o:p-(s??p)},m=(p,h,g=0)=>{if(l)return;let E=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!l){if(g<Kt&&u(t())<p-Ut){m(p,h,g+1);return}h()}},E)},f=p=>{if(n!==void 0){if(p>=3){m(2e3,()=>c(null));return}m(n.onsetsMs[p],()=>{let h=u(t());if(h>2e3){d!==null&&c(null);return}let g=n.colours[p];c(g);let E=i.length===0?0:i[i.length-1].tMs;i.push({tMs:Math.max(E,Math.round(h)),colour:g}),f(p+1)})}};return{started(p){if(n===void 0||l||s!==null)return;s=p;let h=e.frames?.()??null;o=h===null?null:h.mediaTimeMs+(p-h.presentationTimeMs),f(0)},stop(){l||(l=!0,a!==null&&clearTimeout(a),a=null,d!==null&&c(null))},report(){return n===void 0?void 0:{nonce:n.nonce,rendered:[...i]}}}}var M=1;function Ke(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function zt(r,e={}){let t=e.createDetector??R,n=null;r.onmessage=i=>{let a=i.data;if(a.v!==M){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(s=>{n=s;let o={v:M,type:"ready",tier:s.tier,...s.fallbackReason!==void 0?{fallbackReason:s.fallbackReason}:{}};r.postMessage(o)});return}if(a.type==="detect"){let s=o=>{let l={v:M,type:"result",id:a.id,observation:o};r.postMessage(l),a.bitmap.close?.()};if(n===null){s(null);return}n.detect(a.bitmap,a.streamWidth,a.streamHeight).then(s,()=>s(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&zt(self);var Y=class r{constructor(e,t){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",n=>{let i=n.data;if(i.v!==M||i.type!=="result")return;let a=this.pending.get(i.id);this.pending.delete(i.id),a?.(i.observation)})}static create(e,t,n=1e4){return new Promise((i,a)=>{let s=setTimeout(()=>{e.removeEventListener("message",o),e.terminate(),a(new Error(`worker detector not ready within ${n}ms`))},n),o=d=>{let c=d.data;c.v!==M||c.type!=="ready"||(clearTimeout(s),e.removeEventListener("message",o),i(new r(e,c)))};e.addEventListener("message",o);let l={v:M,type:"init",options:t};e.postMessage(l)})}async detect(e,t,n){let i;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i=e:typeof createImageBitmap=="function"?i=await createImageBitmap(e):i=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(s=>{this.pending.set(a,s);let o={v:M,type:"detect",id:a,bitmap:i,streamWidth:t,streamHeight:n};this.worker.postMessage(o,[i])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var Xt=["size","centering","pose","exposure","sharpness","motion"];function Ue(r){if(r.accepted)return null;if(r.factors.presence<=0)return"no_face";let e="size";for(let t of Xt)r.factors[t]<r.factors[e]&&(e=t);return e}var D=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let n=Ue(e);if(n===null){this.acceptedMs+=t;return}let i=this.blocked[n]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[n]=i}summary(){let e={};for(let[t,n]of Object.entries(this.blocked))e[t]={count:n.count,ms:Math.round(n.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var tt=1e3,Q="fcv3.hold_upright",rt=200,j=4,nt=600,it=1e3,Je={sharpness:1,exposure:1,meanLuma:128};function Jt(r,e){return e.width=r.videoWidth,e.height=r.videoHeight,e.getContext("2d").drawImage(r,0,0),new Promise((t,n)=>e.toBlob(i=>i?t(i):n(new Error("empty-keyframe")),"image/jpeg",.92))}function er(){return K()==="phone"}var ye=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(t),()=>n?.delete(t)}emit(e,t){for(let n of[...this.handlers.get(e)??[]])n(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??er)(),this.setState("preflight");let n=re();if(n!=="OK"){this.fail(n==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(d=>navigator.mediaDevices.getUserMedia(d)),a;this.cameraRequestedAt=this.now();try{a=await i(ae(se(),this.facing))}catch(d){if(e!==this.attempt)return;this.fail(te(d));return}if(Le(a),e!==this.attempt){for(let d of a.getTracks())d.stop();return}this.stream=a;let s=a.getVideoTracks?.()[0];if(this.trackProvenance=s===void 0?null:Ge(s).catch(()=>null),this.facing=oe(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let d={v3AssetBaseUrl:t.v3AssetBaseUrl},c=t.createDetector??(t.createWorker!==void 0&&Ke()?async()=>{try{return await Y.create(t.createWorker(),d)}catch{return R(d)}}:()=>R(d)),u;try{u=await c()}catch(m){e===this.attempt&&this.fail("models",m instanceof C?m.fallbackReason:rr(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let o=de(),l=t.deviceClass??me(o);this.profiler=new N(l),this.options.telemetry?.({type:"profile",staticClass:l,activeClass:this.profiler.deviceClass,simd:o.simd}),this.gate=new w(t.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&Promise.resolve().then(()=>($e(),je)).then(d=>ge=d,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let n=new G({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=n,n.start()}async detectTick(e){let{detector:t,gate:n,profiler:i}=this,a=this.options.video;if(e!==this.attempt||t===null||n===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let s=i.deviceClass,o=this.now(),l=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),d=null;try{d=await t.detect(l,a.videoWidth,a.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-o),i.deviceClass!==s&&this.startScheduler(e);let c=d===null?Je:this.options.measureQuality?.(a,d.box)??this.defaultQuality(a,d.box),u=n.tick({timestampMs:this.now(),observation:d,quality:c,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=tt&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,n=this.scheduler;n?.stop(),this.reportGate(!0);let i=n?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((y,S)=>y+S,0)/a.length});let s=t.mode??"clip",o=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let y=this.watchRotation(e,null),S=await o;if(y(),e!==this.attempt)return;if(S===null){this.fail("generic");return}let at=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:S.blob,previewDataUrl:S.previewDataUrl,...at});return}this.setState("recording");let l=t.createRecorder?.()??new P,d=this.stream;if(d===null){this.fail("generic");return}let c=Ve(t.video),u=t.screenRamp?.(),m=u!==void 0,f=He(u,{paint:y=>{(y===null||e===this.attempt)&&this.emit("ramp",{colour:y})},now:()=>this.now(),frames:c.latest});this.ramp=f;let p=()=>{c.stop(),f.stop(),this.ramp===f&&(this.ramp=null)},h=this.watchRotation(e,l),g=null;o.then(y=>{g=y},()=>{});let E=()=>{e===this.attempt&&g!==null&&this.emit("frozen",{previewDataUrl:g.previewDataUrl})},v,_;try{[v,_]=await Promise.all([l.record(d,E,()=>f.started(this.now())),o])}catch(y){if(h(),p(),e!==this.attempt)return;let S=y.kind;this.fail(S==="cliptoolarge"?"cliptoolarge":"recorder");return}h();let k=c.stats();if(p(),e!==this.attempt)return;if(A(v.blob)){this.fail("cliptoolarge");return}if(_===null){this.fail("generic");return}let I=f.report(),$=await this.provenance(k,m);e===this.attempt&&this.finishCapture({clip:v.blob,clipMimeType:v.mimeType,keyframe:_.blob,previewDataUrl:_.previewDataUrl,...I!==void 0&&I.rendered.length>0?{screenRamp:I}:{},...$})}async provenance(e,t){let n=this.trackProvenance;if(n===null)return{};let i,a=new Promise(o=>{i=setTimeout(()=>o(null),it)}),s=await Promise.race([n,a]);return clearTimeout(i),s===null?{}:{provenance:We(s,e,t)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==Q&&(this.lastGuidanceKey=Q,this.emit("guidance",{key:Q}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let n=this.options.video,i=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){o();return}n.videoWidth>0&&this.isLandscape()&&(o(),this.abortRecording(e,t))},a=setInterval(i,rt);n.addEventListener?.("resize",i);let s=!1;function o(){s||(s=!0,clearInterval(a),n.removeEventListener?.("resize",i))}return o}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let n=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new w(this.options.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(n),this.startScheduler(n)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),n=nt/(j-1),i=null;for(let a=0;a<j;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<j-1&&await tr(n)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(n,i,a)=>{i!==null&&a!==null&&(e[n]=Math.max(0,Math.round(a-i)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),n=await(this.facing==="user"?ne:Jt)(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:n,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let n=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),o=n.getContext("2d");return o===null?e:(n.width!==a&&(n.width=a),n.height!==s&&(n.height=s),o.drawImage(e,0,0,a,s),this.snapshotCanvas=n,n)}catch{return e}}defaultQuality(e,t){let n=et(e,t,96);return n===null?Je:{sharpness:q(n),exposure:le(n),meanLuma:X(n)}}centerSharpness(e){let t=T(e),n=et(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return n===null?0:q(n)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,n=this.profiler;if(t===null||n===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:n.deviceClass,cadenceHz:n.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},ge;function tr(r){return new Promise(e=>setTimeout(e,r))}function rr(r){return r instanceof Error?r.message:String(r)}function et(r,e,t){try{let n=document.createElement("canvas"),i=t/Math.max(1,e.width);n.width=Math.max(1,Math.round(e.width*i)),n.height=Math.max(1,Math.round(e.height*i));let a=n.getContext("2d");return a===null?null:(a.drawImage(r,e.x,e.y,e.width,e.height,0,0,n.width,n.height),a.getImageData(0,0,n.width,n.height))}catch{return null}}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,EXPOSURE_BAND,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SHARP_REF,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});
|
|
1
|
+
"use strict";var st=Object.create;var V=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var dt=(r,e)=>()=>(r&&(e=r(r=0)),e);var be=(r,e)=>{for(var t in e)V(r,t,{get:e[t],enumerable:!0})},ve=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ct(e))!ut.call(r,i)&&i!==t&&V(r,i,{get:()=>e[i],enumerable:!(n=ot(e,i))||n.enumerable});return r};var mt=(r,e,t)=>(t=r!=null?st(lt(r)):{},ve(e||!r||!r.__esModule?V(t,"default",{value:r,enumerable:!0}):t,r)),pt=r=>ve(V({},"__esModule",{value:!0}),r);var je={};be(je,{RANK_CANDIDATES:()=>qt,RANK_TOLERANCE:()=>Z,RANK_WINDOW_MS:()=>Yt,ROLL_ZERO_DEG:()=>Qt,SHARPNESS_REPORT_MAX:()=>Ze,YAW_REPORT_MAX:()=>Ye,YAW_ZERO_IOD:()=>Zt,collectRankedKeyframes:()=>Qe,default:()=>$t,featuresOf:()=>Xe,frontalOf:()=>ze,rankKeyframes:()=>qe});function ze(r){let e=r.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let t=e.right.x-e.left.x,n=e.right.y-e.left.y,i=t*t+n*n;if(i===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(n,Math.abs(t))*180/Math.PI),s=Be(1-a/30),o=null,l=r.nose;if(l!==void 0){let d=(e.left.x+e.right.x)/2,c=(e.left.y+e.right.y)/2;o=Math.abs(((l.x-d)*t+(l.y-c)*n)/i),s*=Be(1-o/.5)}return{frontal:s,yaw:o,roll:a}}function Xe(r,e){return r===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...ze(r),eyes:null,score:r.score,sharpness:e}}function qe(r){let e=r.map((i,a)=>a),t=(i,a)=>{let s=Number.NEGATIVE_INFINITY;for(let o of e)s=Math.max(s,i(r[o]));e=e.filter(o=>i(r[o])>=s-a)};t(i=>i.frontal,Z.frontal),t(i=>i.eyes??1,Z.eyes),t(i=>i.score,Z.score);let n=-1;for(let i of e)(n===-1||r[i].sharpness>r[n].sharpness)&&(n=i);return n}function jt(r){return{face:r.face,frontal:O(r.frontal),...r.yaw!==null?{yaw:Math.min(O(r.yaw),Ye)}:{},...r.roll!==null?{roll:O(r.roll)}:{},...r.eyes!==null?{eyes:O(r.eyes)}:{},score:O(r.score),sharpness:Math.min(O(r.sharpness),Ze)}}async function Qe(r,e){let{options:t}=r,n=t.video,i=t.now??(()=>performance.now()),a=t.captureKeyframe??(m=>r.defaultKeyframe(m)),s=600/3,o=[],l=[],d=0;for(let m=0;m<4;m+=1){if(e!==r.attempt)return null;let f=r.detector,p=Promise.resolve(null),h,g=0;try{if(f!==null){let k=r.profiler?.profile.inputWidth??160,I=t.makeSnapshot?.(n,k)??r.defaultSnapshot(n,k);h=a(n).then(y=>(g=i(),y));let $=i();p=f.detect(I,n.videoWidth,n.videoHeight).then(y=>(d+=i()-$,y),()=>null)}else h=a(n).then(k=>(g=i(),k));let[v,_]=await Promise.all([h,p]);o.push(v),l.push(Xe(_,v.sharpness))}catch{h?.catch(()=>{})}let E=g>0?Math.max(0,i()-g):0;m<3&&await new Promise(v=>setTimeout(v,Math.max(0,s-E)))}if(e!==r.attempt)return null;let c=qe(l);if(c===-1)return null;let u=0;l.forEach((m,f)=>{m.sharpness>l[u].sharpness&&(u=f)});try{t.telemetry?.({type:"keyframe",tier:r.detector?.tier??null,chosen:c,sharpest:u,detectMs:Math.round(d),candidates:l.map(jt)})}catch{}return o[c]??null}var qt,Yt,Zt,Qt,Z,Be,O,Ye,Ze,$t,$e=dt(()=>{"use strict";qt=4,Yt=600,Zt=.5,Qt=30,Z={frontal:.1,eyes:.1,score:.05},Be=r=>r<0?0:r>1?1:r;O=r=>Number.isFinite(r)?Math.round(r*1e3)/1e3:0,Ye=99,Ze=999999;$t=Qe});var nr={};be(nr,{CENTERED_FACTOR:()=>Mt,CIRCLE_RADIUS_FACTOR:()=>Et,CLIP_MS:()=>Se,CaptureSessionV3:()=>ye,ClipError:()=>b,ClipRecorder:()=>P,DEFAULT_CLIP_MIME:()=>W,DEFAULT_TIER_ORDER:()=>xe,DEFAULT_V3_ASSET_BASE_URL:()=>Re,DEVICE_PROFILES:()=>Oe,DetectScheduler:()=>G,DetectorLadderError:()=>C,DeviceProfiler:()=>N,EXPOSURE_BAND:()=>L,FaceGateV3:()=>w,GATE_SNAPSHOT_MS:()=>tt,GateBlockStats:()=>D,HOLD_UPRIGHT_KEY:()=>Q,IN_CIRCLE_FACTOR:()=>St,KEYFRAME_CANDIDATES:()=>j,KEYFRAME_WINDOW_MS:()=>nt,MAX_CLIP_BYTES:()=>H,MIME_CANDIDATES:()=>Ee,PHONE_MAX_SHORT_SIDE:()=>ke,PROVENANCE_WAIT_MS:()=>it,SHARP_REF:()=>br,STOP_GRACE_MS:()=>_e,TIMESLICE_MS:()=>Me,UPRIGHT_WATCH_MS:()=>rt,V3_GATE_DEFAULTS:()=>De,VIDEO_BPS:()=>ie,blockReasonOf:()=>Ue,buildCaptureConstraints:()=>ae,buildLivenessV2FormData:()=>ht,cameraPreflight:()=>re,captureMirroredKeyframe:()=>ne,classifyDevice:()=>me,createDetector:()=>R,detectFormFactor:()=>K,detectIsMobile:()=>se,errorCopy:()=>gt,exposure:()=>le,extForMime:()=>J,intrinsicSize:()=>T,isClipTooLarge:()=>A,isMediaRecorderSupported:()=>ft,mapGetUserMediaError:()=>te,meanLuma:()=>X,pickMimeType:()=>ee,probeDevice:()=>de,sharpness:()=>q,toStreamPixels:()=>F,trackFacingMode:()=>oe,uiCopy:()=>yt});module.exports=pt(nr);var Ee=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function ee(){let r=globalThis.MediaRecorder;return!r||typeof r.isTypeSupported!="function"?"":Ee.find(e=>r.isTypeSupported(e))??""}var W="video/webm";function te(r){if(r instanceof TypeError)return"insecure";switch(r?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function re(){let r=globalThis;if(typeof r.window<"u"&&r.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=r.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function ft(){let r=globalThis.MediaRecorder;return typeof r<"u"&&typeof r.isTypeSupported=="function"}var H=8*1024*1024;function A(r){return r.size>H}function J(r){let e=(r||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function ht(r){let{token:e,clip:t,keyframe:n}=r,i=r.ts??Date.now(),a=t.type||W,s=n.type||"image/jpeg",o=new FormData;return o.append("token",e),o.append("clip",new File([t],`liveness-${i}.${J(a)}`,{type:a})),o.append("keyframe",new File([n],`keyframe-${i}.${J(s)}`,{type:s})),o}function ne(r,e,t=.92){return new Promise((n,i)=>{let a=r.videoWidth,s=r.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){i(new Error("no-2d-context"));return}e.width=a,e.height=s,o.scale(-1,1),o.drawImage(r,-a,0),e.toBlob(l=>l?n(l):i(new Error("empty-keyframe")),"image/jpeg",t)})}var gt={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},yt={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Se=2500,Me=1e3,_e=1500,ie=25e5,b=class extends Error{constructor(e,t){super(t??e),this.kind=e}},P=class{constructor(){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.settled=!1}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.hardStopTimer=null,this.graceTimer=null}record(e,t,n){if(this.recorder&&!this.settled)return Promise.reject(new b("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time"));this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e;let i=ee();return new Promise((a,s)=>{let o;try{o=new MediaRecorder(e,i?{mimeType:i,videoBitsPerSecond:ie}:{videoBitsPerSecond:ie})}catch{try{o=new MediaRecorder(e)}catch{s(new b("unsupported"));return}}this.recorder=o;let l=c=>{this.settled||(this.settled=!0,this.clearTimers(),c())},d=()=>l(()=>{let c=o.mimeType||i||W,u=new Blob(this.chunks,{type:c});if(u.size===0){s(new b("generic","empty clip"));return}if(A(u)){s(new b("cliptoolarge"));return}a({blob:u,mimeType:c})});if(o.ondataavailable=c=>{c.data&&c.data.size&&(this.chunks.push(c.data),this.bytes+=c.data.size,this.bytes>H&&l(()=>{try{o.state!=="inactive"&&o.stop()}catch{}s(new b("cliptoolarge"))}))},o.onstop=d,o.onerror=()=>l(()=>s(new b("generic"))),n!==void 0){let c=!1;o.onstart=()=>{if(!(c||this.settled)){c=!0;try{n()}catch{}}}}try{o.start(Me)}catch{l(()=>s(new b("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),o.state!=="inactive"){try{o.stop()}catch{d()}this.graceTimer=setTimeout(d,_e)}else d()},Se)})}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};function ae(r,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var ke=600;function K(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let r=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(r))return"phone";if(/iPad/i.test(r))return"tablet";if(/Android/i.test(r))return/Mobile/i.test(r)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(r))return"phone";if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(r))return"tablet";if(!vt())return"desktop";let t=bt();return t>0&&t<ke?"phone":"tablet"}function se(){return K()!=="desktop"}function bt(){try{let r=window.screen,e=Number(r?.width??0),t=Number(r?.height??0);return e>0&&t>0?Math.min(e,t):0}catch{return 0}}function oe(r){try{let t=r?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return t==="user"||t==="environment"?t:null}catch{return null}}function vt(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Et=.45,St=.9,Mt=.4;var Te=1e4,U=class r{constructor(e,t){this.tier="blaze";this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let n=await import("@mediapipe/tasks-vision"),i=await n.FilesetResolver.forVisionTasks(e),a=await n.FaceDetector.createFromOptions(i,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new r(a,t)}async detect(e,t,n){let i;try{i=this.inner.detect(e).detections}catch{return null}let a=_t(i);if(a?.boundingBox===void 0)return null;let s=T(e),o=kt(a.keypoints,s),l=a.keypoints?.[2],d={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...o!==void 0?{eyes:o}:{},...l!==void 0?{nose:{x:l.x*s.width,y:l.y*s.height}}:{},score:a.categories[0]?.score??0};return F(d,e,t,n)}destroy(){try{this.inner.close()}catch{}}};function _t(r){let e,t=-1;for(let n of r){let i=n.categories[0]?.score??0;i>t&&(e=n,t=i)}return e}function kt(r,e){let t=r?.[0],n=r?.[1];if(t===void 0||n===void 0)return;let i=o=>({x:o.x*e.width,y:o.y*e.height}),[a,s]=[i(t),i(n)];return a.x<=s.x?{left:a,right:s}:{left:s,right:a}}function Tt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let r=document.createElement("canvas");return r.width=2,r.height=2,r}async function Ce(){let r=globalThis.FaceDetector;if(typeof r!="function")return{ok:!1,reason:"unsupported"};try{let e=new r({fastMode:!0,maxDetectedFaces:1});return await e.detect(Tt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var B=class{constructor(e,t){this.tier="native";this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,n){let i;try{i=await this.inner.detect(e)}catch{return null}let a=i[0];if(a===void 0)return null;let s=Ct(a.landmarks),o={box:{x:a.boundingBox.x,y:a.boundingBox.y,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},score:1};return F(o,e,t,n)}destroy(){}};function Ct(r){if(r===void 0)return;let e=r.filter(i=>i.type==="eye").map(i=>i.locations[0]).filter(i=>i!==void 0),[t,n]=e;if(!(t===void 0||n===void 0))return t.x<=n.x?{left:t,right:n}:{left:n,right:t}}var Re="/models-v3",xe=["native","blaze"],C=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function T(r){let e=r;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,n=typeof e.height=="number"?e.height:0;return{width:t,height:n}}function F(r,e,t,n){let i=T(e),a=i.width>0?t/i.width:1,s=i.height>0?n/i.height:1,o=l=>({x:l.x*a,y:l.y*s});return{box:{x:r.box.x*a,y:r.box.y*s,width:r.box.width*a,height:r.box.height*s},...r.eyes!==void 0?{eyes:{left:o(r.eyes.left),right:o(r.eyes.right)}}:{},...r.nose!==void 0?{nose:o(r.nose)}:{},score:r.score}}function Rt(r){return r instanceof Error?r.message:String(r)}async function R(r){let e=r.preferred??xe,t=[];for(let n of e){if(n==="native"){let i=await Ce();if(i.ok)return new B(i.instance,ce(t));t.push(`native:${i.reason}`);continue}try{return await xt(U.create(r.v3AssetBaseUrl??Re,ce(t)),r.blazeInitTimeoutMs??Te)}catch(i){t.push(i instanceof z?"blaze:blaze_init_timeout":`blaze:${Rt(i)}`)}}throw new C(ce(t)??"no_tier_available")}function ce(r){return r.length>0?r.join("; "):void 0}var z=class extends Error{};function xt(r,e){return new Promise((t,n)=>{let i=setTimeout(()=>{n(new z(`init exceeded ${e}ms`)),r.then(a=>a.destroy(),()=>{})},e);r.then(a=>{clearTimeout(i),t(a)},a=>{clearTimeout(i),n(a)})})}var br=180,L=[100,190],wt=64;function we(r,e){return .299*(r[e]??0)+.587*(r[e+1]??0)+.114*(r[e+2]??0)}function X(r){let{data:e,width:t,height:n}=r,i=t*n;if(i===0)return 0;let a=0;for(let s=0;s<i;s+=1)a+=we(e,s*4);return a/i}function q(r){let{data:e,width:t,height:n}=r;if(t<3||n<3)return 0;let i=new Float32Array(t*n);for(let c=0;c<i.length;c+=1)i[c]=we(e,c*4);let a=0,s=0,o=0;for(let c=1;c<n-1;c+=1)for(let u=1;u<t-1;u+=1){let m=c*t+u,f=(i[m-t]??0)+(i[m-1]??0)+(i[m+1]??0)+(i[m+t]??0)-4*(i[m]??0);a+=f,s+=f*f,o+=1}if(o===0)return 0;let l=a/o,d=s/o-l*l;return Math.min(1,Math.max(0,d)/180)}function le(r){let e=X(r),[t,n]=L,i=e<t?t-e:e>n?e-n:0;return Math.max(0,1-i/wt)}var De=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),x=r=>Math.min(1,Math.max(0,r)),w=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...De,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:n,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,centering:0,size:0,pose:0,sharpness:x(n.sharpness),exposure:x(n.exposure),motion:1};if(t!==null){s.presence=1;let c=this.geometryOf(t,e);s.centering=c.centering,s.size=c.size,s.pose=c.pose,s.motion=this.motionOf(c.center,c.iod,i)}else this.lastCenter=null,this.velocityEma=0;let o=Math.min(s.presence,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=x(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*a),this.qWindow.push({at:i,q:o}),this.qWindow=this.qWindow.filter(c=>c.at>=i-this.t.READY_WINDOW_MS);let l=this.qWindow.map(c=>c.q);if(l.length>=3){let c=Math.min(...l),u=l.indexOf(c);l=l.filter((m,f)=>f!==u)}let d=this.p>=1&&l.every(c=>c>=this.t.Q_GOOD);return{at:i,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,n,o),ready:d,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:n,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),o=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:n.x+n.width/2,y:n.y+n.height/2-this.t.BOX_EYE_OFFSET_FACTOR*n.height},l=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*n.width,d=Math.hypot(o.x-a.x,o.y-a.y),c=l<=0?0:1-x(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*l)),u=s>0?l/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let f=1;if(i!==void 0){let p=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;f=1-x(p/this.t.ROLL_MAX_DEG)}return{center:o,iod:l,centering:c,size:m,pose:f}}motionOf(e,t,n){let i=this.lastCenter;if(this.lastCenter={...e,at:n},i===null||t<=0)return 1;let a=(n-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-x(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,n){if(e.presence<=0)return"fcv3.no_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(n<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let s of i)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(L[0]+L[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var Oe=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),Dt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function de(){let r=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(Dt)}catch{e=!1}return{cores:r?.hardwareConcurrency??2,memGB:r?.deviceMemory??null,simd:e}}function me(r){let e=r.memGB??4;return r.cores<4||e<3?"LOW":r.cores>=8&&e>=6?"HIGH":"MID"}var ue=["LOW","MID","HIGH"],N=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return Oe[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let t=this.samples.reduce((n,i)=>n+i,0)/this.samples.length;if(t>70)this.current="LOW";else if(t<25){let n=ue.indexOf(this.current);this.current=ue[Math.min(ue.length-1,n+1)]??this.current}return this.current}};var G=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,n)=>t+n,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var Ie="0.1.0-rc.13";var Ae="sekyro.did",Pe;function Fe(){let r=globalThis.crypto;try{if(typeof r?.randomUUID=="function")return r.randomUUID()}catch{}try{if(typeof r?.getRandomValues=="function"){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}}catch{}}function Ot(){try{let r=localStorage.getItem(Ae);if(r)return r;let e=Fe();return e!==void 0&&localStorage.setItem(Ae,e),e}catch{return Pe??(Pe=Fe()),Pe}}async function It(){let r=globalThis.crypto?.subtle;if(!r)return"";let e=navigator,t=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await r.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function At(r){let e=new TextEncoder().encode(r),t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Pt(r){let e,t;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{t??(t=It().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await t,a=Ot(),s={v:1,platform:"web",sdk:r.sdk.slice(0,64),ids:[...a?[{kind:"web_local",value:a.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return At(JSON.stringify(s))}catch{return}}}}var pe=Symbol.for("sekyro.web.clientContext"),fe=globalThis,Ft=fe[pe]??(fe[pe]=Pt({sdk:`@sekyro/web@${Ie}`}));function Le(r){try{let e=r.getVideoTracks?.()[0];e&&Ft.noteCameraLabel(e.label)}catch{}}var Lt=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],Nt=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function Gt(r){let e=(r??"").trim().toLowerCase();return e.length===0?"unknown":Lt.some(t=>e.includes(t))?"known_virtual":Nt.some(t=>t.test(e))?"platform":"unknown"}function Ne(r){if(typeof r!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(r))}catch{return!1}}function Vt(r=globalThis){return Ne(r.navigator?.mediaDevices?.getUserMedia)&&Ne(r.MediaStreamTrack?.prototype?.getSettings)}async function Wt(r,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let n=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(r)));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Ge(r,e=globalThis){let t={};try{t=typeof r.getSettings=="function"?r.getSettings()??{}:{}}catch{t={}}let n={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(n.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(n.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(n.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(n.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await Wt(t.deviceId,e);a!==void 0&&(n.deviceIdHash=a)}let i;try{i=r.label}catch{i=void 0}return{trackSettings:n,capabilitiesPresent:typeof r.getCapabilities=="function",labelClass:Gt(i),prototypesIntact:Vt(e)}}var he=r=>Math.round(r*100)/100;function Ve(r){let e=r,t=typeof e?.requestVideoFrameCallback=="function",n=null,i=null,a=0,s=0,o=0,l=0,d=0,c=0,u=()=>{!t||e?.requestVideoFrameCallback===void 0||(n=e.requestVideoFrameCallback((m,f)=>{if(n=null,!t)return;let p=f.presentationTime;if(i!==null){let h=p-i.presentationTimeMs;s+=1;let g=h-o;o+=g/s,l+=g*(h-o)}typeof f.captureTime=="number"&&Number.isFinite(f.captureTime)&&(d+=p-f.captureTime,c+=1),a+=1,i={mediaTimeMs:f.mediaTime*1e3,presentationTimeMs:p},u()}))};return u(),{latest:()=>i,stats:()=>({n:a,meanGapMs:s===0?0:he(o),stdGapMs:s<2?0:he(Math.sqrt(l/(s-1))),captureLatencyMs:c===0?null:he(d/c)}),stop:()=>{t&&(t=!1,n!==null&&e?.cancelVideoFrameCallback?.(n),n=null)}}}function We(r,e,t){return{...r,rvfc:e,rampPainter:t}}var Ht=["rose","peach","sand","mint","sky","lilac"];var Kt=4,Ut=4;function Bt(r){if(typeof r!="object"||r===null)return!1;let e=r;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length!==3||!e.colours.every(n=>Ht.includes(n))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==3)return!1;let t=-1;for(let n of e.onsetsMs){if(typeof n!="number"||!Number.isFinite(n)||n<=t||n>=2e3)return!1;t=n}return!0}function He(r,e){let t=e.now??(()=>performance.now()),n=Bt(r)?r:void 0,i=[],a=null,s=null,o=null,l=!1,d=null,c=p=>{d=p;try{e.paint(p)}catch{}},u=p=>{let h=e.frames?.()??null;return h!==null&&o!==null?h.mediaTimeMs+(p-h.presentationTimeMs)-o:p-(s??p)},m=(p,h,g=0)=>{if(l)return;let E=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!l){if(g<Kt&&u(t())<p-Ut){m(p,h,g+1);return}h()}},E)},f=p=>{if(n!==void 0){if(p>=3){m(2e3,()=>c(null));return}m(n.onsetsMs[p],()=>{let h=u(t());if(h>2e3){d!==null&&c(null);return}let g=n.colours[p];c(g);let E=i.length===0?0:i[i.length-1].tMs;i.push({tMs:Math.max(E,Math.round(h)),colour:g}),f(p+1)})}};return{started(p){if(n===void 0||l||s!==null)return;s=p;let h=e.frames?.()??null;o=h===null?null:h.mediaTimeMs+(p-h.presentationTimeMs),f(0)},stop(){l||(l=!0,a!==null&&clearTimeout(a),a=null,d!==null&&c(null))},report(){return n===void 0?void 0:{nonce:n.nonce,rendered:[...i]}}}}var M=1;function Ke(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function zt(r,e={}){let t=e.createDetector??R,n=null;r.onmessage=i=>{let a=i.data;if(a.v!==M){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(s=>{n=s;let o={v:M,type:"ready",tier:s.tier,...s.fallbackReason!==void 0?{fallbackReason:s.fallbackReason}:{}};r.postMessage(o)});return}if(a.type==="detect"){let s=o=>{let l={v:M,type:"result",id:a.id,observation:o};r.postMessage(l),a.bitmap.close?.()};if(n===null){s(null);return}n.detect(a.bitmap,a.streamWidth,a.streamHeight).then(s,()=>s(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&zt(self);var Y=class r{constructor(e,t){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",n=>{let i=n.data;if(i.v!==M||i.type!=="result")return;let a=this.pending.get(i.id);this.pending.delete(i.id),a?.(i.observation)})}static create(e,t,n=1e4){return new Promise((i,a)=>{let s=setTimeout(()=>{e.removeEventListener("message",o),e.terminate(),a(new Error(`worker detector not ready within ${n}ms`))},n),o=d=>{let c=d.data;c.v!==M||c.type!=="ready"||(clearTimeout(s),e.removeEventListener("message",o),i(new r(e,c)))};e.addEventListener("message",o);let l={v:M,type:"init",options:t};e.postMessage(l)})}async detect(e,t,n){let i;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i=e:typeof createImageBitmap=="function"?i=await createImageBitmap(e):i=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(s=>{this.pending.set(a,s);let o={v:M,type:"detect",id:a,bitmap:i,streamWidth:t,streamHeight:n};this.worker.postMessage(o,[i])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var Xt=["size","centering","pose","exposure","sharpness","motion"];function Ue(r){if(r.accepted)return null;if(r.factors.presence<=0)return"no_face";let e="size";for(let t of Xt)r.factors[t]<r.factors[e]&&(e=t);return e}var D=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let n=Ue(e);if(n===null){this.acceptedMs+=t;return}let i=this.blocked[n]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[n]=i}summary(){let e={};for(let[t,n]of Object.entries(this.blocked))e[t]={count:n.count,ms:Math.round(n.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var tt=1e3,Q="fcv3.hold_upright",rt=200,j=4,nt=600,it=1e3,Je={sharpness:1,exposure:1,meanLuma:128};function Jt(r,e){return e.width=r.videoWidth,e.height=r.videoHeight,e.getContext("2d").drawImage(r,0,0),new Promise((t,n)=>e.toBlob(i=>i?t(i):n(new Error("empty-keyframe")),"image/jpeg",.92))}function er(){return K()==="phone"}var ye=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(t),()=>n?.delete(t)}emit(e,t){for(let n of[...this.handlers.get(e)??[]])n(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??er)(),this.setState("preflight");let n=re();if(n!=="OK"){this.fail(n==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(d=>navigator.mediaDevices.getUserMedia(d)),a;this.cameraRequestedAt=this.now();try{a=await i(ae(se(),this.facing))}catch(d){if(e!==this.attempt)return;this.fail(te(d));return}if(Le(a),e!==this.attempt){for(let d of a.getTracks())d.stop();return}this.stream=a;let s=a.getVideoTracks?.()[0];if(this.trackProvenance=s===void 0?null:Ge(s).catch(()=>null),this.facing=oe(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let d={v3AssetBaseUrl:t.v3AssetBaseUrl},c=t.createDetector??(t.createWorker!==void 0&&Ke()?async()=>{try{return await Y.create(t.createWorker(),d)}catch{return R(d)}}:()=>R(d)),u;try{u=await c()}catch(m){e===this.attempt&&this.fail("models",m instanceof C?m.fallbackReason:rr(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let o=de(),l=t.deviceClass??me(o);this.profiler=new N(l),this.options.telemetry?.({type:"profile",staticClass:l,activeClass:this.profiler.deviceClass,simd:o.simd}),this.gate=new w(t.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&Promise.resolve().then(()=>($e(),je)).then(d=>ge=d,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let n=new G({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=n,n.start()}async detectTick(e){let{detector:t,gate:n,profiler:i}=this,a=this.options.video;if(e!==this.attempt||t===null||n===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let s=i.deviceClass,o=this.now(),l=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),d=null;try{d=await t.detect(l,a.videoWidth,a.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-o),i.deviceClass!==s&&this.startScheduler(e);let c=d===null?Je:this.options.measureQuality?.(a,d.box)??this.defaultQuality(a,d.box),u=n.tick({timestampMs:this.now(),observation:d,quality:c,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=tt&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,n=this.scheduler;n?.stop(),this.reportGate(!0);let i=n?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((y,S)=>y+S,0)/a.length});let s=t.mode??"clip",o=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let y=this.watchRotation(e,null),S=await o;if(y(),e!==this.attempt)return;if(S===null){this.fail("generic");return}let at=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:S.blob,previewDataUrl:S.previewDataUrl,...at});return}this.setState("recording");let l=t.createRecorder?.()??new P,d=this.stream;if(d===null){this.fail("generic");return}let c=Ve(t.video),u=t.screenRamp?.(),m=u!==void 0,f=He(u,{paint:y=>{(y===null||e===this.attempt)&&this.emit("ramp",{colour:y})},now:()=>this.now(),frames:c.latest});this.ramp=f;let p=()=>{c.stop(),f.stop(),this.ramp===f&&(this.ramp=null)},h=this.watchRotation(e,l),g=null;o.then(y=>{g=y},()=>{});let E=()=>{e===this.attempt&&g!==null&&this.emit("frozen",{previewDataUrl:g.previewDataUrl})},v,_;try{[v,_]=await Promise.all([l.record(d,E,()=>f.started(this.now())),o])}catch(y){if(h(),p(),e!==this.attempt)return;let S=y.kind;this.fail(S==="cliptoolarge"?"cliptoolarge":"recorder");return}h();let k=c.stats();if(p(),e!==this.attempt)return;if(A(v.blob)){this.fail("cliptoolarge");return}if(_===null){this.fail("generic");return}let I=f.report(),$=await this.provenance(k,m);e===this.attempt&&this.finishCapture({clip:v.blob,clipMimeType:v.mimeType,keyframe:_.blob,previewDataUrl:_.previewDataUrl,...I!==void 0&&I.rendered.length>0?{screenRamp:I}:{},...$})}async provenance(e,t){let n=this.trackProvenance;if(n===null)return{};let i,a=new Promise(o=>{i=setTimeout(()=>o(null),it)}),s=await Promise.race([n,a]);return clearTimeout(i),s===null?{}:{provenance:We(s,e,t)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==Q&&(this.lastGuidanceKey=Q,this.emit("guidance",{key:Q}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let n=this.options.video,i=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){o();return}n.videoWidth>0&&this.isLandscape()&&(o(),this.abortRecording(e,t))},a=setInterval(i,rt);n.addEventListener?.("resize",i);let s=!1;function o(){s||(s=!0,clearInterval(a),n.removeEventListener?.("resize",i))}return o}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let n=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new w(this.options.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(n),this.startScheduler(n)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),n=nt/(j-1),i=null;for(let a=0;a<j;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<j-1&&await tr(n)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(n,i,a)=>{i!==null&&a!==null&&(e[n]=Math.max(0,Math.round(a-i)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),n=await(this.facing==="user"?ne:Jt)(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:n,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let n=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),o=n.getContext("2d");return o===null?e:(n.width!==a&&(n.width=a),n.height!==s&&(n.height=s),o.drawImage(e,0,0,a,s),this.snapshotCanvas=n,n)}catch{return e}}defaultQuality(e,t){let n=et(e,t,96);return n===null?Je:{sharpness:q(n),exposure:le(n),meanLuma:X(n)}}centerSharpness(e){let t=T(e),n=et(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return n===null?0:q(n)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,n=this.profiler;if(t===null||n===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:n.deviceClass,cadenceHz:n.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},ge;function tr(r){return new Promise(e=>setTimeout(e,r))}function rr(r){return r instanceof Error?r.message:String(r)}function et(r,e,t){try{let n=document.createElement("canvas"),i=t/Math.max(1,e.width);n.width=Math.max(1,Math.round(e.width*i)),n.height=Math.max(1,Math.round(e.height*i));let a=n.getContext("2d");return a===null?null:(a.drawImage(r,e.x,e.y,e.width,e.height,0,0,n.width,n.height),a.getImageData(0,0,n.width,n.height))}catch{return null}}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,EXPOSURE_BAND,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SHARP_REF,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CameraErrorKind } from '../capture-session-v3-
|
|
2
|
-
export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GATE_SNAPSHOT_MS, u as GateBlockEntry, v as GateBlockReason, w as GateBlockStats, x as GateBlockSummary, y as GateChecks, H as HOLD_UPRIGHT_KEY, K as KEYFRAME_CANDIDATES, z as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, A as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, B as V3GateFactor, I as V3GateQuality, J as V3GateThresholds, L as V3GateTick, N as V3GateTickInput, O as V3TelemetryEvent, Q as V3_GATE_DEFAULTS, R as VIDEO_BPS, W as blockReasonOf, X as buildLivenessV2FormData, Y as cameraPreflight, Z as classifyDevice, _ as extForMime, $ as isClipTooLarge, a0 as isMediaRecorderSupported, a1 as mapGetUserMediaError, a2 as pickMimeType, a3 as probeDevice } from '../capture-session-v3-
|
|
1
|
+
import { C as CameraErrorKind } from '../capture-session-v3-Db4n6d-k.cjs';
|
|
2
|
+
export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GATE_SNAPSHOT_MS, u as GateBlockEntry, v as GateBlockReason, w as GateBlockStats, x as GateBlockSummary, y as GateChecks, H as HOLD_UPRIGHT_KEY, K as KEYFRAME_CANDIDATES, z as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, A as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, B as V3GateFactor, I as V3GateQuality, J as V3GateThresholds, L as V3GateTick, N as V3GateTickInput, O as V3TelemetryEvent, Q as V3_GATE_DEFAULTS, R as VIDEO_BPS, W as blockReasonOf, X as buildLivenessV2FormData, Y as cameraPreflight, Z as classifyDevice, _ as extForMime, $ as isClipTooLarge, a0 as isMediaRecorderSupported, a1 as mapGetUserMediaError, a2 as pickMimeType, a3 as probeDevice } from '../capture-session-v3-Db4n6d-k.cjs';
|
|
3
3
|
export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, F as FormFactor, I as IN_CIRCLE_FACTOR, P as PHONE_MAX_SHORT_SIDE, b as buildCaptureConstraints, d as detectFormFactor, c as detectIsMobile, t as trackFacingMode } from '../capture-constraints-B5omafmk.cjs';
|
|
4
4
|
export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, d as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-DclNxkZT.cjs';
|
|
5
|
-
import '../types-
|
|
5
|
+
import '../types-DPWT_KMn.cjs';
|
|
6
6
|
|
|
7
7
|
declare function captureMirroredKeyframe(video: HTMLVideoElement, canvas: HTMLCanvasElement, quality?: number): Promise<Blob>;
|
|
8
8
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CameraErrorKind } from '../capture-session-v3-
|
|
2
|
-
export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GATE_SNAPSHOT_MS, u as GateBlockEntry, v as GateBlockReason, w as GateBlockStats, x as GateBlockSummary, y as GateChecks, H as HOLD_UPRIGHT_KEY, K as KEYFRAME_CANDIDATES, z as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, A as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, B as V3GateFactor, I as V3GateQuality, J as V3GateThresholds, L as V3GateTick, N as V3GateTickInput, O as V3TelemetryEvent, Q as V3_GATE_DEFAULTS, R as VIDEO_BPS, W as blockReasonOf, X as buildLivenessV2FormData, Y as cameraPreflight, Z as classifyDevice, _ as extForMime, $ as isClipTooLarge, a0 as isMediaRecorderSupported, a1 as mapGetUserMediaError, a2 as pickMimeType, a3 as probeDevice } from '../capture-session-v3-
|
|
1
|
+
import { C as CameraErrorKind } from '../capture-session-v3-C5DRPBhM.js';
|
|
2
|
+
export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GATE_SNAPSHOT_MS, u as GateBlockEntry, v as GateBlockReason, w as GateBlockStats, x as GateBlockSummary, y as GateChecks, H as HOLD_UPRIGHT_KEY, K as KEYFRAME_CANDIDATES, z as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, A as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, B as V3GateFactor, I as V3GateQuality, J as V3GateThresholds, L as V3GateTick, N as V3GateTickInput, O as V3TelemetryEvent, Q as V3_GATE_DEFAULTS, R as VIDEO_BPS, W as blockReasonOf, X as buildLivenessV2FormData, Y as cameraPreflight, Z as classifyDevice, _ as extForMime, $ as isClipTooLarge, a0 as isMediaRecorderSupported, a1 as mapGetUserMediaError, a2 as pickMimeType, a3 as probeDevice } from '../capture-session-v3-C5DRPBhM.js';
|
|
3
3
|
export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, F as FormFactor, I as IN_CIRCLE_FACTOR, P as PHONE_MAX_SHORT_SIDE, b as buildCaptureConstraints, d as detectFormFactor, c as detectIsMobile, t as trackFacingMode } from '../capture-constraints-B5omafmk.js';
|
|
4
4
|
export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, d as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-DclNxkZT.js';
|
|
5
|
-
import '../types-
|
|
5
|
+
import '../types-DPWT_KMn.js';
|
|
6
6
|
|
|
7
7
|
declare function captureMirroredKeyframe(video: HTMLVideoElement, canvas: HTMLCanvasElement, quality?: number): Promise<Blob>;
|
|
8
8
|
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x,b as k,c as z,d as C,e as L,f as T,k as E,l as N,m as w,n as D,o as G,p as I,q as J,r as M,s as Q,t as W,u as X,v as Y,w as Z}from"../chunk-
|
|
1
|
+
import{a as x,b as k,c as z,d as C,e as L,f as T,k as E,l as N,m as w,n as D,o as G,p as I,q as J,r as M,s as Q,t as W,u as X,v as Y,w as Z}from"../chunk-IBA5CPDV.js";import{a as e,b as r,c as o,d as n,e as a,f as s,g as t,h as i}from"../chunk-FUHDOEBP.js";import{a as P,b as S,c as B,d as F}from"../chunk-POIQGEZM.js";import{a as c,b as p,c as u,d as f,e as m,f as d,g as l,h as v,i as y,j as g}from"../chunk-FHJ7HO3M.js";import{a as O,b as U,c as V,d as j,e as q}from"../chunk-FPXL63KZ.js";import"../chunk-5OIC5TZS.js";import{a as R,b as h,c as b,d as A,e as H,f as K}from"../chunk-OKWG3PVH.js";var _={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},$={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};export{i as CENTERED_FACTOR,s as CIRCLE_RADIUS_FACTOR,x as CLIP_MS,Z as CaptureSessionV3,L as ClipError,T as ClipRecorder,u as DEFAULT_CLIP_MIME,h as DEFAULT_TIER_ORDER,R as DEFAULT_V3_ASSET_BASE_URL,P as DEVICE_PROFILES,N as DetectScheduler,b as DetectorLadderError,F as DeviceProfiler,U as EXPOSURE_BAND,D as FaceGateV3,J as GATE_SNAPSHOT_MS,I as GateBlockStats,M as HOLD_UPRIGHT_KEY,t as IN_CIRCLE_FACTOR,W as KEYFRAME_CANDIDATES,X as KEYFRAME_WINDOW_MS,l as MAX_CLIP_BYTES,c as MIME_CANDIDATES,r as PHONE_MAX_SHORT_SIDE,Y as PROVENANCE_WAIT_MS,O as SHARP_REF,z as STOP_GRACE_MS,k as TIMESLICE_MS,Q as UPRIGHT_WATCH_MS,w as V3_GATE_DEFAULTS,C as VIDEO_BPS,G as blockReasonOf,e as buildCaptureConstraints,g as buildLivenessV2FormData,m as cameraPreflight,E as captureMirroredKeyframe,B as classifyDevice,K as createDetector,o as detectFormFactor,n as detectIsMobile,_ as errorCopy,q as exposure,y as extForMime,A as intrinsicSize,v as isClipTooLarge,d as isMediaRecorderSupported,f as mapGetUserMediaError,V as meanLuma,p as pickMimeType,S as probeDevice,j as sharpness,H as toStreamPixels,a as trackFacingMode,$ as uiCopy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as a,v as b,w as c,x as d}from"./chunk-
|
|
1
|
+
import{u as a,v as b,w as c,x as d}from"./chunk-H6H2RT6M.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-JRSIMNB5.js";import"./chunk-GT2ZLGF7.js";import"./chunk-IBA5CPDV.js";import"./chunk-FUHDOEBP.js";import"./chunk-POIQGEZM.js";import"./chunk-FHJ7HO3M.js";import"./chunk-FPXL63KZ.js";import"./chunk-5OIC5TZS.js";import"./chunk-OKWG3PVH.js";import"./chunk-DK5YPBDQ.js";export{a as SAME_FACE_MAX_DROPS,c as createDocumentCapture,d as createDocumentCaptureInternal,b as warmDocumentCapture};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as Detector } from './detect-worker-DclNxkZT.cjs';
|
|
2
|
-
import { A as AcceptedDocumentType,
|
|
3
|
-
import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, p as DeviceClass, b as CaptureArtifacts, I as V3GateQuality, O as V3TelemetryEvent } from './capture-session-v3-
|
|
4
|
-
import { c as IcaoGateSummary, d as IcaoGateUpdate, P as Point, e as Box, j as IcaoFrameObservation, N as HostedClient, k as IcaoGate } from './icao-gate-
|
|
2
|
+
import { A as AcceptedDocumentType, a4 as NationalEidOption, aq as StepSection, s as HostedBranding, ad as PlanSectionView, aa as PlanChoiceKind, m as ContactChannel, k as CheckReason, aj as RetakeHint, _ as IdentityMethod, E as EidAfterPass, $ as IdentitySummarySource, G as HostedIcaoPolicy, Z as IcaoReportEntry, Y as IcaoCaptureTuning, H as HostedSessionView, V as HostedStepView, ae as PlanStepView, i as CaptureMode, am as ScreenRampReport, j as CaptureProvenance, S as ScreenRampColour, an as SessionFailureReason, h as AgeEstimationReason, as as VerificationLevel, ar as VerificationAssurance, a3 as MethodChoiceView, b as CameraUnavailableCause, X as HostedVoiceView, ak as ScreenRampChallenge, aw as PersonMask, ax as AttestationInput, e as CheckType, ah as PortraitIcaoInput } from './types-DPWT_KMn.cjs';
|
|
3
|
+
import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, p as DeviceClass, b as CaptureArtifacts, I as V3GateQuality, O as V3TelemetryEvent } from './capture-session-v3-Db4n6d-k.cjs';
|
|
4
|
+
import { c as IcaoGateSummary, d as IcaoGateUpdate, P as Point, e as Box, j as IcaoFrameObservation, N as HostedClient, k as IcaoGate } from './icao-gate-B0GDH_JS.cjs';
|
|
5
5
|
|
|
6
6
|
declare const ISSUER_CODES: readonly string[];
|
|
7
7
|
|
|
@@ -106,6 +106,12 @@ interface PhoneOtpSnapshot extends StepAttempts {
|
|
|
106
106
|
* without a channel (SMS). With more than one, `send` needs the person's choice.
|
|
107
107
|
*/
|
|
108
108
|
channels: OtpChannel[];
|
|
109
|
+
/**
|
|
110
|
+
* The countries the number may be from (ISO alpha-2, the first the default of the
|
|
111
|
+
* country picker; person data spec Q16). Absent from a server before person data
|
|
112
|
+
* Task A9: then the person types a full international number.
|
|
113
|
+
*/
|
|
114
|
+
phoneCountries?: string[];
|
|
109
115
|
sentToMasked?: string;
|
|
110
116
|
channel?: "sms" | "whatsapp";
|
|
111
117
|
codeExpiresAt?: string;
|
|
@@ -214,6 +220,9 @@ interface IdentitySummarySnapshot {
|
|
|
214
220
|
nationality?: string;
|
|
215
221
|
documentType?: string;
|
|
216
222
|
documentNumberMasked?: string;
|
|
223
|
+
/** The bound ID number, masked (last 4), from either view name. */
|
|
224
|
+
idNumberMasked?: string;
|
|
225
|
+
/** @deprecated Read `idNumberMasked` (the same value). */
|
|
217
226
|
nniMasked?: string;
|
|
218
227
|
expiryDate?: string;
|
|
219
228
|
/** The portrait can be fetched (`portrait()` on the handle). */
|
|
@@ -396,6 +405,11 @@ interface ProcessingSnapshot {
|
|
|
396
405
|
key: string;
|
|
397
406
|
context: StepContext;
|
|
398
407
|
stalled: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* The service of the step the server is running (`age_estimation`, `face_dedup`, …), when one is known: a screen
|
|
410
|
+
* may say what is being checked. Absent when nothing names the step.
|
|
411
|
+
*/
|
|
412
|
+
service?: string;
|
|
399
413
|
}
|
|
400
414
|
type UnsupportedReason = "platform_unsupported" | "update_required";
|
|
401
415
|
interface UnsupportedSnapshot {
|
|
@@ -892,9 +906,11 @@ interface LivenessCaptureOptions {
|
|
|
892
906
|
* - `attestation` — Turnstile failed client-side or `attestation_invalid` after one retry;
|
|
893
907
|
* - `network` — transport / API failure after the bounded replays;
|
|
894
908
|
* - `nni_unbound` — `population_registry` is the frontier but the session was
|
|
895
|
-
* minted WITHOUT a
|
|
896
|
-
* SDK cannot submit it. Mint the session with the
|
|
897
|
-
* population step yourself) before starting the capture
|
|
909
|
+
* minted WITHOUT a bound ID number (`POST /sessions` `subject.idNumber`), so
|
|
910
|
+
* the SDK cannot submit it. Mint the session with the number (or complete the
|
|
911
|
+
* population step yourself) before starting the capture. `id_number_unbound`
|
|
912
|
+
* is its generic name (person data spec Appendix A.2): this SDK still reports
|
|
913
|
+
* `nni_unbound`; handle both;
|
|
898
914
|
* - `method_required` — the session waits on the identity-method choice
|
|
899
915
|
* (profile v2 step 3; `on('method')` fired). Ask the person, call
|
|
900
916
|
* {@link Verification.selectMethod}, then capture again;
|
|
@@ -913,9 +929,9 @@ interface LivenessCaptureOptions {
|
|
|
913
929
|
* upload when the view says so; otherwise the backend answers the submit with
|
|
914
930
|
* a request-level `409 mobile_required` (no attempt used, nothing billed).
|
|
915
931
|
*/
|
|
916
|
-
type SdkFailureReason = "no_recorder" | "attestation" | "network" | "nni_unbound" | "method_required" | "inference_unavailable" | "portrait_required";
|
|
932
|
+
type SdkFailureReason = "no_recorder" | "attestation" | "network" | "nni_unbound" | "id_number_unbound" | "method_required" | "inference_unavailable" | "portrait_required";
|
|
917
933
|
/** Backend reason taxonomy ∪ the SDK-side failure reasons. */
|
|
918
|
-
type ReasonCode = CheckReason | SessionFailureReason | SdkFailureReason;
|
|
934
|
+
type ReasonCode = CheckReason | SessionFailureReason | SdkFailureReason | AgeEstimationReason;
|
|
919
935
|
/**
|
|
920
936
|
* - `approved` / `rejected` / `review` — the session's verdict;
|
|
921
937
|
* - `retry` — a retryable reason with attempts remaining (`autoRetry` on); the
|
|
@@ -1018,8 +1034,8 @@ interface Verification {
|
|
|
1018
1034
|
consent(): Promise<void>;
|
|
1019
1035
|
/**
|
|
1020
1036
|
* Submit `population_registry` early with an empty input when it is the
|
|
1021
|
-
* pending frontier and the backend holds the
|
|
1022
|
-
* the one the document step read (`
|
|
1037
|
+
* pending frontier and the backend holds the number: the SERVER-bound one, or
|
|
1038
|
+
* the one the document step read (`idNumberFromDocument`). Retries once on
|
|
1023
1039
|
* `registry_unavailable`. Never rejects — failures surface through
|
|
1024
1040
|
* `result`. Idempotent.
|
|
1025
1041
|
*/
|
|
@@ -1201,11 +1217,21 @@ interface EidStepHandle extends EidSnapshot {
|
|
|
1201
1217
|
interface RegistryStepHandle extends RegistrySnapshot {
|
|
1202
1218
|
/** Switch to another option of the open choice (`context.switchable`; `POST /hosted/choice`). Present only with it. */
|
|
1203
1219
|
chooseOption?(option: string): Promise<void>;
|
|
1204
|
-
/**
|
|
1220
|
+
/**
|
|
1221
|
+
* Typed source only: checks the national number locally (the registry country's
|
|
1222
|
+
* rule: 10 digits and the check digit) before submitting it (`{ idNumber, nni }`, the
|
|
1223
|
+
* former name too until it is removed). A refused
|
|
1224
|
+
* number rejects with `InvalidInputError("idNumber", "format" | "check_digit")`.
|
|
1225
|
+
*/
|
|
1226
|
+
submitIdNumber(idNumber: string): Promise<void>;
|
|
1227
|
+
/**
|
|
1228
|
+
* @deprecated Use {@link RegistryStepHandle.submitIdNumber} (the same request).
|
|
1229
|
+
* Rejects with `InvalidInputError("nni", …)`.
|
|
1230
|
+
*/
|
|
1205
1231
|
submitNni(nni: string): Promise<void>;
|
|
1206
|
-
/** Bound or document source: submit with an empty input (the server holds the
|
|
1232
|
+
/** Bound or document source: submit with an empty input (the server holds the number). */
|
|
1207
1233
|
confirm(): Promise<void>;
|
|
1208
|
-
/** After `
|
|
1234
|
+
/** After `registry_record_not_found` (formerly `nni_not_found`; `canUseDocument`): switch to the document photo. */
|
|
1209
1235
|
useDocument(): Promise<void>;
|
|
1210
1236
|
}
|
|
1211
1237
|
/** The document step — any issuing country (profile v2 §5.3a). */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as Detector } from './detect-worker-DclNxkZT.js';
|
|
2
|
-
import { A as AcceptedDocumentType,
|
|
3
|
-
import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, p as DeviceClass, b as CaptureArtifacts, I as V3GateQuality, O as V3TelemetryEvent } from './capture-session-v3-
|
|
4
|
-
import { c as IcaoGateSummary, d as IcaoGateUpdate, P as Point, e as Box, j as IcaoFrameObservation, N as HostedClient, k as IcaoGate } from './icao-gate-
|
|
2
|
+
import { A as AcceptedDocumentType, a4 as NationalEidOption, aq as StepSection, s as HostedBranding, ad as PlanSectionView, aa as PlanChoiceKind, m as ContactChannel, k as CheckReason, aj as RetakeHint, _ as IdentityMethod, E as EidAfterPass, $ as IdentitySummarySource, G as HostedIcaoPolicy, Z as IcaoReportEntry, Y as IcaoCaptureTuning, H as HostedSessionView, V as HostedStepView, ae as PlanStepView, i as CaptureMode, am as ScreenRampReport, j as CaptureProvenance, S as ScreenRampColour, an as SessionFailureReason, h as AgeEstimationReason, as as VerificationLevel, ar as VerificationAssurance, a3 as MethodChoiceView, b as CameraUnavailableCause, X as HostedVoiceView, ak as ScreenRampChallenge, aw as PersonMask, ax as AttestationInput, e as CheckType, ah as PortraitIcaoInput } from './types-DPWT_KMn.js';
|
|
3
|
+
import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, p as DeviceClass, b as CaptureArtifacts, I as V3GateQuality, O as V3TelemetryEvent } from './capture-session-v3-C5DRPBhM.js';
|
|
4
|
+
import { c as IcaoGateSummary, d as IcaoGateUpdate, P as Point, e as Box, j as IcaoFrameObservation, N as HostedClient, k as IcaoGate } from './icao-gate-BP11XO-h.js';
|
|
5
5
|
|
|
6
6
|
declare const ISSUER_CODES: readonly string[];
|
|
7
7
|
|
|
@@ -106,6 +106,12 @@ interface PhoneOtpSnapshot extends StepAttempts {
|
|
|
106
106
|
* without a channel (SMS). With more than one, `send` needs the person's choice.
|
|
107
107
|
*/
|
|
108
108
|
channels: OtpChannel[];
|
|
109
|
+
/**
|
|
110
|
+
* The countries the number may be from (ISO alpha-2, the first the default of the
|
|
111
|
+
* country picker; person data spec Q16). Absent from a server before person data
|
|
112
|
+
* Task A9: then the person types a full international number.
|
|
113
|
+
*/
|
|
114
|
+
phoneCountries?: string[];
|
|
109
115
|
sentToMasked?: string;
|
|
110
116
|
channel?: "sms" | "whatsapp";
|
|
111
117
|
codeExpiresAt?: string;
|
|
@@ -214,6 +220,9 @@ interface IdentitySummarySnapshot {
|
|
|
214
220
|
nationality?: string;
|
|
215
221
|
documentType?: string;
|
|
216
222
|
documentNumberMasked?: string;
|
|
223
|
+
/** The bound ID number, masked (last 4), from either view name. */
|
|
224
|
+
idNumberMasked?: string;
|
|
225
|
+
/** @deprecated Read `idNumberMasked` (the same value). */
|
|
217
226
|
nniMasked?: string;
|
|
218
227
|
expiryDate?: string;
|
|
219
228
|
/** The portrait can be fetched (`portrait()` on the handle). */
|
|
@@ -396,6 +405,11 @@ interface ProcessingSnapshot {
|
|
|
396
405
|
key: string;
|
|
397
406
|
context: StepContext;
|
|
398
407
|
stalled: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* The service of the step the server is running (`age_estimation`, `face_dedup`, …), when one is known: a screen
|
|
410
|
+
* may say what is being checked. Absent when nothing names the step.
|
|
411
|
+
*/
|
|
412
|
+
service?: string;
|
|
399
413
|
}
|
|
400
414
|
type UnsupportedReason = "platform_unsupported" | "update_required";
|
|
401
415
|
interface UnsupportedSnapshot {
|
|
@@ -892,9 +906,11 @@ interface LivenessCaptureOptions {
|
|
|
892
906
|
* - `attestation` — Turnstile failed client-side or `attestation_invalid` after one retry;
|
|
893
907
|
* - `network` — transport / API failure after the bounded replays;
|
|
894
908
|
* - `nni_unbound` — `population_registry` is the frontier but the session was
|
|
895
|
-
* minted WITHOUT a
|
|
896
|
-
* SDK cannot submit it. Mint the session with the
|
|
897
|
-
* population step yourself) before starting the capture
|
|
909
|
+
* minted WITHOUT a bound ID number (`POST /sessions` `subject.idNumber`), so
|
|
910
|
+
* the SDK cannot submit it. Mint the session with the number (or complete the
|
|
911
|
+
* population step yourself) before starting the capture. `id_number_unbound`
|
|
912
|
+
* is its generic name (person data spec Appendix A.2): this SDK still reports
|
|
913
|
+
* `nni_unbound`; handle both;
|
|
898
914
|
* - `method_required` — the session waits on the identity-method choice
|
|
899
915
|
* (profile v2 step 3; `on('method')` fired). Ask the person, call
|
|
900
916
|
* {@link Verification.selectMethod}, then capture again;
|
|
@@ -913,9 +929,9 @@ interface LivenessCaptureOptions {
|
|
|
913
929
|
* upload when the view says so; otherwise the backend answers the submit with
|
|
914
930
|
* a request-level `409 mobile_required` (no attempt used, nothing billed).
|
|
915
931
|
*/
|
|
916
|
-
type SdkFailureReason = "no_recorder" | "attestation" | "network" | "nni_unbound" | "method_required" | "inference_unavailable" | "portrait_required";
|
|
932
|
+
type SdkFailureReason = "no_recorder" | "attestation" | "network" | "nni_unbound" | "id_number_unbound" | "method_required" | "inference_unavailable" | "portrait_required";
|
|
917
933
|
/** Backend reason taxonomy ∪ the SDK-side failure reasons. */
|
|
918
|
-
type ReasonCode = CheckReason | SessionFailureReason | SdkFailureReason;
|
|
934
|
+
type ReasonCode = CheckReason | SessionFailureReason | SdkFailureReason | AgeEstimationReason;
|
|
919
935
|
/**
|
|
920
936
|
* - `approved` / `rejected` / `review` — the session's verdict;
|
|
921
937
|
* - `retry` — a retryable reason with attempts remaining (`autoRetry` on); the
|
|
@@ -1018,8 +1034,8 @@ interface Verification {
|
|
|
1018
1034
|
consent(): Promise<void>;
|
|
1019
1035
|
/**
|
|
1020
1036
|
* Submit `population_registry` early with an empty input when it is the
|
|
1021
|
-
* pending frontier and the backend holds the
|
|
1022
|
-
* the one the document step read (`
|
|
1037
|
+
* pending frontier and the backend holds the number: the SERVER-bound one, or
|
|
1038
|
+
* the one the document step read (`idNumberFromDocument`). Retries once on
|
|
1023
1039
|
* `registry_unavailable`. Never rejects — failures surface through
|
|
1024
1040
|
* `result`. Idempotent.
|
|
1025
1041
|
*/
|
|
@@ -1201,11 +1217,21 @@ interface EidStepHandle extends EidSnapshot {
|
|
|
1201
1217
|
interface RegistryStepHandle extends RegistrySnapshot {
|
|
1202
1218
|
/** Switch to another option of the open choice (`context.switchable`; `POST /hosted/choice`). Present only with it. */
|
|
1203
1219
|
chooseOption?(option: string): Promise<void>;
|
|
1204
|
-
/**
|
|
1220
|
+
/**
|
|
1221
|
+
* Typed source only: checks the national number locally (the registry country's
|
|
1222
|
+
* rule: 10 digits and the check digit) before submitting it (`{ idNumber, nni }`, the
|
|
1223
|
+
* former name too until it is removed). A refused
|
|
1224
|
+
* number rejects with `InvalidInputError("idNumber", "format" | "check_digit")`.
|
|
1225
|
+
*/
|
|
1226
|
+
submitIdNumber(idNumber: string): Promise<void>;
|
|
1227
|
+
/**
|
|
1228
|
+
* @deprecated Use {@link RegistryStepHandle.submitIdNumber} (the same request).
|
|
1229
|
+
* Rejects with `InvalidInputError("nni", …)`.
|
|
1230
|
+
*/
|
|
1205
1231
|
submitNni(nni: string): Promise<void>;
|
|
1206
|
-
/** Bound or document source: submit with an empty input (the server holds the
|
|
1232
|
+
/** Bound or document source: submit with an empty input (the server holds the number). */
|
|
1207
1233
|
confirm(): Promise<void>;
|
|
1208
|
-
/** After `
|
|
1234
|
+
/** After `registry_record_not_found` (formerly `nni_not_found`; `canUseDocument`): switch to the document photo. */
|
|
1209
1235
|
useDocument(): Promise<void>;
|
|
1210
1236
|
}
|
|
1211
1237
|
/** The document step — any issuing country (profile v2 §5.3a). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HostedSessionView, C as ConsentLocale, a as HostedConsentView, b as CameraUnavailableCause, I as IdentityConfirmDecision, M as MediaKind, P as PresignUploadResult, c as CaptureContext, d as CompleteMediaResult, e as CheckType, f as CheckInputByType, g as IcaoCriterion, B as BackgroundUniformity, R as ResolvedIcaoTuning } from './types-
|
|
1
|
+
import { H as HostedSessionView, C as ConsentLocale, a as HostedConsentView, b as CameraUnavailableCause, I as IdentityConfirmDecision, M as MediaKind, P as PresignUploadResult, c as CaptureContext, d as CompleteMediaResult, e as CheckType, f as CheckInputByType, g as IcaoCriterion, B as BackgroundUniformity, R as ResolvedIcaoTuning } from './types-DPWT_KMn.cjs';
|
|
2
2
|
|
|
3
3
|
interface Point {
|
|
4
4
|
x: number;
|
|
@@ -100,8 +100,11 @@ interface SubmitOptions {
|
|
|
100
100
|
* replays the first response without burning another attempt.
|
|
101
101
|
*/
|
|
102
102
|
idempotencyKey?: string;
|
|
103
|
-
/**
|
|
104
|
-
|
|
103
|
+
/**
|
|
104
|
+
* SANDBOX-ONLY deterministic override (plan D-C); a live session 403s it. The `age_*` values ride the liveness
|
|
105
|
+
* submit and pick what the age check (selfie) step decides.
|
|
106
|
+
*/
|
|
107
|
+
forceOutcome?: "pass" | "fail" | "age_over" | "age_uncertain" | "age_under" | "age_unavailable";
|
|
105
108
|
}
|
|
106
109
|
interface UploadMedia {
|
|
107
110
|
kind: MediaKind;
|
|
@@ -112,7 +115,7 @@ interface UploadMedia {
|
|
|
112
115
|
interface HostedClientOptions {
|
|
113
116
|
/** API origin, e.g. `https://api.sekyro.ai` — paths are `${apiOrigin}/api/v2/...`. */
|
|
114
117
|
apiOrigin: string;
|
|
115
|
-
/** The raw session token from the hosted URL (short code
|
|
118
|
+
/** The raw session token from the hosted URL (short code) — sent as `x-session-token` on every API call. */
|
|
116
119
|
sessionToken: string;
|
|
117
120
|
/** Injection seam (tests / non-window contexts). Defaults to `globalThis.fetch`. */
|
|
118
121
|
fetch?: typeof globalThis.fetch;
|
|
@@ -157,6 +160,11 @@ interface HostedClientOptions {
|
|
|
157
160
|
* `idempotency_in_progress`. Everything else — including 429 with its parsed
|
|
158
161
|
* `retryAfterSeconds` — is surfaced to the page to handle.
|
|
159
162
|
*/
|
|
163
|
+
/**
|
|
164
|
+
* The `x-sekyro-sdk` value of this SDK (`@sekyro/web/<version>`, person data spec §5.6): every hosted
|
|
165
|
+
* call sends it. A page that calls a hosted session-token route itself sends it too.
|
|
166
|
+
*/
|
|
167
|
+
declare const SEKYRO_SDK_HEADER: string;
|
|
160
168
|
declare class HostedClient {
|
|
161
169
|
private readonly apiOrigin;
|
|
162
170
|
private readonly sessionToken;
|
|
@@ -497,4 +505,4 @@ interface IcaoGateOptions {
|
|
|
497
505
|
}
|
|
498
506
|
declare function createIcaoGate(t: ResolvedIcaoTuning, options?: IcaoGateOptions): IcaoGate;
|
|
499
507
|
|
|
500
|
-
export { lumaPlane as A, type BackgroundStats as B, CLIPPED_LUMA as C, percentile as D, portraitCropRegion as E, type FaceGeometry as F, poseFromMatrix as G, type HeadPose as H, type IcaoCoachKey as I, regionStats as J, scoreFrame as K, type LumaPlane as L, windowOverflow as M, HostedClient as N, type HostedClientOptions as O, type Point as P, type MediaCheckType as Q, type RegionStats as R,
|
|
508
|
+
export { lumaPlane as A, type BackgroundStats as B, CLIPPED_LUMA as C, percentile as D, portraitCropRegion as E, type FaceGeometry as F, poseFromMatrix as G, type HeadPose as H, type IcaoCoachKey as I, regionStats as J, scoreFrame as K, type LumaPlane as L, windowOverflow as M, HostedClient as N, type HostedClientOptions as O, type Point as P, type MediaCheckType as Q, type RegionStats as R, SEKYRO_SDK_HEADER as S, type SubmitOptions as T, type UploadMedia as U, stripMimeParams as V, type IcaoCriterionState as a, type IcaoGateCriterion as b, type IcaoGateSummary as c, type IcaoGateUpdate as d, type Box as e, type FaceLighting as f, ICAO_CANVAS as g, ICAO_GATE_CRITERIA as h, ICAO_SHARP_REF as i, type IcaoFrameObservation as j, type IcaoGate as k, type IcaoGateOptions as l, type IcaoJudgedCriterion as m, type IcaoMeasures as n, type IcaoPixelStats as o, backgroundStats as p, createIcaoGate as q, eyeLineRoll as r, eyeOpenness as s, eyeSpecular as t, faceGeometry as u, faceLighting as v, faceSharpness as w, icaoPixelStats as x, icaoWindow as y, judgeIcao as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HostedSessionView, C as ConsentLocale, a as HostedConsentView, b as CameraUnavailableCause, I as IdentityConfirmDecision, M as MediaKind, P as PresignUploadResult, c as CaptureContext, d as CompleteMediaResult, e as CheckType, f as CheckInputByType, g as IcaoCriterion, B as BackgroundUniformity, R as ResolvedIcaoTuning } from './types-
|
|
1
|
+
import { H as HostedSessionView, C as ConsentLocale, a as HostedConsentView, b as CameraUnavailableCause, I as IdentityConfirmDecision, M as MediaKind, P as PresignUploadResult, c as CaptureContext, d as CompleteMediaResult, e as CheckType, f as CheckInputByType, g as IcaoCriterion, B as BackgroundUniformity, R as ResolvedIcaoTuning } from './types-DPWT_KMn.js';
|
|
2
2
|
|
|
3
3
|
interface Point {
|
|
4
4
|
x: number;
|
|
@@ -100,8 +100,11 @@ interface SubmitOptions {
|
|
|
100
100
|
* replays the first response without burning another attempt.
|
|
101
101
|
*/
|
|
102
102
|
idempotencyKey?: string;
|
|
103
|
-
/**
|
|
104
|
-
|
|
103
|
+
/**
|
|
104
|
+
* SANDBOX-ONLY deterministic override (plan D-C); a live session 403s it. The `age_*` values ride the liveness
|
|
105
|
+
* submit and pick what the age check (selfie) step decides.
|
|
106
|
+
*/
|
|
107
|
+
forceOutcome?: "pass" | "fail" | "age_over" | "age_uncertain" | "age_under" | "age_unavailable";
|
|
105
108
|
}
|
|
106
109
|
interface UploadMedia {
|
|
107
110
|
kind: MediaKind;
|
|
@@ -112,7 +115,7 @@ interface UploadMedia {
|
|
|
112
115
|
interface HostedClientOptions {
|
|
113
116
|
/** API origin, e.g. `https://api.sekyro.ai` — paths are `${apiOrigin}/api/v2/...`. */
|
|
114
117
|
apiOrigin: string;
|
|
115
|
-
/** The raw session token from the hosted URL (short code
|
|
118
|
+
/** The raw session token from the hosted URL (short code) — sent as `x-session-token` on every API call. */
|
|
116
119
|
sessionToken: string;
|
|
117
120
|
/** Injection seam (tests / non-window contexts). Defaults to `globalThis.fetch`. */
|
|
118
121
|
fetch?: typeof globalThis.fetch;
|
|
@@ -157,6 +160,11 @@ interface HostedClientOptions {
|
|
|
157
160
|
* `idempotency_in_progress`. Everything else — including 429 with its parsed
|
|
158
161
|
* `retryAfterSeconds` — is surfaced to the page to handle.
|
|
159
162
|
*/
|
|
163
|
+
/**
|
|
164
|
+
* The `x-sekyro-sdk` value of this SDK (`@sekyro/web/<version>`, person data spec §5.6): every hosted
|
|
165
|
+
* call sends it. A page that calls a hosted session-token route itself sends it too.
|
|
166
|
+
*/
|
|
167
|
+
declare const SEKYRO_SDK_HEADER: string;
|
|
160
168
|
declare class HostedClient {
|
|
161
169
|
private readonly apiOrigin;
|
|
162
170
|
private readonly sessionToken;
|
|
@@ -497,4 +505,4 @@ interface IcaoGateOptions {
|
|
|
497
505
|
}
|
|
498
506
|
declare function createIcaoGate(t: ResolvedIcaoTuning, options?: IcaoGateOptions): IcaoGate;
|
|
499
507
|
|
|
500
|
-
export { lumaPlane as A, type BackgroundStats as B, CLIPPED_LUMA as C, percentile as D, portraitCropRegion as E, type FaceGeometry as F, poseFromMatrix as G, type HeadPose as H, type IcaoCoachKey as I, regionStats as J, scoreFrame as K, type LumaPlane as L, windowOverflow as M, HostedClient as N, type HostedClientOptions as O, type Point as P, type MediaCheckType as Q, type RegionStats as R,
|
|
508
|
+
export { lumaPlane as A, type BackgroundStats as B, CLIPPED_LUMA as C, percentile as D, portraitCropRegion as E, type FaceGeometry as F, poseFromMatrix as G, type HeadPose as H, type IcaoCoachKey as I, regionStats as J, scoreFrame as K, type LumaPlane as L, windowOverflow as M, HostedClient as N, type HostedClientOptions as O, type Point as P, type MediaCheckType as Q, type RegionStats as R, SEKYRO_SDK_HEADER as S, type SubmitOptions as T, type UploadMedia as U, stripMimeParams as V, type IcaoCriterionState as a, type IcaoGateCriterion as b, type IcaoGateSummary as c, type IcaoGateUpdate as d, type Box as e, type FaceLighting as f, ICAO_CANVAS as g, ICAO_GATE_CRITERIA as h, ICAO_SHARP_REF as i, type IcaoFrameObservation as j, type IcaoGate as k, type IcaoGateOptions as l, type IcaoJudgedCriterion as m, type IcaoMeasures as n, type IcaoPixelStats as o, backgroundStats as p, createIcaoGate as q, eyeLineRoll as r, eyeOpenness as s, eyeSpecular as t, faceGeometry as u, faceLighting as v, faceSharpness as w, icaoPixelStats as x, icaoWindow as y, judgeIcao as z };
|