@sekyro/web 0.1.0-rc.8 → 0.1.0-rc.9
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 +15 -0
- package/README.md +54 -61
- package/dist/{capture-session-doc-YBE3UMJJ.js → capture-session-doc-QQHDBZG4.js} +1 -1
- package/dist/{chunk-YPG7CB4O.js → chunk-4Q7EMVP7.js} +1 -1
- package/dist/{chunk-RNRFHUJA.js → chunk-56GT33O3.js} +1 -1
- package/dist/{chunk-DQWW4OCK.js → chunk-EVVGQSNJ.js} +1 -1
- package/dist/chunk-F5ST423J.js +1 -0
- package/dist/chunk-GBTZIKGZ.js +1 -0
- package/dist/chunk-H6HC7B77.js +1 -0
- package/dist/{chunk-LQ7C44JG.js → chunk-LUHNRNTO.js} +1 -1
- package/dist/{chunk-RVHAKRAI.js → chunk-WRKUWIJW.js} +1 -1
- package/dist/chunk-ZUHTYCY4.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +26 -4
- package/dist/client/index.d.ts +26 -4
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/create-document-capture-DWRNFXA2.js +1 -0
- package/dist/{create-verification-DoFpgzok.d.cts → create-verification-BS2qbe75.d.cts} +101 -16
- package/dist/{create-verification-C0AVIcVW.d.ts → create-verification-CCR-CwVQ.d.ts} +101 -16
- package/dist/{icao-gate-D8qm1O2t.d.cts → icao-gate-DKbWXP51.d.cts} +104 -39
- package/dist/{icao-gate-D8qm1O2t.d.ts → icao-gate-DKbWXP51.d.ts} +104 -39
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +11 -20
- package/dist/internal/index.d.ts +11 -20
- package/dist/internal/index.js +1 -1
- package/dist/{plan-runner-UBK4B4CG.js → plan-runner-X4YW3INX.js} +1 -1
- package/package.json +1 -1
- package/sbom.cdx.json +7 -7
- package/dist/chunk-4RS2YIL4.js +0 -1
- package/dist/chunk-MY6EXEL2.js +0 -1
- package/dist/chunk-XLN5OT25.js +0 -1
- package/dist/chunk-YDQBVWXG.js +0 -1
- package/dist/create-document-capture-T4APHJMY.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as N,c as F,d as U}from"./chunk-POIQGEZM.js";import{b as D,c as k,d as O,e as R,g as w,h as y}from"./chunk-FHJ7HO3M.js";import{b as C,c as K,d as I,e as H}from"./chunk-FPXL63KZ.js";import{b as G}from"./chunk-LQ7C44JG.js";import{c as x,d as V,f as M,h as P,j as L}from"./chunk-OKWG3PVH.js";function B(u,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}function W(){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 ne=.45,oe=.9,ce=.4;var Y=2500,j=1e3,J=1500,z=25e5,f=class extends Error{constructor(e,t){super(t??e),this.kind=e}},b=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=D();return new Promise((i,a)=>{let s;try{s=new MediaRecorder(e,r?{mimeType:r,videoBitsPerSecond:z}:{videoBitsPerSecond:z})}catch{try{s=new MediaRecorder(e)}catch{a(new f("unsupported"));return}}this.recorder=s;let n=d=>{this.settled||(this.settled=!0,this.clearTimers(),d())},o=()=>n(()=>{let d=s.mimeType||r||k,c=new Blob(this.chunks,{type:d});if(c.size===0){a(new f("generic","empty clip"));return}if(y(c)){a(new f("cliptoolarge"));return}i({blob:c,mimeType:d})});s.ondataavailable=d=>{d.data&&d.data.size&&(this.chunks.push(d.data),this.bytes+=d.data.size,this.bytes>w&&n(()=>{try{s.state!=="inactive"&&s.stop()}catch{}a(new f("cliptoolarge"))}))},s.onstop=o,s.onerror=()=>n(()=>a(new f("generic")));try{s.start(j)}catch{n(()=>a(new f("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),s.state!=="inactive"){try{s.stop()}catch{o()}this.graceTimer=setTimeout(o,J)}else o()},Y)})}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 q(u,e,t=.92){return new Promise((r,i)=>{let a=u.videoWidth,s=u.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let n=e.getContext("2d");if(!n){i(new Error("no-2d-context"));return}e.width=a,e.height=s,n.scale(-1,1),n.drawImage(u,-a,0),e.toBlob(o=>o?r(o):i(new Error("empty-keyframe")),"image/jpeg",t)})}var g=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,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 $=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=u=>Math.min(1,Math.max(0,u)),E=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...$,...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,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,centering:0,size:0,pose:0,sharpness:v(r.sharpness),exposure:v(r.exposure),motion:1};if(t!==null){s.presence=1;let c=this.geometryOf(t,e);s.centering=c.centering,s.size=c.size,s.pose=c.pose,s.motion=this.motionOf(c.center,c.iod,i)}else this.lastCenter=null,this.velocityEma=0;let n=Math.min(s.presence,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=v(this.p+(n>=this.t.Q_GOOD?this.t.RISE_PER_S*n:-this.t.FALL_PER_S*(1-n))*a),this.qWindow.push({at:i,q:n}),this.qWindow=this.qWindow.filter(c=>c.at>=i-this.t.READY_WINDOW_MS);let o=this.qWindow.map(c=>c.q);if(o.length>=3){let c=Math.min(...o),l=o.indexOf(c);o=o.filter((h,m)=>m!==l)}let d=this.p>=1&&o.every(c=>c>=this.t.Q_GOOD);return{at:i,q:n,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,n),ready:d,accepted:n>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),n=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},o=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(n.x-a.x,n.y-a.y),c=o<=0?0:1-v(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*o)),l=s>0?o/s:0;this.lastSizeDirection=l<this.t.SIZE_IDEAL_MIN?"far":l>this.t.SIZE_IDEAL_MAX?"close":"ideal";let h;l<this.t.SIZE_HARD_MIN||l>this.t.SIZE_HARD_MAX?h=0:l<this.t.SIZE_IDEAL_MIN?h=(l-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):l>this.t.SIZE_IDEAL_MAX?h=(this.t.SIZE_HARD_MAX-l)/(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:n,iod:o,centering:c,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 a=(r-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let n=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=n*s+(1-n)*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"]],a=i[0];for(let s of i)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(C[0]+C[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var ee=["size","centering","pose","exposure","sharpness","motion"];function te(u){if(u.accepted)return null;if(u.factors.presence<=0)return"no_face";let e="size";for(let t of ee)u.factors[t]<u.factors[e]&&(e=t);return e}var _=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=te(e);if(r===null){this.acceptedMs+=t;return}let i=this.blocked[r]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[r]=i}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var re=1e3,A=4,ie=600,X={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.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;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=R();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o)),a;this.cameraRequestedAt=this.now();try{a=await i(B(W(),this.facing))}catch(o){if(e!==this.attempt)return;this.fail(O(o));return}if(G(a),e!==this.attempt){for(let o of a.getTracks())o.stop();return}if(this.stream=a,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let o={...t.v3AssetBaseUrl!==void 0?{v3AssetBaseUrl:t.v3AssetBaseUrl}:{}},d=t.createDetector??(t.createWorker!==void 0&&P()?async()=>{try{return await L.create(t.createWorker(),o)}catch{return M(o)}}:()=>M(o)),c;try{c=await d()}catch(l){e===this.attempt&&this.fail("models",l instanceof x?l.fallbackReason:se(l));return}if(e!==this.attempt){c.destroy();return}this.detector=c,this.options.telemetry?.({type:"detector",tier:c.tier,fallbackReason:c.fallbackReason})}let s=N(),n=t.deviceClass??F(s);this.profiler=new U(n),this.options.telemetry?.({type:"profile",staticClass:n,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new E(t.thresholds??{}),this.blockStats=new _,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(o=>T=o,()=>{}),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 g({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:i}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||a.videoWidth===0)return;let s=i.deviceClass,n=this.now(),o=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),d=null;try{d=await t.detect(o,a.videoWidth,a.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-n),i.deviceClass!==s&&this.startScheduler(e);let c=d===null?X:this.options.measureQuality?.(a,d.box)??this.defaultQuality(a,d.box),l=r.tick({timestampMs:this.now(),observation:d,quality:c,frameWidth:a.videoWidth,frameHeight:a.videoHeight});l.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=l.at),this.blockStats?.record(l),!l.ready&&l.at-this.lastGateSnapshotAt>=re&&(this.lastGateSnapshotAt=l.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:l.p,q:l.q,factors:l.factors,attempt:e}),l.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=l.guidanceKey,this.emit("guidance",{key:l.guidanceKey})),l.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=l.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let i=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((p,S)=>p+S,0)/a.length});let s=t.mode??"clip",n=t.rankKeyframes?.()&&T?T.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let p=await n;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 o=t.createRecorder?.()??new b,d=this.stream;if(d===null){this.fail("generic");return}let c=null;n.then(p=>{c=p},()=>{});let l=()=>{e===this.attempt&&c!==null&&this.emit("frozen",{previewDataUrl:c.previewDataUrl})},h,m;try{[h,m]=await Promise.all([o.record(d,l),n])}catch(p){if(e!==this.attempt)return;let S=p.kind;this.fail(S==="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??(a=>this.defaultKeyframe(a)),r=ie/(A-1),i=null;for(let a=0;a<A;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<A-1&&await ae(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,n)=>s!==null&&n!==null?Math.max(0,Math.round(n-s)):void 0,t=e(this.cameraRequestedAt,this.cameraReadyAt),r=e(this.cameraReadyAt,this.faceAcquiredAt),i=e(this.faceAcquiredAt,this.captureCompleteAt),a={...t!==void 0?{cameraReadyMs:t}:{},...r!==void 0?{faceAcquireMs:r}:{},...i!==void 0?{captureMs:i}:{}};return Object.keys(a).length>0?a:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await q(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),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),n=r.getContext("2d");return n===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),n.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=Q(e,t,96);return r===null?X:{sharpness:I(r),exposure:H(r),meanLuma:K(r)}}centerSharpness(e){let t=V(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:I(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},T;function ae(u){return new Promise(e=>setTimeout(e,u))}function se(u){return u instanceof Error?u.message:String(u)}function Q(u,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 a=r.getContext("2d");return a===null?null:(a.drawImage(u,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}export{B as a,W as b,ne as c,oe as d,ce as e,Y as f,j as g,J as h,z as i,f as j,b as k,q as l,g as m,$ as n,E as o,te as p,_ as q,re as r,A as s,ie as t,Z as u};
|
|
1
|
+
import{b as N,c as F,d as U}from"./chunk-POIQGEZM.js";import{b as D,c as k,d as O,e as R,g as w,h as y}from"./chunk-FHJ7HO3M.js";import{b as C,c as K,d as I,e as H}from"./chunk-FPXL63KZ.js";import{b as G}from"./chunk-LUHNRNTO.js";import{c as x,d as V,f as M,h as P,j as L}from"./chunk-OKWG3PVH.js";function B(u,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}function W(){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 ne=.45,oe=.9,ce=.4;var Y=2500,j=1e3,J=1500,z=25e5,f=class extends Error{constructor(e,t){super(t??e),this.kind=e}},b=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=D();return new Promise((i,a)=>{let s;try{s=new MediaRecorder(e,r?{mimeType:r,videoBitsPerSecond:z}:{videoBitsPerSecond:z})}catch{try{s=new MediaRecorder(e)}catch{a(new f("unsupported"));return}}this.recorder=s;let n=d=>{this.settled||(this.settled=!0,this.clearTimers(),d())},o=()=>n(()=>{let d=s.mimeType||r||k,c=new Blob(this.chunks,{type:d});if(c.size===0){a(new f("generic","empty clip"));return}if(y(c)){a(new f("cliptoolarge"));return}i({blob:c,mimeType:d})});s.ondataavailable=d=>{d.data&&d.data.size&&(this.chunks.push(d.data),this.bytes+=d.data.size,this.bytes>w&&n(()=>{try{s.state!=="inactive"&&s.stop()}catch{}a(new f("cliptoolarge"))}))},s.onstop=o,s.onerror=()=>n(()=>a(new f("generic")));try{s.start(j)}catch{n(()=>a(new f("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),s.state!=="inactive"){try{s.stop()}catch{o()}this.graceTimer=setTimeout(o,J)}else o()},Y)})}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 q(u,e,t=.92){return new Promise((r,i)=>{let a=u.videoWidth,s=u.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let n=e.getContext("2d");if(!n){i(new Error("no-2d-context"));return}e.width=a,e.height=s,n.scale(-1,1),n.drawImage(u,-a,0),e.toBlob(o=>o?r(o):i(new Error("empty-keyframe")),"image/jpeg",t)})}var g=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,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 $=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=u=>Math.min(1,Math.max(0,u)),E=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...$,...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,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,centering:0,size:0,pose:0,sharpness:v(r.sharpness),exposure:v(r.exposure),motion:1};if(t!==null){s.presence=1;let c=this.geometryOf(t,e);s.centering=c.centering,s.size=c.size,s.pose=c.pose,s.motion=this.motionOf(c.center,c.iod,i)}else this.lastCenter=null,this.velocityEma=0;let n=Math.min(s.presence,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=v(this.p+(n>=this.t.Q_GOOD?this.t.RISE_PER_S*n:-this.t.FALL_PER_S*(1-n))*a),this.qWindow.push({at:i,q:n}),this.qWindow=this.qWindow.filter(c=>c.at>=i-this.t.READY_WINDOW_MS);let o=this.qWindow.map(c=>c.q);if(o.length>=3){let c=Math.min(...o),l=o.indexOf(c);o=o.filter((h,m)=>m!==l)}let d=this.p>=1&&o.every(c=>c>=this.t.Q_GOOD);return{at:i,q:n,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,n),ready:d,accepted:n>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),n=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},o=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(n.x-a.x,n.y-a.y),c=o<=0?0:1-v(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*o)),l=s>0?o/s:0;this.lastSizeDirection=l<this.t.SIZE_IDEAL_MIN?"far":l>this.t.SIZE_IDEAL_MAX?"close":"ideal";let h;l<this.t.SIZE_HARD_MIN||l>this.t.SIZE_HARD_MAX?h=0:l<this.t.SIZE_IDEAL_MIN?h=(l-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):l>this.t.SIZE_IDEAL_MAX?h=(this.t.SIZE_HARD_MAX-l)/(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:n,iod:o,centering:c,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 a=(r-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let n=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=n*s+(1-n)*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"]],a=i[0];for(let s of i)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(C[0]+C[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var ee=["size","centering","pose","exposure","sharpness","motion"];function te(u){if(u.accepted)return null;if(u.factors.presence<=0)return"no_face";let e="size";for(let t of ee)u.factors[t]<u.factors[e]&&(e=t);return e}var _=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=te(e);if(r===null){this.acceptedMs+=t;return}let i=this.blocked[r]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[r]=i}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var re=1e3,A=4,ie=600,X={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.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;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=R();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o)),a;this.cameraRequestedAt=this.now();try{a=await i(B(W(),this.facing))}catch(o){if(e!==this.attempt)return;this.fail(O(o));return}if(G(a),e!==this.attempt){for(let o of a.getTracks())o.stop();return}if(this.stream=a,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let o={...t.v3AssetBaseUrl!==void 0?{v3AssetBaseUrl:t.v3AssetBaseUrl}:{}},d=t.createDetector??(t.createWorker!==void 0&&P()?async()=>{try{return await L.create(t.createWorker(),o)}catch{return M(o)}}:()=>M(o)),c;try{c=await d()}catch(l){e===this.attempt&&this.fail("models",l instanceof x?l.fallbackReason:se(l));return}if(e!==this.attempt){c.destroy();return}this.detector=c,this.options.telemetry?.({type:"detector",tier:c.tier,fallbackReason:c.fallbackReason})}let s=N(),n=t.deviceClass??F(s);this.profiler=new U(n),this.options.telemetry?.({type:"profile",staticClass:n,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new E(t.thresholds??{}),this.blockStats=new _,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(o=>T=o,()=>{}),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 g({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:i}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||a.videoWidth===0)return;let s=i.deviceClass,n=this.now(),o=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),d=null;try{d=await t.detect(o,a.videoWidth,a.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-n),i.deviceClass!==s&&this.startScheduler(e);let c=d===null?X:this.options.measureQuality?.(a,d.box)??this.defaultQuality(a,d.box),l=r.tick({timestampMs:this.now(),observation:d,quality:c,frameWidth:a.videoWidth,frameHeight:a.videoHeight});l.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=l.at),this.blockStats?.record(l),!l.ready&&l.at-this.lastGateSnapshotAt>=re&&(this.lastGateSnapshotAt=l.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:l.p,q:l.q,factors:l.factors,attempt:e}),l.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=l.guidanceKey,this.emit("guidance",{key:l.guidanceKey})),l.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=l.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let i=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((p,S)=>p+S,0)/a.length});let s=t.mode??"clip",n=t.rankKeyframes?.()&&T?T.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let p=await n;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 o=t.createRecorder?.()??new b,d=this.stream;if(d===null){this.fail("generic");return}let c=null;n.then(p=>{c=p},()=>{});let l=()=>{e===this.attempt&&c!==null&&this.emit("frozen",{previewDataUrl:c.previewDataUrl})},h,m;try{[h,m]=await Promise.all([o.record(d,l),n])}catch(p){if(e!==this.attempt)return;let S=p.kind;this.fail(S==="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??(a=>this.defaultKeyframe(a)),r=ie/(A-1),i=null;for(let a=0;a<A;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<A-1&&await ae(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,n)=>s!==null&&n!==null?Math.max(0,Math.round(n-s)):void 0,t=e(this.cameraRequestedAt,this.cameraReadyAt),r=e(this.cameraReadyAt,this.faceAcquiredAt),i=e(this.faceAcquiredAt,this.captureCompleteAt),a={...t!==void 0?{cameraReadyMs:t}:{},...r!==void 0?{faceAcquireMs:r}:{},...i!==void 0?{captureMs:i}:{}};return Object.keys(a).length>0?a:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await q(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),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),n=r.getContext("2d");return n===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),n.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=Q(e,t,96);return r===null?X:{sharpness:I(r),exposure:H(r),meanLuma:K(r)}}centerSharpness(e){let t=V(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:I(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},T;function ae(u){return new Promise(e=>setTimeout(e,u))}function se(u){return u instanceof Error?u.message:String(u)}function Q(u,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 a=r.getContext("2d");return a===null?null:(a.drawImage(u,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}export{B as a,W as b,ne as c,oe as d,ce as e,Y as f,j as g,J as h,z as i,f as j,b as k,q as l,g as m,$ as n,E as o,te as p,_ as q,re as r,A as s,ie as t,Z as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-LUHNRNTO.js";var _=["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","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_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","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active"];function E(s){return _.includes(s)}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),e.details&&(this.details=e.details)}};var g=6e4,m=4,b=3e4,T=9e5,w=200,k=5,S=400;function l(s){return(s.split(";")[0]??"").trim()}var P={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},f=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,i)=>(n??globalThis.fetch).call(globalThis,t,i),this.requestTimeoutMs=e.requestTimeoutMs??b,this.retryAttempts=e.inProgressRetry?.attempts??k,this.retryDelayMs=e.inProgressRetry?.delayMs??S}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 choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n}});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t){let i=await this.ensureSessionId(),o={kind:e,contentType:l(n),contentLength:t};return this.api("POST",`/sessions/${i}/media`,{body:o})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,i={}){let o=await this.ensureSessionId(),r=await this.takeCaptureNonce(),c=r===void 0?void 0:{nonce:r,...i.engine!==void 0?{engine:i.engine.slice(0,32)}:{},...i.durationMs!==void 0&&Number.isFinite(i.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(i.durationMs)))}:{}},a={kind:e,contentType:l(n),contentLength:t,...c!==void 0?{capture:c}:{}};return this.api("POST",`/sessions/${o}/media`,{body:a})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-g>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let t=e();if(t!==void 0)return t;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(m,Math.max(1,e))}}),i=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let o of Array.isArray(t.nonces)?t.nonces:[])typeof o=="string"&&o.length>0&&this.captureNonces.push({nonce:o,expiresAt:i});this.captureNonces=this.captureNonces.slice(-m)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(T)})}catch(o){throw y(o)}if(!i.ok){let o=(await i.text().catch(()=>"")).slice(0,w);throw new d({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let i=await this.ensureSessionId(),o={input:n,...t.forceOutcome!==void 0?{forceOutcome:t.forceOutcome}:{}};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:o,...t.idempotencyKey!==void 0?{idempotencyKey:t.idempotencyKey}:{}})}async uploadAndSubmit(e,n,t,i={}){let o=l(n.contentType),r=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(r.uploadUrl,n.blob,o);let c=await this.completeMedia(r.key),a={...t,[P[e]]:c.key};return this.submitCheck(e,a,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,n,t={}){let i=`${this.apiOrigin}/api/v2${n}`,o={"x-session-token":this.sessionToken};t.body!==void 0&&(o["content-type"]="application/json"),t.idempotencyKey!==void 0&&(o["x-idempotency-key"]=t.idempotencyKey);try{let r=p.timezone();r!==void 0&&(o["sekyro-client-timezone"]=r)}catch{}try{let r=await p.deviceHeader();r!==void 0&&(o["sekyro-client-device"]=r)}catch{}for(let r=0;;r++){let c;try{c=await this.fetchImpl(i,{method:e,headers:o,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(u){throw y(u)}if(c.ok){if(t.blob===!0)try{return await c.blob()}catch(h){throw y(h)}let u;try{u=await c.json()}catch{throw new d({status:c.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${c.status})`})}return C(u)}let a=await I(c);if(a.code==="idempotency_in_progress"&&r<this.retryAttempts){this.retryDelayMs>0&&await M(this.retryDelayMs);continue}throw a}}};function y(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new d({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new d({status:0,code:"network_error",message:`network request failed: ${n}`})}function C(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function I(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,i;try{let c=await s.json();if(c!==null&&typeof c=="object"){let a=c;typeof a.code=="string"&&a.code.length>0&&(e=a.code),typeof a.message=="string"&&a.message.length>0&&(n=a.message),typeof a.retryAfterSeconds=="number"&&(t=a.retryAfterSeconds),Array.isArray(a.details?.issues)&&(i=a.details)}}catch{}let o=s.headers.get("retry-after"),r=o===null?Math.floor(t):Number.parseInt(o,10);return new d({status:s.status,code:e,message:n,...Number.isFinite(r)&&r>=0?{retryAfterSeconds:r}:{},details:i})}function M(s){return new Promise(e=>setTimeout(e,s))}function N(s){let e=s?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"&&!t?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function H(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{_ as a,E as b,d as c,l as d,f as e,N as f,H as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as V,c as H,d as N,e as ye,f as E,g as B,h as P,i as U,j as x,k as v,l as M,t as ge,u as Ce}from"./chunk-ZUHTYCY4.js";import{m as me}from"./chunk-WRKUWIJW.js";import{a as fe}from"./chunk-7V2M6Y2W.js";import{b as J}from"./chunk-EVVGQSNJ.js";import{c as Se,e as he,f as F}from"./chunk-F5ST423J.js";var Be="https://api.sekyro.ai",Ue=5e3,Fe=1500,Ge=10;function Ke(e){return new Promise(t=>setTimeout(t,e))}function qe(){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 o=0;o<16;o+=1)t[o]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let i=[...t].map(o=>o.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}function xt(e){return Ye(e,{})}function Ye(e,t){let i=e.apiOrigin??Be,o=e.autoRetry??!0,r=e.rearm??"auto",a=t.client??new he({apiOrigin:i,sessionToken:e.clientToken,...e.fetch!==void 0?{fetch:e.fetch}:{}}),l=t.sleep??Ke,s=t.uuid??qe,m=t.getTurnstileToken??((n,c)=>import("./turnstile-FATNZ4AG.js").then(d=>d.executeTurnstile(n,c))),f=fe(),p=null,S=null,u=!1,w=new AbortController,h=null,G=null,R=n=>{h=n,f.emit("view",n),p?.onView(n)},C=()=>h!==null?Promise.resolve(h):(G??(G=a.getSession().then(n=>(R(n),n)).finally(()=>{G=null})),G),I=async()=>{let n=await a.getSession();return R(n),n},K=async(n,c)=>{n.plan!==void 0?R(n):await I()},q=null,z=async n=>{let c=await C();if(!n&&c.consentRecorded)return;let d=await a.recordConsent(e.locale);d.plan!==void 0?R(d):h!==null&&R({...h,consentRecorded:!0})},O=n=>n?.force===!0?z(!0):(q??(q=z(!1).finally(()=>{q=null})),q),Y={client:a,ensureConsent:n=>O(n),sleep:l,uuid:s,onBusy:n=>{u||f.emit("busy",n)}},ee=!1,te=null,W=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(ee)return;ee=!0}te=JSON.stringify(n),f.emit("result",n)},Ae=n=>{te!==JSON.stringify(n)&&W(n)},ne=async n=>{let c=h;n&&(c=await I().catch(()=>h));let d=c===null?null:E(c);return d!==null&&!u&&f.emit("method",d),d!==null},ie=null,oe=!1,re=!1,se=()=>ge(Y,(n,c)=>n.submitCheck("population_registry",{},{idempotencyKey:c})),ae=n=>n.nniBound===!0||x(n,"population_registry")?.nniFromDocument===!0,ve=async()=>{try{let n=await C();if(P(n)||E(n)!==null||U(n)?.checkType!=="population_registry")return;if(!ae(n)&&x(n,"population_registry")?.nniFromDocument===void 0&&(n=await I()),!ae(n)){re=!0;return}await O(),await K(await se(),"population_registry");let c=h===null?void 0:x(h,"population_registry");if(c?.state==="input_required"&&c.reason==="registry_unavailable"&&N(c)>0){if(await l(Ue),u)return;await K(await se(),"population_registry")}}catch(n){if(n instanceof Se&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await I().catch(()=>{});return}oe=!0;return}h!==null&&P(h)&&W(M(h,{autoRetry:o}))},ce=()=>(ie??(ie=ve()),ie),Ee=async()=>{let c=(await C()).turnstileSiteKey;return c===null?{sandbox:!0}:{channel:"hosted_web",siteKey:c,turnstileToken:await m(c,{signal:w.signal})}},k=null,le=Promise.resolve(),T=0,we=async()=>{let n=await C();for(let c=0;c<Ge&&!u&&!P(n)&&U(n)===void 0&&H(n).some(d=>d.state==="processing")&&(await l(Fe),!u);c+=1)n=await I();return n},Oe=async(n,c,d)=>{let{capture:_}=n,g=()=>u,L=()=>n.alive&&n.attempt===d,pe=y=>{L()&&_.setFlowState(y)},A=y=>{if(!g()&&(W(y),!!L())){if(y.status==="retry"&&r==="auto"){_.handle.retry();return}_.setFlowState("done")}};if(c.degraded==="NO_RECORDER"){let y=h?.sessionId??(await C().catch(()=>null))?.sessionId??"";A(v(y,"no_recorder"));return}pe("uploading");try{if(await ce(),g())return;let y=await C();if(!P(y)&&E(y)!==null){await ne(!1),A(v(y.sessionId,"method_required"));return}if(!P(y)){if(U(y)?.checkType==="population_registry"){A(v(y.sessionId,re?"nni_unbound":oe?"network":"registry_unavailable"));return}if(await O(),g())return;let Z=await Ce({...Y,artifacts:c,getAttestation:Ee,getView:()=>h??y,refreshView:I,applySubmit:K,onPhase:pe,isCancelled:g,onKeyframePromoted:Ne=>{S=Ne}});if(g())return;if(Z.kind==="unavailable"){A(v(y.sessionId,Z.reason));return}if(Z.kind==="resync"&&await I(),h!==null&&E(h)!==null){await ne(!1),A(v(y.sessionId,"method_required"));return}y=await we()}A(M(y,{autoRetry:o}))}catch{if(g())return;A(v(h?.sessionId??"","network"))}},Te=(n,c)=>{let d=n.attempt;T>0&&n.alive&&n.capture.setFlowState("uploading"),T+=1,le=le.then(()=>Oe(n,c,d)).finally(()=>{T-=1,T===0&&p?.onChainIdle()}).catch(()=>{})},ue=n=>{k?.capture.handle.destroy(),k!==null&&(k.alive=!1);let c=me(n,p?.captureInternals?.(n)??t.capture,()=>h?.capture?.liveness?.keyframe?.rank===!0),d={capture:c,alive:!0,attempt:0};k=d,c.handle.on("state",g=>{g==="starting"&&(d.attempt+=1)}),c.handle.on("captured",g=>{Promise.resolve().then(()=>Te(d,g))});let _=c.handle;return{get state(){return _.state},on:(g,L)=>_.on(g,L),start:g=>_.start(g),retry:()=>_.retry(),switchCamera:()=>_.switchCamera(),destroy:()=>{d.alive=!1,k===d&&(k=null),_.destroy()}}},Ve=async()=>{if(u)return null;try{let n=await C();return u?null:E(n)}catch{return null}},Me=async()=>{if(u)return!1;try{let n=await C();if(u||P(n))return!1;let c=x(n,"liveness");return B(c)&&c?.requiresMobile===!0&&!J()}catch{return!1}},De=async()=>{if(u)return!1;try{let n=await C();return!u&&n.returning===!0}catch{return!1}},Le=async n=>{let c=(await C()).plan?.choice,d=c?.options.find(g=>V[g.service]===n);if(!d)throw new RangeError(`method ${String(n)} is not offered`);let _=await a.choose(c.nodeId,d.id);u||R(_)},de=null,He=()=>(de??(de=import("./plan-runner-X4YW3INX.js").then(n=>{let c=n.createPlanRunner({runtime:Y,currentView:()=>h,ensureView:C,refreshView:I,ensureConsent:()=>O(),liveness:ue,chainBusy:()=>T>0,destroyed:()=>u,sleep:l,isMobile:J,now:t.now??Date.now,keptFaceKey:()=>S,setView:R,baseCapture:t.capture,emitStep:d=>{u||f.emit("step",d)},emitResult:Ae,...t.document!==void 0?{documentInternals:t.document}:{},...t.portrait!==void 0?{portraitInternals:t.portrait}:{},livePhotoInternals:t.livePhoto});return p=c,c})),de);return{consent:()=>O(),startRegistry:ce,methodChoice:Ve,selectMethod:Le,mobileRequired:Me,returning:De,liveness:ue,run:async()=>{if(u)throw new Error("verification destroyed");return(await He()).run()},currentStep:()=>p?.current()??null,voiceClips:async()=>{if(u)return null;try{let n=await C();return u?null:n.voice??null}catch{return null}},on:(n,c)=>f.on(n,c),destroy:()=>{u=!0,w.abort(),p?.destroy(),k!==null&&(k.alive=!1,k.capture.handle.destroy(),k=null),f.clear()}}}var _e=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var We=["carte_identite","passport","residence_permit"];function Ze(e,t){let i=e.byIssuer?.[t]??e.default;return We.filter(o=>i==="*"||i.includes(o))}function At(e,t=_e){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(o=>Ze(e,o).length>0).sort()}function ke(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function vt(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var Vt=["national_number","document_photo","national_eid"],Je=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","face_match","aml_screening","face_dedup"]),Qe=new Set(["supplied_identity","aml_screening","face_dedup"]),j=["document","population_registry","national_eid"],$=["phone_otp","email_otp"],xe={identity_method:j,contact:$},je=["population_registry","document"],Ie="platform_unsupported",$e=new Set(["prefilled","user_entered","prefilled_or_entered"]),Xe={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function b(e){return e.section??Xe[e.checkType]??null}function ze(e,t){let i=e.plan?.choice;if(i===void 0||i.locked)return;let o=i.options.find(r=>r.id!==i.selected&&r.available!==!1&&t.includes(r.service));return o===void 0?void 0:{nodeId:i.nodeId,option:o}}function X(e){let t=e.plan,i=t?.choice;if(t===void 0||i===void 0||i.locked||t.current===null||t.current===i.nodeId||P(e))return null;let o=xe[i.kind]??[...j,...$],r=i.options.flatMap(s=>s.available===!1||!o.includes(s.service)?[]:[s.nationalEid!=null?{id:s.id,service:s.service,nationalEid:s.nationalEid}:{id:s.id,service:s.service}]),a=t.steps.find(s=>s.id===t.current)?.service,l=i.selected??r.find(s=>s.service===a)?.id??null;return r.some(s=>s.id!==l)?{nodeId:i.nodeId,kind:i.kind,current:l,options:r}:null}function be(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function et(e){let t=(e.plan?.sections??[]).map(r=>({id:r.id,state:r.state})),i={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(r=>r.id),progress:t};e.branding!==void 0&&(i.branding=e.branding);let o=X(e);return o!==null&&(i.switchable=o),i}function tt(e){let t={attemptsRemaining:N(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),t}var Re={phone_otp:"phone",email_otp:"email"};function nt(e,t){let i=ze(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Re[i.option.service]}function it(e,t,i,o){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},l=r?t.emailOtp?.emailSource:t.otp?.numberSource,s=l!==void 0&&$e.has(l)?l:r?"prefilled_or_entered":"user_entered",m=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,f=nt(e,r?"email_otp":"phone_otp"),p={key:t.checkType,context:i,section:b(t),phase:m?"verify":"send",canSwitch:f!==void 0,...o},S=r?{kind:"email_otp",...p,emailSource:s,needsEmail:s!=="prefilled"}:{kind:"phone_otp",...p,numberSource:s,needsPhone:s!=="prefilled",channels:(t.otp?.channels??[]).filter(u=>u==="whatsapp"||u==="sms")};return f!==void 0&&(S.switchChannel=f),m&&(S.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(S.channel=t.otp.channel),a.expiresAt!==void 0&&(S.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(S.resendAvailableAt=a.resendAvailableAt),S}function ot(e,t,i,o){let r=e.nniBound===!0?"bound":t.nniFromDocument===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason==="nni_recheck",l=be(X(e)),s=!o.attemptsExhausted&&l.length===1&&l[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:b(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:s,...o}}function rt(e,t,i,o){let r=[...t.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:b(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:ke(e),...o}}function st(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Pe(e,t,i,o,r){let a=t.icao?.report;return{kind:"portrait",key:`portrait:${r}`,context:i,section:b(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:F(e),retakeOnly:r==="capture"&&t.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&st(e),...o}}var Q={minLongSidePx:1280,jpegQuality:.95};function at(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let o=x(e,"portrait_icao"),r=i.still??Q;return{icao:t==="liveness"&&F(e)!==null&&o!==void 0&&o.state==="pending"&&o.reason===void 0,still:{minLongSidePx:r.minLongSidePx??Q.minLongSidePx,jpegQuality:r.jpegQuality??Q.jpegQuality}}}function ct(e,t,i,o){let r=t.eid,a=b(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:a,checkType:"eid_auth",reason:"update_required"};let l=be(X(e)),s=l.length===1&&je.includes(l[0]?.service??"")?l[0]:void 0,m=s===void 0?void 0:V[s.service],f=m!==void 0,p={kind:"eid",key:"eid",context:i,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:f,afterPass:r.afterPass==="continue"?"continue":"end",...o};return f&&(p.cameraMethod=m),r.expiresAt!==void 0&&(p.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(p.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(p.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(p.codeAttemptsRemaining=r.codeAttemptsRemaining),p}function lt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let i=x(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}function ut(e){return H(e).some(t=>t.attemptsExhausted===!0)}function dt(e,t){let i=e.failureReason,o;i===Ie?o="platform_unsupported":e.status==="expired"?o="expired":e.status==="review_pending"?o="review":e.status==="completed"&&e.outcome==="approved"?o="approved":e.status==="completed"&&e.outcome==="review"?o="review":i==="device_cooldown"?o="cooldown":i!==void 0?o="policy_stop":ut(e)?o="attempts_exhausted":o="rejected";let r=o==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:M(e,{autoRetry:!1}),a={kind:"result",key:"result",context:t,section:null,display:o,result:r};return i!==void 0&&(a.failureReason=i),e.retryAfter!==void 0&&(a.retryAfter=e.retryAfter),a}function pt(e,t,i){let o=e.identitySummary;if(o==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:i??"identity",summaryKind:o.kind==="partial"?"partial":o.kind??"full",source:o.source,portraitAvailable:o.portrait?.available===!0,retakeAvailable:o.retakeAvailable===!0};for(let a of ft){let l=o[a];typeof l=="string"&&l!==""&&(r[a]=l)}return r}var ft=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function D(e,t,i,o){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:t,checkType:i,reason:o}}function mt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function St(e,t){let i=xe[e.kind]??[...j,...$],o=mt(e),r=e.options.flatMap(l=>{if(l.available===!1||!i.includes(l.service))return[];let s={id:l.id,service:l.service};return l.nationalEid!=null&&(s.nationalEid=l.nationalEid),[s]});if(r.length===0){let l=e.options.length>0&&e.options.every(s=>s.service==="nfc");return D(t,o,"choice",l?"platform_unsupported":"update_required")}let a={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let l={kind:"method",key:"method",context:t,section:o,options:r.map(m=>V[m.service]),choice:a},s=r.find(m=>m.nationalEid!==void 0)?.nationalEid;return s!==void 0&&(l.nationalEid=s),l}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:o,options:r.map(l=>Re[l.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:o,choice:a}}function Mt(e,t={}){let i=et(e);if(P(e)||e.failureReason===Ie)return dt(e,i);let o=e.plan;if(o===void 0||!Array.isArray(o.sections))return D(i,null,"plan","update_required");let r=ye(e);if(r!==null)return St(r,i);let a=o.current===null?void 0:o.steps.find(S=>S.id===o.current),l=S=>({kind:"processing",key:"processing",context:i,section:S!==void 0?b(S):o.sections.find(u=>u.state==="current")?.id??null,stalled:!1});if(o.current===null)return l(o.steps.find(S=>S.state==="processing"));if(a===void 0||!Je.has(a.service))return D(i,a===void 0?null:b(a),a?.service??"step","update_required");if(Qe.has(a.service)||!B(a))return l(a);let s=a,m=tt(s),f=s.checkType,p=b(s);switch(f){case"phone_otp":case"email_otp":return it(e,s,i,m);case"population_registry":return ot(e,s,i,m);case"eid_auth":return ct(e,s,i,m);case"doc_ocr":return rt(e,s,i,m);case"identity_confirm":return pt(e,i,p)??l(s);case"portrait_icao":return Pe(e,s,i,m,"capture");case"liveness":case"face_match":{let S=lt(e,s);if(S!==null)return Pe(e,S,i,m,"match");let u=s.requiresMobile===!0,w=F(e);return u&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:p,checkType:f}:{kind:"liveness",key:"biometric",context:i,section:p,mode:f==="face_match"?"selfie":"liveness",requiresMobile:u,instructions:w===null?"standard":"icao",icao:w,livePhoto:at(e,f),...m}}case"nfc_chip":return D(i,p,f,"platform_unsupported");default:return D(i,p,f,"update_required")}}export{Be as a,Ue as b,Fe as c,Ge as d,qe as e,xt as f,Ye as g,_e as h,We as i,Ze as j,At as k,ke as l,vt as m,Vt as n,Ie as o,b as p,X as q,be as r,lt as s,Mt as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as K,c as pe,d as me,e as fe,g as he,h as z,j as Y,l as Se,m as ge,t as ye,v as O,w as j}from"./chunk-ZUHTYCY4.js";import{c as le,d as de,e as ue}from"./chunk-FPXL63KZ.js";import{c as F,f as $,g as ke}from"./chunk-F5ST423J.js";var ve=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var Me=["carte_identite","passport","residence_permit"];function Ve(e,n){let i=e.byIssuer?.[n]??e.default;return Me.filter(s=>i==="*"||i.includes(s))}function ht(e,n=ve){return[...new Set([...n,...Object.keys(e.byIssuer??{})])].filter(s=>Ve(e,s).length>0).sort()}function _e(e){if(e.acceptedDocuments)return e.acceptedDocuments;let n=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:n}}}var Le=640,De=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),be=6,Pe=1500,Ce={sharpness:1,exposure:1,meanLuma:128},we=null;function He(e,n){try{we??(we=document.createElement("canvas"));let i=we,s=96/Math.max(1,n.width);i.width=Math.max(1,Math.round(n.width*s)),i.height=Math.max(1,Math.round(n.height*s));let a=i.getContext("2d");if(a===null)return Ce;a.drawImage(e,n.x,n.y,n.width,n.height,0,0,i.width,i.height);let c=a.getImageData(0,0,i.width,i.height);return{sharpness:de(c),exposure:ue(c),meanLuma:le(c)}}catch{return Ce}}async function Ne(e,n){let i=e.source;return"convertToBlob"in i?i.convertToBlob({type:"image/jpeg",quality:n}):new Promise((s,a)=>{i.toBlob(c=>c===null?a(new Error("encode failed")):s(c),"image/jpeg",n)})}function vt(e,n={}){let i=n.now??(()=>performance.now()),s=n.setTimer??((t,o)=>setTimeout(t,o)),a=n.clearTimer??(t=>clearTimeout(t)),c=n.encode??Ne,u=n.quality??He,l=e.tuningVersion??null,g=new Set,k=!1,S=e.video??null,h=null,v=n.grabFrame??null,T=null,M=1e3/be,P=null,w=null,H=!1,A=!1,x=Number.NEGATIVE_INFINITY,C=null,B=0,V=null,N=null,G=Promise.all([import("./icao-gate-PWBMKRGC.js"),import("./icao-tuning-4GGVX6B4.js"),import("./create-portrait-capture-B57GE5FU.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([t,o,r,d,f])=>{let m=o.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);m.background.required&&(w=f.createBackgroundMonitor({tuning:m.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...n.createSegmenter!==void 0?{createSegmenter:n.createSegmenter}:{},now:i})),h=t.createIcaoGate(m,{policy:e.policy??"reject"}),v??(v=r.defaultGrabber()),T=r.observe,M=1e3/Math.min(be,m.cadenceHz);let y=(n.createLandmarker??d.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),p=await new Promise((_,b)=>{let E=setTimeout(()=>{b(new Error("landmarker init timeout")),y.then(I=>I.close(),()=>{})},d.LANDMARKER_INIT_TIMEOUT_MS);y.then(I=>{clearTimeout(E),_(I)},I=>{clearTimeout(E),b(I)})});k?p.close():P=p}).catch(()=>{H=!0}),Q=t=>{for(let o of g)o({holding:A||H,update:t})},U=()=>{if(C=null,!(k||P===null||h===null||v===null||T===null||S===null)){if(i()-x>Pe){Q(null);return}try{let t=v(S,Le);if(t!==null){let o=Math.max(i(),B+1);B=o;let r=P.detect(t.source,o),d=S.videoWidth||t.width,f=S.videoHeight||t.height,m=T(r,t,d,f);m.geometry!==null&&w!==null&&(m.backgroundCheck=w.measure(t,m.geometry.box,d,f));let y=h.push(m,i());A=y.ready,Q(y)}}catch{}C=s(U,M)}},Z=()=>{let t=i()-x>Pe;x=i(),t&&(h?.reset(),A=!1,V=null,N=null),C===null&&P!==null&&!k&&(C=s(U,0))},J=()=>{let t=v===null||S===null?null:v(S,null);if(t===null||h===null||Math.max(t.width,t.height)<e.still.minLongSidePx)return Promise.resolve(null);let o=h.summary();return c(t,e.still.jpegQuality).then(r=>({image:r,width:t.width,height:t.height,gate:o}),()=>null)},L=null;return{engineOptions:{measureQuality:(t,o)=>{S=t,Z();let r=u(t,o);return A||H?r:{...r,sharpness:0}},telemetry:t=>{if(t.type!=="fired"||k)return;V=J();let o=L;o!==null&&V.then(r=>r===null?void 0:o(r).catch(()=>{})),A=!1,C!==null&&a(C),C=null,x=Number.NEGATIVE_INFINITY}},decorate:t=>{let o=new WeakMap,r=new Map,d=p=>{let _=o.get(p);return _===void 0&&(_=(async()=>{let b=await ge(t,"image","image/jpeg",p.image.size,{engine:"portrait"});return await t.uploadToSpaces(b.uploadUrl,p.image,"image/jpeg"),(await t.completeMedia(b.key)).key})(),_.catch(()=>o.delete(p)),o.set(p,_)),_};L=d;let f=async p=>{let _;try{_=await d(p)}catch(b){let E=b?.code;if(typeof E=="string"&&De.has(E))throw b;return null}return{media:{portrait:_},gate:ke(p.gate),...l!==null?{tuningVersion:l}:{}}},m=t.submitCheck.bind(t),y=(async(p,_,b)=>{if(p!=="liveness")return m(p,_,b);let E=b?.idempotencyKey,I=E===void 0?void 0:r.get(E);if(I===void 0){let ae=V;I=ae===null?Promise.resolve(null):ae.then(ce=>ce===null?null:f(ce)),E!==void 0&&(r.set(E,I),I.catch(()=>r.delete(E)))}let X=await I;if(X===null)return m("liveness",_,b);let Re=await m("liveness",{..._,portraitIcao:X},b);return N=X,Re});return new Proxy(t,{get(p,_){if(_==="submitCheck")return y;let b=Reflect.get(p,_);return typeof b=="function"?b.bind(p):b}})},onGate:t=>(g.add(t),()=>g.delete(t)),lastPortraitInput:()=>N,destroy:()=>{k=!0,V=null,N=null,C!==null&&a(C),C=null,g.clear(),G.then(()=>{P?.close(),P=null,w?.close(),w=null})}}}var Ge=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","face_match","aml_screening","face_dedup"]),Be=new Set(["supplied_identity","aml_screening","face_dedup"]),te=["document","population_registry","national_eid"],ne=["phone_otp","email_otp"],Ee={identity_method:te,contact:ne},Ue=["population_registry","document"],Ie="platform_unsupported",Fe=new Set(["prefilled","user_entered","prefilled_or_entered"]),Ke={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function R(e){return e.section??Ke[e.checkType]??null}function ie(e,n){let i=e.plan?.choice;if(i===void 0||i.locked)return;let s=i.options.find(a=>a.id!==i.selected&&a.available!==!1&&n.includes(a.service));return s===void 0?void 0:{nodeId:i.nodeId,option:s}}function oe(e){let n=e.plan,i=n?.choice;if(n===void 0||i===void 0||i.locked||n.current===null||n.current===i.nodeId||z(e))return null;let s=Ee[i.kind]??[...te,...ne],a=i.options.flatMap(l=>l.available===!1||!s.includes(l.service)?[]:[l.nationalEid!=null?{id:l.id,service:l.service,nationalEid:l.nationalEid}:{id:l.id,service:l.service}]),c=n.steps.find(l=>l.id===n.current)?.service,u=i.selected??a.find(l=>l.service===c)?.id??null;return a.some(l=>l.id!==u)?{nodeId:i.nodeId,kind:i.kind,current:u,options:a}:null}function Te(e){return e==null?[]:e.options.filter(n=>n.id!==e.current)}function je(e){let n=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),i={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:n.map(a=>a.id),progress:n};e.branding!==void 0&&(i.branding=e.branding);let s=oe(e);return s!==null&&(i.switchable=s),i}function qe(e){let n={attemptsRemaining:me(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(n.reason=e.reason),n}var Oe={phone_otp:"phone",email_otp:"email"};function Qe(e,n){let i=ie(e,[n==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Oe[i.option.service]}function Ye(e,n,i,s){let a=n.checkType==="email_otp",c=(a?n.emailOtp:n.otp)??{},u=a?n.emailOtp?.emailSource:n.otp?.numberSource,l=u!==void 0&&Fe.has(u)?u:a?"prefilled_or_entered":"user_entered",g=typeof c.sentToMasked=="string"&&c.sentToMasked.length>0,k=Qe(e,a?"email_otp":"phone_otp"),S={key:n.checkType,context:i,section:R(n),phase:g?"verify":"send",canSwitch:k!==void 0,...s},h=a?{kind:"email_otp",...S,emailSource:l,needsEmail:l!=="prefilled"}:{kind:"phone_otp",...S,numberSource:l,needsPhone:l!=="prefilled",channels:(n.otp?.channels??[]).filter(v=>v==="whatsapp"||v==="sms")};return k!==void 0&&(h.switchChannel=k),g&&(h.sentToMasked=c.sentToMasked),!a&&n.otp?.channel!==void 0&&(h.channel=n.otp.channel),c.expiresAt!==void 0&&(h.codeExpiresAt=c.expiresAt),c.resendAvailableAt!==void 0&&(h.resendAvailableAt=c.resendAvailableAt),h}function $e(e,n,i,s){let a=e.nniBound===!0?"bound":n.nniFromDocument===!0?"document":"typed",c=a==="typed"&&n.state==="input_required"&&n.reason==="nni_recheck",u=Te(oe(e)),l=!s.attemptsExhausted&&u.length===1&&u[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:R(n),state:n.state==="input_required"?"input_required":"pending",source:a,recheck:c,canUseDocument:l,...s}}function We(e,n,i,s){let a=[...n.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:R(n),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:_e(e),...s}}function Ze(e){let n=Y(e,"liveness");return n?.state==="passed"||n?.state==="review"}function xe(e,n,i,s,a){let c=n.icao?.report;return{kind:"portrait",key:`portrait:${a}`,context:i,section:R(n),phase:a,report:Array.isArray(c)?c:null,review:n.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:$(e),retakeOnly:a==="capture"&&n.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&Ze(e),...s}}var ee={minLongSidePx:1280,jpegQuality:.95};function Je(e,n){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let s=Y(e,"portrait_icao"),a=i.still??ee;return{icao:n==="liveness"&&$(e)!==null&&s!==void 0&&s.state==="pending"&&s.reason===void 0,still:{minLongSidePx:a.minLongSidePx??ee.minLongSidePx,jpegQuality:a.jpegQuality??ee.jpegQuality}}}function Xe(e,n,i,s){let a=n.eid,c=R(n);if(a===void 0||a.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:c,checkType:"eid_auth",reason:"update_required"};let u=Te(oe(e)),l=u.length===1&&Ue.includes(u[0]?.service??"")?u[0]:void 0,g=l===void 0?void 0:K[l.service],k=g!==void 0,S={kind:"eid",key:"eid",context:i,section:c,provider:a.provider,providerName:a.providerName,country:a.country,challenge:"app_code",phase:a.awaiting==="code"?"code":"identifier",identifierBound:a.identifierBound===!0,canUseCamera:k,afterPass:a.afterPass==="continue"?"continue":"end",...s};return k&&(S.cameraMethod=g),a.expiresAt!==void 0&&(S.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(S.resendAvailableAt=a.resendAvailableAt),a.resendsRemaining!==void 0&&(S.resendsRemaining=a.resendsRemaining),a.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=a.codeAttemptsRemaining),S}function ze(e,n){if(n.checkType!=="face_match"||n.reason!==void 0)return null;let i=Y(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}function et(e){return pe(e).some(n=>n.attemptsExhausted===!0)}function tt(e,n){let i=e.failureReason,s;i===Ie?s="platform_unsupported":e.status==="expired"?s="expired":e.status==="review_pending"?s="review":e.status==="completed"&&e.outcome==="approved"?s="approved":e.status==="completed"&&e.outcome==="review"?s="review":i==="device_cooldown"?s="cooldown":i!==void 0?s="policy_stop":et(e)?s="attempts_exhausted":s="rejected";let a=s==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:Se(e,{autoRetry:!1}),c={kind:"result",key:"result",context:n,section:null,display:s,result:a};return i!==void 0&&(c.failureReason=i),e.retryAfter!==void 0&&(c.retryAfter=e.retryAfter),c}function nt(e,n,i){let s=e.identitySummary;if(s==null)return null;let a={kind:"identity_summary",key:"identity_summary",context:n,section:i??"identity",summaryKind:s.kind==="partial"?"partial":s.kind??"full",source:s.source,portraitAvailable:s.portrait?.available===!0,retakeAvailable:s.retakeAvailable===!0};for(let c of it){let u=s[c];typeof u=="string"&&u!==""&&(a[c]=u)}return a}var it=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function q(e,n,i,s){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:n,checkType:i,reason:s}}function ot(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function rt(e,n){let i=Ee[e.kind]??[...te,...ne],s=ot(e),a=e.options.flatMap(u=>{if(u.available===!1||!i.includes(u.service))return[];let l={id:u.id,service:u.service};return u.nationalEid!=null&&(l.nationalEid=u.nationalEid),[l]});if(a.length===0){let u=e.options.length>0&&e.options.every(l=>l.service==="nfc");return q(n,s,"choice",u?"platform_unsupported":"update_required")}let c={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:a};if(e.kind==="identity_method"){let u={kind:"method",key:"method",context:n,section:s,options:a.map(g=>K[g.service]),choice:c},l=a.find(g=>g.nationalEid!==void 0)?.nationalEid;return l!==void 0&&(u.nationalEid=l),u}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:n,section:s,options:a.map(u=>Oe[u.service]),selected:null,locked:!1,choice:c}:{kind:"choice",key:`choice:${e.nodeId}`,context:n,section:s,choice:c}}function W(e,n={}){let i=je(e);if(z(e)||e.failureReason===Ie)return tt(e,i);let s=e.plan;if(s===void 0||!Array.isArray(s.sections))return q(i,null,"plan","update_required");let a=fe(e);if(a!==null)return rt(a,i);let c=s.current===null?void 0:s.steps.find(h=>h.id===s.current),u=h=>({kind:"processing",key:"processing",context:i,section:h!==void 0?R(h):s.sections.find(v=>v.state==="current")?.id??null,stalled:!1});if(s.current===null)return u(s.steps.find(h=>h.state==="processing"));if(c===void 0||!Ge.has(c.service))return q(i,c===void 0?null:R(c),c?.service??"step","update_required");if(Be.has(c.service)||!he(c))return u(c);let l=c,g=qe(l),k=l.checkType,S=R(l);switch(k){case"phone_otp":case"email_otp":return Ye(e,l,i,g);case"population_registry":return $e(e,l,i,g);case"eid_auth":return Xe(e,l,i,g);case"doc_ocr":return We(e,l,i,g);case"identity_confirm":return nt(e,i,S)??u(l);case"portrait_icao":return xe(e,l,i,g,"capture");case"liveness":case"face_match":{let h=ze(e,l);if(h!==null)return xe(e,h,i,g,"match");let v=l.requiresMobile===!0,T=$(e);return v&&n.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:S,checkType:k}:{kind:"liveness",key:"biometric",context:i,section:S,mode:k==="face_match"?"selfie":"liveness",requiresMobile:v,instructions:T===null?"standard":"icao",icao:T,livePhoto:Je(e,k),...g}}case"nfc_chip":return q(i,S,k,"platform_unsupported");default:return q(i,S,k,"update_required")}}function re(e){return/^\d{10}$/.test(e)&&Number(e)%97===1}function se(e){let n="";for(let i of e){let s=i.codePointAt(0)??0;s>=1632&&s<=1641?n+=String(s-1632):s>=1776&&s<=1785?n+=String(s-1776):i!==" "&&i!=="-"&&i!=="\xA0"&&(n+=i)}return n}var st=[1e3,2e3,4e3,8e3,15e3],at=3e4,ct=/^\+[1-9]\d{7,14}$/,lt=/^\d{6}$/,dt=/^\d{6}$/,ut=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ae=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active"]),pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function Mt(e){let n=!1,i=null,s="",a=!1,c=!1,u=!1,l={},g={},k=new Set,S=!1,h=null,v="idle",T=new Map,M=new Map,P=(t,o,r)=>{let d=`${t}.${o}`,f=T.get(d);if(f!==void 0)return f;let m=M.get(t),y=(m===void 0?r():m.then(r)).finally(()=>{T.delete(d)});T.set(d,y);let p=y.then(()=>{},()=>{});return M.set(t,p),p.then(()=>{M.get(t)===p&&M.delete(t)}),y},w=async(t,o,r)=>{await e.ensureConsent();let d;try{d=await ye(e.runtime,o)}catch(m){if(m instanceof F&&Ae.has(m.code)){await e.refreshView();return}throw m}if(r?.(),e.destroyed())return;let f=d;f.plan!==void 0&&e.setView!==void 0?e.setView(f):await e.refreshView()},H=async t=>{await e.ensureConsent();let o;try{try{o=await t(e.runtime.client)}catch(r){if(!(r instanceof F)||r.code!=="consent_required")throw r;await e.runtime.ensureConsent({force:!0}),o=await t(e.runtime.client)}}catch(r){if(r instanceof F&&Ae.has(r.code)){await e.refreshView();return}throw r}e.destroyed()||(o!==void 0&&e.setView!==void 0?e.setView(o):await e.refreshView())},A=(t,o)=>P("choice",`${t}:${o}`,()=>H(r=>r.choose(t,o))),x=(t,o)=>t.options.some(r=>r.id===o)?A(t.nodeId,o):Promise.reject(new RangeError(`option ${String(o)} is not offered`)),C=(t,o)=>{let r=e.currentView(),d=r===null?void 0:ie(r,t);return d===void 0?Promise.reject(new RangeError(`the ${o} is not offered`)):A(d.nodeId,d.option.id)},B=t=>P("identity",t,()=>H(o=>o.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):o.confirmIdentity(t))),V=(t,o)=>{let r=t.kind,d=r==="phone_otp",f=d?"phone":"email",m={action:"send"};if(d?t.needsPhone:t.needsEmail){let y=o[f]??g[r],p=d?y?.replace(/[\s().-]/g,""):y?.trim();if(p===void 0||!(d?ct:ut).test(p))return Promise.reject(d?new O("phone","format"):new j("email","format"));m[f]=p}if(d){let y=t.channels,p=o.channel??(y.length===1?y[0]:void 0);if(y.length>0){if(p===void 0)return Promise.reject(new j("channel","required"));if(!y.includes(p))return Promise.reject(new j("channel","unavailable"))}p!==void 0&&(m.channel=p)}return P(r,"send",()=>w(r,(y,p)=>y.submitCheck(r,m,{idempotencyKey:p}),()=>{l[r]=e.now(),m[f]!==void 0&&(g[r]=m[f])}))},N=(t,o)=>lt.test(o)?P(t,"verify",()=>w(t,(r,d)=>r.submitCheck(t,{action:"verify",code:o},{idempotencyKey:d}))):Promise.reject(new O("code","format")),G=(t,o)=>P("eid_auth",t,()=>w("eid_auth",(r,d)=>r.submitCheck("eid_auth",o,{idempotencyKey:d}))),Q=(t,o)=>{if(t.identifierBound)return G("start",{action:"start"});let r=se(o??"");if(t.country==="MR"){if(!/^\d{10}$/.test(r))return Promise.reject(new O("nni","format"));if(!re(r))return Promise.reject(new O("nni","check_digit"))}else if(r==="")return Promise.reject(new O("nni","format"));return G("start",{action:"start",identifier:r})},U=t=>{switch(t.kind){case"phone_otp":case"email_otp":{let o={...t,send:(d={})=>V(t,d),verify:d=>N(t.kind,d),switchTo:()=>t.canSwitch&&t.switchChannel!==void 0?C([t.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},r=l[t.kind];return o.resendAvailableAt===void 0&&r!==void 0&&(o.resendAvailableAt=new Date(r+at).toISOString()),o}case"eid":return{...t,start:o=>Q(t,o),verify:o=>dt.test(o)?G("verify",{action:"verify",code:o}):Promise.reject(new O("code","format")),resend:()=>t.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>t.canUseCamera&&t.cameraMethod!==void 0?C(t.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...t,select:o=>{let r=t.choice.options.find(d=>K[d.service]===o);return r!==void 0?x(t.choice,r.id):Promise.reject(new RangeError(`method ${String(o)} is not offered`))},choose:o=>x(t.choice,o)};case"choice":return{...t,choose:o=>x(t.choice,o)};case"registry":return{...t,submitNni:o=>{if(t.source!=="typed")return Promise.reject(new RangeError("this session already holds the NNI"));let r=se(o);return/^\d{10}$/.test(r)?re(r)?P("population_registry","submitNni",()=>w("population_registry",(d,f)=>d.submitCheck("population_registry",{nni:r},{idempotencyKey:f}),()=>{h=`\u2022\u2022\u2022\u2022\u2022\u2022${r.slice(-4)}`})):Promise.reject(new O("nni","check_digit")):Promise.reject(new O("nni","format"))},confirm:()=>P("population_registry","confirm",()=>w("population_registry",(o,r)=>o.submitCheck("population_registry",{},{idempotencyKey:r}))),useDocument:()=>t.canUseDocument?C(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?e.bindDocument(t,D):{...t,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")}};case"portrait":return e.bindPortrait!==void 0?e.bindPortrait(t,D):{...t,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")}};case"contact_choice":return{...t,select:o=>{let r=o==="phone"?"phone_otp":o==="email"?"email_otp":void 0,d=t.choice.options.find(f=>f.service===r);return d!==void 0?x(t.choice,d.id):Promise.reject(new RangeError(`contact ${String(o)} is not offered`))},choose:o=>x(t.choice,o)};case"identity_summary":return{...t,...t.nniMasked===void 0&&t.summaryKind==="partial"&&h!==null?{nniMasked:h}:{},portrait:async()=>{let o=e.runtime.client;if(!t.portraitAvailable||o.identityPortrait===void 0)return null;try{return await o.identityPortrait()}catch{return null}},confirm:()=>B("confirm"),retake:()=>t.retakeAvailable?B("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...t,capture:o=>e.liveness(o),onLivePhoto:o=>t.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(o):()=>{}};case"mobile_required":case"processing":return{...t,refresh:async()=>{a=!1,await e.refreshView()}};case"unsupported":case"result":return{...t};default:{let o=t;throw new Error(`runner: unhandled step ${JSON.stringify(o)}`)}}},Z=async()=>{if(!c){c=!0;try{for(let t of st){if(await e.sleep(t),!n||e.destroyed())return;let o=await e.refreshView().catch(()=>null);if(o!==null&&W(o,{isMobile:e.isMobile()}).kind!=="processing")return}a=!0,D()}finally{c=!1}}},J=t=>{if(t.kind!=="liveness"||t.mode!=="selfie")return null;let o={kind:"processing",key:"processing",context:t.context,section:t.section,stalled:!1};if(v==="inflight")return o;if(!S||v==="done")return null;let r=e.keptFaceKey?.()??null;return r===null?null:(v="inflight",w("face_match",(d,f)=>d.submitCheck("face_match",{imageKey:r},{idempotencyKey:f}),()=>{v="done"}).then(()=>{v==="inflight"&&(v="done",D())},()=>{v="done",D()}),o)},L=(t,o=!1)=>{if(!n||e.destroyed()||e.chainBusy())return;let r=W(t,{isMobile:e.isMobile()});r.kind==="registry"&&r.recheck&&(S=!0,v="idle"),r=J(r)??r,r.kind==="processing"?r.stalled=a:a=!1;let d=U(r),f=r.kind==="result"?void 0:r.context.switchable,m=f===void 0?d:{...d,chooseOption:p=>x({nodeId:f.nodeId,kind:f.kind,selected:f.current,options:f.options},p)},y=JSON.stringify(m);r.kind==="registry"&&r.source==="document"&&r.state==="pending"&&!k.has("registry")&&(k.add("registry"),m.confirm().catch(p=>{(!(p instanceof F)||pt.has(p.code))&&k.delete("registry")})),!(!o&&y===s)&&(s=y,i=m,e.emitStep(m),r.kind==="processing"&&!a&&v!=="inflight"&&Z(),r.kind==="result"&&!u&&(u=!0,e.emitResult(r.result)))};function D(){let t=e.currentView();t!==null&&L(t,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");n=!0;let t=await e.ensureView();return i===null&&L(t),i??U(W(t,{isMobile:e.isMobile()}))},current:()=>i,onView:t=>L(t),onChainIdle:()=>{let t=e.currentView();t!==null&&L(t)},republish:D,submit:w}}export{Ve as a,ht as b,be as c,Pe as d,vt as e,W as f,st as g,at as h,Mt as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c="0.1.0-rc.
|
|
1
|
+
var c="0.1.0-rc.9";var d="sekyro.did",l;function g(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function f(){try{let t=localStorage.getItem(d);if(t)return t;let e=g();return e!==void 0&&localStorage.setItem(d,e),e}catch{return l??(l=g()),l}}async function m(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function p(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(t){let e,r;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{r??(r=m().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await r,s=f(),u={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...s?[{kind:"web_local",value:s.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return p(JSON.stringify(u))}catch{return}}}}var o=Symbol.for("sekyro.web.clientContext"),a=globalThis,b=a[o]??(a[o]=y({sdk:`@sekyro/web@${c}`}));function C(t){try{let e=t.getVideoTracks?.()[0];e&&b.noteCameraLabel(e.label)}catch{}}export{b as a,C as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R,b as K}from"./chunk-7V2M6Y2W.js";import{b as I,u as B}from"./chunk-
|
|
1
|
+
import{a as R,b as K}from"./chunk-7V2M6Y2W.js";import{b as I,u as B}from"./chunk-EVVGQSNJ.js";import{f as H}from"./chunk-FHJ7HO3M.js";import{a as U,f as p}from"./chunk-OKWG3PVH.js";var G=12e4,V=13e4,q=3e3,N=1200,y=Symbol.for("@sekyro/web.preload.v1");function u(){let e=globalThis;return e[y]??(e[y]=new Map),e[y]}function f(e){let t=(e??U).replace(/\/+$/,"");return t===""?"/":t}function F(e){let t=u(),s=t.get(e);return s===void 0&&(s={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,s)),s}function C(e,t){if(e.status!==t){e.status=t;for(let s of[...e.listeners])s(t)}}var D=e=>p({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:G}),k=D;function ne(e){k=e??D}function oe(){for(let e of u().values())e.detector?.destroy();u().clear(),k=D}function $(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function Q(){return navigator.connection?.saveData===!0}function Z(e){let t=window;if(typeof t.requestIdleCallback=="function"){let n=t.requestIdleCallback(e,{timeout:q});return()=>t.cancelIdleCallback?.(n)}let s=setTimeout(e,N);return()=>clearTimeout(s)}function j(e,t){let s,n=new Promise(i=>{s=i}),o=!1,c=()=>{},l={promise:n,settle:i=>{o||(o=!0,c(),e.scheduled===l&&(e.scheduled=null),s(i))}};return e.scheduled=l,c=Z(()=>{o||l.settle(_(e,t))}),n}function _(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;C(e,"loading");let s=new Promise(i=>i(k(t)));e.detectorPromise=s;let n,o=new Promise((i,m)=>{n=setTimeout(()=>{s.then(a=>a.destroy(),()=>{}),m(new Error(`detector preload exceeded ${V} ms`))},V)}),l=Promise.race([s,o]).then(i=>e.detectorPromise!==s?(i.destroy(),e.status):(e.detector=i,C(e,"ready"),"ready"),i=>(e.detectorPromise===s&&(e.detectorPromise=null,e.detector=null,C(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",i)),e.status)).finally(()=>clearTimeout(n));return e.promise=l,e.scheduled?.settle(l),l}function ie(e={}){if(!$())return Promise.resolve("idle");let t=f(e.assetBaseUrl),s=F(t);return e.respectSaveData===!0&&Q()?Promise.resolve(s.status):(s.status==="loading"||s.status==="ready")&&s.promise!==null?s.promise:e.idle===!0?s.scheduled?.promise??j(s,t):_(s,t)}function ae(e){return u().get(f(e))?.status??"idle"}function le(e,t){let s=F(f(t));return s.listeners.add(e),()=>{s.listeners.delete(e)}}function de(e){let t=u().get(f(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,C(t,"idle"))}function J(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function W(e){let t=f(e),s=u().get(t);if(!(s===void 0||s.detector===null&&s.detectorPromise===null&&s.scheduled===null))return async()=>{s.scheduled!==null&&_(s,t);let n=s.promise;for(;s.detector===null&&n!==null&&(await n,s.promise!==n);)n=s.promise;return s.detector!==null?J(s.detector):p({v3AssetBaseUrl:t})}}function X(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 Y(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function ee(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function te(e,t={},s){let n=t.now??(()=>performance.now()),o=R(),c=!H(),l=t.engineOptions,i=l?.createDetector===void 0&&l?.createWorker===void 0?{createDetector:()=>{let r=W(e.assetBaseUrl);return r!==void 0?r():p({v3AssetBaseUrl:e.assetBaseUrl})}}:{},m={video:e.video,mode:c?"photo":"clip",rankKeyframes:s,facingMode:e.facing,v3AssetBaseUrl:e.assetBaseUrl,...t.engineOptions??{},...i},a=t.createEngine?.(m)??new B(m),v="idle",g=null,S=0,E=!1,b="full",L=null,h=null,A=0,P=0,O=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(A=e.video.videoWidth,P=e.video.videoHeight)},M=K({enabled:e.keepScreenAwake!==!1}),T=r=>{v=r,M.setActive(r==="starting"||r==="gating"||r==="recording"),o.emit("state",r)},w=()=>o.emit("gate",{progress:S,hint:g,faceDetected:E}),x=()=>{let r=a.animations??"full";r!==b&&(b=r,o.emit("profile",{animations:b}))},z=[a.on("statechange",({state:r})=>{let d=Y(r);d==="starting"&&v!=="starting"&&(g=null,S=0,E=!1,L=null,h=null,A=0,P=0),T(d),x(),d==="recording"&&(O(),L=n(),g="hold",S=1,w())}),a.on("checks",r=>{O(),S=r.progress,E=r.factors.presence>0,w(),x()}),a.on("guidance",({key:r})=>{g=X(r),w()}),a.on("frozen",({previewDataUrl:r})=>{h=n(),o.emit("frozen",{previewDataUrl:r})}),a.on("artifacts",r=>{let d=L!==null&&h!==null?Math.max(0,Math.round(h-L)):void 0;o.emit("captured",{keyframe:r.keyframe,...r.clip!==void 0?{clip:r.clip}:{},...r.clipMimeType!==void 0?{clipMime:r.clipMimeType}:{},width:e.video.videoWidth||A,height:e.video.videoHeight||P,...d!==void 0?{clipMs:d}:{},captureChannel:I()?"mobile":"desktop",...c?{degraded:"NO_RECORDER"}:{},engine:"v3",...r.timing})}),a.on("error",({kind:r,retryable:d})=>{o.emit("error",{kind:ee(r),retryable:d})})];return{handle:{get state(){return v},on:(r,d)=>o.on(r,d),start:r=>a.start({facingMode:r?.facing}),retry:()=>a.retry(),switchCamera:()=>a.switchCamera(),destroy:()=>{for(let r of z)r();M.setActive(!1),a.destroy(),o.clear()}},setFlowState:r=>{v!==r&&T(r)}}}function Le(e){return te(e).handle}export{G as a,V as b,ne as c,oe as d,ie as e,ae as f,le as g,de as h,W as i,X as j,Y as k,ee as l,te as m,Le as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as C,d as P}from"./chunk-F5ST423J.js";var F=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","nationality_unreadable","liveness_inconclusive","match_inconclusive","document_authenticity","probe_not_from_liveness","chip_read_failed","chip_access_denied","chip_parse_failed","icao_pose","icao_eyes","icao_mouth","icao_occlusion","icao_lighting","icao_background","icao_resolution","portrait_not_from_liveness","nni_recheck","device_integrity_failed","eid_identifier_invalid","eid_code_invalid","eid_code_expired","eid_unavailable","eid_resend_too_soon"]),O={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}function M(e){return Math.max(0,e.attempts.max-e.attempts.used)}function K(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function ie(e){let n=K(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(r=>O[r.service]).filter(r=>r!==void 0),i=n.options.find(r=>r.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var q=new Set(["liveness","face_match"]);function k(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function E(e){return e.status!=="created"&&e.status!=="in_progress"}function b(e){let n=e.plan?.current,t=n==null?void 0:y(e).find(i=>i.id===n);return k(t)?t:void 0}function l(e,n){return y(e).find(t=>t.checkType===n)}function x(e,n){let t=l(n,"liveness")?.state,i=l(n,"face_match")?.state;return(l(e,"face_match")?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function S(e,n){return n===void 0?{sessionId:e,status:"unavailable"}:{sessionId:e,status:"unavailable",reason:n}}function _(e,n,t){return t===void 0?{sessionId:e,status:n}:{sessionId:e,status:n,reason:t}}function oe(e,n){let{sessionId:t}=e;switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:t,status:"approved"}:e.outcome==="review"?_(t,"review",h(e,"review")):_(t,"rejected",h(e,"failed"));case"failed":{let o=_(t,"rejected",e.failureReason??h(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(o.retryAfter=e.retryAfter),o}case"review_pending":return _(t,"review",h(e,"review"));case"expired":return S(t);case"created":case"in_progress":break;default:{let o=e.status;throw new Error(`mapSessionResult: unhandled status ${o}`)}}let i=y(e).find(o=>q.has(o.checkType)&&o.state==="input_required"&&o.reason!==void 0);if(i?.reason==="mobile_required")return S(t,"mobile_required");if(i?.reason!==void 0){let o=n.autoRetry&&F.has(i.reason)&&M(i)>0;return{sessionId:t,status:o?"retry":"rejected",reason:i.reason,attemptsRemaining:M(i)}}let r=b(e);return r===void 0&&y(e).some(o=>o.state==="review")?_(t,"review",h(e,"review")):r?.checkType==="portrait_icao"?S(t,"portrait_required"):S(t)}function h(e,n){return y(e).find(t=>t.state===n&&t.reason!==void 0)?.reason}function A(e,n,t,i,r){return e.presignCapture!==void 0?e.presignCapture(n,t,i,r):e.presign(n,t,i)}function T(e){return{...e?.engine!==void 0?{engine:e.engine}:{},...e?.clipMs!==void 0?{durationMs:e.clipMs}:{}}}var N=["video/webm","video/mp4"],V="image/jpeg",Y=2,D=1e3,U=1e4,B=3,$=10,j=30,z=3,X=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),W=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),g=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function G(e){let n=l(e,"face_match");return l(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?k(n):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(n){super(n),this.name="AttestationError"}};async function H(e,n,t={}){let i=e.uuid(),r=!1,o=!1,u=0,c=0;for(;;)try{return await n(e.client,i)}catch(a){if(a instanceof w){if(o)throw a;o=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(a instanceof C))throw a;if(a.code==="consent_required"&&!r){r=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(a.code==="attestation_invalid"&&!o){o=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(a.code==="inference_unavailable"&&c<B){c+=1;let s=Math.min(a.retryAfterSeconds??$,j);e.onBusy?.({attempt:c,retryAfterSeconds:s}),await e.sleep(s*1e3),t.onAttestationInvalid?.(),i=e.uuid();continue}if(X.has(a.code)&&u<Y){u+=1;let s=a.retryAfterSeconds!==void 0?a.retryAfterSeconds*1e3:void 0;await e.sleep(s!==void 0?Math.min(s,U):D);continue}throw a}}var J=new Set(["passed","review","processing","skipped"]);async function ue(e){let{artifacts:n}=e,t=n.clip,i=P(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!N.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let r=Q(e,n.keyframe),o=Z(e,t,i,r),u=ee(e,r),c=!1,a=!1,s=!0,f=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let d=e.getView();if(E(d))return{kind:"settled"};let R=b(d)?.checkType,v=R==="liveness"&&!c?"liveness":R==="face_match"&&!a&&s?"face_match":null;if(v===null)return{kind:"settled"};if(v==="liveness"&&n.captureChannel==="desktop"&&l(d,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(v==="liveness"){c=!0;let p=await o();if(e.isCancelled())return{kind:"cancelled"};a=x(d,p),await e.applySubmit(p,"liveness");let m=l(e.getView(),"liveness")?.state;s=m===void 0||J.has(m)}else{a=!0;let p=await u();if(e.isCancelled())return{kind:"cancelled"};await e.applySubmit(p,"face_match")}}catch(p){if(e.isCancelled()||p instanceof g)return{kind:"cancelled"};let m=te(p);if(m.kind!=="resync"||f>=z)return m;f+=1,await e.refreshView()}}}function Q(e,n){let t=null,i=null,r=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let o=await A(e.client,"image",V,n.size,T(e.artifacts));return await e.client.uploadToSpaces(o.uploadUrl,n,V),t=(await e.client.completeMedia(o.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:r,attempt:()=>r().catch(()=>null),current:()=>t}}function Z(e,n,t,i){let r=null,o,u=null;return()=>H(e,async(c,a)=>{if(r===null||o===void 0){if(e.isCancelled())throw new g;o===void 0&&!G(e.getView())&&(o=null),e.onPhase("uploading");let[s,f]=await Promise.all([r!==null?Promise.resolve(r):(async()=>{let d=await A(c,"clip",t,n.size,T(e.artifacts));return await c.uploadToSpaces(d.uploadUrl,n,t),(await c.completeMedia(d.key)).key})(),o!==void 0?Promise.resolve(o===null?null:o.imageKey):i.attempt()]);r=s,o===void 0&&(o=f===null?null:{imageKey:f})}if(u===null)try{u=await e.getAttestation()}catch(s){throw new w(s instanceof Error?s.message:String(s))}return e.onPhase("checking"),c.submitCheck("liveness",{clipKey:r,attestation:u,captureChannel:e.artifacts.captureChannel,capture:ne(e.artifacts),...o!==null?{faceMatch:o}:{}},{idempotencyKey:a})},{onAttestationInvalid:()=>{u=null}})}function ee(e,n){return()=>H(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new g;e.onPhase("uploading")}let r=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:r},{idempotencyKey:i})})}function ne(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 te(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof C){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(W.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var L=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},I=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};export{F as a,O as b,y as c,M as d,K as e,ie as f,k as g,E as h,b as i,l as j,S as k,oe as l,A as m,N as n,Y as o,D as p,B as q,$ as r,w as s,H as t,ue as u,L as v,I as w};
|
package/dist/client/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var o in e)y(t,o,{get:e[o],enumerable:!0})},M=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!v.call(t,i)&&i!==o&&y(t,i,{get:()=>e[i],enumerable:!(n=R(e,i))||n.enumerable});return t};var A=t=>M(y({},"__esModule",{value:!0}),t);var Y={};H(Y,{HostedApiError:()=>d,HostedClient:()=>p,KNOWN_CODES:()=>g,icaoPolicyOf:()=>I,isKnownCode:()=>T,portraitIcaoGate:()=>k,stripMimeParams:()=>u});module.exports=A(Y);var b="0.1.0-rc.9";var w="sekyro.did",S;function C(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}}catch{}}function N(){try{let t=localStorage.getItem(w);if(t)return t;let e=C();return e!==void 0&&localStorage.setItem(w,e),e}catch{return S??(S=C()),S}}async function x(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,o=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(o));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function D(t){let e=new TextEncoder().encode(t),o="";for(let n of e)o+=String.fromCharCode(n);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function V(t){let e,o;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{o??(o=x().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await o,s=N(),r={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...s?[{kind:"web_local",value:s.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return D(JSON.stringify(r))}catch{return}}}}var m=Symbol.for("sekyro.web.clientContext"),f=globalThis,h=f[m]??(f[m]=V({sdk:`@sekyro/web@${b}`}));var g=["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","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_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","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active"];function T(t){return g.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),e.details&&(this.details=e.details)}};var K=6e4,P=4,U=3e4,L=9e5,q=200,F=5,$=400;function u(t){return(t.split(";")[0]??"").trim()}var B={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},p=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let o=e.fetch;this.fetchImpl=(n,i)=>(o??globalThis.fetch).call(globalThis,n,i),this.requestTimeoutMs=e.requestTimeoutMs??U,this.retryAttempts=e.inProgressRetry?.attempts??F,this.retryDelayMs=e.inProgressRetry?.delayMs??$}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 choose(e,o){let n=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:o}});return this.sessionId=n.sessionId,n}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,o,n){let i=await this.ensureSessionId(),s={kind:e,contentType:u(o),contentLength:n};return this.api("POST",`/sessions/${i}/media`,{body:s})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,o,n,i={}){let s=await this.ensureSessionId(),r=await this.takeCaptureNonce(),c=r===void 0?void 0:{nonce:r,...i.engine!==void 0?{engine:i.engine.slice(0,32)}:{},...i.durationMs!==void 0&&Number.isFinite(i.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(i.durationMs)))}:{}},a={kind:e,contentType:u(o),contentLength:n,...c!==void 0?{capture:c}:{}};return this.api("POST",`/sessions/${s}/media`,{body:a})}async takeCaptureNonce(){let e=()=>{let o=Date.now();return this.captureNonces=this.captureNonces.filter(n=>n.expiresAt-K>o),this.captureNonces.shift()?.nonce};for(let o=0;o<2;o++){let n=e();if(n!==void 0)return n;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let o=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${o}/media/capture-nonces`,{body:{count:Math.min(P,Math.max(1,e))}}),i=Date.now()+Math.max(0,n.expiresIn)*1e3;for(let s of Array.isArray(n.nonces)?n.nonces:[])typeof s=="string"&&s.length>0&&this.captureNonces.push({nonce:s,expiresAt:i});this.captureNonces=this.captureNonces.slice(-P)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,o,n){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":u(n)},body:o,signal:AbortSignal.timeout(L)})}catch(s){throw _(s)}if(!i.ok){let s=(await i.text().catch(()=>"")).slice(0,q);throw new d({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${s?`: ${s}`:""}`})}}async completeMedia(e){let o=await this.ensureSessionId();return this.api("POST",`/sessions/${o}/media/complete`,{body:{key:e}})}async submitCheck(e,o,n={}){let i=await this.ensureSessionId(),s={input:o,...n.forceOutcome!==void 0?{forceOutcome:n.forceOutcome}:{}};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:s,...n.idempotencyKey!==void 0?{idempotencyKey:n.idempotencyKey}:{}})}async uploadAndSubmit(e,o,n,i={}){let s=u(o.contentType),r=await this.presign(o.kind,s,o.blob.size);await this.uploadToSpaces(r.uploadUrl,o.blob,s);let c=await this.completeMedia(r.key),a={...n,[B[e]]:c.key};return this.submitCheck(e,a,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,o,n={}){let i=`${this.apiOrigin}/api/v2${o}`,s={"x-session-token":this.sessionToken};n.body!==void 0&&(s["content-type"]="application/json"),n.idempotencyKey!==void 0&&(s["x-idempotency-key"]=n.idempotencyKey);try{let r=h.timezone();r!==void 0&&(s["sekyro-client-timezone"]=r)}catch{}try{let r=await h.deviceHeader();r!==void 0&&(s["sekyro-client-device"]=r)}catch{}for(let r=0;;r++){let c;try{c=await this.fetchImpl(i,{method:e,headers:s,...n.body!==void 0?{body:JSON.stringify(n.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw _(l)}if(c.ok){if(n.blob===!0)try{return await c.blob()}catch(E){throw _(E)}let l;try{l=await c.json()}catch{throw new d({status:c.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${c.status})`})}return j(l)}let a=await G(c);if(a.code==="idempotency_in_progress"&&r<this.retryAttempts){this.retryDelayMs>0&&await z(this.retryDelayMs);continue}throw a}}};function _(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new d({status:0,code:"timeout",message:"request timed out"});let o=t instanceof Error?t.message:String(t);return new d({status:0,code:"network_error",message:`network request failed: ${o}`})}function j(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function G(t){let e="unknown_error",o=`request failed (HTTP ${t.status})`,n=Number.NaN,i;try{let c=await t.json();if(c!==null&&typeof c=="object"){let a=c;typeof a.code=="string"&&a.code.length>0&&(e=a.code),typeof a.message=="string"&&a.message.length>0&&(o=a.message),typeof a.retryAfterSeconds=="number"&&(n=a.retryAfterSeconds),Array.isArray(a.details?.issues)&&(i=a.details)}}catch{}let s=t.headers.get("retry-after"),r=s===null?Math.floor(n):Number.parseInt(s,10);return new d({status:t.status,code:e,message:o,...Number.isFinite(r)&&r>=0?{retryAfterSeconds:r}:{},details:i})}function z(t){return new Promise(e=>setTimeout(e,t))}function I(t){let e=t?.portrait,o=e?.icao,n=e?.purpose==="id_document";return o==null?n?{policy:"reject",profile:"id_document"}:null:{policy:o.policy==="alert"&&!n?"alert":"reject",profile:n||o.profile==="id_document"?"id_document":"selfie"}}function k(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,icaoPolicyOf,isKnownCode,portraitIcaoGate,stripMimeParams});
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AcceptedDocumentType,
|
|
1
|
+
import { z as HostedSessionView, r as HostedIcaoPolicy, O as IcaoGateSummary, a9 as PortraitIcaoInput } from '../icao-gate-DKbWXP51.cjs';
|
|
2
|
+
export { A as AcceptedDocumentType, aU as AttestationInput, aV as CaptureContext, aW as CaptureNoncesResult, aX as CaptureProof, aY as CheckInputByType, C as CheckReason, a as CheckState, b as CheckType, aZ as CompleteMediaResult, a_ as ConsentLocale, c as ContactChannel, D as DecisionReason, a$ as DocDeviceRead, b0 as DocOcrInput, d as DocReason, b1 as DocSide, E as EidAfterPass, e as EidAuthInput, f as EidReason, b2 as EmailOtpInput, g as EmailOtpReason, b3 as FaceMatchInput, F as FaceMatchReason, h as HostedAcceptedDocuments, k as HostedCaptureTuning, aT as HostedClient, b4 as HostedClientOptions, l as HostedConsentView, m as HostedDocumentCaptureTuning, n as HostedDocumentScanTuning, o as HostedEidView, p as HostedEmailOtpView, q as HostedFlowRef, s as HostedIntegrity, t as HostedLivePhotoTuning, u as HostedNativeCaptureTuning, v as HostedOcrTuning, w as HostedOtpView, x as HostedPlanView, y as HostedPortraitView, B as HostedStepView, G as HostedVoiceLocale, I as HostedVoiceView, L as IcaoCriterion, Q as IcaoReportEntry, R as IdentityConfirmDecision, S as IdentityMethod, T as IdentitySummarySource, U as IdentitySummaryView, b5 as LivenessCaptureInput, b6 as LivenessInput, V as LivenessReason, W as MatchReason, b7 as MediaCheckType, b8 as MediaKind, X as MethodChoiceView, Y as NationalEidOption, Z as NfcChipReason, _ as NfcStepView, $ as OtpChoiceView, b9 as PhoneOtpInput, a0 as PhoneOtpReason, a1 as PlanAttempts, a2 as PlanChoiceKind, a3 as PlanChoiceOption, a4 as PlanChoiceView, a5 as PlanSectionView, a6 as PlanStepView, a7 as PolicyFailureReason, ba as PopulationInput, a8 as PopulationReason, aa as PortraitIcaoReason, bb as PresignRequest, bc as PresignUploadResult, bd as RecordConsentResult, ab as SessionFailureReason, ac as SessionOutcome, ad as SessionStatus, be as SessionStepView, bf as SessionView, ae as StepSection, bg as SubmitCheckBody, bh as SubmitOptions, bi as UploadMedia, bj as stripMimeParams } from '../icao-gate-DKbWXP51.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Every error code the hosted page can receive from the session-token surface.
|
|
6
6
|
* A closed string-literal union — switch over {@link KnownCode} with a `never`
|
|
7
7
|
* default arm for compile-checked exhaustiveness.
|
|
8
8
|
*/
|
|
9
|
-
declare const KNOWN_CODES: readonly ["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", "platform_unregistered", "app_attest_invalid", "too_many_challenges", "inference_unavailable", "mobile_required", "nni_locked", "
|
|
9
|
+
declare const KNOWN_CODES: readonly ["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", "platform_unregistered", "app_attest_invalid", "too_many_challenges", "inference_unavailable", "mobile_required", "nni_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", "nfc_outcome_not_accepted", "identity_confirm_required", "identity_confirm_locked", "choice_not_found", "choice_locked", "choice_option_unavailable", "step_not_on_path", "check_not_active"];
|
|
10
10
|
/** Closed union of {@link KNOWN_CODES} — exhaustively switchable. */
|
|
11
11
|
type KnownCode = (typeof KNOWN_CODES)[number];
|
|
12
12
|
/** Narrow an arbitrary wire code to the known union (unknown codes stay `string`). */
|
|
13
13
|
declare function isKnownCode(code: string): code is KnownCode;
|
|
14
|
+
/** One machine-readable problem of an error's `details` (Sekyro flows spec §9.4). */
|
|
15
|
+
interface HostedErrorIssue {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
/** The request field (`option`, `nodeId`, …). */
|
|
19
|
+
path?: string;
|
|
20
|
+
/** A node of the flow. */
|
|
21
|
+
nodeId?: string;
|
|
22
|
+
service?: string;
|
|
23
|
+
field?: string;
|
|
24
|
+
}
|
|
25
|
+
/** `details` of a flow error envelope (`choice_*`, `step_not_on_path`, …): the issues, and more per code. */
|
|
26
|
+
interface HostedErrorDetails {
|
|
27
|
+
issues: HostedErrorIssue[];
|
|
28
|
+
/** `override_widens_flow`: the widened fields. */
|
|
29
|
+
fields?: string[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
14
32
|
/**
|
|
15
33
|
* Typed transport error: EVERY failure surfaces as one of these — non-2xx
|
|
16
34
|
* responses, rejected fetches, timeouts, and unparseable bodies alike. The
|
|
@@ -24,16 +42,20 @@ declare function isKnownCode(code: string): code is KnownCode;
|
|
|
24
42
|
* ('network_error' / 'timeout').
|
|
25
43
|
* - `retryAfterSeconds` — parsed from the `Retry-After` header when present
|
|
26
44
|
* (rate-limit 429s always set it).
|
|
45
|
+
* - `details` — the envelope's machine-readable `details` when present (flow
|
|
46
|
+
* errors: `issues[]`).
|
|
27
47
|
*/
|
|
28
48
|
declare class HostedApiError extends Error {
|
|
29
49
|
readonly status: number;
|
|
30
50
|
readonly code: string;
|
|
31
51
|
readonly retryAfterSeconds?: number;
|
|
52
|
+
readonly details?: HostedErrorDetails;
|
|
32
53
|
constructor(args: {
|
|
33
54
|
status: number;
|
|
34
55
|
code: string;
|
|
35
56
|
message: string;
|
|
36
57
|
retryAfterSeconds?: number;
|
|
58
|
+
details?: HostedErrorDetails | undefined;
|
|
37
59
|
});
|
|
38
60
|
}
|
|
39
61
|
|
|
@@ -46,4 +68,4 @@ declare function icaoPolicyOf(view: Pick<HostedSessionView, "portrait"> | null |
|
|
|
46
68
|
*/
|
|
47
69
|
declare function portraitIcaoGate(summary: IcaoGateSummary): NonNullable<PortraitIcaoInput["gate"]>;
|
|
48
70
|
|
|
49
|
-
export { HostedApiError, HostedIcaoPolicy, HostedSessionView, KNOWN_CODES, type KnownCode, PortraitIcaoInput, icaoPolicyOf, isKnownCode, portraitIcaoGate };
|
|
71
|
+
export { HostedApiError, type HostedErrorDetails, type HostedErrorIssue, HostedIcaoPolicy, HostedSessionView, KNOWN_CODES, type KnownCode, PortraitIcaoInput, icaoPolicyOf, isKnownCode, portraitIcaoGate };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AcceptedDocumentType,
|
|
1
|
+
import { z as HostedSessionView, r as HostedIcaoPolicy, O as IcaoGateSummary, a9 as PortraitIcaoInput } from '../icao-gate-DKbWXP51.js';
|
|
2
|
+
export { A as AcceptedDocumentType, aU as AttestationInput, aV as CaptureContext, aW as CaptureNoncesResult, aX as CaptureProof, aY as CheckInputByType, C as CheckReason, a as CheckState, b as CheckType, aZ as CompleteMediaResult, a_ as ConsentLocale, c as ContactChannel, D as DecisionReason, a$ as DocDeviceRead, b0 as DocOcrInput, d as DocReason, b1 as DocSide, E as EidAfterPass, e as EidAuthInput, f as EidReason, b2 as EmailOtpInput, g as EmailOtpReason, b3 as FaceMatchInput, F as FaceMatchReason, h as HostedAcceptedDocuments, k as HostedCaptureTuning, aT as HostedClient, b4 as HostedClientOptions, l as HostedConsentView, m as HostedDocumentCaptureTuning, n as HostedDocumentScanTuning, o as HostedEidView, p as HostedEmailOtpView, q as HostedFlowRef, s as HostedIntegrity, t as HostedLivePhotoTuning, u as HostedNativeCaptureTuning, v as HostedOcrTuning, w as HostedOtpView, x as HostedPlanView, y as HostedPortraitView, B as HostedStepView, G as HostedVoiceLocale, I as HostedVoiceView, L as IcaoCriterion, Q as IcaoReportEntry, R as IdentityConfirmDecision, S as IdentityMethod, T as IdentitySummarySource, U as IdentitySummaryView, b5 as LivenessCaptureInput, b6 as LivenessInput, V as LivenessReason, W as MatchReason, b7 as MediaCheckType, b8 as MediaKind, X as MethodChoiceView, Y as NationalEidOption, Z as NfcChipReason, _ as NfcStepView, $ as OtpChoiceView, b9 as PhoneOtpInput, a0 as PhoneOtpReason, a1 as PlanAttempts, a2 as PlanChoiceKind, a3 as PlanChoiceOption, a4 as PlanChoiceView, a5 as PlanSectionView, a6 as PlanStepView, a7 as PolicyFailureReason, ba as PopulationInput, a8 as PopulationReason, aa as PortraitIcaoReason, bb as PresignRequest, bc as PresignUploadResult, bd as RecordConsentResult, ab as SessionFailureReason, ac as SessionOutcome, ad as SessionStatus, be as SessionStepView, bf as SessionView, ae as StepSection, bg as SubmitCheckBody, bh as SubmitOptions, bi as UploadMedia, bj as stripMimeParams } from '../icao-gate-DKbWXP51.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Every error code the hosted page can receive from the session-token surface.
|
|
6
6
|
* A closed string-literal union — switch over {@link KnownCode} with a `never`
|
|
7
7
|
* default arm for compile-checked exhaustiveness.
|
|
8
8
|
*/
|
|
9
|
-
declare const KNOWN_CODES: readonly ["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", "platform_unregistered", "app_attest_invalid", "too_many_challenges", "inference_unavailable", "mobile_required", "nni_locked", "
|
|
9
|
+
declare const KNOWN_CODES: readonly ["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", "platform_unregistered", "app_attest_invalid", "too_many_challenges", "inference_unavailable", "mobile_required", "nni_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", "nfc_outcome_not_accepted", "identity_confirm_required", "identity_confirm_locked", "choice_not_found", "choice_locked", "choice_option_unavailable", "step_not_on_path", "check_not_active"];
|
|
10
10
|
/** Closed union of {@link KNOWN_CODES} — exhaustively switchable. */
|
|
11
11
|
type KnownCode = (typeof KNOWN_CODES)[number];
|
|
12
12
|
/** Narrow an arbitrary wire code to the known union (unknown codes stay `string`). */
|
|
13
13
|
declare function isKnownCode(code: string): code is KnownCode;
|
|
14
|
+
/** One machine-readable problem of an error's `details` (Sekyro flows spec §9.4). */
|
|
15
|
+
interface HostedErrorIssue {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
/** The request field (`option`, `nodeId`, …). */
|
|
19
|
+
path?: string;
|
|
20
|
+
/** A node of the flow. */
|
|
21
|
+
nodeId?: string;
|
|
22
|
+
service?: string;
|
|
23
|
+
field?: string;
|
|
24
|
+
}
|
|
25
|
+
/** `details` of a flow error envelope (`choice_*`, `step_not_on_path`, …): the issues, and more per code. */
|
|
26
|
+
interface HostedErrorDetails {
|
|
27
|
+
issues: HostedErrorIssue[];
|
|
28
|
+
/** `override_widens_flow`: the widened fields. */
|
|
29
|
+
fields?: string[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
14
32
|
/**
|
|
15
33
|
* Typed transport error: EVERY failure surfaces as one of these — non-2xx
|
|
16
34
|
* responses, rejected fetches, timeouts, and unparseable bodies alike. The
|
|
@@ -24,16 +42,20 @@ declare function isKnownCode(code: string): code is KnownCode;
|
|
|
24
42
|
* ('network_error' / 'timeout').
|
|
25
43
|
* - `retryAfterSeconds` — parsed from the `Retry-After` header when present
|
|
26
44
|
* (rate-limit 429s always set it).
|
|
45
|
+
* - `details` — the envelope's machine-readable `details` when present (flow
|
|
46
|
+
* errors: `issues[]`).
|
|
27
47
|
*/
|
|
28
48
|
declare class HostedApiError extends Error {
|
|
29
49
|
readonly status: number;
|
|
30
50
|
readonly code: string;
|
|
31
51
|
readonly retryAfterSeconds?: number;
|
|
52
|
+
readonly details?: HostedErrorDetails;
|
|
32
53
|
constructor(args: {
|
|
33
54
|
status: number;
|
|
34
55
|
code: string;
|
|
35
56
|
message: string;
|
|
36
57
|
retryAfterSeconds?: number;
|
|
58
|
+
details?: HostedErrorDetails | undefined;
|
|
37
59
|
});
|
|
38
60
|
}
|
|
39
61
|
|
|
@@ -46,4 +68,4 @@ declare function icaoPolicyOf(view: Pick<HostedSessionView, "portrait"> | null |
|
|
|
46
68
|
*/
|
|
47
69
|
declare function portraitIcaoGate(summary: IcaoGateSummary): NonNullable<PortraitIcaoInput["gate"]>;
|
|
48
70
|
|
|
49
|
-
export { HostedApiError, HostedIcaoPolicy, HostedSessionView, KNOWN_CODES, type KnownCode, PortraitIcaoInput, icaoPolicyOf, isKnownCode, portraitIcaoGate };
|
|
71
|
+
export { HostedApiError, type HostedErrorDetails, type HostedErrorIssue, HostedIcaoPolicy, HostedSessionView, KNOWN_CODES, type KnownCode, PortraitIcaoInput, icaoPolicyOf, isKnownCode, portraitIcaoGate };
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t,c as o,d as i,e as n,f as s,g as a}from"../chunk-
|
|
1
|
+
import{a as e,b as t,c as o,d as i,e as n,f as s,g as a}from"../chunk-F5ST423J.js";import"../chunk-LUHNRNTO.js";export{o as HostedApiError,n as HostedClient,e as KNOWN_CODES,s as icaoPolicyOf,t as isKnownCode,a as portraitIcaoGate,i as stripMimeParams};
|