1import{Pt as e,yt as t}from"./utils-2QJCWHty.js";import{t as n}from"./createLucideIcon-CbSleXky.js";import{a as r,n as i,o as a,s as o}from"./app-CJHvcjra.js";var s=n(`FingerprintIcon`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]);function c(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function l(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function u(){return d.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var d={stubThis:e=>e};function f(e){let{id:t}=e;return{...e,id:l(t),transports:e.transports}}function p(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var m=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function h({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new m({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new m({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new m({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new m({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new m({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new m({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new m({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new m({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!p(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new m({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new m({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new m({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var g=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},_=[`cross-platform`,`platform`];function v(e){if(e&&!(_.indexOf(e)<0))return e}async function y(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!u())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:l(t.challenge),user:{...t.user,id:l(t.user.id)},excludeCredentials:t.excludeCredentials?.map(f)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=g.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw h({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:d,type:p}=a,m;typeof d.getTransports==`function`&&(m=d.getTransports());let _;if(typeof d.getPublicKeyAlgorithm==`function`)try{_=d.getPublicKeyAlgorithm()}catch(e){b(`getPublicKeyAlgorithm()`,e)}let y;if(typeof d.getPublicKey==`function`)try{let e=d.getPublicKey();e!==null&&(y=c(e))}catch(e){b(`getPublicKey()`,e)}let x;if(typeof d.getAuthenticatorData==`function`)try{x=c(d.getAuthenticatorData())}catch(e){b(`getAuthenticatorData()`,e)}return{id:o,rawId:c(s),response:{attestationObject:c(d.attestationObject),clientDataJSON:c(d.clientDataJSON),transports:m,publicKeyAlgorithm:_,publicKey:y,authenticatorData:x},type:p,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:v(a.authenticatorAttachment)}}function b(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function x(){if(!u())return S.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?S.stubThis(new Promise(e=>e(!1))):S.stubThis(e.isConditionalMediationAvailable())}var S={stubThis:e=>e};function C({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);
1if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new m({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new m({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!p(t))return new m({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new m({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new m({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function w(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!u())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(f));let a={...t,challenge:l(t.challenge),allowCredentials:i},o={};if(n){if(!await x())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=g.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw C({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:d,rawId:p,response:m,type:h}=s,_;return m.userHandle&&(_=c(m.userHandle)),{id:d,rawId:c(p),response:{authenticatorData:c(m.authenticatorData),clientDataJSON:c(m.clientDataJSON),signature:c(m.signature),userHandle:_},type:h,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:v(s.authenticatorAttachment)}}function T(){let n=t(u()),s=t(!1),c=t(!1),l=t(null);function d(e){return e instanceof m&&(e.name===`NotAllowedError`||e.code===`ERROR_CEREMONY_ABORTED`)||e instanceof Error&&e.name===`NotAllowedError`?null:`Your browser could not complete the passkey request. Please try again.`}async function f(t=``){l.value=null,s.value=!0;try{let n=await(await fetch(a.url(),{headers:{Accept:`application/json`},credentials:`same-origin`})).json(),r=await y({optionsJSON:n});e.post(o.url(),{passkey:JSON.stringify(r),options:JSON.stringify(n),name:t},{preserveScroll:!0})}catch(e){l.value=d(e)}finally{s.value=!1}}async function p(){l.value=null,c.value=!0;try{let t=await w({optionsJSON:await(await fetch(i.url(),{headers:{Accept:`application/json`},credentials:`same-origin`})).json()});e.post(r.url(),{start_authentication_response:JSON.stringify(t)})}catch(e){l.value=d(e)}finally{c.value=!1}}return{isSupported:n,registering:s,authenticating:c,error:l,register:f,authenticate:p}}export{s as n,T as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.