@sekyro/web 0.1.0-rc.7 → 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 +102 -0
- package/LICENSE +25 -16
- package/README.md +54 -63
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/capture-session-doc-QQHDBZG4.js +1 -0
- package/dist/{capture-session-v3-Okq0EQHG.d.ts → capture-session-v3-CQK-G-qX.d.ts} +72 -3
- package/dist/{capture-session-v3-UQU_WjO2.d.cts → capture-session-v3-Dvob-uH2.d.cts} +72 -3
- package/dist/chunk-4Q7EMVP7.js +1 -0
- package/dist/chunk-56GT33O3.js +1 -0
- package/dist/chunk-7V2M6Y2W.js +1 -0
- package/dist/chunk-7ZCZY3ZP.js +1 -0
- package/dist/chunk-A3FUGHAH.js +2 -0
- package/dist/chunk-BPE5NSQ2.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-EVVGQSNJ.js +1 -0
- package/dist/chunk-F5ST423J.js +1 -0
- package/dist/chunk-FHJ7HO3M.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GBTZIKGZ.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-H6HC7B77.js +1 -0
- package/dist/{chunk-IYUOYINS.js → chunk-LUHNRNTO.js} +1 -1
- package/dist/chunk-M43ET4NJ.js +1 -0
- package/dist/chunk-MXWLCDFX.js +1 -0
- package/dist/chunk-O5WKNZ2C.js +1 -0
- package/dist/chunk-OKWG3PVH.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-TDLIXFDT.js +1 -0
- package/dist/chunk-WRKUWIJW.js +1 -0
- package/dist/chunk-ZUHTYCY4.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +35 -3
- package/dist/client/index.d.ts +35 -3
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- package/dist/core/ocr/worker.bundle.js +42 -0
- package/dist/core/ocr/worker.cjs +42 -0
- package/dist/core/ocr/worker.d.cts +84 -0
- package/dist/core/ocr/worker.d.ts +84 -0
- package/dist/core/ocr/worker.js +41 -0
- package/dist/core/v3/detect-worker.cjs +1 -1
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -1
- package/dist/create-document-capture-DWRNFXA2.js +1 -0
- package/dist/create-portrait-capture-B57GE5FU.js +1 -0
- package/dist/create-verification-BS2qbe75.d.cts +2872 -0
- package/dist/create-verification-CCR-CwVQ.d.ts +2872 -0
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
- package/dist/detector-scanic-YCDNLCGV.js +1 -0
- package/dist/icao-gate-DKbWXP51.d.cts +1720 -0
- package/dist/icao-gate-DKbWXP51.d.ts +1720 -0
- package/dist/icao-gate-PWBMKRGC.js +1 -0
- package/dist/icao-tuning-4GGVX6B4.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +349 -321
- package/dist/internal/index.d.ts +349 -321
- package/dist/internal/index.js +1 -1
- package/dist/keyframe-rank-YAJLYJYF.js +1 -0
- package/dist/landmarker-KB7LVXAU.js +1 -0
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/plan-runner-X4YW3INX.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/turnstile-FATNZ4AG.js +1 -0
- package/package.json +22 -4
- package/sbom.cdx.json +8 -8
- package/dist/chunk-B45J4KC3.js +0 -1
- package/dist/chunk-BMA36W2W.js +0 -1
- package/dist/chunk-P7ECRN47.js +0 -1
- package/dist/chunk-YOB4ZTYN.js +0 -1
- package/dist/chunk-YQBK6OIM.js +0 -1
- package/dist/create-verification-C2JhOO6Y.d.cts +0 -533
- package/dist/create-verification-CGazwtAh.d.ts +0 -533
- package/dist/detector-scanic-VQFFXKTL.js +0 -1
- package/dist/hosted-client-kBeq-mnJ.d.cts +0 -602
- package/dist/hosted-client-kBeq-mnJ.d.ts +0 -602
|
@@ -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
|
+
var K={enabled:!0,hz:3,segmenterTimeoutMs:8e3,segmenterBudgetMs:120,maskThreshold:.5,maxColorStd:28,maxEdgeDensity:.08,edgeLuma:24,maxGradient:.18,minPixels:300,timeoutMs:4e3},V=12e3,b=(n,o,t)=>Math.min(t,Math.max(o,Math.round(n)));function W(n,o,t){let{x:r,y:m,width:a,height:u}=n;if(t)return[{x:r-1.5*a,y:m-.8*u,width:4*a,height:2.8*u}];let d=m-.4*u,p=1.4*u;return[{x:r-.9*a,y:d,width:.75*a,height:p},{x:r+1.15*a,y:d,width:.75*a,height:p}].map(h=>{let M=Math.max(0,h.x),l=Math.min(o.width,h.x+h.width);return{x:M,y:h.y,width:Math.max(0,l-M),height:h.height}})}function Z(n,o,t,r=K){let m=t!==null&&t.width>0&&t.height>0,a=W(o,n,m),u=a.reduce((e,s)=>e+Math.max(0,s.width)*Math.max(0,s.height),0);if(u<=0)return null;let d=Math.max(1,Math.floor(Math.sqrt(u/V))),p=m?t.data instanceof Float32Array?1:1/255:1,h=(e,s)=>{if(!m)return!1;let w=b(e/n.width*t.width-.5,0,t.width-1),C=b(s/n.height*t.height-.5,0,t.height-1);return t.data[C*t.width+w]*p>=r.maskThreshold},M=e=>.299*n.data[e]+.587*n.data[e+1]+.114*n.data[e+2],l=0,B=[0,0,0],S=[0,0,0],k=0,T=0,D=0,_=0,P=0,A=0,E=0,L=0,F=0,G=0,O=Math.min(...a.map(e=>e.x)),j=Math.max(...a.map(e=>e.x+e.width)),H=Math.min(...a.map(e=>e.y)),I=Math.max(...a.map(e=>e.y+e.height)),J=(O+j)/2,Q=(H+I)/2;for(let e of a){let s=b(e.x,0,n.width),w=b(e.x+e.width,0,n.width),C=b(e.y,0,n.height),q=b(e.y+e.height,0,n.height);for(let c=C;c<q;c+=d)for(let g=s;g<w;g+=d){if(h(g,c))continue;let Y=(c*n.width+g)*4;for(let i=0;i<3;i+=1){let x=n.data[Y+i];B[i]=B[i]+x,S[i]=S[i]+x*x}l+=1;let y=M(Y);g<J?(D+=y,_+=1):(P+=y,A+=1),c<Q?(E+=y,L+=1):(F+=y,G+=1);for(let[i,x]of[[g+d,c],[g,c+d]])i>=w||x>=q||h(i,x)||(k+=1,Math.abs(M((x*n.width+i)*4)-y)>r.edgeLuma&&(T+=1))}}if(l<r.minPixels)return null;let U=0;for(let e=0;e<3;e+=1){let s=B[e]/l;U+=Math.max(0,S[e]/l-s*s)}let N=Math.sqrt(U/3),z=k===0?0:T/k,f=(e,s)=>s===0?null:e/s,R=(e,s)=>e===null||s===null?0:Math.abs(e-s)/255,X=Math.max(R(f(D,_),f(P,A)),R(f(E,L),f(F,G)));return{method:m?"segmenter":"strip",uniform:N<=r.maxColorStd&&z<=r.maxEdgeDensity&&X<=r.maxGradient,colorStd:Math.round(N*10)/10,edgeDensity:Math.round(z*1e3)/1e3,gradient:Math.round(X*1e3)/1e3,pixels:l}}function $(n){let o=n!==null&&typeof n=="object"?n:{},t=K,r=(m,a,u,d)=>typeof m=="number"&&Number.isFinite(m)&&m>=u&&m<=d?m:a;return{enabled:typeof o.enabled=="boolean"?o.enabled:t.enabled,hz:r(o.hz,t.hz,.5,15),segmenterTimeoutMs:r(o.segmenterTimeoutMs,t.segmenterTimeoutMs,0,6e4),segmenterBudgetMs:r(o.segmenterBudgetMs,t.segmenterBudgetMs,1,2e3),maskThreshold:r(o.maskThreshold,t.maskThreshold,0,1),maxColorStd:r(o.maxColorStd,t.maxColorStd,0,255),maxEdgeDensity:r(o.maxEdgeDensity,t.maxEdgeDensity,0,1),edgeLuma:r(o.edgeLuma,t.edgeLuma,0,255),maxGradient:r(o.maxGradient,t.maxGradient,0,1),minPixels:r(o.minPixels,t.minPixels,1,1e6),timeoutMs:r(o.timeoutMs,t.timeoutMs,0,6e4)}}export{K as a,Z as b,$ as c};
|
|
@@ -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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as te,d as ne}from"./chunk-CJHMFPL6.js";import{a as re}from"./chunk-RI3E7GBN.js";import{a as I,e as Q,g as $,m as Z}from"./chunk-7ZCZY3ZP.js";import{b as ee}from"./chunk-BPE5NSQ2.js";import{a as X,b as J}from"./chunk-7V2M6Y2W.js";import{d as z}from"./chunk-FHJ7HO3M.js";var le=250,me=180,de=96;function ae(n){let{data:t,width:e,height:r}=n,a=new Uint8Array(e*r);for(let o=0,u=0;o<a.length;o+=1,u+=4)a[o]=Math.round(.299*(t[u]??0)+.587*(t[u+1]??0)+.114*(t[u+2]??0));return{data:a,width:e,height:r}}function H(n,t){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(t.width,Math.ceil(n.x+n.width)),y1:Math.min(t.height,Math.ceil(n.y+n.height))}}function T(n,t,e){let r=H(t,n),a=e===void 0?null:H(e,n),o=0,u=0,s=0,m=0;for(let c=r.y0;c<r.y1;c+=1)for(let p=r.x0;p<r.x1;p+=1){if(a!==null&&p>=a.x0&&p<a.x1&&c>=a.y0&&c<a.y1)continue;let v=n.data[c*n.width+p];o+=1,u+=v,s+=v*v,v>=le&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let l=u/o;return{mean:l,sd:Math.sqrt(Math.max(0,s/o-l*l)),clipped:m/o,count:o}}function oe(n){let{box:t}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:r,width:.7*t.width,height:Math.max(1,a-r)}}function he(n,t){let e=oe(t),r=T(n,e);if(r.count===0)return null;let a=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),o=T(n,{x:e.x,y:e.y,width:a-e.x,height:e.height}),u=T(n,{x:a,y:e.y,width:e.x+e.width-a,height:e.height}),s=u.mean>0?o.mean/u.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:s,clipped:r.clipped}}function fe(n,t){let e=0,r=0;for(let a of[t.leftEyeBox,t.rightEyeBox]){let o=a.width*.15,u=a.height*.5,s=T(n,{x:a.x-o,y:a.y-u,width:a.width+2*o,height:a.height+2*u});e+=s.count,r+=s.clipped*s.count}return e===0?null:r/e}function ge(n,t){let e=Q(t),{box:r}=t,a={x:r.x-.2*r.width,y:e.y,width:1.4*r.width,height:r.y+r.height-e.y},o=0,u=0,s=0;for(let l of[e.x,e.x+.8*e.width]){let c=T(n,{x:l,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},a);o+=c.count,u+=c.mean*c.count,s+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let m=u/o;return{luma:m,sd:Math.sqrt(Math.max(0,s/o-m*m)),count:o}}function pe(n,t){let e=H(oe(t),n),r=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/de)),a=(l,c)=>n.data[c*n.width+l],o=0,u=0,s=0;for(let l=e.y0+r;l<e.y1-r;l+=r)for(let c=e.x0+r;c<e.x1-r;c+=r){let p=a(c,l-r)+a(c-r,l)+a(c+r,l)+a(c,l+r)-4*a(c,l);o+=1,u+=p,s+=p*p}if(o===0)return null;let m=u/o;return Math.min(1,Math.max(0,s/o-m*m)/me)}function ie(n,t){return{lighting:he(n,t),eyeSpecular:fe(n,t),background:ge(n,t),sharpness:pe(n,t)}}var ye="/models-v3",xe=640,be=1600,we=.92;function _(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function D(n,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=n,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,t):null}function ve(){let n=null;return(t,e)=>{let{width:r,height:a}=_(t);if(r===0||a===0)return null;let o=e===null?1:Math.min(1,e/Math.max(r,a)),u=Math.round(r*o),s=Math.round(a*o),m;e===null?m=D(u,s):((n===null||n.width!==u||n.height!==s)&&(n=D(u,s)),m=n);let l=m?.getContext("2d",{willReadFrequently:!0});if(m==null||l==null)return null;l.drawImage(t,0,0,u,s);let c=null;try{c=l.getImageData(0,0,u,s)}catch{c=null}return{source:m,width:u,height:s,pixels:c}}}async function Ce(n,t,e,r){let a=Math.round(e*t.width/t.height),o=D(a,e),u=o?.getContext("2d");if(o==null||u==null)throw new Error("canvas unavailable");return u.fillStyle="#fff",u.fillRect(0,0,a,e),u.drawImage(n.source,t.x,t.y,t.width,t.height,0,0,a,e),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((s,m)=>{o.toBlob(l=>l===null?m(new Error("encode failed")):s(l),"image/jpeg",r)})}var V=class extends Error{};function ke(n,t,e){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new V(`init exceeded ${t}ms`)),n.then(e,()=>{})},t);n.then(u=>{clearTimeout(o),r(u)},u=>{clearTimeout(o),a(u)})})}function Le(n){let t=z(n),e=t==="overconstrained"?"generic":t;return{kind:e,retryable:e!=="insecure"&&e!=="unsupported"}}function Pe(n,t,e,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:I(a.landmarks,e,r),u=null;if(a!==void 0&&t.pixels!==null){let s=I(a.landmarks,t.width,t.height),m=ae(t.pixels);s!==null&&(u=ie(m,s))}return{frameWidth:e,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:u}}function He(n,t={}){let e=ee(n.tuning,n.tuningVersion),r=X(),a=t.now??(()=>performance.now()),o=t.setTimer??((i,d)=>setTimeout(i,d)),u=t.clearTimer??(i=>clearTimeout(i)),s=t.grabFrame??ve(),m=t.encodeRegion??Ce,l=t.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),c=t.createLandmarker??ne,p=n.assetBaseUrl??ye,v=J({enabled:n.keepScreenAwake!==!1}),k=Z(e,{policy:n.policy??"reject"}),x=n.video,q=re({tuning:e.backgroundCheck,assetBaseUrl:p,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:a}),h="idle",b=null,y=null,E=null,R=!1,f=!1,g=0,N=0,G=[],L=i=>{h===i||f||(h=i,v.setActive(i==="starting"||i==="gating"),r.emit("state",i))},B=()=>{E!==null&&u(E),E=null},W=()=>{B();for(let i of b?.getTracks()??[])i.stop();b=null;try{x.srcObject=null}catch{}},A=i=>{W(),L("error"),r.emit("error",i)},Y=()=>{let i=Math.max(a(),N+1);return N=i,i},ue=async i=>{let d=s(x,null),{width:w,height:P}=d??_(x);if(d===null||y===null){k.reset();return}let M=y.detect(d.source,Y()),C=(M.length===1?M:G.length===1?G:[])[0],S=C===void 0?null:I(C.landmarks,w,P);if(S===null){k.reset();return}let F=$(S,w,P,{margin:e.cropMargin,minWidth:e.resolution.minWidth,minHeight:e.resolution.minHeight}),O=Math.max(e.resolution.minHeight,Math.min(F.height,be)),se=await m(d,F,O,we);if(f||i!==g)return;let K={image:se,width:Math.round(O*F.width/F.height),height:O,gate:k.summary()};e.tuningVersion!==null&&(K.tuningVersion=e.tuningVersion),B(),L("captured"),r.emit("captured",K)},U=async i=>{if(!(f||i!==g||h!=="gating"||y===null)){if(!R){R=!0;try{let d=s(x,xe);if(d!==null){let{width:w,height:P}=_(x),M=y.detect(d.source,Y());G=M;let C=Pe(M,d,w||d.width,P||d.height);C.geometry!==null&&e.background.required&&(C.backgroundCheck=q.measure(d,C.geometry.box,w||d.width,P||d.height));let S=k.push(C,a());if(f||i!==g||(r.emit("gate",S),S.ready&&(await ue(i),h!=="gating")))return}}catch{}finally{R=!1}}!f&&i===g&&h==="gating"&&(E=o(()=>{U(i)},1e3/e.cadenceHz))}},ce=()=>ke(c(p),2e4,i=>i.close()),j=async()=>{if(f||h==="starting"||h==="gating")return;g+=1;let i=g;if(k.reset(),L("starting"),b===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){A({kind:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported",retryable:!1});return}let d=y!==null?Promise.resolve(y):ce();d.catch(()=>{});try{if(b===null){if(b=await l({video:{facingMode:"user",width:{ideal:e.camera.width},height:{ideal:e.camera.height}},audio:!1}),f||i!==g){for(let w of b.getTracks())w.stop();f&&(b=null);return}x.srcObject=b,x.muted=!0,x.playsInline=!0,await x.play().catch(()=>{})}}catch(w){!f&&i===g&&A(Le(w));return}try{y=await d}catch{!f&&i===g&&A({kind:"generic",retryable:!0});return}f||i!==g||(L("gating"),U(i))};return{handle:{get state(){return h},on:(i,d)=>r.on(i,d),start:j,retry:()=>{if(!f){if(b!==null&&y!==null&&h!=="error"){g+=1;let i=g;B(),k.reset(),L("gating"),U(i);return}h="idle",j()}},destroy:()=>{f||(g+=1,W(),v.setActive(!1),f=!0,y?.close(),y=null,q.close(),r.clear())}},setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&L(i)}}}function _e(){import("@mediapipe/tasks-vision").catch(()=>{})}export{le as a,me as b,ae as c,T as d,he as e,fe as f,ge as g,pe as h,ie as i,xe as j,be as k,we as l,ve as m,Pe as n,He as o,_e as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as x}from"./chunk-TDLIXFDT.js";import{b}from"./chunk-FPXL63KZ.js";var T=480,y=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),p=e=>Math.min(1,Math.max(0,e));function E(e,o,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let s=0;s<4;s++){let r=n[s],c=n[(s+1)%4];i+=r.x*c.y-c.x*r.y}let a=o*t;return a>0?Math.abs(i/2)/a:0}function I(e,o){let t=D(e),n=D(o),i=Math.max(t.x1,n.x1),a=Math.max(t.y1,n.y1),s=Math.min(t.x2,n.x2),r=Math.min(t.y2,n.y2),c=Math.max(0,s-i)*Math.max(0,r-a),u=(t.x2-t.x1)*(t.y2-t.y1),_=(n.x2-n.x1)*(n.y2-n.y1),m=u+_-c;return m>0?c/m:0}function R(e){let o=D(e);return{width:o.x2-o.x1,height:o.y2-o.y1}}function D(e){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];return{x1:Math.min(...o.map(t=>t.x)),y1:Math.min(...o.map(t=>t.y)),x2:Math.max(...o.map(t=>t.x)),y2:Math.max(...o.map(t=>t.y))}}function M(e){let o=Math.hypot(e.topRight.x-e.topLeft.x,e.topRight.y-e.topLeft.y),t=Math.hypot(e.bottomRight.x-e.bottomLeft.x,e.bottomRight.y-e.bottomLeft.y),n=Math.hypot(e.bottomLeft.x-e.topLeft.x,e.bottomLeft.y-e.topLeft.y),i=Math.hypot(e.bottomRight.x-e.topRight.x,e.bottomRight.y-e.topRight.y),a=(o+t)/2,s=(n+i)/2;return a<=0||s<=0?0:Math.max(a,s)/Math.min(a,s)}var d=class{constructor(o,t={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...y,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:t,quality:n,timestampMs:i}=o,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s=null;if(t===null)s="dcv1.no_doc";else if(this.format==="ID-3"){let h=R(t),f=h.height>0?h.width/h.height:0;h.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":(f<this.t.ID3_BAND_ASPECT_MIN||f>this.t.ID3_BAND_ASPECT_MAX)&&(s="dcv1.wrong_shape")}else E(t,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":x(this.format,M(t))||(s="dcv1.wrong_shape");let r=s===null,c=p(n.exposure)>=this.t.GUIDE_EXPOSURE,u=p(n.sharpness)>=this.t.GUIDE_SHARPNESS,_=c&&u;if(r&&_&&t!==null){let h=this.lastQuad===null||I(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=h?this.streak+1:1}else this.streak=0;this.lastQuad=t;let m=r&&_;this.p=p(this.p+(m?this.t.RISE_PER_S:-this.t.FALL_PER_S)*a);let A=m&&this.streak>=this.t.STABLE_TICKS,l;if(s!==null)l=s;else if(c)u?l="dcv1.hold_still":l="dcv1.steady";else{let h=(b[0]+b[1])/2;l=n.meanLuma<h?"dcv1.more_light":"dcv1.too_bright"}return{at:i,quad:t,plausible:r,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,t,n){let i=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(s=>s.x<=i||s.y<=i||s.x>=t-i||s.y>=n-i)}};export{T as a,y as b,E as c,I as d,R as e,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="https://challenges.cloudflare.com/turnstile/v0/api.js",g=3e4;function p(){return window.turnstile}var o=null;function w(){o=null}function E(){return o??(o=new Promise((s,t)=>{let r=p();if(r){s(r);return}let e=document.createElement("script");e.src=f,e.async=!0,e.onload=()=>{let n=p();n?s(n):(o=null,t(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{o=null,e.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),o}function d(){return new Error("Turnstile challenge aborted")}async function x(s,t={}){let r=t.timeoutMs??3e4,e=t.signal;if(e?.aborted)throw d();let n=await E();if(e?.aborted)throw d();let a=document.createElement("div");document.body.appendChild(a);let i,c,u;try{return await new Promise((m,l)=>{if(c=setTimeout(()=>l(new Error(`Turnstile challenge timed out (${r} ms)`)),r),e!==void 0&&(u=()=>l(d()),e.addEventListener("abort",u,{once:!0})),i=n.render(a,{sitekey:s,execution:"execute",appearance:"execute",callback:m,"error-callback":T=>{l(new Error(`Turnstile challenge failed${T?` (${T})`:""}`))}}),i===void 0){l(new Error("Turnstile render returned no widget id"));return}n.execute(i)})}finally{if(clearTimeout(c),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),i!==void 0)try{n.remove(i)}catch{}a.remove()}}export{f as a,g as b,w as c,E as d,x as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=1e4,u=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=g(e),s=w(r.keypoints,a),c=r.keypoints?.[2],b={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*a.width,y:c.y*a.height}}:{},score:r.categories[0]?.score??0};return l(b,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function x(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=g(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function k(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await x();if(n.ok)return new m(n.instance,h(i));i.push(`native:${n.reason}`);continue}try{return await S(u.create(t.v3AssetBaseUrl??F,h(i)),t.blazeInitTimeoutMs??v)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new y(h(i)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var d=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??k,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==d){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:d,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:d,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var D=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==d||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=b=>{let p=b.data;p.v!==d||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:d,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:d,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,y as c,g as d,l as e,k as f,d as g,A as h,M as i,D as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),u=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function o(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(u)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function l(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var n=["LOW","MID","HIGH"],i=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return a[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let s=this.samples.reduce((r,c)=>r+c,0)/this.samples.length;if(s>70)this.current="LOW";else if(s<25){let r=n.indexOf(this.current);this.current=n[Math.min(n.length-1,r+1)]??this.current}return this.current}};export{a,o as b,l as c,i as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as M}from"./chunk-GI3UFGRQ.js";var A=2;function L(u){let l=u.tuning,s=u.now??(()=>performance.now()),t=null,o=!1,g=!1,d=Number.NEGATIVE_INFINITY,a=null,h=0,i=null,n=null,f=0,p=!1,T=()=>{if(p||!l.enabled)return;p=!0;let r=(u.createSegmenter??(e=>import("./segmenter-USLNBX65.js").then(m=>m.createSelfieSegmenter(e))))(u.assetBaseUrl);n=setTimeout(()=>{t===null&&(o=!0)},l.segmenterTimeoutMs),r.then(e=>{n!==null&&clearTimeout(n),g||o?e.close():t=e},()=>{n!==null&&clearTimeout(n),o=!0})};return{measure(r,e,m,S){if(!l.enabled||r.pixels===null)return null;T();let c=s();if(c-d<1e3/l.hz)return a;d=c;let k=r.width/Math.max(1,m),y=r.height/Math.max(1,S),w={x:e.x*k,y:e.y*y,width:e.width*k,height:e.height*y},B=null;if(t!==null&&!o){let x=Math.max(c,h+1);h=x;let U=s();B=t.segment(r.source,x);let b=s()-U;f+=1,f>A&&(i=i===null?b:i*.7+b*.3),i!==null&&i>l.segmenterBudgetMs&&(o=!0,t.close(),t=null)}return a=M(r.pixels,w,B,l),a},close(){g=!0,n!==null&&clearTimeout(n),t?.close(),t=null}}}export{L as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),I=12;function F(H,D={}){let r={...p,...D},{data:s,width:n,height:t}=H;if(n<32||t<32)return null;let c=new Array(t).fill(!1),R=new Float32Array(t),u=new Int32Array(t).fill(n),a=new Int32Array(t).fill(-1),w=n/I,d=new Array(I);for(let e=0;e<t;e++){let M=0;d.fill(!1);let E=e*n*4,G=.299*(s[E]??0)+.587*(s[E+1]??0)+.114*(s[E+2]??0);for(let o=1;o<n;o++){let T=E+o*4,y=.299*(s[T]??0)+.587*(s[T+1]??0)+.114*(s[T+2]??0);Math.abs(y-G)>=r.EDGE_LUMA_DELTA&&(M+=1,d[Math.min(I-1,Math.floor(o/w))]=!0,o<u[e]&&(u[e]=o),o>a[e]&&(a[e]=o)),G=y}R[e]=M/n;let O=d.filter(Boolean).length/I;c[e]=R[e]>=r.MIN_ROW_DENSITY&&O>=r.MIN_COLUMN_COVERAGE&&a[e]-u[e]>=r.MIN_WIDTH_FRAC*n}let _=null,l=-1,f=-1,i=0,N=e=>{if(l<0)return;let M=e-l+1;M>=r.MIN_HEIGHT_FRAC*t&&M<=r.MAX_HEIGHT_FRAC*t&&i>=4&&(_===null||i>_.rows)&&(_={top:l,bottom:e,rows:i}),l=-1,i=0};for(let e=0;e<t;e++)c[e]&&(l<0?l=e:e-f>r.ROW_MERGE_GAP&&(N(f),l=e),f=e,i+=1);if(N(f),_===null)return null;let b=_,m=n,A=-1,C=0,h=0;for(let e=b.top;e<=b.bottom;e++)c[e]&&(u[e]<m&&(m=u[e]),a[e]>A&&(A=a[e]),C+=R[e],h+=1);return A-m<r.MIN_WIDTH_FRAC*n?null:{x:m,y:b.top,width:A-m,height:b.bottom-b.top+1,density:h>0?C/h:0}}export{p as a,F as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={"ID-1":{center:1.586,tolerance:.15},"ID-2":{center:1.419,tolerance:.12},"ID-3":{center:1.42,tolerance:.2}},c={"ID-1":["ID-1"],"ID-2":["ID-2"],"ID-3":["ID-3"],card:["ID-1","ID-2"]};function i(e){return o[e==="card"?"ID-1":e]}function d(e,r){return c[e].some(t=>Math.abs(r-o[t].center)<=o[t].tolerance)}var a=[{docType:"carte_identite",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"},{docType:"passport",format:"ID-3",sides:["single"],mrz:"td3",portraitSide:"single",aspectRatio:1.42,identifierSource:"mrz"}],n=[...a,{docType:"residence_permit",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"}];function s(e){let r=n.find(t=>t.docType===e);return r===void 0||r.format==="ID-1"?"card":r.format}export{o as a,i as b,d as c,a as d,n as e,s as f};
|
|
@@ -0,0 +1 @@
|
|
|
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,15 +1,34 @@
|
|
|
1
|
-
|
|
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';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Every error code the hosted page can receive from the session-token surface.
|
|
5
6
|
* A closed string-literal union — switch over {@link KnownCode} with a `never`
|
|
6
7
|
* default arm for compile-checked exhaustiveness.
|
|
7
8
|
*/
|
|
8
|
-
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", "
|
|
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"];
|
|
9
10
|
/** Closed union of {@link KNOWN_CODES} — exhaustively switchable. */
|
|
10
11
|
type KnownCode = (typeof KNOWN_CODES)[number];
|
|
11
12
|
/** Narrow an arbitrary wire code to the known union (unknown codes stay `string`). */
|
|
12
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
|
+
}
|
|
13
32
|
/**
|
|
14
33
|
* Typed transport error: EVERY failure surfaces as one of these — non-2xx
|
|
15
34
|
* responses, rejected fetches, timeouts, and unparseable bodies alike. The
|
|
@@ -23,17 +42,30 @@ declare function isKnownCode(code: string): code is KnownCode;
|
|
|
23
42
|
* ('network_error' / 'timeout').
|
|
24
43
|
* - `retryAfterSeconds` — parsed from the `Retry-After` header when present
|
|
25
44
|
* (rate-limit 429s always set it).
|
|
45
|
+
* - `details` — the envelope's machine-readable `details` when present (flow
|
|
46
|
+
* errors: `issues[]`).
|
|
26
47
|
*/
|
|
27
48
|
declare class HostedApiError extends Error {
|
|
28
49
|
readonly status: number;
|
|
29
50
|
readonly code: string;
|
|
30
51
|
readonly retryAfterSeconds?: number;
|
|
52
|
+
readonly details?: HostedErrorDetails;
|
|
31
53
|
constructor(args: {
|
|
32
54
|
status: number;
|
|
33
55
|
code: string;
|
|
34
56
|
message: string;
|
|
35
57
|
retryAfterSeconds?: number;
|
|
58
|
+
details?: HostedErrorDetails | undefined;
|
|
36
59
|
});
|
|
37
60
|
}
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
/** The session's ICAO policy and profile, or `null` when the selfie is not ICAO-checked. */
|
|
63
|
+
declare function icaoPolicyOf(view: Pick<HostedSessionView, "portrait"> | null | undefined): HostedIcaoPolicy | null;
|
|
64
|
+
/**
|
|
65
|
+
* The `gate` block of a `portrait_icao` body from the gate's summary: the eye
|
|
66
|
+
* baseline, the device verdict under the server's criterion names, and the
|
|
67
|
+
* background-uniformity numbers (telemetry).
|
|
68
|
+
*/
|
|
69
|
+
declare function portraitIcaoGate(summary: IcaoGateSummary): NonNullable<PortraitIcaoInput["gate"]>;
|
|
70
|
+
|
|
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,15 +1,34 @@
|
|
|
1
|
-
|
|
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';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Every error code the hosted page can receive from the session-token surface.
|
|
5
6
|
* A closed string-literal union — switch over {@link KnownCode} with a `never`
|
|
6
7
|
* default arm for compile-checked exhaustiveness.
|
|
7
8
|
*/
|
|
8
|
-
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", "
|
|
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"];
|
|
9
10
|
/** Closed union of {@link KNOWN_CODES} — exhaustively switchable. */
|
|
10
11
|
type KnownCode = (typeof KNOWN_CODES)[number];
|
|
11
12
|
/** Narrow an arbitrary wire code to the known union (unknown codes stay `string`). */
|
|
12
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
|
+
}
|
|
13
32
|
/**
|
|
14
33
|
* Typed transport error: EVERY failure surfaces as one of these — non-2xx
|
|
15
34
|
* responses, rejected fetches, timeouts, and unparseable bodies alike. The
|
|
@@ -23,17 +42,30 @@ declare function isKnownCode(code: string): code is KnownCode;
|
|
|
23
42
|
* ('network_error' / 'timeout').
|
|
24
43
|
* - `retryAfterSeconds` — parsed from the `Retry-After` header when present
|
|
25
44
|
* (rate-limit 429s always set it).
|
|
45
|
+
* - `details` — the envelope's machine-readable `details` when present (flow
|
|
46
|
+
* errors: `issues[]`).
|
|
26
47
|
*/
|
|
27
48
|
declare class HostedApiError extends Error {
|
|
28
49
|
readonly status: number;
|
|
29
50
|
readonly code: string;
|
|
30
51
|
readonly retryAfterSeconds?: number;
|
|
52
|
+
readonly details?: HostedErrorDetails;
|
|
31
53
|
constructor(args: {
|
|
32
54
|
status: number;
|
|
33
55
|
code: string;
|
|
34
56
|
message: string;
|
|
35
57
|
retryAfterSeconds?: number;
|
|
58
|
+
details?: HostedErrorDetails | undefined;
|
|
36
59
|
});
|
|
37
60
|
}
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
/** The session's ICAO policy and profile, or `null` when the selfie is not ICAO-checked. */
|
|
63
|
+
declare function icaoPolicyOf(view: Pick<HostedSessionView, "portrait"> | null | undefined): HostedIcaoPolicy | null;
|
|
64
|
+
/**
|
|
65
|
+
* The `gate` block of a `portrait_icao` body from the gate's summary: the eye
|
|
66
|
+
* baseline, the device verdict under the server's criterion names, and the
|
|
67
|
+
* background-uniformity numbers (telemetry).
|
|
68
|
+
*/
|
|
69
|
+
declare function portraitIcaoGate(summary: IcaoGateSummary): NonNullable<PortraitIcaoInput["gate"]>;
|
|
70
|
+
|
|
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
|
|
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};
|