@authsignal/browser 1.17.0 → 1.18.0

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.
@@ -5,8 +5,9 @@ export declare class PushApiClient {
5
5
  baseUrl: string;
6
6
  onTokenExpired?: () => void;
7
7
  constructor({ baseUrl, tenantId, onTokenExpired }: ApiClientOptions);
8
- challenge({ action, token }: {
8
+ challenge({ action, userAuthenticatorId, token, }: {
9
9
  action: string;
10
+ userAuthenticatorId?: string;
10
11
  token: string;
11
12
  }): Promise<PushChallengeResponse | ErrorResponse>;
12
13
  verify({ challengeId, token, }: {
package/dist/index.js CHANGED
@@ -3598,11 +3598,11 @@ var PushApiClient = /** @class */ (function () {
3598
3598
  PushApiClient.prototype.challenge = function (_a) {
3599
3599
  return __awaiter(this, arguments, void 0, function (_b) {
3600
3600
  var body, response, responseJson;
3601
- var action = _b.action, token = _b.token;
3601
+ var action = _b.action, userAuthenticatorId = _b.userAuthenticatorId, token = _b.token;
3602
3602
  return __generator(this, function (_c) {
3603
3603
  switch (_c.label) {
3604
3604
  case 0:
3605
- body = { action: action };
3605
+ body = __assign({ action: action }, (userAuthenticatorId && { userAuthenticatorId: userAuthenticatorId }));
3606
3606
  return [4 /*yield*/, fetch("".concat(this.baseUrl, "/client/challenge/push"), {
3607
3607
  method: "POST",
3608
3608
  headers: buildHeaders({ token: token, tenantId: this.tenantId }),
@@ -3657,14 +3657,14 @@ var Push = /** @class */ (function () {
3657
3657
  Push.prototype.challenge = function (_a) {
3658
3658
  return __awaiter(this, arguments, void 0, function (_b) {
3659
3659
  var response;
3660
- var action = _b.action;
3660
+ var action = _b.action, userAuthenticatorId = _b.userAuthenticatorId;
3661
3661
  return __generator(this, function (_c) {
3662
3662
  switch (_c.label) {
3663
3663
  case 0:
3664
3664
  if (!this.cache.token) {
3665
3665
  return [2 /*return*/, this.cache.handleTokenNotSetError()];
3666
3666
  }
3667
- return [4 /*yield*/, this.api.challenge({ action: action, token: this.cache.token })];
3667
+ return [4 /*yield*/, this.api.challenge({ action: action, userAuthenticatorId: userAuthenticatorId, token: this.cache.token })];
3668
3668
  case 1:
3669
3669
  response = _c.sent();
3670
3670
  return [2 /*return*/, handleApiResponse({ response: response, enableLogging: this.enableLogging })];
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- var authsignal=function(e){"use strict";let t;const n=new Uint8Array(16);function i(){if(!t&&(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function s(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const s=(e=e||{}).random||(e.rng||i)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=s[e];return t}return function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(s)}var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l=function(){return l=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},l.apply(this,arguments)};function h(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function u(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function d(e,t){var n,i,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function p(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}function g(e){const t=new Uint8Array(e);let n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function f(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,i=t.padEnd(t.length+n,"="),o=atob(i),r=new ArrayBuffer(o.length),s=new Uint8Array(r);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return r}function v(){return b.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const b={stubThis:e=>e};function y(e){const{id:t}=e;return{...e,id:f(t),transports:e.transports}}function m(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class k extends Error{constructor({message:e,code:t,cause:n,name:i}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i??n.name,this.code=t}}const w=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},E=["cross-platform","platform"];function I(e){if(e&&!(E.indexOf(e)<0))return e}async function T(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});const{optionsJSON:t,useAutoRegister:n=!1}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");const i={...t,challenge:f(t.challenge),user:{...t.user,id:f(t.user.id)},excludeCredentials:t.excludeCredentials?.map(y)},o={};let r;n&&(o.mediation="conditional"),o.publicKey=i,o.signal=w.createNewAbortSignal();try{r=await navigator.credentials.create(o)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new k({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===n.authenticatorSelection?.requireResidentKey)return new k({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&"required"===n.authenticatorSelection?.userVerification)return new k({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if("required"===n.authenticatorSelection?.userVerification)return new k({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if("InvalidStateError"===e.name)return new k({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new k({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===n.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new k({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new k({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!m(t))return new k({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new k({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new k({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new k({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}({error:e,options:o})}if(!r)throw new Error("Registration was not completed");const{id:s,rawId:a,response:c,type:l}=r;let h,u,d,p;if("function"==typeof c.getTransports&&(h=c.getTransports()),"function"==typeof c.getPublicKeyAlgorithm)try{u=c.getPublicKeyAlgorithm()}catch(e){C("getPublicKeyAlgorithm()",e)}if("function"==typeof c.getPublicKey)try{const e=c.getPublicKey();null!==e&&(d=g(e))}catch(e){C("getPublicKey()",e)}if("function"==typeof c.getAuthenticatorData)try{p=g(c.getAuthenticatorData())}catch(e){C("getAuthenticatorData()",e)}return{id:s,rawId:g(a),response:{attestationObject:g(c.attestationObject),clientDataJSON:g(c.clientDataJSON),transports:h,publicKeyAlgorithm:u,publicKey:d,authenticatorData:p},type:l,clientExtensionResults:r.getClientExtensionResults(),authenticatorAttachment:I(r.authenticatorAttachment)}}function C(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)}const A={stubThis:e=>e};async function S(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});const{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:i=!0}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");let o;0!==t.allowCredentials?.length&&(o=t.allowCredentials?.map(y));const r={...t,challenge:f(t.challenge),allowCredentials:o},s={};if(n){if(!await function(){if(!v())return A.stubThis(new Promise((e=>e(!1))));const e=globalThis.PublicKeyCredential;return void 0===e?.isConditionalMediationAvailable?A.stubThis(new Promise((e=>e(!1)))):A.stubThis(e.isConditionalMediationAvailable())}())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&i)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');s.mediation="conditional",r.allowCredentials=[]}let a;s.publicKey=r,s.signal=w.createNewAbortSignal();try{a=await navigator.credentials.get(s)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new k({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new k({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!m(t))return new k({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rpId!==t)return new k({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new k({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}({error:e,options:s})}if(!a)throw new Error("Authentication was not completed");const{id:c,rawId:l,response:h,type:u}=a;let d;return h.userHandle&&(d=g(h.userHandle)),{id:c,rawId:g(l),response:{authenticatorData:g(h.authenticatorData),clientDataJSON:g(h.clientDataJSON),signature:g(h.signature),userHandle:d},type:u,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:I(a.authenticatorAttachment)}}function R(e){var t=e.name,n=e.value,i=e.expire,o=e.domain,r=e.secure,s=i===1/0?" expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+i;document.cookie=encodeURIComponent(t)+"="+n+"; path=/;"+s+(o?"; domain="+o:"")+(r?"; secure":"")}function L(e){var t,n=e.errorResponse;return e.enableLogging&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:null!==(t=n.errorDescription)&&void 0!==t?t:n.error,errorCode:n.errorCode,errorDescription:n.errorDescription}}function O(e){var t,n=e.response,i=e.enableLogging;if(n&&"object"==typeof n&&"error"in n){var o=null!==(t=n.errorDescription)&&void 0!==t?t:n.error;return i&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:o,errorCode:n.errorCode,errorDescription:n.errorDescription}}if(n&&"object"==typeof n&&"accessToken"in n&&"string"==typeof n.accessToken){var r=n.accessToken,s=h(n,["accessToken"]);return{data:l(l({},s),{token:r})}}return{data:n}}function _(e){var t,n;if(e instanceof k&&"ERROR_INVALID_RP_ID"===e.code){var i=(null===(n=null===(t=e.message)||void 0===t?void 0:t.match(/"([^"]*)"/))||void 0===n?void 0:n[1])||"";console.error('[Authsignal] The Relying Party ID "'.concat(i,'" is invalid for this domain.\n To learn more, visit https://docs.authsignal.com/scenarios/passkeys-prebuilt-ui#defining-the-relying-party'))}}var x,P;function U(e){var t=e.token,n=e.tenantId;return{"Content-Type":"application/json",Authorization:t?"Bearer ".concat(t):"Basic ".concat(window.btoa(encodeURIComponent(n)))}}function N(e){var t=e.response,n=e.onTokenExpired;"error"in t&&"expired_token"===t.errorCode&&n&&n()}e.AuthsignalWindowMessage=void 0,(x=e.AuthsignalWindowMessage||(e.AuthsignalWindowMessage={})).AUTHSIGNAL_CLOSE_POPUP="AUTHSIGNAL_CLOSE_POPUP",x.AUTHSIGNAL_API_ERROR="AUTHSIGNAL_API_ERROR",x.AUTHSIGNAL_READY="AUTHSIGNAL_READY",e.ErrorCode=void 0,(P=e.ErrorCode||(e.ErrorCode={})).token_not_set="token_not_set",P.expired_token="expired_token",P.network_error="network_error",P.too_many_requests="too_many_requests",P.invalid_credential="invalid_credential",P.unknown_credential="unknown_credential";var D,$,j,H=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r=e.token,s=e.username,a=e.authenticatorAttachment,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t=Boolean(a)?{username:s,authenticatorAttachment:a}:{username:s},n="".concat(this.baseUrl,c?"/client/user-authenticators/passkey/registration-options/web":"/client/user-authenticators/passkey/registration-options"),i=c?"include":"same-origin",[4,fetch(n,{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:i})];case 1:return[4,e.sent().json()];case 2:return N({response:o=e.sent(),onTokenExpired:this.onTokenExpired}),[2,o]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.challengeId,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({challengeId:i}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptionsWeb=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options/web"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({}),credentials:"include"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.registrationCredential,r=e.conditionalCreate,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={registrationCredential:o,conditionalCreate:r,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.authenticationCredential,o=e.token,r=e.deviceId,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={authenticationCredential:i,deviceId:r,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/verify/passkey"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.getAuthenticators=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators"),{method:"GET",headers:U({token:n,tenantId:this.tenantId}),credentials:i?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.getPasskeyAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey?credentialIds=").concat(n),{method:"GET",headers:U({tenantId:this.tenantId})})];case 1:if(!(t=e.sent()).ok)throw new Error(t.statusText);return[2,t.json()]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t="".concat(this.baseUrl,o?"/client/challenge/web":"/client/challenge"),[4,fetch(t,{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify({action:i}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),M=function(){function t(){this.token=null}return t.prototype.handleTokenNotSetError=function(){var t=e.ErrorCode.token_not_set,n="A token has not been set. Call 'setToken' first.";return console.error("Error: ".concat(n)),{error:t,errorCode:t,errorDescription:n}},t.shared=new t,t}();function K(){return"undefined"==typeof window||void 0===window.PublicKeyCredential?null:window.PublicKeyCredential}function W(e,t){return u(this,arguments,void 0,(function(e,t){var n,i,o=e.rpId,r=e.userId,s=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:if(!(null==(n=K())?void 0:n.signalAllAcceptedCredentials))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.signalAllAcceptedCredentials({rpId:o,userId:r,allAcceptedCredentialIds:s})];case 2:return e.sent(),[3,4];case 3:return i=e.sent(),t&&console.warn("[Authsignal] signalAllAcceptedCredentials failed",i),[3,4];case 4:return[2]}}))}))}function J(e,t){return u(this,arguments,void 0,(function(e,t){var n,i,o=e.rpId,r=e.credentialId;return d(this,(function(e){switch(e.label){case 0:if(!(null==(n=K())?void 0:n.signalUnknownCredential))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.signalUnknownCredential({rpId:o,credentialId:r})];case 2:return e.sent(),[3,4];case 3:return i=e.sent(),t&&console.warn("[Authsignal] signalUnknownCredential failed",i),[3,4];case 4:return[2]}}))}))}!function(e){e.SMS="SMS",e.AUTHENTICATOR_APP="AUTHENTICATOR_APP",e.RECOVERY_CODE="RECOVERY_CODE",e.EMAIL_MAGIC_LINK="EMAIL_MAGIC_LINK",e.EMAIL_OTP="EMAIL_OTP",e.PUSH="PUSH",e.SECURITY_KEY="SECURITY_KEY",e.PASSKEY="PASSKEY",e.VERIFF="VERIFF",e.IPROOV="IPROOV",e.PALM_BIOMETRICS_RR="PALM_BIOMETRICS_RR",e.IDVERSE="IDVERSE",e.DEVICE="DEVICE"}(D||(D={})),function(e){e.DEFAULT="DEFAULT",e.WHATSAPP="WHATSAPP",e.SMS="SMS"}($||($={})),function(e){e.IOS="IOS",e.ANDROID="ANDROID",e.WEB="WEB"}(j||(j={}));var V=!1,G=function(){function t(e){var t=e.baseUrl,n=e.tenantId,i=e.anonymousId,o=e.onTokenExpired,r=e.enableLogging;this.passkeyLocalStorageKey="as_user_passkey_map",this.cache=M.shared,this.enableLogging=!1,this.api=new H({baseUrl:t,tenantId:n,onTokenExpired:o}),this.anonymousId=i,this.enableLogging=r}return t.prototype.signUp=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s,a,c,h=e.username,u=e.displayName,p=e.token,g=e.authenticatorAttachment,f=void 0===g?"platform":g,v=e.hints,b=e.useAutoRegister,y=void 0!==b&&b,m=e.useCookies,k=void 0!==m&&m,w=e.syncCredentials,E=void 0===w||w;return d(this,(function(e){switch(e.label){case 0:return(t=null!=p?p:this.cache.token)?y?[4,this.doesBrowserSupportConditionalCreate()]:[3,2]:[2,this.cache.handleTokenNotSetError()];case 1:if(!e.sent())throw new Error("CONDITIONAL_CREATE_NOT_SUPPORTED");e.label=2;case 2:return n={username:h,displayName:u,token:t,authenticatorAttachment:f,useCookies:k},[4,this.api.registrationOptions(n)];case 3:if("error"in(i=e.sent()))return[2,L({errorResponse:i,enableLogging:this.enableLogging})];e.label=4;case 4:return e.trys.push([4,7,,8]),[4,T({optionsJSON:v?l(l({},i.options),{hints:v}):i.options,useAutoRegister:y})];case 5:return o=e.sent(),[4,this.api.addAuthenticator({registrationCredential:o,token:t,conditionalCreate:y,challengeId:i.challengeId,useCookies:k})];case 6:return"error"in(r=e.sent())?[2,L({errorResponse:r,enableLogging:this.enableLogging})]:(r.isVerified&&this.storeCredentialAgainstDevice(l(l({},o),{userId:r.userId})),r.accessToken&&(this.cache.token=r.accessToken),E&&r.isVerified&&(r.accessToken||k)&&(s=null!==(c=i.options.rp.id)&&void 0!==c?c:window.location.hostname,this.syncPasskeysWithCredentialManager({rpId:s,userHandle:i.options.user.id,credentialId:o.id,token:r.accessToken,useCookies:k})),[2,{data:{token:r.accessToken,userAuthenticator:r.userAuthenticator,registrationResponse:o}}]);case 7:throw a=e.sent(),V=!1,_(a),a;case 8:return[2]}}))}))},t.prototype.signIn=function(t){return u(this,void 0,void 0,(function(){var n,i,o,r,s,a,c,h,u,p,g,f,v,b,y,m,k;return d(this,(function(d){switch(d.label){case 0:if((null==t?void 0:t.token)&&t.autofill)throw new Error("autofill is not supported when providing a token");if((null==t?void 0:t.action)&&t.token)throw new Error("action is not supported when providing a token");if(n=null===(k=null==t?void 0:t.syncCredentials)||void 0===k||k,null==t?void 0:t.autofill){if(V)return[2,{}];V=!0}return(null==t?void 0:t.action)?[4,this.api.challenge({action:null==t?void 0:t.action,useCookies:null==t?void 0:t.useCookies})]:[3,2];case 1:return o=d.sent(),[3,3];case 2:o=null,d.label=3;case 3:return(i=o)&&"error"in i?(V=!1,[2,L({errorResponse:i,enableLogging:this.enableLogging})]):!(null==t?void 0:t.action)&&(null==t?void 0:t.useCookies)?[3,5]:[4,this.api.authenticationOptions({token:null==t?void 0:t.token,challengeId:null==i?void 0:i.challengeId,useCookies:null==t?void 0:t.useCookies})];case 4:return s=d.sent(),[3,7];case 5:return[4,this.api.authenticationOptionsWeb({token:null==t?void 0:t.token})];case 6:s=d.sent(),d.label=7;case 7:if("error"in(r=s))return V=!1,[2,L({errorResponse:r,enableLogging:this.enableLogging})];d.label=8;case 8:return d.trys.push([8,14,,15]),[4,S({optionsJSON:r.options,useBrowserAutofill:null==t?void 0:t.autofill})];case 9:return a=d.sent(),(null==t?void 0:t.onVerificationStarted)&&t.onVerificationStarted(),[4,this.api.verify({authenticationCredential:a,token:null==t?void 0:t.token,deviceId:this.anonymousId,challengeId:r.challengeId,useCookies:null==t?void 0:t.useCookies})];case 10:return"error"in(c=d.sent())?(V=!1,n&&c.errorCode===e.ErrorCode.unknown_credential?[4,J({rpId:u=this.getAuthOptionsRpId(r.options),credentialId:a.id},this.enableLogging)]:[3,12]):[3,13];case 11:d.sent(),this.removeCredentialFromLocalCache(a.id),d.label=12;case 12:return[2,L({errorResponse:c,enableLogging:this.enableLogging})];case 13:return c.isVerified&&this.storeCredentialAgainstDevice(l(l({},a),{userId:c.userId})),c.accessToken&&(this.cache.token=c.accessToken),h=a.response.userHandle,n&&c.isVerified&&(c.accessToken||(null==t?void 0:t.useCookies))&&h&&(u=this.getAuthOptionsRpId(r.options),this.syncPasskeysWithCredentialManager({rpId:u,userHandle:h,credentialId:a.id,token:c.accessToken,useCookies:null==t?void 0:t.useCookies})),p=c.accessToken,g=c.userId,f=c.userAuthenticatorId,v=c.username,b=c.userDisplayName,y=c.isVerified,V=!1,[2,{data:{isVerified:y,token:p,userId:g,userAuthenticatorId:f,username:v,displayName:b,authenticationResponse:a}}];case 14:throw m=d.sent(),V=!1,_(m),m;case 15:return[2]}}))}))},t.prototype.isAvailableOnDevice=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r=e.userId;return d(this,(function(e){switch(e.label){case 0:if(!r)throw new Error("userId is required");if(!(t=localStorage.getItem(this.passkeyLocalStorageKey)))return[2,!1];if(n=JSON.parse(t),0===(i=null!==(o=n[r])&&void 0!==o?o:[]).length)return[2,!1];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.api.getPasskeyAuthenticator({credentialIds:i})];case 2:return e.sent(),[2,!0];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},t.prototype.storeCredentialAgainstDevice=function(e){var t=e.id,n=e.authenticatorAttachment,i=e.userId,o=void 0===i?"":i;if("cross-platform"!==n){var r=localStorage.getItem(this.passkeyLocalStorageKey),s=r?JSON.parse(r):{};s[o]?s[o].includes(t)||s[o].push(t):s[o]=[t],localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(s))}},t.prototype.doesBrowserSupportConditionalCreate=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return(null==(e=window.PublicKeyCredential)?void 0:e.getClientCapabilities)?[4,e.getClientCapabilities()]:[3,2];case 1:if(t.sent().conditionalCreate)return[2,!0];t.label=2;case 2:return[2,!1]}}))}))},t.prototype.getAuthOptionsRpId=function(e){var t=null==e?void 0:e.rpId;return null!=t?t:window.location.hostname},t.prototype.syncPasskeysWithCredentialManager=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o=e.rpId,r=e.userHandle,s=e.credentialId,a=e.token,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.api.getAuthenticators({token:a,useCookies:c})];case 1:return t=e.sent(),Array.isArray(t)?(n=t.filter((function(e){var t;return e.verificationMethod===D.PASSKEY&&Boolean(null===(t=e.webauthnCredential)||void 0===t?void 0:t.credentialId)})).map((function(e){return e.webauthnCredential.credentialId})),[4,W({rpId:o,userId:r,credentialIds:Array.from(new Set(p(p([],n,!0),[s],!1)))},this.enableLogging)]):(this.enableLogging&&console.warn("[Authsignal] Could not fetch authenticators for passkey sync",t),[2]);case 2:return e.sent(),[3,4];case 3:return i=e.sent(),this.enableLogging&&console.warn("[Authsignal] Passkey sync failed",i),[3,4];case 4:return[2]}}))}))},t.prototype.removeCredentialFromLocalCache=function(e){var t=localStorage.getItem(this.passkeyLocalStorageKey);if(t){var n;try{n=JSON.parse(t)}catch(e){return}for(var i=!1,o=0,r=Object.keys(n);o<r.length;o++){var s=r[o],a=n[s].filter((function(t){return t!==e}));a.length!==n[s].length&&(n[s]=a,i=!0)}i&&localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(n))}},t}(),F=function(){function e(){this.windowRef=null}return e.prototype.show=function(e){var t=e.url,n=e.width,i=void 0===n?400:n,o=e.height,r=function(e){var t=e.url,n=e.width,i=e.height,o=e.win;if(!o.top)return null;var r=o.top.outerHeight/2+o.top.screenY-i/2,s=o.top.outerWidth/2+o.top.screenX-n/2;return window.open(t,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(n,", height=").concat(i,", top=").concat(r,", left=").concat(s))}({url:t,width:i,height:void 0===o?500:o,win:window});if(!r)throw new Error("Window is not initialized");return this.windowRef=r,r},e.prototype.close=function(){if(!this.windowRef)throw new Error("Window is not initialized");this.windowRef.close()},e}();const q=":not([inert]):not([inert] *)",Y=':not([tabindex^="-"])',z=":not(:disabled)";var B=[`a[href]${q}${Y}`,`area[href]${q}${Y}`,`input:not([type="hidden"]):not([type="radio"])${q}${Y}${z}`,`input[type="radio"]${q}${Y}${z}`,`select${q}${Y}${z}`,`textarea${q}${Y}${z}`,`button${q}${Y}${z}`,`details${q} > summary:first-of-type${Y}`,`iframe${q}${Y}`,`audio[controls]${q}${Y}`,`video[controls]${q}${Y}`,`[contenteditable]${q}${Y}`,`[tabindex]${q}${Y}`];function Q(e){(e.querySelector("[autofocus]")||e).focus()}function X(e,t){if(t&&te(e))return e;if(!((n=e).shadowRoot&&"-1"===n.getAttribute("tabindex")||n.matches(":disabled,[hidden],[inert]")))if(e.shadowRoot){let n=Z(e.shadowRoot,t);for(;n;){const e=X(n,t);if(e)return e;n=ee(n,t)}}else if("slot"===e.localName){const n=e.assignedElements({flatten:!0});t||n.reverse();for(const e of n){const n=X(e,t);if(n)return n}}else{let n=Z(e,t);for(;n;){const e=X(n,t);if(e)return e;n=ee(n,t)}}var n;return!t&&te(e)?e:null}function Z(e,t){return t?e.firstElementChild:e.lastElementChild}function ee(e,t){return t?e.nextElementSibling:e.previousElementSibling}const te=e=>!e.shadowRoot?.delegatesFocus&&(e.matches(B.join(","))&&!(e=>!(!e.matches("details:not([open]) *")||e.matches("details>summary:first-of-type"))||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length))(e));function ne(e=document){const t=e.activeElement;return t?t.shadowRoot?ne(t.shadowRoot)||document.activeElement:t:null}function ie(e,t){const[n,i]=function(e){const t=X(e,!0);return[t,t?X(e,!1)||t:null]}(e);if(!n)return t.preventDefault();const o=ne();t.shiftKey&&o===n?(i.focus(),t.preventDefault()):t.shiftKey||o!==i||(n.focus(),t.preventDefault())}class oe{$el;id;previouslyFocused;shown;constructor(e){this.$el=e,this.id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this.previouslyFocused=null,this.shown=!1,this.maintainFocus=this.maintainFocus.bind(this),this.bindKeypress=this.bindKeypress.bind(this),this.handleTriggerClicks=this.handleTriggerClicks.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.$el.setAttribute("aria-hidden","true"),this.$el.setAttribute("aria-modal","true"),this.$el.setAttribute("tabindex","-1"),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),document.addEventListener("click",this.handleTriggerClicks,!0)}destroy(){return this.hide(),document.removeEventListener("click",this.handleTriggerClicks,!0),this.$el.replaceWith(this.$el.cloneNode(!0)),this.fire("destroy"),this}show(e){return this.shown||(this.shown=!0,this.$el.removeAttribute("aria-hidden"),this.previouslyFocused=ne(),"BODY"===this.previouslyFocused?.tagName&&e?.target&&(this.previouslyFocused=e.target),"focus"===e?.type?this.maintainFocus(e):Q(this.$el),document.body.addEventListener("focus",this.maintainFocus,!0),this.$el.addEventListener("keydown",this.bindKeypress,!0),this.fire("show",e)),this}hide(e){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this.previouslyFocused?.focus?.(),document.body.removeEventListener("focus",this.maintainFocus,!0),this.$el.removeEventListener("keydown",this.bindKeypress,!0),this.fire("hide",e),this):this}on(e,t,n){return this.$el.addEventListener(e,t,n),this}off(e,t,n){return this.$el.removeEventListener(e,t,n),this}fire(e,t){this.$el.dispatchEvent(new CustomEvent(e,{detail:t,cancelable:!0}))}handleTriggerClicks(e){const t=e.target;t.closest(`[data-a11y-dialog-show="${this.id}"]`)&&this.show(e),(t.closest(`[data-a11y-dialog-hide="${this.id}"]`)||t.closest("[data-a11y-dialog-hide]")&&t.closest('[aria-modal="true"]')===this.$el)&&this.hide(e)}bindKeypress(e){if(document.activeElement?.closest('[aria-modal="true"]')!==this.$el)return;let t=!1;try{t=!!this.$el.querySelector('[popover]:not([popover="manual"]):popover-open')}catch{}"Escape"!==e.key||"alertdialog"===this.$el.getAttribute("role")||t||(e.preventDefault(),this.hide(e)),"Tab"===e.key&&ie(this.$el,e)}maintainFocus(e){e.target.closest('[aria-modal="true"], [data-a11y-dialog-ignore-focus-trap]')||Q(this.$el)}}function re(){for(const e of document.querySelectorAll("[data-a11y-dialog]"))new oe(e)}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",re):re());var se="__authsignal-popup-container",ae="__authsignal-popup-content",ce="__authsignal-popup-overlay",le="385px",he=function(){function t(e){var t=e.width,n=e.height,i=e.isClosable;if(this.popup=null,this.resizeListener=null,this.fallbackTimer=null,this.iframeReady=!1,this.containerEl=null,this.contentEl=null,this.styleEl=null,this.iframeEl=null,document.querySelector("#".concat(se)))throw new Error("Multiple instances of Authsignal popup is not supported.");this.height=n,this.init({width:t,height:n,isClosable:i})}return t.prototype.init=function(e){var t=this,n=e.width,i=void 0===n?le:n,o=e.height,r=e.isClosable,s=void 0===r||r,a=i;CSS.supports("width",i)||(console.warn("Invalid CSS value for `popupOptions.width`. Using default value instead."),a=le);var c=document.createElement("div");c.setAttribute("id",se),c.setAttribute("aria-hidden","true"),s||c.setAttribute("role","alertdialog");var l=document.createElement("div");l.setAttribute("id",ce),s&&l.setAttribute("data-a11y-dialog-hide","true");var h=document.createElement("div");h.setAttribute("id",ae),document.body.appendChild(c);var u=document.createElement("style");u.setAttribute("id","__authsignal-popup-style"),u.textContent="\n #".concat(se,",\n #").concat(ce," {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(se," {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(se,"[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(ce," {\n background-color: rgba(0, 0, 0, 0.18);\n opacity: 0;\n transition: opacity 150ms ease-out;\n }\n\n #").concat(se,".as-popup-visible #").concat(ce," {\n opacity: 1;\n }\n\n #").concat(se,".as-popup-closing #").concat(ce," {\n opacity: 0;\n transition-duration: 120ms;\n transition-timing-function: ease-in;\n }\n\n #").concat(ae," {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n overflow: hidden;\n width: ").concat(a,";\n opacity: 0;\n transform: scale(0.95);\n transition: opacity 150ms ease-out, transform 150ms ease-out;\n }\n\n #").concat(se,".as-popup-visible #").concat(ae," {\n opacity: 1;\n transform: scale(1);\n }\n\n #").concat(se,".as-popup-closing #").concat(ae," {\n opacity: 0;\n transform: scale(0.95);\n transition-duration: 120ms;\n transition-timing-function: ease-in;\n }\n\n #").concat(ae," iframe {\n width: 1px;\n min-width: 100%;\n border: 0;\n border-radius: inherit;\n max-height: ").concat(o?"100%":"95vh",";\n height: ").concat(null!=o?o:"384px",";\n opacity: 0;\n transition: opacity 200ms ease-out;\n }\n\n #").concat(ae," iframe.as-iframe-ready {\n opacity: 1;\n }\n\n @media (prefers-reduced-motion: reduce) {\n #").concat(ce,",\n #").concat(ae,",\n #").concat(ae," iframe {\n transition: none !important;\n }\n }\n "),document.head.insertAdjacentElement("beforeend",u),c.appendChild(l),c.appendChild(h),this.containerEl=c,this.contentEl=h,this.styleEl=u,this.popup=new oe(c),c.focus(),this.popup.on("hide",(function(){t.destroy()}))},t.prototype.destroy=function(){var e,t;(null===(e=this.containerEl)||void 0===e?void 0:e.parentNode)&&this.containerEl.parentNode.removeChild(this.containerEl),this.containerEl=null,this.contentEl=null,this.iframeEl=null,(null===(t=this.styleEl)||void 0===t?void 0:t.parentNode)&&this.styleEl.parentNode.removeChild(this.styleEl),this.styleEl=null,this.resizeListener&&(window.removeEventListener("message",this.resizeListener),this.resizeListener=null),this.fallbackTimer&&(clearTimeout(this.fallbackTimer),this.fallbackTimer=null),void 0!==this.previousOverflow&&(document.body.style.overflow=this.previousOverflow,this.previousOverflow=void 0)},t.prototype.show=function(t){var n=this,i=t.url,o=t.expectedOrigin;if(!this.popup||!this.contentEl||!this.containerEl)throw new Error("Popup is not initialized");var r=document.createElement("iframe");r.setAttribute("id","__authsignal-popup-iframe"),r.setAttribute("name","authsignal"),r.setAttribute("title","Authsignal multi-factor authentication"),r.setAttribute("src",i),r.setAttribute("allow","publickey-credentials-get *; publickey-credentials-create *; clipboard-write"),this.height||(r.style.overflow="hidden"),this.contentEl.appendChild(r),this.iframeEl=r,this.previousOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.popup.show();var s=this.containerEl,a=function(){requestAnimationFrame((function(){requestAnimationFrame((function(){s.classList.add("as-popup-visible")}))}))};if(this.height)a(),r.addEventListener("load",(function(){setTimeout((function(){r.classList.add("as-iframe-ready")}),50)}));else{var c=function(){n.iframeReady||(n.iframeReady=!0,r.classList.add("as-iframe-ready"),a())};this.fallbackTimer=setTimeout(c,3e3),this.resizeListener=function(t){if(t.origin===o&&(n.resizeIframe(t),!n.iframeReady)){var i=void 0;try{var r=JSON.parse(t.data);i=null==r?void 0:r.event}catch(e){}i===e.AuthsignalWindowMessage.AUTHSIGNAL_READY&&(n.fallbackTimer&&(clearTimeout(n.fallbackTimer),n.fallbackTimer=null),c())}},window.addEventListener("message",this.resizeListener)}},t.prototype.close=function(){var e=this;if(!this.popup||!this.containerEl||!this.contentEl)throw new Error("Popup is not initialized");this.containerEl.classList.remove("as-popup-visible"),this.containerEl.classList.add("as-popup-closing");var t=!1,n=function(){var n;t||(t=!0,null===(n=e.popup)||void 0===n||n.hide())};this.contentEl.addEventListener("transitionend",n,{once:!0}),setTimeout(n,150)},t.prototype.on=function(e,t){if(!this.popup)throw new Error("Popup is not initialized");this.popup.on(e,t)},t.prototype.resizeIframe=function(e){this.iframeEl&&e.data.height&&(this.iframeEl.style.height=e.data.height+"px")},t}(),ue=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/totp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/totp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),de=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new ue({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-otp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-otp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/email-otp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ge=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new pe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),fe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return t={phoneNumber:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/sms"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/sms"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/sms"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ve=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new fe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,phoneNumber:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),be=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-magic-link"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-magic-link"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.checkVerificationStatus=function(e){return u(this,arguments,void 0,(function(e){var t,n=this,i=e.token;return d(this,(function(e){switch(e.label){case 0:return t=function(){return u(n,void 0,void 0,(function(){var e,n=this;return d(this,(function(o){switch(o.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/email-magic-link/finalize"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,o.sent().json()];case 2:return N({response:e=o.sent(),onTokenExpired:this.onTokenExpired}),e.isVerified?[2,e]:[2,new Promise((function(e){setTimeout((function(){return u(n,void 0,void 0,(function(){var n;return d(this,(function(i){switch(i.label){case 0:return n=e,[4,t()];case 1:return n.apply(void 0,[i.sent()]),[2]}}))}))}),1e3)}))]}}))}))},[4,t()];case 1:return[2,e.sent()]}}))}))},e}(),ye=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new be({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.checkVerificationStatus=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.cache.token?[4,this.api.checkVerificationStatus({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(e=t.sent())&&e.accessToken&&(this.cache.token=e.accessToken),[2,O({response:e,enableLogging:this.enableLogging})]}}))}))},e}(),me=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/registration-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.registrationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(i)})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.authenticationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(i)})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e}(),ke=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.api=new me({baseUrl:t,tenantId:n,onTokenExpired:i}),this.enableLogging=o}return e.prototype.enroll=function(){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s=(void 0===e?{}:e).hints;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?(t={token:this.cache.token},[4,this.api.registrationOptions(t)]):[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(n=e.sent()))return[2,L({errorResponse:n,enableLogging:this.enableLogging})];e.label=2;case 2:return e.trys.push([2,5,,6]),[4,T({optionsJSON:s?l(l({},n),{hints:s}):n})];case 3:return i=e.sent(),[4,this.api.addAuthenticator({registrationCredential:i,token:this.cache.token})];case 4:return"error"in(o=e.sent())?[2,L({errorResponse:o,enableLogging:this.enableLogging})]:(o.accessToken&&(this.cache.token=o.accessToken),[2,{data:{token:o.accessToken,registrationResponse:i}}]);case 5:throw _(r=e.sent()),r;case 6:return[2]}}))}))},e.prototype.verify=function(){return u(this,void 0,void 0,(function(){var e,t,n,i,o;return d(this,(function(r){switch(r.label){case 0:return this.cache.token?[4,this.api.authenticationOptions({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(e=r.sent()))return[2,L({errorResponse:e,enableLogging:this.enableLogging})];r.label=2;case 2:return r.trys.push([2,5,,6]),[4,S({optionsJSON:e})];case 3:return t=r.sent(),[4,this.api.verify({authenticationCredential:t,token:this.cache.token})];case 4:return"error"in(n=r.sent())?[2,L({errorResponse:n,enableLogging:this.enableLogging})]:(n.accessToken&&(this.cache.token=n.accessToken),i=n.accessToken,[2,{data:{isVerified:n.isVerified,token:i,authenticationResponse:t}}]);case 5:throw _(o=r.sent()),o;case 6:return[2]}}))}))},e}(),we=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.tenantId=n,this.baseUrl=t}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.action,i=e.token,o=e.custom;return d(this,(function(e){switch(e.label){case 0:return t={action:n,custom:o},[4,fetch("".concat(this.baseUrl,"/client/challenge/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId,token:i}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.challengeId,i=e.deviceCode;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:n,deviceCode:i},[4,fetch("".concat(this.baseUrl,"/client/verify/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e}(),Ee=function(){},Ie=54e4,Te=3e3,Ce=function(e){function t(t){var n=t.baseUrl,i=t.tenantId,o=t.enableLogging,r=e.call(this)||this;return r.cache=M.shared,r.enableLogging=!1,r.enableLogging=o,r.api=new we({baseUrl:n,tenantId:i}),r}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,i,o,r,s=this;return d(this,(function(a){switch(a.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:e.action,custom:e.custom})];case 1:return t=a.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.currentChallengeParams=e,this.clearPolling(),i=e.pollInterval||Te,o=e.refreshInterval||Ie,n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:e.onStateChange,pollInterval:i}),e.onRefresh&&(r=e.onRefresh,this.startRefreshTimer((function(){return s.performRefresh({action:e.action,custom:e.custom,onRefresh:r,onStateChange:e.onStateChange,pollInterval:i})}),o))),[2,n]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s,a,c,l,h=this,u=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return this.currentChallengeParams?[4,this.api.challenge({token:this.cache.token||void 0,action:this.currentChallengeParams.action,custom:u||this.currentChallengeParams.custom})]:[2];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),this.currentChallengeParams.onRefresh&&this.currentChallengeParams.onRefresh(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:this.currentChallengeParams.onStateChange,pollInterval:this.currentChallengeParams.pollInterval||Te}),this.currentChallengeParams.onRefresh&&(i=this.currentChallengeParams.refreshInterval||Ie,o=this.currentChallengeParams,r=o.action,s=o.custom,a=o.onRefresh,c=o.onStateChange,l=o.pollInterval,this.startRefreshTimer((function(){return h.performRefresh({action:r,custom:s,onRefresh:a,onStateChange:c,pollInterval:l||Te})}),i))),[2]}}))}))},t.prototype.disconnect=function(){this.clearPolling(),this.clearRefreshTimer(),this.currentChallengeParams=void 0},t.prototype.startRefreshTimer=function(e,t){var n=this;this.clearRefreshTimer(),this.refreshTimeout=setTimeout((function(){return u(n,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,e()];case 1:return n.sent(),this.startRefreshTimer(e,t),[2]}}))}))}),t)},t.prototype.clearRefreshTimer=function(){this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=void 0)},t.prototype.performRefresh=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.custom,r=e.onRefresh,s=e.onStateChange,a=e.pollInterval;return d(this,(function(e){switch(e.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:i,custom:o})];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),r(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:s,pollInterval:a})),[2]}}))}))},t.prototype.startPolling=function(e){var t=this,n=e.challengeId,i=e.deviceCode,o=e.onStateChange,r=e.pollInterval;this.pollingInterval=setInterval((function(){return u(t,void 0,void 0,(function(){var e,t;return d(this,(function(r){switch(r.label){case 0:return[4,this.api.verify({challengeId:n,deviceCode:i})];case 1:return e=r.sent(),(t=O({response:e,enableLogging:this.enableLogging})).data&&(t.data.isVerified?(o("approved",t.data.token),this.clearPolling()):t.data.isClaimed&&!t.data.isConsumed?o("claimed"):t.data.isClaimed&&t.data.isConsumed&&(o("rejected"),this.clearPolling())),[2]}}))}))}),r)},t.prototype.clearPolling=function(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)},t}(Ee),Ae="CHALLENGE_CREATED_HANDLER",Se=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.ws=null,this.messageHandlers=new Map,this.options=null,this.refreshInterval=null,this.tokenCache=M.shared;var i=t.replace("https://","wss://").replace("http://","ws://").replace("v1","ws-v1-challenge").replace("api","api-ws");this.baseUrl=i,this.tenantId=n}return e.prototype.connect=function(){return u(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t,n){try{var i=["authsignal-ws"];e.tokenCache.token?i.push("x.authsignal.token.".concat(e.tokenCache.token)):i.push("x.authsignal.tenant.".concat(e.tenantId)),e.ws=new WebSocket(e.baseUrl,i),e.ws.onopen=function(){t()},e.ws.onerror=function(e){n(new Error("WebSocket connection error: ".concat(e)))},e.ws.onclose=function(){e.refreshInterval&&(clearInterval(e.refreshInterval),e.refreshInterval=null),e.messageHandlers.clear(),e.ws=null},e.ws.onmessage=function(t){try{var n=JSON.parse(t.data);e.handleMessage(n)}catch(e){console.error("Failed to parse WebSocket message:",e)}}}catch(e){n(e)}}))]}))}))},e.prototype.handleMessage=function(e){if("CHALLENGE_CREATED"===e.type){if(!(t=this.messageHandlers.get(Ae)))throw new Error("Challenge created handler not found");t(e)}else if("STATE_CHANGE"===e.type){var t;(t=this.messageHandlers.get(e.data.challengeId))&&t(e)}},e.prototype.createQrCodeChallenge=function(e){return u(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:n.sent(),n.label=2;case 2:return this.refreshInterval&&clearInterval(this.refreshInterval),this.options=e,[2,new Promise((function(n,i){t.messageHandlers.set(Ae,(function(i){if("CHALLENGE_CREATED"===i.type){var o=i;t.messageHandlers.delete(Ae),t.monitorChallengeState(o.data.challengeId,e),t.startRefreshCycle(o.data.challengeId,e),n({challengeId:o.data.challengeId,expiresAt:o.data.expiresAt,state:o.data.state})}})),t.sendChallengeRequest(e).catch(i)}))]}}))}))},e.prototype.monitorChallengeState=function(e,t){var n=this;this.messageHandlers.set(e,(function(i){var o;if("STATE_CHANGE"===i.type){var r=i;null===(o=t.onStateChange)||void 0===o||o.call(t,r.data.state,r.data.accessToken),"approved"!==r.data.state&&"rejected"!==r.data.state||n.messageHandlers.delete(e)}}))},e.prototype.startRefreshCycle=function(e,t){var n=this,i=t.refreshInterval||54e4,o=e;this.refreshInterval=setInterval((function(){return u(n,void 0,void 0,(function(){var e,n,i;return d(this,(function(r){switch(r.label){case 0:this.messageHandlers.delete(o),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.createQrCodeChallenge(t)];case 2:return e=r.sent(),o=e.challengeId,null===(i=t.onRefresh)||void 0===i||i.call(t,e.challengeId,e.expiresAt),[3,4];case 3:return n=r.sent(),console.error("Failed to refresh QR code challenge:",n),this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null),[3,4];case 4:return[2]}}))}))}),i)},e.prototype.sendChallengeRequest=function(e){return u(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:t.sent(),t.label=2;case 2:if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket connection could not be established");return this.sendMessage({type:"CREATE_CHALLENGE",data:{challengeType:"QR_CODE",actionCode:e.action,custom:e.custom}}),[2]}}))}))},e.prototype.sendMessage=function(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(e))},e.prototype.refreshQrCodeChallenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o=e.custom;return d(this,(function(e){switch(e.label){case 0:if(!this.options)throw new Error("Call createQrCodeChallenge first");return[4,this.createQrCodeChallenge(l(l({},this.options),void 0!==o&&{custom:o}))];case 1:return t=e.sent(),null===(i=(n=this.options).onRefresh)||void 0===i||i.call(n,t.challengeId,t.expiresAt),[2,t]}}))}))},e.prototype.disconnect=function(){this.ws&&this.ws.close()},e}(),Re=function(e){function t(t){var n=t.baseUrl,i=t.tenantId,o=t.enableLogging,r=e.call(this)||this;return r.cache=M.shared,r.enableLogging=!1,r.enableLogging=o,r.wsClient=new Se({baseUrl:n,tenantId:i}),r}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,this.wsClient.createQrCodeChallenge({token:this.cache.token||void 0,action:e.action,custom:e.custom,refreshInterval:e.refreshInterval,onRefresh:e.onRefresh,onStateChange:e.onStateChange})];case 1:return[2,{data:{challengeId:(t=n.sent()).challengeId,expiresAt:t.expiresAt}}]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return[4,this.wsClient.refreshQrCodeChallenge({custom:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.disconnect=function(){this.wsClient.disconnect()},t}(Ee),Le=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.enableLogging;this.handler=null,this.enableLogging=!1,this.baseUrl=t,this.tenantId=n,this.enableLogging=i}return e.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,i;return d(this,(function(o){return t=e.polling,n=void 0!==t&&t,i=h(e,["polling"]),this.handler&&this.handler.disconnect(),this.handler=n?new Ce({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}):new Re({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}),[2,this.handler.challenge(i)]}))}))},e.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){if(!this.handler)throw new Error("challenge() must be called before refresh()");return[2,this.handler.refresh({custom:t})]}))}))},e.prototype.disconnect=function(){this.handler&&(this.handler.disconnect(),this.handler=null)},e}(),Oe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t={action:i},[4,fetch("".concat(this.baseUrl,"/client/challenge/push"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.challengeId,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:i},[4,fetch("".concat(this.baseUrl,"/client/verify/push"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),_e=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new Oe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t=e.action;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({action:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t=e.challengeId;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({challengeId:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e}(),xe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/whatsapp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/whatsapp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new xe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),Ue="4a08uqve",Ne=function(){function t(e){var t=e.cookieDomain,n=e.cookieName,i=void 0===n?"__as_aid":n,o=e.baseUrl,r=void 0===o?"https://api.authsignal.com/v1":o,a=e.tenantId,c=e.onTokenExpired,l=e.enableLogging,h=void 0!==l&&l;if(this.anonymousId="",this.profilingId="",this.cookieDomain="",this.anonymousIdCookieName="",this.enableLogging=!1,this.cookieDomain=t||document.location.hostname.replace("www.",""),this.anonymousIdCookieName=i,!a)throw new Error("tenantId is required");var u,d=(u=this.anonymousIdCookieName)&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(u).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null;d?this.anonymousId=d:(this.anonymousId=s(),R({name:this.anonymousIdCookieName,value:this.anonymousId,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol})),this.enableLogging=h,this.passkey=new G({tenantId:a,baseUrl:r,anonymousId:this.anonymousId,onTokenExpired:c,enableLogging:this.enableLogging}),this.totp=new de({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.email=new ge({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.emailML=new ye({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.sms=new ve({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.securityKey=new ke({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.qrCode=new Le({tenantId:a,baseUrl:r,enableLogging:this.enableLogging}),this.push=new _e({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.whatsapp=new Pe({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging})}return t.prototype.setToken=function(e){M.shared.token=e},t.prototype.launch=function(e,t){switch(null==t?void 0:t.mode){case"window":return this.launchWithWindow(e,t);case"popup":return this.launchWithPopup(e,t);default:this.launchWithRedirect(e)}},t.prototype.initAdvancedProfiling=function(e){var t=s();this.profilingId=t,R({name:"__as_pid",value:t,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol});var n=e?"".concat(e,"/fp/tags.js?org_id=").concat(Ue,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags.js?org_id=".concat(Ue,"&session_id=").concat(t),i=document.createElement("script");i.src=n,i.async=!1,i.id="as_adv_profile",document.head.appendChild(i);var o=document.createElement("noscript");o.setAttribute("id","as_adv_profile_pixel"),o.setAttribute("aria-hidden","true");var r=document.createElement("iframe"),a=e?"".concat(e,"/fp/tags?org_id=").concat(Ue,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags?org_id=".concat(Ue,"&session_id=").concat(t);r.setAttribute("id","as_adv_profile_pixel"),r.setAttribute("src",a),r.setAttribute("style","width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;"),o&&(o.appendChild(r),document.body.prepend(o))},t.prototype.launchWithRedirect=function(e){window.location.href=e},t.prototype.launchWithPopup=function(t,n){var i=n.popupOptions,o=n.onError,r=new he({width:null==i?void 0:i.width,height:null==i?void 0:i.height,isClosable:null==i?void 0:i.isClosable}),s="".concat(t,"&mode=popup"),a=new URL(t).origin;return r.show({url:s,expectedOrigin:a}),new Promise((function(t){var n=void 0,i=function(t){if(t.origin===a){var i=null;try{i=JSON.parse(t.data)}catch(e){}(null==i?void 0:i.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_API_ERROR&&(null==o||o({errorCode:i.errorCode,statusCode:i.statusCode})),(null==i?void 0:i.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(n=i.token,r.close())}};r.on("hide",(function(){window.removeEventListener("message",i),t({token:n})})),window.addEventListener("message",i,!1)}))},t.prototype.launchWithWindow=function(t,n){var i=n.windowOptions,o=n.onError,r=new F,s="".concat(t,"&mode=popup"),a=new URL(t).origin;return r.show({url:s,width:null==i?void 0:i.width,height:null==i?void 0:i.height}),new Promise((function(t){var n=function(i){if(i.origin===a){var s=null;try{s=JSON.parse(i.data)}catch(e){}(null==s?void 0:s.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_API_ERROR&&(null==o||o({errorCode:s.errorCode,statusCode:s.statusCode})),(null==s?void 0:s.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(window.removeEventListener("message",n),r.close(),t({token:s.token}))}};window.addEventListener("message",n,!1)}))},t}();return e.Authsignal=Ne,e.WebAuthnError=k,e.Whatsapp=Pe,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var authsignal=function(e){"use strict";let t;const n=new Uint8Array(16);function i(){if(!t&&(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function s(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const s=(e=e||{}).random||(e.rng||i)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=s[e];return t}return function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(s)}var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l=function(){return l=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},l.apply(this,arguments)};function h(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function u(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function d(e,t){var n,i,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function p(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}function g(e){const t=new Uint8Array(e);let n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function f(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,i=t.padEnd(t.length+n,"="),o=atob(i),r=new ArrayBuffer(o.length),s=new Uint8Array(r);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return r}function v(){return b.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const b={stubThis:e=>e};function y(e){const{id:t}=e;return{...e,id:f(t),transports:e.transports}}function m(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class k extends Error{constructor({message:e,code:t,cause:n,name:i}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i??n.name,this.code=t}}const w=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},E=["cross-platform","platform"];function I(e){if(e&&!(E.indexOf(e)<0))return e}async function T(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});const{optionsJSON:t,useAutoRegister:n=!1}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");const i={...t,challenge:f(t.challenge),user:{...t.user,id:f(t.user.id)},excludeCredentials:t.excludeCredentials?.map(y)},o={};let r;n&&(o.mediation="conditional"),o.publicKey=i,o.signal=w.createNewAbortSignal();try{r=await navigator.credentials.create(o)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new k({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===n.authenticatorSelection?.requireResidentKey)return new k({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&"required"===n.authenticatorSelection?.userVerification)return new k({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if("required"===n.authenticatorSelection?.userVerification)return new k({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if("InvalidStateError"===e.name)return new k({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new k({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===n.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new k({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new k({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!m(t))return new k({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new k({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new k({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new k({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}({error:e,options:o})}if(!r)throw new Error("Registration was not completed");const{id:s,rawId:a,response:c,type:l}=r;let h,u,d,p;if("function"==typeof c.getTransports&&(h=c.getTransports()),"function"==typeof c.getPublicKeyAlgorithm)try{u=c.getPublicKeyAlgorithm()}catch(e){C("getPublicKeyAlgorithm()",e)}if("function"==typeof c.getPublicKey)try{const e=c.getPublicKey();null!==e&&(d=g(e))}catch(e){C("getPublicKey()",e)}if("function"==typeof c.getAuthenticatorData)try{p=g(c.getAuthenticatorData())}catch(e){C("getAuthenticatorData()",e)}return{id:s,rawId:g(a),response:{attestationObject:g(c.attestationObject),clientDataJSON:g(c.clientDataJSON),transports:h,publicKeyAlgorithm:u,publicKey:d,authenticatorData:p},type:l,clientExtensionResults:r.getClientExtensionResults(),authenticatorAttachment:I(r.authenticatorAttachment)}}function C(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)}const A={stubThis:e=>e};async function S(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});const{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:i=!0}=e;if(!v())throw new Error("WebAuthn is not supported in this browser");let o;0!==t.allowCredentials?.length&&(o=t.allowCredentials?.map(y));const r={...t,challenge:f(t.challenge),allowCredentials:o},s={};if(n){if(!await function(){if(!v())return A.stubThis(new Promise((e=>e(!1))));const e=globalThis.PublicKeyCredential;return void 0===e?.isConditionalMediationAvailable?A.stubThis(new Promise((e=>e(!1)))):A.stubThis(e.isConditionalMediationAvailable())}())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&i)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');s.mediation="conditional",r.allowCredentials=[]}let a;s.publicKey=r,s.signal=w.createNewAbortSignal();try{a=await navigator.credentials.get(s)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new k({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new k({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!m(t))return new k({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rpId!==t)return new k({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new k({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}({error:e,options:s})}if(!a)throw new Error("Authentication was not completed");const{id:c,rawId:l,response:h,type:u}=a;let d;return h.userHandle&&(d=g(h.userHandle)),{id:c,rawId:g(l),response:{authenticatorData:g(h.authenticatorData),clientDataJSON:g(h.clientDataJSON),signature:g(h.signature),userHandle:d},type:u,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:I(a.authenticatorAttachment)}}function R(e){var t=e.name,n=e.value,i=e.expire,o=e.domain,r=e.secure,s=i===1/0?" expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+i;document.cookie=encodeURIComponent(t)+"="+n+"; path=/;"+s+(o?"; domain="+o:"")+(r?"; secure":"")}function L(e){var t,n=e.errorResponse;return e.enableLogging&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:null!==(t=n.errorDescription)&&void 0!==t?t:n.error,errorCode:n.errorCode,errorDescription:n.errorDescription}}function O(e){var t,n=e.response,i=e.enableLogging;if(n&&"object"==typeof n&&"error"in n){var o=null!==(t=n.errorDescription)&&void 0!==t?t:n.error;return i&&console.error("[Authsignal] ".concat(n.errorCode).concat(n.errorDescription?": ".concat(n.errorDescription):"")),{error:o,errorCode:n.errorCode,errorDescription:n.errorDescription}}if(n&&"object"==typeof n&&"accessToken"in n&&"string"==typeof n.accessToken){var r=n.accessToken,s=h(n,["accessToken"]);return{data:l(l({},s),{token:r})}}return{data:n}}function _(e){var t,n;if(e instanceof k&&"ERROR_INVALID_RP_ID"===e.code){var i=(null===(n=null===(t=e.message)||void 0===t?void 0:t.match(/"([^"]*)"/))||void 0===n?void 0:n[1])||"";console.error('[Authsignal] The Relying Party ID "'.concat(i,'" is invalid for this domain.\n To learn more, visit https://docs.authsignal.com/scenarios/passkeys-prebuilt-ui#defining-the-relying-party'))}}var x,P;function U(e){var t=e.token,n=e.tenantId;return{"Content-Type":"application/json",Authorization:t?"Bearer ".concat(t):"Basic ".concat(window.btoa(encodeURIComponent(n)))}}function N(e){var t=e.response,n=e.onTokenExpired;"error"in t&&"expired_token"===t.errorCode&&n&&n()}e.AuthsignalWindowMessage=void 0,(x=e.AuthsignalWindowMessage||(e.AuthsignalWindowMessage={})).AUTHSIGNAL_CLOSE_POPUP="AUTHSIGNAL_CLOSE_POPUP",x.AUTHSIGNAL_API_ERROR="AUTHSIGNAL_API_ERROR",x.AUTHSIGNAL_READY="AUTHSIGNAL_READY",e.ErrorCode=void 0,(P=e.ErrorCode||(e.ErrorCode={})).token_not_set="token_not_set",P.expired_token="expired_token",P.network_error="network_error",P.too_many_requests="too_many_requests",P.invalid_credential="invalid_credential",P.unknown_credential="unknown_credential";var D,$,j,H=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r=e.token,s=e.username,a=e.authenticatorAttachment,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t=Boolean(a)?{username:s,authenticatorAttachment:a}:{username:s},n="".concat(this.baseUrl,c?"/client/user-authenticators/passkey/registration-options/web":"/client/user-authenticators/passkey/registration-options"),i=c?"include":"same-origin",[4,fetch(n,{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:i})];case 1:return[4,e.sent().json()];case 2:return N({response:o=e.sent(),onTokenExpired:this.onTokenExpired}),[2,o]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.challengeId,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({challengeId:i}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptionsWeb=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey/authentication-options/web"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({}),credentials:"include"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.registrationCredential,r=e.conditionalCreate,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={registrationCredential:o,conditionalCreate:r,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.authenticationCredential,o=e.token,r=e.deviceId,s=e.challengeId,a=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t={authenticationCredential:i,deviceId:r,challengeId:s},[4,fetch("".concat(this.baseUrl,"/client/verify/passkey"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t),credentials:a?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.getAuthenticators=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators"),{method:"GET",headers:U({token:n,tenantId:this.tenantId}),credentials:i?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.getPasskeyAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/passkey?credentialIds=").concat(n),{method:"GET",headers:U({tenantId:this.tenantId})})];case 1:if(!(t=e.sent()).ok)throw new Error(t.statusText);return[2,t.json()]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return t="".concat(this.baseUrl,o?"/client/challenge/web":"/client/challenge"),[4,fetch(t,{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify({action:i}),credentials:o?"include":"same-origin"})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),M=function(){function t(){this.token=null}return t.prototype.handleTokenNotSetError=function(){var t=e.ErrorCode.token_not_set,n="A token has not been set. Call 'setToken' first.";return console.error("Error: ".concat(n)),{error:t,errorCode:t,errorDescription:n}},t.shared=new t,t}();function K(){return"undefined"==typeof window||void 0===window.PublicKeyCredential?null:window.PublicKeyCredential}function W(e,t){return u(this,arguments,void 0,(function(e,t){var n,i,o=e.rpId,r=e.userId,s=e.credentialIds;return d(this,(function(e){switch(e.label){case 0:if(!(null==(n=K())?void 0:n.signalAllAcceptedCredentials))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.signalAllAcceptedCredentials({rpId:o,userId:r,allAcceptedCredentialIds:s})];case 2:return e.sent(),[3,4];case 3:return i=e.sent(),t&&console.warn("[Authsignal] signalAllAcceptedCredentials failed",i),[3,4];case 4:return[2]}}))}))}function J(e,t){return u(this,arguments,void 0,(function(e,t){var n,i,o=e.rpId,r=e.credentialId;return d(this,(function(e){switch(e.label){case 0:if(!(null==(n=K())?void 0:n.signalUnknownCredential))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.signalUnknownCredential({rpId:o,credentialId:r})];case 2:return e.sent(),[3,4];case 3:return i=e.sent(),t&&console.warn("[Authsignal] signalUnknownCredential failed",i),[3,4];case 4:return[2]}}))}))}!function(e){e.SMS="SMS",e.AUTHENTICATOR_APP="AUTHENTICATOR_APP",e.RECOVERY_CODE="RECOVERY_CODE",e.EMAIL_MAGIC_LINK="EMAIL_MAGIC_LINK",e.EMAIL_OTP="EMAIL_OTP",e.PUSH="PUSH",e.SECURITY_KEY="SECURITY_KEY",e.PASSKEY="PASSKEY",e.VERIFF="VERIFF",e.IPROOV="IPROOV",e.PALM_BIOMETRICS_RR="PALM_BIOMETRICS_RR",e.IDVERSE="IDVERSE",e.DEVICE="DEVICE"}(D||(D={})),function(e){e.DEFAULT="DEFAULT",e.WHATSAPP="WHATSAPP",e.SMS="SMS"}($||($={})),function(e){e.IOS="IOS",e.ANDROID="ANDROID",e.WEB="WEB"}(j||(j={}));var V=!1,G=function(){function t(e){var t=e.baseUrl,n=e.tenantId,i=e.anonymousId,o=e.onTokenExpired,r=e.enableLogging;this.passkeyLocalStorageKey="as_user_passkey_map",this.cache=M.shared,this.enableLogging=!1,this.api=new H({baseUrl:t,tenantId:n,onTokenExpired:o}),this.anonymousId=i,this.enableLogging=r}return t.prototype.signUp=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s,a,c,h=e.username,u=e.displayName,p=e.token,g=e.authenticatorAttachment,f=void 0===g?"platform":g,v=e.hints,b=e.useAutoRegister,y=void 0!==b&&b,m=e.useCookies,k=void 0!==m&&m,w=e.syncCredentials,E=void 0===w||w;return d(this,(function(e){switch(e.label){case 0:return(t=null!=p?p:this.cache.token)?y?[4,this.doesBrowserSupportConditionalCreate()]:[3,2]:[2,this.cache.handleTokenNotSetError()];case 1:if(!e.sent())throw new Error("CONDITIONAL_CREATE_NOT_SUPPORTED");e.label=2;case 2:return n={username:h,displayName:u,token:t,authenticatorAttachment:f,useCookies:k},[4,this.api.registrationOptions(n)];case 3:if("error"in(i=e.sent()))return[2,L({errorResponse:i,enableLogging:this.enableLogging})];e.label=4;case 4:return e.trys.push([4,7,,8]),[4,T({optionsJSON:v?l(l({},i.options),{hints:v}):i.options,useAutoRegister:y})];case 5:return o=e.sent(),[4,this.api.addAuthenticator({registrationCredential:o,token:t,conditionalCreate:y,challengeId:i.challengeId,useCookies:k})];case 6:return"error"in(r=e.sent())?[2,L({errorResponse:r,enableLogging:this.enableLogging})]:(r.isVerified&&this.storeCredentialAgainstDevice(l(l({},o),{userId:r.userId})),r.accessToken&&(this.cache.token=r.accessToken),E&&r.isVerified&&(r.accessToken||k)&&(s=null!==(c=i.options.rp.id)&&void 0!==c?c:window.location.hostname,this.syncPasskeysWithCredentialManager({rpId:s,userHandle:i.options.user.id,credentialId:o.id,token:r.accessToken,useCookies:k})),[2,{data:{token:r.accessToken,userAuthenticator:r.userAuthenticator,registrationResponse:o}}]);case 7:throw a=e.sent(),V=!1,_(a),a;case 8:return[2]}}))}))},t.prototype.signIn=function(t){return u(this,void 0,void 0,(function(){var n,i,o,r,s,a,c,h,u,p,g,f,v,b,y,m,k;return d(this,(function(d){switch(d.label){case 0:if((null==t?void 0:t.token)&&t.autofill)throw new Error("autofill is not supported when providing a token");if((null==t?void 0:t.action)&&t.token)throw new Error("action is not supported when providing a token");if(n=null===(k=null==t?void 0:t.syncCredentials)||void 0===k||k,null==t?void 0:t.autofill){if(V)return[2,{}];V=!0}return(null==t?void 0:t.action)?[4,this.api.challenge({action:null==t?void 0:t.action,useCookies:null==t?void 0:t.useCookies})]:[3,2];case 1:return o=d.sent(),[3,3];case 2:o=null,d.label=3;case 3:return(i=o)&&"error"in i?(V=!1,[2,L({errorResponse:i,enableLogging:this.enableLogging})]):!(null==t?void 0:t.action)&&(null==t?void 0:t.useCookies)?[3,5]:[4,this.api.authenticationOptions({token:null==t?void 0:t.token,challengeId:null==i?void 0:i.challengeId,useCookies:null==t?void 0:t.useCookies})];case 4:return s=d.sent(),[3,7];case 5:return[4,this.api.authenticationOptionsWeb({token:null==t?void 0:t.token})];case 6:s=d.sent(),d.label=7;case 7:if("error"in(r=s))return V=!1,[2,L({errorResponse:r,enableLogging:this.enableLogging})];d.label=8;case 8:return d.trys.push([8,14,,15]),[4,S({optionsJSON:r.options,useBrowserAutofill:null==t?void 0:t.autofill})];case 9:return a=d.sent(),(null==t?void 0:t.onVerificationStarted)&&t.onVerificationStarted(),[4,this.api.verify({authenticationCredential:a,token:null==t?void 0:t.token,deviceId:this.anonymousId,challengeId:r.challengeId,useCookies:null==t?void 0:t.useCookies})];case 10:return"error"in(c=d.sent())?(V=!1,n&&c.errorCode===e.ErrorCode.unknown_credential?[4,J({rpId:u=this.getAuthOptionsRpId(r.options),credentialId:a.id},this.enableLogging)]:[3,12]):[3,13];case 11:d.sent(),this.removeCredentialFromLocalCache(a.id),d.label=12;case 12:return[2,L({errorResponse:c,enableLogging:this.enableLogging})];case 13:return c.isVerified&&this.storeCredentialAgainstDevice(l(l({},a),{userId:c.userId})),c.accessToken&&(this.cache.token=c.accessToken),h=a.response.userHandle,n&&c.isVerified&&(c.accessToken||(null==t?void 0:t.useCookies))&&h&&(u=this.getAuthOptionsRpId(r.options),this.syncPasskeysWithCredentialManager({rpId:u,userHandle:h,credentialId:a.id,token:c.accessToken,useCookies:null==t?void 0:t.useCookies})),p=c.accessToken,g=c.userId,f=c.userAuthenticatorId,v=c.username,b=c.userDisplayName,y=c.isVerified,V=!1,[2,{data:{isVerified:y,token:p,userId:g,userAuthenticatorId:f,username:v,displayName:b,authenticationResponse:a}}];case 14:throw m=d.sent(),V=!1,_(m),m;case 15:return[2]}}))}))},t.prototype.isAvailableOnDevice=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o,r=e.userId;return d(this,(function(e){switch(e.label){case 0:if(!r)throw new Error("userId is required");if(!(t=localStorage.getItem(this.passkeyLocalStorageKey)))return[2,!1];if(n=JSON.parse(t),0===(i=null!==(o=n[r])&&void 0!==o?o:[]).length)return[2,!1];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.api.getPasskeyAuthenticator({credentialIds:i})];case 2:return e.sent(),[2,!0];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},t.prototype.storeCredentialAgainstDevice=function(e){var t=e.id,n=e.authenticatorAttachment,i=e.userId,o=void 0===i?"":i;if("cross-platform"!==n){var r=localStorage.getItem(this.passkeyLocalStorageKey),s=r?JSON.parse(r):{};s[o]?s[o].includes(t)||s[o].push(t):s[o]=[t],localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(s))}},t.prototype.doesBrowserSupportConditionalCreate=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return(null==(e=window.PublicKeyCredential)?void 0:e.getClientCapabilities)?[4,e.getClientCapabilities()]:[3,2];case 1:if(t.sent().conditionalCreate)return[2,!0];t.label=2;case 2:return[2,!1]}}))}))},t.prototype.getAuthOptionsRpId=function(e){var t=null==e?void 0:e.rpId;return null!=t?t:window.location.hostname},t.prototype.syncPasskeysWithCredentialManager=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o=e.rpId,r=e.userHandle,s=e.credentialId,a=e.token,c=e.useCookies;return d(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.api.getAuthenticators({token:a,useCookies:c})];case 1:return t=e.sent(),Array.isArray(t)?(n=t.filter((function(e){var t;return e.verificationMethod===D.PASSKEY&&Boolean(null===(t=e.webauthnCredential)||void 0===t?void 0:t.credentialId)})).map((function(e){return e.webauthnCredential.credentialId})),[4,W({rpId:o,userId:r,credentialIds:Array.from(new Set(p(p([],n,!0),[s],!1)))},this.enableLogging)]):(this.enableLogging&&console.warn("[Authsignal] Could not fetch authenticators for passkey sync",t),[2]);case 2:return e.sent(),[3,4];case 3:return i=e.sent(),this.enableLogging&&console.warn("[Authsignal] Passkey sync failed",i),[3,4];case 4:return[2]}}))}))},t.prototype.removeCredentialFromLocalCache=function(e){var t=localStorage.getItem(this.passkeyLocalStorageKey);if(t){var n;try{n=JSON.parse(t)}catch(e){return}for(var i=!1,o=0,r=Object.keys(n);o<r.length;o++){var s=r[o],a=n[s].filter((function(t){return t!==e}));a.length!==n[s].length&&(n[s]=a,i=!0)}i&&localStorage.setItem(this.passkeyLocalStorageKey,JSON.stringify(n))}},t}(),F=function(){function e(){this.windowRef=null}return e.prototype.show=function(e){var t=e.url,n=e.width,i=void 0===n?400:n,o=e.height,r=function(e){var t=e.url,n=e.width,i=e.height,o=e.win;if(!o.top)return null;var r=o.top.outerHeight/2+o.top.screenY-i/2,s=o.top.outerWidth/2+o.top.screenX-n/2;return window.open(t,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(n,", height=").concat(i,", top=").concat(r,", left=").concat(s))}({url:t,width:i,height:void 0===o?500:o,win:window});if(!r)throw new Error("Window is not initialized");return this.windowRef=r,r},e.prototype.close=function(){if(!this.windowRef)throw new Error("Window is not initialized");this.windowRef.close()},e}();const q=":not([inert]):not([inert] *)",Y=':not([tabindex^="-"])',z=":not(:disabled)";var B=[`a[href]${q}${Y}`,`area[href]${q}${Y}`,`input:not([type="hidden"]):not([type="radio"])${q}${Y}${z}`,`input[type="radio"]${q}${Y}${z}`,`select${q}${Y}${z}`,`textarea${q}${Y}${z}`,`button${q}${Y}${z}`,`details${q} > summary:first-of-type${Y}`,`iframe${q}${Y}`,`audio[controls]${q}${Y}`,`video[controls]${q}${Y}`,`[contenteditable]${q}${Y}`,`[tabindex]${q}${Y}`];function Q(e){(e.querySelector("[autofocus]")||e).focus()}function X(e,t){if(t&&te(e))return e;if(!((n=e).shadowRoot&&"-1"===n.getAttribute("tabindex")||n.matches(":disabled,[hidden],[inert]")))if(e.shadowRoot){let n=Z(e.shadowRoot,t);for(;n;){const e=X(n,t);if(e)return e;n=ee(n,t)}}else if("slot"===e.localName){const n=e.assignedElements({flatten:!0});t||n.reverse();for(const e of n){const n=X(e,t);if(n)return n}}else{let n=Z(e,t);for(;n;){const e=X(n,t);if(e)return e;n=ee(n,t)}}var n;return!t&&te(e)?e:null}function Z(e,t){return t?e.firstElementChild:e.lastElementChild}function ee(e,t){return t?e.nextElementSibling:e.previousElementSibling}const te=e=>!e.shadowRoot?.delegatesFocus&&(e.matches(B.join(","))&&!(e=>!(!e.matches("details:not([open]) *")||e.matches("details>summary:first-of-type"))||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length))(e));function ne(e=document){const t=e.activeElement;return t?t.shadowRoot?ne(t.shadowRoot)||document.activeElement:t:null}function ie(e,t){const[n,i]=function(e){const t=X(e,!0);return[t,t?X(e,!1)||t:null]}(e);if(!n)return t.preventDefault();const o=ne();t.shiftKey&&o===n?(i.focus(),t.preventDefault()):t.shiftKey||o!==i||(n.focus(),t.preventDefault())}class oe{$el;id;previouslyFocused;shown;constructor(e){this.$el=e,this.id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this.previouslyFocused=null,this.shown=!1,this.maintainFocus=this.maintainFocus.bind(this),this.bindKeypress=this.bindKeypress.bind(this),this.handleTriggerClicks=this.handleTriggerClicks.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.$el.setAttribute("aria-hidden","true"),this.$el.setAttribute("aria-modal","true"),this.$el.setAttribute("tabindex","-1"),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),document.addEventListener("click",this.handleTriggerClicks,!0)}destroy(){return this.hide(),document.removeEventListener("click",this.handleTriggerClicks,!0),this.$el.replaceWith(this.$el.cloneNode(!0)),this.fire("destroy"),this}show(e){return this.shown||(this.shown=!0,this.$el.removeAttribute("aria-hidden"),this.previouslyFocused=ne(),"BODY"===this.previouslyFocused?.tagName&&e?.target&&(this.previouslyFocused=e.target),"focus"===e?.type?this.maintainFocus(e):Q(this.$el),document.body.addEventListener("focus",this.maintainFocus,!0),this.$el.addEventListener("keydown",this.bindKeypress,!0),this.fire("show",e)),this}hide(e){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this.previouslyFocused?.focus?.(),document.body.removeEventListener("focus",this.maintainFocus,!0),this.$el.removeEventListener("keydown",this.bindKeypress,!0),this.fire("hide",e),this):this}on(e,t,n){return this.$el.addEventListener(e,t,n),this}off(e,t,n){return this.$el.removeEventListener(e,t,n),this}fire(e,t){this.$el.dispatchEvent(new CustomEvent(e,{detail:t,cancelable:!0}))}handleTriggerClicks(e){const t=e.target;t.closest(`[data-a11y-dialog-show="${this.id}"]`)&&this.show(e),(t.closest(`[data-a11y-dialog-hide="${this.id}"]`)||t.closest("[data-a11y-dialog-hide]")&&t.closest('[aria-modal="true"]')===this.$el)&&this.hide(e)}bindKeypress(e){if(document.activeElement?.closest('[aria-modal="true"]')!==this.$el)return;let t=!1;try{t=!!this.$el.querySelector('[popover]:not([popover="manual"]):popover-open')}catch{}"Escape"!==e.key||"alertdialog"===this.$el.getAttribute("role")||t||(e.preventDefault(),this.hide(e)),"Tab"===e.key&&ie(this.$el,e)}maintainFocus(e){e.target.closest('[aria-modal="true"], [data-a11y-dialog-ignore-focus-trap]')||Q(this.$el)}}function re(){for(const e of document.querySelectorAll("[data-a11y-dialog]"))new oe(e)}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",re):re());var se="__authsignal-popup-container",ae="__authsignal-popup-content",ce="__authsignal-popup-overlay",le="385px",he=function(){function t(e){var t=e.width,n=e.height,i=e.isClosable;if(this.popup=null,this.resizeListener=null,this.fallbackTimer=null,this.iframeReady=!1,this.containerEl=null,this.contentEl=null,this.styleEl=null,this.iframeEl=null,document.querySelector("#".concat(se)))throw new Error("Multiple instances of Authsignal popup is not supported.");this.height=n,this.init({width:t,height:n,isClosable:i})}return t.prototype.init=function(e){var t=this,n=e.width,i=void 0===n?le:n,o=e.height,r=e.isClosable,s=void 0===r||r,a=i;CSS.supports("width",i)||(console.warn("Invalid CSS value for `popupOptions.width`. Using default value instead."),a=le);var c=document.createElement("div");c.setAttribute("id",se),c.setAttribute("aria-hidden","true"),s||c.setAttribute("role","alertdialog");var l=document.createElement("div");l.setAttribute("id",ce),s&&l.setAttribute("data-a11y-dialog-hide","true");var h=document.createElement("div");h.setAttribute("id",ae),document.body.appendChild(c);var u=document.createElement("style");u.setAttribute("id","__authsignal-popup-style"),u.textContent="\n #".concat(se,",\n #").concat(ce," {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n #").concat(se," {\n z-index: 2147483647;\n display: flex;\n }\n\n #").concat(se,"[aria-hidden='true'] {\n display: none;\n }\n\n #").concat(ce," {\n background-color: rgba(0, 0, 0, 0.18);\n opacity: 0;\n transition: opacity 150ms ease-out;\n }\n\n #").concat(se,".as-popup-visible #").concat(ce," {\n opacity: 1;\n }\n\n #").concat(se,".as-popup-closing #").concat(ce," {\n opacity: 0;\n transition-duration: 120ms;\n transition-timing-function: ease-in;\n }\n\n #").concat(ae," {\n margin: auto;\n z-index: 2147483647;\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n overflow: hidden;\n width: ").concat(a,";\n opacity: 0;\n transform: scale(0.95);\n transition: opacity 150ms ease-out, transform 150ms ease-out;\n }\n\n #").concat(se,".as-popup-visible #").concat(ae," {\n opacity: 1;\n transform: scale(1);\n }\n\n #").concat(se,".as-popup-closing #").concat(ae," {\n opacity: 0;\n transform: scale(0.95);\n transition-duration: 120ms;\n transition-timing-function: ease-in;\n }\n\n #").concat(ae," iframe {\n width: 1px;\n min-width: 100%;\n border: 0;\n border-radius: inherit;\n max-height: ").concat(o?"100%":"95vh",";\n height: ").concat(null!=o?o:"384px",";\n opacity: 0;\n transition: opacity 200ms ease-out;\n }\n\n #").concat(ae," iframe.as-iframe-ready {\n opacity: 1;\n }\n\n @media (prefers-reduced-motion: reduce) {\n #").concat(ce,",\n #").concat(ae,",\n #").concat(ae," iframe {\n transition: none !important;\n }\n }\n "),document.head.insertAdjacentElement("beforeend",u),c.appendChild(l),c.appendChild(h),this.containerEl=c,this.contentEl=h,this.styleEl=u,this.popup=new oe(c),c.focus(),this.popup.on("hide",(function(){t.destroy()}))},t.prototype.destroy=function(){var e,t;(null===(e=this.containerEl)||void 0===e?void 0:e.parentNode)&&this.containerEl.parentNode.removeChild(this.containerEl),this.containerEl=null,this.contentEl=null,this.iframeEl=null,(null===(t=this.styleEl)||void 0===t?void 0:t.parentNode)&&this.styleEl.parentNode.removeChild(this.styleEl),this.styleEl=null,this.resizeListener&&(window.removeEventListener("message",this.resizeListener),this.resizeListener=null),this.fallbackTimer&&(clearTimeout(this.fallbackTimer),this.fallbackTimer=null),void 0!==this.previousOverflow&&(document.body.style.overflow=this.previousOverflow,this.previousOverflow=void 0)},t.prototype.show=function(t){var n=this,i=t.url,o=t.expectedOrigin;if(!this.popup||!this.contentEl||!this.containerEl)throw new Error("Popup is not initialized");var r=document.createElement("iframe");r.setAttribute("id","__authsignal-popup-iframe"),r.setAttribute("name","authsignal"),r.setAttribute("title","Authsignal multi-factor authentication"),r.setAttribute("src",i),r.setAttribute("allow","publickey-credentials-get *; publickey-credentials-create *; clipboard-write"),this.height||(r.style.overflow="hidden"),this.contentEl.appendChild(r),this.iframeEl=r,this.previousOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.popup.show();var s=this.containerEl,a=function(){requestAnimationFrame((function(){requestAnimationFrame((function(){s.classList.add("as-popup-visible")}))}))};if(this.height)a(),r.addEventListener("load",(function(){setTimeout((function(){r.classList.add("as-iframe-ready")}),50)}));else{var c=function(){n.iframeReady||(n.iframeReady=!0,r.classList.add("as-iframe-ready"),a())};this.fallbackTimer=setTimeout(c,3e3),this.resizeListener=function(t){if(t.origin===o&&(n.resizeIframe(t),!n.iframeReady)){var i=void 0;try{var r=JSON.parse(t.data);i=null==r?void 0:r.event}catch(e){}i===e.AuthsignalWindowMessage.AUTHSIGNAL_READY&&(n.fallbackTimer&&(clearTimeout(n.fallbackTimer),n.fallbackTimer=null),c())}},window.addEventListener("message",this.resizeListener)}},t.prototype.close=function(){var e=this;if(!this.popup||!this.containerEl||!this.contentEl)throw new Error("Popup is not initialized");this.containerEl.classList.remove("as-popup-visible"),this.containerEl.classList.add("as-popup-closing");var t=!1,n=function(){var n;t||(t=!0,null===(n=e.popup)||void 0===n||n.hide())};this.contentEl.addEventListener("transitionend",n,{once:!0}),setTimeout(n,150)},t.prototype.on=function(e,t){if(!this.popup)throw new Error("Popup is not initialized");this.popup.on(e,t)},t.prototype.resizeIframe=function(e){this.iframeEl&&e.data.height&&(this.iframeEl.style.height=e.data.height+"px")},t}(),ue=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/totp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/totp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),de=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new ue({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-otp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-otp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/email-otp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ge=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new pe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),fe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return t={phoneNumber:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/sms"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/sms"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/sms"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),ve=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new fe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.phoneNumber;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,phoneNumber:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),be=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.email;return d(this,(function(e){switch(e.label){case 0:return t={email:o},[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/email-magic-link"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/email-magic-link"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.checkVerificationStatus=function(e){return u(this,arguments,void 0,(function(e){var t,n=this,i=e.token;return d(this,(function(e){switch(e.label){case 0:return t=function(){return u(n,void 0,void 0,(function(){var e,n=this;return d(this,(function(o){switch(o.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/email-magic-link/finalize"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,o.sent().json()];case 2:return N({response:e=o.sent(),onTokenExpired:this.onTokenExpired}),e.isVerified?[2,e]:[2,new Promise((function(e){setTimeout((function(){return u(n,void 0,void 0,(function(){var n;return d(this,(function(i){switch(i.label){case 0:return n=e,[4,t()];case 1:return n.apply(void 0,[i.sent()]),[2]}}))}))}),1e3)}))]}}))}))},[4,t()];case 1:return[2,e.sent()]}}))}))},e}(),ye=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new be({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.enroll=function(e){return u(this,arguments,void 0,(function(e){var t=e.email;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.enroll({token:this.cache.token,email:t})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.checkVerificationStatus=function(){return u(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.cache.token?[4,this.api.checkVerificationStatus({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(e=t.sent())&&e.accessToken&&(this.cache.token=e.accessToken),[2,O({response:e,enableLogging:this.enableLogging})]}}))}))},e}(),me=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.registrationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/registration-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.authenticationOptions=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key/authentication-options"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify({})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.addAuthenticator=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.registrationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/user-authenticators/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(i)})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token,i=e.authenticationCredential;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/verify/security-key"),{method:"POST",headers:U({token:n,tenantId:this.tenantId}),body:JSON.stringify(i)})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e}(),ke=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.api=new me({baseUrl:t,tenantId:n,onTokenExpired:i}),this.enableLogging=o}return e.prototype.enroll=function(){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s=(void 0===e?{}:e).hints;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?(t={token:this.cache.token},[4,this.api.registrationOptions(t)]):[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(n=e.sent()))return[2,L({errorResponse:n,enableLogging:this.enableLogging})];e.label=2;case 2:return e.trys.push([2,5,,6]),[4,T({optionsJSON:s?l(l({},n),{hints:s}):n})];case 3:return i=e.sent(),[4,this.api.addAuthenticator({registrationCredential:i,token:this.cache.token})];case 4:return"error"in(o=e.sent())?[2,L({errorResponse:o,enableLogging:this.enableLogging})]:(o.accessToken&&(this.cache.token=o.accessToken),[2,{data:{token:o.accessToken,registrationResponse:i}}]);case 5:throw _(r=e.sent()),r;case 6:return[2]}}))}))},e.prototype.verify=function(){return u(this,void 0,void 0,(function(){var e,t,n,i,o;return d(this,(function(r){switch(r.label){case 0:return this.cache.token?[4,this.api.authenticationOptions({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:if("error"in(e=r.sent()))return[2,L({errorResponse:e,enableLogging:this.enableLogging})];r.label=2;case 2:return r.trys.push([2,5,,6]),[4,S({optionsJSON:e})];case 3:return t=r.sent(),[4,this.api.verify({authenticationCredential:t,token:this.cache.token})];case 4:return"error"in(n=r.sent())?[2,L({errorResponse:n,enableLogging:this.enableLogging})]:(n.accessToken&&(this.cache.token=n.accessToken),i=n.accessToken,[2,{data:{isVerified:n.isVerified,token:i,authenticationResponse:t}}]);case 5:throw _(o=r.sent()),o;case 6:return[2]}}))}))},e}(),we=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.tenantId=n,this.baseUrl=t}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.action,i=e.token,o=e.custom;return d(this,(function(e){switch(e.label){case 0:return t={action:n,custom:o},[4,fetch("".concat(this.baseUrl,"/client/challenge/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId,token:i}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.challengeId,i=e.deviceCode;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:n,deviceCode:i},[4,fetch("".concat(this.baseUrl,"/client/verify/qr-code"),{method:"POST",headers:U({tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}}))}))},e}(),Ee=function(){},Ie=54e4,Te=3e3,Ce=function(e){function t(t){var n=t.baseUrl,i=t.tenantId,o=t.enableLogging,r=e.call(this)||this;return r.cache=M.shared,r.enableLogging=!1,r.enableLogging=o,r.api=new we({baseUrl:n,tenantId:i}),r}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,i,o,r,s=this;return d(this,(function(a){switch(a.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:e.action,custom:e.custom})];case 1:return t=a.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.currentChallengeParams=e,this.clearPolling(),i=e.pollInterval||Te,o=e.refreshInterval||Ie,n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:e.onStateChange,pollInterval:i}),e.onRefresh&&(r=e.onRefresh,this.startRefreshTimer((function(){return s.performRefresh({action:e.action,custom:e.custom,onRefresh:r,onStateChange:e.onStateChange,pollInterval:i})}),o))),[2,n]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t,n,i,o,r,s,a,c,l,h=this,u=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return this.currentChallengeParams?[4,this.api.challenge({token:this.cache.token||void 0,action:this.currentChallengeParams.action,custom:u||this.currentChallengeParams.custom})]:[2];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),this.currentChallengeParams.onRefresh&&this.currentChallengeParams.onRefresh(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:this.currentChallengeParams.onStateChange,pollInterval:this.currentChallengeParams.pollInterval||Te}),this.currentChallengeParams.onRefresh&&(i=this.currentChallengeParams.refreshInterval||Ie,o=this.currentChallengeParams,r=o.action,s=o.custom,a=o.onRefresh,c=o.onStateChange,l=o.pollInterval,this.startRefreshTimer((function(){return h.performRefresh({action:r,custom:s,onRefresh:a,onStateChange:c,pollInterval:l||Te})}),i))),[2]}}))}))},t.prototype.disconnect=function(){this.clearPolling(),this.clearRefreshTimer(),this.currentChallengeParams=void 0},t.prototype.startRefreshTimer=function(e,t){var n=this;this.clearRefreshTimer(),this.refreshTimeout=setTimeout((function(){return u(n,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,e()];case 1:return n.sent(),this.startRefreshTimer(e,t),[2]}}))}))}),t)},t.prototype.clearRefreshTimer=function(){this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=void 0)},t.prototype.performRefresh=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.custom,r=e.onRefresh,s=e.onStateChange,a=e.pollInterval;return d(this,(function(e){switch(e.label){case 0:return[4,this.api.challenge({token:this.cache.token||void 0,action:i,custom:o})];case 1:return t=e.sent(),(n=O({response:t,enableLogging:this.enableLogging})).data&&(this.clearPolling(),r(n.data.challengeId,n.data.expiresAt),n.data.deviceCode&&this.startPolling({challengeId:n.data.challengeId,deviceCode:n.data.deviceCode,onStateChange:s,pollInterval:a})),[2]}}))}))},t.prototype.startPolling=function(e){var t=this,n=e.challengeId,i=e.deviceCode,o=e.onStateChange,r=e.pollInterval;this.pollingInterval=setInterval((function(){return u(t,void 0,void 0,(function(){var e,t;return d(this,(function(r){switch(r.label){case 0:return[4,this.api.verify({challengeId:n,deviceCode:i})];case 1:return e=r.sent(),(t=O({response:e,enableLogging:this.enableLogging})).data&&(t.data.isVerified?(o("approved",t.data.token),this.clearPolling()):t.data.isClaimed&&!t.data.isConsumed?o("claimed"):t.data.isClaimed&&t.data.isConsumed&&(o("rejected"),this.clearPolling())),[2]}}))}))}),r)},t.prototype.clearPolling=function(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)},t}(Ee),Ae="CHALLENGE_CREATED_HANDLER",Se=function(){function e(e){var t=e.baseUrl,n=e.tenantId;this.ws=null,this.messageHandlers=new Map,this.options=null,this.refreshInterval=null,this.tokenCache=M.shared;var i=t.replace("https://","wss://").replace("http://","ws://").replace("v1","ws-v1-challenge").replace("api","api-ws");this.baseUrl=i,this.tenantId=n}return e.prototype.connect=function(){return u(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t,n){try{var i=["authsignal-ws"];e.tokenCache.token?i.push("x.authsignal.token.".concat(e.tokenCache.token)):i.push("x.authsignal.tenant.".concat(e.tenantId)),e.ws=new WebSocket(e.baseUrl,i),e.ws.onopen=function(){t()},e.ws.onerror=function(e){n(new Error("WebSocket connection error: ".concat(e)))},e.ws.onclose=function(){e.refreshInterval&&(clearInterval(e.refreshInterval),e.refreshInterval=null),e.messageHandlers.clear(),e.ws=null},e.ws.onmessage=function(t){try{var n=JSON.parse(t.data);e.handleMessage(n)}catch(e){console.error("Failed to parse WebSocket message:",e)}}}catch(e){n(e)}}))]}))}))},e.prototype.handleMessage=function(e){if("CHALLENGE_CREATED"===e.type){if(!(t=this.messageHandlers.get(Ae)))throw new Error("Challenge created handler not found");t(e)}else if("STATE_CHANGE"===e.type){var t;(t=this.messageHandlers.get(e.data.challengeId))&&t(e)}},e.prototype.createQrCodeChallenge=function(e){return u(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:n.sent(),n.label=2;case 2:return this.refreshInterval&&clearInterval(this.refreshInterval),this.options=e,[2,new Promise((function(n,i){t.messageHandlers.set(Ae,(function(i){if("CHALLENGE_CREATED"===i.type){var o=i;t.messageHandlers.delete(Ae),t.monitorChallengeState(o.data.challengeId,e),t.startRefreshCycle(o.data.challengeId,e),n({challengeId:o.data.challengeId,expiresAt:o.data.expiresAt,state:o.data.state})}})),t.sendChallengeRequest(e).catch(i)}))]}}))}))},e.prototype.monitorChallengeState=function(e,t){var n=this;this.messageHandlers.set(e,(function(i){var o;if("STATE_CHANGE"===i.type){var r=i;null===(o=t.onStateChange)||void 0===o||o.call(t,r.data.state,r.data.accessToken),"approved"!==r.data.state&&"rejected"!==r.data.state||n.messageHandlers.delete(e)}}))},e.prototype.startRefreshCycle=function(e,t){var n=this,i=t.refreshInterval||54e4,o=e;this.refreshInterval=setInterval((function(){return u(n,void 0,void 0,(function(){var e,n,i;return d(this,(function(r){switch(r.label){case 0:this.messageHandlers.delete(o),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.createQrCodeChallenge(t)];case 2:return e=r.sent(),o=e.challengeId,null===(i=t.onRefresh)||void 0===i||i.call(t,e.challengeId,e.expiresAt),[3,4];case 3:return n=r.sent(),console.error("Failed to refresh QR code challenge:",n),this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null),[3,4];case 4:return[2]}}))}))}),i)},e.prototype.sendChallengeRequest=function(e){return u(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return this.ws&&this.ws.readyState===WebSocket.OPEN?[3,2]:[4,this.connect()];case 1:t.sent(),t.label=2;case 2:if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket connection could not be established");return this.sendMessage({type:"CREATE_CHALLENGE",data:{challengeType:"QR_CODE",actionCode:e.action,custom:e.custom}}),[2]}}))}))},e.prototype.sendMessage=function(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(e))},e.prototype.refreshQrCodeChallenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i,o=e.custom;return d(this,(function(e){switch(e.label){case 0:if(!this.options)throw new Error("Call createQrCodeChallenge first");return[4,this.createQrCodeChallenge(l(l({},this.options),void 0!==o&&{custom:o}))];case 1:return t=e.sent(),null===(i=(n=this.options).onRefresh)||void 0===i||i.call(n,t.challengeId,t.expiresAt),[2,t]}}))}))},e.prototype.disconnect=function(){this.ws&&this.ws.close()},e}(),Re=function(e){function t(t){var n=t.baseUrl,i=t.tenantId,o=t.enableLogging,r=e.call(this)||this;return r.cache=M.shared,r.enableLogging=!1,r.enableLogging=o,r.wsClient=new Se({baseUrl:n,tenantId:i}),r}return c(t,e),t.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,this.wsClient.createQrCodeChallenge({token:this.cache.token||void 0,action:e.action,custom:e.custom,refreshInterval:e.refreshInterval,onRefresh:e.onRefresh,onStateChange:e.onStateChange})];case 1:return[2,{data:{challengeId:(t=n.sent()).challengeId,expiresAt:t.expiresAt}}]}}))}))},t.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){switch(e.label){case 0:return[4,this.wsClient.refreshQrCodeChallenge({custom:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.disconnect=function(){this.wsClient.disconnect()},t}(Ee),Le=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.enableLogging;this.handler=null,this.enableLogging=!1,this.baseUrl=t,this.tenantId=n,this.enableLogging=i}return e.prototype.challenge=function(e){return u(this,void 0,void 0,(function(){var t,n,i;return d(this,(function(o){return t=e.polling,n=void 0!==t&&t,i=h(e,["polling"]),this.handler&&this.handler.disconnect(),this.handler=n?new Ce({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}):new Re({baseUrl:this.baseUrl,tenantId:this.tenantId,enableLogging:this.enableLogging}),[2,this.handler.challenge(i)]}))}))},e.prototype.refresh=function(){return u(this,arguments,void 0,(function(e){var t=(void 0===e?{}:e).custom;return d(this,(function(e){if(!this.handler)throw new Error("challenge() must be called before refresh()");return[2,this.handler.refresh({custom:t})]}))}))},e.prototype.disconnect=function(){this.handler&&(this.handler.disconnect(),this.handler=null)},e}(),Oe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.action,o=e.userAuthenticatorId,r=e.token;return d(this,(function(e){switch(e.label){case 0:return t=l({action:i},o&&{userAuthenticatorId:o}),[4,fetch("".concat(this.baseUrl,"/client/challenge/push"),{method:"POST",headers:U({token:r,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.challengeId,o=e.token;return d(this,(function(e){switch(e.label){case 0:return t={challengeId:i},[4,fetch("".concat(this.baseUrl,"/client/verify/push"),{method:"POST",headers:U({token:o,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),_e=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new Oe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t=e.action,n=e.userAuthenticatorId;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({action:t,userAuthenticatorId:n,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t=e.challengeId;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({challengeId:t,token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e}(),xe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired;this.tenantId=n,this.baseUrl=t,this.onTokenExpired=i}return e.prototype.challenge=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.token;return d(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(this.baseUrl,"/client/challenge/whatsapp"),{method:"POST",headers:U({token:n,tenantId:this.tenantId})})];case 1:return[4,e.sent().json()];case 2:return N({response:t=e.sent(),onTokenExpired:this.onTokenExpired}),[2,t]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n,i=e.token,o=e.code;return d(this,(function(e){switch(e.label){case 0:return t={verificationCode:o},[4,fetch("".concat(this.baseUrl,"/client/verify/whatsapp"),{method:"POST",headers:U({token:i,tenantId:this.tenantId}),body:JSON.stringify(t)})];case 1:return[4,e.sent().json()];case 2:return N({response:n=e.sent(),onTokenExpired:this.onTokenExpired}),[2,n]}}))}))},e}(),Pe=function(){function e(e){var t=e.baseUrl,n=e.tenantId,i=e.onTokenExpired,o=e.enableLogging;this.cache=M.shared,this.enableLogging=!1,this.enableLogging=o,this.api=new xe({baseUrl:t,tenantId:n,onTokenExpired:i})}return e.prototype.challenge=function(){return u(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.challenge({token:this.cache.token})]:[2,this.cache.handleTokenNotSetError()];case 1:return[2,O({response:e.sent(),enableLogging:this.enableLogging})]}}))}))},e.prototype.verify=function(e){return u(this,arguments,void 0,(function(e){var t,n=e.code;return d(this,(function(e){switch(e.label){case 0:return this.cache.token?[4,this.api.verify({token:this.cache.token,code:n})]:[2,this.cache.handleTokenNotSetError()];case 1:return"accessToken"in(t=e.sent())&&t.accessToken&&(this.cache.token=t.accessToken),[2,O({response:t,enableLogging:this.enableLogging})]}}))}))},e}(),Ue="4a08uqve",Ne=function(){function t(e){var t=e.cookieDomain,n=e.cookieName,i=void 0===n?"__as_aid":n,o=e.baseUrl,r=void 0===o?"https://api.authsignal.com/v1":o,a=e.tenantId,c=e.onTokenExpired,l=e.enableLogging,h=void 0!==l&&l;if(this.anonymousId="",this.profilingId="",this.cookieDomain="",this.anonymousIdCookieName="",this.enableLogging=!1,this.cookieDomain=t||document.location.hostname.replace("www.",""),this.anonymousIdCookieName=i,!a)throw new Error("tenantId is required");var u,d=(u=this.anonymousIdCookieName)&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(u).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null;d?this.anonymousId=d:(this.anonymousId=s(),R({name:this.anonymousIdCookieName,value:this.anonymousId,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol})),this.enableLogging=h,this.passkey=new G({tenantId:a,baseUrl:r,anonymousId:this.anonymousId,onTokenExpired:c,enableLogging:this.enableLogging}),this.totp=new de({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.email=new ge({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.emailML=new ye({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.sms=new ve({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.securityKey=new ke({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.qrCode=new Le({tenantId:a,baseUrl:r,enableLogging:this.enableLogging}),this.push=new _e({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging}),this.whatsapp=new Pe({tenantId:a,baseUrl:r,onTokenExpired:c,enableLogging:this.enableLogging})}return t.prototype.setToken=function(e){M.shared.token=e},t.prototype.launch=function(e,t){switch(null==t?void 0:t.mode){case"window":return this.launchWithWindow(e,t);case"popup":return this.launchWithPopup(e,t);default:this.launchWithRedirect(e)}},t.prototype.initAdvancedProfiling=function(e){var t=s();this.profilingId=t,R({name:"__as_pid",value:t,expire:1/0,domain:this.cookieDomain,secure:"http:"!==document.location.protocol});var n=e?"".concat(e,"/fp/tags.js?org_id=").concat(Ue,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags.js?org_id=".concat(Ue,"&session_id=").concat(t),i=document.createElement("script");i.src=n,i.async=!1,i.id="as_adv_profile",document.head.appendChild(i);var o=document.createElement("noscript");o.setAttribute("id","as_adv_profile_pixel"),o.setAttribute("aria-hidden","true");var r=document.createElement("iframe"),a=e?"".concat(e,"/fp/tags?org_id=").concat(Ue,"&session_id=").concat(t):"https://h.online-metrix.net/fp/tags?org_id=".concat(Ue,"&session_id=").concat(t);r.setAttribute("id","as_adv_profile_pixel"),r.setAttribute("src",a),r.setAttribute("style","width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;"),o&&(o.appendChild(r),document.body.prepend(o))},t.prototype.launchWithRedirect=function(e){window.location.href=e},t.prototype.launchWithPopup=function(t,n){var i=n.popupOptions,o=n.onError,r=new he({width:null==i?void 0:i.width,height:null==i?void 0:i.height,isClosable:null==i?void 0:i.isClosable}),s="".concat(t,"&mode=popup"),a=new URL(t).origin;return r.show({url:s,expectedOrigin:a}),new Promise((function(t){var n=void 0,i=function(t){if(t.origin===a){var i=null;try{i=JSON.parse(t.data)}catch(e){}(null==i?void 0:i.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_API_ERROR&&(null==o||o({errorCode:i.errorCode,statusCode:i.statusCode})),(null==i?void 0:i.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(n=i.token,r.close())}};r.on("hide",(function(){window.removeEventListener("message",i),t({token:n})})),window.addEventListener("message",i,!1)}))},t.prototype.launchWithWindow=function(t,n){var i=n.windowOptions,o=n.onError,r=new F,s="".concat(t,"&mode=popup"),a=new URL(t).origin;return r.show({url:s,width:null==i?void 0:i.width,height:null==i?void 0:i.height}),new Promise((function(t){var n=function(i){if(i.origin===a){var s=null;try{s=JSON.parse(i.data)}catch(e){}(null==s?void 0:s.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_API_ERROR&&(null==o||o({errorCode:s.errorCode,statusCode:s.statusCode})),(null==s?void 0:s.event)===e.AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP&&(window.removeEventListener("message",n),r.close(),t({token:s.token}))}};window.addEventListener("message",n,!1)}))},t}();return e.Authsignal=Ne,e.WebAuthnError=k,e.Whatsapp=Pe,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
package/dist/push.d.ts CHANGED
@@ -8,6 +8,7 @@ type PushOptions = {
8
8
  };
9
9
  type ChallengeParams = {
10
10
  action: string;
11
+ userAuthenticatorId?: string;
11
12
  };
12
13
  type VerifyParams = {
13
14
  challengeId: string;
@@ -17,7 +18,7 @@ export declare class Push {
17
18
  private cache;
18
19
  private enableLogging;
19
20
  constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: PushOptions);
20
- challenge({ action }: ChallengeParams): Promise<AuthsignalResponse<PushChallengeResponse>>;
21
+ challenge({ action, userAuthenticatorId }: ChallengeParams): Promise<AuthsignalResponse<PushChallengeResponse>>;
21
22
  verify({ challengeId }: VerifyParams): Promise<AuthsignalResponse<PushVerifyResponse>>;
22
23
  }
23
24
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authsignal/browser",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",