@sekyro/web 0.1.0-rc.22.1 → 0.1.0-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -2
- package/README.md +2 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/camera-trait-V4UAOPIQ.js +1 -0
- package/dist/{capture-session-doc-VSUEDAEN.js → capture-session-doc-RIBBH3M4.js} +1 -1
- package/dist/{capture-session-v3-DD-MXSU4.d.cts → capture-session-v3-CPHzDT7E.d.cts} +1 -1
- package/dist/{capture-session-v3-C-Q-21Fm.d.ts → capture-session-v3-TUPtnvmu.d.ts} +1 -1
- package/dist/{chunk-XLYHT4ZQ.js → chunk-33KKMPJ5.js} +1 -1
- package/dist/{chunk-J5IQ6THP.js → chunk-5YVQIHQA.js} +1 -1
- package/dist/{chunk-HFCVN6AG.js → chunk-A3FUGHAH.js} +1 -1
- package/dist/chunk-DMOGKGDS.js +1 -0
- package/dist/{chunk-H6REKPZ4.js → chunk-FLA42JCK.js} +1 -1
- package/dist/{chunk-EKEHAFEK.js → chunk-G6LKLN4U.js} +1 -1
- package/dist/chunk-IC6TI6GV.js +1 -0
- package/dist/chunk-IFLOS5OT.js +1 -0
- package/dist/{chunk-NHXLIDQJ.js → chunk-LBH6KGTV.js} +1 -1
- package/dist/{chunk-FSJPKOCC.js → chunk-MQBX4DQQ.js} +1 -1
- package/dist/{chunk-AXJ2VWIK.js → chunk-MXWLCDFX.js} +1 -1
- package/dist/{chunk-6RJTKX5I.js → chunk-QY6TJCOJ.js} +1 -1
- package/dist/{chunk-TYJA2XJR.js → chunk-RI3E7GBN.js} +1 -1
- package/dist/{chunk-RJZ5SARR.js → chunk-SX7TUC3V.js} +1 -1
- package/dist/{chunk-ACP2ZOVW.js → chunk-VWGKUQ3C.js} +1 -1
- package/dist/chunk-XI5FXEKC.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- package/dist/core/ocr/worker.js +1 -1
- package/dist/core/v3/detect-worker.js +1 -1
- package/dist/create-document-capture-XQURFZZK.js +1 -0
- package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
- package/dist/{create-verification-BsZ038gI.d.cts → create-verification-DF60lg8Y.d.cts} +29 -5
- package/dist/{create-verification-CfSZiPSN.d.ts → create-verification-acQzNRiB.d.ts} +29 -5
- package/dist/{detector-scanic-F3Y5X3DF.js → detector-scanic-YCDNLCGV.js} +1 -1
- package/dist/{icao-gate-BrnPW_gd.d.ts → icao-gate-CX0chQMM.d.cts} +8 -1
- package/dist/icao-gate-T3BTOKFJ.js +1 -0
- package/dist/{icao-gate-Bw0Fxd30.d.cts → icao-gate-VwsQo8Bq.d.ts} +8 -1
- package/dist/{icao-policy-C14ZKZ7r.d.ts → icao-policy-B02jDiox.d.ts} +2 -2
- package/dist/{icao-policy-DcaumEDt.d.cts → icao-policy-WnG2OSyp.d.cts} +2 -2
- package/dist/icao-tuning-4ETMF53W.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +6 -6
- package/dist/internal/index.d.ts +6 -6
- package/dist/internal/index.js +1 -1
- package/dist/{landmarker-3BBP3RBY.js → landmarker-KB7LVXAU.js} +1 -1
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/{plan-runner-5UZYQ2XH.js → plan-runner-LDV4PYN7.js} +1 -1
- package/dist/popup/index.js +1 -1
- package/dist/{print-4WOMNRBE.js → print-SEWS3VHQ.js} +1 -1
- package/dist/{turnstile-MX6YN4YH.js → turnstile-52B3RFXD.js} +1 -1
- package/dist/{types-ChKVytm_.d.ts → types-1s8CQrEN.d.cts} +33 -11
- package/dist/{types-ChKVytm_.d.cts → types-1s8CQrEN.d.ts} +33 -11
- package/package.json +1 -1
- package/sbom.cdx.json +10 -10
- package/dist/background-monitor-GCMNCJMG.js +0 -1
- package/dist/camera-trait-HVV5ZEDI.js +0 -1
- package/dist/chunk-PVSYKKMP.js +0 -1
- package/dist/chunk-TTD5LQG2.js +0 -1
- package/dist/chunk-XK4CCTLL.js +0 -1
- package/dist/chunk-ZGDUIZC2.js +0 -1
- package/dist/create-document-capture-D7GUVFWF.js +0 -1
- package/dist/create-portrait-capture-VRZZOMJS.js +0 -1
- package/dist/icao-gate-SO6YJ7RV.js +0 -1
- package/dist/icao-tuning-DCZCMCEQ.js +0 -1
- package/dist/mrz-band-DCXFWDBD.js +0 -1
- /package/dist/{chunk-XB4KLBHY.js → chunk-2LDOXGY3.js} +0 -0
- /package/dist/{chunk-25TEJBSB.js → chunk-53POX7U4.js} +0 -0
- /package/dist/{chunk-CPK5FYNJ.js → chunk-7QZWBDI5.js} +0 -0
- /package/dist/{chunk-YH7DR3PF.js → chunk-CJHMFPL6.js} +0 -0
- /package/dist/{chunk-7KXJEF7P.js → chunk-CPUECYAJ.js} +0 -0
- /package/dist/{chunk-VP37FW6C.js → chunk-DFTCAWMP.js} +0 -0
- /package/dist/{chunk-LYYLXNA4.js → chunk-DK5YPBDQ.js} +0 -0
- /package/dist/{chunk-FK2DJADA.js → chunk-FPXL63KZ.js} +0 -0
- /package/dist/{chunk-UBRNDTTD.js → chunk-FSSMUAKC.js} +0 -0
- /package/dist/{chunk-LL3YYUKR.js → chunk-GI3UFGRQ.js} +0 -0
- /package/dist/{chunk-7TGVXBW6.js → chunk-LJYMZQY2.js} +0 -0
- /package/dist/{chunk-V5P5P3HY.js → chunk-POIQGEZM.js} +0 -0
- /package/dist/{chunk-NYRFUVAR.js → chunk-SMKCBUJL.js} +0 -0
- /package/dist/{chunk-V4VFZ7NQ.js → chunk-TDCLQRT4.js} +0 -0
- /package/dist/{chunk-BPKDXDDH.js → chunk-TDLIXFDT.js} +0 -0
- /package/dist/{chunk-CDDYFUER.js → chunk-TSA6GHUG.js} +0 -0
- /package/dist/{clip-inspect-HZ7N2YOP.js → clip-inspect-DLJXVKV6.js} +0 -0
- /package/dist/{keyframe-rank-R4NPQGN3.js → keyframe-rank-YAJLYJYF.js} +0 -0
- /package/dist/{scanic-ml-stub-XPNKT2N3.js → scanic-ml-stub-KW7IZHUT.js} +0 -0
- /package/dist/{segmenter-3CVPTZMM.js → segmenter-USLNBX65.js} +0 -0
- /package/dist/{upload-file-C4MFKLT3.js → upload-file-UYXOHCRG.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as ke,D as x,E as j,d as K,e as he,f as Se,g as ge,i as ye,j as ee,l as q,m as te,o as be,p as Ce,t as Pe}from"./chunk-QY6TJCOJ.js";import{c as pe,d as me,e as fe}from"./chunk-FPXL63KZ.js";import{c as F,h as Q,i as _e}from"./chunk-XI5FXEKC.js";var Re=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var We=["carte_identite","passport","residence_permit"];function qe(e,t){let i=e.byIssuer?.[t]??e.default;return We.filter(a=>i==="*"||i.includes(a))}function Yt(e,t=Re){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(a=>qe(e,a).length>0).sort()}function Me(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var Qe=640,$e=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ee=6,Ae=1500,Ie={sharpness:1,exposure:1,meanLuma:128},ve=null;function Je(e,t){try{ve??(ve=document.createElement("canvas"));let i=ve,a=96/Math.max(1,t.width);i.width=Math.max(1,Math.round(t.width*a)),i.height=Math.max(1,Math.round(t.height*a));let r=i.getContext("2d");if(r===null)return Ie;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,i.width,i.height);let u=r.getImageData(0,0,i.width,i.height);return{sharpness:me(u),exposure:fe(u),meanLuma:pe(u)}}catch{return Ie}}async function ze(e,t){let i=e.source;return"convertToBlob"in i?i.convertToBlob({type:"image/jpeg",quality:t}):new Promise((a,r)=>{i.toBlob(u=>u===null?r(new Error("encode failed")):a(u),"image/jpeg",t)})}function $t(e,t={}){let i=t.now??(()=>performance.now()),a=t.setTimer??((m,C)=>setTimeout(m,C)),r=t.clearTimer??(m=>clearTimeout(m)),u=t.encode??ze,l=t.quality??Je,c=e.tuningVersion??null,p=new Set,S=!1,y=e.video??null,E=null,f=t.grabFrame??null,b=null,v=1e3/Ee,A=null,I=null,T=!1,N=!1,D=Number.NEGATIVE_INFINITY,M=null,G=0,L=null,B=null,J=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([m,C,R,w,O])=>{let _=C.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);_.background.required&&(I=O.createBackgroundMonitor({tuning:_.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:i})),E=m.createIcaoGate(_,{policy:e.policy??"reject"}),f??(f=R.defaultGrabber()),b=R.observe,v=1e3/Math.min(Ee,_.cadenceHz);let n=(t.createLandmarker??w.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,d)=>{let h=setTimeout(()=>{d(new Error("landmarker init timeout")),n.then(g=>g.close(),()=>{})},w.LANDMARKER_INIT_TIMEOUT_MS);n.then(g=>{clearTimeout(h),s(g)},g=>{clearTimeout(h),d(g)})});S?o.close():A=o}).catch(()=>{T=!0}),H=m=>{for(let C of p)C({holding:N||T,update:m})},Y=()=>{if(M=null,!(S||A===null||E===null||f===null||b===null||y===null)){if(i()-D>Ae){H(null);return}try{let m=f(y,Qe);if(m!==null){let C=Math.max(i(),G+1);G=C;let R=A.detect(m.source,C),w=y.videoWidth||m.width,O=y.videoHeight||m.height,_=b(R,m,w,O);_.geometry!==null&&I!==null&&(_.backgroundCheck=I.measure(m,_.geometry.box,w,O));let n=E.push(_,i());N=n.ready,H(n)}}catch{}M=a(Y,v)}},Z=()=>{let m=i()-D>Ae;D=i(),m&&(E?.reset(),N=!1,L=null,B=null),M===null&&A!==null&&!S&&(M=a(Y,0))},z=()=>{let m=f===null||y===null?null:f(y,null);if(m===null||E===null||Math.max(m.width,m.height)<e.still.minLongSidePx)return Promise.resolve(null);let C=E.summary();return u(m,e.still.jpegQuality).then(R=>({image:R,width:m.width,height:m.height,gate:C}),()=>null)},W=null;return{engineOptions:{measureQuality:(m,C)=>{y=m,Z();let R=l(m,C);return N||T?R:{...R,sharpness:0}},telemetry:m=>{if(m.type!=="fired"||S)return;L=z();let C=W;C!==null&&L.then(R=>R===null?void 0:C(R).catch(()=>{})),N=!1,M!==null&&r(M),M=null,D=Number.NEGATIVE_INFINITY}},decorate:m=>{let C=new WeakMap,R=new Map,w=o=>{let s=C.get(o);return s===void 0&&(s=(async()=>{let d=await Pe(m,"image","image/jpeg",o.image.size,{engine:"portrait"});return await m.uploadToSpaces(d.uploadUrl,o.image,"image/jpeg"),(await m.completeMedia(d.key)).key})(),s.catch(()=>C.delete(o)),C.set(o,s)),s};W=w;let O=async o=>{let s;try{s=await w(o)}catch(d){let h=d?.code;if(typeof h=="string"&&$e.has(h))throw d;return null}return{media:{portrait:s},gate:_e(o.gate),...c!==null?{tuningVersion:c}:{}}},_=m.submitCheck.bind(m),n=(async(o,s,d)=>{if(o!=="liveness")return _(o,s,d);let h=d?.idempotencyKey,g=h===void 0?void 0:R.get(h);if(g===void 0){let de=L;g=de===null?Promise.resolve(null):de.then(le=>le===null?null:O(le)),h!==void 0&&(R.set(h,g),g.catch(()=>R.delete(h)))}let P=await g;if(P===null)return _("liveness",s,d);let k=await _("liveness",{...s,portraitIcao:P},d);return B=P,k});return new Proxy(m,{get(o,s){if(s==="submitCheck")return n;let d=Reflect.get(o,s);return typeof d=="function"?d.bind(o):d}})},onGate:m=>(p.add(m),()=>p.delete(m)),lastPortraitInput:()=>B,destroy:()=>{S=!0,L=null,B=null,M!==null&&r(M),M=null,p.clear(),J.then(()=>{A?.close(),A=null,I?.close(),I=null})}}}function Te(e){return e.idNumberBound??e.nniBound}function Oe(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function we(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var xe=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Xe=new Map(Object.entries(xe)),Xt=new Map(Object.entries(xe).map(([e,t])=>[t,e]));function Ne(e){return Xe.get(e)??e}var et=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),tt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ie=["document","population_registry","national_eid"],oe=["phone_otp","email_otp"],De={identity_method:ie,contact:oe},nt=["population_registry","document"],re="platform_unsupported",it=new Set(["prefilled","user_entered","prefilled_or_entered"]),ot={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 V(e){return e.section??ot[e.checkType]??null}function se(e,t){let i=e.plan?.choice;if(i===void 0||i.locked)return;let a=i.options.find(r=>r.id!==i.selected&&r.available!==!1&&t.includes(r.service));return a===void 0?void 0:{nodeId:i.nodeId,option:a}}function ae(e){let t=e.plan,i=t?.choice;if(t===void 0||i===void 0||i.locked||t.current===null||t.current===i.nodeId||ee(e))return null;let a=De[i.kind]??[...ie,...oe],r=i.options.flatMap(c=>c.available===!1||!a.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),u=t.steps.find(c=>c.id===t.current)?.service,l=i.selected??r.find(c=>c.service===u)?.id??null;return r.some(c=>c.id!==l)?{nodeId:i.nodeId,kind:i.kind,current:l,options:r}:null}function He(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function rt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:i,skipCapture:a}=t;return typeof i=="string"&&i!==""&&typeof a=="boolean"?{otpCode:i,skipCapture:a}:void 0}function st(e){let t=(e.plan?.sections??[]).map(l=>({id:l.id,state:l.state})),i={sessionId:te(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(l=>l.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(i.branding=e.branding),e.cameraUnavailableHandled===!0&&(i.cameraUnavailableHandled=!0);let a=rt(e);a!==void 0&&(i.simulation=a);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(i.testerGate={attemptsLeft:r.attemptsLeft});let u=ae(e);return u!==null&&(i.switchable=u),i}function at(e){let t={attemptsRemaining:Se(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ge={phone_otp:"phone",email_otp:"email"};function ct(e,t){let i=se(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Ge[i.option.service]}function ut(e,t,i,a){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},l=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=l!==void 0&&it.has(l)?l:r?"prefilled_or_entered":"user_entered",p=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,S=u.prefilled===!0,y=ct(e,r?"email_otp":"phone_otp"),E={key:t.checkType,context:i,section:V(t),phase:p?"verify":"send",canSwitch:y!==void 0,...a},f=r?{kind:"email_otp",...E,emailSource:c,needsEmail:c!=="prefilled"&&!S}:{kind:"phone_otp",...E,numberSource:c,needsPhone:c!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(b=>b==="whatsapp"||b==="sms")};if(y!==void 0&&(f.switchChannel=y),S&&(f.prefilled=!0),p&&(f.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(f.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(f.phoneCountries=t.phoneCountries.filter(b=>typeof b=="string"&&/^[A-Z]{2}$/.test(b))),!r&&Array.isArray(t.phoneRules)){let b=f.phoneCountries??[];f.phoneRules=t.phoneRules.flatMap(v=>{let A=pt(v);return A!==void 0&&b.includes(A.code)?[A]:[]})}return!r&&t.phoneInternational===!0&&(f.phoneInternational=!0),u.expiresAt!==void 0&&(f.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(f.resendAvailableAt=u.resendAvailableAt),f}var dt=/^[\d[\]\-|()?:^]{1,64}$/;function lt(e){try{return typeof e=="string"&&dt.test(e)&&new RegExp(e)!==null}catch{return!1}}var Le=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function pt(e){let{code:t,dial:i,trunk:a,lengths:r,formats:u}=e??{};if(typeof t!="string"||typeof i!="string"||!/^\d{1,3}$/.test(i)||a!==void 0&&(typeof a!="string"||!/^\d{1,3}$/.test(a))||!Array.isArray(r)||r.length===0||!r.every(Le))return;let l={code:t,dial:i,lengths:[...r].sort((c,p)=>c-p)};if(a!==void 0&&(l.trunk=a),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(p=>lt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(Le)&&r.includes(p.groups.reduce((S,y)=>S+y,0)))))return;l.formats=u.map(p=>({leading:p.leading,groups:[...p.groups]}))}return l}function mt(e,t,i,a){let r=Te(e)===!0?"bound":Oe(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&Ne(t.reason)==="id_number_recheck",l=He(ae(e)),c=!a.attemptsExhausted&&l.length===1&&l[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:c,...a}}function ft(e,t,i,a,r){let u=[...t.acceptedSides??[]],l={kind:"document",key:"document",context:i,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Me(e),photo:Ue(Be(e.documents),r),...a};return e.detectedCountry!==void 0&&(l.detectedCountry=e.detectedCountry),ht(e)&&(l.ageStepUp=!0),l}function Be(e,t=!0){let i=e?.source==="upload"||e?.source==="choice"?e.source:"camera",a=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:i,pick:a,uploadOffered:t&&e?.uploadOffered===!0}}function Ue(e,t){return t?{...e,cameraOnPhone:!0}:e}function ht(e){let t=he(e).find(a=>a.checkType==="age_estimation"),i=t?.reason;return t?.state==="failed"&&(i==="age_uncertain"||i==="age_unavailable")}function St(e){let t=q(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ve(e,t,i,a,r,u=!1){let l=t.icao?.report,c=e.portrait,p=r==="capture"?c?.pendingFix??null:null;p!==null&&(r="review");let S=Fe(e);return{kind:"portrait",key:`portrait:${r}`,context:i,section:V(t),phase:r,report:Array.isArray(l)?l:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:Q(e),retakeOnly:r==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&St(e),photo:Ue(Be(c,r==="capture"),u&&r==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...a}}function Fe(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function gt(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let a=q(e,"portrait_icao"),r=i.still??ne;return{icao:t==="liveness"&&Q(e)!==null&&Fe(e)===void 0&&a!==void 0&&a.state==="pending"&&a.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ne.minLongSidePx,jpegQuality:r.jpegQuality??ne.jpegQuality}}}function yt(e,t,i,a){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:u,checkType:"eid_auth",reason:"update_required"};let l=He(ae(e)),c=l.length===1&&nt.includes(l[0]?.service??"")?l[0]:void 0,p=c===void 0?void 0:K[c.service],S=p!==void 0,y={kind:"eid",key:"eid",context:i,section:u,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",...a};return S&&(y.cameraMethod=p),r.expiresAt!==void 0&&(y.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(y.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(y.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(y.codeAttemptsRemaining=r.codeAttemptsRemaining),y}function bt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let i=q(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}var Ct={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function Pt(e){return e.reasonCode===re?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?Ct[e.reason]:void 0)??"rejected"}function kt(e,t){let i=Pt(e),a=i==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable",reasonCode:re}:be(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:i,result:a};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function _t(e,t,i){let a=e.identitySummary;if(a==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:i??"identity",summaryKind:a.kind==="partial"?"partial":a.kind??"full",source:a.source,portraitAvailable:a.portrait?.available===!0,retakeAvailable:a.retakeAvailable===!0};for(let l of Rt){let c=a[l];typeof c=="string"&&c!==""&&(r[l]=c)}let u=we(a);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var Rt=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function U(e,t,i,a){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:t,checkType:i,reason:a}}function Mt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Et(e,t){let i=De[e.kind]??[...ie,...oe],a=Mt(e),r=e.options.flatMap(l=>{if(l.available===!1||!i.includes(l.service))return[];let c={id:l.id,service:l.service};l.nationalEid!=null&&(c.nationalEid=l.nationalEid);let p=(l.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return l.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(r.length===0){let l=e.options.length>0&&e.options.every(c=>c.service==="nfc");return U(t,a,"choice",l?"platform_unsupported":"update_required")}let u={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:a,options:r.map(p=>K[p.service]),choice:u},c=r.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(l.nationalEid=c),l}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:a,options:r.map(l=>Ge[l.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:a,choice:u}}function $(e,t={}){let i=st(e);if(ee(e)||e.reasonCode===re)return kt(e,i);let a=e.plan;if(a===void 0||!Array.isArray(a.sections))return U(i,null,"plan","update_required");let r=ge(e);if(r!==null)return Et(r,i);let u=a.current===null?void 0:a.steps.find(f=>f.id===a.current),l=f=>{let b={kind:"processing",key:"processing",context:i,section:f!==void 0?V(f):a.sections.find(v=>v.state==="current")?.id??null,stalled:!1};return typeof f?.service=="string"&&f.service!==""&&(b.service=f.service),b};if(a.current===null)return l(a.steps.find(f=>f.state==="processing"));if(u===void 0)return U(i,null,"step","update_required");if(!et.has(u.service))return u.interaction==="server"?l(u):U(i,V(u),u.service,"update_required");if(tt.has(u.service)||!ye(u))return l(u);let c=u,p=at(c),S=c.checkType,y=V(c),E=t.isMobile===!1?Ce(e,c):null;if(E==="phone")return{kind:"mobile_required",key:"mobile_required",context:i,section:y,checkType:S};switch(S){case"phone_otp":case"email_otp":return ut(e,c,i,p);case"population_registry":return mt(e,c,i,p);case"eid_auth":return yt(e,c,i,p);case"doc_ocr":return ft(e,c,i,p,E==="upload_or_phone");case"identity_confirm":return _t(e,i,y)??l(c);case"portrait_icao":return Ve(e,c,i,p,"capture",E==="upload_or_phone");case"liveness":case"face_match":{let f=bt(e,c);if(f!==null)return Ve(e,f,i,p,"match");let b=c.requiresMobile===!0,v=Q(e);return{kind:"liveness",key:"biometric",context:i,section:y,mode:S==="face_match"?"selfie":"liveness",requiresMobile:b,instructions:v===null?"standard":"icao",icao:v,livePhoto:gt(e,S),...p}}case"nfc_chip":return U(i,y,S,"platform_unsupported");default:return U(i,y,S,"update_required")}}var At=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,It=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>At.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"});function vt(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var Tt=Object.freeze({normalize:e=>e.trim(),check:e=>vt(e),registrySources:Object.freeze(["MR.anrpts"]),describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}),Ot=Object.freeze({"MR:national_id":Tt});function ce(e,t){return Ot[`${e.toUpperCase()}:${t}`]??It}var wt=Object.freeze({MRT:"MR"});function Ke(e,t){let i=e.trim().toUpperCase();return ce(wt[i]??i,t)}function je(e){let t=Ke(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function Ye(e){return ce("MR","national_id").check(e)}function ue(e){let t="";for(let i of e){let a=i.codePointAt(0)??0;a>=1632&&a<=1641?t+=String(a-1632):a>=1776&&a<=1785?t+=String(a-1776):i!==" "&&i!=="-"&&i!==" "&&(t+=i)}return t}var xt=[1e3,2e3,4e3,8e3,15e3],Nt=3e4,Lt=/^\+[1-9]\d{6,14}$/,Vt=/^\d{6}$/,Dt=/^\d{6}$/,Ht=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ze=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"]),Gt={simulatedCapture:!0},Bt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function yn(e){let t=!1,i=null,a="",r=!1,u=!1,l=!1,c={},p={},S=new Set,y=!1,E=!1,f=null,b="idle",v=new Map,A=new Map,I=(n,o,s)=>{let d=`${n}.${o}`,h=v.get(d);if(h!==void 0)return h;let g=A.get(n),P=(g===void 0?s():g.then(s)).finally(()=>{v.delete(d)});v.set(d,P);let k=P.then(()=>{},()=>{});return A.set(n,k),k.then(()=>{A.get(n)===k&&A.delete(n)}),P},T=async(n,o,s)=>{await e.ensureConsent();let d;try{d=await ke(e.runtime,o)}catch(g){if(g instanceof F&&Ze.has(g.code)){await e.refreshView();return}throw g}if(s?.(d),e.destroyed())return;let h=d;h.plan!==void 0&&e.setView!==void 0?e.setView(h):await e.refreshView()},N=async n=>{await e.ensureConsent();let o;try{try{o=await n(e.runtime.client)}catch(s){if(!(s instanceof F)||s.code!=="consent_required")throw s;await e.runtime.ensureConsent({force:!0}),o=await n(e.runtime.client)}}catch(s){if(s instanceof F&&Ze.has(s.code)){await e.refreshView();return}throw s}e.destroyed()||(o!==void 0&&e.setView!==void 0?e.setView(o):await e.refreshView())},D=(n,o)=>I("choice",`${n}:${o}`,()=>N(s=>s.choose(n,o))),M=(n,o)=>n.options.some(s=>s.id===o)?D(n.nodeId,o):Promise.reject(new RangeError(`option ${String(o)} is not offered`)),G=(n,o)=>{let s=e.currentView(),d=s===null?void 0:se(s,n);return d===void 0?Promise.reject(new RangeError(`the ${o} is not offered`)):D(d.nodeId,d.option.id)},L=n=>I("identity",n,()=>N(o=>o.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):o.confirmIdentity(n))),B=(n,o)=>{let s=n.kind,d=s==="phone_otp",h=d?"phone":"email",g={action:"send"};if(d?n.needsPhone:n.needsEmail){let P=o[h]??p[s],k=d?P?.replace(/[\s().-]/g,""):P?.trim();if(k!==void 0||n.phase!=="verify"){if(k===void 0||!(d?Lt:Ht).test(k))return Promise.reject(d?new x("phone","format"):new j("email","format"));g[h]=k}}if(d){let P=n.channels,k=o.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(k===void 0)return Promise.reject(new j("channel","required"));if(!P.includes(k))return Promise.reject(new j("channel","unavailable"))}k!==void 0&&(g.channel=k),g.phoneRules=1}return I(s,"send",()=>T(s,(P,k)=>P.submitCheck(s,g,{idempotencyKey:k}),P=>{Ft(P,s)||(c[s]=e.now(),g[h]!==void 0&&(p[s]=g[h]))}))},J=(n,o)=>Vt.test(o)?I(n,"verify",()=>T(n,(s,d)=>s.submitCheck(n,{action:"verify",code:o},{idempotencyKey:d}))):Promise.reject(new x("code","format")),H=(n,o)=>I("eid_auth",n,()=>T("eid_auth",(s,d)=>s.submitCheck("eid_auth",o,{idempotencyKey:d}))),Y=(n,o)=>{if(n.identifierBound)return H("start",{action:"start"});let s=ue(o??"");if(n.country==="MR"){if(!/^\d{10}$/.test(s))return Promise.reject(new x("nni","format"));if(!Ye(s))return Promise.reject(new x("nni","check_digit"))}else if(s==="")return Promise.reject(new x("nni","format"));return H("start",{action:"start",identifier:s})},Z=(n,o,s)=>{if(n.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let d=ue(o);return/^\d{10}$/.test(d)?je({type:"national_id",issuingCountry:"MR",number:d})?I("population_registry","submitIdNumber",()=>T("population_registry",(h,g)=>h.submitCheck("population_registry",{idNumber:d,nni:d},{idempotencyKey:g}),()=>{f=`\u2022\u2022\u2022\u2022\u2022\u2022${d.slice(-4)}`})):Promise.reject(new x(s,"check_digit")):Promise.reject(new x(s,"format"))},z=n=>(e.stopCameras?.(),I(n,"skipCapture",()=>T(n,(o,s)=>o.submitCheck(n,Gt,{idempotencyKey:s}),()=>{(n==="liveness"||n==="portrait_icao")&&(y=!0)}))),W=n=>{if(n.kind==="result"||n.context.simulation?.skipCapture!==!0)return n;let o=Ut(n);return o===null?n:{...n,skipCapture:()=>z(o)}},X=n=>((n.kind==="document"||n.kind==="portrait")&&n.photo?.cameraOnPhone===!0&&(n.refresh=async()=>{await e.refreshView()}),n),m=n=>{switch(n.kind){case"phone_otp":case"email_otp":{let o={...n,send:(d={})=>B(n,d),verify:d=>J(n.kind,d),switchTo:()=>n.canSwitch&&n.switchChannel!==void 0?G([n.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},s=c[n.kind];return o.resendAvailableAt===void 0&&s!==void 0&&(o.resendAvailableAt=new Date(s+Nt).toISOString()),o}case"eid":return{...n,start:o=>Y(n,o),verify:o=>Dt.test(o)?H("verify",{action:"verify",code:o}):Promise.reject(new x("code","format")),resend:()=>n.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):H("resend",{action:"resend"}),useCamera:()=>n.canUseCamera&&n.cameraMethod!==void 0?G(n.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...n,select:o=>{let s=n.choice.options.find(d=>K[d.service]===o);return s!==void 0?M(n.choice,s.id):Promise.reject(new RangeError(`method ${String(o)} is not offered`))},choose:o=>M(n.choice,o)};case"choice":return{...n,choose:o=>M(n.choice,o)};case"registry":return{...n,submitIdNumber:o=>Z(n,o,"idNumber"),submitNni:o=>Z(n,o,"nni"),confirm:()=>I("population_registry","confirm",()=>T("population_registry",(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s}))),useDocument:()=>n.canUseDocument?G(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?X(e.bindDocument(n,_)):{...n,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")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?X(e.bindPortrait(n,_)):{...n,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"contact_choice":return{...n,select:o=>{let s=o==="phone"?"phone_otp":o==="email"?"email_otp":void 0,d=n.choice.options.find(h=>h.service===s);return d!==void 0?M(n.choice,d.id):Promise.reject(new RangeError(`contact ${String(o)} is not offered`))},choose:o=>M(n.choice,o)};case"identity_summary":return{...n,...n.idNumberMasked===void 0&&n.summaryKind==="partial"&&f!==null?{idNumberMasked:f,nniMasked:f}:{},portrait:async()=>{let o=e.runtime.client;if(!n.portraitAvailable||o.identityPortrait===void 0)return null;try{return await o.identityPortrait()}catch{return null}},confirm:()=>L("confirm"),retake:()=>n.retakeAvailable?L("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...n,capture:o=>e.liveness(o),onLivePhoto:o=>n.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(o):()=>{}};case"mobile_required":case"processing":return{...n,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...n};default:{let o=n;throw new Error(`runner: unhandled step ${JSON.stringify(o)}`)}}},C=n=>W(m(n)),R=async()=>{if(!u){u=!0;try{for(let n of xt){if(await e.sleep(n),!t||e.destroyed())return;let o=await e.refreshView().catch(()=>null);if(o!==null&&$(o,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,_()}finally{u=!1}}},w=n=>{if(n.kind!=="liveness"||n.mode!=="selfie")return null;let o={kind:"processing",key:"processing",context:n.context,section:n.section,stalled:!1};if(b==="inflight")return o;if(!E||b==="done")return null;let s=e.keptFaceKey?.()??null;return s===null?null:(b="inflight",T("face_match",(d,h)=>d.submitCheck("face_match",{imageKey:s},{idempotencyKey:h}),()=>{b="done"}).then(()=>{b==="inflight"&&(b="done",_())},()=>{b="done",_()}),o)},O=(n,o=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let s=$(n,{isMobile:e.isMobile()});s.kind==="registry"&&s.recheck&&(E=!0,b="idle"),s=w(s)??s,s.kind==="processing"?s.stalled=r:r=!1;let d=C(s),h=s.kind==="result"?void 0:s.context.switchable,g=h===void 0?d:{...d,chooseOption:k=>M({nodeId:h.nodeId,kind:h.kind,selected:h.current,options:h.options},k)},P=JSON.stringify(g);s.kind==="registry"&&s.source==="document"&&s.state==="pending"&&!S.has("registry")&&(S.add("registry"),g.confirm().catch(k=>{(!(k instanceof F)||Bt.has(k.code))&&S.delete("registry")})),!(!o&&P===a)&&(a=P,i=g,e.emitStep(g),s.kind==="processing"&&!r&&b!=="inflight"&&R(),s.kind==="result"&&!l&&(l=!0,e.emitResult(s.result)))};function _(){let n=e.currentView();n!==null&&O(n,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let n=await e.ensureView();return i===null&&O(n),i??C($(n,{isMobile:e.isMobile()}))},current:()=>i,onView:n=>O(n),onChainIdle:()=>{let n=e.currentView();n!==null&&O(n)},republish:_,submit:T,faceProbeSkipped:()=>y}}function Ut(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"mobile_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function Ft(e,t){let i=e,a=i?.plan?.steps??i?.steps;return Array.isArray(a)?a.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{qe as a,Yt as b,Ee as c,Ae as d,$t as e,Fe as f,$ as g,xt as h,Nt as i,yn as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="0.1.0-rc.24";var T=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function p(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return T.test(e)}var h="sekyro.did",P=1e4,v=()=>globalThis.process?.versions?.node,y;function b(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function I(){try{let t=localStorage.getItem(h);if(t)return t;let e=b();return e!==void 0&&localStorage.setItem(h,e),e}catch{return y??(y=b()),y}}async function w(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function k(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function x(t){let e=new TextEncoder().encode(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function A(t){let e,r,i,o,a,l,u=()=>l?.readyState==="live",_=()=>{a!==void 0||!globalThis.crypto?.subtle||v()||u()||(a=Promise.race([import("./print-SEWS3VHQ.js"),new Promise(n=>setTimeout(n,P))]).then(n=>n?.computePrint(u)).then(n=>{n==="busy"?a=void 0:o=n}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},noteCamera(n){r=n},noteCameraTrack(n){l=n},async deviceHeader(){try{i??(i=w().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let g=await i,m=I(),S={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...k(),...e?{cameraLabel:e}:{},...n.length?{signals:n}:{},...o?{print:{v:2,...o,...r?{camera:r}:{}}}:{},...p()?{inApp:!0}:{}},C=x(JSON.stringify(S));return _(),C}catch{return}},printReady(){return a??Promise.resolve()}}}var s=Symbol.for("sekyro.web.clientContext"),c=globalThis,d=c[s]??(c[s]=A({sdk:`@sekyro/web@${f}`}));function M(t){try{let e=t.getVideoTracks?.()[0];if(e){if(d.noteCameraLabel(e.label),d.noteCameraTrack(e),v())return;import("./camera-trait-V4UAOPIQ.js").then(r=>r.noteCameraTrait(e,d)).catch(()=>{})}}catch{}}export{f as a,p as b,d as c,M as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y,d as ee,e as O,f as te,g as ne}from"./chunk-
|
|
1
|
+
import{a as Y,d as ee,e as O,f as te,g as ne}from"./chunk-7QZWBDI5.js";import{C as X,a as j}from"./chunk-5YVQIHQA.js";import{f as Q,l as Z}from"./chunk-CPUECYAJ.js";import{c as $}from"./chunk-TSA6GHUG.js";import{c as J,h as C}from"./chunk-FSSMUAKC.js";var ue=12e4,re=13e4,le=3e3,fe=1200,P=Symbol.for("@sekyro/web.preload.v1");function g(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function S(e){let n=(e??J).replace(/\/+$/,"");return n===""?"/":n}function se(e){let n=g(),r=n.get(e);return r===void 0&&(r={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},n.set(e,r)),r}function A(e,n){if(e.status!==n){e.status=n;for(let r of[...e.listeners])r(n)}}var x=e=>C({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:ue}),F=x;function Pe(e){F=e??x}function Ae(){for(let e of g().values())e.detector?.destroy();g().clear(),F=x}function pe(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function me(){return navigator.connection?.saveData===!0}function ve(e){let n=window;if(typeof n.requestIdleCallback=="function"){let s=n.requestIdleCallback(e,{timeout:le});return()=>n.cancelIdleCallback?.(s)}let r=setTimeout(e,fe);return()=>clearTimeout(r)}function ge(e,n){let r,s=new Promise(i=>{r=i}),m=!1,d=()=>{},u={promise:s,settle:i=>{m||(m=!0,d(),e.scheduled===u&&(e.scheduled=null),r(i))}};return e.scheduled=u,d=ve(()=>{m||u.settle(I(e,n))}),s}function I(e,n){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let r=new Promise(i=>i(F(n)));e.detectorPromise=r;let s,m=new Promise((i,f)=>{s=setTimeout(()=>{r.then(h=>h.destroy(),()=>{}),f(new Error(`detector preload exceeded ${re} ms`))},re)}),u=Promise.race([r,m]).then(i=>e.detectorPromise!==r?(i.destroy(),e.status):(e.detector=i,A(e,"ready"),"ready"),i=>(e.detectorPromise===r&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",i)),e.status)).finally(()=>clearTimeout(s));return e.promise=u,e.scheduled?.settle(u),u}function we(e={}){if(!pe())return Promise.resolve("idle");let n=S(e.assetBaseUrl),r=se(n);return e.respectSaveData===!0&&me()?Promise.resolve(r.status):(r.status==="loading"||r.status==="ready")&&r.promise!==null?r.promise:e.idle===!0?r.scheduled?.promise??ge(r,n):I(r,n)}function ke(e){return g().get(S(e))?.status??"idle"}function De(e,n){let r=se(S(n));return r.listeners.add(e),()=>{r.listeners.delete(e)}}function _e(e){let n=g().get(S(e));n!==void 0&&(n.scheduled?.settle("idle"),n.detector?.destroy(),n.detector=null,n.detectorPromise=null,n.promise=null,A(n,"idle"))}function he(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...n)=>e.detect(...n),destroy:()=>{}}}function oe(e){let n=S(e),r=g().get(n);if(!(r===void 0||r.detector===null&&r.detectorPromise===null&&r.scheduled===null))return async()=>{r.scheduled!==null&&I(r,n);let s=r.promise;for(;r.detector===null&&s!==null&&(await s,r.promise!==s);)s=r.promise;return r.detector!==null?he(r.detector):C({v3AssetBaseUrl:n})}}function Ce(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";case"fcv3.one_face":return"one_face";default:return null}}function Se(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function ie(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;case"backcamera":return"notfound";default:{let n=e;return"generic"}}}function Le(e,n,r){if(r===void 0)return{kind:ie(e),retryable:n};let s=Z(r.name);return{kind:ie(e),retryable:n,detail:{...s!==void 0?{name:s}:{},phase:r.phase,engineKind:e}}}var ye=new Set(["captured","uploading","checking"]);function Ee(e,n={},r,s=()=>"self",m=()=>{},d){let u=n.now??(()=>performance.now()),i=n.canChooseFacing??ee,f="user",h=te(),p=s(),l=Y(),B=!Q(),H=n.engineOptions,ae=H?.createDetector===void 0&&H?.createWorker===void 0?{createDetector:()=>{let t=oe(e.assetBaseUrl);return t!==void 0?t():C({v3AssetBaseUrl:e.assetBaseUrl})}}:{},U={video:e.video,mode:B?"photo":"clip",rankKeyframes:r,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,screenRamp:()=>p==="self"&&l.count("ramp")>0?m():void 0,...n.engineOptions??{},...ae},o=n.createEngine?.(U)??new X(U),v="idle",L=null,y=0,w=!1,k="full",E=null,b=null,D=0,_=0,K=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(D=e.video.videoWidth,_=e.video.videoHeight)},V=ne({enabled:e.keepScreenAwake!==!1}),M=t=>{v=t,V.setActive(t==="starting"||t==="gating"||t==="recording"),l.emit("state",t)},R=()=>l.emit("gate",{progress:y,hint:L,faceDetected:w}),G=()=>{let t=o.animations??"full";t!==k&&(k=t,l.emit("profile",{animations:k}))},de=[o.on("statechange",({state:t})=>{let a=Se(t);a==="starting"&&v!=="starting"&&(L=null,y=0,w=!1,E=null,b=null,D=0,_=0),M(a),G(),a==="recording"&&(K(),E=u(),L="hold",y=1,R())}),o.on("checks",t=>{K(),y=t.progress,w=t.factors.presence>0,R(),G()}),o.on("guidance",({key:t})=>{L=Ce(t),R()}),o.on("frozen",({previewDataUrl:t})=>{b=u(),l.emit("frozen",{previewDataUrl:t})}),o.on("ramp",t=>l.emit("ramp",t)),o.on("artifacts",t=>{if(v!=="captured")return;let a=$(),c=t.clipStats,q=c!==void 0?Math.round(c.durationMs):E!==null&&b!==null?Math.max(0,Math.round(b-E)):void 0,N=c!==void 0&&c.frames>1&&c.durationMs>0?Math.round(c.frames*1e4/c.durationMs)/10:void 0;l.emit("captured",{keyframe:t.keyframe,...t.clip!==void 0?{clip:t.clip}:{},...t.clipMimeType!==void 0?{clipMime:t.clipMimeType}:{},width:e.video.videoWidth||D,height:e.video.videoHeight||_,...q!==void 0?{clipMs:q}:{},...c!==void 0?{clipFrames:c.frames}:{},...N!==void 0?{fps:N}:{},...t.clipRetakes!==void 0?{clipRetakes:t.clipRetakes}:{},...t.clipMimeType!==void 0?{codec:j(t.clipMimeType)}:{},captureChannel:a==="desktop"?"desktop":"mobile",formFactor:a,...B?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:o.facingMode,mode:p,...t.timing,...t.screenRamp!==void 0?{screenRamp:t.screenRamp}:{},...t.provenance!==void 0?{provenance:t.provenance}:{}})}),o.on("error",({kind:t,retryable:a,detail:c})=>{t==="backcamera"&&ce()||l.emit("error",Le(t,a,c))})],z=!1;function ce(){return T||z||p!=="assisted"||d===void 0||d.session()!=="choice"?!1:(z=!0,d.onModeChange("self"),p="self",f=O("self"),M("mode_switch"),o.restart(f),!0)}let W=async()=>d!==void 0&&d.session()==="choice"&&await i().catch(()=>!1),T=!1;return{handle:{get state(){return v},get captureMode(){return s()},get facingMode(){return o.facingMode??f},on:(t,a)=>l.on(t,a),start:t=>(p=s(),h.facing(p,e.facing),f=h.facing(p,t?.facing),o.start({facingMode:f})),retry:()=>o.retry(),switchCamera:()=>h.refuseSwitch(s()),canSwitchCaptureMode:W,setCaptureMode:async t=>{if(t===s()||!await W()||T||ye.has(v)||d===void 0)return!1;d.onModeChange(t),p=t;let a=O(t);return f=a,v==="idle"||(M("mode_switch"),o.restart(a)),!0},destroy:()=>{T=!0;for(let t of de)t();V.setActive(!1),o.destroy(),l.clear()}},setFlowState:t=>{v!==t&&M(t)}}}function ze(e){return Ee(e).handle}export{ue as a,re as b,Pe as c,Ae as d,we as e,ke as f,De as g,_e as h,oe as i,Ce as j,Se as k,ie as l,Le as m,Ee as n,ze as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as J,h as he,i as ye,j as Se,l as Me}from"./chunk-EKEHAFEK.js";import{f as be}from"./chunk-BPKDXDDH.js";import{m as V}from"./chunk-NHXLIDQJ.js";import{a as fe,g as ge}from"./chunk-CPK5FYNJ.js";import{k as $}from"./chunk-7KXJEF7P.js";var qe={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function He(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:l}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,c=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":c&&f?p="good":p="mid";let b=qe[p],S=l&&l>0?Math.min(b.maxLongEdge,l):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function ke(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),He(t)}function Xe(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function Ve(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function Ye(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function De(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:l,height:s}=Ve(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let c=u.getContext("2d");if(!c)return null;c.drawImage(e,0,0,l,s);let f=I=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",I)}),p=Xe(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ye(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:l,height:s}}async function Z(e){let t=ke(Math.max(e.width,e.height)),n=await De(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function mt(e){let t=await createImageBitmap(e);try{return await Z(t)}finally{t.close()}}var ft=250,gt=.6,bt=1800,ht=6e3,yt=2e3,we=.16;function te(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}var Ce=e=>e==="recto"?"verso":"recto",Re=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",ne=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ee(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function Qe(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;r&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),r||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Re(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Ke(e,t){if(!Re(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function je(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,l=r?[]:[...e.pending,t],s={...e,captured:i,pending:l,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||ne({captured:i,pending:l})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function xe(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Ce(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function $e(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return xe(e,t,n);let r=e.pending.filter(c=>c!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(ne(i)!==1||e.layout==="singlePage")return i;let l=Ce(n),s=l==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:l,phase:u?s:e.phase}}function Je(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),l=e.layout==="twoSided"&&ne({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,c=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function ve(e,t){switch(t.type){case"report":return Qe(ee(e,t.at),t.report,t.at);case"tick":return Ke(ee(e,t.at),t.at);case"captured":return je(ee(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return $e(e,t.id,t.side);case"duplicate":return xe(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return Je(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...te(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function Ze(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function et(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-DCXFWDBD.js");return Ze(n,e,t)}async function re(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},l=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=l;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,l),await et(u.getImageData(0,0,t,l),r))}finally{s.width=0,s.height=0}}async function Mt(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,r),n.close(),l.getImageData(0,0,t,r))}catch{return null}}var oe=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Y=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Le(e,t,n,r){let i=r.decode??(c=>createImageBitmap(c)),l=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await l()}catch{try{await new Promise(c=>setTimeout(c,r.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:oe(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[Y(u[0]),Y(u[1]),Y(Math.min(u[2],1-u[0])),Y(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:oe(n.framesToValid,1,1e3),msToValid:oe(n.msToValid,0,12e4)}}function Dt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var tt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),nt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function _e(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,tt)||!n.call(t.WebAssembly,nt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function Te(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var T=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Ee(){let e=t=>(t.close(),Promise.reject(new T("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Oe(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return Ee()}catch{return Ee()}let n=new Map,r=0,i=!1,l=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new T("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function c(d,g=[]){if(i)return Promise.reject(new T("disposed"));let C=++r;return new Promise((B,O)=>{n.set(C,{resolve:B,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new T("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new T("disposed"));n.clear()}}let p=(async()=>{let d=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await c({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),I=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new T("disposed");if(!s)throw g.close(),new T("not_ready");if(l)throw g.close(),new T("busy");l=!0;let B;try{let O=new Promise((k,A)=>{B=setTimeout(()=>{A(new T("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(d,[g]),O]);if(P.kind===C){let{id:k,...A}=P;return A}throw new T(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(B),l=!1}}return{ready:I,get busy(){return l},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",ae=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Pe=(e,t)=>typeof e=="boolean"?e:t,Ae=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Be(e,t={}){let n=ae(e),r=ae(n.liveMrz),i=ae(n.frontLock),l=Ae(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,c=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Ae(d.minEngine??U)<=l,b=Se,S=p(r,c)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Pe(r.hint,!0),stillConfirm:Pe(r.stillConfirm,!0)}:null,I=ye,h=(d,g,C)=>v(i[d],g,C,I[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:c,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Ie(e,t){return e.enabled?!(t.probe??_e)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??Te)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Oe({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function rt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var F=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),ie=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function We(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:ie(t?.reads??0,0,1e4)??0,browser:e.browser??rt()},s=(u,c)=>{c!==void 0&&(l[u]=c)};return s("format",t?.format),s("framesToValid",ie(t?.framesToValid,1,1e4)),s("msToValid",F(t?.msToValid)),s("framesToLock",ie(t?.framesToLock,1,1e4)),s("msToLock",F(t?.msToLock)),s("msToCapture",F(e.msToCapture)),s("readP50Ms",F(t?.readP50Ms)),s("readP90Ms",F(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",F(n.warmupMs)),s("downloadMs",F(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function se(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var ot=2;async function at(e){let t=await import("./capture-session-doc-VSUEDAEN.js");return new t.CaptureSessionDoc(e)}function it(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function st(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<r.length;l+=1){let s=r[l],u=r[(l+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Gt(){import("./capture-session-doc-VSUEDAEN.js").then(e=>e.warmDocDetector()).catch(()=>{})}function qt(e){return ut(e,{}).handle}function ut(e,t){let n=fe(),r=ge({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",c=te(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";c={...c,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,I=0,h=0,w=!1,d=!1,g="",C=null,B,O=null,P=[],k=t.webOcr!==void 0?Be(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,A=null,z=k===null||!k.enabled?"off":null,G=null,q=null,ue=new WeakMap,Q="";if(k!==null&&k.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ie(k,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){A=a.engine;let m=new Me({textLock:k.textLock,liveMrz:k.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{z=L,typeof L!="string"&&S&&m.setEngine(y)})}else z=a.reason}let N=o=>{let a=JSON.stringify(o);a!==Q&&(Q=a,n.emit("mrz",o))},le=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||k===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?k.liveMrzArm??k.frontLockArm:k.frontLockArm;if(L===null||Math.random()>=k.reportSampleRate)return;let _=o.via==="live_mrz"?q:null,x=()=>{let E=_?.value??null;m([We({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:se(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},W=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Fe=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,ze=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:Fe(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),ce=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=c;c=ve(c,o),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ce),c.phase==="result"&&a.phase!=="result"&&(W("done"),de());let m=ze(c),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function de(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let me=()=>p?.captureReport?.(),K=!1,pe=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{Q="",!(p===null||c.phase==="reading"||c.phase==="result")&&(K=!1,p.rearm(u?"single":c.current??o))},Ne=async(o,a,m,y)=>{if(q=null,y!==void 0&&A!==null&&k?.liveMrz?.hint===!0){let M={promise:Le(A,o,y,{engine:U,detectorLimit:k.liveMrz.detectorLimit}).catch(()=>null),value:null};M.promise.then(D=>{M.value=D}),q=M}y!==void 0&&se(y.format,e.documentType==="passport"?"passport":"card")&&N({state:"mismatch",format:y.format});let L=me();pe(L,"captured"),K=!0,le(L,y);let _=m===void 0?C:m===null?null:{quad:it(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await Ue(o,a,_,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},Ue=async(o,a,m,y,L)=>{let _=`shot-${I+=1}`;if(R({type:"captured",id:_,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&l>0){let M=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(D=>D===null?-1:he(D,J(m?.quad??null,m?.inStill===!0?D:{width:m?.frameWidth??0,height:m?.frameHeight??0},D)))).catch(()=>-1);if(!S)return;if(Number.isFinite(M)&&M>=0&&M<l){w=!0;let D=u?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:D,id:_,issue:"blurry"}),H(D);return}}w=!1;let x;if(u)x="single";else{let M=c.current,D=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?M??"recto":m?.inStill===!0?re(X,480,null,!0):re(X,480,J(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>M??"recto");if(!S)return;if(c.captured[D]!==void 0&&h<ot){h+=1,R({type:"duplicate",id:_,side:D}),H(D==="recto"?"verso":"recto");return}x=c.captured[D]!==void 0&&M!==void 0?M:D,h=0,R({type:"classified",id:_,side:x})}let E=x==="verso"?"verso":"recto";try{let M=t.encode!==void 0?await t.encode(o):await y().then(D=>{if(D===null)throw new Error("the still could not be decoded");return Z(D)});if(!S)return;L!==null&&ue.set(M.blob,L),n.emit("captured",{image:M.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:M.width,height:M.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch(M){R({type:"readFailed",side:E,id:_,issue:"technical"}),n.emit("error",V("generic",!0,{phase:"keyframes",name:$(M)}))}H(E==="recto"?"verso":"recto")},Ge=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?W("starting"):a==="positioning"?W("scanning"):a==="captured"?W("captured"):a==="error"&&W("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?N({state:"fallback",reason:m.reason}):m.state==="valid"?N({state:"valid",format:m.format}):m.state==="reading"?N({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):N({state:"searching"}));let y=a.quad===null?0:st(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m,detail:y})=>n.emit("error",V(a,m,y))),o.on("artifacts",a=>{Ne(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},j=()=>(b??(b=(async()=>{if(S){if(p===null){let o;try{o=await(t.createEngine??at)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:be(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){W("error"),n.emit("error",V("models",!0,{phase:"models",name:$(m)}));return}if(!S){o.destroy();return}p=o,Ge(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),k!==null&&k.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&N({state:"fallback",reason:z}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:j,retry:()=>{if(p===null&&c.phase==="result"){R({type:"retake"}),h=0,w=!1,j();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}j()},setSide:o=>{u||o==="single"||(c.current!==o&&(c={...c,current:o}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&p?.rearm(o))},shutter:ce,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{B=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=me();!K&&o!==void 0&&o.ticks>0&&pe(o,"abandoned"),le(o,void 0)}S=!1,de(),G?.setEngine(null),A?.dispose(),A=null,n.clear()}},setFlowState:o=>{(c.phase==="reading"||c.phase==="result")&&W(o==="done"&&c.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ue.get(o.image)?.value??null}}export{mt as a,ft as b,gt as c,bt as d,ht as e,yt as f,we as g,te as h,ve as i,Ze as j,et as k,Mt as l,Le as m,Dt as n,U as o,Be as p,Ie as q,rt as r,We as s,se as t,ot as u,Gt as v,qt as w,ut as x};
|
|
1
|
+
import{d as J,h as he,i as ye,j as Se,l as Me}from"./chunk-G6LKLN4U.js";import{f as be}from"./chunk-TDLIXFDT.js";import{m as V}from"./chunk-LBH6KGTV.js";import{a as fe,g as ge}from"./chunk-7QZWBDI5.js";import{k as $}from"./chunk-CPUECYAJ.js";var qe={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function He(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:l}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,c=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":c&&f?p="good":p="mid";let b=qe[p],S=l&&l>0?Math.min(b.maxLongEdge,l):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function ke(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),He(t)}function Xe(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function Ve(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function Ye(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function De(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:l,height:s}=Ve(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let c=u.getContext("2d");if(!c)return null;c.drawImage(e,0,0,l,s);let f=I=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",I)}),p=Xe(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ye(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:l,height:s}}async function Z(e){let t=ke(Math.max(e.width,e.height)),n=await De(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function mt(e){let t=await createImageBitmap(e);try{return await Z(t)}finally{t.close()}}var ft=250,gt=.6,bt=1800,ht=6e3,yt=2e3,we=.16;function te(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}var Ce=e=>e==="recto"?"verso":"recto",Re=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",ne=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ee(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function Qe(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;r&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),r||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Re(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Ke(e,t){if(!Re(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function je(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,l=r?[]:[...e.pending,t],s={...e,captured:i,pending:l,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||ne({captured:i,pending:l})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function xe(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Ce(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function $e(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return xe(e,t,n);let r=e.pending.filter(c=>c!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(ne(i)!==1||e.layout==="singlePage")return i;let l=Ce(n),s=l==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:l,phase:u?s:e.phase}}function Je(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),l=e.layout==="twoSided"&&ne({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,c=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function ve(e,t){switch(t.type){case"report":return Qe(ee(e,t.at),t.report,t.at);case"tick":return Ke(ee(e,t.at),t.at);case"captured":return je(ee(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return $e(e,t.id,t.side);case"duplicate":return xe(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return Je(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...te(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function Ze(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function et(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return Ze(n,e,t)}async function re(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},l=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=l;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,l),await et(u.getImageData(0,0,t,l),r))}finally{s.width=0,s.height=0}}async function Mt(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,r),n.close(),l.getImageData(0,0,t,r))}catch{return null}}var oe=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Y=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Le(e,t,n,r){let i=r.decode??(c=>createImageBitmap(c)),l=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await l()}catch{try{await new Promise(c=>setTimeout(c,r.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:oe(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[Y(u[0]),Y(u[1]),Y(Math.min(u[2],1-u[0])),Y(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:oe(n.framesToValid,1,1e3),msToValid:oe(n.msToValid,0,12e4)}}function Dt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var tt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),nt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function _e(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,tt)||!n.call(t.WebAssembly,nt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function Te(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var T=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Ee(){let e=t=>(t.close(),Promise.reject(new T("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Oe(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return Ee()}catch{return Ee()}let n=new Map,r=0,i=!1,l=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new T("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function c(d,g=[]){if(i)return Promise.reject(new T("disposed"));let C=++r;return new Promise((B,O)=>{n.set(C,{resolve:B,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new T("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new T("disposed"));n.clear()}}let p=(async()=>{let d=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await c({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),I=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new T("disposed");if(!s)throw g.close(),new T("not_ready");if(l)throw g.close(),new T("busy");l=!0;let B;try{let O=new Promise((k,A)=>{B=setTimeout(()=>{A(new T("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(d,[g]),O]);if(P.kind===C){let{id:k,...A}=P;return A}throw new T(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(B),l=!1}}return{ready:I,get busy(){return l},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",ae=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Pe=(e,t)=>typeof e=="boolean"?e:t,Ae=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Be(e,t={}){let n=ae(e),r=ae(n.liveMrz),i=ae(n.frontLock),l=Ae(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,c=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Ae(d.minEngine??U)<=l,b=Se,S=p(r,c)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Pe(r.hint,!0),stillConfirm:Pe(r.stillConfirm,!0)}:null,I=ye,h=(d,g,C)=>v(i[d],g,C,I[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:c,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Ie(e,t){return e.enabled?!(t.probe??_e)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??Te)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Oe({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function rt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var F=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),ie=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function We(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:ie(t?.reads??0,0,1e4)??0,browser:e.browser??rt()},s=(u,c)=>{c!==void 0&&(l[u]=c)};return s("format",t?.format),s("framesToValid",ie(t?.framesToValid,1,1e4)),s("msToValid",F(t?.msToValid)),s("framesToLock",ie(t?.framesToLock,1,1e4)),s("msToLock",F(t?.msToLock)),s("msToCapture",F(e.msToCapture)),s("readP50Ms",F(t?.readP50Ms)),s("readP90Ms",F(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",F(n.warmupMs)),s("downloadMs",F(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function se(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var ot=2;async function at(e){let t=await import("./capture-session-doc-RIBBH3M4.js");return new t.CaptureSessionDoc(e)}function it(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function st(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<r.length;l+=1){let s=r[l],u=r[(l+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Gt(){import("./capture-session-doc-RIBBH3M4.js").then(e=>e.warmDocDetector()).catch(()=>{})}function qt(e){return ut(e,{}).handle}function ut(e,t){let n=fe(),r=ge({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",c=te(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";c={...c,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,I=0,h=0,w=!1,d=!1,g="",C=null,B,O=null,P=[],k=t.webOcr!==void 0?Be(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,A=null,z=k===null||!k.enabled?"off":null,G=null,q=null,ue=new WeakMap,Q="";if(k!==null&&k.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ie(k,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){A=a.engine;let m=new Me({textLock:k.textLock,liveMrz:k.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{z=L,typeof L!="string"&&S&&m.setEngine(y)})}else z=a.reason}let N=o=>{let a=JSON.stringify(o);a!==Q&&(Q=a,n.emit("mrz",o))},le=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||k===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?k.liveMrzArm??k.frontLockArm:k.frontLockArm;if(L===null||Math.random()>=k.reportSampleRate)return;let _=o.via==="live_mrz"?q:null,x=()=>{let E=_?.value??null;m([We({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:se(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},W=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Fe=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,ze=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:Fe(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),ce=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=c;c=ve(c,o),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ce),c.phase==="result"&&a.phase!=="result"&&(W("done"),de());let m=ze(c),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function de(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let me=()=>p?.captureReport?.(),K=!1,pe=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{Q="",!(p===null||c.phase==="reading"||c.phase==="result")&&(K=!1,p.rearm(u?"single":c.current??o))},Ne=async(o,a,m,y)=>{if(q=null,y!==void 0&&A!==null&&k?.liveMrz?.hint===!0){let M={promise:Le(A,o,y,{engine:U,detectorLimit:k.liveMrz.detectorLimit}).catch(()=>null),value:null};M.promise.then(D=>{M.value=D}),q=M}y!==void 0&&se(y.format,e.documentType==="passport"?"passport":"card")&&N({state:"mismatch",format:y.format});let L=me();pe(L,"captured"),K=!0,le(L,y);let _=m===void 0?C:m===null?null:{quad:it(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await Ue(o,a,_,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},Ue=async(o,a,m,y,L)=>{let _=`shot-${I+=1}`;if(R({type:"captured",id:_,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&l>0){let M=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(D=>D===null?-1:he(D,J(m?.quad??null,m?.inStill===!0?D:{width:m?.frameWidth??0,height:m?.frameHeight??0},D)))).catch(()=>-1);if(!S)return;if(Number.isFinite(M)&&M>=0&&M<l){w=!0;let D=u?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:D,id:_,issue:"blurry"}),H(D);return}}w=!1;let x;if(u)x="single";else{let M=c.current,D=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?M??"recto":m?.inStill===!0?re(X,480,null,!0):re(X,480,J(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>M??"recto");if(!S)return;if(c.captured[D]!==void 0&&h<ot){h+=1,R({type:"duplicate",id:_,side:D}),H(D==="recto"?"verso":"recto");return}x=c.captured[D]!==void 0&&M!==void 0?M:D,h=0,R({type:"classified",id:_,side:x})}let E=x==="verso"?"verso":"recto";try{let M=t.encode!==void 0?await t.encode(o):await y().then(D=>{if(D===null)throw new Error("the still could not be decoded");return Z(D)});if(!S)return;L!==null&&ue.set(M.blob,L),n.emit("captured",{image:M.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:M.width,height:M.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch(M){R({type:"readFailed",side:E,id:_,issue:"technical"}),n.emit("error",V("generic",!0,{phase:"keyframes",name:$(M)}))}H(E==="recto"?"verso":"recto")},Ge=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?W("starting"):a==="positioning"?W("scanning"):a==="captured"?W("captured"):a==="error"&&W("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?N({state:"fallback",reason:m.reason}):m.state==="valid"?N({state:"valid",format:m.format}):m.state==="reading"?N({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):N({state:"searching"}));let y=a.quad===null?0:st(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m,detail:y})=>n.emit("error",V(a,m,y))),o.on("artifacts",a=>{Ne(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},j=()=>(b??(b=(async()=>{if(S){if(p===null){let o;try{o=await(t.createEngine??at)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:be(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){W("error"),n.emit("error",V("models",!0,{phase:"models",name:$(m)}));return}if(!S){o.destroy();return}p=o,Ge(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),k!==null&&k.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&N({state:"fallback",reason:z}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:j,retry:()=>{if(p===null&&c.phase==="result"){R({type:"retake"}),h=0,w=!1,j();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}j()},setSide:o=>{u||o==="single"||(c.current!==o&&(c={...c,current:o}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&p?.rearm(o))},shutter:ce,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{B=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=me();!K&&o!==void 0&&o.ticks>0&&pe(o,"abandoned"),le(o,void 0)}S=!1,de(),G?.setEngine(null),A?.dispose(),A=null,n.clear()}},setFlowState:o=>{(c.phase==="reading"||c.phase==="result")&&W(o==="done"&&c.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ue.get(o.image)?.value??null}}export{mt as a,ft as b,gt as c,bt as d,ht as e,yt as f,we as g,te as h,ve as i,Ze as j,et as k,Mt as l,Le as m,Dt as n,U as o,Be as p,Ie as q,rt as r,We as s,se as t,ot as u,Gt as v,qt as w,ut as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as x}from"./chunk-
|
|
1
|
+
import{c as x}from"./chunk-TDLIXFDT.js";import{b}from"./chunk-FPXL63KZ.js";var T=480,y=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),p=e=>Math.min(1,Math.max(0,e));function E(e,o,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let s=0;s<4;s++){let r=n[s],c=n[(s+1)%4];i+=r.x*c.y-c.x*r.y}let a=o*t;return a>0?Math.abs(i/2)/a:0}function I(e,o){let t=D(e),n=D(o),i=Math.max(t.x1,n.x1),a=Math.max(t.y1,n.y1),s=Math.min(t.x2,n.x2),r=Math.min(t.y2,n.y2),c=Math.max(0,s-i)*Math.max(0,r-a),u=(t.x2-t.x1)*(t.y2-t.y1),_=(n.x2-n.x1)*(n.y2-n.y1),m=u+_-c;return m>0?c/m:0}function R(e){let o=D(e);return{width:o.x2-o.x1,height:o.y2-o.y1}}function D(e){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];return{x1:Math.min(...o.map(t=>t.x)),y1:Math.min(...o.map(t=>t.y)),x2:Math.max(...o.map(t=>t.x)),y2:Math.max(...o.map(t=>t.y))}}function M(e){let o=Math.hypot(e.topRight.x-e.topLeft.x,e.topRight.y-e.topLeft.y),t=Math.hypot(e.bottomRight.x-e.bottomLeft.x,e.bottomRight.y-e.bottomLeft.y),n=Math.hypot(e.bottomLeft.x-e.topLeft.x,e.bottomLeft.y-e.topLeft.y),i=Math.hypot(e.bottomRight.x-e.topRight.x,e.bottomRight.y-e.topRight.y),a=(o+t)/2,s=(n+i)/2;return a<=0||s<=0?0:Math.max(a,s)/Math.min(a,s)}var d=class{constructor(o,t={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...y,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:t,quality:n,timestampMs:i}=o,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s=null;if(t===null)s="dcv1.no_doc";else if(this.format==="ID-3"){let h=R(t),f=h.height>0?h.width/h.height:0;h.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":(f<this.t.ID3_BAND_ASPECT_MIN||f>this.t.ID3_BAND_ASPECT_MAX)&&(s="dcv1.wrong_shape")}else E(t,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":x(this.format,M(t))||(s="dcv1.wrong_shape");let r=s===null,c=p(n.exposure)>=this.t.GUIDE_EXPOSURE,u=p(n.sharpness)>=this.t.GUIDE_SHARPNESS,_=c&&u;if(r&&_&&t!==null){let h=this.lastQuad===null||I(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=h?this.streak+1:1}else this.streak=0;this.lastQuad=t;let m=r&&_;this.p=p(this.p+(m?this.t.RISE_PER_S:-this.t.FALL_PER_S)*a);let A=m&&this.streak>=this.t.STABLE_TICKS,l;if(s!==null)l=s;else if(c)u?l="dcv1.hold_still":l="dcv1.steady";else{let h=(b[0]+b[1])/2;l=n.meanLuma<h?"dcv1.more_light":"dcv1.too_bright"}return{at:i,quad:t,plausible:r,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,t,n){let i=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(s=>s.x<=i||s.y<=i||s.x>=t-i||s.y>=n-i)}};export{T as a,y as b,E as c,I as d,R as e,d as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as b,d as E,e as H}from"./chunk-ZGDUIZC2.js";var Y=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function _e(e){return Y.has(e)}function ge(e,n,t){let i=n.detail;return{check:e,kind:n.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,t))}}function Ce(){let e=-1,n="";return{note(t){t==="starting"&&n!=="starting"&&(e+=1),n=t},newHandle(){n=""},noteError(){e<0&&(e=0)},get value(){return e}}}var $={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function f(e){return e.plan?.steps??[]}function P(e){return Math.max(0,e.attempts.max-e.attempts.used)}function j(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function ke(e){let n=j(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(o=>$[o.service]).filter(o=>o!==void 0),i=n.options.find(o=>o.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var z=new Set(["liveness","face_match"]);function _(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function I(e){return e.status!=="created"&&e.status!=="in_progress"}function V(e){let n=e.plan?.current,t=n==null?void 0:f(e).find(i=>i.id===n);return _(t)?t:void 0}function y(e,n){return f(e).find(t=>t.checkType===n)}function S(e){let n=f(e),t=n.findIndex(i=>i.checkType==="liveness");return n.find((i,o)=>o>t&&i.checkType==="face_match")}function A(e,n){let t=y(n,"liveness")?.state,i=S(n)?.state;return(S(e)?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function x(e,n){let t=new Map(f(e).map(i=>[i.id,i.state]));return f(n).filter(i=>i.checkType==="face_match"&&(t.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}var W=/^[0-9a-f]{24}$/i;function g(e){return W.test(e)?`ses_${e}`:e}function k(e,n){let t=g(e);return n===void 0?{sessionId:t,status:"unavailable"}:{sessionId:t,status:"unavailable",reasonCode:n}}function T(e,n,t){let i=g(e);return t===void 0?{sessionId:i,status:n}:{sessionId:i,status:n,reasonCode:t}}function Re(e,n){let t=g(e.sessionId);switch(e.status){case"created":case"in_progress":return Z(e,n);case"verified":return R(e,{sessionId:t,status:"verified"});case"review_pending":return R(e,T(t,"review",L(e,"review")));case"not_verified":return R(e,G(e));default:return R(e,{sessionId:t,status:"not_verified"})}}var X=new Set([0,1,2,3]);function R(e,n){return X.has(e.level)&&(n.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(n.assurance=e.assurance),n}function G(e){let n={sessionId:g(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(n.reason=e.reason),e.reasonCode!==void 0&&(n.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(n.retryAfter=e.retryAfter),n}function J(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}function Q(e,n){if(n===void 0)return!1;let t=f(n).find(i=>i.id===e.id);return t!==void 0&&t.attempts.used===e.attempts.used}function Z(e,n){let t=g(e.sessionId),i=f(e).find(r=>z.has(r.checkType)&&r.state==="input_required"&&r.reason!==void 0);if(i?.reason==="mobile_required")return k(t,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return k(t,i.reason);let a=n.autoRetry&&(P(i)>0||Q(i,n.previous))?{sessionId:t,status:"retry",reasonCode:i.reason,attemptsRemaining:P(i)}:{sessionId:t,status:"not_verified",reason:J(i.result),reasonCode:i.reason,attemptsRemaining:P(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let o=V(e);return o===void 0&&f(e).some(r=>r.state==="review")?T(t,"review",L(e,"review")):o?.checkType==="portrait_icao"?k(t,"portrait_required"):k(t)}function L(e,n){return f(e).find(t=>t.state===n&&t.reason!==void 0)?.reason}function F(e,n,t,i,o){return e.presignCapture!==void 0?e.presignCapture(n,t,i,o):e.presign(n,t,i)}function K(e){return{engine:e?.engine,durationMs:e?.clipMs}}var ee=["video/webm","video/mp4"],O="image/jpeg",ne=2,te=1e3,ie=1e4,oe=3,re=10,se=3,ae=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),ue=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"]),C=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function de(e){let n=S(e);return y(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?_(n):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(n){super(n),this.name="AttestationError"}};async function N(e,n,t={}){let i=e.uuid(),o=!1,r=!1,a=0,l=0;for(;;)try{return await n(e.client,i)}catch(s){if(s instanceof w){if(r)throw s;r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(s instanceof b))throw s;if(s.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(s.code==="attestation_invalid"&&!r){r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(s.code==="inference_unavailable"&&l<oe){l+=1;let d=E(s.retryAfterSeconds,re,e.random??Math.random);e.onBusy?.({attempt:l,retryAfterSeconds:d/1e3}),await e.sleep(d),t.onAttestationInvalid?.(),i=e.uuid();continue}if(ae.has(s.code)&&a<ne){a+=1;let d=s.retryAfterSeconds!==void 0?s.retryAfterSeconds*1e3:void 0;await e.sleep(d!==void 0?Math.min(d,ie):te);continue}throw s}}var ce=new Set(["passed","review","processing","skipped"]);async function Me(e){let{artifacts:n}=e,t=n.clip,i=H(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!ee.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=le(e,n.keyframe),r=fe(e,t,i,o),a=pe(e,o),l=!1,s=new Set,d=!0,m=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let u=e.getView();if(I(u))return{kind:"settled"};let h=V(u),M=h?.checkType,v=M==="liveness"&&!l?"liveness":M==="face_match"&&!s.has(h?.id)&&s.size<2&&d?"face_match":null;if(v===null)return{kind:"settled"};if(v==="liveness"&&n.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(v==="liveness"){l=!0;let c=await r();if(e.isCancelled())return{kind:"cancelled"};A(u,c)&&s.add(S(c)?.id);for(let D of x(u,c))s.add(D);await e.applySubmit(c,"liveness");let p=y(e.getView(),"liveness")?.state;d=p===void 0||ce.has(p)}else{s.add(h?.id);let c=await a();if(e.isCancelled())return{kind:"cancelled"};for(let p of x(u,c))s.add(p);await e.applySubmit(c,"face_match")}}catch(c){if(e.isCancelled()||c instanceof C)return{kind:"cancelled"};let p=ye(c);if(p.kind!=="resync"||m>=se)return p;m+=1,await e.refreshView()}}}function le(e,n){let t=null,i=null,o=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let r=await F(e.client,"image",O,n.size,K(e.artifacts));return await e.client.uploadToSpaces(r.uploadUrl,n,O),t=(await e.client.completeMedia(r.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>t}}function fe(e,n,t,i){let o=null,r,a=null,l=0;return()=>N(e,async(s,d)=>{if(o===null||r===void 0){if(e.isCancelled())throw new C;r===void 0&&!de(e.getView())&&(r=null),e.onPhase("uploading");let[m,u]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let h=await F(s,"clip",t,n.size,K(e.artifacts));return await s.uploadToSpaces(h.uploadUrl,n,t),(await s.completeMedia(h.key)).key})(),r!==void 0?Promise.resolve(r===null?null:r.imageKey):i.attempt()]);o=m,r===void 0&&(r=u===null?null:{imageKey:u})}if(a===null){let m=performance.now();try{a=await e.getAttestation()}catch(u){throw new w(u instanceof Error?u.message:String(u))}l=Math.round(performance.now()-m)}return e.onPhase("checking"),s.submitCheck("liveness",{clipKey:o,attestation:a,captureChannel:e.artifacts.captureChannel,capture:{...me(e.artifacts),attestationMs:l},...r!==null?{faceMatch:r}:{}},{idempotencyKey:d})},{onAttestationInvalid:()=>{a=null}})}function pe(e,n){return()=>N(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new C;e.onPhase("uploading")}let o=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function me(e){let n={width:e.width,height:e.height};for(let t of he)e[t]!==void 0&&(n[t]=e[t]);return n}var he=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ye(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof b){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(ue.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var q=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},U=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};function B(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}function Ae(e,n){if(n===void 0||!_(n)||n.requiresMobile!==!0)return null;switch(n.checkType){case"liveness":return"phone";case"face_match":{if(n.reason!==void 0)return"phone";let t=y(e,"portrait_icao");return t?.state==="passed"||t?.state==="review"?null:"phone"}case"doc_ocr":return B(e.documents);case"portrait_icao":{let t=e.portrait;return t?.pendingFix!==void 0||t?.reuse?.pending===!0?null:B(t)}default:return null}}function Se(e){let n=e?.capture,t=n?.mode;return t==="assisted"||t==="self"||t==="choice"?t:n?.cameraSwitch===!0?"assisted":"self"}function Le(e){let n=e?.capture?.pick;return Se(e)==="choice"&&(n==="self"||n==="assisted")?n:null}function Oe(e,n,t=null){return e==="choice"?n??t??"self":e}export{_e as a,ge as b,Ce as c,$ as d,f as e,P as f,j as g,ke as h,_ as i,I as j,V as k,y as l,g as m,k as n,Re as o,Ae as p,Se as q,Le as r,Oe as s,F as t,ee as u,ne as v,te as w,oe as x,re as y,w as z,N as A,Me as B,q as C,U as D};
|
|
1
|
+
import{c as b,d as E,e as H}from"./chunk-XI5FXEKC.js";var Y=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function _e(e){return Y.has(e)}function Ce(e,n,t){let i=n.detail;return{check:e,kind:n.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,t))}}function ge(){let e=-1,n="";return{note(t){t==="starting"&&n!=="starting"&&(e+=1),n=t},newHandle(){n=""},noteError(){e<0&&(e=0)},get value(){return e}}}var $={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function f(e){return e.plan?.steps??[]}function P(e){return Math.max(0,e.attempts.max-e.attempts.used)}function j(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function ke(e){let n=j(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(o=>$[o.service]).filter(o=>o!==void 0),i=n.options.find(o=>o.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var z=new Set(["liveness","face_match"]);function _(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function I(e){return e.status!=="created"&&e.status!=="in_progress"}function V(e){let n=e.plan?.current,t=n==null?void 0:f(e).find(i=>i.id===n);return _(t)?t:void 0}function y(e,n){return f(e).find(t=>t.checkType===n)}function S(e){let n=f(e),t=n.findIndex(i=>i.checkType==="liveness");return n.find((i,o)=>o>t&&i.checkType==="face_match")}function A(e,n){let t=y(n,"liveness")?.state,i=S(n)?.state;return(S(e)?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function x(e,n){let t=new Map(f(e).map(i=>[i.id,i.state]));return f(n).filter(i=>i.checkType==="face_match"&&(t.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}var G=/^[0-9a-f]{24}$/i;function C(e){return G.test(e)?`ses_${e}`:e}function k(e,n){let t=C(e);return n===void 0?{sessionId:t,status:"unavailable"}:{sessionId:t,status:"unavailable",reasonCode:n}}function T(e,n,t){let i=C(e);return t===void 0?{sessionId:i,status:n}:{sessionId:i,status:n,reasonCode:t}}function Re(e,n){let t=C(e.sessionId);switch(e.status){case"created":case"in_progress":return Z(e,n);case"verified":return R(e,{sessionId:t,status:"verified"});case"review_pending":return R(e,T(t,"review",L(e,"review")));case"not_verified":return R(e,X(e));default:return R(e,{sessionId:t,status:"not_verified"})}}var W=new Set([0,1,2,3]);function R(e,n){return W.has(e.level)&&(n.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(n.assurance=e.assurance),n}function X(e){let n={sessionId:C(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(n.reason=e.reason),e.reasonCode!==void 0&&(n.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(n.retryAfter=e.retryAfter),n}function J(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}function Q(e,n){if(n===void 0)return!1;let t=f(n).find(i=>i.id===e.id);return t!==void 0&&t.attempts.used===e.attempts.used}function Z(e,n){let t=C(e.sessionId),i=f(e).find(r=>z.has(r.checkType)&&r.state==="input_required"&&r.reason!==void 0);if(i?.reason==="mobile_required")return k(t,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return k(t,i.reason);let a=n.autoRetry&&(P(i)>0||Q(i,n.previous))?{sessionId:t,status:"retry",reasonCode:i.reason,attemptsRemaining:P(i)}:{sessionId:t,status:"not_verified",reason:J(i.result),reasonCode:i.reason,attemptsRemaining:P(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let o=V(e);return o===void 0&&f(e).some(r=>r.state==="review")?T(t,"review",L(e,"review")):o?.checkType==="portrait_icao"?k(t,"portrait_required"):k(t)}function L(e,n){return f(e).find(t=>t.state===n&&t.reason!==void 0)?.reason}function F(e,n,t,i,o){return e.presignCapture!==void 0?e.presignCapture(n,t,i,o):e.presign(n,t,i)}function K(e){return{engine:e?.engine,durationMs:e?.clipMs}}var ee=["video/webm","video/mp4"],O="image/jpeg",ne=2,te=1e3,ie=1e4,oe=3,re=10,se=3,ae=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),ue=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 de(e){let n=S(e);return y(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?_(n):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(n){super(n),this.name="AttestationError"}};async function N(e,n,t={}){let i=e.uuid(),o=!1,r=!1,a=0,l=0;for(;;)try{return await n(e.client,i)}catch(s){if(s instanceof w){if(r)throw s;r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(s instanceof b))throw s;if(s.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(s.code==="attestation_invalid"&&!r){r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(s.code==="inference_unavailable"&&l<oe){l+=1;let d=E(s.retryAfterSeconds,re,e.random??Math.random);e.onBusy?.({attempt:l,retryAfterSeconds:d/1e3}),await e.sleep(d),t.onAttestationInvalid?.(),i=e.uuid();continue}if(ae.has(s.code)&&a<ne){a+=1;let d=s.retryAfterSeconds!==void 0?s.retryAfterSeconds*1e3:void 0;await e.sleep(d!==void 0?Math.min(d,ie):te);continue}throw s}}var ce=new Set(["passed","review","processing","skipped"]);async function Me(e){let{artifacts:n}=e,t=n.clip,i=H(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!ee.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=le(e,n.keyframe),r=fe(e,t,i,o),a=pe(e,o),l=!1,s=new Set,d=!0,m=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let u=e.getView();if(I(u))return{kind:"settled"};let h=V(u),M=h?.checkType,v=M==="liveness"&&!l?"liveness":M==="face_match"&&!s.has(h?.id)&&s.size<2&&d?"face_match":null;if(v===null)return{kind:"settled"};if(v==="liveness"&&n.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(v==="liveness"){l=!0;let c=await r();if(e.isCancelled())return{kind:"cancelled"};A(u,c)&&s.add(S(c)?.id);for(let D of x(u,c))s.add(D);await e.applySubmit(c,"liveness");let p=y(e.getView(),"liveness")?.state;d=p===void 0||ce.has(p)}else{s.add(h?.id);let c=await a();if(e.isCancelled())return{kind:"cancelled"};for(let p of x(u,c))s.add(p);await e.applySubmit(c,"face_match")}}catch(c){if(e.isCancelled()||c instanceof g)return{kind:"cancelled"};let p=ye(c);if(p.kind!=="resync"||m>=se)return p;m+=1,await e.refreshView()}}}function le(e,n){let t=null,i=null,o=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let r=await F(e.client,"image",O,n.size,K(e.artifacts));return await e.client.uploadToSpaces(r.uploadUrl,n,O),t=(await e.client.completeMedia(r.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>t}}function fe(e,n,t,i){let o=null,r,a=null,l=0;return()=>N(e,async(s,d)=>{if(o===null||r===void 0){if(e.isCancelled())throw new g;r===void 0&&!de(e.getView())&&(r=null),e.onPhase("uploading");let[m,u]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let h=await F(s,"clip",t,n.size,K(e.artifacts));return await s.uploadToSpaces(h.uploadUrl,n,t),(await s.completeMedia(h.key)).key})(),r!==void 0?Promise.resolve(r===null?null:r.imageKey):i.attempt()]);o=m,r===void 0&&(r=u===null?null:{imageKey:u})}if(a===null){let m=performance.now();try{a=await e.getAttestation()}catch(u){throw new w(u instanceof Error?u.message:String(u))}l=Math.round(performance.now()-m)}return e.onPhase("checking"),s.submitCheck("liveness",{clipKey:o,attestation:a,captureChannel:e.artifacts.captureChannel,capture:{...me(e.artifacts),attestationMs:l},...r!==null?{faceMatch:r}:{}},{idempotencyKey:d})},{onAttestationInvalid:()=>{a=null}})}function pe(e,n){return()=>N(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new g;e.onPhase("uploading")}let o=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function me(e){let n={width:e.width,height:e.height};for(let t of he)e[t]!==void 0&&(n[t]=e[t]);return n}var he=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ye(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof b){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(ue.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var q=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},U=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};function B(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}function Ae(e,n){if(n===void 0||!_(n)||n.requiresMobile!==!0)return null;switch(n.checkType){case"liveness":return"phone";case"face_match":{if(n.reason!==void 0)return"phone";let t=y(e,"portrait_icao");return t?.state==="passed"||t?.state==="review"?null:"phone"}case"doc_ocr":return B(e.documents);case"portrait_icao":{let t=e.portrait;return t?.pendingFix!==void 0||t?.reuse?.pending===!0?null:B(t)}default:return null}}function Se(e){let n=e?.capture,t=n?.mode;return t==="assisted"||t==="self"||t==="choice"?t:n?.cameraSwitch===!0?"assisted":"self"}function Le(e){let n=e?.capture?.pick;return Se(e)==="choice"&&(n==="self"||n==="assisted")?n:null}function Oe(e,n,t=null){return e==="choice"?n??t??"self":e}export{_e as a,Ce as b,ge as c,$ as d,f as e,P as f,j as g,ke as h,_ as i,I as j,V as k,y as l,C as m,k as n,Re as o,Ae as p,Se as q,Le as r,Oe as s,F as t,ee as u,ne as v,te as w,oe as x,re as y,w as z,N as A,Me as B,me as C,q as D,U as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as M}from"./chunk-
|
|
1
|
+
import{b as M}from"./chunk-GI3UFGRQ.js";var A=2;function L(u){let l=u.tuning,s=u.now??(()=>performance.now()),t=null,o=!1,g=!1,d=Number.NEGATIVE_INFINITY,a=null,h=0,i=null,n=null,f=0,p=!1,T=()=>{if(p||!l.enabled)return;p=!0;let r=(u.createSegmenter??(e=>import("./segmenter-USLNBX65.js").then(m=>m.createSelfieSegmenter(e))))(u.assetBaseUrl);n=setTimeout(()=>{t===null&&(o=!0)},l.segmenterTimeoutMs),r.then(e=>{n!==null&&clearTimeout(n),g||o?e.close():t=e},()=>{n!==null&&clearTimeout(n),o=!0})};return{measure(r,e,m,S){if(!l.enabled||r.pixels===null)return null;T();let c=s();if(c-d<1e3/l.hz)return a;d=c;let k=r.width/Math.max(1,m),y=r.height/Math.max(1,S),w={x:e.x*k,y:e.y*y,width:e.width*k,height:e.height*y},B=null;if(t!==null&&!o){let x=Math.max(c,h+1);h=x;let U=s();B=t.segment(r.source,x);let b=s()-U;f+=1,f>A&&(i=i===null?b:i*.7+b*.3),i!==null&&i>l.segmenterBudgetMs&&(o=!0,t.close(),t=null)}return a=M(r.pixels,w,B,l),a},close(){g=!0,n!==null&&clearTimeout(n),t?.close(),t=null}}}export{L as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as k,r as w}from"./chunk-
|
|
1
|
+
import{p as k,r as w}from"./chunk-CPUECYAJ.js";import{e as M}from"./chunk-TSA6GHUG.js";var u=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},S=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function h(r){try{return String(r?.name??"")}catch{return""}}function c(r){if(r!==null)for(let t of r.getTracks())t.stop()}async function C(r,t,n){let a=e=>({video:{...t,...e},audio:!1});if(r==="user")return n.getUserMedia(a({facingMode:"user"}));let o=e=>M(e)!=="user";try{let e=await n.getUserMedia(a({facingMode:{exact:"environment"}}));if(o(e))return e;c(e)}catch(e){if(S.has(h(e)))throw e}let d=!1,l=async()=>{if(n.enumerateDevices===void 0||d)return null;let e;try{e=w(await n.enumerateDevices()).slice(0,3)}catch{return null}d=e.length>0;for(let v of e){let i;try{i=await n.getUserMedia(a({deviceId:{exact:v}}))}catch(g){if(S.has(h(g)))throw g;continue}if(o(i))return i;c(i)}return null},m=await l();if(m!==null)return m;let s=await n.getUserMedia(a({facingMode:"environment"}));if(o(s))return s;c(s);let f=await l();if(f!==null)return f;throw new u}export{u as a,C as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,e as me,g as fe,m as he}from"./chunk-
|
|
1
|
+
import{a as G,e as me,g as fe,m as he}from"./chunk-53POX7U4.js";import{b as ge}from"./chunk-33KKMPJ5.js";import{a as pe,d as ye}from"./chunk-CJHMFPL6.js";import{a as be}from"./chunk-RI3E7GBN.js";import{a as ce,d as ue,e as K,f as le,g as de}from"./chunk-7QZWBDI5.js";import{a as V,b as se}from"./chunk-SX7TUC3V.js";import{k as N,m as oe,n as ie}from"./chunk-CPUECYAJ.js";import{e as ae}from"./chunk-TSA6GHUG.js";var Ee=250,Ie=180,Re=96;function xe(n){let{data:e,width:t,height:a}=n,r=new Uint8Array(t*a);for(let o=0,s=0;o<r.length;o+=1,s+=4)r[o]=Math.round(.299*(e[s]??0)+.587*(e[s+1]??0)+.114*(e[s+2]??0));return{data:r,width:t,height:a}}function W(n,e){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(e.width,Math.ceil(n.x+n.width)),y1:Math.min(e.height,Math.ceil(n.y+n.height))}}function T(n,e,t){let a=W(e,n),r=t===void 0?null:W(t,n),o=0,s=0,l=0,m=0;for(let c=a.y0;c<a.y1;c+=1)for(let b=a.x0;b<a.x1;b+=1){if(r!==null&&b>=r.x0&&b<r.x1&&c>=r.y0&&c<r.y1)continue;let L=n.data[c*n.width+b];o+=1,s+=L,l+=L*L,L>=Ee&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let d=s/o;return{mean:d,sd:Math.sqrt(Math.max(0,l/o-d*d)),clipped:m/o,count:o}}function ve(n){let{box:e}=n,a=(n.leftEye.y+n.rightEye.y)/2-.1*e.height,r=e.y+.85*e.height;return{x:e.x+.15*e.width,y:a,width:.7*e.width,height:Math.max(1,r-a)}}function Be(n,e){let t=ve(e),a=T(n,t);if(a.count===0)return null;let r=Math.min(Math.max(e.nose.x,t.x+1),t.x+t.width-1),o=T(n,{x:t.x,y:t.y,width:r-t.x,height:t.height}),s=T(n,{x:r,y:t.y,width:t.x+t.width-r,height:t.height}),l=s.mean>0?o.mean/s.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:a.mean,halfRatio:l,clipped:a.clipped}}function Ge(n,e){let t=0,a=0;for(let r of[e.leftEyeBox,e.rightEyeBox]){let o=r.width*.15,s=r.height*.5,l=T(n,{x:r.x-o,y:r.y-s,width:r.width+2*o,height:r.height+2*s});t+=l.count,a+=l.clipped*l.count}return t===0?null:a/t}function Ae(n,e){let t=me(e),{box:a}=e,r={x:a.x-.2*a.width,y:t.y,width:1.4*a.width,height:a.y+a.height-t.y},o=0,s=0,l=0;for(let d of[t.x,t.x+.8*t.width]){let c=T(n,{x:d,y:t.y+.04*t.height,width:.2*t.width,height:.25*t.height},r);o+=c.count,s+=c.mean*c.count,l+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let m=s/o;return{luma:m,sd:Math.sqrt(Math.max(0,l/o-m*m)),count:o}}function Oe(n,e){let t=W(ve(e),n),a=Math.max(1,Math.floor(Math.max(t.x1-t.x0,t.y1-t.y0)/Re)),r=(d,c)=>n.data[c*n.width+d],o=0,s=0,l=0;for(let d=t.y0+a;d<t.y1-a;d+=a)for(let c=t.x0+a;c<t.x1-a;c+=a){let b=r(c,d-a)+r(c-a,d)+r(c+a,d)+r(c,d+a)-4*r(c,d);o+=1,s+=b,l+=b*b}if(o===0)return null;let m=s/o;return Math.min(1,Math.max(0,l/o-m*m)/Ie)}function we(n,e){return{lighting:Be(n,e),eyeSpecular:Ge(n,e),background:Ae(n,e),sharpness:Oe(n,e)}}var Ue="/models-v3",De=640,_e=.92;function Y(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function j(n,e){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=n,t.height=e,t}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,e):null}function He(){let n=null;return(e,t)=>{let{width:a,height:r}=Y(e);if(a===0||r===0)return null;let o=t===null?1:Math.min(1,t/Math.max(a,r)),s=Math.round(a*o),l=Math.round(r*o),m;t===null?m=j(s,l):((n===null||n.width!==s||n.height!==l)&&(n=j(s,l)),m=n);let d=m?.getContext("2d",{willReadFrequently:!0});if(m==null||d==null)return null;d.drawImage(e,0,0,s,l);let c=null;try{c=d.getImageData(0,0,s,l)}catch{c=null}return{source:m,width:s,height:l,pixels:c}}}async function qe(n,e,t,a){let r=Math.round(t*e.width/e.height),o=j(r,t),s=o?.getContext("2d");if(o==null||s==null)throw new Error("canvas unavailable");return s.fillStyle="#fff",s.fillRect(0,0,r,t),s.drawImage(n.source,e.x,e.y,e.width,e.height,0,0,r,t),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:a}):new Promise((l,m)=>{o.toBlob(d=>d===null?m(new Error("encode failed")):l(d),"image/jpeg",a)})}var z=class extends Error{};function Ne(n,e,t){return new Promise((a,r)=>{let o=setTimeout(()=>{r(new z(`init exceeded ${e}ms`)),n.then(t,()=>{})},e);n.then(s=>{clearTimeout(o),a(s)},s=>{clearTimeout(o),r(s)})})}function Ve(n){if(n instanceof V)return{kind:"notfound",retryable:!0,detail:{name:n.name,phase:"acquiring",engineKind:"backcamera"}};let e=oe(n),t=e==="overconstrained"?"generic":e,a=N(n);return{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:{...a!==void 0?{name:a}:{},phase:"acquiring",engineKind:e}}}function Ke(n,e,t,a){let r=n.length===1?n[0]:void 0,o=r===void 0?null:G(r.landmarks,t,a),s=null;if(r!==void 0&&e.pixels!==null){let l=G(r.landmarks,e.width,e.height),m=xe(e.pixels);l!==null&&(s=we(m,l))}return{frameWidth:t,frameHeight:a,faces:n.length,geometry:o,matrix:r?.matrix??null,blendshapes:r?.blendshapes??null,stats:s}}function ct(n,e={},t=()=>"self",a){let r=ge(n.tuning,n.tuningVersion),o=ce(),s=e.now??(()=>performance.now()),l=e.setTimer??((i,u)=>setTimeout(i,u)),m=e.clearTimer??(i=>clearTimeout(i)),d=e.grabFrame??He(),c=e.encodeRegion??qe,b=e.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),L=e.enumerateDevices??(e.getUserMedia===void 0&&typeof navigator<"u"&&typeof navigator.mediaDevices?.enumerateDevices=="function"?()=>navigator.mediaDevices.enumerateDevices():void 0),Ce=e.createLandmarker??ye,J=n.assetBaseUrl??Ue,Q=de({enabled:n.keepScreenAwake!==!1}),S=he(r,{policy:n.policy??"reject"}),w=n.video,X=be({tuning:r.backgroundCheck,assetBaseUrl:J,...e.createSegmenter!==void 0?{createSegmenter:e.createSegmenter}:{},now:s}),f="idle",C=null,x=null,E=null,A=!1,g=!1,p=0,$=0,O=[],v="user",U=le(),Z=!1,ke=e.canChooseFacing??ue,k=i=>{f===i||g||(f=i,Q.setActive(i==="starting"||i==="gating"),o.emit("state",i))},D=()=>{E!==null&&m(E),E=null},I=()=>{D();for(let i of C?.getTracks()??[])i.stop();C=null;try{w.srcObject=null}catch{}},_=i=>{I(),k("error"),o.emit("error",i)},ee=()=>{let i=Math.max(s(),$+1);return $=i,i},Me=async i=>{let u=d(w,null),{width:M,height:P}=u??Y(w);if(u===null||x===null){S.reset();return}let h=x.detect(u.source,ee()),y=(h.length===1?h:O.length===1?O:[])[0],F=y===void 0?null:G(y.landmarks,M,P);if(F===null){S.reset();return}let B=fe(F,M,P,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),q=Math.max(r.resolution.minHeight,B.height),Te=await c(u,B,q,_e);if(g||i!==p)return;let re={image:Te,width:Math.round(q*B.width/B.height),height:q,gate:S.summary(),facingMode:v};r.tuningVersion!==null&&(re.tuningVersion=r.tuningVersion),D(),k("captured"),o.emit("captured",re)},H=async i=>{if(!(g||i!==p||f!=="gating"||x===null)){if(!A){A=!0;try{let u=d(w,De);if(u!==null){let{width:M,height:P}=Y(w),h=x.detect(u.source,ee());O=h;let y=Ke(h,u,M||u.width,P||u.height);y.geometry!==null&&r.background.required&&(y.backgroundCheck=X.measure(u,y.geometry.box,M||u.width,P||u.height));let F=S.push(y,s());if(g||i!==p||(o.emit("gate",F),F.ready&&(await Me(i),f!=="gating")))return}}catch{}finally{A=!1}}!g&&i===p&&f==="gating"&&(E=l(()=>{H(i)},1e3/r.cadenceHz))}},Pe=()=>Ne(Ce(J),2e4,i=>i.close()),Le=i=>{let u=t()==="assisted"?"assisted":"self";return Z||U.facing(u,n.facing),U.facing(u,i)},te=!1;function Se(){return te||a===void 0||a.session()!=="choice"||t()!=="assisted"?!1:(te=!0,a.onModeChange("self"),v=K("self"),k("mode_switch"),R({facing:v}),!0)}let R=async i=>{if(g||f==="starting"||f==="gating")return;p+=1;let u=p;S.reset(),k("starting");let M=Le(i?.facing);if(C!==null&&M!==v&&I(),v=M,Z=!0,C===null&&e.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){let h=typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported";_({kind:h,retryable:!1,detail:{phase:"preflight",engineKind:h}});return}let P=x!==null?Promise.resolve(x):Pe();P.catch(()=>{});try{if(C===null){let h=await se(v,{width:{ideal:r.camera.width},height:{ideal:r.camera.height}},{getUserMedia:b,...L!==void 0?{enumerateDevices:L}:{}});if(g||u!==p){for(let y of h.getTracks())y.stop();return}C=h,ie(h),v=ae(h)??v,w.srcObject=C,w.muted=!0,w.playsInline=!0,await w.play().catch(()=>{})}}catch(h){if(g||u!==p||h instanceof V&&Se())return;_(Ve(h));return}try{x=await P}catch(h){if(!g&&u===p){let y=N(h);_({kind:"generic",retryable:!0,detail:{...y!==void 0?{name:y}:{},phase:"models",engineKind:"models"}})}return}g||u!==p||(k("gating"),H(u))},ne=async()=>a!==void 0&&a.session()==="choice"&&await ke().catch(()=>!1),Fe=()=>f==="idle"||f==="starting"||f==="gating"||f==="error";return{handle:{get state(){return f},get captureMode(){return t()},get facingMode(){return v},on:(i,u)=>o.on(i,u),start:R,retry:()=>{if(!g){if(C!==null&&x!==null&&f!=="error"){p+=1;let i=p;D(),S.reset(),k("gating"),H(i);return}f="idle",R()}},switchCamera:()=>U.refuseSwitch(t()==="assisted"?"assisted":"self"),canSwitchCaptureMode:ne,setCaptureMode:async i=>{if(g||a===void 0||i===t()||!await ne()||g||!Fe())return!1;a.onModeChange(i);let u=K(i);return f==="idle"&&C===null||(p+=1,I(),v=u,k("mode_switch"),R({facing:u})),!0},destroy:()=>{g||(p+=1,I(),Q.setActive(!1),g=!0,x?.close(),x=null,X.close(),o.clear())}},gateScores:()=>S.scores(),setFlowState:i=>{(f==="captured"||f==="uploading"||f==="checking"||f==="done"&&i==="done")&&k(i)}}}function ut(){import("@mediapipe/tasks-vision").catch(()=>{})}export{Ee as a,Ie as b,xe as c,T as d,Be as e,Ge as f,Ae as g,Oe as h,we as i,De as j,_e as k,He as l,Ke as m,ct as n,ut as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as f}from"./chunk-TSA6GHUG.js";import{a as h,c as y}from"./chunk-IFLOS5OT.js";var w=["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","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden"];function D(s){return w.includes(s)}var c=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)}};function _(s,e,n=Math.random){let t=(s??e)*1e3,o=Math.min(Math.max(t,500),2e4),i=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(i,500),2e4)}var k=6e4,b=4,R=3e4,I=9e5,P=200,E=5,M=400,C=new Set(["server_busy","request_timeout"]),A=2;function l(s){return(s.split(";")[0]??"").trim()}var O={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},v=`@sekyro/web/${h}`,N=v,g=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,o)=>(n??globalThis.fetch).call(globalThis,t,o),this.requestTimeoutMs=e.requestTimeoutMs??R,this.retryAttempts=e.inProgressRetry?.attempts??E,this.retryDelayMs=e.inProgressRetry?.delayMs??M,this.random=e.random??Math.random}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},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",t=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,i=[e.check,o??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(i);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...t!==void 0?{engineKind:t}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},r=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(i)});return this.reportedIssues.set(i,r),r}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});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,o={}){let i=await this.ensureSessionId(),a={kind:e,contentType:l(n),contentLength:t,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${i}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,o={}){let i=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},r={kind:e,contentType:l(n),contentLength:t,capture:d};return this.api("POST",`/sessions/${i}/media`,{body:r})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-k>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(b,Math.max(1,e))}}),o=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let i of Array.isArray(t.nonces)?t.nonces:[])typeof i=="string"&&i.length>0&&this.captureNonces.push({nonce:i,expiresAt:o});this.captureNonces=this.captureNonces.slice(-b)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(I)})}catch(i){throw m(i)}if(!o.ok){let i=(await o.text().catch(()=>"")).slice(0,P);throw new c({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${i?`: ${i}`:""}`})}}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 o=await this.ensureSessionId(),i={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:i,idempotencyKey:t.idempotencyKey,busyRetry:t.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,t,o={}){let i=l(n.contentType),a=await this.presign(n.kind,i,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,i);let d=await this.completeMedia(a.key),r={...t,[O[e]]:d.key};return this.submitCheck(e,r,o)}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 o=e==="GET"||t.busyRetry===!0,i=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":N};t.body!==void 0&&(a["content-type"]="application/json"),t.idempotencyKey!==void 0&&(a["x-idempotency-key"]=t.idempotencyKey);try{let d=y.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=f();try{let d=await y.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let r;try{r=await this.fetchImpl(i,{method:e,headers:a,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(p){throw m(p)}if(r.ok){if(t.empty===!0)return;if(t.blob===!0)try{return await r.blob()}catch(S){throw m(S)}let p;try{p=await r.json()}catch{throw new c({status:r.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${r.status})`})}return H(p)}let u=await x(r);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await T(this.retryDelayMs);continue}if(o&&u.status===503&&C.has(u.code)){o=!1,await T(_(u.retryAfterSeconds,A,this.random));continue}throw u}}};function m(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new c({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new c({status:0,code:"network_error",message:`network request failed: ${n}`})}function H(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function x(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,o;try{let d=await s.json();if(d!==null&&typeof d=="object"){let r=d;typeof r.code=="string"&&r.code.length>0&&(e=r.code),typeof r.message=="string"&&r.message.length>0&&(n=r.message),typeof r.retryAfterSeconds=="number"&&(t=r.retryAfterSeconds),Array.isArray(r.details?.issues)&&(o=r.details)}}catch{}let i=s.headers.get("retry-after"),a=i===null?Math.floor(t):Number.parseInt(i,10);return new c({status:s.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function T(s){return new Promise(e=>setTimeout(e,s))}function L(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"?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function j(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},...s.baselineEyeOpennessLeft!==void 0&&s.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:s.baselineEyeOpennessLeft,baselineEyeOpennessRight:s.baselineEyeOpennessRight}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{w as a,D as b,c,_ as d,l as e,v as f,g,L as h,j as i};
|
package/dist/client/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var M=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},X=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of G(e))!z.call(t,o)&&o!==n&&g(t,o,{get:()=>e[o],enumerable:!(i=j(e,o))||i.enumerable});return t};var J=t=>X(g({},"__esModule",{value:!0}),t);var I=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let i=setTimeout(()=>n(void 0),e),o=r=>{clearTimeout(i),n(r)};try{t().then(o,()=>o(void 0))}catch{o(void 0)}})}async function R(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var E=b(()=>{"use strict";I()});var H={};M(H,{computePrint:()=>me,readHints:()=>O});function A(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function O(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),re);if(e==null)return;let n=A(e.model,ae),i=A(e.platformVersion,ce),o={...n!==void 0?{model:n}:{},...i!==void 0?{platformVersion:i}:{}};return Object.keys(o).length>0?o:void 0}async function le(){let[t,e]=await Promise.all([new x.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:ie}).get(),O()]),n=t?.thumbmark;if(typeof n!="string"||n.length<de||n.length>ue)return;let i={};for(let o of ne){let r=t.components?.[o];r==null||r.timeout==="true"||(i[o]=await R(r))}return{hash:n,c:i,...e!==void 0?{hints:e}:{}}}function pe(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:se}):t()})}async function me(t){return t()||(await pe(),t())?"busy":_(le,oe)}var x,ne,ie,oe,re,se,ae,ce,de,ue,N=b(()=>{"use strict";x=require("@thumbmarkjs/thumbmarkjs");E();ne=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],ie=2e3,oe=4e3,re=1e3,se=2e3,ae=64,ce=32,de=8,ue=128});var Oe={};M(Oe,{HostedApiError:()=>u,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>k,icaoPolicyOf:()=>q,isInAppBrowser:()=>y,isKnownCode:()=>L,portraitIcaoGate:()=>$,stripMimeParams:()=>p});module.exports=J(Oe);var Z=600;function v(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),n=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(n))return"phone";if(/iPad/i.test(n))return"tablet";if(/Android/i.test(n))return/Mobile/i.test(n)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(n))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(n))return"tablet";if(/Windows NT|CrOS/.test(n)||!ee())return"desktop"}let i=Q();return i>0&&i<Z?"phone":"tablet"}function Q(){try{let t=window.screen,e=Number(t?.width??0),n=Number(t?.height??0);return e>0&&n>0?Math.min(e,n):0}catch{return 0}}function ee(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var f="0.1.0-rc.22.1";var te=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return te.test(e)}var D="sekyro.did",fe=1e4,ye=()=>globalThis.process?.versions?.node,V;function F(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function he(){try{let t=localStorage.getItem(D);if(t)return t;let e=F();return e!==void 0&&localStorage.setItem(D,e),e}catch{return V??(V=F()),V}}async function ge(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function be(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function _e(t){let e=new TextEncoder().encode(t),n="";for(let i of e)n+=String.fromCharCode(i);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Se(t){let e,n,i,o,r,a,d=()=>a?.readyState==="live",s=()=>{r!==void 0||!globalThis.crypto?.subtle||ye()||d()||(r=Promise.race([Promise.resolve().then(()=>(N(),H)),new Promise(c=>setTimeout(c,fe))]).then(c=>c?.computePrint(d)).then(c=>{c==="busy"?r=void 0:o=c}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(c){c&&(e=c.slice(0,128))},noteCamera(c){n=c},noteCameraTrack(c){a=c},async deviceHeader(){try{i??(i=ge().catch(()=>""));let c=[];navigator.webdriver&&c.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&c.push("headless");let l=await i,m=he(),Y={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...be(),...e?{cameraLabel:e}:{},...c.length?{signals:c}:{},...o?{print:{v:2,...o,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},W=_e(JSON.stringify(Y));return s(),W}catch{return}},printReady(){return r??Promise.resolve()}}}var S=Symbol.for("sekyro.web.clientContext"),T=globalThis,w=T[S]??(T[S]=Se({sdk:`@sekyro/web@${f}`}));var P=["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","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden"];function L(t){return P.includes(t)}var u=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)}};function U(t,e,n=Math.random){let i=(t??e)*1e3,o=Math.min(Math.max(i,500),2e4),r=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}var Te=6e4,K=4,we=3e4,Pe=9e5,Ce=200,ke=5,Me=400,ve=new Set(["server_busy","request_timeout"]),Ie=2;function p(t){return(t.split(";")[0]??"").trim()}var Re={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},k=`@sekyro/web/${f}`,Ee=k,h=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(i,o)=>(n??globalThis.fetch).call(globalThis,i,o),this.requestTimeoutMs=e.requestTimeoutMs??we,this.retryAttempts=e.inProgressRetry?.attempts??ke,this.retryDelayMs=e.inProgressRetry?.delayMs??Me,this.random=e.random??Math.random}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},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,r=[e.check,o??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(r);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...i!==void 0?{engineKind:i}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},s=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(r)});return this.reportedIssues.set(r,s),s}async choose(e,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}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,i,o={}){let r=await this.ensureSessionId(),a={kind:e,contentType:p(n),contentLength:i,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,i,o={}){let r=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},s={kind:e,contentType:p(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-Te>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let i=e();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(K,Math.max(1,e))}}),o=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let r of Array.isArray(i.nonces)?i.nonces:[])typeof r=="string"&&r.length>0&&this.captureNonces.push({nonce:r,expiresAt:o});this.captureNonces=this.captureNonces.slice(-K)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,i){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(i)},body:n,signal:AbortSignal.timeout(Pe)})}catch(r){throw C(r)}if(!o.ok){let r=(await o.text().catch(()=>"")).slice(0,Ce);throw new u({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${r?`: ${r}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,i={}){let o=await this.ensureSessionId(),r={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:r,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,i,o={}){let r=p(n.contentType),a=await this.presign(n.kind,r,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,r);let d=await this.completeMedia(a.key),s={...i,[Re[e]]:d.key};return this.submitCheck(e,s,o)}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,i={}){let o=e==="GET"||i.busyRetry===!0,r=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":Ee};i.body!==void 0&&(a["content-type"]="application/json"),i.idempotencyKey!==void 0&&(a["x-idempotency-key"]=i.idempotencyKey);try{let d=w.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=v();try{let d=await w.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(r,{method:e,headers:a,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw C(l)}if(s.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await s.blob()}catch(m){throw C(m)}let l;try{l=await s.json()}catch{throw new u({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return Ae(l)}let c=await xe(s);if(c.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(o&&c.status===503&&ve.has(c.code)){o=!1,await B(U(c.retryAfterSeconds,Ie,this.random));continue}throw c}}};function C(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function Ae(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function xe(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,i=Number.NaN,o;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(i=s.retryAfterSeconds),Array.isArray(s.details?.issues)&&(o=s.details)}}catch{}let r=t.headers.get("retry-after"),a=r===null?Math.floor(i):Number.parseInt(r,10);return new u({status:t.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function B(t){return new Promise(e=>setTimeout(e,t))}function q(t){let e=t?.portrait,n=e?.icao,i=e?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}function $(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
|
|
1
|
+
"use strict";var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var M=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},X=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of j(e))!z.call(t,r)&&r!==n&&g(t,r,{get:()=>e[r],enumerable:!(i=W(e,r))||i.enumerable});return t};var J=t=>X(g({},"__esModule",{value:!0}),t);var v=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let i=setTimeout(()=>n(void 0),e),r=o=>{clearTimeout(i),n(o)};try{t().then(r,()=>r(void 0))}catch{r(void 0)}})}async function R(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var E=b(()=>{"use strict";v()});var H={};M(H,{computePrint:()=>me,readHints:()=>O});function A(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function O(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),oe);if(e==null)return;let n=A(e.model,ae),i=A(e.platformVersion,ce),r={...n!==void 0?{model:n}:{},...i!==void 0?{platformVersion:i}:{}};return Object.keys(r).length>0?r:void 0}async function le(){let[t,e]=await Promise.all([new x.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:ie}).get(),O()]),n=t?.thumbmark;if(typeof n!="string"||n.length<de||n.length>ue)return;let i={};for(let r of ne){let o=t.components?.[r];o==null||o.timeout==="true"||(i[r]=await R(o))}return{hash:n,c:i,...e!==void 0?{hints:e}:{}}}function pe(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:se}):t()})}async function me(t){return t()||(await pe(),t())?"busy":_(le,re)}var x,ne,ie,re,oe,se,ae,ce,de,ue,N=b(()=>{"use strict";x=require("@thumbmarkjs/thumbmarkjs");E();ne=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],ie=2e3,re=4e3,oe=1e3,se=2e3,ae=64,ce=32,de=8,ue=128});var Oe={};M(Oe,{HostedApiError:()=>u,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>k,icaoPolicyOf:()=>q,isInAppBrowser:()=>y,isKnownCode:()=>L,portraitIcaoGate:()=>G,stripMimeParams:()=>p});module.exports=J(Oe);var Z=600;function I(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),n=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(n))return"phone";if(/iPad/i.test(n))return"tablet";if(/Android/i.test(n))return/Mobile/i.test(n)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(n))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(n))return"tablet";if(/Windows NT|CrOS/.test(n)||!ee())return"desktop"}let i=Q();return i>0&&i<Z?"phone":"tablet"}function Q(){try{let t=window.screen,e=Number(t?.width??0),n=Number(t?.height??0);return e>0&&n>0?Math.min(e,n):0}catch{return 0}}function ee(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var f="0.1.0-rc.24";var te=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return te.test(e)}var D="sekyro.did",fe=1e4,ye=()=>globalThis.process?.versions?.node,V;function F(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function he(){try{let t=localStorage.getItem(D);if(t)return t;let e=F();return e!==void 0&&localStorage.setItem(D,e),e}catch{return V??(V=F()),V}}async function ge(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(i),r=>r.toString(16).padStart(2,"0")).join("").slice(0,32)}function be(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function _e(t){let e=new TextEncoder().encode(t),n="";for(let i of e)n+=String.fromCharCode(i);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Te(t){let e,n,i,r,o,a,d=()=>a?.readyState==="live",s=()=>{o!==void 0||!globalThis.crypto?.subtle||ye()||d()||(o=Promise.race([Promise.resolve().then(()=>(N(),H)),new Promise(c=>setTimeout(c,fe))]).then(c=>c?.computePrint(d)).then(c=>{c==="busy"?o=void 0:r=c}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(c){c&&(e=c.slice(0,128))},noteCamera(c){n=c},noteCameraTrack(c){a=c},async deviceHeader(){try{i??(i=ge().catch(()=>""));let c=[];navigator.webdriver&&c.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&c.push("headless");let l=await i,m=he(),$={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...be(),...e?{cameraLabel:e}:{},...c.length?{signals:c}:{},...r?{print:{v:2,...r,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},Y=_e(JSON.stringify($));return s(),Y}catch{return}},printReady(){return o??Promise.resolve()}}}var T=Symbol.for("sekyro.web.clientContext"),S=globalThis,w=S[T]??(S[T]=Te({sdk:`@sekyro/web@${f}`}));var P=["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","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden"];function L(t){return P.includes(t)}var u=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)}};function U(t,e,n=Math.random){let i=(t??e)*1e3,r=Math.min(Math.max(i,500),2e4),o=Math.round(r*(1+(n()*2-1)*.25));return Math.min(Math.max(o,500),2e4)}var Se=6e4,K=4,we=3e4,Pe=9e5,Ce=200,ke=5,Me=400,Ie=new Set(["server_busy","request_timeout"]),ve=2;function p(t){return(t.split(";")[0]??"").trim()}var Re={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},k=`@sekyro/web/${f}`,Ee=k,h=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(i,r)=>(n??globalThis.fetch).call(globalThis,i,r),this.requestTimeoutMs=e.requestTimeoutMs??we,this.retryAttempts=e.inProgressRetry?.attempts??ke,this.retryDelayMs=e.inProgressRetry?.delayMs??Me,this.random=e.random??Math.random}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},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,r=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,o=[e.check,r??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(o);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...i!==void 0?{engineKind:i}:{},...r!==void 0?{attempt:r}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},s=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(o)});return this.reportedIssues.set(o,s),s}async choose(e,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}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,i,r={}){let o=await this.ensureSessionId(),a={kind:e,contentType:p(n),contentLength:i,...r.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${o}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,i,r={}){let o=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...r.engine!==void 0?{engine:r.engine.slice(0,32)}:{},...r.durationMs!==void 0&&Number.isFinite(r.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(r.durationMs)))}:{}},s={kind:e,contentType:p(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${o}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-Se>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let i=e();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(K,Math.max(1,e))}}),r=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let o of Array.isArray(i.nonces)?i.nonces:[])typeof o=="string"&&o.length>0&&this.captureNonces.push({nonce:o,expiresAt:r});this.captureNonces=this.captureNonces.slice(-K)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,i){let r;try{r=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(i)},body:n,signal:AbortSignal.timeout(Pe)})}catch(o){throw C(o)}if(!r.ok){let o=(await r.text().catch(()=>"")).slice(0,Ce);throw new u({status:r.status,code:"upload_failed",message:`media upload failed (HTTP ${r.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,i={}){let r=await this.ensureSessionId(),o={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${r}/checks/${e}`,{body:o,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,i,r={}){let o=p(n.contentType),a=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,o);let d=await this.completeMedia(a.key),s={...i,[Re[e]]:d.key};return this.submitCheck(e,s,r)}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,i={}){let r=e==="GET"||i.busyRetry===!0,o=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":Ee};i.body!==void 0&&(a["content-type"]="application/json"),i.idempotencyKey!==void 0&&(a["x-idempotency-key"]=i.idempotencyKey);try{let d=w.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=I();try{let d=await w.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(o,{method:e,headers:a,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw C(l)}if(s.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await s.blob()}catch(m){throw C(m)}let l;try{l=await s.json()}catch{throw new u({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return Ae(l)}let c=await xe(s);if(c.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(r&&c.status===503&&Ie.has(c.code)){r=!1,await B(U(c.retryAfterSeconds,ve,this.random));continue}throw c}}};function C(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function Ae(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function xe(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,i=Number.NaN,r;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(i=s.retryAfterSeconds),Array.isArray(s.details?.issues)&&(r=s.details)}}catch{}let o=t.headers.get("retry-after"),a=o===null?Math.floor(i):Number.parseInt(o,10);return new u({status:t.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:r})}function B(t){return new Promise(e=>setTimeout(e,t))}function q(t){let e=t?.portrait,n=e?.icao,i=e?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}function G(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-
|
|
2
|
-
export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-
|
|
3
|
-
export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, H as HostedAcceptedDocuments, v as HostedCaptureTuning, w as HostedConsentView, x as HostedDocumentCaptureTuning, y as HostedDocumentScanTuning, z as HostedDocumentsView, B as HostedEidView, G as HostedEmailOtpView, I as HostedFlowRef, J as HostedIcaoPolicy, K as HostedIntegrity, L as HostedLivePhotoTuning, M as HostedNativeCaptureTuning, N as HostedOcrTuning, O as HostedOtpView, P as HostedPlanView, Q as HostedPortraitPendingFix, R as HostedPortraitView, S as HostedSessionView, T as HostedSimulationView, U as HostedStepView, V as
|
|
1
|
+
export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-CX0chQMM.cjs';
|
|
2
|
+
export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-WnG2OSyp.cjs';
|
|
3
|
+
export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, H as HostedAcceptedDocuments, v as HostedCaptureTuning, w as HostedConsentView, x as HostedDocumentCaptureTuning, y as HostedDocumentScanTuning, z as HostedDocumentsView, B as HostedEidView, G as HostedEmailOtpView, I as HostedFlowRef, J as HostedIcaoPolicy, K as HostedIntegrity, L as HostedLivePhotoTuning, M as HostedNativeCaptureTuning, N as HostedOcrTuning, O as HostedOtpView, P as HostedPlanView, Q as HostedPortraitPendingFix, R as HostedPortraitView, S as HostedSessionView, T as HostedSimulationView, U as HostedStepView, V as HostedTesterGateView, W as HostedVoiceLocale, X as HostedVoiceView, Y as IcaoCriterion, Z as IcaoReportEntry, _ as IdentityConfirmDecision, $ as IdentityMethod, a0 as IdentitySummarySource, a1 as IdentitySummaryView, a2 as LivenessCaptureInput, a3 as LivenessInput, a4 as LivenessReason, a5 as MatchReason, a6 as MediaKind, a7 as MethodChoiceView, a8 as NationalEidOption, a9 as NfcChipReason, aa as NfcStepView, ab as OtpChoiceView, ac as PhoneCountryRule, ad as PhoneFormat, ae as PhoneOtpInput, af as PhoneOtpReason, ag as PhotoSource, ah as PhotoSourcePick, ai as PlanAttempts, aj as PlanChoiceKind, ak as PlanChoiceOption, al as PlanChoiceView, am as PlanSectionView, an as PlanStepView, ao as PopulationInput, ap as PopulationReason, aq as PortraitFix, ar as PortraitFixReviewInput, as as PortraitIcaoInput, at as PortraitIcaoReason, au as PortraitOutputFormat, av as PresignRequest, aw as PresignUploadResult, ax as RecordConsentResult, ay as ResolvedCaptureMode, az as SessionDecidingStep, aA as SessionFailureReason, aB as SessionReason, aC as SessionStatus, aD as SessionStepView, aE as SessionView, aF as SimulatedCaptureInput, aG as StepResult, aH as StepSection, aI as SubmitCheckBody, aJ as TesterGateInput, aK as TesterGateResponse, aL as VerificationAssurance, aM as VerificationLevel } from '../types-1s8CQrEN.cjs';
|
|
4
4
|
|
|
5
5
|
/** The page runs inside an app's WebView (WhatsApp, Instagram, Facebook, TikTok, Snapchat, LINE, LinkedIn, WeChat, an Android WebView…). */
|
|
6
6
|
declare function isInAppBrowser(userAgent?: string): boolean;
|