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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{capture-session-doc-KW5VR4IR.js → capture-session-doc-7LQAOCHJ.js} +1 -1
  3. package/dist/{capture-session-v3-DqUUcIU-.d.ts → capture-session-v3-C5DRPBhM.d.ts} +1 -1
  4. package/dist/{capture-session-v3-xNtY5m-7.d.cts → capture-session-v3-Db4n6d-k.d.cts} +1 -1
  5. package/dist/chunk-57VOMVKM.js +1 -0
  6. package/dist/{chunk-4IVRXJR2.js → chunk-5OIC5TZS.js} +1 -1
  7. package/dist/{chunk-U6YQAQBD.js → chunk-H6H2RT6M.js} +1 -1
  8. package/dist/{chunk-YZH5PR5R.js → chunk-IBA5CPDV.js} +1 -1
  9. package/dist/{chunk-EF52BRBD.js → chunk-JRSIMNB5.js} +1 -1
  10. package/dist/chunk-UBDG5IAP.js +1 -0
  11. package/dist/{chunk-OBLQOE66.js → chunk-VJM76LUI.js} +1 -1
  12. package/dist/chunk-WTQE6IGL.js +1 -0
  13. package/dist/chunk-XBVSYVKA.js +1 -0
  14. package/dist/client/index.cjs +1 -1
  15. package/dist/client/index.d.cts +5 -5
  16. package/dist/client/index.d.ts +5 -5
  17. package/dist/client/index.js +1 -1
  18. package/dist/core/index.cjs +1 -1
  19. package/dist/core/index.d.cts +3 -3
  20. package/dist/core/index.d.ts +3 -3
  21. package/dist/core/index.js +1 -1
  22. package/dist/{create-document-capture-PXOJHLWV.js → create-document-capture-RTFDQSBC.js} +1 -1
  23. package/dist/{create-verification-D4749F6L.d.cts → create-verification-BV_T0-CR.d.cts} +33 -12
  24. package/dist/{create-verification-CDOTGHQj.d.ts → create-verification-P6i3tyce.d.ts} +33 -12
  25. package/dist/{icao-gate-BRuIgOE2.d.cts → icao-gate-B0GDH_JS.d.cts} +8 -3
  26. package/dist/{icao-gate-CphntEQ2.d.ts → icao-gate-BP11XO-h.d.ts} +8 -3
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.cts +36 -10
  29. package/dist/index.d.ts +36 -10
  30. package/dist/index.js +1 -1
  31. package/dist/internal/index.cjs +1 -1
  32. package/dist/internal/index.d.cts +7 -6
  33. package/dist/internal/index.d.ts +7 -6
  34. package/dist/internal/index.js +1 -1
  35. package/dist/plan-runner-RVVF5DJV.js +1 -0
  36. package/dist/{types-4rgeNIlz.d.cts → types-DPWT_KMn.d.cts} +38 -11
  37. package/dist/{types-4rgeNIlz.d.ts → types-DPWT_KMn.d.ts} +38 -11
  38. package/package.json +1 -1
  39. package/sbom.cdx.json +7 -7
  40. package/dist/chunk-6DPFJNGL.js +0 -1
  41. package/dist/chunk-IF6YOFFO.js +0 -1
  42. package/dist/chunk-MUVEJRGK.js +0 -1
  43. package/dist/chunk-Y7S7LYCL.js +0 -1
  44. package/dist/plan-runner-2FJLUALJ.js +0 -1
@@ -1 +0,0 @@
1
- import{a as j,c as V,d as L,e as N,f as Ce,g as O,h as U,i as P,j as B,k as x,l as w,m as D,u as _e,v as ke}from"./chunk-IF6YOFFO.js";import{m as ye}from"./chunk-EF52BRBD.js";import{a as he}from"./chunk-GT2ZLGF7.js";import{d as J}from"./chunk-FUHDOEBP.js";import{c as Q,e as ge,f as F}from"./chunk-MUVEJRGK.js";var Ge="https://api.sekyro.ai",Ke=5e3,qe=1500,Ye=10;function We(e){return new Promise(t=>setTimeout(t,e))}function Ze(){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 It(e){return Je(e,{})}function Je(e,t){let i=e.apiOrigin??Ge,o=e.autoRetry??!0,r=e.rearm??"auto",s=t.client??new ge({apiOrigin:i,sessionToken:e.clientToken,fetch:e.fetch}),l=t.sleep??We,a=t.uuid??Ze,h=t.getTurnstileToken??((n,c)=>import("./turnstile-FATNZ4AG.js").then(d=>d.executeTurnstile(n,c))),S=he(),f=null,m=null,u=!1,I=new AbortController,p=null,G=null,v=n=>{p=n,S.emit("view",n),f?.onView(n)},_=()=>p!==null?Promise.resolve(p):(G??(G=s.getSession().then(n=>(v(n),n)).finally(()=>{G=null})),G),b=async()=>{let n=await s.getSession();return v(n),n},K=async(n,c)=>{n.plan!==void 0?v(n):await b()},q=null,te=async n=>{let c=await _();if(!n&&c.consentRecorded)return;let d=await s.recordConsent(e.locale);d.plan!==void 0?v(d):p!==null&&v({...p,consentRecorded:!0})},E=n=>n?.force===!0?te(!0):(q??(q=te(!1).finally(()=>{q=null})),q),Y={client:s,ensureConsent:n=>E(n),sleep:l,uuid:a,onBusy:n=>{u||S.emit("busy",n)}},ne=!1,ie=null,W=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(ne)return;ne=!0}ie=JSON.stringify(n),S.emit("result",n)},we=n=>{ie!==JSON.stringify(n)&&W(n)},oe=async n=>{let c=p;n&&(c=await b().catch(()=>p));let d=c===null?null:O(c);return d!==null&&!u&&S.emit("method",d),d!==null},re=null,se=!1,ae=!1,ce=()=>_e(Y,(n,c)=>n.submitCheck("population_registry",{},{idempotencyKey:c})),le=n=>n.nniBound===!0||x(n,"population_registry")?.nniFromDocument===!0,Ee=async()=>{try{let n=await _();if(P(n)||O(n)!==null||B(n)?.checkType!=="population_registry")return;if(!le(n)&&x(n,"population_registry")?.nniFromDocument===void 0&&(n=await b()),!le(n)){ae=!0;return}await E(),await K(await ce(),"population_registry");let c=p===null?void 0:x(p,"population_registry");if(c?.state==="input_required"&&c.reason==="registry_unavailable"&&N(c)>0){if(await l(Ke),u)return;await K(await ce(),"population_registry")}}catch(n){if(n instanceof Q&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await b().catch(()=>{});return}se=!0;return}p!==null&&P(p)&&W(D(p,{autoRetry:o}))},ue=()=>(re??(re=Ee()),re),Oe=async()=>{let c=(await _()).turnstileSiteKey;return c===null?{sandbox:!0}:{channel:"hosted_web",siteKey:c,turnstileToken:await h(c,{signal:I.signal})}},k=null,de=Promise.resolve(),M=0,Te=async()=>{let n=await _();for(let c=0;c<Ye&&!u&&!P(n)&&B(n)===void 0&&L(n).some(d=>d.state==="processing")&&(await l(qe),!u);c+=1)n=await b();return n},Me=async(n,c,d)=>{let{capture:g}=n,C=()=>u,H=()=>n.alive&&n.attempt===d,me=y=>{H()&&g.setFlowState(y)},A=y=>{if(!C()&&(W(y),!!H())){if(y.status==="retry"&&r==="auto"){g.handle.retry();return}g.setFlowState("done")}};if(c.degraded==="NO_RECORDER"){let y=p?.sessionId??(await _().catch(()=>null))?.sessionId??"";A(w(y,"no_recorder"));return}me("uploading");try{if(await ue(),C())return;let y=await _(),Se;if(!P(y)&&O(y)!==null){await oe(!1),A(w(y.sessionId,"method_required"));return}if(!P(y)){if(B(y)?.checkType==="population_registry"){A(w(y.sessionId,ae?"nni_unbound":se?"network":"registry_unavailable"));return}if(await E(),C())return;Se=p??y;let Z=await ke({...Y,artifacts:c,getAttestation:Oe,getView:()=>p??y,refreshView:b,applySubmit:K,onPhase:me,isCancelled:C,onKeyframePromoted:Fe=>{m=Fe}});if(C())return;if(Z.kind==="unavailable"){A(w(y.sessionId,Z.reason));return}if(Z.kind==="resync"&&await b(),p!==null&&O(p)!==null){await oe(!1),A(w(y.sessionId,"method_required"));return}y=await Te()}A(D(y,{autoRetry:o,previous:Se}))}catch{if(C())return;A(w(p?.sessionId??"","network"))}},Ve=(n,c)=>{let d=n.attempt;M>0&&n.alive&&n.capture.setFlowState("uploading"),M+=1,de=de.then(()=>Me(n,c,d)).finally(()=>{M-=1,M===0&&f?.onChainIdle()}).catch(()=>{})},pe=n=>{k?.capture.handle.destroy(),k!==null&&(k.alive=!1);let c=ye(n,f?.captureInternals?.(n)??t.capture,()=>p?.capture?.liveness?.keyframe?.rank===!0,()=>j(p),()=>p?.capture?.liveness?.screenRamp),d={capture:c,alive:!0,attempt:0};k=d,c.handle.on("state",C=>{C==="starting"&&(d.attempt+=1)}),c.handle.on("captured",C=>{Promise.resolve().then(()=>Ve(d,C))});let g=c.handle;return{get state(){return g.state},get captureMode(){return g.captureMode},get facingMode(){return g.facingMode},on:(C,H)=>g.on(C,H),start:async C=>{if(p===null&&await _().catch(()=>{}),!!d.alive)return g.start(C)},retry:()=>g.retry(),switchCamera:()=>g.switchCamera(),destroy:()=>{d.alive=!1,k===d&&(k=null),g.destroy()}}},De=async()=>{if(u)return null;try{let n=await _();return u?null:O(n)}catch{return null}},He=async()=>{if(u)return"self";try{let n=await _();return u?"self":j(n)}catch{return"self"}},Le=async()=>{if(u)return!1;try{let n=await _();if(u||P(n))return!1;let c=x(n,"liveness");return U(c)&&c?.requiresMobile===!0&&!J()}catch{return!1}},Ne=async()=>{if(u)return!1;try{let n=await _();return!u&&n.returning===!0}catch{return!1}},Ue=async n=>{let c=(await _()).plan?.choice,d=c?.options.find(C=>V[C.service]===n);if(!d)throw new RangeError(`method ${String(n)} is not offered`);let g=await s.choose(c.nodeId,d.id);u||v(g)},fe=null,Be=()=>(fe??(fe=import("./plan-runner-2FJLUALJ.js").then(n=>{let c=n.createPlanRunner({runtime:Y,currentView:()=>p,ensureView:_,refreshView:b,ensureConsent:()=>E(),liveness:pe,chainBusy:()=>M>0,destroyed:()=>u,sleep:l,isMobile:J,now:t.now??Date.now,keptFaceKey:()=>m,setView:v,baseCapture:t.capture,emitStep:d=>{u||S.emit("step",d)},emitResult:we,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto});return f=c,c})),fe);return{consent:()=>E(),startRegistry:ue,methodChoice:De,selectMethod:Ue,reportCameraUnavailable:async n=>{await E();let c=s.reportCameraUnavailable;if(c===void 0)throw new TypeError("this client cannot report a missing camera");let d=await c.call(s,n).catch(g=>{if(g instanceof Q&&g.code==="check_out_of_order")return s.getSession();throw g});u||v(d)},mobileRequired:Le,captureMode:He,returning:Ne,liveness:pe,run:async()=>{if(u)throw new Error("verification destroyed");return(await Be()).run()},currentStep:()=>f?.current()??null,voiceClips:async()=>{if(u)return null;try{let n=await _();return u?null:n.voice??null}catch{return null}},on:(n,c)=>S.on(n,c),destroy:()=>{u=!0,I.abort(),f?.destroy(),k!==null&&(k.alive=!1,k.capture.handle.destroy(),k=null),S.clear()}}}var Pe=["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 Qe=["carte_identite","passport","residence_permit"];function je(e,t){let i=e.byIssuer?.[t]??e.default;return Qe.filter(o=>i==="*"||i.includes(o))}function Ot(e,t=Pe){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(o=>je(e,o).length>0).sort()}function xe(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Tt(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"],$e=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","face_match","aml_screening","face_dedup","age_estimation"]),Xe=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),X=["document","population_registry","national_eid"],z=["phone_otp","email_otp"],be={identity_method:X,contact:z},ze=["population_registry","document"],Re="platform_unsupported",et=new Set(["prefilled","user_entered","prefilled_or_entered"]),tt={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??tt[e.checkType]??null}function nt(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 ee(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=be[i.kind]??[...X,...z],r=i.options.flatMap(a=>a.available===!1||!o.includes(a.service)?[]:[a.nationalEid!=null?{id:a.id,service:a.service,nationalEid:a.nationalEid}:{id:a.id,service:a.service}]),s=t.steps.find(a=>a.id===t.current)?.service,l=i.selected??r.find(a=>a.service===s)?.id??null;return r.some(a=>a.id!==l)?{nodeId:i.nodeId,kind:i.kind,current:l,options:r}:null}function Ie(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function it(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,purpose:e.purpose??"identity"};e.branding!==void 0&&(i.branding=e.branding),e.cameraUnavailableHandled===!0&&(i.cameraUnavailableHandled=!0);let o=ee(e);return o!==null&&(i.switchable=o),i}function ot(e){let t={attemptsRemaining:N(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ae={phone_otp:"phone",email_otp:"email"};function rt(e,t){let i=nt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Ae[i.option.service]}function st(e,t,i,o){let r=t.checkType==="email_otp",s=(r?t.emailOtp:t.otp)??{},l=r?t.emailOtp?.emailSource:t.otp?.numberSource,a=l!==void 0&&et.has(l)?l:r?"prefilled_or_entered":"user_entered",h=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,S=rt(e,r?"email_otp":"phone_otp"),f={key:t.checkType,context:i,section:R(t),phase:h?"verify":"send",canSwitch:S!==void 0,...o},m=r?{kind:"email_otp",...f,emailSource:a,needsEmail:a!=="prefilled"}:{kind:"phone_otp",...f,numberSource:a,needsPhone:a!=="prefilled",channels:(t.otp?.channels??[]).filter(u=>u==="whatsapp"||u==="sms")};return S!==void 0&&(m.switchChannel=S),h&&(m.sentToMasked=s.sentToMasked),!r&&t.otp?.channel!==void 0&&(m.channel=t.otp.channel),s.expiresAt!==void 0&&(m.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(m.resendAvailableAt=s.resendAvailableAt),m}function at(e,t,i,o){let r=e.nniBound===!0?"bound":t.nniFromDocument===!0?"document":"typed",s=r==="typed"&&t.state==="input_required"&&t.reason==="nni_recheck",l=Ie(ee(e)),a=!o.attemptsExhausted&&l.length===1&&l[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:R(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:s,canUseDocument:a,...o}}function ct(e,t,i,o){let r=[...t.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:R(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:xe(e),...o}}function lt(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function ve(e,t,i,o,r){let s=t.icao?.report;return{kind:"portrait",key:`portrait:${r}`,context:i,section:R(t),phase:r,report:Array.isArray(s)?s: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&&lt(e),...o}}var $={minLongSidePx:1280,jpegQuality:.95};function ut(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let o=x(e,"portrait_icao"),r=i.still??$;return{icao:t==="liveness"&&F(e)!==null&&o!==void 0&&o.state==="pending"&&o.reason===void 0,still:{minLongSidePx:r.minLongSidePx??$.minLongSidePx,jpegQuality:r.jpegQuality??$.jpegQuality}}}function dt(e,t,i,o){let r=t.eid,s=R(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:s,checkType:"eid_auth",reason:"update_required"};let l=Ie(ee(e)),a=l.length===1&&ze.includes(l[0]?.service??"")?l[0]:void 0,h=a===void 0?void 0:V[a.service],S=h!==void 0,f={kind:"eid",key:"eid",context:i,section:s,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:S,afterPass:r.afterPass==="continue"?"continue":"end",...o};return S&&(f.cameraMethod=h),r.expiresAt!==void 0&&(f.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(f.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(f.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(f.codeAttemptsRemaining=r.codeAttemptsRemaining),f}function pt(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 ft(e){return L(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function mt(e,t){let i=e.failureReason,o;i===Re?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":ft(e)?o="attempts_exhausted":o="rejected";let r=o==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:D(e,{autoRetry:!1}),s={kind:"result",key:"result",context:t,section:null,display:o,result:r};return i!==void 0&&(s.failureReason=i),e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}function St(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 s of ht){let l=o[s];typeof l=="string"&&l!==""&&(r[s]=l)}return r}var ht=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function T(e,t,i,o){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:t,checkType:i,reason:o}}function yt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function gt(e,t){let i=be[e.kind]??[...X,...z],o=yt(e),r=e.options.flatMap(l=>{if(l.available===!1||!i.includes(l.service))return[];let a={id:l.id,service:l.service};return l.nationalEid!=null&&(a.nationalEid=l.nationalEid),[a]});if(r.length===0){let l=e.options.length>0&&e.options.every(a=>a.service==="nfc");return T(t,o,"choice",l?"platform_unsupported":"update_required")}let s={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(h=>V[h.service]),choice:s},a=r.find(h=>h.nationalEid!==void 0)?.nationalEid;return a!==void 0&&(l.nationalEid=a),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:s}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:o,choice:s}}function Nt(e,t={}){let i=it(e);if(P(e)||e.failureReason===Re)return mt(e,i);let o=e.plan;if(o===void 0||!Array.isArray(o.sections))return T(i,null,"plan","update_required");let r=Ce(e);if(r!==null)return gt(r,i);let s=o.current===null?void 0:o.steps.find(m=>m.id===o.current),l=m=>{let u={kind:"processing",key:"processing",context:i,section:m!==void 0?R(m):o.sections.find(I=>I.state==="current")?.id??null,stalled:!1};return typeof m?.service=="string"&&m.service!==""&&(u.service=m.service),u};if(o.current===null)return l(o.steps.find(m=>m.state==="processing"));if(s===void 0)return T(i,null,"step","update_required");if(!$e.has(s.service))return s.interaction==="server"?l(s):T(i,R(s),s.service,"update_required");if(Xe.has(s.service)||!U(s))return l(s);let a=s,h=ot(a),S=a.checkType,f=R(a);switch(S){case"phone_otp":case"email_otp":return st(e,a,i,h);case"population_registry":return at(e,a,i,h);case"eid_auth":return dt(e,a,i,h);case"doc_ocr":return ct(e,a,i,h);case"identity_confirm":return St(e,i,f)??l(a);case"portrait_icao":return ve(e,a,i,h,"capture");case"liveness":case"face_match":{let m=pt(e,a);if(m!==null)return ve(e,m,i,h,"match");let u=a.requiresMobile===!0,I=F(e);return u&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:f,checkType:S}:{kind:"liveness",key:"biometric",context:i,section:f,mode:S==="face_match"?"selfie":"liveness",requiresMobile:u,instructions:I===null?"standard":"icao",icao:I,livePhoto:ut(e,S),...h}}case"nfc_chip":return T(i,f,S,"platform_unsupported");default:return T(i,f,S,"update_required")}}export{Ge as a,Ke as b,qe as c,Ye as d,Ze as e,It as f,Je as g,Pe as h,Qe as i,je as j,Ot as k,xe as l,Tt as m,Lt as n,Re as o,R as p,ee as q,Ie as r,pt as s,Nt as t};
@@ -1 +0,0 @@
1
- import{e as _}from"./chunk-A3FUGHAH.js";import{a as O,b as B,e as F,f as w,i as U}from"./chunk-6DPFJNGL.js";import{o as A}from"./chunk-73M7LS4H.js";import"./chunk-CJHMFPL6.js";import"./chunk-RI3E7GBN.js";import{A as T,F as x,i as L}from"./chunk-OBLQOE66.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import{x as V}from"./chunk-U6YQAQBD.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-7ZCZY3ZP.js";import"./chunk-BPE5NSQ2.js";import"./chunk-GI3UFGRQ.js";import{a as M,n as I}from"./chunk-IF6YOFFO.js";import"./chunk-EF52BRBD.js";import"./chunk-GT2ZLGF7.js";import"./chunk-YZH5PR5R.js";import"./chunk-FUHDOEBP.js";import"./chunk-POIQGEZM.js";import"./chunk-FHJ7HO3M.js";import"./chunk-FPXL63KZ.js";import{g as H}from"./chunk-MUVEJRGK.js";import"./chunk-4IVRXJR2.js";import"./chunk-OKWG3PVH.js";import"./chunk-DFTCAWMP.js";import"./chunk-DK5YPBDQ.js";function K(e){let a=null,c=Promise.resolve(),u=!1,g=null,y=null,C=null,h=!1,m=()=>{a?.controller.handle.destroy(),a=null},k=()=>{let i=e.currentView(),s=i===null?null:w(i,{isMobile:e.isMobile()});return s?.kind==="portrait"?s:null},P=async(i,s)=>{if(e.destroyed())return;s.setFlowState("uploading"),u=!1;let d=null;try{await e.runner().submit("portrait_icao",async(n,r)=>{if(d===null){let p=await I(n,"image","image/jpeg",i.image.size,{engine:"portrait"});await n.uploadToSpaces(p.uploadUrl,i.image,"image/jpeg"),d=(await n.completeMedia(p.key)).key}s.setFlowState("checking");let l={media:{portrait:d},gate:H(i.gate),...i.tuningVersion!==void 0?{tuningVersion:i.tuningVersion}:{}};return n.submitCheck("portrait_icao",l,{idempotencyKey:r})},()=>{g=d})}catch{u=!0}if(s.setFlowState("done"),e.destroyed())return;let t=k();(t===null||t.phase!=="capture")&&a?.controller===s&&m(),e.runner().republish()},b=i=>e.runner().submit("face_match",(s,d)=>s.submitCheck("face_match",g!==null?{imageKey:g}:{},{idempotencyKey:d})).then(()=>{},()=>{u=!0,i()});return{bind:(i,s)=>{if(i.phase==="match")return m(),y!==i.attemptsRemaining&&!u&&(y=i.attemptsRemaining,b(s)),{...i,uploadFailed:u,resubmit:()=>(u=!1,y=i.attemptsRemaining,s(),b(s)),capture:()=>{throw new Error("the portrait was already accepted")}};y=null;let d=e.keptPortraitInput?.()??null;return d!==null&&(h||d!==C&&i.report===null&&i.reason===void 0&&!i.retakeOnly)?(h||(C=d,h=!0,e.runner().submit("portrait_icao",(t,n)=>t.submitCheck("portrait_icao",d,{idempotencyKey:n}),()=>{g=d.media.portrait}).catch(()=>{}).finally(()=>{h=!1,s()})),{kind:"processing",key:"processing",context:i.context,section:i.section,stalled:!1,refresh:()=>Promise.resolve()}):{...i,uploadFailed:u,resubmit:()=>Promise.resolve(),capture:t=>{if(a!==null&&a.video===t.video)return a.controller.handle;m(),u=!1;let n=A({video:t.video,tuning:i.tuning,tuningVersion:i.tuningVersion,...i.icao!=null?{policy:i.icao.policy}:{},...t.keepScreenAwake!==void 0?{keepScreenAwake:t.keepScreenAwake}:{},...t.assetBaseUrl!==void 0?{assetBaseUrl:t.assetBaseUrl}:{}},e.internals,()=>e.destroyed()?"self":M(e.currentView()));return a={video:t.video,controller:n},n.handle.on("captured",r=>{c=c.then(()=>P(r,n)).catch(()=>{})}),n.handle}}},destroy:m}}function j(e){let a=e;if(typeof a.apiOrigin!="string"||typeof a.sessionToken!="string")return;let c=`${a.apiOrigin}/api/v2/hosted/capture-reports`,u=a.sessionToken;return g=>{try{fetch(c,{method:"POST",headers:{"content-type":"application/json","x-session-token":u},body:JSON.stringify({reports:g}),keepalive:!0}).catch(()=>{})}catch{}}}function E(e){let a=e.apiOrigin;return _("sdk",typeof a=="string"&&/staging|sandbox|localhost/.test(a)?"sandbox":"live")}function ue(e){let a=null,c=null,u=null,g=Promise.resolve(),y=()=>{u?.flow.handle.destroy(),u=null},C=async(t,n)=>{if(e.destroyed())return;n.setFlowState("uploading");let r=null,l,p=!1;try{await a.submit("doc_ocr",async(S,z)=>{if(r===null){let R=await I(S,"image","image/jpeg",t.image.size,{engine:"document"});await S.uploadToSpaces(R.uploadUrl,t.image,"image/jpeg"),r=(await S.completeMedia(R.key)).key}return n.setFlowState("checking"),l===void 0&&(l=n.takeDeviceRead(t)),S.submitCheck("doc_ocr",{imageKey:r,side:t.side,...l!==null?{deviceRead:l}:{}},{idempotencyKey:z})})}catch{p=!0}finally{n.setFlowState("done")}if(e.destroyed())return;if(p){n.settle(t.side,{ok:!1,issue:"technical"});return}let v=e.currentView(),o=v===null?null:w(v,{isMobile:e.isMobile()});if(o?.kind!=="document"){n.settle(t.side,{ok:!0}),u?.flow===n?y():n.handle.destroy();return}if(o.reason==="document_type_not_accepted"){c=null,u?.flow===n&&y(),a.republish();return}t.side==="single"||o.acceptedSides.includes(t.side)||o.reason==="side_missing"?(n.settle(t.side,{ok:!0}),c?.documentType!=="passport"&&n.handle.setSide(o.side)):n.settle(t.side,{ok:!1,issue:"reread"})},h=(t,n)=>({...t,issuer:c?.issuer??null,documentType:c?.documentType??null,captureSide:c===null?null:c.documentType==="passport"?"single":t.side,selectDocument:(r,l)=>{if(!B(t.documents).includes(r)||!O(t.documents,r).includes(l))throw new RangeError(`${l} from ${r} is not accepted`);(c?.issuer!==r||c.documentType!==l)&&y(),c={issuer:r,documentType:l},n()},capture:r=>{if(c===null)throw new Error("selectDocument() first");if(u!==null&&u.video===r.video)return u.flow.handle;y();let l=c,p=l.documentType==="passport"?"single":t.acceptedSides.length>0?t.side:void 0,v=V({video:r.video,documentType:l.documentType,issuer:l.issuer,...p!==void 0?{side:p}:{},...r.keepScreenAwake!==void 0?{keepScreenAwake:r.keepScreenAwake}:{},...r.liveMrz!==void 0?{liveMrz:r.liveMrz}:{}},{...e.documentInternals??{},...(()=>{let o=e.currentView()?.capture?.document,f=e.documentInternals?.blurRefuseSharpnessMax??o?.scan?.blurRefuseSharpnessMax;return{engineOptions:{camera:L(o?.camera),shutter:x(o?.scan),guideLock:T(o?.guide),...e.documentInternals?.engineOptions??{}},...typeof f=="number"&&Number.isFinite(f)&&f>=0&&f<=1?{blurRefuseSharpnessMax:f}:{}}})(),deferRead:!0,...(()=>{let o=e.currentView();if(o===null||e.documentInternals?.webOcr!==void 0)return{};let f=j(e.runtime.client);return{webOcr:{captureDocument:o.capture?.document,salt:o.sessionId,baseUrl:E(e.runtime.client),...f!==void 0?{reports:f}:{}}}})()});return u={video:r.video,flow:v},v.handle.on("captured",o=>{g=g.then(()=>C(o,v)).catch(()=>{})}),v.handle}}),m=null,k=null,P=new Set,b=e.runtime.client;e.runtime.client=new Proxy(b,{get(t,n){if(n==="submitCheck")return(k??t).submitCheck.bind(k??t);let r=Reflect.get(t,n);return typeof r=="function"?r.bind(t):r}});let D=()=>{m?.destroy(),m=null,k=null},i=t=>{let n=e.currentView(),r=n===null?null:w(n,{isMobile:e.isMobile()});if(n===null||r?.kind!=="liveness"||r.livePhoto?.icao!==!0)return;if(m===null){let o=F({tuning:n.capture?.icao??null,tuningVersion:n.capture?.tuningVersion??null,...r.icao!=null?{policy:r.icao.policy}:{},still:r.livePhoto.still,...t.assetBaseUrl!==void 0?{assetBaseUrl:t.assetBaseUrl}:{}},e.livePhotoInternals);m=o,k=o.decorate(b),o.onGate(f=>{for(let S of P)S(f)})}let l=m,p=e.baseCapture??{},v=p.engineOptions?.telemetry;return{...p,engineOptions:{...p.engineOptions??{},measureQuality:l.engineOptions.measureQuality,telemetry:o=>{v?.(o),l.engineOptions.telemetry(o)}}}},s=K({keptPortraitInput:()=>m?.lastPortraitInput()??null,runner:()=>a,currentView:e.currentView,destroyed:e.destroyed,isMobile:e.isMobile,...e.portraitInternals!==void 0?{internals:e.portraitInternals}:{}}),d=U({...e,bindDocument:h,bindPortrait:s.bind,onLivePhoto:t=>(P.add(t),()=>P.delete(t))});return a=d,{...d,captureInternals:i,destroy:()=>{y(),s.destroy(),D(),P.clear()}}}export{ue as createPlanRunner,E as sdkAssetBase};