@sekyro/web 0.1.0-rc.10 → 0.1.0-rc.12

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{capture-session-doc-GK6G7JOI.js → capture-session-doc-KW5VR4IR.js} +1 -1
  3. package/dist/{capture-session-v3-DGG2stO6.d.ts → capture-session-v3-DqUUcIU-.d.ts} +34 -3
  4. package/dist/{capture-session-v3-CmJw_bK0.d.cts → capture-session-v3-xNtY5m-7.d.cts} +34 -3
  5. package/dist/{chunk-BAGSM67V.js → chunk-4IVRXJR2.js} +1 -1
  6. package/dist/chunk-6DPFJNGL.js +1 -0
  7. package/dist/{chunk-SEC64KZ3.js → chunk-73M7LS4H.js} +1 -1
  8. package/dist/chunk-EF52BRBD.js +1 -0
  9. package/dist/chunk-GT2ZLGF7.js +1 -0
  10. package/dist/chunk-IF6YOFFO.js +1 -0
  11. package/dist/chunk-MUVEJRGK.js +1 -0
  12. package/dist/{chunk-UGMHAFEY.js → chunk-OBLQOE66.js} +1 -1
  13. package/dist/chunk-U6TYL2IJ.js +1 -0
  14. package/dist/{chunk-FFDB6LQN.js → chunk-U6YQAQBD.js} +1 -1
  15. package/dist/chunk-Y7S7LYCL.js +1 -0
  16. package/dist/chunk-YZH5PR5R.js +1 -0
  17. package/dist/client/index.cjs +1 -1
  18. package/dist/client/index.d.cts +5 -3
  19. package/dist/client/index.d.ts +5 -3
  20. package/dist/client/index.js +1 -1
  21. package/dist/core/index.cjs +1 -1
  22. package/dist/core/index.d.cts +3 -2
  23. package/dist/core/index.d.ts +3 -2
  24. package/dist/core/index.js +1 -1
  25. package/dist/{create-document-capture-IGUQP2NS.js → create-document-capture-PXOJHLWV.js} +1 -1
  26. package/dist/{create-portrait-capture-RJSFY37D.js → create-portrait-capture-C462EIB6.js} +1 -1
  27. package/dist/{create-verification-Bb20j6zk.d.ts → create-verification-CDOTGHQj.d.ts} +87 -9
  28. package/dist/{create-verification-CtqF4A9W.d.cts → create-verification-D4749F6L.d.cts} +87 -9
  29. package/dist/icao-gate-BRuIgOE2.d.cts +503 -0
  30. package/dist/icao-gate-CphntEQ2.d.ts +503 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +16 -5
  33. package/dist/index.d.ts +16 -5
  34. package/dist/index.js +1 -1
  35. package/dist/internal/index.cjs +1 -1
  36. package/dist/internal/index.d.cts +17 -8
  37. package/dist/internal/index.d.ts +17 -8
  38. package/dist/internal/index.js +1 -1
  39. package/dist/{plan-runner-QCK2SOGS.js → plan-runner-2FJLUALJ.js} +1 -1
  40. package/dist/popup/index.cjs +1 -1
  41. package/dist/popup/index.d.cts +7 -1
  42. package/dist/popup/index.d.ts +7 -1
  43. package/dist/popup/index.js +1 -1
  44. package/dist/{icao-gate-terzKYD7.d.cts → types-4rgeNIlz.d.cts} +179 -498
  45. package/dist/{icao-gate-terzKYD7.d.ts → types-4rgeNIlz.d.ts} +179 -498
  46. package/package.json +1 -1
  47. package/sbom.cdx.json +7 -7
  48. package/dist/chunk-3MSUJYBO.js +0 -1
  49. package/dist/chunk-ETY6SAAZ.js +0 -1
  50. package/dist/chunk-HAO6EQTH.js +0 -1
  51. package/dist/chunk-HWAXEQD5.js +0 -1
  52. package/dist/chunk-SXZCL5NO.js +0 -1
  53. package/dist/chunk-SZ7YGNUZ.js +0 -1
  54. package/dist/chunk-WKJJEPWA.js +0 -1
  55. package/dist/chunk-XR64UFLK.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sekyro/web",
3
- "version": "0.1.0-rc.10",
3
+ "version": "0.1.0-rc.12",
4
4
  "description": "Sekyro AI web SDK \u2014 browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
package/sbom.cdx.json CHANGED
@@ -97,8 +97,8 @@
97
97
  "type": "application",
98
98
  "name": "web",
99
99
  "group": "@sekyro",
100
- "version": "0.1.0-rc.10",
101
- "bom-ref": "@sekyro/web@0.1.0-rc.10",
100
+ "version": "0.1.0-rc.12",
101
+ "bom-ref": "@sekyro/web@0.1.0-rc.12",
102
102
  "description": "Sekyro AI web SDK — browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
103
103
  "licenses": [
104
104
  {
@@ -108,7 +108,7 @@
108
108
  }
109
109
  }
110
110
  ],
111
- "purl": "pkg:npm/%40sekyro/web@0.1.0-rc.10?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-web",
111
+ "purl": "pkg:npm/%40sekyro/web@0.1.0-rc.12?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-web",
112
112
  "externalReferences": [
113
113
  {
114
114
  "url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
@@ -150,7 +150,7 @@
150
150
  "name": "tasks-vision",
151
151
  "group": "@mediapipe",
152
152
  "version": "0.10.35",
153
- "bom-ref": "@sekyro/web@0.1.0-rc.10|@mediapipe/tasks-vision@0.10.35",
153
+ "bom-ref": "@sekyro/web@0.1.0-rc.12|@mediapipe/tasks-vision@0.10.35",
154
154
  "licenses": [
155
155
  {
156
156
  "license": {
@@ -183,13 +183,13 @@
183
183
  ],
184
184
  "dependencies": [
185
185
  {
186
- "ref": "@sekyro/web@0.1.0-rc.10",
186
+ "ref": "@sekyro/web@0.1.0-rc.12",
187
187
  "dependsOn": [
188
- "@sekyro/web@0.1.0-rc.10|@mediapipe/tasks-vision@0.10.35"
188
+ "@sekyro/web@0.1.0-rc.12|@mediapipe/tasks-vision@0.10.35"
189
189
  ]
190
190
  },
191
191
  {
192
- "ref": "@sekyro/web@0.1.0-rc.10|@mediapipe/tasks-vision@0.10.35"
192
+ "ref": "@sekyro/web@0.1.0-rc.12|@mediapipe/tasks-vision@0.10.35"
193
193
  }
194
194
  ]
195
195
  }
@@ -1 +0,0 @@
1
- import{a as Q,c as M,d as H,e as N,f as ge,g as E,h as B,i as P,j as U,k as x,l as v,m as V,u as Ce,v as _e}from"./chunk-XR64UFLK.js";import{m as Se}from"./chunk-ETY6SAAZ.js";import{a as me}from"./chunk-HAO6EQTH.js";import{d as J}from"./chunk-FUHDOEBP.js";import{c as he,e as ye,f as F}from"./chunk-HWAXEQD5.js";var Fe="https://api.sekyro.ai",Ge=5e3,Ke=1500,qe=10;function Ye(e){return new Promise(t=>setTimeout(t,e))}function We(){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 Rt(e){return Ze(e,{})}function Ze(e,t){let i=e.apiOrigin??Fe,o=e.autoRetry??!0,r=e.rearm??"auto",a=t.client??new ye({apiOrigin:i,sessionToken:e.clientToken,fetch:e.fetch}),l=t.sleep??Ye,s=t.uuid??We,S=t.getTurnstileToken??((n,c)=>import("./turnstile-FATNZ4AG.js").then(d=>d.executeTurnstile(n,c))),f=me(),p=null,h=null,u=!1,w=new AbortController,m=null,G=null,R=n=>{m=n,f.emit("view",n),p?.onView(n)},C=()=>m!==null?Promise.resolve(m):(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,ee=async n=>{let c=await C();if(!n&&c.consentRecorded)return;let d=await a.recordConsent(e.locale);d.plan!==void 0?R(d):m!==null&&R({...m,consentRecorded:!0})},O=n=>n?.force===!0?ee(!0):(q??(q=ee(!1).finally(()=>{q=null})),q),Y={client:a,ensureConsent:n=>O(n),sleep:l,uuid:s,onBusy:n=>{u||f.emit("busy",n)}},te=!1,ne=null,W=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(te)return;te=!0}ne=JSON.stringify(n),f.emit("result",n)},ve=n=>{ne!==JSON.stringify(n)&&W(n)},ie=async n=>{let c=m;n&&(c=await I().catch(()=>m));let d=c===null?null:E(c);return d!==null&&!u&&f.emit("method",d),d!==null},oe=null,re=!1,se=!1,ae=()=>Ce(Y,(n,c)=>n.submitCheck("population_registry",{},{idempotencyKey:c})),ce=n=>n.nniBound===!0||x(n,"population_registry")?.nniFromDocument===!0,Ee=async()=>{try{let n=await C();if(P(n)||E(n)!==null||U(n)?.checkType!=="population_registry")return;if(!ce(n)&&x(n,"population_registry")?.nniFromDocument===void 0&&(n=await I()),!ce(n)){se=!0;return}await O(),await K(await ae(),"population_registry");let c=m===null?void 0:x(m,"population_registry");if(c?.state==="input_required"&&c.reason==="registry_unavailable"&&N(c)>0){if(await l(Ge),u)return;await K(await ae(),"population_registry")}}catch(n){if(n instanceof he&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await I().catch(()=>{});return}re=!0;return}m!==null&&P(m)&&W(V(m,{autoRetry:o}))},le=()=>(oe??(oe=Ee()),oe),we=async()=>{let c=(await C()).turnstileSiteKey;return c===null?{sandbox:!0}:{channel:"hosted_web",siteKey:c,turnstileToken:await S(c,{signal:w.signal})}},k=null,ue=Promise.resolve(),T=0,Oe=async()=>{let n=await C();for(let c=0;c<qe&&!u&&!P(n)&&U(n)===void 0&&H(n).some(d=>d.state==="processing")&&(await l(Ke),!u);c+=1)n=await I();return n},Te=async(n,c,d)=>{let{capture:_}=n,g=()=>u,L=()=>n.alive&&n.attempt===d,fe=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=m?.sessionId??(await C().catch(()=>null))?.sessionId??"";A(v(y,"no_recorder"));return}fe("uploading");try{if(await le(),g())return;let y=await C();if(!P(y)&&E(y)!==null){await ie(!1),A(v(y.sessionId,"method_required"));return}if(!P(y)){if(U(y)?.checkType==="population_registry"){A(v(y.sessionId,se?"nni_unbound":re?"network":"registry_unavailable"));return}if(await O(),g())return;let Z=await _e({...Y,artifacts:c,getAttestation:we,getView:()=>m??y,refreshView:I,applySubmit:K,onPhase:fe,isCancelled:g,onKeyframePromoted:Ue=>{h=Ue}});if(g())return;if(Z.kind==="unavailable"){A(v(y.sessionId,Z.reason));return}if(Z.kind==="resync"&&await I(),m!==null&&E(m)!==null){await ie(!1),A(v(y.sessionId,"method_required"));return}y=await Oe()}A(V(y,{autoRetry:o}))}catch{if(g())return;A(v(m?.sessionId??"","network"))}},Me=(n,c)=>{let d=n.attempt;T>0&&n.alive&&n.capture.setFlowState("uploading"),T+=1,ue=ue.then(()=>Te(n,c,d)).finally(()=>{T-=1,T===0&&p?.onChainIdle()}).catch(()=>{})},de=n=>{k?.capture.handle.destroy(),k!==null&&(k.alive=!1);let c=Se(n,p?.captureInternals?.(n)??t.capture,()=>m?.capture?.liveness?.keyframe?.rank===!0,()=>Q(m)),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(()=>Me(d,g))});let _=c.handle;return{get state(){return _.state},get captureMode(){return _.captureMode},get facingMode(){return _.facingMode},on:(g,L)=>_.on(g,L),start:async g=>{if(m===null&&await C().catch(()=>{}),!!d.alive)return _.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}},De=async()=>{if(u)return"self";try{let n=await C();return u?"self":Q(n)}catch{return"self"}},Le=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}},He=async()=>{if(u)return!1;try{let n=await C();return!u&&n.returning===!0}catch{return!1}},Ne=async n=>{let c=(await C()).plan?.choice,d=c?.options.find(g=>M[g.service]===n);if(!d)throw new RangeError(`method ${String(n)} is not offered`);let _=await a.choose(c.nodeId,d.id);u||R(_)},pe=null,Be=()=>(pe??(pe=import("./plan-runner-QCK2SOGS.js").then(n=>{let c=n.createPlanRunner({runtime:Y,currentView:()=>m,ensureView:C,refreshView:I,ensureConsent:()=>O(),liveness:de,chainBusy:()=>T>0,destroyed:()=>u,sleep:l,isMobile:J,now:t.now??Date.now,keptFaceKey:()=>h,setView:R,baseCapture:t.capture,emitStep:d=>{u||f.emit("step",d)},emitResult:ve,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto});return p=c,c})),pe);return{consent:()=>O(),startRegistry:le,methodChoice:Ve,selectMethod:Ne,mobileRequired:Le,captureMode:De,returning:He,liveness:de,run:async()=>{if(u)throw new Error("verification destroyed");return(await Be()).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 ke=["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 Je=["carte_identite","passport","residence_permit"];function Qe(e,t){let i=e.byIssuer?.[t]??e.default;return Je.filter(o=>i==="*"||i.includes(o))}function wt(e,t=ke){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(o=>Qe(e,o).length>0).sort()}function Pe(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Ot(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var Lt=["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"]),$e=new Set(["supplied_identity","aml_screening","face_dedup"]),$=["document","population_registry","national_eid"],X=["phone_otp","email_otp"],Ie={identity_method:$,contact:X},Xe=["population_registry","document"],be="platform_unsupported",ze=new Set(["prefilled","user_entered","prefilled_or_entered"]),et={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??et[e.checkType]??null}function tt(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 z(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=Ie[i.kind]??[...$,...X],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 Re(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function nt(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=z(e);return o!==null&&(i.switchable=o),i}function it(e){let t={attemptsRemaining:N(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),t}var Ae={phone_otp:"phone",email_otp:"email"};function ot(e,t){let i=tt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Ae[i.option.service]}function rt(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&&ze.has(l)?l:r?"prefilled_or_entered":"user_entered",S=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,f=ot(e,r?"email_otp":"phone_otp"),p={key:t.checkType,context:i,section:b(t),phase:S?"verify":"send",canSwitch:f!==void 0,...o},h=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&&(h.switchChannel=f),S&&(h.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(h.channel=t.otp.channel),a.expiresAt!==void 0&&(h.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(h.resendAvailableAt=a.resendAvailableAt),h}function st(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=Re(z(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 at(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:Pe(e),...o}}function ct(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function xe(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&&ct(e),...o}}var j={minLongSidePx:1280,jpegQuality:.95};function lt(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let o=x(e,"portrait_icao"),r=i.still??j;return{icao:t==="liveness"&&F(e)!==null&&o!==void 0&&o.state==="pending"&&o.reason===void 0,still:{minLongSidePx:r.minLongSidePx??j.minLongSidePx,jpegQuality:r.jpegQuality??j.jpegQuality}}}function ut(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=Re(z(e)),s=l.length===1&&Xe.includes(l[0]?.service??"")?l[0]:void 0,S=s===void 0?void 0:M[s.service],f=S!==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=S),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 dt(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 pt(e){return H(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function ft(e,t){let i=e.failureReason,o;i===be?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":pt(e)?o="attempts_exhausted":o="rejected";let r=o==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:V(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 mt(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 St){let l=o[a];typeof l=="string"&&l!==""&&(r[a]=l)}return r}var St=["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 ht(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function yt(e,t){let i=Ie[e.kind]??[...$,...X],o=ht(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(S=>M[S.service]),choice:a},s=r.find(S=>S.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=>Ae[l.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:o,choice:a}}function Ht(e,t={}){let i=nt(e);if(P(e)||e.failureReason===be)return ft(e,i);let o=e.plan;if(o===void 0||!Array.isArray(o.sections))return D(i,null,"plan","update_required");let r=ge(e);if(r!==null)return yt(r,i);let a=o.current===null?void 0:o.steps.find(h=>h.id===o.current),l=h=>({kind:"processing",key:"processing",context:i,section:h!==void 0?b(h):o.sections.find(u=>u.state==="current")?.id??null,stalled:!1});if(o.current===null)return l(o.steps.find(h=>h.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($e.has(a.service)||!B(a))return l(a);let s=a,S=it(s),f=s.checkType,p=b(s);switch(f){case"phone_otp":case"email_otp":return rt(e,s,i,S);case"population_registry":return st(e,s,i,S);case"eid_auth":return ut(e,s,i,S);case"doc_ocr":return at(e,s,i,S);case"identity_confirm":return mt(e,i,p)??l(s);case"portrait_icao":return xe(e,s,i,S,"capture");case"liveness":case"face_match":{let h=dt(e,s);if(h!==null)return xe(e,h,i,S,"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:lt(e,f),...S}}case"nfc_chip":return D(i,p,f,"platform_unsupported");default:return D(i,p,f,"update_required")}}export{Fe as a,Ge as b,Ke as c,qe as d,We as e,Rt as f,Ze as g,ke as h,Je as i,Qe as j,wt as k,Pe as l,Ot as m,Lt as n,be as o,b as p,z as q,Re as r,dt as s,Ht as t};
@@ -1 +0,0 @@
1
- import{a as $,d as Q,e as Z}from"./chunk-HAO6EQTH.js";import{r as N}from"./chunk-SZ7YGNUZ.js";import{c as z}from"./chunk-FUHDOEBP.js";import{f as q}from"./chunk-FHJ7HO3M.js";import{a as G,f as v}from"./chunk-OKWG3PVH.js";var te=12e4,j=13e4,se=3e3,re=1200,P=Symbol.for("@sekyro/web.preload.v1");function l(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function g(e){let t=(e??G).replace(/\/+$/,"");return t===""?"/":t}function J(e){let t=l(),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 A(e,t){if(e.status!==t){e.status=t;for(let s of[...e.listeners])s(t)}}var T=e=>v({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:te}),x=T;function ve(e){x=e??T}function ge(){for(let e of l().values())e.detector?.destroy();l().clear(),x=T}function ne(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function oe(){return navigator.connection?.saveData===!0}function ie(e){let t=window;if(typeof t.requestIdleCallback=="function"){let n=t.requestIdleCallback(e,{timeout:se});return()=>t.cancelIdleCallback?.(n)}let s=setTimeout(e,re);return()=>clearTimeout(s)}function ae(e,t){let s,n=new Promise(i=>{s=i}),d=!1,f=()=>{},a={promise:n,settle:i=>{d||(d=!0,f(),e.scheduled===a&&(e.scheduled=null),s(i))}};return e.scheduled=a,f=ie(()=>{d||a.settle(I(e,t))}),n}function I(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let s=new Promise(i=>i(x(t)));e.detectorPromise=s;let n,d=new Promise((i,h)=>{n=setTimeout(()=>{s.then(p=>p.destroy(),()=>{}),h(new Error(`detector preload exceeded ${j} ms`))},j)}),a=Promise.race([s,d]).then(i=>e.detectorPromise!==s?(i.destroy(),e.status):(e.detector=i,A(e,"ready"),"ready"),i=>(e.detectorPromise===s&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",i)),e.status)).finally(()=>clearTimeout(n));return e.promise=a,e.scheduled?.settle(a),a}function he(e={}){if(!ne())return Promise.resolve("idle");let t=g(e.assetBaseUrl),s=J(t);return e.respectSaveData===!0&&oe()?Promise.resolve(s.status):(s.status==="loading"||s.status==="ready")&&s.promise!==null?s.promise:e.idle===!0?s.scheduled?.promise??ae(s,t):I(s,t)}function Se(e){return l().get(g(e))?.status??"idle"}function Le(e,t){let s=J(g(t));return s.listeners.add(e),()=>{s.listeners.delete(e)}}function Ce(e){let t=l().get(g(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,A(t,"idle"))}function ce(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function X(e){let t=g(e),s=l().get(t);if(!(s===void 0||s.detector===null&&s.detectorPromise===null&&s.scheduled===null))return async()=>{s.scheduled!==null&&I(s,t);let n=s.promise;for(;s.detector===null&&n!==null&&(await n,s.promise!==n);)n=s.promise;return s.detector!==null?ce(s.detector):v({v3AssetBaseUrl:t})}}function de(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";case"fcv3.hold_upright":return"upright";default:return null}}function ue(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function le(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function fe(e,t={},s,n=()=>"self"){let d=t.now??(()=>performance.now()),f=t.canChooseFacing??Q,a="user",i=!1,h=r=>(r==="environment"&&!i&&(i=!0,console.warn('[@sekyro/web] facing "environment" ignored: this capture is a self capture (the person films themselves), which uses the front camera only. The back camera is for assisted capture, set in the flow.')),"user"),p=!1,S=n(),u=$(),H=!q(),U=t.engineOptions,Y=U?.createDetector===void 0&&U?.createWorker===void 0?{createDetector:()=>{let r=X(e.assetBaseUrl);return r!==void 0?r():v({v3AssetBaseUrl:e.assetBaseUrl})}}:{},B={video:e.video,mode:H?"photo":"clip",rankKeyframes:s,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,...t.engineOptions??{},...Y},o=t.createEngine?.(B)??new N(B),L="idle",C=null,y=0,k=!1,D="full",E=null,b=null,M=0,_=0,R=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(M=e.video.videoWidth,_=e.video.videoHeight)},K=Z({enabled:e.keepScreenAwake!==!1}),V=r=>{L=r,K.setActive(r==="starting"||r==="gating"||r==="recording"),u.emit("state",r)},F=()=>u.emit("gate",{progress:y,hint:C,faceDetected:k}),W=()=>{let r=o.animations??"full";r!==D&&(D=r,u.emit("profile",{animations:D}))},ee=[o.on("statechange",({state:r})=>{let c=ue(r);c==="starting"&&L!=="starting"&&(C=null,y=0,k=!1,E=null,b=null,M=0,_=0),V(c),W(),c==="recording"&&(R(),E=d(),C="hold",y=1,F())}),o.on("checks",r=>{R(),y=r.progress,k=r.factors.presence>0,F(),W()}),o.on("guidance",({key:r})=>{C=de(r),F()}),o.on("frozen",({previewDataUrl:r})=>{b=d(),u.emit("frozen",{previewDataUrl:r})}),o.on("artifacts",r=>{let c=z(),m=E!==null&&b!==null?Math.max(0,Math.round(b-E)):void 0;u.emit("captured",{keyframe:r.keyframe,...r.clip!==void 0?{clip:r.clip}:{},...r.clipMimeType!==void 0?{clipMime:r.clipMimeType}:{},width:e.video.videoWidth||M,height:e.video.videoHeight||_,...m!==void 0?{clipMs:m}:{},captureChannel:c==="desktop"?"desktop":"mobile",formFactor:c,...H?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:o.facingMode,mode:S,...r.timing})}),o.on("error",({kind:r,retryable:c})=>{u.emit("error",{kind:le(r),retryable:c})})];return{handle:{get state(){return L},get captureMode(){return n()},get facingMode(){return o.facingMode??a},on:(r,c)=>u.on(r,c),start:r=>{if(S=n(),S==="self")return h(e.facing),h(r?.facing),p=!0,a="user",o.start({facingMode:"user"});let c=!p;p=!0;let m=r?.facing??(c?e.facing:void 0),O=w=>(a=w,o.start({facingMode:w}));return m!==void 0?O(m):c?f().then(w=>O(w?"environment":"user"),()=>O("user")):o.start({})},retry:()=>o.retry(),switchCamera:()=>n()!=="assisted"?!1:(S="assisted",a=a==="user"?"environment":"user",o.switchCamera(),!0),destroy:()=>{for(let r of ee)r();K.setActive(!1),o.destroy(),u.clear()}},setFlowState:r=>{L!==r&&V(r)}}}function _e(e){return fe(e).handle}export{te as a,j as b,ve as c,ge as d,he as e,Se as f,Le as g,Ce as h,X as i,de as j,ue as k,le as l,fe as m,_e as n};
@@ -1 +0,0 @@
1
- function y(){let e=new Map;return{on(i,n){let t=e.get(i);t===void 0&&(t=new Set,e.set(i,t));let r=n;return t.add(r),()=>{t?.delete(r)}},emit(i,n){let t=e.get(i);if(t!==void 0)for(let r of[...t])r(n)},clear(){e.clear()}}}async function f(){try{return typeof navigator>"u"||typeof navigator.permissions?.query!="function"?null:await navigator.permissions.query({name:"camera"})}catch{return null}}function u(e){return e==="granted"||e==="prompt"||e==="denied"?e:"unknown"}async function h(){let e=await f();return e===null?"unknown":u(e.state)}function g(e){let i=!1,n=null,t=()=>{!i&&n!==null&&e(u(n.state))};return f().then(r=>{i||(n=r,e(r===null?"unknown":u(r.state)),r?.addEventListener?.("change",t))}),()=>{i=!0,n?.removeEventListener?.("change",t)}}async function S(){if(typeof navigator>"u")return!1;let e=String(navigator.userAgent??"");if(/Android|iPhone|iPad|iPod/i.test(e)||/Macintosh/.test(e)&&(navigator.maxTouchPoints??0)>1)return!0;try{return(await navigator.mediaDevices?.enumerateDevices?.()??[]).filter(n=>n.kind==="videoinput").length>=2}catch{return!1}}function v(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let e=navigator.wakeLock;return typeof e?.request=="function"?e:null}function m(){return typeof document>"u"||document.visibilityState==="visible"}function p(e){try{e.release().catch(()=>{})}catch{}}function E(e={}){if(e.enabled===!1)return{setActive:()=>{}};let i=!1,n=null,t=!1,r=!1,l=()=>{if(!i||t||n!==null&&!n.released)return;let a=v();if(a===null||!m())return;let o;try{o=a.request("screen")}catch{return}t=!0,o.then(s=>{if(t=!1,!i){p(s);return}n=s,s.addEventListener?.("release",()=>{n===s&&(n=null)})},()=>{t=!1})},c=()=>{m()&&l()},d=a=>{typeof document>"u"||a===r||(r=a,a?document.addEventListener("visibilitychange",c):document.removeEventListener("visibilitychange",c))};return{setActive:a=>{if(i=a,a){if(v()===null)return;d(!0),l();return}if(d(!1),n!==null){let o=n;n=null,p(o)}}}}export{y as a,h as b,g as c,S as d,E as e};
@@ -1 +0,0 @@
1
- import{a as p}from"./chunk-BAGSM67V.js";var _=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active"];function E(s){return _.includes(s)}var d=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};var g=6e4,m=4,b=3e4,T=9e5,w=200,k=5,S=400;function l(s){return(s.split(";")[0]??"").trim()}var P={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},f=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,i)=>(n??globalThis.fetch).call(globalThis,t,i),this.requestTimeoutMs=e.requestTimeoutMs??b,this.retryAttempts=e.inProgressRetry?.attempts??k,this.retryDelayMs=e.inProgressRetry?.delayMs??S}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e}})}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n}});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t){let i=await this.ensureSessionId(),o={kind:e,contentType:l(n),contentLength:t};return this.api("POST",`/sessions/${i}/media`,{body:o})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,i={}){let o=await this.ensureSessionId(),r=await this.takeCaptureNonce(),c=r===void 0?void 0:{nonce:r,...i.engine!==void 0?{engine:i.engine.slice(0,32)}:{},...i.durationMs!==void 0&&Number.isFinite(i.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(i.durationMs)))}:{}},a={kind:e,contentType:l(n),contentLength:t,capture:c};return this.api("POST",`/sessions/${o}/media`,{body:a})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-g>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let t=e();if(t!==void 0)return t;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(m,Math.max(1,e))}}),i=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let o of Array.isArray(t.nonces)?t.nonces:[])typeof o=="string"&&o.length>0&&this.captureNonces.push({nonce:o,expiresAt:i});this.captureNonces=this.captureNonces.slice(-m)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(T)})}catch(o){throw y(o)}if(!i.ok){let o=(await i.text().catch(()=>"")).slice(0,w);throw new d({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let i=await this.ensureSessionId(),o={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:o,idempotencyKey:t.idempotencyKey})}async uploadAndSubmit(e,n,t,i={}){let o=l(n.contentType),r=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(r.uploadUrl,n.blob,o);let c=await this.completeMedia(r.key),a={...t,[P[e]]:c.key};return this.submitCheck(e,a,i)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,t={}){let i=`${this.apiOrigin}/api/v2${n}`,o={"x-session-token":this.sessionToken};t.body!==void 0&&(o["content-type"]="application/json"),t.idempotencyKey!==void 0&&(o["x-idempotency-key"]=t.idempotencyKey);try{let r=p.timezone();r!==void 0&&(o["sekyro-client-timezone"]=r)}catch{}try{let r=await p.deviceHeader();r!==void 0&&(o["sekyro-client-device"]=r)}catch{}for(let r=0;;r++){let c;try{c=await this.fetchImpl(i,{method:e,headers:o,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(u){throw y(u)}if(c.ok){if(t.blob===!0)try{return await c.blob()}catch(h){throw y(h)}let u;try{u=await c.json()}catch{throw new d({status:c.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${c.status})`})}return C(u)}let a=await I(c);if(a.code==="idempotency_in_progress"&&r<this.retryAttempts){this.retryDelayMs>0&&await M(this.retryDelayMs);continue}throw a}}};function y(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new d({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new d({status:0,code:"network_error",message:`network request failed: ${n}`})}function C(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function I(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,i;try{let c=await s.json();if(c!==null&&typeof c=="object"){let a=c;typeof a.code=="string"&&a.code.length>0&&(e=a.code),typeof a.message=="string"&&a.message.length>0&&(n=a.message),typeof a.retryAfterSeconds=="number"&&(t=a.retryAfterSeconds),Array.isArray(a.details?.issues)&&(i=a.details)}}catch{}let o=s.headers.get("retry-after"),r=o===null?Math.floor(t):Number.parseInt(o,10);return new d({status:s.status,code:e,message:n,...Number.isFinite(r)&&r>=0?{retryAfterSeconds:r}:{},details:i})}function M(s){return new Promise(e=>setTimeout(e,s))}function N(s){let e=s?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"&&!t?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function H(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{_ as a,E as b,d as c,l as d,f as e,N as f,H as g};
@@ -1 +0,0 @@
1
- var c=["session.completed","session.failed","session.review_pending","session.expired","session.cancelled"],v="sekyro-verify",u="width=480,height=720,noopener=false",a=new Set(c);function E(e){if(e===null||typeof e!="object")return!1;let n=e;return n.source==="sekyro"&&n.version===1&&typeof n.sessionId=="string"&&typeof n.event=="string"&&a.has(n.event)}function l(e){let n=new URL(e.hostedUrl).origin,t=window.open(e.hostedUrl,v,u);if(!t)return{error:"popup_blocked"};let r=o=>{if(o.source!==t||o.origin!==n||!E(o.data))return;let{source:s,version:i,event:p,sessionId:d}=o.data;e.onEvent({source:s,version:i,event:p,sessionId:d})};return window.addEventListener("message",r),{close(){window.removeEventListener("message",r),t.close()}}}function f(e,n){return n.mode==="redirect"?(window.location.assign(e),{close(){}}):l({hostedUrl:e,onEvent:n.onEvent??(()=>{})})}export{c as a,l as b,f as c};
@@ -1 +0,0 @@
1
- import{a as R,c as w,d as O,e as G}from"./chunk-FUHDOEBP.js";import{b as W,c as z,d as q}from"./chunk-POIQGEZM.js";import{b as x,c as V,d as P,e as L,g as F,h as _}from"./chunk-FHJ7HO3M.js";import{b as T,c as X,d as I,e as Z}from"./chunk-FPXL63KZ.js";import{b as H}from"./chunk-BAGSM67V.js";import{c as N,d as K,f as C,h as U,j as B}from"./chunk-OKWG3PVH.js";var ee=2500,te=1e3,re=1500,Q=25e5,p=class extends Error{constructor(e,t){super(t??e),this.kind=e}},S=class{constructor(){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.settled=!1}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.hardStopTimer=null,this.graceTimer=null}record(e,t){if(this.recorder&&!this.settled)return Promise.reject(new p("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time"));this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e;let r=x();return new Promise((i,s)=>{let a;try{a=new MediaRecorder(e,r?{mimeType:r,videoBitsPerSecond:Q}:{videoBitsPerSecond:Q})}catch{try{a=new MediaRecorder(e)}catch{s(new p("unsupported"));return}}this.recorder=a;let n=h=>{this.settled||(this.settled=!0,this.clearTimers(),h())},o=()=>n(()=>{let h=a.mimeType||r||V,l=new Blob(this.chunks,{type:h});if(l.size===0){s(new p("generic","empty clip"));return}if(_(l)){s(new p("cliptoolarge"));return}i({blob:l,mimeType:h})});a.ondataavailable=h=>{h.data&&h.data.size&&(this.chunks.push(h.data),this.bytes+=h.data.size,this.bytes>F&&n(()=>{try{a.state!=="inactive"&&a.stop()}catch{}s(new p("cliptoolarge"))}))},a.onstop=o,a.onerror=()=>n(()=>s(new p("generic")));try{a.start(te)}catch{n(()=>s(new p("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),a.state!=="inactive"){try{a.stop()}catch{o()}this.graceTimer=setTimeout(o,re)}else o()},ee)})}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};function Y(u,e,t=.92){return new Promise((r,i)=>{let s=u.videoWidth,a=u.videoHeight;if(!s||!a){i(new Error("video-not-ready"));return}let n=e.getContext("2d");if(!n){i(new Error("no-2d-context"));return}e.width=s,e.height=a,n.scale(-1,1),n.drawImage(u,-s,0),e.toBlob(o=>o?r(o):i(new Error("empty-keyframe")),"image/jpeg",t)})}var M=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var ie=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),g=u=>Math.min(1,Math.max(0,u)),b=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...ie,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:i}=e,s=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let a={presence:0,centering:0,size:0,pose:0,sharpness:g(r.sharpness),exposure:g(r.exposure),motion:1};if(t!==null){a.presence=1;let l=this.geometryOf(t,e);a.centering=l.centering,a.size=l.size,a.pose=l.pose,a.motion=this.motionOf(l.center,l.iod,i)}else this.lastCenter=null,this.velocityEma=0;let n=Math.min(a.presence,a.centering,a.size,a.pose,a.sharpness,a.exposure,a.motion);this.p=g(this.p+(n>=this.t.Q_GOOD?this.t.RISE_PER_S*n:-this.t.FALL_PER_S*(1-n))*s),this.qWindow.push({at:i,q:n}),this.qWindow=this.qWindow.filter(l=>l.at>=i-this.t.READY_WINDOW_MS);let o=this.qWindow.map(l=>l.q);if(o.length>=3){let l=Math.min(...o),c=o.indexOf(l);o=o.filter((m,d)=>d!==c)}let h=this.p>=1&&o.every(l=>l>=this.t.Q_GOOD);return{at:i,q:n,p:this.p,factors:a,guidanceKey:this.guidanceOf(a,r,n),ready:h,accepted:n>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,s={x:t.frameWidth/2,y:t.frameHeight/2},a=Math.min(t.frameWidth,t.frameHeight),n=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},o=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(n.x-s.x,n.y-s.y),l=o<=0?0:1-g(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*o)),c=a>0?o/a:0;this.lastSizeDirection=c<this.t.SIZE_IDEAL_MIN?"far":c>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;c<this.t.SIZE_HARD_MIN||c>this.t.SIZE_HARD_MAX?m=0:c<this.t.SIZE_IDEAL_MIN?m=(c-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):c>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-c)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let d=1;if(i!==void 0){let y=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;d=1-g(y/this.t.ROLL_MAX_DEG)}return{center:n,iod:o,centering:l,size:m,pose:d}}motionOf(e,t,r){let i=this.lastCenter;if(this.lastCenter={...e,at:r},i===null||t<=0)return 1;let s=(r-i.at)/1e3;if(s<=0)return 1;let a=Math.hypot(e.x-i.x,e.y-i.y)/t/s;a<=this.t.MOTION_DEADBAND_IOD_PER_S&&(a=0);let n=1-Math.exp(-s/this.t.MOTION_TAU_S);return this.velocityEma=n*a+(1-n)*this.velocityEma,1-g(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],s=i[0];for(let a of i)e[a[0]]<e[s[0]]&&(s=a);return s[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(T[0]+T[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var se=["size","centering","pose","exposure","sharpness","motion"];function ae(u){if(u.accepted)return null;if(u.factors.presence<=0)return"no_face";let e="size";for(let t of se)u.factors[t]<u.factors[e]&&(e=t);return e}var E=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=ae(e);if(r===null){this.acceptedMs+=t;return}let i=this.blocked[r]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[r]=i}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var ne=1e3,A="fcv3.hold_upright",oe=200,D=4,ce=600,j={sharpness:1,exposure:1,meanLuma:128};function le(u,e){return e.width=u.videoWidth,e.height=u.videoHeight,e.getContext("2d").drawImage(u,0,0),new Promise((t,r)=>e.toBlob(i=>i?t(i):r(new Error("empty-keyframe")),"image/jpeg",.92))}function ue(){return w()==="phone"}var J=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??ue)(),this.setState("preflight");let r=L();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o)),s;this.cameraRequestedAt=this.now();try{s=await i(R(O(),this.facing))}catch(o){if(e!==this.attempt)return;this.fail(P(o));return}if(H(s),e!==this.attempt){for(let o of s.getTracks())o.stop();return}if(this.stream=s,this.facing=G(s)??this.facing,t.video.srcObject=s,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let o={v3AssetBaseUrl:t.v3AssetBaseUrl},h=t.createDetector??(t.createWorker!==void 0&&U()?async()=>{try{return await B.create(t.createWorker(),o)}catch{return C(o)}}:()=>C(o)),l;try{l=await h()}catch(c){e===this.attempt&&this.fail("models",c instanceof N?c.fallbackReason:de(c));return}if(e!==this.attempt){l.destroy();return}this.detector=l,this.options.telemetry?.({type:"detector",tier:l.tier,fallbackReason:l.fallbackReason})}let a=W(),n=t.deviceClass??z(a);this.profiler=new q(n),this.options.telemetry?.({type:"profile",staticClass:n,activeClass:this.profiler.deviceClass,simd:a.simd}),this.gate=new b(t.thresholds??{}),this.blockStats=new E,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(o=>k=o,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let r=new M({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:i}=this,s=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||s.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let a=i.deviceClass,n=this.now(),o=this.options.makeSnapshot?.(s,i.profile.inputWidth)??this.defaultSnapshot(s,i.profile.inputWidth),h=null;try{h=await t.detect(o,s.videoWidth,s.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-n),i.deviceClass!==a&&this.startScheduler(e);let l=h===null?j:this.options.measureQuality?.(s,h.box)??this.defaultQuality(s,h.box),c=r.tick({timestampMs:this.now(),observation:h,quality:l,frameWidth:s.videoWidth,frameHeight:s.videoHeight});c.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=c.at),this.blockStats?.record(c),!c.ready&&c.at-this.lastGateSnapshotAt>=ne&&(this.lastGateSnapshotAt=c.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:c.p,q:c.q,factors:c.factors,attempt:e}),c.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=c.guidanceKey,this.emit("guidance",{key:c.guidanceKey})),c.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=c.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let i=r?.stats()??{degradeCount:0,meanDetectMs:0},s=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:s.length===0?0:s.reduce((f,v)=>f+v,0)/s.length});let a=t.mode??"clip",n=t.rankKeyframes?.()&&k?k.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(a==="photo"){let f=this.watchRotation(e,null),v=await n;if(f(),e!==this.attempt)return;if(v===null){this.fail("generic");return}this.finishCapture({keyframe:v.blob,previewDataUrl:v.previewDataUrl});return}this.setState("recording");let o=t.createRecorder?.()??new S,h=this.stream;if(h===null){this.fail("generic");return}let l=this.watchRotation(e,o),c=null;n.then(f=>{c=f},()=>{});let m=()=>{e===this.attempt&&c!==null&&this.emit("frozen",{previewDataUrl:c.previewDataUrl})},d,y;try{[d,y]=await Promise.all([o.record(h,m),n])}catch(f){if(l(),e!==this.attempt)return;let v=f.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder");return}if(l(),e===this.attempt){if(_(d.blob)){this.fail("cliptoolarge");return}if(y===null){this.fail("generic");return}this.finishCapture({clip:d.blob,clipMimeType:d.mimeType,keyframe:y.blob,previewDataUrl:y.previewDataUrl})}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==A&&(this.lastGuidanceKey=A,this.emit("guidance",{key:A}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,i=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){n();return}r.videoWidth>0&&this.isLandscape()&&(n(),this.abortRecording(e,t))},s=setInterval(i,oe);r.addEventListener?.("resize",i);let a=!1;function n(){a||(a=!0,clearInterval(s),r.removeEventListener?.("resize",i))}return n}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.fired=!1,this.captureCompleteAt=null,this.gate=new b(this.options.thresholds??{}),this.blockStats=new E,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(s=>this.defaultKeyframe(s)),r=ce/(D-1),i=null;for(let s=0;s<D;s+=1){if(e!==this.attempt)return i;try{let a=await t(this.options.video);(i===null||a.sharpness>i.sharpness)&&(i=a)}catch{}s<D-1&&await he(r)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(r,i,s)=>{i!==null&&s!==null&&(e[r]=Math.max(0,Math.round(s-i)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?Y:le)(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),s=Math.max(1,Math.round(e.videoWidth*i)),a=Math.max(1,Math.round(e.videoHeight*i)),n=r.getContext("2d");return n===null?e:(r.width!==s&&(r.width=s),r.height!==a&&(r.height=a),n.drawImage(e,0,0,s,a),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=$(e,t,96);return r===null?j:{sharpness:I(r),exposure:Z(r),meanLuma:X(r)}}centerSharpness(e){let t=K(e),r=$(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:I(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},k;function he(u){return new Promise(e=>setTimeout(e,u))}function de(u){return u instanceof Error?u.message:String(u)}function $(u,e,t){try{let r=document.createElement("canvas"),i=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*i)),r.height=Math.max(1,Math.round(e.height*i));let s=r.getContext("2d");return s===null?null:(s.drawImage(u,e.x,e.y,e.width,e.height,0,0,r.width,r.height),s.getImageData(0,0,r.width,r.height))}catch{return null}}export{ee as a,te as b,re as c,Q as d,p as e,S as f,Y as g,M as h,ie as i,b as j,ae as k,E as l,ne as m,A as n,oe as o,D as p,ce as q,J as r};
@@ -1 +0,0 @@
1
- import{c as K,d as pe,e as me,f as fe,h as he,i as z,k as Y,m as Se,n as ge,u as ye,w as O,x as j}from"./chunk-XR64UFLK.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-HWAXEQD5.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-RJSFY37D.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).filter(n=>n.state==="failed").pop()?.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 +0,0 @@
1
- import{c as v,d as P}from"./chunk-HWAXEQD5.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 E(e){return Math.max(0,e.attempts.max-e.attempts.used)}function K(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}function oe(e){let t=K(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(r=>O[r.service]).filter(r=>r!==void 0),i=t.options.find(r=>r.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}var N=new Set(["liveness","face_match"]);function k(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function x(e){return e.status!=="created"&&e.status!=="in_progress"}function b(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return k(n)?n:void 0}function l(e,t){return y(e).find(n=>n.checkType===t)}function M(e,t){let n=l(t,"liveness")?.state,i=l(t,"face_match")?.state;return(l(e,"face_match")?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function S(e,t){return t===void 0?{sessionId:e,status:"unavailable"}:{sessionId:e,status:"unavailable",reason:t}}function _(e,t,n){return n===void 0?{sessionId:e,status:t}:{sessionId:e,status:t,reason:n}}function re(e,t){let{sessionId:n}=e;switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:n,status:"approved"}:e.outcome==="review"?_(n,"review",h(e,"review")):_(n,"rejected",h(e,"failed"));case"failed":{let o=_(n,"rejected",e.failureReason??h(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(o.retryAfter=e.retryAfter),o}case"review_pending":return _(n,"review",h(e,"review"));case"expired":return S(n);case"created":case"in_progress":break;default:{let o=e.status;throw new Error(`mapSessionResult: unhandled status ${o}`)}}let i=y(e).find(o=>N.has(o.checkType)&&o.state==="input_required"&&o.reason!==void 0);if(i?.reason==="mobile_required")return S(n,"mobile_required");if(i?.reason!==void 0){let o=t.autoRetry&&F.has(i.reason)&&E(i)>0;return{sessionId:n,status:o?"retry":"rejected",reason:i.reason,attemptsRemaining:E(i)}}let r=b(e);return r===void 0&&y(e).some(o=>o.state==="review")?_(n,"review",h(e,"review")):r?.checkType==="portrait_icao"?S(n,"portrait_required"):S(n)}function h(e,t){let n=y(e).filter(i=>i.state===t&&i.reason!==void 0);return n[t==="failed"?n.length-1:0]?.reason}function A(e,t,n,i,r){return e.presignCapture!==void 0?e.presignCapture(t,n,i,r):e.presign(t,n,i)}function T(e){return{engine:e?.engine,durationMs:e?.clipMs}}var q=["video/webm","video/mp4"],V="image/jpeg",Y=2,U=1e3,D=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 t=l(e,"face_match");return l(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?k(t):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(t){super(t),this.name="AttestationError"}};async function H(e,t,n={}){let i=e.uuid(),r=!1,o=!1,u=0,c=0;for(;;)try{return await t(e.client,i)}catch(a){if(a instanceof w){if(o)throw a;o=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(a instanceof v))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,n.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),n.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,D):U);continue}throw a}}var J=new Set(["passed","review","processing","skipped"]);async function le(e){let{artifacts:t}=e,n=t.clip,i=P(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!q.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let r=Q(e,t.keyframe),o=Z(e,n,i,r),u=ee(e,r),c=!1,a=!1,s=!0,p=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let d=e.getView();if(x(d))return{kind:"settled"};let R=b(d)?.checkType,C=R==="liveness"&&!c?"liveness":R==="face_match"&&!a&&s?"face_match":null;if(C===null)return{kind:"settled"};if(C==="liveness"&&t.captureChannel==="desktop"&&l(d,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(C==="liveness"){c=!0;let f=await o();if(e.isCancelled())return{kind:"cancelled"};a=M(d,f),await e.applySubmit(f,"liveness");let m=l(e.getView(),"liveness")?.state;s=m===void 0||J.has(m)}else{a=!0;let f=await u();if(e.isCancelled())return{kind:"cancelled"};await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof g)return{kind:"cancelled"};let m=ie(f);if(m.kind!=="resync"||p>=z)return m;p+=1,await e.refreshView()}}}function Q(e,t){let n=null,i=null,r=()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let o=await A(e.client,"image",V,t.size,T(e.artifacts));return await e.client.uploadToSpaces(o.uploadUrl,t,V),n=(await e.client.completeMedia(o.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i);return{ensure:r,attempt:()=>r().catch(()=>null),current:()=>n}}function Z(e,t,n,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,p]=await Promise.all([r!==null?Promise.resolve(r):(async()=>{let d=await A(c,"clip",n,t.size,T(e.artifacts));return await c.uploadToSpaces(d.uploadUrl,t,n),(await c.completeMedia(d.key)).key})(),o!==void 0?Promise.resolve(o===null?null:o.imageKey):i.attempt()]);r=s,o===void 0&&(o=p===null?null:{imageKey:p})}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:te(e.artifacts),...o!==null?{faceMatch:o}:{}},{idempotencyKey:a})},{onAttestationInvalid:()=>{u=null}})}function ee(e,t){return()=>H(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new g;e.onPhase("uploading")}let r=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:r},{idempotencyKey:i})})}function te(e){let t={width:e.width,height:e.height};for(let n of ne)e[n]!==void 0&&(t[n]=e[n]);return t}var ne=["engine","facingMode","mode","formFactor","clipMs","cameraReadyMs","faceAcquireMs","captureMs"];function ie(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof v){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(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}};function pe(e){let t=e?.capture;return t?.mode==="assisted"||t?.mode==="self"?t.mode:t?.cameraSwitch===!0?"assisted":"self"}export{pe as a,F as b,O as c,y as d,E as e,K as f,oe as g,k as h,x as i,b as j,l as k,S as l,re as m,A as n,q as o,Y as p,U as q,B as r,$ as s,w as t,H as u,le as v,L as w,I as x};