/* [@simplewebauthn/browser@14.0.0] */ function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(e,t){if("function"==typeof define&&define.amd)define("SimpleWebAuthnBrowser",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.SimpleWebAuthnBrowser=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function r(){r=function(){return n};var t,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},s=u.iterator||"@@iterator",c=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof g?t:g,i=Object.create(o.prototype),u=new k(n||[]);return a(i,"_invoke",{value:S(e,r,u)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var h="suspendedStart",y="suspendedYield",b="executing",w="completed",v={};function g(){}function m(){}function A(){}var E={};f(E,s,(function(){return this}));var R=Object.getPrototypeOf,O=R&&R(R(N([])));O&&O!==o&&i.call(O,s)&&(E=O);var _=A.prototype=g.prototype=Object.create(E);function I(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function P(t,r){function n(o,a,u,s){var c=d(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(e){n("next",e,u,s)}),(function(e){n("throw",e,u,s)})):r.resolve(f).then((function(e){l.value=e,u(l)}),(function(e){return n("throw",e,u,s)}))}s(c.arg)}var o;a(this,"_invoke",{value:function(e,t){function i(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(i,i):i()}})}function S(e,r,n){var o=h;return function(i,a){if(o===b)throw Error("Generator is already running");if(o===w){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var s=C(u,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=w,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var c=d(e,r,n);if("normal"===c.type){if(o=n.done?w:y,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=w,n.method="throw",n.arg=c.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(r){if(r||""===r){var n=r[s];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},n}function n(e,t,r,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,s,"next",e)}function s(e){n(a,o,i,u,s,"throw",e)}u(void 0)}))}}function i(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r64)return new _({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}var P=function(){return a((function e(){u(this,e),Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}),[{key:"createNewAbortSignal",value:function(){if(this.controller){var e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}var t=new AbortController;return this.controller=t,t.signal}},{key:"cancelCeremony",value:function(){if(this.controller){var e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}])}(),S=t.WebAuthnAbortService=new P,C=["cross-platform","platform"];function x(e){if(e&&!(C.indexOf(e)<0))return e}function T(){return(T=o(r().mark((function e(t){var n,o,i,a,u,s,c,l,f,p,d,y,b,w,v,E,O,_;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.optionsJSON&&t.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."),t={optionsJSON:t}),i=(o=t).optionsJSON,a=o.useAutoRegister,u=void 0!==a&&a,A()){e.next=4;break}throw new Error("WebAuthn is not supported in this browser");case 4:return s=h(h({},i),{},{challenge:m(i.challenge),user:h(h({},i.user),{},{id:m(i.user.id)}),excludeCredentials:null===(n=i.excludeCredentials)||void 0===n?void 0:n.map(R)}),c={},u&&(c.mediation="conditional"),c.publicKey=s,c.signal=S.createNewAbortSignal(),e.prev=9,e.next=12,navigator.credentials.create(c);case 12:l=e.sent,e.next=18;break;case 15:throw e.prev=15,e.t0=e.catch(9),I({error:e.t0,options:c});case 18:if(l){e.next=20;break}throw new Error("Registration was not completed");case 20:if(p=(f=l).id,d=f.rawId,y=f.response,b=f.type,w=void 0,"function"==typeof y.getTransports&&(w=y.getTransports()),v=void 0,"function"==typeof y.getPublicKeyAlgorithm)try{v=y.getPublicKeyAlgorithm()}catch(e){k("getPublicKeyAlgorithm()",e)}if(E=void 0,"function"==typeof y.getPublicKey)try{null!==(O=y.getPublicKey())&&(E=g(O))}catch(e){k("getPublicKey()",e)}if("function"==typeof y.getAuthenticatorData)try{_=g(y.getAuthenticatorData())}catch(e){k("getAuthenticatorData()",e)}return e.abrupt("return",{id:p,rawId:g(d),response:{attestationObject:g(y.attestationObject),clientDataJSON:g(y.clientDataJSON),transports:w,publicKeyAlgorithm:v,publicKey:E,authenticatorData:_},type:b,clientExtensionResults:l.getClientExtensionResults(),authenticatorAttachment:x(l.authenticatorAttachment)});case 29:case"end":return e.stop()}}),e,null,[[9,15]])})))).apply(this,arguments)}function k(e,t){console.warn("The browser extension that intercepted this WebAuthn API call incorrectly implemented ".concat(e,". You should report this error to them.\n"),t)}function N(){if(!A())return D.stubThis(new Promise((function(e){return e(!1)})));var e=window.PublicKeyCredential;return void 0===(null==e?void 0:e.isConditionalMediationAvailable)?D.stubThis(new Promise((function(e){return e(!1)}))):D.stubThis(e.isConditionalMediationAvailable())}var D=t._browserSupportsWebAuthnAutofillInternals={stubThis:function(e){return e}};function L(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new _({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){var o=window.location.hostname;if(!O(o))return new _({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==o)return new _({message:'The RP ID "'.concat(n.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}function U(){return(U=o(r().mark((function e(t){var n,o,i,a,u,s,c,l,f,p,d,y,b,w,v,E,O,_;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.optionsJSON&&t.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."),t={optionsJSON:t}),i=(o=t).optionsJSON,a=o.useBrowserAutofill,u=void 0!==a&&a,s=o.verifyBrowserAutofillInput,c=void 0===s||s,A()){e.next=4;break}throw new Error("WebAuthn is not supported in this browser");case 4:if(0!==(null===(n=i.allowCredentials)||void 0===n?void 0:n.length)&&(l=null===(f=i.allowCredentials)||void 0===f?void 0:f.map(R)),p=h(h({},i),{},{challenge:m(i.challenge),allowCredentials:l}),d={},!u){e.next=17;break}return e.next=10,N();case 10:if(e.sent){e.next=12;break}throw Error("Browser does not support WebAuthn autofill");case 12:if(!(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&c)){e.next=15;break}throw Error('No with "webauthn" as the only or last value in its `autocomplete` attribute was detected');case 15:d.mediation="conditional",p.allowCredentials=[];case 17:return d.publicKey=p,d.signal=S.createNewAbortSignal(),e.prev=19,e.next=22,navigator.credentials.get(d);case 22:y=e.sent,e.next=28;break;case 25:throw e.prev=25,e.t0=e.catch(19),L({error:e.t0,options:d});case 28:if(y){e.next=30;break}throw new Error("Authentication was not completed");case 30:return w=(b=y).id,v=b.rawId,E=b.response,O=b.type,_=void 0,E.userHandle&&(_=g(E.userHandle)),e.abrupt("return",{id:w,rawId:g(v),response:{authenticatorData:g(E.authenticatorData),clientDataJSON:g(E.clientDataJSON),signature:g(E.signature),userHandle:_},type:O,clientExtensionResults:y.getClientExtensionResults(),authenticatorAttachment:x(y.authenticatorAttachment)});case 34:case"end":return e.stop()}}),e,null,[[19,25]])})))).apply(this,arguments)}function j(e){var t=e.error,r=e.options;if("SecurityError"===t.name)return O(window.location.hostname)?new _({message:'The browser does not support Related Origins to enable signals for RP ID "'.concat(r.rpID,'" on domain "').concat(window.location.hostname,'"'),code:"ERROR_INVALID_RP_ID",cause:t}):new _({message:'"'.concat(window.location.hostname,'" is an invalid domain'),code:"ERROR_INVALID_DOMAIN",cause:t});if("unknownCredential"===r.signalName){if("TypeError"===t.name)return new _({message:"credentialID is an invalid base64url string",code:"ERROR_SIGNAL_INVALID_ARGUMENT",cause:t})}else if("allAcceptedCredentials"===r.signalName){if("TypeError"===t.name)return new _({message:"userID, or an entry in allAcceptedCredentialIDs, is an invalid base64url string",code:"ERROR_SIGNAL_INVALID_ARGUMENT",cause:t})}else if("currentUserDetails"===r.signalName&&"TypeError"===t.name)return new _({message:"userID is an invalid base64url string",code:"ERROR_SIGNAL_INVALID_ARGUMENT",cause:t});return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function K(){return(K=o(r().mark((function e(t){var n;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("unknownCredential"!==(n=t.signalName)){e.next=5;break}return e.abrupt("return",G(t));case 5:if("allAcceptedCredentials"!==n){e.next=9;break}return e.abrupt("return",V(t));case 9:if("currentUserDetails"!==n){e.next=11;break}return e.abrupt("return",W(t));case 11:throw new Error('Received unrecognized signalName "'.concat(t.signalName,'"'));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function G(e){return M.apply(this,arguments)}function M(){return(M=o(r().mark((function e(t){var n;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"==typeof(n=window.PublicKeyCredential).signalUnknownCredential){e.next=3;break}throw new Error("This browser does not support PublicKeyCredential.signalUnknownCredential()");case 3:return e.prev=3,e.next=6,n.signalUnknownCredential({rpId:t.rpID,credentialId:t.credentialID});case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(3),j({error:e.t0,options:t});case 11:return e.abrupt("return",void 0);case 12:case"end":return e.stop()}}),e,null,[[3,8]])})))).apply(this,arguments)}function V(e){return B.apply(this,arguments)}function B(){return(B=o(r().mark((function e(t){var n;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"==typeof(n=window.PublicKeyCredential).signalAllAcceptedCredentials){e.next=3;break}throw new Error("This browser does not support PublicKeyCredential.signalAllAcceptedCredentials()");case 3:return e.prev=3,e.next=6,n.signalAllAcceptedCredentials({rpId:t.rpID,userId:t.userID,allAcceptedCredentialIds:t.allAcceptedCredentialIDs});case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(3),j({error:e.t0,options:t});case 11:return e.abrupt("return",void 0);case 12:case"end":return e.stop()}}),e,null,[[3,8]])})))).apply(this,arguments)}function W(e){return H.apply(this,arguments)}function H(){return(H=o(r().mark((function e(t){var n,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"==typeof(n=window.PublicKeyCredential).signalCurrentUserDetails){e.next=3;break}throw new Error("This browser does not support PublicKeyCredential.signalCurrentUserDetails()");case 3:return e.prev=3,e.next=6,n.signalCurrentUserDetails({rpId:t.rpID,userId:t.userID,name:t.userName,displayName:null!==(o=t.userDisplayName)&&void 0!==o?o:""});case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(3),j({error:e.t0,options:t});case 11:return e.abrupt("return",void 0);case 12:case"end":return e.stop()}}),e,null,[[3,8]])})))).apply(this,arguments)}function Y(){return F.apply(this,arguments)}function F(){return(F=o(r().mark((function e(){var t,n,o,i,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof PublicKeyCredential.getClientCapabilities){e.next=17;break}return e.next=3,PublicKeyCredential.getClientCapabilities();case 3:if(t=e.sent,"unknown"!==(n=J(t.userVerifyingPlatformAuthenticator))||"function"!=typeof PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable){e.next=10;break}return e.next=8,PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();case 8:o=e.sent,n=o?"supported":"unsupported";case 10:if("unknown"!==(i=J(t.conditionalGet))||"function"!=typeof PublicKeyCredential.isConditionalMediationAvailable){e.next=16;break}return e.next=14,PublicKeyCredential.isConditionalMediationAvailable();case 14:a=e.sent,i=a?"supported":"unsupported";case 16:return e.abrupt("return",q.stubThis({conditionalCreate:J(t.conditionalCreate),conditionalGet:i,hybridTransport:J(t.hybridTransport),passkeyPlatformAuthenticator:J(t.passkeyPlatformAuthenticator),userVerifyingPlatformAuthenticator:n,relatedOrigins:J(t.relatedOrigins),signalAllAcceptedCredentials:J(t.signalAllAcceptedCredentials),signalCurrentUserDetails:J(t.signalCurrentUserDetails),signalUnknownCredential:J(t.signalUnknownCredential)}));case 17:return e.abrupt("return",q.stubThis({conditionalCreate:"unknown",conditionalGet:"unknown",hybridTransport:"unknown",passkeyPlatformAuthenticator:"unknown",userVerifyingPlatformAuthenticator:"unknown",relatedOrigins:"unknown",signalAllAcceptedCredentials:"unknown",signalCurrentUserDetails:"unknown",signalUnknownCredential:"unknown"}));case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e){if(!0===e)return"supported";if(!1===e)return"unsupported";if(void 0===e)return"unknown";throw new Error("Unexpected capability value:",e)}var q=t._getBrowserCapabilitiesInternals={stubThis:function(e){return e}};function z(){return(z=o(r().mark((function e(){var t,n,o,i;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(A()){e.next=2;break}return e.abrupt("return",new Promise((function(e){return e(!1)})));case 2:return e.next=4,Y();case 4:return t=e.sent,n=t.passkeyPlatformAuthenticator,o=t.userVerifyingPlatformAuthenticator,i=t.hybridTransport,e.abrupt("return","supported"===n||"supported"===i||"supported"===o);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}}));