@sekyro/web 0.1.0-rc.7 → 0.1.0-rc.8
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 +87 -0
- package/LICENSE +25 -16
- package/README.md +3 -5
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/capture-session-doc-YBE3UMJJ.js +1 -0
- package/dist/{capture-session-v3-Okq0EQHG.d.ts → capture-session-v3-CQK-G-qX.d.ts} +72 -3
- package/dist/{capture-session-v3-UQU_WjO2.d.cts → capture-session-v3-Dvob-uH2.d.cts} +72 -3
- package/dist/chunk-4RS2YIL4.js +1 -0
- package/dist/chunk-7V2M6Y2W.js +1 -0
- package/dist/chunk-7ZCZY3ZP.js +1 -0
- package/dist/chunk-A3FUGHAH.js +2 -0
- package/dist/chunk-BPE5NSQ2.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-DQWW4OCK.js +1 -0
- package/dist/chunk-FHJ7HO3M.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/{chunk-IYUOYINS.js → chunk-LQ7C44JG.js} +1 -1
- package/dist/chunk-M43ET4NJ.js +1 -0
- package/dist/chunk-MXWLCDFX.js +1 -0
- package/dist/chunk-MY6EXEL2.js +1 -0
- package/dist/chunk-O5WKNZ2C.js +1 -0
- package/dist/chunk-OKWG3PVH.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-RNRFHUJA.js +1 -0
- package/dist/chunk-RVHAKRAI.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-TDLIXFDT.js +1 -0
- package/dist/chunk-XLN5OT25.js +1 -0
- package/dist/chunk-YDQBVWXG.js +1 -0
- package/dist/chunk-YPG7CB4O.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +13 -3
- package/dist/client/index.d.ts +13 -3
- 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/core/ocr/worker.bundle.js +42 -0
- package/dist/core/ocr/worker.cjs +42 -0
- package/dist/core/ocr/worker.d.cts +84 -0
- package/dist/core/ocr/worker.d.ts +84 -0
- package/dist/core/ocr/worker.js +41 -0
- package/dist/core/v3/detect-worker.cjs +1 -1
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -1
- package/dist/create-document-capture-T4APHJMY.js +1 -0
- package/dist/create-portrait-capture-B57GE5FU.js +1 -0
- package/dist/create-verification-C0AVIcVW.d.ts +2787 -0
- package/dist/create-verification-DoFpgzok.d.cts +2787 -0
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
- package/dist/detector-scanic-YCDNLCGV.js +1 -0
- package/dist/icao-gate-D8qm1O2t.d.cts +1655 -0
- package/dist/icao-gate-D8qm1O2t.d.ts +1655 -0
- package/dist/icao-gate-PWBMKRGC.js +1 -0
- package/dist/icao-tuning-4GGVX6B4.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +345 -308
- package/dist/internal/index.d.ts +345 -308
- package/dist/internal/index.js +1 -1
- package/dist/keyframe-rank-YAJLYJYF.js +1 -0
- package/dist/landmarker-KB7LVXAU.js +1 -0
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/plan-runner-UBK4B4CG.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/turnstile-FATNZ4AG.js +1 -0
- package/package.json +22 -4
- package/sbom.cdx.json +8 -8
- package/dist/chunk-B45J4KC3.js +0 -1
- package/dist/chunk-BMA36W2W.js +0 -1
- package/dist/chunk-P7ECRN47.js +0 -1
- package/dist/chunk-YOB4ZTYN.js +0 -1
- package/dist/chunk-YQBK6OIM.js +0 -1
- package/dist/create-verification-C2JhOO6Y.d.cts +0 -533
- package/dist/create-verification-CGazwtAh.d.ts +0 -533
- package/dist/detector-scanic-VQFFXKTL.js +0 -1
- package/dist/hosted-client-kBeq-mnJ.d.cts +0 -602
- package/dist/hosted-client-kBeq-mnJ.d.ts +0 -602
package/dist/internal/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as Re,B as ve,C as xe,D as Ie,E as Ce,F as we,G as Fe,H as Le,J as Oe,K as Pe,L as Ne,M as Ge,O as He,a as se,b as ne,c as ce,d as le,i as ue,j as he,k as de,l as me,m as pe,o as fe,p as ge,q as _e,r as be,s as De,t as ye,u as Me,v as Ee,w as Te,x as Se,y as Ae,z as ke}from"../chunk-P7ECRN47.js";import{b as re,c as ie,d as oe,e as ae,i as N,x as H,y as U}from"../chunk-YQBK6OIM.js";import"../chunk-YOB4ZTYN.js";import{b as G}from"../chunk-IYUOYINS.js";import"../chunk-BMA36W2W.js";import{a as Ze,b as W,c as Je,d as C,e as V,f as Q,g as $e,h as w,i as X}from"../chunk-B45J4KC3.js";import{b as x,c as K,d as I,e as B}from"../chunk-FPXL63KZ.js";var Ue=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),S=12;function z(i,e={}){let r={...Ue,...e},{data:t,width:s,height:o}=i;if(s<32||o<32)return null;let n=new Array(o).fill(!1),c=new Float32Array(o),a=new Int32Array(o).fill(s),d=new Int32Array(o).fill(-1),p=s/S,h=new Array(S);for(let l=0;l<o;l++){let y=0;h.fill(!1);let T=l*s*4,O=.299*(t[T]??0)+.587*(t[T+1]??0)+.114*(t[T+2]??0);for(let g=1;g<s;g++){let v=T+g*4,P=.299*(t[v]??0)+.587*(t[v+1]??0)+.114*(t[v+2]??0);Math.abs(P-O)>=r.EDGE_LUMA_DELTA&&(y+=1,h[Math.min(S-1,Math.floor(g/p))]=!0,g<a[l]&&(a[l]=g),g>d[l]&&(d[l]=g)),O=P}c[l]=y/s;let te=h.filter(Boolean).length/S;n[l]=c[l]>=r.MIN_ROW_DENSITY&&te>=r.MIN_COLUMN_COVERAGE&&d[l]-a[l]>=r.MIN_WIDTH_FRAC*s}let u=null,m=-1,f=-1,_=0,F=l=>{if(m<0)return;let y=l-m+1;y>=r.MIN_HEIGHT_FRAC*o&&y<=r.MAX_HEIGHT_FRAC*o&&_>=4&&(u===null||_>u.rows)&&(u={top:m,bottom:l,rows:_}),m=-1,_=0};for(let l=0;l<o;l++)n[l]&&(m<0?m=l:l-f>r.ROW_MERGE_GAP&&(F(f),m=l),f=l,_+=1);if(F(f),u===null)return null;let b=u,D=s,E=-1,L=0,R=0;for(let l=b.top;l<=b.bottom;l++)n[l]&&(a[l]<D&&(D=a[l]),d[l]>E&&(E=d[l]),L+=c[l],R+=1);return E-D<r.MIN_WIDTH_FRAC*s?null:{x:D,y:b.top,width:E-D,height:b.bottom-b.top+1,density:R>0?L/R:0}}var Ke=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function j(i){let{data:e,width:r,height:t}=i,s=r*t;if(s===0)return 0;let o=0;for(let n=0;n<s;n++){let c=n*4;.299*(e[c]??0)+.587*(e[c+1]??0)+.114*(e[c+2]??0)>=252&&o++}return o/s}function Be(i){let e=(a,d)=>Math.hypot(d.x-a.x,d.y-a.y),r=e(i.topLeft,i.topRight),t=e(i.bottomLeft,i.bottomRight),s=e(i.topLeft,i.bottomLeft),o=e(i.topRight,i.bottomRight),n=Math.max(r,t)/Math.max(1e-6,Math.min(r,t)),c=Math.max(s,o)/Math.max(1e-6,Math.min(s,o));return Math.max(n,c)}function Z(i){let e={...V,...i.thresholds},r=Ke,{quad:t,frameWidth:s,frameHeight:o,measures:n}=i,c=i.format==="ID-3",a="ok";if(t===null)a="no_document";else if(c){let u=w(t),m=s>0?u.width/s:0,f=u.height>0?u.width/u.height:0;m<e.ID3_BAND_MIN_WIDTH_FRAC?a="too_far":Y(t,s,o,e.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":(f<e.ID3_BAND_ASPECT_MIN||f>e.ID3_BAND_ASPECT_MAX)&&(a="wrong_shape")}else{let u=Q(t,s,o),m=W(i.format),f=w(t),_=Math.max(f.width,f.height)/Math.max(1e-6,Math.min(f.width,f.height));u<e.MIN_AREA_FRAC?a="too_far":u>r.MAX_AREA_FRAC?a="too_close":Y(t,s,o,e.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":Math.abs(_-m.center)>m.tolerance?a="wrong_shape":Be(t)>r.TILT_MAX_SIDE_RATIO&&(a="tilted")}let d=n.exposure>=e.GUIDE_EXPOSURE?"ok":n.meanLuma<(x[0]+x[1])/2?"too_dark":"too_bright",p=n.sharpness>=e.GUIDE_SHARPNESS?"ok":"blurry",h=n.specularFraction>=r.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:a,lighting:d,blur:p,glare:h,acceptable:a==="ok"&&d==="ok"&&p==="ok"&&h==="ok"}}function Y(i,e,r,t){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(o=>o.x<=t||o.y<=t||o.x>=e-t||o.y>=r-t)}var A=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function J(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}var k=class{constructor(e=2600,r=.35){this.windowMs=e;this.decayPerSecond=r;this.votes=[];this.current=A.sensing;this.currentSinceMs=null}reset(){this.votes=[],this.current=A.sensing,this.currentSinceMs=null}force(e,r){return this.votes=[],this.current=A[e],this.currentSinceMs=r,this.current}tick(e,r){if(this.currentSinceMs===null&&(this.currentSinceMs=r),this.votes.push({key:e,atMs:r}),this.votes=this.votes.filter(n=>r-n.atMs<=this.windowMs),r-this.currentSinceMs<this.current.minDurationMs)return this.current;let t=new Map;for(let n of this.votes){let c=(r-n.atMs)/1e3,a=this.decayPerSecond**c;t.set(n.key,(t.get(n.key)??0)+a)}let s=this.current.key,o=-1;for(let[n,c]of t)c>o&&(o=c,s=n);return s!==this.current.key&&(this.current=A[s],this.currentSinceMs=r),this.current}};var M=null;async function We(i){return M===null&&(M=(await import("../detector-scanic-VQFFXKTL.js")).detectQuad),M(i)}async function Ve(i){let e=z(i);return e===null?null:{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function mt(){M===null&&import("../detector-scanic-VQFFXKTL.js").then(i=>{M=i.detectQuad}).catch(()=>{})}var Qe=Object.freeze({LOW:3,MID:5,HIGH:6}),$=class{constructor(e){this.handlers=new Map;this.stream=null;this.timer=null;this.state="idle";this.lastGuidance=null;this.attempt=0;this.capturing=!1;this.feedback=new k;this.lastFeedbackKey=null;this.opts=e,this.gate=new X(e.format??"ID-1",e.thresholds);let r=e.deviceClass??U(H());this.cadenceMs=1e3/Qe[r]}on(e,r){let t=this.handlers.get(e);return t||(t=new Set,this.handlers.set(e,t)),t.add(r),()=>t?.delete(r)}emit(e,r){for(let t of[...this.handlers.get(e)??[]])t(r)}async start(){let e=++this.attempt;this.gate.reset(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.setState("preflight");try{let r=this.opts.getUserMedia??(t=>navigator.mediaDevices.getUserMedia(t));if(this.setState("acquiring"),this.stream=await r({audio:!1,video:{facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}}}),G(this.stream),e!==this.attempt){for(let t of this.stream.getTracks())t.stop();return}this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),this.setState("positioning"),this.scheduleTick(e)}catch(r){let t=N(r);this.setState("error"),this.emit("error",{kind:t,retryable:!0})}}rearm(e){e!==void 0&&(this.opts.side=e),this.gate.reset(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.stream)for(let e of this.stream.getTracks())e.stop();this.stream=null,this.opts.video.srcObject=null}setState(e){this.state=e,this.emit("statechange",{state:e})}scheduleTick(e){let r=this.opts.setTimer??setTimeout;this.timer=r(()=>{this.tick(e)},this.cadenceMs)}async tick(e){if(e!==this.attempt||this.state!=="positioning"||this.capturing)return;let r=this.opts.now??(()=>performance.now()),t=this.opts.grabDetectFrame??q,s=this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?Ve:We),o=t(this.opts.video,C);if(o===null){this.scheduleTick(e);return}let n=null;try{n=await s(o)}catch{n=null}if(e!==this.attempt)return;let c=n!==null?ee(o,n):o,a=r(),d={sharpness:I(c),exposure:B(c),meanLuma:K(c),specularFraction:j(c)},p=Z({format:this.opts.format??"ID-1",quad:n,frameWidth:o.width,frameHeight:o.height,measures:d,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),h=this.gate.tick({timestampMs:a,quad:n,quality:d,frameWidth:o.width,frameHeight:o.height});this.emit("checks",{engine:"docv1",p:h.p,plausible:h.plausible,stableTicks:h.stableTicks,quad:h.quad,frameWidth:o.width,frameHeight:o.height,analysis:p});let u=this.feedback.tick(J(p),a);if(u.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=u.key,this.emit("feedback",u)),h.guidanceKey!==this.lastGuidance&&(this.lastGuidance=h.guidanceKey,this.emit("guidance",{key:h.guidanceKey})),h.ready&&n!==null){let m=this.feedback.force("processing",a);this.lastFeedbackKey=m.key,this.emit("feedback",m),await this.fire(e,n,{width:o.width,height:o.height,tickSharpness:d.sharpness});return}this.scheduleTick(e)}async fire(e,r,t){this.capturing=!0;let s=this.opts.captureStill??je,o=this.opts.grabDetectFrame??q,n=this.opts.setTimer??setTimeout,c={width:t.width,height:t.height};try{let a={still:await s(this.opts.video,r,c),sharpness:t.tickSharpness};for(let d=0;d<Xe;d++){if(await new Promise(u=>{n(()=>u(),ze)}),e!==this.attempt)return;let p=o(this.opts.video,C);if(p===null)continue;let h=I(ee(p,r));if(h>a.sharpness*Ye){let u=await s(this.opts.video,r,c);if(e!==this.attempt)return;a={still:u,sharpness:h}}}if(e!==this.attempt)return;this.setState("captured"),this.emit("artifacts",{keyframe:a.still.blob,previewDataUrl:a.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{}})}catch{if(e!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.scheduleTick(e)}}},Xe=2,ze=260,Ye=1.08;function q(i,e){let r=i.videoWidth,t=i.videoHeight;if(r===0||t===0)return null;let s=Math.min(1,e/r),o=Math.round(r*s),n=Math.round(t*s),c=document.createElement("canvas");c.width=o,c.height=n;let a=c.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.drawImage(i,0,0,o,n),a.getImageData(0,0,o,n))}async function je(i,e,r){let t=document.createElement("canvas");t.width=Math.max(1,i.videoWidth),t.height=Math.max(1,i.videoHeight);let s=t.getContext("2d");if(s===null)throw new Error("2d context unavailable");return s.drawImage(i,0,0,t.width,t.height),{blob:await new Promise((n,c)=>{t.toBlob(a=>a?n(a):c(new Error("toBlob failed")),"image/jpeg",.92)}),previewDataUrl:t.toDataURL("image/jpeg",.85)}}function ee(i,e){let r=[e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x],t=[e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y],s=Math.max(0,Math.floor(Math.min(...r))),o=Math.max(0,Math.floor(Math.min(...t))),n=Math.min(i.width,Math.ceil(Math.max(...r))),c=Math.min(i.height,Math.ceil(Math.max(...t))),a=Math.max(1,n-s),d=Math.max(1,c-o),p=new Uint8ClampedArray(a*d*4);for(let h=0;h<d;h++){let u=((o+h)*i.width+s)*4;p.set(i.data.subarray(u,u+a*4),h*a*4)}return{data:p,width:a,height:d,colorSpace:i.colorSpace}}export{Ze as ASPECT_BANDS,Re as AttestationError,ze as CAPTURE_CANDIDATE_SPACING_MS,Xe as CAPTURE_EXTRA_CANDIDATES,ae as CENTERED_FACTOR,ie as CIRCLE_RADIUS_FACTOR,Ee as CLIP_MIME_ALLOWLIST,$ as CaptureSessionDoc,Ke as DOC_ANALYSIS_DEFAULTS,Qe as DOC_CADENCE_HZ,C as DOC_DETECT_WIDTH,A as DOC_FEEDBACK_STATES,V as DOC_GATE_V1_DEFAULTS,k as DocFeedbackAggregator,X as DocGateV1,Ae as INFERENCE_RETRY_ATTEMPTS,ke as INFERENCE_RETRY_DEFAULT_S,oe as IN_CIRCLE_FACTOR,Ue as MRZ_BAND_DEFAULTS,Je as MR_DOC_CATALOG,se as PRELOAD_BLAZE_INIT_TIMEOUT_MS,ne as PRELOAD_BUDGET_MS,Pe as PROCESSING_POLL_DELAY_MS,Ne as PROCESSING_POLL_MAX,Oe as REGISTRY_RETRY_DELAY_MS,fe as RETRYABLE_REASONS,Te as TRANSPORT_REPLAY_ATTEMPTS,Se as TRANSPORT_REPLAY_DELAY_MS,Ce as TURNSTILE_EXECUTE_TIMEOUT_MS,Ie as TURNSTILE_SCRIPT_SRC,Z as analyzeDocFrame,W as aspectBand,pe as createLivenessCaptureInternal,He as createVerificationInternal,re as detectIsMobile,z as detectMrzBand,Le as executeTurnstile,J as feedbackVoteOf,be as frontierStep,ge as isExecutable,_e as isTerminalView,Fe as loadTurnstile,de as mapEngineState,me as mapErrorKind,he as mapGuidanceHint,Me as mapSessionResult,ye as mergeSessionView,ue as preloadedDetectorFactory,Q as quadAreaFrac,w as quadBounds,$e as quadIou,Be as quadTiltRatio,Ge as randomUuid,le as resetLivenessAssetsForTests,we as resetTurnstileForTests,xe as runLivenessFlow,ve as runSubmission,ce as setPreloadLoaderForTests,j as specularFraction,De as stepOf,mt as warmDocDetector};
|
|
1
|
+
import{c as _e,d as Le,e as Re,g as Se,h as Te,i as le}from"../chunk-MY6EXEL2.js";import{a as wt,b as Bt,c as Vt,d as zt,e as Xt,f as Zt,g as Jt,h as Qt,i as jt,j as ae,l as se,n as Ee,o as me}from"../chunk-M43ET4NJ.js";import{b as pe,c as ie,d as ne}from"../chunk-CJHMFPL6.js";import"../chunk-RI3E7GBN.js";import{a as d,b as M,c as F,d as N,e as v}from"../chunk-O5WKNZ2C.js";import{A as yt,B as ft,C as ut,D as Ot,E as At,F as It,G as xt,H as Ct,I as Pt,J as Dt,a as We,b as ke,c as Ke,d as Je,e as Qe,f as je,g as qe,h as $e,i as et,j as tt,k as rt,l as ot,m as pt,n as it,o as nt,p as at,q as st,r as Et,s as mt,t as _t,u as Lt,v as Rt,w as St,x as Tt,y as lt,z as ct}from"../chunk-YPG7CB4O.js";import{a as Ye,b as He}from"../chunk-SMKCBUJL.js";import{a as we,b as Be,c as Ve,d as ze,e as Xe,f as Ze}from"../chunk-MXWLCDFX.js";import{a as k,b as Fe,c as Ne,d as ve,e as ge,f as be,g as Ge,h as he,i as Ue,j as K,k as w,l as B,m as Z,n as J,o as Q,p as j,q,r as $,s as ee,t as te,u as re,x as oe}from"../chunk-RNRFHUJA.js";import{a as g,b,c as G,d as h,e as U,f as Y,g as H,h as W,i as V,j as z,l as X}from"../chunk-G6LKLN4U.js";import{a as xe,b as Ce,c as Pe,d as De,e as de,f as Me}from"../chunk-TDLIXFDT.js";import{a as dt,b as Mt,c as Ft,d as Nt,e as vt,f as gt,g as bt,h as Gt,i as ht,j as Ut,k as Yt,l as Ht,m as Wt}from"../chunk-7ZCZY3ZP.js";import{a as kt,b as Kt}from"../chunk-BPE5NSQ2.js";import"../chunk-GI3UFGRQ.js";import{b as ye,c as fe,d as ue,e as Oe,g as Ae,h as qt,i as $t,j as er,k as tr,l as rr,m as or,q as Ie}from"../chunk-XLN5OT25.js";import{a as R,c as S,d as T,e as l,f as c,g as y,i as f,k as u,l as O,m as A,n as I,o as x,p as C,q as P,r as D}from"../chunk-YDQBVWXG.js";import{a as p,b as i,c as n,d as a,i as s,j as E,k as m,l as _,m as L}from"../chunk-RVHAKRAI.js";import"../chunk-7V2M6Y2W.js";import{b as e,c as t,d as r,e as o}from"../chunk-DQWW4OCK.js";import"../chunk-POIQGEZM.js";import"../chunk-FHJ7HO3M.js";import"../chunk-FPXL63KZ.js";import"../chunk-4RS2YIL4.js";import"../chunk-LQ7C44JG.js";import"../chunk-OKWG3PVH.js";import{a as ce}from"../chunk-DFTCAWMP.js";import"../chunk-DK5YPBDQ.js";export{ae as ANALYSIS_LONG_EDGE,xe as ASPECT_BANDS,C as AttestationError,Ge as BLUR_REFUSE_SHARPNESS_MAX,Dt as CAPTURE_CANDIDATE_SPACING_MS,Pt as CAPTURE_EXTRA_CANDIDATES,o as CENTERED_FACTOR,t as CIRCLE_RADIUS_FACTOR,wt as CLIPPED_LUMA,u as CLIP_MIME_ALLOWLIST,xt as CaptureSessionDoc,$t as DOCUMENT_TYPE_ORDER,Je as DOC_ANALYSIS_DEFAULTS,Ot as DOC_CADENCE_HZ,$e as DOC_CAMERA_TUNING_DEFAULTS,de as DOC_CATALOG,we as DOC_DETECT_WIDTH,We as DOC_FEEDBACK_STATES,Be as DOC_GATE_V1_DEFAULTS,At as DOC_SHUTTER_DEFAULTS,X as DocAssist,Ke as DocFeedbackAggregator,Ze as DocGateV1,Rt as EMPTY_GUIDE_METRICS,Ne as FLIP_FILL_MIN,Fe as FLIP_GAP_MS,ve as FLIP_TIMEOUT_MS,ct as GUIDE_LOCK_DEFAULTS,ft as GuideLock,Nt as ICAO_CANVAS,kt as ICAO_FALLBACK,Gt as ICAO_GATE_CRITERIA,Bt as ICAO_SHARP_REF,I as INFERENCE_RETRY_ATTEMPTS,x as INFERENCE_RETRY_DEFAULT_S,r as IN_CIRCLE_FACTOR,qt as ISSUER_CODES,pe as LANDMARKER_MODEL,ot as LENS_STORAGE_KEY,_t as LENS_TRY_MAX,z as LIVE_MRZ_DEFAULTS,Le as LIVE_PHOTO_IDLE_MS,_e as LIVE_PHOTO_MAX_HZ,ge as MANUAL_SHUTTER_MS,Ye as MRZ_BAND_DEFAULTS,De as MR_DOC_CATALOG,be as NO_REPORT_MS,ce as OCR_ASSET_SET,Te as OTP_RESEND_COOLDOWN_MS,se as PORTRAIT_JPEG_QUALITY,p as PRELOAD_BLAZE_INIT_TIMEOUT_MS,i as PRELOAD_BUDGET_MS,Se as PROCESSING_BACKOFF_MS,fe as PROCESSING_POLL_DELAY_MS,ue as PROCESSING_POLL_MAX,G as REGION_PAD,ye as REGISTRY_RETRY_DELAY_MS,R as RETRYABLE_REASONS,re as SAME_FACE_MAX_DROPS,g as SHARPNESS_LONG_EDGE,V as TEXT_LOCK_DEFAULTS,O as TRANSPORT_REPLAY_ATTEMPTS,A as TRANSPORT_REPLAY_DELAY_MS,M as TURNSTILE_EXECUTE_TIMEOUT_MS,d as TURNSTILE_SCRIPT_SRC,Q as WEB_OCR_ENGINE,tr as acceptedIssuers,er as acceptedTypesFor,qe as analyzeDocFrame,Tt as analyzeGuide,Ce as aspectBand,Pe as aspectFits,Jt as backgroundStats,$ as browserFamily,Z as buildDeviceReadHint,w as classifyCardSide,K as classifyCardSideWith,st as coverPointToVideo,oe as createDocumentCaptureInternal,ne as createFaceLandmarker,Wt as createIcaoGate,Re as createLivePhotoKit,L as createLivenessCaptureInternal,me as createPortraitCaptureInternal,le as createStepRunner,Ae as createVerificationInternal,U as cropImage,e as detectIsMobile,He as detectMrzBand,Et as docZoomFor,k as encodeDocumentImage,v as executeTurnstile,Ft as eyeLineRoll,Ut as eyeOpenness,Zt as eyeSpecular,dt as faceGeometry,Xt as faceLighting,Qt as faceSharpness,ie as facesOf,ke as feedbackVoteOf,or as flagOf,mt as focusOk,te as formatMismatch,l as frontierStep,lt as guideQuad,St as guideRegionInFrame,jt as icaoPixelStats,vt as icaoWindow,he as initialScanState,S as isExecutable,T as isTerminalView,ht as judgeIcao,tt as lensKindOf,ee as liveMrzWireReport,N as loadTurnstile,Vt as lumaPlane,m as mapEngineState,_ as mapErrorKind,E as mapGuidanceHint,f as mapSessionResult,W as measureBitmapSharpness,H as measureRegionSharpness,y as mergeSessionView,Ue as nextScanState,Ee as observePortraitFrame,Lt as openDocCamera,Ct as passportBandOf,Yt as percentile,b as photoSharpness,bt as portraitCropRegion,Ie as portraitMatchStep,Mt as poseFromMatrix,s as preloadedDetectorFactory,Ve as quadAreaFrac,Xe as quadBounds,ze as quadIou,je as quadTiltRatio,Oe as randomUuid,rt as rankBackCameras,pt as readStoredLens,zt as regionStats,a as resetLivenessAssetsForTests,F as resetTurnstileForTests,Y as resizeLongEdge,rr as resolveAcceptedDocuments,et as resolveDocCameraTuning,It as resolveDocShutterTuning,yt as resolveGuideLockTuning,Kt as resolveIcaoTuning,j as resolveWebOcrPlan,D as runLivenessFlow,P as runSubmission,Me as scannerFormatFor,Ht as scoreFrame,n as setPreloadLoaderForTests,J as settledHint,at as singleShotFocusAt,Qe as specularFraction,q as startWebOcr,c as stepOf,h as stillRegionOf,B as stillToImageData,nt as supportsFocusMode,ut as warmDocDetector,gt as windowOverflow,it as writeStoredLens};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=4,P=600,k=.5,W=30,A={frontal:.1,eyes:.1,score:.05},_=e=>e<0?0:e>1?1:e;function w(e){let r=e.eyes;if(r===void 0)return{frontal:1,yaw:null,roll:null};let a=r.right.x-r.left.x,n=r.right.y-r.left.y,t=a*a+n*n;if(t===0)return{frontal:1,yaw:null,roll:null};let s=Math.abs(Math.atan2(n,Math.abs(a))*180/Math.PI),u=_(1-s/30),o=null,l=e.nose;if(l!==void 0){let m=(r.left.x+r.right.x)/2,f=(r.left.y+r.right.y)/2;o=Math.abs(((l.x-m)*a+(l.y-f)*n)/t),u*=_(1-o/.5)}return{frontal:u,yaw:o,roll:s}}function F(e,r){return e===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:r}:{face:!0,...w(e),eyes:null,score:e.score,sharpness:r}}function v(e){let r=e.map((t,s)=>s),a=(t,s)=>{let u=Number.NEGATIVE_INFINITY;for(let o of r)u=Math.max(u,t(e[o]));r=r.filter(o=>t(e[o])>=u-s)};a(t=>t.frontal,A.frontal),a(t=>t.eyes??1,A.eyes),a(t=>t.score,A.score);let n=-1;for(let t of r)(n===-1||e[t].sharpness>e[n].sharpness)&&(n=t);return n}var i=e=>Number.isFinite(e)?Math.round(e*1e3)/1e3:0,D=99,S=999999;function T(e){return{face:e.face,frontal:i(e.frontal),...e.yaw!==null?{yaw:Math.min(i(e.yaw),D)}:{},...e.roll!==null?{roll:i(e.roll)}:{},...e.eyes!==null?{eyes:i(e.eyes)}:{},score:i(e.score),sharpness:Math.min(i(e.sharpness),S)}}var g=I;async function I(e,r){let{options:a}=e,n=a.video,t=a.now??(()=>performance.now()),s=a.captureKeyframe??(c=>e.defaultKeyframe(c)),u=600/3,o=[],l=[],m=0;for(let c=0;c<4;c+=1){if(r!==e.attempt)return null;let d=e.detector,E=Promise.resolve(null),p,y=0;try{if(d!==null){let b=e.profiler?.profile.inputWidth??160,R=a.makeSnapshot?.(n,b)??e.defaultSnapshot(n,b);p=s(n).then(K=>(y=t(),K));let N=t();E=d.detect(R,n.videoWidth,n.videoHeight).then(K=>(m+=t()-N,K),()=>null)}else p=s(n).then(b=>(y=t(),b));let[h,O]=await Promise.all([p,E]);o.push(h),l.push(F(O,h.sharpness))}catch{p?.catch(()=>{})}let M=y>0?Math.max(0,t()-y):0;c<3&&await new Promise(h=>setTimeout(h,Math.max(0,u-M)))}if(r!==e.attempt)return null;let f=v(l);if(f===-1)return null;let x=0;l.forEach((c,d)=>{c.sharpness>l[x].sharpness&&(x=d)});try{a.telemetry?.({type:"keyframe",tier:e.detector?.tier??null,chosen:f,sharpest:x,detectMs:Math.round(m),candidates:l.map(T)})}catch{}return o[f]??null}export{C as RANK_CANDIDATES,A as RANK_TOLERANCE,P as RANK_WINDOW_MS,W as ROLL_ZERO_DEG,S as SHARPNESS_REPORT_MAX,D as YAW_REPORT_MAX,k as YAW_ZERO_IOD,I as collectRankedKeyframes,g as default,F as featuresOf,w as frontalOf,v as rankKeyframes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-CJHMFPL6.js";export{a as LANDMARKER_INIT_TIMEOUT_MS,b as LANDMARKER_MODEL,d as createFaceLandmarker,c as facesOf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-SMKCBUJL.js";export{a as MRZ_BAND_DEFAULTS,b as detectMrzBand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as U}from"./chunk-A3FUGHAH.js";import{a as V,b as O,e as A,f as w,i as F}from"./chunk-MY6EXEL2.js";import{o as H}from"./chunk-M43ET4NJ.js";import"./chunk-CJHMFPL6.js";import"./chunk-RI3E7GBN.js";import{A as L,F as T,i as M}from"./chunk-YPG7CB4O.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import{x}from"./chunk-RNRFHUJA.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-7ZCZY3ZP.js";import"./chunk-BPE5NSQ2.js";import"./chunk-GI3UFGRQ.js";import{j as I}from"./chunk-YDQBVWXG.js";import"./chunk-RVHAKRAI.js";import"./chunk-7V2M6Y2W.js";import"./chunk-DQWW4OCK.js";import"./chunk-POIQGEZM.js";import"./chunk-FHJ7HO3M.js";import"./chunk-FPXL63KZ.js";import{g as B}from"./chunk-4RS2YIL4.js";import"./chunk-LQ7C44JG.js";import"./chunk-OKWG3PVH.js";import"./chunk-DFTCAWMP.js";import"./chunk-DK5YPBDQ.js";function _(t){let a=null,c=Promise.resolve(),u=!1,g=null,y=null,C=null,h=!1,m=()=>{a?.controller.handle.destroy(),a=null},k=()=>{let i=t.currentView(),s=i===null?null:w(i,{isMobile:t.isMobile()});return s?.kind==="portrait"?s:null},P=async(i,s)=>{if(t.destroyed())return;s.setFlowState("uploading"),u=!1;let d=null;try{await t.runner().submit("portrait_icao",async(n,r)=>{if(d===null){let p=await I(n,"image","image/jpeg",i.image.size,{engine:"portrait"});await n.uploadToSpaces(p.uploadUrl,i.image,"image/jpeg"),d=(await n.completeMedia(p.key)).key}s.setFlowState("checking");let l={media:{portrait:d},gate:B(i.gate),...i.tuningVersion!==void 0?{tuningVersion:i.tuningVersion}:{}};return n.submitCheck("portrait_icao",l,{idempotencyKey:r})},()=>{g=d})}catch{u=!0}if(s.setFlowState("done"),t.destroyed())return;let e=k();(e===null||e.phase!=="capture")&&a?.controller===s&&m(),t.runner().republish()},b=i=>t.runner().submit("face_match",(s,d)=>s.submitCheck("face_match",g!==null?{imageKey:g}:{},{idempotencyKey:d})).then(()=>{},()=>{u=!0,i()});return{bind:(i,s)=>{if(i.phase==="match")return m(),y!==i.attemptsRemaining&&!u&&(y=i.attemptsRemaining,b(s)),{...i,uploadFailed:u,resubmit:()=>(u=!1,y=i.attemptsRemaining,s(),b(s)),capture:()=>{throw new Error("the portrait was already accepted")}};y=null;let d=t.keptPortraitInput?.()??null;return d!==null&&(h||d!==C&&i.report===null&&i.reason===void 0&&!i.retakeOnly)?(h||(C=d,h=!0,t.runner().submit("portrait_icao",(e,n)=>e.submitCheck("portrait_icao",d,{idempotencyKey:n}),()=>{g=d.media.portrait}).catch(()=>{}).finally(()=>{h=!1,s()})),{kind:"processing",key:"processing",context:i.context,section:i.section,stalled:!1,refresh:()=>Promise.resolve()}):{...i,uploadFailed:u,resubmit:()=>Promise.resolve(),capture:e=>{if(a!==null&&a.video===e.video)return a.controller.handle;m(),u=!1;let n=H({video:e.video,tuning:i.tuning,tuningVersion:i.tuningVersion,...i.icao!=null?{policy:i.icao.policy}:{},...e.keepScreenAwake!==void 0?{keepScreenAwake:e.keepScreenAwake}:{},...e.assetBaseUrl!==void 0?{assetBaseUrl:e.assetBaseUrl}:{}},t.internals);return a={video:e.video,controller:n},n.handle.on("captured",r=>{c=c.then(()=>P(r,n)).catch(()=>{})}),n.handle}}},destroy:m}}function z(t){let a=t;if(typeof a.apiOrigin!="string"||typeof a.sessionToken!="string")return;let c=`${a.apiOrigin}/api/v2/hosted/capture-reports`,u=a.sessionToken;return g=>{try{fetch(c,{method:"POST",headers:{"content-type":"application/json","x-session-token":u},body:JSON.stringify({reports:g}),keepalive:!0}).catch(()=>{})}catch{}}}function j(t){let a=t.apiOrigin;return U("sdk",typeof a=="string"&&/staging|sandbox|localhost/.test(a)?"sandbox":"live")}function oe(t){let a=null,c=null,u=null,g=Promise.resolve(),y=()=>{u?.flow.handle.destroy(),u=null},C=async(e,n)=>{if(t.destroyed())return;n.setFlowState("uploading");let r=null,l,p=!1;try{await a.submit("doc_ocr",async(S,K)=>{if(r===null){let R=await I(S,"image","image/jpeg",e.image.size,{engine:"document"});await S.uploadToSpaces(R.uploadUrl,e.image,"image/jpeg"),r=(await S.completeMedia(R.key)).key}return n.setFlowState("checking"),l===void 0&&(l=n.takeDeviceRead(e)),S.submitCheck("doc_ocr",{imageKey:r,side:e.side,...l!==null?{deviceRead:l}:{}},{idempotencyKey:K})})}catch{p=!0}finally{n.setFlowState("done")}if(t.destroyed())return;if(p){n.settle(e.side,{ok:!1,issue:"technical"});return}let v=t.currentView(),o=v===null?null:w(v,{isMobile:t.isMobile()});if(o?.kind!=="document"){n.settle(e.side,{ok:!0}),u?.flow===n?y():n.handle.destroy();return}if(o.reason==="document_type_not_accepted"){c=null,u?.flow===n&&y(),a.republish();return}e.side==="single"||o.acceptedSides.includes(e.side)||o.reason==="side_missing"?(n.settle(e.side,{ok:!0}),c?.documentType!=="passport"&&n.handle.setSide(o.side)):n.settle(e.side,{ok:!1,issue:"reread"})},h=(e,n)=>({...e,issuer:c?.issuer??null,documentType:c?.documentType??null,captureSide:c===null?null:c.documentType==="passport"?"single":e.side,selectDocument:(r,l)=>{if(!O(e.documents).includes(r)||!V(e.documents,r).includes(l))throw new RangeError(`${l} from ${r} is not accepted`);(c?.issuer!==r||c.documentType!==l)&&y(),c={issuer:r,documentType:l},n()},capture:r=>{if(c===null)throw new Error("selectDocument() first");if(u!==null&&u.video===r.video)return u.flow.handle;y();let l=c,p=l.documentType==="passport"?"single":e.acceptedSides.length>0?e.side:void 0,v=x({video:r.video,documentType:l.documentType,issuer:l.issuer,...p!==void 0?{side:p}:{},...r.keepScreenAwake!==void 0?{keepScreenAwake:r.keepScreenAwake}:{},...r.liveMrz!==void 0?{liveMrz:r.liveMrz}:{}},{...t.documentInternals??{},...(()=>{let o=t.currentView()?.capture?.document,f=t.documentInternals?.blurRefuseSharpnessMax??o?.scan?.blurRefuseSharpnessMax;return{engineOptions:{camera:M(o?.camera),shutter:T(o?.scan),guideLock:L(o?.guide),...t.documentInternals?.engineOptions??{}},...typeof f=="number"&&Number.isFinite(f)&&f>=0&&f<=1?{blurRefuseSharpnessMax:f}:{}}})(),deferRead:!0,...(()=>{let o=t.currentView();if(o===null||t.documentInternals?.webOcr!==void 0)return{};let f=z(t.runtime.client);return{webOcr:{captureDocument:o.capture?.document,salt:o.sessionId,baseUrl:j(t.runtime.client),...f!==void 0?{reports:f}:{}}}})()});return u={video:r.video,flow:v},v.handle.on("captured",o=>{g=g.then(()=>C(o,v)).catch(()=>{})}),v.handle}}),m=null,k=null,P=new Set,b=t.runtime.client;t.runtime.client=new Proxy(b,{get(e,n){if(n==="submitCheck")return(k??e).submitCheck.bind(k??e);let r=Reflect.get(e,n);return typeof r=="function"?r.bind(e):r}});let D=()=>{m?.destroy(),m=null,k=null},i=e=>{let n=t.currentView(),r=n===null?null:w(n,{isMobile:t.isMobile()});if(n===null||r?.kind!=="liveness"||r.livePhoto?.icao!==!0)return;if(m===null){let o=A({tuning:n.capture?.icao??null,tuningVersion:n.capture?.tuningVersion??null,...r.icao!=null?{policy:r.icao.policy}:{},still:r.livePhoto.still,...e.assetBaseUrl!==void 0?{assetBaseUrl:e.assetBaseUrl}:{}},t.livePhotoInternals);m=o,k=o.decorate(b),o.onGate(f=>{for(let S of P)S(f)})}let l=m,p=t.baseCapture??{},v=p.engineOptions?.telemetry;return{...p,engineOptions:{...p.engineOptions??{},measureQuality:l.engineOptions.measureQuality,telemetry:o=>{v?.(o),l.engineOptions.telemetry(o)}}}},s=_({keptPortraitInput:()=>m?.lastPortraitInput()??null,runner:()=>a,currentView:t.currentView,destroyed:t.destroyed,isMobile:t.isMobile,...t.portraitInternals!==void 0?{internals:t.portraitInternals}:{}}),d=F({...t,bindDocument:h,bindPortrait:s.bind,onLivePhoto:e=>(P.add(e),()=>P.delete(e))});return a=d,{...d,captureInternals:i,destroy:()=>{y(),s.destroy(),D(),P.clear()}}}export{oe as createPlanRunner,j as sdkAssetBase};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c="selfie_segmenter.tflite";function l(t){if(t===void 0||t.length===0)return null;let r=t.length===1,n=t[0],s=Float32Array.from(n.getAsFloat32Array());if(!r)for(let e=0;e<s.length;e+=1)s[e]=1-s[e];return{data:s,width:n.width,height:n.height}}async function u(t){let r=t.replace(/\/+$/,""),n=await import("@mediapipe/tasks-vision"),s=await n.FilesetResolver.forVisionTasks(r),e=await n.ImageSegmenter.createFromOptions(s,{baseOptions:{modelAssetPath:`${r}/${c}`,delegate:"CPU"},runningMode:"VIDEO",outputConfidenceMasks:!0,outputCategoryMask:!1});return{segment(i,a){try{let o=e.segmentForVideo(i,a);try{return l(o.confidenceMasks)}finally{o.close?.()}}catch{return null}},close(){try{e.close()}catch{}}}}export{c as SEGMENTER_MODEL,u as createSelfieSegmenter,l as personMaskOf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-O5WKNZ2C.js";export{b as TURNSTILE_EXECUTE_TIMEOUT_MS,a as TURNSTILE_SCRIPT_SRC,e as executeTurnstile,d as loadTurnstile,c as resetTurnstileForTests};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sekyro/web",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
4
|
-
"description": "Sekyro AI web SDK
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.1.0-rc.8",
|
|
4
|
+
"description": "Sekyro AI web SDK \u2014 browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/IBTIKAR-Technologies/ibtikar-identity.git",
|
|
@@ -57,6 +57,17 @@
|
|
|
57
57
|
"default": "./dist/core/v3/detect-worker.cjs"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
+
"./core/ocr/worker": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/core/ocr/worker.d.ts",
|
|
63
|
+
"default": "./dist/core/ocr/worker.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/core/ocr/worker.d.cts",
|
|
67
|
+
"default": "./dist/core/ocr/worker.cjs"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./core/ocr/worker.bundle.js": "./dist/core/ocr/worker.bundle.js",
|
|
60
71
|
"./client": {
|
|
61
72
|
"import": {
|
|
62
73
|
"types": "./dist/client/index.d.ts",
|
|
@@ -93,6 +104,7 @@
|
|
|
93
104
|
"README.md",
|
|
94
105
|
"CHANGELOG.md",
|
|
95
106
|
"LICENSE",
|
|
107
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
96
108
|
"sbom.cdx.json"
|
|
97
109
|
],
|
|
98
110
|
"scripts": {
|
|
@@ -100,7 +112,12 @@
|
|
|
100
112
|
"test": "vitest run",
|
|
101
113
|
"typecheck": "tsc --noEmit",
|
|
102
114
|
"api:report": "api-extractor run --local",
|
|
103
|
-
"api:check": "api-extractor run"
|
|
115
|
+
"api:check": "api-extractor run",
|
|
116
|
+
"check:lazy-doc": "node scripts/check-lazy-doc.mjs",
|
|
117
|
+
"check:lazy-portrait": "node scripts/check-lazy-portrait.mjs",
|
|
118
|
+
"size": "node scripts/check-size.mjs",
|
|
119
|
+
"gen:ocr-assets": "node scripts/gen-ocr-assets.mjs",
|
|
120
|
+
"check:ocr-assets": "node scripts/gen-ocr-assets.mjs --check && node scripts/check-ocr-assets.mjs"
|
|
104
121
|
},
|
|
105
122
|
"dependencies": {
|
|
106
123
|
"@mediapipe/tasks-vision": "0.10.35"
|
|
@@ -109,6 +126,7 @@
|
|
|
109
126
|
"@microsoft/api-extractor": "^7.59.4",
|
|
110
127
|
"@types/node": "^22",
|
|
111
128
|
"@vitest/coverage-v8": "^3",
|
|
129
|
+
"jpeg-js": "0.4.4",
|
|
112
130
|
"jsdom": "^25",
|
|
113
131
|
"tsup": "^8",
|
|
114
132
|
"typescript": "^5.7",
|
package/sbom.cdx.json
CHANGED
|
@@ -97,18 +97,18 @@
|
|
|
97
97
|
"type": "application",
|
|
98
98
|
"name": "web",
|
|
99
99
|
"group": "@sekyro",
|
|
100
|
-
"version": "0.1.0-rc.
|
|
101
|
-
"bom-ref": "@sekyro/web@0.1.0-rc.
|
|
100
|
+
"version": "0.1.0-rc.8",
|
|
101
|
+
"bom-ref": "@sekyro/web@0.1.0-rc.8",
|
|
102
102
|
"description": "Sekyro AI web SDK — browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
|
|
103
103
|
"licenses": [
|
|
104
104
|
{
|
|
105
105
|
"license": {
|
|
106
|
-
"name": "
|
|
106
|
+
"name": "SEE LICENSE IN LICENSE",
|
|
107
107
|
"acknowledgement": "declared"
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
],
|
|
111
|
-
"purl": "pkg:npm/%40sekyro/web@0.1.0-rc.
|
|
111
|
+
"purl": "pkg:npm/%40sekyro/web@0.1.0-rc.8?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-web",
|
|
112
112
|
"externalReferences": [
|
|
113
113
|
{
|
|
114
114
|
"url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"name": "tasks-vision",
|
|
151
151
|
"group": "@mediapipe",
|
|
152
152
|
"version": "0.10.35",
|
|
153
|
-
"bom-ref": "@sekyro/web@0.1.0-rc.
|
|
153
|
+
"bom-ref": "@sekyro/web@0.1.0-rc.8|@mediapipe/tasks-vision@0.10.35",
|
|
154
154
|
"licenses": [
|
|
155
155
|
{
|
|
156
156
|
"license": {
|
|
@@ -183,13 +183,13 @@
|
|
|
183
183
|
],
|
|
184
184
|
"dependencies": [
|
|
185
185
|
{
|
|
186
|
-
"ref": "@sekyro/web@0.1.0-rc.
|
|
186
|
+
"ref": "@sekyro/web@0.1.0-rc.8",
|
|
187
187
|
"dependsOn": [
|
|
188
|
-
"@sekyro/web@0.1.0-rc.
|
|
188
|
+
"@sekyro/web@0.1.0-rc.8|@mediapipe/tasks-vision@0.10.35"
|
|
189
189
|
]
|
|
190
190
|
},
|
|
191
191
|
{
|
|
192
|
-
"ref": "@sekyro/web@0.1.0-rc.
|
|
192
|
+
"ref": "@sekyro/web@0.1.0-rc.8|@mediapipe/tasks-vision@0.10.35"
|
|
193
193
|
}
|
|
194
194
|
]
|
|
195
195
|
}
|
package/dist/chunk-B45J4KC3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as d}from"./chunk-FPXL63KZ.js";var y={"ID-1":{center:1.586,tolerance:.15},"ID-3":{center:1.42,tolerance:.2}};function f(t){return y[t]}var M=[{docType:"carte_identite",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"},{docType:"passport",format:"ID-3",sides:["single"],mrz:"td3",portraitSide:"single",aspectRatio:1.42,identifierSource:"mrz"}];var C=480,I=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),D=t=>Math.min(1,Math.max(0,t));function E(t,o,e){let n=[t.topLeft,t.topRight,t.bottomRight,t.bottomLeft],a=0;for(let r=0;r<4;r++){let c=n[r],m=n[(r+1)%4];a+=c.x*m.y-m.x*c.y}let i=o*e;return i>0?Math.abs(a/2)/i:0}function R(t,o){let e=b(t),n=b(o),a=Math.max(e.x1,n.x1),i=Math.max(e.y1,n.y1),r=Math.min(e.x2,n.x2),c=Math.min(e.y2,n.y2),m=Math.max(0,r-a)*Math.max(0,c-i),u=(e.x2-e.x1)*(e.y2-e.y1),p=(n.x2-n.x1)*(n.y2-n.y1),h=u+p-m;return h>0?m/h:0}function S(t){let o=b(t);return{width:o.x2-o.x1,height:o.y2-o.y1}}function b(t){let o=[t.topLeft,t.topRight,t.bottomRight,t.bottomLeft];return{x1:Math.min(...o.map(e=>e.x)),y1:Math.min(...o.map(e=>e.y)),x2:Math.max(...o.map(e=>e.x)),y2:Math.max(...o.map(e=>e.y))}}function g(t){let o=Math.hypot(t.topRight.x-t.topLeft.x,t.topRight.y-t.topLeft.y),e=Math.hypot(t.bottomRight.x-t.bottomLeft.x,t.bottomRight.y-t.bottomLeft.y),n=Math.hypot(t.bottomLeft.x-t.topLeft.x,t.bottomLeft.y-t.topLeft.y),a=Math.hypot(t.bottomRight.x-t.topRight.x,t.bottomRight.y-t.topRight.y),i=(o+e)/2,r=(n+a)/2;return i<=0||r<=0?0:Math.max(i,r)/Math.min(i,r)}var x=class{constructor(o,e={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...I,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:e,quality:n,timestampMs:a}=o,i=this.lastTickAt===null?0:Math.max(0,(a-this.lastTickAt)/1e3);this.lastTickAt=a;let r=null;if(e===null)r="dcv1.no_doc";else if(this.format==="ID-3"){let s=S(e),_=s.height>0?s.width/s.height:0;s.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?r="dcv1.come_closer":this.edgeClipped(e,o.frameWidth,o.frameHeight)?r="dcv1.fit_document":(_<this.t.ID3_BAND_ASPECT_MIN||_>this.t.ID3_BAND_ASPECT_MAX)&&(r="dcv1.wrong_shape")}else if(E(e,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC)r="dcv1.come_closer";else if(this.edgeClipped(e,o.frameWidth,o.frameHeight))r="dcv1.fit_document";else{let s=f(this.format),_=g(e);Math.abs(_-s.center)>s.tolerance&&(r="dcv1.wrong_shape")}let c=r===null,m=D(n.exposure)>=this.t.GUIDE_EXPOSURE,u=D(n.sharpness)>=this.t.GUIDE_SHARPNESS,p=m&&u;if(c&&p&&e!==null){let s=this.lastQuad===null||R(e,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=s?this.streak+1:1}else this.streak=0;this.lastQuad=e;let h=c&&p;this.p=D(this.p+(h?this.t.RISE_PER_S:-this.t.FALL_PER_S)*i);let A=h&&this.streak>=this.t.STABLE_TICKS,l;if(r!==null)l=r;else if(m)u?l="dcv1.hold_still":l="dcv1.steady";else{let s=(d[0]+d[1])/2;l=n.meanLuma<s?"dcv1.more_light":"dcv1.too_bright"}return{at:a,quad:e,plausible:c,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,e,n){let a=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(r=>r.x<=a||r.y<=a||r.x>=e-a||r.y>=n-a)}};export{y as a,f as b,M as c,C as d,I as e,E as f,R as g,S as h,x as i};
|
package/dist/chunk-BMA36W2W.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var y=1e4,d=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=p(e),s=w(r.keypoints,a),c={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},score:r.categories[0]?.score??0};return l(c,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function v(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],h=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function p(t){let e=t;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 i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=p(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function x(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await v();if(n.ok)return new m(n.instance,g(i));i.push(`native:${n.reason}`);continue}try{return await S(d.create(t.v3AssetBaseUrl??F,g(i)),t.blazeInitTimeoutMs??y)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new h(g(i)??"no_tier_available")}function g(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var u=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??x,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==u){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:u,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:u,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var k=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==u||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=D=>{let b=D.data;b.v!==u||b.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,b)))};e.addEventListener("message",s);let c={v:u,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:u,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,h as c,p as d,l as e,x as f,u as g,A as h,M as i,k as j};
|
package/dist/chunk-P7ECRN47.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as we,b as Q,k as ye}from"./chunk-YQBK6OIM.js";import{c as U,d as Se,e as be}from"./chunk-YOB4ZTYN.js";import{a as ge,f as F}from"./chunk-BMA36W2W.js";var Ue=12e4,_e=13e4,qe=3e3,Ke=1200,Z=Symbol.for("@sekyro/web.preload.v1");function H(){let e=globalThis;return e[Z]??(e[Z]=new Map),e[Z]}function q(e){let t=(e??ge).replace(/\/+$/,"");return t===""?"/":t}function Ce(e){let t=H(),n=t.get(e);return n===void 0&&(n={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,n)),n}function J(e,t){if(e.status!==t){e.status=t;for(let n of[...e.listeners])n(t)}}var re=e=>F({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:Ue}),se=re;function At(e){se=e??re}function Pt(){for(let e of H().values())e.detector?.destroy();H().clear(),se=re}function Be(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function Ne(){return navigator.connection?.saveData===!0}function We(e){let t=window;if(typeof t.requestIdleCallback=="function"){let i=t.requestIdleCallback(e,{timeout:qe});return()=>t.cancelIdleCallback?.(i)}let n=setTimeout(e,Ke);return()=>clearTimeout(n)}function Ye(e,t){let n,i=new Promise(d=>{n=d}),s=!1,l=()=>{},u={promise:i,settle:d=>{s||(s=!0,l(),e.scheduled===u&&(e.scheduled=null),n(d))}};return e.scheduled=u,l=We(()=>{s||u.settle(oe(e,t))}),i}function oe(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;J(e,"loading");let n=new Promise(d=>d(se(t)));e.detectorPromise=n;let i,s=new Promise((d,o)=>{i=setTimeout(()=>{n.then(c=>c.destroy(),()=>{}),o(new Error(`detector preload exceeded ${_e} ms`))},_e)}),u=Promise.race([n,s]).then(d=>e.detectorPromise!==n?(d.destroy(),e.status):(e.detector=d,J(e,"ready"),"ready"),d=>(e.detectorPromise===n&&(e.detectorPromise=null,e.detector=null,J(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",d)),e.status)).finally(()=>clearTimeout(i));return e.promise=u,e.scheduled?.settle(u),u}function xt(e={}){if(!Be())return Promise.resolve("idle");let t=q(e.assetBaseUrl),n=Ce(t);return e.respectSaveData===!0&&Ne()?Promise.resolve(n.status):(n.status==="loading"||n.status==="ready")&&n.promise!==null?n.promise:e.idle===!0?n.scheduled?.promise??Ye(n,t):oe(n,t)}function Mt(e){return H().get(q(e))?.status??"idle"}function Vt(e,t){let n=Ce(q(t));return n.listeners.add(e),()=>{n.listeners.delete(e)}}function It(e){let t=H().get(q(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,J(t,"idle"))}function $e(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function Ee(e){let t=q(e),n=H().get(t);if(!(n===void 0||n.detector===null&&n.detectorPromise===null&&n.scheduled===null))return async()=>{n.scheduled!==null&&oe(n,t);let i=n.promise;for(;n.detector===null&&i!==null&&(await i,n.promise!==i);)i=n.promise;return n.detector!==null?$e(n.detector):F({v3AssetBaseUrl:t})}}function ee(){let e=new Map;return{on(t,n){let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i));let s=n;return i.add(s),()=>{i?.delete(s)}},emit(t,n){let i=e.get(t);if(i!==void 0)for(let s of[...i])s(n)},clear(){e.clear()}}}function ke(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let e=navigator.wakeLock;return typeof e?.request=="function"?e:null}function Le(){return typeof document>"u"||document.visibilityState==="visible"}function Re(e){try{e.release().catch(()=>{})}catch{}}function Te(e={}){if(e.enabled===!1)return{setActive:()=>{}};let t=!1,n=null,i=!1,s=!1,l=()=>{if(!t||i||n!==null&&!n.released)return;let o=ke();if(o===null||!Le())return;let c;try{c=o.request("screen")}catch{return}i=!0,c.then(p=>{if(i=!1,!t){Re(p);return}n=p,p.addEventListener?.("release",()=>{n===p&&(n=null)})},()=>{i=!1})},u=()=>{Le()&&l()},d=o=>{typeof document>"u"||o===s||(s=o,o?document.addEventListener("visibilitychange",u):document.removeEventListener("visibilitychange",u))};return{setActive:o=>{if(t=o,o){if(ke()===null)return;d(!0),l();return}if(d(!1),n!==null){let c=n;n=null,Re(c)}}}}function ze(e){switch(e){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";default:return null}}function Ge(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";case"idle":case"recording":case"captured":case"error":return e;default:{let t=e;throw new Error(`mapEngineState: unhandled state ${t}`)}}}function Xe(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;case"overconstrained":case"generic":case"models":case"cliptoolarge":case"recorder":return"generic";default:{let t=e;throw new Error(`mapErrorKind: unhandled kind ${t}`)}}}function ae(e,t={}){let n=t.now??(()=>performance.now()),i=ee(),s=!ye(),l=t.engineOptions,u=l?.createDetector===void 0&&l?.createWorker===void 0?{createDetector:()=>{let a=Ee(e.assetBaseUrl);return a!==void 0?a():F(e.assetBaseUrl!==void 0?{v3AssetBaseUrl:e.assetBaseUrl}:{})}}:{},d={video:e.video,mode:s?"photo":"clip",...e.facing!==void 0?{facingMode:e.facing}:{},...e.assetBaseUrl!==void 0?{v3AssetBaseUrl:e.assetBaseUrl}:{},...t.engineOptions??{},...u},o=t.createEngine?.(d)??new we(d),c="idle",p=null,h=0,m=!1,_="full",y=null,v=null,C=0,P=0,M=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(C=e.video.videoWidth,P=e.video.videoHeight)},O=Te({enabled:e.keepScreenAwake!==!1}),x=a=>{c=a,O.setActive(a==="starting"||a==="gating"||a==="recording"),i.emit("state",a)},V=()=>i.emit("gate",{progress:h,hint:p,faceDetected:m}),D=()=>{let a=o.animations??"full";a!==_&&(_=a,i.emit("profile",{animations:_}))},G=[o.on("statechange",({state:a})=>{let b=Ge(a);b==="starting"&&c!=="starting"&&(p=null,h=0,m=!1,y=null,v=null,C=0,P=0),x(b),D(),b==="recording"&&(M(),y=n(),p="hold",h=1,V())}),o.on("checks",a=>{M(),h=a.progress,m=a.factors.presence>0,V(),D()}),o.on("guidance",({key:a})=>{p=ze(a),V()}),o.on("frozen",({previewDataUrl:a})=>{v=n(),i.emit("frozen",{previewDataUrl:a})}),o.on("artifacts",a=>{let b=y!==null&&v!==null?Math.max(0,Math.round(v-y)):void 0;i.emit("captured",{keyframe:a.keyframe,...a.clip!==void 0?{clip:a.clip}:{},...a.clipMimeType!==void 0?{clipMime:a.clipMimeType}:{},width:e.video.videoWidth||C,height:e.video.videoHeight||P,...b!==void 0?{clipMs:b}:{},captureChannel:Q()?"mobile":"desktop",...s?{degraded:"NO_RECORDER"}:{},engine:"v3",...a.timing?.cameraReadyMs!==void 0?{cameraReadyMs:a.timing.cameraReadyMs}:{},...a.timing?.faceAcquireMs!==void 0?{faceAcquireMs:a.timing.faceAcquireMs}:{},...a.timing?.captureMs!==void 0?{captureMs:a.timing.captureMs}:{}})}),o.on("error",({kind:a,retryable:b})=>{i.emit("error",{kind:Xe(a),retryable:b})})];return{handle:{get state(){return c},on:(a,b)=>i.on(a,b),start:a=>o.start(a?.facing!==void 0?{facingMode:a.facing}:{}),retry:()=>o.retry(),switchCamera:()=>o.switchCamera(),destroy:()=>{for(let a of G)a();O.setActive(!1),o.destroy(),i.clear()}},setFlowState:a=>{c!==a&&x(a)}}}function Yt(e){return ae(e).handle}var je=new Set(["no_face","media_unreadable","clip_too_short","no_face_source","side_missing","unreadable","registry_unavailable","otp_mismatch","otp_expired","otp_send_failed","document_type_not_accepted","age_unverifiable","liveness_inconclusive","match_inconclusive","document_authenticity"]);function N(e){let t=e.methodChoice;return t===void 0||!t.available||t.selected!==null||A(e)?.checkType==="phone_otp"?null:t}var Qe=new Set(["liveness","face_match"]);function W(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function R(e){return e.status!=="created"&&e.status!=="in_progress"}function A(e){return e.steps.find(t=>W(t))}function T(e,t){return e.steps.find(n=>n.checkType===t)}function ue(e,t){let n=t.steps.find(s=>s.checkType==="liveness"),i=t.steps.find(s=>s.checkType==="face_match");return T(e,"face_match")?.state==="pending"&&(n?.state==="passed"||n?.state==="review")&&i!==void 0&&i.state!=="pending"&&i.state!=="skipped"}function Ae(e,t,n){let i=new Map(e.steps.map(u=>[u.checkType,u])),s=n==="liveness"&&ue(e,t),l=t.steps.map(u=>{let d=i.get(u.checkType),o=d?.attemptsRemaining??0,c={...d??{},checkType:u.checkType,state:u.state,attemptsRemaining:u.checkType===n||u.checkType==="face_match"&&s?Math.max(0,o-1):o};return u.reason!==void 0?c.reason=u.reason:delete c.reason,u.attemptsExhausted!==void 0?c.attemptsExhausted=u.attemptsExhausted:delete c.attemptsExhausted,c});return{...e,status:t.status,outcome:t.outcome,failureReason:t.failureReason,steps:l,expiresAt:t.expiresAt}}function L(e,t){return t===void 0?{sessionId:e,status:"unavailable"}:{sessionId:e,status:"unavailable",reason:t}}function K(e,t,n){return n===void 0?{sessionId:e,status:t}:{sessionId:e,status:t,reason:n}}function le(e,t){let{sessionId:n}=e;switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:n,status:"approved"}:e.outcome==="review"?K(n,"review",B(e,"review")):K(n,"rejected",B(e,"failed"));case"failed":{let s=K(n,"rejected",e.failureReason??B(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}case"review_pending":return K(n,"review",B(e,"review"));case"expired":return L(n);case"created":case"in_progress":break;default:{let s=e.status;throw new Error(`mapSessionResult: unhandled status ${s}`)}}let i=e.steps.find(s=>Qe.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return L(n,"mobile_required");if(i?.reason!==void 0){let s=t.autoRetry&&je.has(i.reason)&&i.attemptsRemaining>0;return{sessionId:n,status:s?"retry":"rejected",reason:i.reason,attemptsRemaining:i.attemptsRemaining}}return A(e)===void 0&&e.steps.some(s=>s.state==="review")?K(n,"review",B(e,"review")):L(n)}function B(e,t){return e.steps.find(n=>n.state===t&&n.reason!==void 0)?.reason}var Ze=["video/webm","video/mp4"],Pe="image/jpeg",Je=2,et=1e3,tt=1e4,nt=3,it=10,rt=30,st=3,ot=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),at=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order"]),Y=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function ut(e){let t=e.steps.findIndex(i=>i.checkType==="liveness");return t<0?!1:e.steps.slice(t+1).find(i=>W(i))?.checkType==="face_match"}var $=class extends Error{constructor(t){super(t),this.name="AttestationError"}};async function te(e,t,n={}){let i=e.uuid(),s=!1,l=!1,u=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof $){if(l)throw o;l=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof U))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!l){l=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<nt){d+=1;let c=Math.min(o.retryAfterSeconds??it,rt);e.onBusy?.({attempt:d,retryAfterSeconds:c}),await e.sleep(c*1e3),n.onAttestationInvalid?.(),i=e.uuid();continue}if(ot.has(o.code)&&u<Je){u+=1;let c=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(c!==void 0?Math.min(c,tt):et);continue}throw o}}var lt=new Set(["passed","review","processing","skipped"]);async function xe(e){let{artifacts:t}=e,n=t.clip,i=Se(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!Ze.includes(i))return{kind:"unavailable",reason:"no_recorder"};let s=ct(e,t.keyframe),l=dt(e,n,i,s),u=ft(e,s),d=!1,o=!1,c=!0,p=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let h=e.getView();if(R(h))return{kind:"settled"};let m=A(h)?.checkType,_=m==="liveness"&&!d?"liveness":m==="face_match"&&!o&&c?"face_match":null;if(_===null)return{kind:"settled"};if(_==="liveness"&&t.captureChannel==="desktop"&&T(h,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(_==="liveness"){d=!0;let y=await l();if(e.isCancelled())return{kind:"cancelled"};o=ue(h,y),e.applySubmit(y,"liveness");let v=T(e.getView(),"liveness")?.state;c=v===void 0||lt.has(v)}else{o=!0;let y=await u();if(e.isCancelled())return{kind:"cancelled"};e.applySubmit(y,"face_match")}}catch(y){if(e.isCancelled()||y instanceof Y)return{kind:"cancelled"};let v=mt(y);if(v.kind!=="resync"||p>=st)return v;p+=1,await e.refreshView()}}}function ct(e,t){let n=null,i=null,s=()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let l=await e.client.presign("image",Pe,t.size);return await e.client.uploadToSpaces(l.uploadUrl,t,Pe),n=(await e.client.completeMedia(l.key)).key,n})().finally(()=>{i=null})),i);return{ensure:s,attempt:()=>s().catch(()=>null),current:()=>n}}function dt(e,t,n,i){let s=null,l,u=null;return()=>te(e,async(d,o)=>{if(s===null||l===void 0){if(e.isCancelled())throw new Y;l===void 0&&!ut(e.getView())&&(l=null),e.onPhase("uploading");let[c,p]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let h=await d.presign("clip",n,t.size);return await d.uploadToSpaces(h.uploadUrl,t,n),(await d.completeMedia(h.key)).key})(),l!==void 0?Promise.resolve(l===null?null:l.imageKey):i.attempt()]);s=c,l===void 0&&(l=p===null?null:{imageKey:p})}if(u===null)try{u=await e.getAttestation()}catch(c){throw new $(c instanceof Error?c.message:String(c))}return e.onPhase("checking"),d.submitCheck("liveness",{clipKey:s,attestation:u,captureChannel:e.artifacts.captureChannel,capture:pt(e.artifacts),...l!==null?{faceMatch:l}:{}},{idempotencyKey:o})},{onAttestationInvalid:()=>{u=null}})}function ft(e,t){return()=>te(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new Y;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}function pt(e){return{...e.engine!==void 0?{engine:e.engine}:{},width:e.width,height:e.height,...e.clipMs!==void 0?{clipMs:e.clipMs}:{},...e.cameraReadyMs!==void 0?{cameraReadyMs:e.cameraReadyMs}:{},...e.faceAcquireMs!==void 0?{faceAcquireMs:e.faceAcquireMs}:{},...e.captureMs!==void 0?{captureMs:e.captureMs}:{}}}function mt(e){if(e instanceof $)return{kind:"unavailable",reason:"attestation"};if(e instanceof U){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="method_required")return{kind:"unavailable",reason:"method_required"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(at.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var vt="https://challenges.cloudflare.com/turnstile/v0/api.js",Zt=3e4;function Me(){return window.turnstile}var z=null;function Jt(){z=null}function ht(){return z??(z=new Promise((e,t)=>{let n=Me();if(n){e(n);return}let i=document.createElement("script");i.src=vt,i.async=!0,i.onload=()=>{let s=Me();s?e(s):(z=null,t(new Error("Turnstile script loaded but exposed no API")))},i.onerror=()=>{z=null,i.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(i)})),z}function ce(){return new Error("Turnstile challenge aborted")}async function Ve(e,t={}){let n=t.timeoutMs??3e4,i=t.signal;if(i?.aborted)throw ce();let s=await ht();if(i?.aborted)throw ce();let l=document.createElement("div");document.body.appendChild(l);let u,d,o;try{return await new Promise((c,p)=>{if(d=setTimeout(()=>p(new Error(`Turnstile challenge timed out (${n} ms)`)),n),i!==void 0&&(o=()=>p(ce()),i.addEventListener("abort",o,{once:!0})),u=s.render(l,{sitekey:e,execution:"execute",appearance:"execute",callback:c,"error-callback":h=>{p(new Error(`Turnstile challenge failed${h?` (${h})`:""}`))}}),u===void 0){p(new Error("Turnstile render returned no widget id"));return}s.execute(u)})}finally{if(clearTimeout(d),i!==void 0&&o!==void 0&&i.removeEventListener("abort",o),u!==void 0)try{s.remove(u)}catch{}l.remove()}}var yt="https://api.sekyro.ai",gt=5e3,wt=1500,St=10;function bt(e){return new Promise(t=>setTimeout(t,e))}function _t(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let n=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function cn(e){return Ct(e,{})}function Ct(e,t){let n=e.apiOrigin??yt,i=e.autoRetry??!0,s=e.rearm??"auto",l=t.client??new be({apiOrigin:n,sessionToken:e.clientToken,...e.fetch!==void 0?{fetch:e.fetch}:{}}),u=t.sleep??bt,d=t.uuid??_t,o=t.getTurnstileToken??Ve,c=ee(),p=!1,h=new AbortController,m=null,_=null,y=r=>{m=r,c.emit("view",r)},v=()=>m!==null?Promise.resolve(m):(_??(_=l.getSession().then(r=>(y(r),r)).finally(()=>{_=null})),_),C=async()=>{let r=await l.getSession();return y(r),r},P=(r,f)=>{m!==null&&y(Ae(m,r,f))},M=null,O=async r=>{let f=await v();!r&&f.consentRecorded||(await l.recordConsent(e.locale),m!==null&&y({...m,consentRecorded:!0}))},x=r=>r?.force===!0?O(!0):(M??(M=O(!1).finally(()=>{M=null})),M),V={client:l,ensureConsent:r=>x(r),sleep:u,uuid:d,onBusy:r=>{p||c.emit("busy",r)}},D=!1,G=r=>{if(r.status==="approved"||r.status==="rejected"||r.status==="review"){if(D)return;D=!0}c.emit("result",r)},ne=async r=>{let f=m;r&&(f=await C().catch(()=>m));let w=f===null?null:N(f);return w!==null&&!p&&c.emit("method",w),w!==null},a=null,b=!1,de=!1,fe=()=>te(V,(r,f)=>r.submitCheck("population_registry",{},{idempotencyKey:f})),pe=r=>r.nniBound===!0||T(r,"population_registry")?.nniFromDocument===!0,Ie=async()=>{try{let r=await v();if(R(r)||N(r)!==null||A(r)?.checkType!=="population_registry")return;if(!pe(r)&&T(r,"population_registry")?.nniFromDocument===void 0&&(r=await C()),!pe(r)){de=!0;return}await x(),P(await fe(),"population_registry");let f=m===null?void 0:T(m,"population_registry");if(f?.state==="input_required"&&f.reason==="registry_unavailable"&&f.attemptsRemaining>0){if(await u(gt),p)return;P(await fe(),"population_registry")}}catch(r){if(r instanceof U&&r.code==="method_required"){await C().catch(()=>{});return}b=!0;return}m!==null&&R(m)&&G(le(m,{autoRetry:i}))},me=()=>(a??(a=Ie()),a),He=async()=>{let f=(await v()).turnstileSiteKey;return f===null?{sandbox:!0}:{channel:"hosted_web",siteKey:f,turnstileToken:await o(f,{signal:h.signal})}},E=null,ve=Promise.resolve(),ie=0,Oe=async()=>{let r=await v();for(let f=0;f<St&&!p&&!R(r)&&A(r)===void 0&&r.steps.some(w=>w.state==="processing")&&(await u(wt),!p);f+=1)r=await C();return r},De=async(r,f,w)=>{let{capture:k}=r,S=()=>p,X=()=>r.alive&&r.attempt===w,he=g=>{X()&&k.setFlowState(g)},I=g=>{if(!S()&&(G(g),!!X())){if(g.status==="retry"&&s==="auto"){k.handle.retry();return}k.setFlowState("done")}};if(f.degraded==="NO_RECORDER"){let g=m?.sessionId??(await v().catch(()=>null))?.sessionId??"";I(L(g,"no_recorder"));return}he("uploading");try{if(await me(),S())return;let g=await v();if(!R(g)&&N(g)!==null){await ne(!1),I(L(g.sessionId,"method_required"));return}if(!R(g)){if(A(g)?.checkType==="population_registry"){I(L(g.sessionId,de?"nni_unbound":b?"network":"registry_unavailable"));return}if(await x(),S())return;let j=await xe({...V,artifacts:f,getAttestation:He,getView:()=>m??g,refreshView:C,applySubmit:P,onPhase:he,isCancelled:S});if(S())return;if(j.kind==="unavailable"){if(j.reason==="method_required"&&await ne(!0),S())return;I(L(g.sessionId,j.reason));return}j.kind==="resync"&&await C(),g=await Oe()}I(le(g,{autoRetry:i}))}catch{if(S())return;I(L(m?.sessionId??"","network"))}},Fe=(r,f)=>{let w=r.attempt;ie>0&&r.alive&&r.capture.setFlowState("uploading"),ie+=1,ve=ve.then(()=>De(r,f,w)).finally(()=>{ie-=1}).catch(()=>{})};return{consent:()=>x(),startRegistry:me,methodChoice:async()=>{if(p)return null;try{let r=await v();return p?null:N(r)}catch{return null}},selectMethod:async r=>{let f=await l.selectMethod(r);p||y(f)},mobileRequired:async()=>{if(p)return!1;try{let r=await v();if(p||R(r))return!1;let f=T(r,"liveness");return W(f)&&f?.requiresMobile===!0&&!Q()}catch{return!1}},liveness:r=>{E?.capture.handle.destroy(),E!==null&&(E.alive=!1);let f=ae(r,t.capture),w={capture:f,alive:!0,attempt:0};E=w,f.handle.on("state",S=>{S==="starting"&&(w.attempt+=1)}),f.handle.on("captured",S=>{Promise.resolve().then(()=>Fe(w,S))});let k=f.handle;return{get state(){return k.state},on:(S,X)=>k.on(S,X),start:S=>k.start(S),retry:()=>k.retry(),switchCamera:()=>k.switchCamera(),destroy:()=>{w.alive=!1,E===w&&(E=null),k.destroy()}}},voiceClips:async()=>{if(p)return null;try{let r=await v();return p?null:r.voice??null}catch{return null}},on:(r,f)=>c.on(r,f),destroy:()=>{p=!0,h.abort(),E!==null&&(E.alive=!1,E.capture.handle.destroy(),E=null),c.clear()}}}export{Ue as a,_e as b,At as c,Pt as d,xt as e,Mt as f,Vt as g,It as h,Ee as i,ze as j,Ge as k,Xe as l,ae as m,Yt as n,je as o,W as p,R as q,A as r,T as s,Ae as t,le as u,Ze as v,Je as w,et as x,nt as y,it as z,$ as A,te as B,xe as C,vt as D,Zt as E,Jt as F,ht as G,Ve as H,yt as I,gt as J,wt as K,St as L,_t as M,cn as N,Ct as O};
|
package/dist/chunk-YOB4ZTYN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-IYUOYINS.js";var h=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","inference_unavailable","mobile_required","nni_locked","method_required","method_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout"];function R(t){return h.includes(t)}var d=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds)}};var f=3e4,_=9e5,T=200,g=5,b=400;function p(t){return(t.split(";")[0]??"").trim()}var w={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},y=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let s=e.fetch;this.fetchImpl=(n,i)=>(s??globalThis.fetch).call(globalThis,n,i),this.requestTimeoutMs=e.requestTimeoutMs??f,this.retryAttempts=e.inProgressRetry?.attempts??g,this.retryDelayMs=e.inProgressRetry?.delayMs??b}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e}})}async selectMethod(e){let s=await this.api("POST","/hosted/method",{body:{method:e}});return this.sessionId=s.sessionId,s}async presign(e,s,n){let i=await this.ensureSessionId(),o={kind:e,contentType:p(s),contentLength:n};return this.api("POST",`/sessions/${i}/media`,{body:o})}async uploadToSpaces(e,s,n){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(n)},body:s,signal:AbortSignal.timeout(_)})}catch(o){throw m(o)}if(!i.ok){let o=(await i.text().catch(()=>"")).slice(0,T);throw new d({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let s=await this.ensureSessionId();return this.api("POST",`/sessions/${s}/media/complete`,{body:{key:e}})}async submitCheck(e,s,n={}){let i=await this.ensureSessionId(),o={input:s,...n.forceOutcome!==void 0?{forceOutcome:n.forceOutcome}:{}};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:o,...n.idempotencyKey!==void 0?{idempotencyKey:n.idempotencyKey}:{}})}async uploadAndSubmit(e,s,n,i={}){let o=p(s.contentType),a=await this.presign(s.kind,o,s.blob.size);await this.uploadToSpaces(a.uploadUrl,s.blob,o);let r=await this.completeMedia(a.key),c={...n,[w[e]]:r.key};return this.submitCheck(e,c,i)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,s,n={}){let i=`${this.apiOrigin}/api/v2${s}`,o={"x-session-token":this.sessionToken};n.body!==void 0&&(o["content-type"]="application/json"),n.idempotencyKey!==void 0&&(o["x-idempotency-key"]=n.idempotencyKey);try{let a=l.timezone();a!==void 0&&(o["sekyro-client-timezone"]=a)}catch{}try{let a=await l.deviceHeader();a!==void 0&&(o["sekyro-client-device"]=a)}catch{}for(let a=0;;a++){let r;try{r=await this.fetchImpl(i,{method:e,headers:o,...n.body!==void 0?{body:JSON.stringify(n.body)}:{},signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(u){throw m(u)}if(r.ok){let u;try{u=await r.json()}catch{throw new d({status:r.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${r.status})`})}return k(u)}let c=await S(r);if(c.code==="idempotency_in_progress"&&a<this.retryAttempts){this.retryDelayMs>0&&await P(this.retryDelayMs);continue}throw c}}};function m(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new d({status:0,code:"timeout",message:"request timed out"});let s=t instanceof Error?t.message:String(t);return new d({status:0,code:"network_error",message:`network request failed: ${s}`})}function k(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function S(t){let e="unknown_error",s=`request failed (HTTP ${t.status})`,n=Number.NaN;try{let a=await t.json();if(a!==null&&typeof a=="object"){let r=a;typeof r.code=="string"&&r.code.length>0&&(e=r.code),typeof r.message=="string"&&r.message.length>0&&(s=r.message),typeof r.retryAfterSeconds=="number"&&(n=r.retryAfterSeconds)}}catch{}let i=t.headers.get("retry-after"),o=i===null?Math.floor(n):Number.parseInt(i,10);return new d({status:t.status,code:e,message:s,...Number.isFinite(o)&&o>=0?{retryAfterSeconds:o}:{}})}function P(t){return new Promise(e=>setTimeout(e,t))}export{h as a,R as b,d as c,p as d,y as e};
|
package/dist/chunk-YQBK6OIM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as O}from"./chunk-IYUOYINS.js";import{c as R,d as x,f as C,h as k,j as L}from"./chunk-BMA36W2W.js";import{b as D,c as G,d as S,e as P}from"./chunk-FPXL63KZ.js";function V(a,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}function N(){return typeof window>"u"||typeof navigator>"u"?!1:window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(String(navigator.userAgent??""))}var ae=.45,oe=.9,ce=.4;var Y=["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 F(){let a=globalThis.MediaRecorder;return!a||typeof a.isTypeSupported!="function"?"":Y.find(e=>a.isTypeSupported(e))??""}var T="video/webm";function H(a){if(a instanceof TypeError)return"insecure";switch(a?.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 W(){let a=globalThis;if(typeof a.window<"u"&&a.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=a.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function ue(){let a=globalThis.MediaRecorder;return typeof a<"u"&&typeof a.isTypeSupported=="function"}var I=8*1024*1024;function y(a){return a.size>I}function U(a){let e=(a||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function de(a){let{token:e,clip:t,keyframe:r}=a,i=a.ts??Date.now(),n=t.type||T,s=r.type||"image/jpeg",o=new FormData;return o.append("token",e),o.append("clip",new File([t],`liveness-${i}.${U(n)}`,{type:n})),o.append("keyframe",new File([r],`keyframe-${i}.${U(s)}`,{type:s})),o}var j=2500,$=1e3,J=1500,K=25e5,f=class extends Error{constructor(e,t){super(t??e),this.kind=e}},g=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){if(this.recorder&&!this.settled)return Promise.reject(new f("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 r=F();return new Promise((i,n)=>{let s;try{s=new MediaRecorder(e,r?{mimeType:r,videoBitsPerSecond:K}:{videoBitsPerSecond:K})}catch{try{s=new MediaRecorder(e)}catch{n(new f("unsupported"));return}}this.recorder=s;let o=d=>{this.settled||(this.settled=!0,this.clearTimers(),d())},c=()=>o(()=>{let d=s.mimeType||r||T,l=new Blob(this.chunks,{type:d});if(y(l)){n(new f("cliptoolarge"));return}i({blob:l,mimeType:d})});s.ondataavailable=d=>{d.data&&d.data.size&&(this.chunks.push(d.data),this.bytes+=d.data.size,this.bytes>I&&o(()=>{try{s.state!=="inactive"&&s.stop()}catch{}n(new f("cliptoolarge"))}))},s.onstop=c,s.onerror=()=>o(()=>n(new f("generic")));try{s.start($)}catch{o(()=>n(new f("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),s.state!=="inactive"){try{s.stop()}catch{c()}this.graceTimer=setTimeout(c,J)}else c()},j)})}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 B(a,e,t=.92){return new Promise((r,i)=>{let n=a.videoWidth,s=a.videoHeight;if(!n||!s){i(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){i(new Error("no-2d-context"));return}e.width=n,e.height=s,o.scale(-1,1),o.drawImage(a,-n,0),e.toBlob(c=>c?r(c):i(new Error("empty-keyframe")),"image/jpeg",t)})}var ee=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"})}),te=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 z(){let a=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(te)}catch{e=!1}return{cores:a?.hardwareConcurrency??2,memGB:a?.deviceMemory??null,simd:e}}function X(a){let e=a.memGB??4;return a.cores<4||e<3?"LOW":a.cores>=8&&e>=6?"HIGH":"MID"}var A=["LOW","MID","HIGH"],b=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return ee[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((r,i)=>r+i,0)/this.samples.length;if(t>70)this.current="LOW";else if(t<25){let r=A.indexOf(this.current);this.current=A[Math.min(A.length-1,r+1)]??this.current}return this.current}};var E=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,r)=>t+r,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 re=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}),v=a=>Math.min(1,Math.max(0,a)),_=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...re,...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:r,timestampMs:i}=e,n=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:v(r.sharpness),exposure:v(r.exposure),motion:1};if(t!==null){s.presence=1;let l=this.geometryOf(t,e);s.centering=l.centering,s.size=l.size,s.pose=l.pose,s.motion=this.motionOf(l.center,l.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=v(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*n),this.qWindow.push({at:i,q:o}),this.qWindow=this.qWindow.filter(l=>l.at>=i-this.t.READY_WINDOW_MS);let c=this.qWindow.map(l=>l.q);if(c.length>=3){let l=Math.min(...c),u=c.indexOf(l);c=c.filter((h,m)=>m!==u)}let d=this.p>=1&&c.every(l=>l>=this.t.Q_GOOD);return{at:i,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,o),ready:d,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,n={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:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,d=Math.hypot(o.x-n.x,o.y-n.y),l=c<=0?0:1-v(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=s>0?c/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let h;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?h=0:u<this.t.SIZE_IDEAL_MIN?h=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?h=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):h=1;let m=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;m=1-v(p/this.t.ROLL_MAX_DEG)}return{center:o,iod:c,centering:l,size:h,pose:m}}motionOf(e,t,r){let i=this.lastCenter;if(this.lastCenter={...e,at:r},i===null||t<=0)return 1;let n=(r-i.at)/1e3;if(n<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/n;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-n/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-v(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){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(r<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"]],n=i[0];for(let s of i)e[s[0]]<e[n[0]]&&(n=s);return n[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(D[0]+D[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var w=4,ie=600,q={sharpness:1,exposure:1,meanLuma:128},Z=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.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(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.setState("preflight");let r=W();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(c=>navigator.mediaDevices.getUserMedia(c)),n;this.cameraRequestedAt=this.now();try{n=await i(V(N(),this.facing))}catch(c){if(e!==this.attempt)return;this.fail(H(c));return}if(O(n),e!==this.attempt){for(let c of n.getTracks())c.stop();return}if(this.stream=n,t.video.srcObject=n,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let c={...t.v3AssetBaseUrl!==void 0?{v3AssetBaseUrl:t.v3AssetBaseUrl}:{}},d=t.createDetector??(t.createWorker!==void 0&&k()?async()=>{try{return await L.create(t.createWorker(),c)}catch{return C(c)}}:()=>C(c)),l;try{l=await d()}catch(u){e===this.attempt&&this.fail("models",u instanceof R?u.fallbackReason:se(u));return}if(e!==this.attempt){l.destroy();return}this.detector=l,this.options.telemetry?.({type:"detector",tier:l.tier,...l.fallbackReason!==void 0?{fallbackReason:l.fallbackReason}:{}})}let s=z(),o=t.deviceClass??X(s);this.profiler=new b(o),this.options.telemetry?.({type:"profile",staticClass:o,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new _(t.thresholds??{}),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 r=new E({cadenceHz:t.profile.cadenceHz,video:this.options.video,...this.options.now!==void 0?{now:this.options.now}:{},run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:i}=this,n=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||n.videoWidth===0)return;let s=i.deviceClass,o=this.now(),c=this.options.makeSnapshot?.(n,i.profile.inputWidth)??this.defaultSnapshot(n,i.profile.inputWidth),d=null;try{d=await t.detect(c,n.videoWidth,n.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-o),i.deviceClass!==s&&this.startScheduler(e);let l=d===null?q:this.options.measureQuality?.(n,d.box)??this.defaultQuality(n,d.box),u=r.tick({timestampMs:this.now(),observation:d,quality:l,frameWidth:n.videoWidth,frameHeight:n.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),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,r=this.scheduler;r?.stop();let i=r?.stats()??{degradeCount:0,meanDetectMs:0},n=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:n.length===0?0:n.reduce((p,M)=>p+M,0)/n.length});let s=t.mode??"clip",o=this.collectKeyframes(e);if(s==="photo"){let p=await o;if(e!==this.attempt)return;if(p===null){this.fail("generic");return}this.finishCapture({keyframe:p.blob,previewDataUrl:p.previewDataUrl});return}this.setState("recording");let c=t.createRecorder?.()??new g,d=this.stream;if(d===null){this.fail("generic");return}let l=null;o.then(p=>{l=p},()=>{});let u=()=>{e===this.attempt&&l!==null&&this.emit("frozen",{previewDataUrl:l.previewDataUrl})},h,m;try{[h,m]=await Promise.all([c.record(d,u),o])}catch(p){if(e!==this.attempt)return;let M=p.kind;this.fail(M==="cliptoolarge"?"cliptoolarge":"recorder");return}if(e===this.attempt){if(y(h.blob)){this.fail("cliptoolarge");return}if(m===null){this.fail("generic");return}this.finishCapture({clip:h.blob,clipMimeType:h.mimeType,keyframe:m.blob,previewDataUrl:m.previewDataUrl})}}async collectKeyframes(e){let t=this.options.captureKeyframe??(n=>this.defaultKeyframe(n)),r=ie/(w-1),i=null;for(let n=0;n<w;n+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}n<w-1&&await ne(r)}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=(s,o)=>s!==null&&o!==null?Math.max(0,Math.round(o-s)):void 0,t=e(this.cameraRequestedAt,this.cameraReadyAt),r=e(this.cameraReadyAt,this.faceAcquiredAt),i=e(this.faceAcquiredAt,this.captureCompleteAt),n={...t!==void 0?{cameraReadyMs:t}:{},...r!==void 0?{faceAcquireMs:r}:{},...i!==void 0?{captureMs:i}:{}};return Object.keys(n).length>0?n:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await B(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),n=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),o=r.getContext("2d");return o===null?e:(r.width!==n&&(r.width=n),r.height!==s&&(r.height=s),o.drawImage(e,0,0,n,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=Q(e,t,96);return r===null?q:{sharpness:S(r),exposure:P(r),meanLuma:G(r)}}centerSharpness(e){let t=x(e),r=Q(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:S(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.gate=null,this.stopTracks()}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,...t!==void 0?{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()}};function ne(a){return new Promise(e=>setTimeout(e,a))}function se(a){return a instanceof Error?a.message:String(a)}function Q(a,e,t){try{let r=document.createElement("canvas"),i=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*i)),r.height=Math.max(1,Math.round(e.height*i));let n=r.getContext("2d");return n===null?null:(n.drawImage(a,e.x,e.y,e.width,e.height,0,0,r.width,r.height),n.getImageData(0,0,r.width,r.height))}catch{return null}}export{V as a,N as b,ae as c,oe as d,ce as e,Y as f,F as g,T as h,H as i,W as j,ue as k,I as l,y as m,U as n,de as o,j as p,$ as q,J as r,K as s,f as t,g as u,B as v,ee as w,z as x,X as y,b as z,E as A,re as B,_ as C,w as D,ie as E,Z as F};
|