@descope/web-js-sdk
Advanced tools
Comparing version 1.10.4 to 1.10.5
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@descope/core-js-sdk"),n=require("@fingerprintjs/fingerprintjs-pro"),a=require("js-cookie");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(t),r=o(a);const s=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,a)=>{var o;return n[a]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[a])||[]).concat((null==t?void 0:t[a])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},l=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},c=async e=>{const t=await l(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},u="undefined"!=typeof localStorage,d=(e,t)=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),g=e=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),p=e=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),f=(...e)=>{console.debug(...e)},w="undefined"!=typeof window,h=Math.pow(2,31)-1,v=w&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",b="fp",y=(e=!1)=>{const t=localStorage.getItem(b);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},m=async e=>{try{if(y())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),a=n.load({apiKey:e,endpoint:v}),o=await a,{requestId:i}=await o.get({linkedId:t}),r=((e,t)=>({vsid:e,vrid:t}))(t,i);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(b,JSON.stringify(t))})(r)}catch(e){global.FB_DEBUG&&console.error(e)}},S=e=>{const t=y(!0);return t&&e.body&&(e.body.fpData=t),e},O="dls_last_user_login_id",I="dls_last_user_display_name",_=()=>g(O),k=()=>g(I),j=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,a={}]=t,o=_(),i=k();o&&(null!==(n=a.lastAuth)&&void 0!==n||(a.lastAuth={}),a.lastAuth.loginId=o,a.lastAuth.name=i);return await e(...t)},D=e=>async(...t)=>{const n=await e(...t);return p(O),p(I),n};function T(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const U="DS",x="DSR";function A(e,t,{cookiePath:n,cookieDomain:a,cookieExpiration:o}){if(t){const i=new Date(1e3*o),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(a);r.default.set(e,t,{path:n,domain:s?a:void 0,expires:i,sameSite:"Strict",secure:!0})}}function J(e=""){return g(`${e}${x}`)||""}function K(e=""){p(`${e}${x}`),p(`${e}${U}`),r.default.remove(U)}const N=e=>t=>async(...n)=>{const a=await t(...n);return K(e),a};async function E(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=F(n.publicKey.challenge),n.publicKey.user.id=F(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=F(e.id)})),n}(e),n=await navigator.credentials.create(t);return a=n,JSON.stringify({id:a.id,rawId:L(a.rawId),type:a.type,response:{attestationObject:L(a.response.attestationObject),clientDataJSON:L(a.response.clientDataJSON)}});var a}async function R(e){const t=q(e);return P(await navigator.credentials.get(t))}async function $(e,t){const n=q(e);n.signal=t.signal,n.mediation="conditional";return P(await navigator.credentials.get(n))}async function C(e=!1){if(!w)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function q(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=F(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=F(e.id)})),n}function P(e){return JSON.stringify({id:e.id,rawId:L(e.rawId),type:e.type,response:{authenticatorData:L(e.response.authenticatorData),clientDataJSON:L(e.response.clientDataJSON),signature:L(e.response.signature),userHandle:e.response.userHandle?L(e.response.userHandle):void 0}})}function F(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function L(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var H,G=(H=e=>({async signUp(t,n){const a=await e.webauthn.signUp.start(t,window.location.origin,n);if(!a.ok)return a;const o=await E(a.data.options);return await e.webauthn.signUp.finish(a.data.transactionId,o)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const a=await R(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,a)},async signUpOrIn(t){var n;const a=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!a.ok)return a;if(null===(n=a.data)||void 0===n?void 0:n.create){const t=await E(a.data.options);return await e.webauthn.signUp.finish(a.data.transactionId,t)}{const t=await R(a.data.options);return await e.webauthn.signIn.finish(a.data.transactionId,t)}},async update(t,n){const a=await e.webauthn.update.start(t,window.location.origin,n);if(!a.ok)return a;const o=await E(a.data.options);return await e.webauthn.update.finish(a.data.transactionId,o)},helpers:{create:E,get:R,isSupported:C,conditional:$}}),(...e)=>{const t=H(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const M=e=>({async oneTap(t,n,a,o){const i=null!=t?t:"google",r=await e.oauth.startNative(i,a);if(!r.ok)return r;const{clientId:s,stateId:l,nonce:c}=r.data,u=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var a,r;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(r=null==n?void 0:n.use_fedcm_for_prompt)||void 0===r||r,client_id:s,callback:n=>{t(e.oauth.finishNative(i,l,"","",n.credential))},nonce:c})),u.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==o||o())}))}))}});var V=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await C(),a=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=a,e.flow.start(...t)}});const W=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:a,fpLoad:o}=n,i=e.__rest(n,["fpKey","fpLoad"]);return w?(a&&o&&m(a).catch((()=>null)),t(s(i,{beforeRequest:S}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(i))}),(n=>a=>{var{autoRefresh:o}=a,i=e.__rest(a,["autoRefresh"]);if(!o)return n(i);const{clearAllTimers:r,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let u,d;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(f("Expiration time passed, refreshing session"),g.refresh(d))}));const g=n(s(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:a}=await l(t);if(401===(null==t?void 0:t.status))f("Received 401, canceling all timers"),r();else if(a){u=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(a),d=n;let e=((o=u)?o.getTime()-(new Date).getTime():0)-2e4;e>h&&(f(`Timeout is too large (${e}ms), setting it to ${h}ms`),e=h),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});f(`Setting refresh timer for ${t}. (${e}ms)`),c((()=>{f("Refreshing session due to timer"),g.refresh(n)}),e)}var o}}));return t.wrapWith(g,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return f("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.4"},t.baseHeaders)}))),(e=>n=>{const a=T(),o=T(),i=e(s(n,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))a.pub(null),o.pub(null);else{const e=await c(t);e&&o.pub(e);const{sessionJwt:n}=await l(t);n&&a.pub(n)}}})),r=t.wrapWith(i,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return a.pub(null),o.pub(null),n}));return Object.assign(r,{onSessionTokenChange:a.sub,onUserChange:o.sub})}),(e=>n=>{const a=e(s(n,{afterRequest:async(e,t)=>{var n;const a=await c(t),o=null===(n=null==a?void 0:a.loginIds)||void 0===n?void 0:n[0],i=null==a?void 0:a.name;o&&((e=>{d(O,e)})(o),(e=>{d(I,e)})(i))}}));let o=t.wrapWith(a,["flow.start"],j);return o=t.wrapWith(o,["logout","logoutAll"],D),Object.assign(o,{getLastUserLoginId:_,getLastUserDisplayName:k})}),(n=>a=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:c}=a,u=e.__rest(a,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!w)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),n(u);const p=n(s(u,{beforeRequest:(f=c,e=>Object.assign(e,{token:e.token||J(f)})),afterRequest:async(t,n)=>{401===(null==n?void 0:n.status)?K(c):((t={},n,a)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e.__rest(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===a&&(a=""),o&&d(`${a}${x}`,o),i&&(n?A(U,i,r):d(`${a}${U}`,i))})(await l(n),i,c)}}));var f;const h=t.wrapWith(p,["logout","logoutAll"],N(c));return Object.assign(h,{getRefreshToken:()=>J(c),getSessionToken:()=>function(e=""){return r.default.get(U)||g(`${e}${U}`)||""}(c)})}))(((...e)=>{const t=i.default(...e);return Object.assign(Object.assign({},t),{flow:V(t),webauthn:G(t),fedcm:M(t)})}));exports.REFRESH_TOKEN_KEY=x,exports.SESSION_TOKEN_KEY=U,exports.clearFingerprintData=()=>{localStorage.removeItem(b)},exports.default=W,exports.ensureFingerprintIds=m; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@descope/core-js-sdk"),n=require("@fingerprintjs/fingerprintjs-pro"),a=require("js-cookie");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(t),r=i(a);const s=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,a)=>{var i;return n[a]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[a])||[]).concat((null==t?void 0:t[a])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},l=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},c=async e=>{const t=await l(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},u="undefined"!=typeof localStorage,d=(e,t)=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),g=e=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),p=e=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),w=(...e)=>{console.debug(...e)},f="undefined"!=typeof window,h=Math.pow(2,31)-1,v=f&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",b="fp",y=(e=!1)=>{const t=localStorage.getItem(b);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},m=async(e,t=v)=>{try{if(y())return;const a=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=n.load({apiKey:e,endpoint:[i.toString(),n.defaultEndpoint],scriptUrlPattern:[r,n.defaultScriptUrlPattern]}),l=await s,{requestId:c}=await l.get({linkedId:a}),u=((e,t)=>({vsid:e,vrid:t}))(a,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(b,JSON.stringify(t))})(u)}catch(e){console.warn("Could not load fingerprint",e)}},S=e=>{const t=y(!0);return t&&e.body&&(e.body.fpData=t),e},I="dls_last_user_login_id",O="dls_last_user_display_name",k=()=>g(I),_=()=>g(O),j=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,a={}]=t,i=k(),o=_();i&&(null!==(n=a.lastAuth)&&void 0!==n||(a.lastAuth={}),a.lastAuth.loginId=i,a.lastAuth.name=o);return await e(...t)},D=e=>async(...t)=>{const n=await e(...t);return p(I),p(O),n};function T(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const U="DS",x="DSR";function J(e,t,{cookiePath:n,cookieDomain:a,cookieExpiration:i}){if(t){const o=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(a);r.default.set(e,t,{path:n,domain:s?a:void 0,expires:o,sameSite:"Strict",secure:!0})}}function K(e=""){return g(`${e}${x}`)||""}function A(e=""){p(`${e}${x}`),p(`${e}${U}`),r.default.remove(U)}const R=e=>t=>async(...n)=>{const a=await t(...n);return A(e),a};async function E(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=L(n.publicKey.challenge),n.publicKey.user.id=L(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=L(e.id)})),n}(e),n=await navigator.credentials.create(t);return a=n,JSON.stringify({id:a.id,rawId:V(a.rawId),type:a.type,response:{attestationObject:V(a.response.attestationObject),clientDataJSON:V(a.response.clientDataJSON)}});var a}async function N(e){const t=P(e);return q(await navigator.credentials.get(t))}async function $(e,t){const n=P(e);n.signal=t.signal,n.mediation="conditional";return q(await navigator.credentials.get(n))}async function C(e=!1){if(!f)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function P(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=L(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=L(e.id)})),n}function q(e){return JSON.stringify({id:e.id,rawId:V(e.rawId),type:e.type,response:{authenticatorData:V(e.response.authenticatorData),clientDataJSON:V(e.response.clientDataJSON),signature:V(e.response.signature),userHandle:e.response.userHandle?V(e.response.userHandle):void 0}})}function L(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function V(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var F,H=(F=e=>({async signUp(t,n){const a=await e.webauthn.signUp.start(t,window.location.origin,n);if(!a.ok)return a;const i=await E(a.data.options);return await e.webauthn.signUp.finish(a.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const a=await N(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,a)},async signUpOrIn(t){var n;const a=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!a.ok)return a;if(null===(n=a.data)||void 0===n?void 0:n.create){const t=await E(a.data.options);return await e.webauthn.signUp.finish(a.data.transactionId,t)}{const t=await N(a.data.options);return await e.webauthn.signIn.finish(a.data.transactionId,t)}},async update(t,n){const a=await e.webauthn.update.start(t,window.location.origin,n);if(!a.ok)return a;const i=await E(a.data.options);return await e.webauthn.update.finish(a.data.transactionId,i)},helpers:{create:E,get:N,isSupported:C,conditional:$}}),(...e)=>{const t=F(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const M=e=>({async oneTap(t,n,a,i){const o=null!=t?t:"google",r=await e.oauth.startNative(o,a);if(!r.ok)return r;const{clientId:s,stateId:l,nonce:c}=r.data,u=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var a,r;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(r=null==n?void 0:n.use_fedcm_for_prompt)||void 0===r||r,client_id:s,callback:n=>{t(e.oauth.finishNative(o,l,"","",n.credential))},nonce:c})),u.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==i||i())}))}))}});var W=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await C(),a=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=a,e.flow.start(...t)}});const G=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:a,fpLoad:i}=n,o=e.__rest(n,["fpKey","fpLoad"]);return f?(a&&i&&m(a).catch((()=>null)),t(s(o,{beforeRequest:S}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(o))}),(n=>a=>{var{autoRefresh:i}=a,o=e.__rest(a,["autoRefresh"]);if(!i)return n(o);const{clearAllTimers:r,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let u,d;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(w("Expiration time passed, refreshing session"),g.refresh(d))}));const g=n(s(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:a}=await l(t);if(401===(null==t?void 0:t.status))w("Received 401, canceling all timers"),r();else if(a){u=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(a),d=n;let e=((i=u)?i.getTime()-(new Date).getTime():0)-2e4;e>h&&(w(`Timeout is too large (${e}ms), setting it to ${h}ms`),e=h),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});w(`Setting refresh timer for ${t}. (${e}ms)`),c((()=>{w("Refreshing session due to timer"),g.refresh(n)}),e)}var i}}));return t.wrapWith(g,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return w("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.5"},t.baseHeaders)}))),(e=>n=>{const a=T(),i=T(),o=e(s(n,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))a.pub(null),i.pub(null);else{const e=await c(t);e&&i.pub(e);const{sessionJwt:n}=await l(t);n&&a.pub(n)}}})),r=t.wrapWith(o,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return a.pub(null),i.pub(null),n}));return Object.assign(r,{onSessionTokenChange:a.sub,onUserChange:i.sub})}),(e=>n=>{const a=e(s(n,{afterRequest:async(e,t)=>{var n;const a=await c(t),i=null===(n=null==a?void 0:a.loginIds)||void 0===n?void 0:n[0],o=null==a?void 0:a.name;i&&((e=>{d(I,e)})(i),(e=>{d(O,e)})(o))}}));let i=t.wrapWith(a,["flow.start"],j);return i=t.wrapWith(i,["logout","logoutAll"],D),Object.assign(i,{getLastUserLoginId:k,getLastUserDisplayName:_})}),(n=>a=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:c}=a,u=e.__rest(a,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!f)return i&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),n(u);const p=n(s(u,{beforeRequest:(w=c,e=>Object.assign(e,{token:e.token||K(w)})),afterRequest:async(t,n)=>{401===(null==n?void 0:n.status)?A(c):((t={},n,a)=>{var{refreshJwt:i,sessionJwt:o}=t,r=e.__rest(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===a&&(a=""),i&&d(`${a}${x}`,i),o&&(n?J(U,o,r):d(`${a}${U}`,o))})(await l(n),o,c)}}));var w;const h=t.wrapWith(p,["logout","logoutAll"],R(c));return Object.assign(h,{getRefreshToken:()=>K(c),getSessionToken:()=>function(e=""){return r.default.get(U)||g(`${e}${U}`)||""}(c)})}))(((...e)=>{const t=o.default(...e);return Object.assign(Object.assign({},t),{flow:W(t),webauthn:H(t),fedcm:M(t)})}));exports.REFRESH_TOKEN_KEY=x,exports.SESSION_TOKEN_KEY=U,exports.clearFingerprintData=()=>{localStorage.removeItem(b)},exports.default=G,exports.ensureFingerprintIds=m; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
import{__rest as e}from"tslib";import t,{wrapWith as n}from"@descope/core-js-sdk";import{load as o}from"@fingerprintjs/fingerprintjs-pro";import a from"js-cookie";const i=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var a;return n[o]=[].concat((null===(a=e.hooks)||void 0===a?void 0:a[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},s=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},r=async e=>{const t=await s(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},l="undefined"!=typeof localStorage,c=(e,t)=>l&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),u=e=>l&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),d=e=>l&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),g=(...e)=>{console.debug(...e)},p="undefined"!=typeof window,f=Math.pow(2,31)-1,w=p&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",h="fp",b=(e=!1)=>{const t=localStorage.getItem(h);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},v=async e=>{try{if(b())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=o({apiKey:e,endpoint:w}),a=await n,{requestId:i}=await a.get({linkedId:t}),s=((e,t)=>({vsid:e,vrid:t}))(t,i);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(h,JSON.stringify(t))})(s)}catch(e){global.FB_DEBUG&&console.error(e)}},m=()=>{localStorage.removeItem(h)},y=e=>{const t=b(!0);return t&&e.body&&(e.body.fpData=t),e},S="dls_last_user_login_id",I="dls_last_user_display_name",O=()=>u(S),k=()=>u(I),j=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,a=O(),i=k();a&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=a,o.lastAuth.name=i);return await e(...t)},D=e=>async(...t)=>{const n=await e(...t);return d(S),d(I),n};function T(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const _="DS",U="DSR";function A(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const s=new Date(1e3*i),r=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);a.set(e,t,{path:n,domain:r?o:void 0,expires:s,sameSite:"Strict",secure:!0})}}function J(e=""){return u(`${e}${U}`)||""}function $(e=""){d(`${e}${U}`),d(`${e}${_}`),a.remove(_)}const C=e=>t=>async(...n)=>{const o=await t(...n);return $(e),o};async function K(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=E(n.publicKey.challenge),n.publicKey.user.id=E(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=E(e.id)})),n}(e),n=await navigator.credentials.create(t);return o=n,JSON.stringify({id:o.id,rawId:L(o.rawId),type:o.type,response:{attestationObject:L(o.response.attestationObject),clientDataJSON:L(o.response.clientDataJSON)}});var o}async function N(e){const t=P(e);return q(await navigator.credentials.get(t))}async function R(e,t){const n=P(e);n.signal=t.signal,n.mediation="conditional";return q(await navigator.credentials.get(n))}async function x(e=!1){if(!p)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function P(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=E(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=E(e.id)})),n}function q(e){return JSON.stringify({id:e.id,rawId:L(e.rawId),type:e.type,response:{authenticatorData:L(e.response.authenticatorData),clientDataJSON:L(e.response.clientDataJSON),signature:L(e.response.signature),userHandle:e.response.userHandle?L(e.response.userHandle):void 0}})}function E(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function L(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var G,H=(G=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const a=await K(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,a)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await N(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await K(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await N(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const a=await K(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,a)},helpers:{create:K,get:N,isSupported:x,conditional:R}}),(...e)=>{const t=G(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const V=e=>({async oneTap(t,n,o,a){const i=null!=t?t:"google",s=await e.oauth.startNative(i,o);if(!s.ok)return s;const{clientId:r,stateId:l,nonce:c}=s.data,u=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,s;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:r,callback:n=>{t(e.oauth.finishNative(i,l,"","",n.credential))},nonce:c})),u.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==a||a())}))}))}});var F=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await x(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const M=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:o,fpLoad:a}=n,s=e(n,["fpKey","fpLoad"]);return p?(o&&a&&v(o).catch((()=>null)),t(i(s,{beforeRequest:y}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(s))}),(t=>o=>{var{autoRefresh:a}=o,r=e(o,["autoRefresh"]);if(!a)return t(r);const{clearAllTimers:l,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let u,d;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(g("Expiration time passed, refreshing session"),p.refresh(d))}));const p=t(i(r,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await s(t);if(401===(null==t?void 0:t.status))g("Received 401, canceling all timers"),l();else if(o){u=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(o),d=n;let e=((a=u)?a.getTime()-(new Date).getTime():0)-2e4;e>f&&(g(`Timeout is too large (${e}ms), setting it to ${f}ms`),e=f),l();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});g(`Setting refresh timer for ${t}. (${e}ms)`),c((()=>{g("Refreshing session due to timer"),p.refresh(n)}),e)}var a}}));return n(p,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return g("Clearing all timers"),l(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.4"},t.baseHeaders)}))),(e=>t=>{const o=T(),a=T(),l=e(i(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),a.pub(null);else{const e=await r(t);e&&a.pub(e);const{sessionJwt:n}=await s(t);n&&o.pub(n)}}})),c=n(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return o.pub(null),a.pub(null),n}));return Object.assign(c,{onSessionTokenChange:o.sub,onUserChange:a.sub})}),(e=>t=>{const o=e(i(t,{afterRequest:async(e,t)=>{var n;const o=await r(t),a=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;a&&((e=>{c(S,e)})(a),(e=>{c(I,e)})(i))}}));let a=n(o,["flow.start"],j);return a=n(a,["logout","logoutAll"],D),Object.assign(a,{getLastUserLoginId:O,getLastUserDisplayName:k})}),(t=>o=>{var{persistTokens:r,sessionTokenViaCookie:l,storagePrefix:d}=o,g=e(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!r||!p)return r&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(g);const f=t(i(g,{beforeRequest:(w=d,e=>Object.assign(e,{token:e.token||J(w)})),afterRequest:async(t,n)=>{401===(null==n?void 0:n.status)?$(d):((t={},n,o)=>{var{refreshJwt:a,sessionJwt:i}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),a&&c(`${o}${U}`,a),i&&(n?A(_,i,s):c(`${o}${_}`,i))})(await s(n),l,d)}}));var w;const h=n(f,["logout","logoutAll"],C(d));return Object.assign(h,{getRefreshToken:()=>J(d),getSessionToken:()=>function(e=""){return a.get(_)||u(`${e}${_}`)||""}(d)})}))(((...e)=>{const n=t(...e);return Object.assign(Object.assign({},n),{flow:F(n),webauthn:H(n),fedcm:V(n)})}));export{U as REFRESH_TOKEN_KEY,_ as SESSION_TOKEN_KEY,m as clearFingerprintData,M as default,v as ensureFingerprintIds}; | ||
import{__rest as t}from"tslib";import e,{wrapWith as n}from"@descope/core-js-sdk";import{load as o,defaultEndpoint as a,defaultScriptUrlPattern as i}from"@fingerprintjs/fingerprintjs-pro";import r from"js-cookie";const s=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var a;return n[o]=[].concat((null===(a=t.hooks)||void 0===a?void 0:a[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},l=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},c=async t=>{const e=await l(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},u="undefined"!=typeof localStorage,d=(t,e)=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),g=t=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),p=t=>u&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),w=(...t)=>{console.debug(...t)},f="undefined"!=typeof window,h=Math.pow(2,31)-1,v=f&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",b="fp",m=(t=!1)=>{const e=localStorage.getItem(b);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},y=async(t,e=v)=>{try{if(m())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),r=new URL(e);r.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const s=new URL(e);s.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const l=s.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",c=o({apiKey:t,endpoint:[r.toString(),a],scriptUrlPattern:[l,i]}),u=await c,{requestId:d}=await u.get({linkedId:n}),g=((t,e)=>({vsid:t,vrid:e}))(n,d);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(b,JSON.stringify(e))})(g)}catch(t){console.warn("Could not load fingerprint",t)}},S=()=>{localStorage.removeItem(b)},I=t=>{const e=m(!0);return e&&t.body&&(t.body.fpData=e),t},O="dls_last_user_login_id",k="dls_last_user_display_name",j=()=>g(O),D=()=>g(k),U=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,a=j(),i=D();a&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=a,o.lastAuth.name=i);return await t(...e)},J=t=>async(...e)=>{const n=await t(...e);return p(O),p(k),n};function T(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const A="DS",_="DSR";function R(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:a}){if(e){const i=new Date(1e3*a),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);r.set(t,e,{path:n,domain:s?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}function x(t=""){return g(`${t}${_}`)||""}function K(t=""){p(`${t}${_}`),p(`${t}${A}`),r.remove(A)}const $=t=>e=>async(...n)=>{const o=await e(...n);return K(t),o};async function C(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=V(n.publicKey.challenge),n.publicKey.user.id=V(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=V(t.id)})),n}(t),n=await navigator.credentials.create(e);return o=n,JSON.stringify({id:o.id,rawId:H(o.rawId),type:o.type,response:{attestationObject:H(o.response.attestationObject),clientDataJSON:H(o.response.clientDataJSON)}});var o}async function N(t){const e=E(t);return L(await navigator.credentials.get(e))}async function P(t,e){const n=E(t);n.signal=e.signal,n.mediation="conditional";return L(await navigator.credentials.get(n))}async function q(t=!1){if(!f)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function E(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=V(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=V(t.id)})),n}function L(t){return JSON.stringify({id:t.id,rawId:H(t.rawId),type:t.type,response:{authenticatorData:H(t.response.authenticatorData),clientDataJSON:H(t.response.clientDataJSON),signature:H(t.response.signature),userHandle:t.response.userHandle?H(t.response.userHandle):void 0}})}function V(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function H(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var G,M=(G=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const a=await C(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,a)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await N(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await C(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await N(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const a=await C(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,a)},helpers:{create:C,get:N,isSupported:q,conditional:P}}),(...t)=>{const e=G(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const B=t=>({async oneTap(e,n,o,a){const i=null!=e?e:"google",r=await t.oauth.startNative(i,o);if(!r.ok)return r;const{clientId:s,stateId:l,nonce:c}=r.data,u=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var o,r;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(r=null==n?void 0:n.use_fedcm_for_prompt)||void 0===r||r,client_id:s,callback:n=>{e(t.oauth.finishNative(i,l,"","",n.credential))},nonce:c})),u.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==a||a())}))}))}});var F=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await q(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Z=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((e=>n=>{var{fpKey:o,fpLoad:a}=n,i=t(n,["fpKey","fpLoad"]);return f?(o&&a&&y(o).catch((()=>null)),e(s(i,{beforeRequest:I}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(i))}),(e=>o=>{var{autoRefresh:a}=o,i=t(o,["autoRefresh"]);if(!a)return e(i);const{clearAllTimers:r,setTimer:c}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let u,d;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(w("Expiration time passed, refreshing session"),g.refresh(d))}));const g=e(s(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await l(e);if(401===(null==e?void 0:e.status))w("Received 401, canceling all timers"),r();else if(o){u=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o),d=n;let t=((a=u)?a.getTime()-(new Date).getTime():0)-2e4;t>h&&(w(`Timeout is too large (${t}ms), setting it to ${h}ms`),t=h),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});w(`Setting refresh timer for ${e}. (${t}ms)`),c((()=>{w("Refreshing session due to timer"),g.refresh(n)}),t)}var a}}));return n(g,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return w("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.5"},e.baseHeaders)}))),(t=>e=>{const o=T(),a=T(),i=t(s(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))o.pub(null),a.pub(null);else{const t=await c(e);t&&a.pub(t);const{sessionJwt:n}=await l(e);n&&o.pub(n)}}})),r=n(i,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return o.pub(null),a.pub(null),n}));return Object.assign(r,{onSessionTokenChange:o.sub,onUserChange:a.sub})}),(t=>e=>{const o=t(s(e,{afterRequest:async(t,e)=>{var n;const o=await c(e),a=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;a&&((t=>{d(O,t)})(a),(t=>{d(k,t)})(i))}}));let a=n(o,["flow.start"],U);return a=n(a,["logout","logoutAll"],J),Object.assign(a,{getLastUserLoginId:j,getLastUserDisplayName:D})}),(e=>o=>{var{persistTokens:a,sessionTokenViaCookie:i,storagePrefix:c}=o,u=t(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!a||!f)return a&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(u);const p=e(s(u,{beforeRequest:(w=c,t=>Object.assign(t,{token:t.token||x(w)})),afterRequest:async(e,n)=>{401===(null==n?void 0:n.status)?K(c):((e={},n,o)=>{var{refreshJwt:a,sessionJwt:i}=e,r=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),a&&d(`${o}${_}`,a),i&&(n?R(A,i,r):d(`${o}${A}`,i))})(await l(n),i,c)}}));var w;const h=n(p,["logout","logoutAll"],$(c));return Object.assign(h,{getRefreshToken:()=>x(c),getSessionToken:()=>function(t=""){return r.get(A)||g(`${t}${A}`)||""}(c)})}))(((...t)=>{const n=e(...t);return Object.assign(Object.assign({},n),{flow:F(n),webauthn:M(n),fedcm:B(n)})}));export{_ as REFRESH_TOKEN_KEY,A as SESSION_TOKEN_KEY,S as clearFingerprintData,Z as default,y as ensureFingerprintIds}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,4 +0,4 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Descope=t()}(this,(function(){"use strict";const e=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},t=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},n=async e=>{const n=await t(e);return(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0)},o="undefined"!=typeof localStorage,r=(e,t)=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),i=e=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),a=e=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e));var s=function(){return s=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};function c(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e){this.message=e}"function"==typeof SuppressedError&&SuppressedError,u.prototype=new Error,u.prototype.name="InvalidCharacterError";var l="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,a="";o=t.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?a+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function d(e){this.message=e}function p(e,t){if("string"!=typeof e)throw new d("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(l(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return l(t)}}(e.split(".")[n]))}catch(e){throw new d("Invalid token specified: "+e.message)}}d.prototype=new Error,d.prototype.name="InvalidTokenError";var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h="__lodash_hash_undefined__",v=1/0,y="[object Function]",b="[object GeneratorFunction]",w="[object Symbol]",m=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,O=/^\w*$/,I=/^\./,k=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,j=/\\(\\)?/g,_=/^\[object .+?Constructor\]$/,S="object"==typeof f&&f&&f.Object===Object&&f,U="object"==typeof self&&self&&self.Object===Object&&self,P=S||U||Function("return this")();var R,E=Array.prototype,x=Function.prototype,T=Object.prototype,A=P["__core-js_shared__"],C=(R=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"",$=x.toString,q=T.hasOwnProperty,D=T.toString,J=RegExp("^"+$.call(q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),N=P.Symbol,K=E.splice,M=W(P,"Map"),L=W(Object,"create"),F=N?N.prototype:void 0,H=F?F.toString:void 0;function B(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function z(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function V(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function G(e,t){for(var n,o,r=e.length;r--;)if((n=e[r][0])===(o=t)||n!=n&&o!=o)return r;return-1}function Z(e,t){var n;t=function(e,t){if(ne(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||re(e))return!0;return O.test(e)||!m.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ne(n=t)?n:X(n);for(var o=0,r=t.length;null!=e&&o<r;)e=e[ee(t[o++])];return o&&o==r?e:void 0}function Y(e){if(!oe(e)||(t=e,C&&C in t))return!1;var t,n=function(e){var t=oe(e)?D.call(e):"";return t==y||t==b}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?J:_;return n.test(function(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Q(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function W(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Y(n)?n:void 0}B.prototype.clear=function(){this.__data__=L?L(null):{}},B.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},B.prototype.get=function(e){var t=this.__data__;if(L){var n=t[e];return n===h?void 0:n}return q.call(t,e)?t[e]:void 0},B.prototype.has=function(e){var t=this.__data__;return L?void 0!==t[e]:q.call(t,e)},B.prototype.set=function(e,t){return this.__data__[e]=L&&void 0===t?h:t,this},z.prototype.clear=function(){this.__data__=[]},z.prototype.delete=function(e){var t=this.__data__,n=G(t,e);return!(n<0)&&(n==t.length-1?t.pop():K.call(t,n,1),!0)},z.prototype.get=function(e){var t=this.__data__,n=G(t,e);return n<0?void 0:t[n][1]},z.prototype.has=function(e){return G(this.__data__,e)>-1},z.prototype.set=function(e,t){var n=this.__data__,o=G(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},V.prototype.clear=function(){this.__data__={hash:new B,map:new(M||z),string:new B}},V.prototype.delete=function(e){return Q(this,e).delete(e)},V.prototype.get=function(e){return Q(this,e).get(e)},V.prototype.has=function(e){return Q(this,e).has(e)},V.prototype.set=function(e,t){return Q(this,e).set(e,t),this};var X=te((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(re(e))return H?H.call(e):"";var t=e+"";return"0"==t&&1/e==-v?"-0":t}(t);var n=[];return I.test(e)&&n.push(""),e.replace(k,(function(e,t,o,r){n.push(o?r.replace(j,"$1"):t||e)})),n}));function ee(e){if("string"==typeof e||re(e))return e;var t=e+"";return"0"==t&&1/e==-v?"-0":t}function te(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var a=e.apply(this,o);return n.cache=i.set(r,a),a};return n.cache=new(te.Cache||V),n}te.Cache=V;var ne=Array.isArray;function oe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function re(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&D.call(e)==w}var ie=g((function(e,t,n){var o=null==e?void 0:Z(e,t);return void 0===o?n:o})),ae="/v1/auth/accesskey/exchange",se="/v1/auth/otp/verify",ce="/v1/auth/otp/signin",ue="/v1/auth/otp/signup",le={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},de="/v1/auth/otp/signup-in",pe="/v1/auth/magiclink/verify",fe="/v1/auth/magiclink/signin",ge="/v1/auth/magiclink/signup",he={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ve="/v1/auth/magiclink/signup-in",ye="/v1/auth/enchantedlink/verify",be="/v1/auth/enchantedlink/signin",we="/v1/auth/enchantedlink/signup",me="/v1/auth/enchantedlink/pending-session",Oe={email:"/v1/auth/enchantedlink/update/email"},Ie="/v1/auth/enchantedlink/signup-in",ke="/v1/auth/oauth/authorize",je="/v1/auth/oauth/exchange",_e="v1/auth/oauth/native/start",Se="v1/auth/oauth/native/finish",Ue="/v1/auth/saml/authorize",Pe="/v1/auth/saml/exchange",Re="/v1/auth/totp/verify",Ee="/v1/auth/totp/signup",xe="/v1/auth/totp/update",Te={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ae={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Ce={start:"/v1/auth/webauthn/signup-in/start"},$e={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},qe="/v1/auth/password/signup",De="/v1/auth/password/signin",Je="/v1/auth/password/reset",Ne="/v1/auth/password/update",Ke="/v1/auth/password/replace",Me="/v1/auth/password/policy",Le="/v1/auth/refresh",Fe="/v1/auth/tenant/select",He="/v1/auth/logout",Be="/v1/auth/logoutall",ze="/v1/auth/me",Ve="/v1/auth/me/history",Ge="/v1/flow/start",Ze="/v1/flow/next";const Ye="<region>",Qe=`https://api.${Ye}descope.com`,We=6e5,Xe=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var et;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(et||(et={}));const tt=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),nt=e=>void 0===e?void 0:JSON.stringify(e),ot=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},rt=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:a})=>{const s=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Xe().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Xe().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,a),c=async o=>{const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:c,body:u,headers:l,queryParams:d,method:p,token:f}=a,g={headers:tt(ot(t,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.11.3"},(null==n?void 0:n.baseHeaders)||{},l),method:p,body:nt(u)};null!==i&&(g.credentials=i||"include");const h=await s((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Ye,r?r+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:d,projectId:t}),g);return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:et.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:et.post,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:et.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:et.delete,token:o}),hooks:r}};var it=429;function at(e,t,n){var o;let r=st(e);t&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function st(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return p(e)}function ct(e){const{exp:t}=st(e);return(new Date).getTime()/1e3>t}function ut(e){let t=st(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function lt(e,t){return at(e,t,"permissions")}function dt(e,t){return at(e,t,"roles")}const pt=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ft(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===it&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const gt=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ht=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),vt=e=>t=>e.test(t),yt=vt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),bt=vt(/^\+[1-9]{1}[0-9]{3,14}$/),wt=gt(yt,'"{val}" is not a valid email'),mt=gt(bt,'"{val}" is not a valid phone number'),Ot=gt((1,e=>e.length>=1),"Minimum length is 1");const It=gt((e=>"string"==typeof e),"Input is not a string"),kt=gt((e=>void 0===e),"Input is defined"),jt=(_t=[It(),kt()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=_t.filter((e=>e(t)));return!(n.length<_t.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var _t;const St=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ht(...e).validate(n[t]))),t(...n)),Ut=e=>[It(`"${e}" must be a string`),Ot(`"${e}" must not be empty`)],Pt=e=>[It(`"${e}" must be a string`),wt()],Rt=e=>[It(`"${e}" must be a string`),mt()],Et=St(Ut("accessKey")),xt=e=>({exchange:Et(((t,n)=>ft(e.post(ae,{loginOptions:n},{token:t}))))});var Tt,At;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Tt||(Tt={})),function(e){e.email="email"}(At||(At={}));const Ct=Object.assign(Object.assign({},Tt),At);var $t;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}($t||($t={}));const qt=Ut("loginId"),Dt=St(Ut("token")),Jt=St(qt),Nt=St(Ut("pendingRef")),Kt=St(qt,Pt("email")),Mt=e=>({verify:Dt((t=>ft(e.post(ye,{token:t})))),signIn:Jt(((t,n,o,r)=>ft(e.post(pt(be,Ct.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:Jt(((t,n,o)=>ft(e.post(pt(Ie,Ct.email),{loginId:t,URI:n,loginOptions:o})))),signUp:Jt(((t,n,o,r)=>ft(e.post(pt(we,Ct.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:Nt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||We,We)}))(n);let a;const s=setInterval((async()=>{const n=await e.post(me,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),o(ft(Promise.resolve(n))))}),r);a=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:Kt(((t,n,o,r,i)=>ft(e.post(Oe.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),Lt=St(Ut("flowId")),Ft=St(Ut("executionId"),Ut("stepId"),Ut("interactionId")),Ht=e=>({start:Lt(((t,n,o,r,i,a,s)=>ft(e.post(Ge,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,version:i,componentsVersion:a,input:s})))),next:Ft(((t,n,o,r,i,a)=>ft(e.post(Ze,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:a}))))}),Bt=Ut("loginId"),zt=St(Ut("token")),Vt=St(Bt),Gt=St(Bt,Rt("phone")),Zt=St(Bt,Pt("email")),Yt=e=>({verify:zt((t=>ft(e.post(pe,{token:t})))),signIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Vt(((t,o,r,i)=>ft(e.post(pt(fe,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Vt(((t,o,r,i)=>ft(e.post(pt(ge,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Vt(((t,o,r)=>ft(e.post(pt(ve,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:Zt(((t,n,o,r,i)=>ft(e.post(he.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i,a)=>ft(e.post(pt(he.phone,n),Object.assign({loginId:t,phone:o,URI:r},a),{token:i}))))})),{})}});var Qt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Qt||(Qt={}));const Wt=St(Ut("code")),Xt=e=>({start:Object.assign(((t,n,o,r)=>ft(e.post(ke,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(Qt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>ft(e.post(ke,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:Wt((t=>ft(e.post(je,{code:t})))),startNative:(t,n)=>ft(e.post(_e,{provider:t,loginOptions:n})),finishNative:(t,n,o,r,i)=>ft(e.post(Se,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),en=Ut("loginId"),tn=St(en,Ut("code")),nn=St(en),on=St(en,Rt("phone")),rn=St(en,Pt("email")),an=e=>({verify:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tn(((t,o)=>ft(e.post(pt(se,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o,r)=>ft(e.post(pt(ce,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o,r)=>ft(e.post(pt(ue,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o)=>ft(e.post(pt(de,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:rn(((t,n,o,r)=>ft(e.post(le.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:on(((t,o,r,i)=>ft(e.post(pt(le.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),sn=St(Ut("tenant")),cn=St(Ut("code")),un=e=>({start:sn(((t,n,o,r)=>ft(e.post(Ue,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:cn((t=>ft(e.post(Pe,{code:t}))))}),ln=Ut("loginId"),dn=St(ln,Ut("code")),pn=St(ln),fn=St(ln),gn=e=>({signUp:pn(((t,n)=>ft(e.post(Ee,{loginId:t,user:n})))),verify:dn(((t,n,o,r)=>ft(e.post(Re,{loginId:t,code:n,loginOptions:o},{token:r})))),update:fn(((t,n)=>ft(e.post(xe,{loginId:t},{token:n}))))}),hn=Ut("loginId"),vn=Ut("newPassword"),yn=St(hn,Ut("password")),bn=St(hn),wn=St(hn,vn),mn=St(hn,Ut("oldPassword"),vn),On=e=>({signUp:yn(((t,n,o)=>ft(e.post(qe,{loginId:t,password:n,user:o})))),signIn:yn(((t,n)=>ft(e.post(De,{loginId:t,password:n})))),sendReset:bn(((t,n,o)=>ft(e.post(Je,{loginId:t,redirectUrl:n,templateOptions:o})))),update:wn(((t,n,o)=>ft(e.post(Ne,{loginId:t,newPassword:n},{token:o})))),replace:mn(((t,n,o)=>ft(e.post(Ke,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>ft(e.get(Me))}),In=[It('"loginId" must be a string')],kn=Ut("loginId"),jn=Ut("origin"),_n=St(kn,jn,Ut("name")),Sn=St(kn,jn),Un=St(In,jn),Pn=St(kn,jn,Ut("token")),Rn=St(Ut("transactionId"),Ut("response")),En=e=>({signUp:{start:_n(((t,n,o)=>ft(e.post(Te.start,{user:{loginId:t,name:o},origin:n})))),finish:Rn(((t,n)=>ft(e.post(Te.finish,{transactionId:t,response:n}))))},signIn:{start:Un(((t,n,o,r)=>ft(e.post(Ae.start,{loginId:t,origin:n,loginOptions:o},{token:r})))),finish:Rn(((t,n)=>ft(e.post(Ae.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Sn(((t,n)=>ft(e.post(Ce.start,{loginId:t,origin:n}))))},update:{start:Pn(((t,n,o)=>ft(e.post($e.start,{loginId:t,origin:n},{token:o})))),finish:Rn(((t,n)=>ft(e.post($e.finish,{transactionId:t,response:n}))))}}),xn=St(Ut("token")),Tn=St([jt('"token" must be string or undefined')]);var An,Cn=St([("projectId",An=Ut("projectId"),gt(((e,t)=>n=>ht(...t).validate(ie(n,e)))("projectId",An))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:a})=>{return s=rt({baseUrl:n||Qe,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:xt(s),otp:an(s),magicLink:Yt(s),enchantedLink:Mt(s),oauth:Xt(s),saml:un(s),totp:gn(s),webauthn:En(s),password:On(s),flow:Ht(s),refresh:Tn((e=>ft(s.post(Le,{},{token:e})))),selectTenant:St([It("tenantId")],[jt('"token" must be string or undefined')])(((e,t)=>ft(s.post(Fe,{tenant:e},{token:t})))),logout:Tn((e=>ft(s.post(He,{},{token:e})))),logoutAll:Tn((e=>ft(s.post(Be,{},{token:e})))),me:Tn((e=>ft(s.get(ze,{token:e})))),history:Tn((e=>ft(s.get(Ve,{token:e})))),isJwtExpired:xn(ct),getTenants:xn(ut),getJwtPermissions:xn(lt),getJwtRoles:xn(dt),httpClient:s};var s})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const $n=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const a=i[r];i[r]=n(a)})),e);var qn=Object.assign(Cn,{DeliveryMethods:Ct});const Dn=(...e)=>{console.debug(...e)},Jn="undefined"!=typeof window,Nn=Math.pow(2,31)-1,Kn=Jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com";var Mn="Blocked by CSP",Ln="9319";function Fn(e,t){var n=[];return function(e,t){var n,o,r=(o=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return o[0]},postpone:function(){var e=o.shift();void 0!==e&&o.push(e)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),a=r.current();if(void 0===a)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var s=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Mn||t===Ln}(e)?r.postpone():r.exclude();var t,o=r.current();if(void 0===o)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return s(o,n+1)}))}))};return s(a,0)}(e,(function(e){var o=new Date,r=function(t){return n.push({url:e,startedAt:o,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return r()}),r),i})).then((function(e){return[e,{attempts:n}]}))}var Hn="Failed to load the JS script of the agent";function Bn(e){var t;e.scriptUrlPattern;var n=e.token,o=e.apiKey,r=void 0===o?n:o,i=c(e,["scriptUrlPattern","token","apiKey"]),a=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!r||"string"!=typeof r)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.8.5"):e}))}(String(e),t)}))}(a,r);return Fn(e,zn).catch(Gn)})).then((function(e){var t=e[0],n=e[1];return t.load(s(s({},i),{ldi:n}))}))}function zn(e){return function(e,t,n,o){var r,i=document,a="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(a,s);var c=function(){return i.removeEventListener(a,s)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),r)return function(){throw new Error(Mn)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(Hn))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)})).then(Vn)}function Vn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Ln);return n}function Gn(e){throw e instanceof Error&&e.message===Ln?new Error(Hn):e}const Zn=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Yn=async e=>{try{if(Zn())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Bn({apiKey:e,endpoint:Kn}),o=await n,{requestId:r}=await o.get({linkedId:t}),i=((e,t)=>({vsid:e,vrid:t}))(t,r);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(i)}catch(e){global.FB_DEBUG&&console.error(e)}},Qn=e=>{const t=Zn(!0);return t&&e.body&&(e.body.fpData=t),e},Wn="dls_last_user_login_id",Xn="dls_last_user_display_name",eo=()=>i(Wn),to=()=>i(Xn),no=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=eo(),i=to();r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i);return await e(...t)},oo=e=>async(...t)=>{const n=await e(...t);return a(Wn),a(Xn),n};function ro(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}} | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Descope=t()}(this,(function(){"use strict";const e=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},t=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},n=async e=>{const n=await t(e);return(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0)},o="undefined"!=typeof localStorage,r=(e,t)=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),i=e=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),a=e=>o&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e));var s=function(){return s=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};function c(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e){this.message=e}"function"==typeof SuppressedError&&SuppressedError,u.prototype=new Error,u.prototype.name="InvalidCharacterError";var l="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,a="";o=t.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?a+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function d(e){this.message=e}function p(e,t){if("string"!=typeof e)throw new d("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(l(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return l(t)}}(e.split(".")[n]))}catch(e){throw new d("Invalid token specified: "+e.message)}}d.prototype=new Error,d.prototype.name="InvalidTokenError";var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h="__lodash_hash_undefined__",v=1/0,y="[object Function]",b="[object GeneratorFunction]",w="[object Symbol]",m=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,I=/^\w*$/,O=/^\./,k=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,j=/\\(\\)?/g,_=/^\[object .+?Constructor\]$/,S="object"==typeof f&&f&&f.Object===Object&&f,U="object"==typeof self&&self&&self.Object===Object&&self,P=S||U||Function("return this")();var R,E=Array.prototype,x=Function.prototype,T=Object.prototype,A=P["__core-js_shared__"],C=(R=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"",$=x.toString,q=T.hasOwnProperty,D=T.toString,J=RegExp("^"+$.call(q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),K=P.Symbol,N=E.splice,L=Q(P,"Map"),M=Q(Object,"create"),F=K?K.prototype:void 0,V=F?F.toString:void 0;function H(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function B(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function z(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function G(e,t){for(var n,o,r=e.length;r--;)if((n=e[r][0])===(o=t)||n!=n&&o!=o)return r;return-1}function Z(e,t){var n;t=function(e,t){if(ne(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||re(e))return!0;return I.test(e)||!m.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ne(n=t)?n:W(n);for(var o=0,r=t.length;null!=e&&o<r;)e=e[ee(t[o++])];return o&&o==r?e:void 0}function X(e){if(!oe(e)||(t=e,C&&C in t))return!1;var t,n=function(e){var t=oe(e)?D.call(e):"";return t==y||t==b}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?J:_;return n.test(function(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Y(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function Q(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return X(n)?n:void 0}H.prototype.clear=function(){this.__data__=M?M(null):{}},H.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},H.prototype.get=function(e){var t=this.__data__;if(M){var n=t[e];return n===h?void 0:n}return q.call(t,e)?t[e]:void 0},H.prototype.has=function(e){var t=this.__data__;return M?void 0!==t[e]:q.call(t,e)},H.prototype.set=function(e,t){return this.__data__[e]=M&&void 0===t?h:t,this},B.prototype.clear=function(){this.__data__=[]},B.prototype.delete=function(e){var t=this.__data__,n=G(t,e);return!(n<0)&&(n==t.length-1?t.pop():N.call(t,n,1),!0)},B.prototype.get=function(e){var t=this.__data__,n=G(t,e);return n<0?void 0:t[n][1]},B.prototype.has=function(e){return G(this.__data__,e)>-1},B.prototype.set=function(e,t){var n=this.__data__,o=G(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},z.prototype.clear=function(){this.__data__={hash:new H,map:new(L||B),string:new H}},z.prototype.delete=function(e){return Y(this,e).delete(e)},z.prototype.get=function(e){return Y(this,e).get(e)},z.prototype.has=function(e){return Y(this,e).has(e)},z.prototype.set=function(e,t){return Y(this,e).set(e,t),this};var W=te((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(re(e))return V?V.call(e):"";var t=e+"";return"0"==t&&1/e==-v?"-0":t}(t);var n=[];return O.test(e)&&n.push(""),e.replace(k,(function(e,t,o,r){n.push(o?r.replace(j,"$1"):t||e)})),n}));function ee(e){if("string"==typeof e||re(e))return e;var t=e+"";return"0"==t&&1/e==-v?"-0":t}function te(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var a=e.apply(this,o);return n.cache=i.set(r,a),a};return n.cache=new(te.Cache||z),n}te.Cache=z;var ne=Array.isArray;function oe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function re(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&D.call(e)==w}var ie=g((function(e,t,n){var o=null==e?void 0:Z(e,t);return void 0===o?n:o})),ae="/v1/auth/accesskey/exchange",se="/v1/auth/otp/verify",ce="/v1/auth/otp/signin",ue="/v1/auth/otp/signup",le={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},de="/v1/auth/otp/signup-in",pe="/v1/auth/magiclink/verify",fe="/v1/auth/magiclink/signin",ge="/v1/auth/magiclink/signup",he={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ve="/v1/auth/magiclink/signup-in",ye="/v1/auth/enchantedlink/verify",be="/v1/auth/enchantedlink/signin",we="/v1/auth/enchantedlink/signup",me="/v1/auth/enchantedlink/pending-session",Ie={email:"/v1/auth/enchantedlink/update/email"},Oe="/v1/auth/enchantedlink/signup-in",ke="/v1/auth/oauth/authorize",je="/v1/auth/oauth/exchange",_e="v1/auth/oauth/native/start",Se="v1/auth/oauth/native/finish",Ue="/v1/auth/saml/authorize",Pe="/v1/auth/saml/exchange",Re="/v1/auth/totp/verify",Ee="/v1/auth/totp/signup",xe="/v1/auth/totp/update",Te={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ae={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Ce={start:"/v1/auth/webauthn/signup-in/start"},$e={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},qe="/v1/auth/password/signup",De="/v1/auth/password/signin",Je="/v1/auth/password/reset",Ke="/v1/auth/password/update",Ne="/v1/auth/password/replace",Le="/v1/auth/password/policy",Me="/v1/auth/refresh",Fe="/v1/auth/tenant/select",Ve="/v1/auth/logout",He="/v1/auth/logoutall",Be="/v1/auth/me",ze="/v1/auth/me/history",Ge="/v1/flow/start",Ze="/v1/flow/next";const Xe="<region>",Ye=`https://api.${Xe}descope.com`,Qe=6e5,We=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var et;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(et||(et={}));const tt=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),nt=e=>void 0===e?void 0:JSON.stringify(e),ot=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},rt=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:a})=>{const s=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>We().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return We().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,a),c=async o=>{const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:c,body:u,headers:l,queryParams:d,method:p,token:f}=a,g={headers:tt(ot(t,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.11.3"},(null==n?void 0:n.baseHeaders)||{},l),method:p,body:nt(u)};null!==i&&(g.credentials=i||"include");const h=await s((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Xe,r?r+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:d,projectId:t}),g);return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:et.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:et.post,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:et.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:et.delete,token:o}),hooks:r}};var it=429;function at(e,t,n){var o;let r=st(e);t&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function st(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return p(e)}function ct(e){const{exp:t}=st(e);return(new Date).getTime()/1e3>t}function ut(e){let t=st(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function lt(e,t){return at(e,t,"permissions")}function dt(e,t){return at(e,t,"roles")}const pt=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ft(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===it&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const gt=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ht=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),vt=e=>t=>e.test(t),yt=vt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),bt=vt(/^\+[1-9]{1}[0-9]{3,14}$/),wt=gt(yt,'"{val}" is not a valid email'),mt=gt(bt,'"{val}" is not a valid phone number'),It=gt((1,e=>e.length>=1),"Minimum length is 1");const Ot=gt((e=>"string"==typeof e),"Input is not a string"),kt=gt((e=>void 0===e),"Input is defined"),jt=(_t=[Ot(),kt()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=_t.filter((e=>e(t)));return!(n.length<_t.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var _t;const St=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ht(...e).validate(n[t]))),t(...n)),Ut=e=>[Ot(`"${e}" must be a string`),It(`"${e}" must not be empty`)],Pt=e=>[Ot(`"${e}" must be a string`),wt()],Rt=e=>[Ot(`"${e}" must be a string`),mt()],Et=St(Ut("accessKey")),xt=e=>({exchange:Et(((t,n)=>ft(e.post(ae,{loginOptions:n},{token:t}))))});var Tt,At;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Tt||(Tt={})),function(e){e.email="email"}(At||(At={}));const Ct=Object.assign(Object.assign({},Tt),At);var $t;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}($t||($t={}));const qt=Ut("loginId"),Dt=St(Ut("token")),Jt=St(qt),Kt=St(Ut("pendingRef")),Nt=St(qt,Pt("email")),Lt=e=>({verify:Dt((t=>ft(e.post(ye,{token:t})))),signIn:Jt(((t,n,o,r)=>ft(e.post(pt(be,Ct.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:Jt(((t,n,o)=>ft(e.post(pt(Oe,Ct.email),{loginId:t,URI:n,loginOptions:o})))),signUp:Jt(((t,n,o,r)=>ft(e.post(pt(we,Ct.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:Kt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Qe,Qe)}))(n);let a;const s=setInterval((async()=>{const n=await e.post(me,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),o(ft(Promise.resolve(n))))}),r);a=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:Nt(((t,n,o,r,i)=>ft(e.post(Ie.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),Mt=St(Ut("flowId")),Ft=St(Ut("executionId"),Ut("stepId"),Ut("interactionId")),Vt=e=>({start:Mt(((t,n,o,r,i,a,s)=>ft(e.post(Ge,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,version:i,componentsVersion:a,input:s})))),next:Ft(((t,n,o,r,i,a)=>ft(e.post(Ze,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:a}))))}),Ht=Ut("loginId"),Bt=St(Ut("token")),zt=St(Ht),Gt=St(Ht,Rt("phone")),Zt=St(Ht,Pt("email")),Xt=e=>({verify:Bt((t=>ft(e.post(pe,{token:t})))),signIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zt(((t,o,r,i)=>ft(e.post(pt(fe,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zt(((t,o,r,i)=>ft(e.post(pt(ge,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zt(((t,o,r)=>ft(e.post(pt(ve,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:Zt(((t,n,o,r,i)=>ft(e.post(he.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i,a)=>ft(e.post(pt(he.phone,n),Object.assign({loginId:t,phone:o,URI:r},a),{token:i}))))})),{})}});var Yt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Yt||(Yt={}));const Qt=St(Ut("code")),Wt=e=>({start:Object.assign(((t,n,o,r)=>ft(e.post(ke,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(Yt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>ft(e.post(ke,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:Qt((t=>ft(e.post(je,{code:t})))),startNative:(t,n)=>ft(e.post(_e,{provider:t,loginOptions:n})),finishNative:(t,n,o,r,i)=>ft(e.post(Se,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),en=Ut("loginId"),tn=St(en,Ut("code")),nn=St(en),on=St(en,Rt("phone")),rn=St(en,Pt("email")),an=e=>({verify:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tn(((t,o)=>ft(e.post(pt(se,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o,r)=>ft(e.post(pt(ce,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o,r)=>ft(e.post(pt(ue,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Ct).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nn(((t,o)=>ft(e.post(pt(de,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:rn(((t,n,o,r)=>ft(e.post(le.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:on(((t,o,r,i)=>ft(e.post(pt(le.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),sn=St(Ut("tenant")),cn=St(Ut("code")),un=e=>({start:sn(((t,n,o,r)=>ft(e.post(Ue,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:cn((t=>ft(e.post(Pe,{code:t}))))}),ln=Ut("loginId"),dn=St(ln,Ut("code")),pn=St(ln),fn=St(ln),gn=e=>({signUp:pn(((t,n)=>ft(e.post(Ee,{loginId:t,user:n})))),verify:dn(((t,n,o,r)=>ft(e.post(Re,{loginId:t,code:n,loginOptions:o},{token:r})))),update:fn(((t,n)=>ft(e.post(xe,{loginId:t},{token:n}))))}),hn=Ut("loginId"),vn=Ut("newPassword"),yn=St(hn,Ut("password")),bn=St(hn),wn=St(hn,vn),mn=St(hn,Ut("oldPassword"),vn),In=e=>({signUp:yn(((t,n,o)=>ft(e.post(qe,{loginId:t,password:n,user:o})))),signIn:yn(((t,n)=>ft(e.post(De,{loginId:t,password:n})))),sendReset:bn(((t,n,o)=>ft(e.post(Je,{loginId:t,redirectUrl:n,templateOptions:o})))),update:wn(((t,n,o)=>ft(e.post(Ke,{loginId:t,newPassword:n},{token:o})))),replace:mn(((t,n,o)=>ft(e.post(Ne,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>ft(e.get(Le))}),On=[Ot('"loginId" must be a string')],kn=Ut("loginId"),jn=Ut("origin"),_n=St(kn,jn,Ut("name")),Sn=St(kn,jn),Un=St(On,jn),Pn=St(kn,jn,Ut("token")),Rn=St(Ut("transactionId"),Ut("response")),En=e=>({signUp:{start:_n(((t,n,o)=>ft(e.post(Te.start,{user:{loginId:t,name:o},origin:n})))),finish:Rn(((t,n)=>ft(e.post(Te.finish,{transactionId:t,response:n}))))},signIn:{start:Un(((t,n,o,r)=>ft(e.post(Ae.start,{loginId:t,origin:n,loginOptions:o},{token:r})))),finish:Rn(((t,n)=>ft(e.post(Ae.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Sn(((t,n)=>ft(e.post(Ce.start,{loginId:t,origin:n}))))},update:{start:Pn(((t,n,o)=>ft(e.post($e.start,{loginId:t,origin:n},{token:o})))),finish:Rn(((t,n)=>ft(e.post($e.finish,{transactionId:t,response:n}))))}}),xn=St(Ut("token")),Tn=St([jt('"token" must be string or undefined')]);var An,Cn=St([("projectId",An=Ut("projectId"),gt(((e,t)=>n=>ht(...t).validate(ie(n,e)))("projectId",An))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:a})=>{return s=rt({baseUrl:n||Ye,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:xt(s),otp:an(s),magicLink:Xt(s),enchantedLink:Lt(s),oauth:Wt(s),saml:un(s),totp:gn(s),webauthn:En(s),password:In(s),flow:Vt(s),refresh:Tn((e=>ft(s.post(Me,{},{token:e})))),selectTenant:St([Ot("tenantId")],[jt('"token" must be string or undefined')])(((e,t)=>ft(s.post(Fe,{tenant:e},{token:t})))),logout:Tn((e=>ft(s.post(Ve,{},{token:e})))),logoutAll:Tn((e=>ft(s.post(He,{},{token:e})))),me:Tn((e=>ft(s.get(Be,{token:e})))),history:Tn((e=>ft(s.get(ze,{token:e})))),isJwtExpired:xn(ct),getTenants:xn(ut),getJwtPermissions:xn(lt),getJwtRoles:xn(dt),httpClient:s};var s})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const $n=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const a=i[r];i[r]=n(a)})),e);var qn=Object.assign(Cn,{DeliveryMethods:Ct});const Dn=(...e)=>{console.debug(...e)},Jn="undefined"!=typeof window,Kn=Math.pow(2,31)-1,Nn=Jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com";var Ln={default:"endpoint"},Mn="Blocked by CSP",Fn="9319";function Vn(e,t){var n=[];return function(e,t){var n,o,r=(o=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return o[0]},postpone:function(){var e=o.shift();void 0!==e&&o.push(e)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),a=r.current();if(void 0===a)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var s=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Mn||t===Fn}(e)?r.postpone():r.exclude();var t,o=r.current();if(void 0===o)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return s(o,n+1)}))}))};return s(a,0)}(e,(function(e){var o=new Date,r=function(t){return n.push({url:e,startedAt:o,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return r()}),r),i})).then((function(e){return[e,{attempts:n}]}))}var Hn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Bn=Hn,zn="Failed to load the JS script of the agent";function Gn(e){var t;e.scriptUrlPattern;var n=e.token,o=e.apiKey,r=void 0===o?n:o,i=c(e,["scriptUrlPattern","token","apiKey"]),a=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:Hn;return Promise.resolve().then((function(){if(!r||"string"!=typeof r)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.8.5"):e}))}(String(e),t)}))}(a,r);return Vn(e,Zn).catch(Yn)})).then((function(e){var t=e[0],n=e[1];return t.load(s(s({},i),{ldi:n}))}))}function Zn(e){return function(e,t,n,o){var r,i=document,a="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(a,s);var c=function(){return i.removeEventListener(a,s)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),r)return function(){throw new Error(Mn)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(zn))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)})).then(Xn)}function Xn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Fn);return n}function Yn(e){throw e instanceof Error&&e.message===Fn?new Error(zn):e}const Qn=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Wn=async(e,t=Nn)=>{try{if(Qn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",a=Gn({apiKey:e,endpoint:[o.toString(),Ln],scriptUrlPattern:[i,Bn]}),s=await a,{requestId:c}=await s.get({linkedId:n}),u=((e,t)=>({vsid:e,vrid:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(u)}catch(e){console.warn("Could not load fingerprint",e)}},eo=e=>{const t=Qn(!0);return t&&e.body&&(e.body.fpData=t),e},to="dls_last_user_login_id",no="dls_last_user_display_name",oo=()=>i(to),ro=()=>i(no),io=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=oo(),i=ro();r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i);return await e(...t)},ao=e=>async(...t)=>{const n=await e(...t);return a(to),a(no),n};function so(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}} | ||
/*! js-cookie v3.0.5 | MIT */ | ||
function io(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var ao=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=io({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in r)r[a]&&(i+="; "+a,!0!==r[a]&&(i+="="+r[a].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(o[s]=t.read(a,s),e===s)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",io({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,io({},this.attributes,t))},withConverter:function(t){return e(io({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const so="DS",co="DSR";function uo(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),a=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);ao.set(e,t,{path:n,domain:a?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}function lo(e=""){return i(`${e}${co}`)||""}function po(e=""){a(`${e}${co}`),a(`${e}${so}`),ao.remove(so)}const fo=e=>t=>async(...n)=>{const o=await t(...n);return po(e),o};async function go(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=mo(n.publicKey.challenge),n.publicKey.user.id=mo(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=mo(e.id)})),n}(e),n=await navigator.credentials.create(t);return o=n,JSON.stringify({id:o.id,rawId:Oo(o.rawId),type:o.type,response:{attestationObject:Oo(o.response.attestationObject),clientDataJSON:Oo(o.response.clientDataJSON)}});var o}async function ho(e){const t=bo(e);return wo(await navigator.credentials.get(t))}async function vo(e,t){const n=bo(e);n.signal=t.signal,n.mediation="conditional";return wo(await navigator.credentials.get(n))}async function yo(e=!1){if(!Jn)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function bo(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=mo(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=mo(e.id)})),n}function wo(e){return JSON.stringify({id:e.id,rawId:Oo(e.rawId),type:e.type,response:{authenticatorData:Oo(e.response.authenticatorData),clientDataJSON:Oo(e.response.clientDataJSON),signature:Oo(e.response.signature),userHandle:e.response.userHandle?Oo(e.response.userHandle):void 0}})}function mo(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Oo(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Io,ko=(Io=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const r=await go(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await ho(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await go(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ho(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const r=await go(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:go,get:ho,isSupported:yo,conditional:vo}}),(...e)=>{const t=Io(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const jo=e=>({async oneTap(t,n,o,r){const i=null!=t?t:"google",a=await e.oauth.startNative(i,o);if(!a.ok)return a;const{clientId:s,stateId:c,nonce:u}=a.data,l=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,a;l.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:s,callback:n=>{t(e.oauth.finishNative(i,c,"","",n.credential))},nonce:u})),l.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==r||r())}))}))}});var _o=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await yo(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const So=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=c(n,["fpKey","fpLoad"]);return Jn?(o&&r&&Yn(o).catch((()=>null)),t(e(i,{beforeRequest:Qn}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(i))}),(n=>o=>{var{autoRefresh:r}=o,i=c(o,["autoRefresh"]);if(!r)return n(i);const{clearAllTimers:a,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let u,l;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(Dn("Expiration time passed, refreshing session"),d.refresh(l))}));const d=n(e(i,{afterRequest:async(e,n)=>{const{refreshJwt:o,sessionJwt:r}=await t(n);if(401===(null==n?void 0:n.status))Dn("Received 401, canceling all timers"),a();else if(r){u=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(r),l=o;let e=((i=u)?i.getTime()-(new Date).getTime():0)-2e4;e>Nn&&(Dn(`Timeout is too large (${e}ms), setting it to ${Nn}ms`),e=Nn),a();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Dn(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Dn("Refreshing session due to timer"),d.refresh(o)}),e)}var i}}));return $n(d,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Dn("Clearing all timers"),a(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.4"},t.baseHeaders)}))),(o=>r=>{const i=ro(),a=ro(),s=o(e(r,{afterRequest:async(e,o)=>{if(401===(null==o?void 0:o.status))i.pub(null),a.pub(null);else{const e=await n(o);e&&a.pub(e);const{sessionJwt:r}=await t(o);r&&i.pub(r)}}})),c=$n(s,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return i.pub(null),a.pub(null),n}));return Object.assign(c,{onSessionTokenChange:i.sub,onUserChange:a.sub})}),(t=>o=>{const i=t(e(o,{afterRequest:async(e,t)=>{var o;const i=await n(t),a=null===(o=null==i?void 0:i.loginIds)||void 0===o?void 0:o[0],s=null==i?void 0:i.name;a&&((e=>{r(Wn,e)})(a),(e=>{r(Xn,e)})(s))}}));let a=$n(i,["flow.start"],no);return a=$n(a,["logout","logoutAll"],oo),Object.assign(a,{getLastUserLoginId:eo,getLastUserDisplayName:to})}),(n=>o=>{var{persistTokens:a,sessionTokenViaCookie:s,storagePrefix:u}=o,l=c(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!a||!Jn)return a&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),n(l);const d=n(e(l,{beforeRequest:(p=u,e=>Object.assign(e,{token:e.token||lo(p)})),afterRequest:async(e,n)=>{401===(null==n?void 0:n.status)?po(u):((e={},t,n)=>{var{refreshJwt:o,sessionJwt:i}=e,a=c(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===n&&(n=""),o&&r(`${n}${co}`,o),i&&(t?uo(so,i,a):r(`${n}${so}`,i))})(await t(n),s,u)}}));var p;const f=$n(d,["logout","logoutAll"],fo(u));return Object.assign(f,{getRefreshToken:()=>lo(u),getSessionToken:()=>function(e=""){return ao.get(so)||i(`${e}${so}`)||""}(u)})}))(((...e)=>{const t=qn(...e);return Object.assign(Object.assign({},t),{flow:_o(t),webauthn:ko(t),fedcm:jo(t)})}));return So.REFRESH_TOKEN_KEY=co,So.SESSION_TOKEN_KEY=so,So})); | ||
function co(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var uo=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=co({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in r)r[a]&&(i+="; "+a,!0!==r[a]&&(i+="="+r[a].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(o[s]=t.read(a,s),e===s)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",co({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,co({},this.attributes,t))},withConverter:function(t){return e(co({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const lo="DS",po="DSR";function fo(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),a=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);uo.set(e,t,{path:n,domain:a?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}function go(e=""){return i(`${e}${po}`)||""}function ho(e=""){a(`${e}${po}`),a(`${e}${lo}`),uo.remove(lo)}const vo=e=>t=>async(...n)=>{const o=await t(...n);return ho(e),o};async function yo(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ko(n.publicKey.challenge),n.publicKey.user.id=ko(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ko(e.id)})),n}(e),n=await navigator.credentials.create(t);return o=n,JSON.stringify({id:o.id,rawId:jo(o.rawId),type:o.type,response:{attestationObject:jo(o.response.attestationObject),clientDataJSON:jo(o.response.clientDataJSON)}});var o}async function bo(e){const t=Io(e);return Oo(await navigator.credentials.get(t))}async function wo(e,t){const n=Io(e);n.signal=t.signal,n.mediation="conditional";return Oo(await navigator.credentials.get(n))}async function mo(e=!1){if(!Jn)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Io(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ko(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ko(e.id)})),n}function Oo(e){return JSON.stringify({id:e.id,rawId:jo(e.rawId),type:e.type,response:{authenticatorData:jo(e.response.authenticatorData),clientDataJSON:jo(e.response.clientDataJSON),signature:jo(e.response.signature),userHandle:e.response.userHandle?jo(e.response.userHandle):void 0}})}function ko(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function jo(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var _o,So=(_o=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const r=await yo(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await bo(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await yo(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await bo(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const r=await yo(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:yo,get:bo,isSupported:mo,conditional:wo}}),(...e)=>{const t=_o(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Uo=e=>({async oneTap(t,n,o,r){const i=null!=t?t:"google",a=await e.oauth.startNative(i,o);if(!a.ok)return a;const{clientId:s,stateId:c,nonce:u}=a.data,l=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,a;l.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:s,callback:n=>{t(e.oauth.finishNative(i,c,"","",n.credential))},nonce:u})),l.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==r||r())}))}))}});var Po=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await mo(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const Ro=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=c(n,["fpKey","fpLoad"]);return Jn?(o&&r&&Wn(o).catch((()=>null)),t(e(i,{beforeRequest:eo}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(i))}),(n=>o=>{var{autoRefresh:r}=o,i=c(o,["autoRefresh"]);if(!r)return n(i);const{clearAllTimers:a,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let u,l;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>u&&(Dn("Expiration time passed, refreshing session"),d.refresh(l))}));const d=n(e(i,{afterRequest:async(e,n)=>{const{refreshJwt:o,sessionJwt:r}=await t(n);if(401===(null==n?void 0:n.status))Dn("Received 401, canceling all timers"),a();else if(r){u=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(r),l=o;let e=((i=u)?i.getTime()-(new Date).getTime():0)-2e4;e>Kn&&(Dn(`Timeout is too large (${e}ms), setting it to ${Kn}ms`),e=Kn),a();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Dn(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Dn("Refreshing session due to timer"),d.refresh(o)}),e)}var i}}));return $n(d,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Dn("Clearing all timers"),a(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.5"},t.baseHeaders)}))),(o=>r=>{const i=so(),a=so(),s=o(e(r,{afterRequest:async(e,o)=>{if(401===(null==o?void 0:o.status))i.pub(null),a.pub(null);else{const e=await n(o);e&&a.pub(e);const{sessionJwt:r}=await t(o);r&&i.pub(r)}}})),c=$n(s,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return i.pub(null),a.pub(null),n}));return Object.assign(c,{onSessionTokenChange:i.sub,onUserChange:a.sub})}),(t=>o=>{const i=t(e(o,{afterRequest:async(e,t)=>{var o;const i=await n(t),a=null===(o=null==i?void 0:i.loginIds)||void 0===o?void 0:o[0],s=null==i?void 0:i.name;a&&((e=>{r(to,e)})(a),(e=>{r(no,e)})(s))}}));let a=$n(i,["flow.start"],io);return a=$n(a,["logout","logoutAll"],ao),Object.assign(a,{getLastUserLoginId:oo,getLastUserDisplayName:ro})}),(n=>o=>{var{persistTokens:a,sessionTokenViaCookie:s,storagePrefix:u}=o,l=c(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!a||!Jn)return a&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),n(l);const d=n(e(l,{beforeRequest:(p=u,e=>Object.assign(e,{token:e.token||go(p)})),afterRequest:async(e,n)=>{401===(null==n?void 0:n.status)?ho(u):((e={},t,n)=>{var{refreshJwt:o,sessionJwt:i}=e,a=c(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===n&&(n=""),o&&r(`${n}${po}`,o),i&&(t?fo(lo,i,a):r(`${n}${lo}`,i))})(await t(n),s,u)}}));var p;const f=$n(d,["logout","logoutAll"],vo(u));return Object.assign(f,{getRefreshToken:()=>go(u),getSessionToken:()=>function(e=""){return uo.get(lo)||i(`${e}${lo}`)||""}(u)})}))(((...e)=>{const t=qn(...e);return Object.assign(Object.assign({},t),{flow:Po(t),webauthn:So(t),fedcm:Uo(t)})}));return Ro.REFRESH_TOKEN_KEY=po,Ro.SESSION_TOKEN_KEY=lo,Ro})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@descope/web-js-sdk", | ||
"version": "1.10.4", | ||
"version": "1.10.5", | ||
"author": "Descope Team <info@descope.com>", | ||
@@ -45,3 +45,3 @@ "homepage": "https://github.com/descope/web-js-sdk", | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "20.11.17", | ||
"@types/node": "20.11.19", | ||
"@types/js-cookie": "^3.0.2", | ||
@@ -48,0 +48,0 @@ "@types/lodash.get": "^4.4.7", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
450745
2144