Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@descope/web-js-sdk

Package Overview
Dependencies
Maintainers
4
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@descope/web-js-sdk - npm Package Compare versions

Comparing version 0.1.0-alpha.8 to 0.1.0-alpha.9

2

dist/cjs/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";var e=require("tslib"),t=require("@descope/core-js-sdk"),s=require("@fingerprintjs/fingerprintjs-pro"),n=require("js-cookie");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(t),r=a(n);const o=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],c=e=>{const t=s.load({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=o("vsid")),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",e);const s=await t,n=await s.get({linkedId:e});sessionStorage.setItem("vrid",n.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var l,u,d,g,p;const f=e=>Object.assign({},e);class h{constructor(t){l.add(this),u.set(this,void 0),d.set(this,{}),g.set(this,0),e.__classPrivateFieldSet(this,u,t,"f")}get current(){return f(e.__classPrivateFieldGet(this,u,"f"))}update(t){const s=t;if(!((e,t)=>{const s=e&&Object.getOwnPropertyNames(e)||[],n=t&&Object.getOwnPropertyNames(t)||[];if(s.length!==n.length)return!1;for(let n=0;n<s.length;n+=1){const a=s[n];if(e[a]!==t[a])return!1}return!0})(e.__classPrivateFieldGet(this,u,"f"),s)){const t=e.__classPrivateFieldGet(this,u,"f");e.__classPrivateFieldSet(this,u,s,"f"),Object.freeze(e.__classPrivateFieldGet(this,u,"f")),setTimeout((()=>{Object.values(e.__classPrivateFieldGet(this,d,"f")).forEach((e=>e(f(s),t)))}),0)}}subscribe(t){e.__classPrivateFieldSet(this,g,e.__classPrivateFieldGet(this,g,"f")+1,"f"),e.__classPrivateFieldGet(this,d,"f")[e.__classPrivateFieldGet(this,g,"f")]=t;const s=e.__classPrivateFieldGet(this,g,"f");return()=>e.__classPrivateFieldGet(this,l,"m",p).call(this,s.toString())}unsubscribeAll(){e.__classPrivateFieldSet(this,d,{},"f")}}u=new WeakMap,d=new WeakMap,g=new WeakMap,l=new WeakSet,p=function(t){!!e.__classPrivateFieldGet(this,d,"f")[t]&&delete e.__classPrivateFieldGet(this,d,"f")[t]};let w=[];function v(e,t,s){const n=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(n){let t;for(;t=w.pop();)clearTimeout(t);const a=n.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(s)}),a);w.push(i)}}function b(e,t,s){!function(e,{cookiePath:t,cookieDomain:s,cookieExpiration:n}){e&&r.default.set("DS",e,{path:t,domain:s,expires:n,sameSite:"None",secure:!0})}(e,s),function(e){localStorage&&e&&localStorage.setItem("DSR",e)}(t)}function S(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function _(e){const t=function(e){var t;const s=JSON.parse(e);return s.publicKey.challenge=O(s.publicKey.challenge),s.publicKey.user.id=O(s.publicKey.user.id),null===(t=s.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=O(e.id)})),s}(e),s=await navigator.credentials.create(t);return n=s,JSON.stringify(Object.assign(Object.assign({},n),{rawId:m(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:m(n.response.attestationObject),clientDataJSON:m(n.response.clientDataJSON)})}));var n}async function y(e){const t=function(e){var t;const s=JSON.parse(e);return s.publicKey.challenge=O(s.publicKey.challenge),null===(t=s.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=O(e.id)})),s}(e),s=await navigator.credentials.get(t);return n=s,JSON.stringify(Object.assign(Object.assign({},n),{rawId:m(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:m(n.response.authenticatorData),clientDataJSON:m(n.response.clientDataJSON),signature:m(n.response.signature),userHandle:n.response.userHandle?m(n.response.userHandle):void 0})}));var n}function O(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function m(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const k="undefined"!=typeof window;module.exports=t=>{var{autoRefresh:s=!0,persistTokens:n=!0}=t,a=e.__rest(t,["autoRefresh","persistTokens"]);k?c(a.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const o=a;let l,u;const d=new h({sessionToken:""}),g=new h({});o.hooks={beforeRequest:e=>null==l?void 0:l(e),afterRequest:(e,t)=>null==u?void 0:u(e,t)};const p=i.default(o),f=Object.assign(Object.assign({},p),{webauthn:(w=p,{async signUp(e,t){const s=await w.webauthn.signUp.start(e,window.location.origin,t),n=await _(s.data.options);return await w.webauthn.signUp.finish(s.data.transactionId,n)},async signIn(e){const t=await w.webauthn.signIn.start(e,window.location.origin),s=await y(t.data.options);return await w.webauthn.signIn.finish(t.data.transactionId,s)},async signUpOrIn(e){var t;const s=await w.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=s.data)||void 0===t?void 0:t.create){const e=await _(s.data.options);return await w.webauthn.signUp.finish(s.data.transactionId,e)}{const e=await y(s.data.options);return await w.webauthn.signIn.finish(s.data.transactionId,e)}},async update(e,t){const s=await w.webauthn.update.start(e,window.location.origin,t),n=await _(s.data.options);return await w.webauthn.update.finish(s.data.transactionId,n)},helpers:{create:_,get:y}}),onSessionTokenChange:e=>{var t;const s=null===(t=d.current)||void 0===t?void 0:t.sessionToken;return s&&e(s),d.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=g.current;return t&&Object.entries(t).length>0&&e(t),g.subscribe((t=>{e(t)}))}});var w;return s&&["logout","logoutAll"].forEach((e=>{const t=p[e];f[e]=(...e)=>{const s=S(),n=[(null==e?void 0:e.shift())||s,...e],a=t(...n);return localStorage&&localStorage.removeItem("DSR"),r.default.remove("DS"),d.update({sessionToken:""}),a}})),l=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!e.token&&n&&(e.token=S()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.8"}),e},f.me=async(...e)=>{var t;const s=await p.me(...e);if(s.ok){const e=await(null===(t=s.response)||void 0===t?void 0:t.clone().json());g.update(e)}return s},(s||n)&&(u=(t,a)=>{!async function(t,s,n,a){try{if(401===s.status)return n.sessionToken.update({sessionToken:""}),void n.user.update({});const i=await(null==s?void 0:s.json());if(i){const s=function(e){return(null==e?void 0:e.authInfo)||e||{}}(i),{sessionJwt:r,refreshJwt:o,user:c}=s,l=e.__rest(s,["sessionJwt","refreshJwt","user"]);a.persistTokens&&b(r,o,l),r&&n.sessionToken.update({sessionToken:r}),c&&n.user.update(c),r&&o&&a.autoRefresh&&v(t,r,o)}}catch(e){console.error("Could not set tokens from body",e)}}(f.refresh,a,{sessionToken:d,user:g},{autoRefresh:s,persistTokens:n})}),s&&S()&&f.refresh(),f};
"use strict";var e=require("tslib"),t=require("@descope/core-js-sdk"),n=require("@fingerprintjs/fingerprintjs-pro"),s=require("js-cookie");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(t),r=a(s);const o="undefined"!=typeof window,c=o&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",l=o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",u=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],d=e=>{const t=n.load({apiKey:e||c,endpoint:l});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=u("vsid")),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",e);const n=await t,s=await n.get({linkedId:e});sessionStorage.setItem("vrid",s.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var g,p,f,h,w;const v=e=>Object.assign({},e);class b{constructor(t){g.add(this),p.set(this,void 0),f.set(this,{}),h.set(this,0),e.__classPrivateFieldSet(this,p,t,"f")}get current(){return v(e.__classPrivateFieldGet(this,p,"f"))}update(t){const n=t;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],s=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==s.length)return!1;for(let s=0;s<n.length;s+=1){const a=n[s];if(e[a]!==t[a])return!1}return!0})(e.__classPrivateFieldGet(this,p,"f"),n)){const t=e.__classPrivateFieldGet(this,p,"f");e.__classPrivateFieldSet(this,p,n,"f"),Object.freeze(e.__classPrivateFieldGet(this,p,"f")),setTimeout((()=>{Object.values(e.__classPrivateFieldGet(this,f,"f")).forEach((e=>e(v(n),t)))}),0)}}subscribe(t){e.__classPrivateFieldSet(this,h,e.__classPrivateFieldGet(this,h,"f")+1,"f"),e.__classPrivateFieldGet(this,f,"f")[e.__classPrivateFieldGet(this,h,"f")]=t;const n=e.__classPrivateFieldGet(this,h,"f");return()=>e.__classPrivateFieldGet(this,g,"m",w).call(this,n.toString())}unsubscribeAll(){e.__classPrivateFieldSet(this,f,{},"f")}}p=new WeakMap,f=new WeakMap,h=new WeakMap,g=new WeakSet,w=function(t){!!e.__classPrivateFieldGet(this,f,"f")[t]&&delete e.__classPrivateFieldGet(this,f,"f")[t]};let S=[];function y(e,t,n){const s=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(s){let t;for(;t=S.pop();)clearTimeout(t);const a=s.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(n)}),a);S.push(i)}}function _(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:s}){e&&r.default.set("DS",e,{path:t,domain:n,expires:s,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem("DSR",e)}(t)}function m(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function k(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=I(n.publicKey.challenge),n.publicKey.user.id=I(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=I(e.id)})),n}(e),n=await navigator.credentials.create(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:P(s.rawId),response:Object.assign(Object.assign({},s.response),{attestationObject:P(s.response.attestationObject),clientDataJSON:P(s.response.clientDataJSON)})}));var s}async function O(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=I(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=I(e.id)})),n}(e),n=await navigator.credentials.get(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:P(s.rawId),response:Object.assign(Object.assign({},s.response),{authenticatorData:P(s.response.authenticatorData),clientDataJSON:P(s.response.clientDataJSON),signature:P(s.response.signature),userHandle:s.response.userHandle?P(s.response.userHandle):void 0})}));var s}async function j(e=!1){const t=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function I(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function P(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}module.exports=t=>{var{autoRefresh:n=!0,persistTokens:s=!0}=t,a=e.__rest(t,["autoRefresh","persistTokens"]);o?d(a.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const c=a;let l,u;const g=new b({sessionToken:""}),p=new b({});c.hooks={beforeRequest:e=>null==l?void 0:l(e),afterRequest:(e,t)=>null==u?void 0:u(e,t)};const f=i.default(c),h=Object.assign(Object.assign({},f),{webauthn:(w=f,{async signUp(e,t){const n=await w.webauthn.signUp.start(e,window.location.origin,t),s=await k(n.data.options);return await w.webauthn.signUp.finish(n.data.transactionId,s)},async signIn(e){const t=await w.webauthn.signIn.start(e,window.location.origin),n=await O(t.data.options);return await w.webauthn.signIn.finish(t.data.transactionId,n)},async signUpOrIn(e){var t;const n=await w.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=n.data)||void 0===t?void 0:t.create){const e=await k(n.data.options);return await w.webauthn.signUp.finish(n.data.transactionId,e)}{const e=await O(n.data.options);return await w.webauthn.signIn.finish(n.data.transactionId,e)}},async update(e,t){const n=await w.webauthn.update.start(e,window.location.origin,t),s=await k(n.data.options);return await w.webauthn.update.finish(n.data.transactionId,s)},helpers:{create:k,get:O,isSupported:j}}),onSessionTokenChange:e=>{var t;const n=null===(t=g.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),g.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=p.current;return t&&Object.entries(t).length>0&&e(t),p.subscribe((t=>{e(t)}))}});var w;return o?(n&&["logout","logoutAll"].forEach((e=>{const t=f[e];h[e]=(...e)=>{const n=m(),s=[(null==e?void 0:e.shift())||n,...e],a=t(...s);return localStorage&&localStorage.removeItem("DSR"),r.default.remove("DS"),g.update({sessionToken:""}),a}})),l=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!e.token&&s&&(e.token=m()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.9"}),e},h.me=async(...e)=>{var t;const n=await f.me(...e);if(n.ok){const e=await(null===(t=n.response)||void 0===t?void 0:t.clone().json());p.update(e)}return n},(n||s)&&(u=(t,a)=>{!async function(t,n,s,a){try{if(401===n.status)return s.sessionToken.update({sessionToken:""}),void s.user.update({});const i=await(null==n?void 0:n.json());if(i){const n=function(e){return(null==e?void 0:e.authInfo)||e||{}}(i),{sessionJwt:r,refreshJwt:o,user:c}=n,l=e.__rest(n,["sessionJwt","refreshJwt","user"]);a.persistTokens&&_(r,o,l),r&&s.sessionToken.update({sessionToken:r}),c&&s.user.update(c),r&&o&&a.autoRefresh&&y(t,r,o)}}catch(e){console.error("Could not set tokens from body",e)}}(h.refresh,a,{sessionToken:g,user:p},{autoRefresh:n,persistTokens:s})}),n&&m()&&h.refresh(),h):(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"),h)};
//# sourceMappingURL=index.cjs.js.map

@@ -29,2 +29,3 @@ import * as _descope_core_js_sdk from '@descope/core-js-sdk';

get: (options: string) => Promise<string>;
isSupported: (requirePlatformAuthenticator?: boolean) => Promise<boolean>;
};

@@ -116,43 +117,18 @@ };

};
crossDevice: {
verify: (token: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
signIn: {
email: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
sms: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
whatsapp: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
};
signUpOrIn: {
email: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
sms: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
whatsapp: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
};
signUp: {
email: (identifier: string, uri: string, user?: {
email?: string;
name?: string;
phone?: string;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
sms: (identifier: string, uri: string, user?: {
email?: string;
name?: string;
phone?: string;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
whatsapp: (identifier: string, uri: string, user?: {
email?: string;
name?: string;
phone?: string;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
};
waitForSession: (pendingRef: string, config?: {
pollingIntervalMs: number;
timeoutMs: number;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
update: {
email: (identifier: string, email: string, uri: string, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
phone: {
email: (identifier: string, phone: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
sms: (identifier: string, phone: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
whatsapp: (identifier: string, phone: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
};
};
};
enchantedLink: {
verify: (token: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
signIn: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
signUpOrIn: (identifier: string, uri: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
signUp: (identifier: string, uri: string, user?: {
email?: string;
name?: string;
phone?: string;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
waitForSession: (pendingRef: string, config?: {
pollingIntervalMs: number;
timeoutMs: number;
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
update: {
email: (identifier: string, email: string, uri: string, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.PendingRefResponse>>;
};

@@ -210,4 +186,5 @@ };

verify: (identifier: string, code: string, loginOptions?: {
stepup: boolean;
customClaims: Map<string, any>;
stepup?: boolean;
mfa?: boolean;
customClaims?: Map<string, any>;
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;

@@ -220,2 +197,10 @@ update: (identifier: string, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.TOTPResponse>>;

tenant?: string;
deviceInfo?: {
webAuthnSupport?: boolean;
};
lastUser?: {
authMethod?: "otp" | "totp" | "webauthn" | "magiclink" | "social" | "sso";
oauthProvider?: string;
externalId?: string;
};
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;

@@ -222,0 +207,0 @@ next: (executionId: string, stepId: string, interactionId: string, input?: Record<string, FormDataEntryValue>) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;

@@ -1,2 +0,2 @@

import{__classPrivateFieldSet as e,__classPrivateFieldGet as t,__rest as n}from"tslib";import s from"@descope/core-js-sdk";import{load as a}from"@fingerprintjs/fingerprintjs-pro";import o from"js-cookie";const i=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],r=e=>{const t=a({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=i("vsid")),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",e);const n=await t,s=await n.get({linkedId:e});sessionStorage.setItem("vrid",s.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var c,u,l,d,g;const p=e=>Object.assign({},e);class h{constructor(t){c.add(this),u.set(this,void 0),l.set(this,{}),d.set(this,0),e(this,u,t,"f")}get current(){return p(t(this,u,"f"))}update(n){const s=n;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],s=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==s.length)return!1;for(let s=0;s<n.length;s+=1){const a=n[s];if(e[a]!==t[a])return!1}return!0})(t(this,u,"f"),s)){const n=t(this,u,"f");e(this,u,s,"f"),Object.freeze(t(this,u,"f")),setTimeout((()=>{Object.values(t(this,l,"f")).forEach((e=>e(p(s),n)))}),0)}}subscribe(n){e(this,d,t(this,d,"f")+1,"f"),t(this,l,"f")[t(this,d,"f")]=n;const s=t(this,d,"f");return()=>t(this,c,"m",g).call(this,s.toString())}unsubscribeAll(){e(this,l,{},"f")}}u=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakSet,g=function(e){!!t(this,l,"f")[e]&&delete t(this,l,"f")[e]};let f=[];function w(e,t,n){const s=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(s){let t;for(;t=f.pop();)clearTimeout(t);const a=s.getTime()-2e4-(new Date).getTime(),o=setTimeout((()=>{e(n)}),a);f.push(o)}}function b(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:s}){e&&o.set("DS",e,{path:t,domain:n,expires:s,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem("DSR",e)}(t)}function v(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function m(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=y(n.publicKey.challenge),n.publicKey.user.id=y(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=y(e.id)})),n}(e),n=await navigator.credentials.create(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:O(s.rawId),response:Object.assign(Object.assign({},s.response),{attestationObject:O(s.response.attestationObject),clientDataJSON:O(s.response.clientDataJSON)})}));var s}async function S(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=y(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=y(e.id)})),n}(e),n=await navigator.credentials.get(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:O(s.rawId),response:Object.assign(Object.assign({},s.response),{authenticatorData:O(s.response.authenticatorData),clientDataJSON:O(s.response.clientDataJSON),signature:O(s.response.signature),userHandle:s.response.userHandle?O(s.response.userHandle):void 0})}));var s}function y(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function O(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const k="undefined"!=typeof window;var j=e=>{var{autoRefresh:t=!0,persistTokens:a=!0}=e,i=n(e,["autoRefresh","persistTokens"]);k?r(i.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const c=i;let u,l;const d=new h({sessionToken:""}),g=new h({});c.hooks={beforeRequest:e=>null==u?void 0:u(e),afterRequest:(e,t)=>null==l?void 0:l(e,t)};const p=s(c),f=Object.assign(Object.assign({},p),{webauthn:(y=p,{async signUp(e,t){const n=await y.webauthn.signUp.start(e,window.location.origin,t),s=await m(n.data.options);return await y.webauthn.signUp.finish(n.data.transactionId,s)},async signIn(e){const t=await y.webauthn.signIn.start(e,window.location.origin),n=await S(t.data.options);return await y.webauthn.signIn.finish(t.data.transactionId,n)},async signUpOrIn(e){var t;const n=await y.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=n.data)||void 0===t?void 0:t.create){const e=await m(n.data.options);return await y.webauthn.signUp.finish(n.data.transactionId,e)}{const e=await S(n.data.options);return await y.webauthn.signIn.finish(n.data.transactionId,e)}},async update(e,t){const n=await y.webauthn.update.start(e,window.location.origin,t),s=await m(n.data.options);return await y.webauthn.update.finish(n.data.transactionId,s)},helpers:{create:m,get:S}}),onSessionTokenChange:e=>{var t;const n=null===(t=d.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),d.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=g.current;return t&&Object.entries(t).length>0&&e(t),g.subscribe((t=>{e(t)}))}});var y;return t&&["logout","logoutAll"].forEach((e=>{const t=p[e];f[e]=(...e)=>{const n=v(),s=[(null==e?void 0:e.shift())||n,...e],a=t(...s);return localStorage&&localStorage.removeItem("DSR"),o.remove("DS"),d.update({sessionToken:""}),a}})),u=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!e.token&&a&&(e.token=v()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.8"}),e},f.me=async(...e)=>{var t;const n=await p.me(...e);if(n.ok){const e=await(null===(t=n.response)||void 0===t?void 0:t.clone().json());g.update(e)}return n},(t||a)&&(l=(e,s)=>{!async function(e,t,s,a){try{if(401===t.status)return s.sessionToken.update({sessionToken:""}),void s.user.update({});const o=await(null==t?void 0:t.json());if(o){const t=function(e){return(null==e?void 0:e.authInfo)||e||{}}(o),{sessionJwt:i,refreshJwt:r,user:c}=t,u=n(t,["sessionJwt","refreshJwt","user"]);a.persistTokens&&b(i,r,u),i&&s.sessionToken.update({sessionToken:i}),c&&s.user.update(c),i&&r&&a.autoRefresh&&w(e,i,r)}}catch(e){console.error("Could not set tokens from body",e)}}(f.refresh,s,{sessionToken:d,user:g},{autoRefresh:t,persistTokens:a})}),t&&v()&&f.refresh(),f};export{j as default};
import{__classPrivateFieldSet as e,__classPrivateFieldGet as t,__rest as n}from"tslib";import s from"@descope/core-js-sdk";import{load as a}from"@fingerprintjs/fingerprintjs-pro";import i from"js-cookie";const o="undefined"!=typeof window,r=o&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",c=o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",l=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],u=e=>{const t=a({apiKey:e||r,endpoint:c});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=l("vsid")),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",e);const n=await t,s=await n.get({linkedId:e});sessionStorage.setItem("vrid",s.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var d,g,p,f,h;const w=e=>Object.assign({},e);class b{constructor(t){d.add(this),g.set(this,void 0),p.set(this,{}),f.set(this,0),e(this,g,t,"f")}get current(){return w(t(this,g,"f"))}update(n){const s=n;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],s=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==s.length)return!1;for(let s=0;s<n.length;s+=1){const a=n[s];if(e[a]!==t[a])return!1}return!0})(t(this,g,"f"),s)){const n=t(this,g,"f");e(this,g,s,"f"),Object.freeze(t(this,g,"f")),setTimeout((()=>{Object.values(t(this,p,"f")).forEach((e=>e(w(s),n)))}),0)}}subscribe(n){e(this,f,t(this,f,"f")+1,"f"),t(this,p,"f")[t(this,f,"f")]=n;const s=t(this,f,"f");return()=>t(this,d,"m",h).call(this,s.toString())}unsubscribeAll(){e(this,p,{},"f")}}g=new WeakMap,p=new WeakMap,f=new WeakMap,d=new WeakSet,h=function(e){!!t(this,p,"f")[e]&&delete t(this,p,"f")[e]};let v=[];function m(e,t,n){const s=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(s){let t;for(;t=v.pop();)clearTimeout(t);const a=s.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(n)}),a);v.push(i)}}function y(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:s}){e&&i.set("DS",e,{path:t,domain:n,expires:s,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem("DSR",e)}(t)}function S(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function k(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=I(n.publicKey.challenge),n.publicKey.user.id=I(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=I(e.id)})),n}(e),n=await navigator.credentials.create(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:T(s.rawId),response:Object.assign(Object.assign({},s.response),{attestationObject:T(s.response.attestationObject),clientDataJSON:T(s.response.clientDataJSON)})}));var s}async function O(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=I(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=I(e.id)})),n}(e),n=await navigator.credentials.get(t);return s=n,JSON.stringify(Object.assign(Object.assign({},s),{rawId:T(s.rawId),response:Object.assign(Object.assign({},s.response),{authenticatorData:T(s.response.authenticatorData),clientDataJSON:T(s.response.clientDataJSON),signature:T(s.response.signature),userHandle:s.response.userHandle?T(s.response.userHandle):void 0})}));var s}async function j(e=!1){const t=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function I(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function T(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var D=e=>{var{autoRefresh:t=!0,persistTokens:a=!0}=e,r=n(e,["autoRefresh","persistTokens"]);o?u(r.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const c=r;let l,d;const g=new b({sessionToken:""}),p=new b({});c.hooks={beforeRequest:e=>null==l?void 0:l(e),afterRequest:(e,t)=>null==d?void 0:d(e,t)};const f=s(c),h=Object.assign(Object.assign({},f),{webauthn:(w=f,{async signUp(e,t){const n=await w.webauthn.signUp.start(e,window.location.origin,t),s=await k(n.data.options);return await w.webauthn.signUp.finish(n.data.transactionId,s)},async signIn(e){const t=await w.webauthn.signIn.start(e,window.location.origin),n=await O(t.data.options);return await w.webauthn.signIn.finish(t.data.transactionId,n)},async signUpOrIn(e){var t;const n=await w.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=n.data)||void 0===t?void 0:t.create){const e=await k(n.data.options);return await w.webauthn.signUp.finish(n.data.transactionId,e)}{const e=await O(n.data.options);return await w.webauthn.signIn.finish(n.data.transactionId,e)}},async update(e,t){const n=await w.webauthn.update.start(e,window.location.origin,t),s=await k(n.data.options);return await w.webauthn.update.finish(n.data.transactionId,s)},helpers:{create:k,get:O,isSupported:j}}),onSessionTokenChange:e=>{var t;const n=null===(t=g.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),g.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=p.current;return t&&Object.entries(t).length>0&&e(t),p.subscribe((t=>{e(t)}))}});var w;return o?(t&&["logout","logoutAll"].forEach((e=>{const t=f[e];h[e]=(...e)=>{const n=S(),s=[(null==e?void 0:e.shift())||n,...e],a=t(...s);return localStorage&&localStorage.removeItem("DSR"),i.remove("DS"),g.update({sessionToken:""}),a}})),l=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!e.token&&a&&(e.token=S()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.9"}),e},h.me=async(...e)=>{var t;const n=await f.me(...e);if(n.ok){const e=await(null===(t=n.response)||void 0===t?void 0:t.clone().json());p.update(e)}return n},(t||a)&&(d=(e,s)=>{!async function(e,t,s,a){try{if(401===t.status)return s.sessionToken.update({sessionToken:""}),void s.user.update({});const i=await(null==t?void 0:t.json());if(i){const t=function(e){return(null==e?void 0:e.authInfo)||e||{}}(i),{sessionJwt:o,refreshJwt:r,user:c}=t,l=n(t,["sessionJwt","refreshJwt","user"]);a.persistTokens&&y(o,r,l),o&&s.sessionToken.update({sessionToken:o}),c&&s.user.update(c),o&&r&&a.autoRefresh&&m(e,o,r)}}catch(e){console.error("Could not set tokens from body",e)}}(h.refresh,s,{sessionToken:g,user:p},{autoRefresh:t,persistTokens:a})}),t&&S()&&h.refresh(),h):(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"),h)};export{D as default};
//# 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).descopeSdk=t()}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function r(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function o(e){this.message=e}o.prototype=new Error,o.prototype.name="InvalidCharacterError";var a="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new o("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,a=0,i=0,s="";r=t.charAt(i++);~r&&(n=a%4?64*n+r:r,a++%4)?s+=String.fromCharCode(255&n>>(-2*a&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function i(e){this.message=e}function s(e,t){if("string"!=typeof e)throw new i("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(a(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 a(t)}}(e.split(".")[n]))}catch(e){throw new i("Invalid token specified: "+e.message)}}i.prototype=new Error,i.prototype.name="InvalidTokenError";var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u="__lodash_hash_undefined__",l="[object Function]",p="[object GeneratorFunction]",d=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,f=/^\./,g=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,v=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,b="object"==typeof c&&c&&c.Object===Object&&c,w="object"==typeof self&&self&&self.Object===Object&&self,m=b||w||Function("return this")();var O,k=Array.prototype,j=Function.prototype,I=Object.prototype,_=m["__core-js_shared__"],x=(O=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",S=j.toString,P=I.hasOwnProperty,U=I.toString,R=RegExp("^"+S.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=m.Symbol,E=k.splice,C=F(m,"Map"),D=F(Object,"create"),A=T?T.prototype:void 0,q=A?A.toString:void 0;function $(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function J(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function M(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function N(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function K(e,t){var n;t=function(e,t){if(G(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||V(e))return!0;return h.test(e)||!d.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:G(n=t)?n:z(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[H(t[r++])];return r&&r==o?e:void 0}function L(e){if(!Z(e)||(t=e,x&&x in t))return!1;var t,n=function(e){var t=Z(e)?U.call(e):"";return t==l||t==p}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?R:y;return n.test(function(e){if(null!=e){try{return S.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function B(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function F(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return L(n)?n:void 0}$.prototype.clear=function(){this.__data__=D?D(null):{}},$.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},$.prototype.get=function(e){var t=this.__data__;if(D){var n=t[e];return n===u?void 0:n}return P.call(t,e)?t[e]:void 0},$.prototype.has=function(e){var t=this.__data__;return D?void 0!==t[e]:P.call(t,e)},$.prototype.set=function(e,t){return this.__data__[e]=D&&void 0===t?u:t,this},J.prototype.clear=function(){this.__data__=[]},J.prototype.delete=function(e){var t=this.__data__,n=N(t,e);return!(n<0)&&(n==t.length-1?t.pop():E.call(t,n,1),!0)},J.prototype.get=function(e){var t=this.__data__,n=N(t,e);return n<0?void 0:t[n][1]},J.prototype.has=function(e){return N(this.__data__,e)>-1},J.prototype.set=function(e,t){var n=this.__data__,r=N(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},M.prototype.clear=function(){this.__data__={hash:new $,map:new(C||J),string:new $}},M.prototype.delete=function(e){return B(this,e).delete(e)},M.prototype.get=function(e){return B(this,e).get(e)},M.prototype.has=function(e){return B(this,e).has(e)},M.prototype.set=function(e,t){return B(this,e).set(e,t),this};var z=W((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(V(e))return q?q.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return f.test(e)&&n.push(""),e.replace(g,(function(e,t,r,o){n.push(r?o.replace(v,"$1"):t||e)})),n}));function H(e){if("string"==typeof e||V(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function W(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var i=e.apply(this,r);return n.cache=a.set(o,i),i};return n.cache=new(W.Cache||M),n}W.Cache=M;var G=Array.isArray;function Z(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function V(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==U.call(e)}var Q,X=function(e,t,n){var r=null==e?void 0:K(e,t);return void 0===r?n:r},Y="/v1/auth/accesskey/exchange",ee="/v1/auth/otp/verify",te="/v1/auth/otp/signin",ne="/v1/auth/otp/signup",re={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},oe="/v1/auth/otp/signup-in",ae="/v1/auth/magiclink/verify",ie="/v1/auth/magiclink/signin",se="/v1/auth/magiclink/signup",ce="/v1/auth/magiclink/pending-session",ue={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},le="/v1/auth/magiclink/signup-in",pe="/v1/auth/oauth/authorize",de="/v1/auth/oauth/exchange",he="/v1/auth/saml/authorize",fe="/v1/auth/saml/exchange",ge="/v1/auth/totp/verify",ve="/v1/auth/totp/signup",ye="/v1/user/totp/update",be={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},we={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},me={start:"/v1/auth/webauthn/signup-in/start"},Oe={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ke="/v1/flow/start",je="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(Q||(Q={}));const Ie=()=>{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")}},_e=(...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,r])=>(e[n]=r,e)),e),e}),{})),xe=e=>void 0===e?void 0:JSON.stringify(e),Se=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Pe=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:a})=>{const i=((e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>Ie().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),Ie().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r),s=async r=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:p,method:d,token:h}=s,f=await i((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:p}),{headers:_e(Se(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.27"},(null==n?void 0:n.baseHeaders)||{},l),method:d,body:xe(u),credentials:a||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(e,{headers:t,queryParams:n,token:r}={})=>s({path:e,headers:t,queryParams:n,body:void 0,method:Q.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Q.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Q.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Q.delete,token:o})}};function Ue(e,t,n){var r;let o=Re(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const a=o[n];return Array.isArray(a)?a:[]}function Re(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s(e)}function Te(e){const{exp:t}=Re(e);return(new Date).getTime()/1e3>t}function Ee(e,t){return Ue(e,t,"permissions")}function Ce(e,t){return Ue(e,t,"roles")}const De=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ae(e){const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.clone().json();return t.ok?n.data=r:n.error=r,n}const qe=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$e=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Je=e=>t=>e.test(t),Me=Je(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ne=Je(/^\+[1-9]{1}[0-9]{3,14}$/),Ke=qe(Me,'"{val}" is not a valid email'),Le=qe(Ne,'"{val}" is not a valid phone number'),Be=qe((1,e=>e.length>=1),"Minimum length is 1");const Fe=qe((e=>"string"==typeof e),"Input is not a string"),ze=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>$e(...e).validate(n[t]))),t(...n)),He=e=>[Fe(`"${e}" must be a string`),Be(`"${e}" must not be empty`)],We=e=>[Fe(`"${e}" must be a string`),Ke()],Ge=e=>[Fe(`"${e}" must be a string`),Le()],Ze=ze(He("accessKey")),Ve=e=>({exchange:Ze((t=>Ae(e.post(Y,{},{token:t}))))});var Qe,Xe,Ye,et,tt;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Qe||(Qe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Xe||(Xe={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ye||(Ye={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(et||(et={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(tt||(tt={}));const nt=He("identifier"),rt=ze(nt,He("code")),ot=ze(nt),at=ze(nt,Ge("phone")),it=ze(nt,We("email")),st=e=>({verify:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:rt(((t,r)=>Ae(e.post(De(ee,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ot(((t,r,o)=>Ae(e.post(De(te,n),{externalId:t,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ot(((t,r)=>Ae(e.post(De(ne,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ot((t=>Ae(e.post(De(oe,n),{externalId:t}))))})),{}),update:{email:it(((t,n,r)=>Ae(e.post(re.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Qe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:at(((t,r,o)=>Ae(e.post(De(re.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),ct=He("identifier"),ut=He("uri"),lt=ze(He("token")),pt=ze(ct,ut),dt=ze(He("pendingRef")),ht=ze(ct,Ge("phone"),ut),ft=ze(ct,We("email"),ut),gt=e=>({verify:lt((t=>Ae(e.post(ae,{token:t})))),signIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o,a)=>Ae(e.post(De(ie,n),{externalId:t,URI:r,crossDevice:!0,loginOptions:o},{token:a}))))})),{}),signUpOrIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r)=>Ae(e.post(De(le,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o)=>Ae(e.post(De(se,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:dt(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let i;const s=setInterval((async()=>{const n=await e.post(ce,{pendingRef:t});n.ok&&(clearInterval(s),i&&clearTimeout(i),r(Ae(Promise.resolve(n))))}),o);i=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(s)}),a)})))),update:{email:ft(((t,n,r,o)=>Ae(e.post(ue.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Qe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r,o,a)=>Ae(e.post(De(ue.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:a}))))})),{})}}),vt=e=>({verify:lt((t=>Ae(e.post(ae,{token:t})))),signIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o,a)=>Ae(e.post(De(ie,n),{externalId:t,URI:r,loginOptions:o},{token:a}))))})),{}),signUp:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o)=>Ae(e.post(De(se,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r)=>Ae(e.post(De(le,n),{externalId:t,URI:r}))))})),{}),update:{email:ft(((t,n,r,o)=>Ae(e.post(ue.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(Qe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r,o,a)=>Ae(e.post(De(ue.phone,n),{externalId:t,phone:r,URI:o},{token:a}))))})),{})},crossDevice:gt(e)});var yt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(yt||(yt={}));const bt=ze(He("code")),wt=e=>({start:Object.keys(yt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={},o,a)=>{const i=await e.post(pe,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:a});if(!r||!i.ok)return Ae(Promise.resolve(i));const{url:s}=await i.json();window.location.href=s}})),{}),exchange:bt((t=>Ae(e.post(de,{code:t}))))}),mt=ze(He("flowId")),Ot=ze(He("executionId"),He("stepId"),He("interactionId")),kt=e=>({start:mt(((t,n)=>Ae(e.post(ke,{flowId:t,options:n})))),next:Ot(((t,n,r,o)=>Ae(e.post(je,{executionId:t,stepId:n,interactionId:r,input:o}))))}),jt=ze(He("tenant")),It=ze(He("code")),_t=e=>({start:jt((async(t,n,{redirect:r=!1}={},o,a)=>{const i=await e.post(he,o||{},{queryParams:{tenant:t,redirectURL:n},token:a});if(!r||!i.ok)return Ae(Promise.resolve(i));const{url:s}=await i.json();window.location.href=s})),exchange:It((t=>Ae(e.post(fe,{code:t}))))}),xt=He("identifier"),St=ze(xt,He("code")),Pt=ze(xt),Ut=ze(xt),Rt=e=>({signUp:Pt(((t,n)=>Ae(e.post(ve,{externalId:t,user:n})))),verify:St(((t,n,r,o)=>Ae(e.post(ge,{externalId:t,code:n,loginOptions:r},{token:o})))),update:Ut(((t,n)=>Ae(e.post(ye,{externalId:t},{token:n}))))}),Tt=He("identifier"),Et=He("origin"),Ct=ze(Tt,Et,He("name")),Dt=ze(Tt,Et),At=ze(Tt,Et,He("token")),qt=ze(He("transactionId"),He("response")),$t=e=>({signUp:{start:Ct(((t,n,r)=>Ae(e.post(be.start,{user:{externalId:t,name:r},origin:n})))),finish:qt(((t,n)=>Ae(e.post(be.finish,{transactionId:t,response:n}))))},signIn:{start:Dt(((t,n,r,o)=>Ae(e.post(we.start,{externalId:t,origin:n,loginOptions:r},{token:o})))),finish:qt(((t,n)=>Ae(e.post(we.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Dt(((t,n)=>Ae(e.post(me.start,{externalId:t,origin:n}))))},update:{start:At(((t,n,r)=>Ae(e.post(Oe.start,{externalId:t,origin:n},{token:r})))),finish:qt(((t,n)=>Ae(e.post(Oe.finish,{transactionId:t,response:n}))))}}),Jt=ze(He("token"));var Mt;const Nt=ze([("projectId",Mt=He("projectId"),qe(((e,t)=>e=>$e(...t).validate(X(e,"projectId")))(0,Mt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return a=Pe({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:Ve(a),otp:st(a),magicLink:vt(a),oauth:wt(a),saml:_t(a),totp:Rt(a),webauthn:$t(a),flow:kt(a),refresh:e=>Ae(a.post("/v1/auth/refresh",{},{token:e})),logout:e=>Ae(a.post("/v1/auth/logout",{},{token:e})),logoutAll:e=>Ae(a.post("/v1/auth/logoutall",{},{token:e})),me:e=>Ae(a.get("/v1/auth/me",{token:e})),isJwtExpired:Jt(Te),getJwtPermissions:Jt(Ee),getJwtRoles:Jt(Ce),httpClient:a};var a}));Nt.DeliveryMethods=Xe;const Kt="vsid",Lt="vrid";function Bt(e,t,n){return void 0===n&&(n=0),t(n).catch((function(r){if(n>=e.maxRetries||!e.shouldRetry(r))throw r;var o,a,i,s,c=(o=e.baseDelay,a=e.maxDelay,i=e.baseDelay*Math.pow(2,n),Math.max(o,Math.min(a,i)));return(s=c,new Promise((function(e){return setTimeout(e,s)}))).then((function(){return Bt(e,t,n+1)}))}))}var Ft="Failed to load the JS script of the agent";function zt(n){var r,o=n.scriptUrlPattern,a=n.token,i=n.apiKey,s=void 0===i?a:i,c=t(n,["scriptUrlPattern","token","apiKey"]),u=(r=n,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(r,"scriptUrlPattern")?o:void 0),l=[];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");return Bt({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(e){return!(e instanceof Error&&"Blocked by CSP"===e.message)}},(function(){var e,t=new Date,n=function(){return l.push({startedAt:t,finishedAt:new Date})},r=function(e,t,n,r){var o,a=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,c())};a.addEventListener(i,s);var c=function(){return a.removeEventListener(i,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(),o)return function(){throw new Error("Blocked by CSP")}();throw e}))}))}(e=function(e,t){void 0===t&&(t="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.7.1"):t}))}(s,u),(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},a=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Ft))},r.async=!0,r.src=e,a.appendChild(r)}))}(e)}));return r.then(n,n),r}))})).then((function(){var t=window,n="__fpjs_p_l_b",r=t[n];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(t,n),"function"!=typeof(null==r?void 0:r.load))throw new Error(Ft);return r.load(e(e({},c),{ldi:{attempts:l}}))}))}const Ht=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Wt=e=>{const t=zt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Kt);e||(e=Ht(Kt)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Kt,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Lt,r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var Gt,Zt,Vt,Qt,Xt;const Yt=e=>Object.assign({},e);class en{constructor(e){Gt.add(this),Zt.set(this,void 0),Vt.set(this,{}),Qt.set(this,0),r(this,Zt,e,"f")}get current(){return Yt(n(this,Zt,"f"))}update(e){const t=e;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],r=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(e[o]!==t[o])return!1}return!0})(n(this,Zt,"f"),t)){const e=n(this,Zt,"f");r(this,Zt,t,"f"),Object.freeze(n(this,Zt,"f")),setTimeout((()=>{Object.values(n(this,Vt,"f")).forEach((n=>n(Yt(t),e)))}),0)}}subscribe(e){r(this,Qt,n(this,Qt,"f")+1,"f"),n(this,Vt,"f")[n(this,Qt,"f")]=e;const t=n(this,Qt,"f");return()=>n(this,Gt,"m",Xt).call(this,t.toString())}unsubscribeAll(){r(this,Vt,{},"f")}}
!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).descopeSdk=t()}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function r(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function o(e){this.message=e}o.prototype=new Error,o.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new o("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,a=0,s="";r=t.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function a(e){this.message=e}function s(e,t){if("string"!=typeof e)throw new a("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(i(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 i(t)}}(e.split(".")[n]))}catch(e){throw new a("Invalid token specified: "+e.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u="__lodash_hash_undefined__",l="[object Function]",p="[object GeneratorFunction]",d=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,f=/^\w*$/,h=/^\./,g=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,v=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,b="object"==typeof c&&c&&c.Object===Object&&c,w="object"==typeof self&&self&&self.Object===Object&&self,m=b||w||Function("return this")();var k,O=Array.prototype,I=Function.prototype,j=Object.prototype,_=m["__core-js_shared__"],S=(k=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"",x=I.toString,P=j.hasOwnProperty,U=j.toString,T=RegExp("^"+x.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=m.Symbol,R=O.splice,C=F(m,"Map"),A=F(Object,"create"),q=E?E.prototype:void 0,D=q?q.toString:void 0;function $(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function J(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function M(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function K(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function N(e,t){var n;t=function(e,t){if(W(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||Z(e))return!0;return f.test(e)||!d.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:W(n=t)?n:z(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[H(t[r++])];return r&&r==o?e:void 0}function L(e){if(!G(e)||(t=e,S&&S in t))return!1;var t,n=function(e){var t=G(e)?U.call(e):"";return t==l||t==p}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?T:y;return n.test(function(e){if(null!=e){try{return x.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function B(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function F(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return L(n)?n:void 0}$.prototype.clear=function(){this.__data__=A?A(null):{}},$.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},$.prototype.get=function(e){var t=this.__data__;if(A){var n=t[e];return n===u?void 0:n}return P.call(t,e)?t[e]:void 0},$.prototype.has=function(e){var t=this.__data__;return A?void 0!==t[e]:P.call(t,e)},$.prototype.set=function(e,t){return this.__data__[e]=A&&void 0===t?u:t,this},J.prototype.clear=function(){this.__data__=[]},J.prototype.delete=function(e){var t=this.__data__,n=K(t,e);return!(n<0)&&(n==t.length-1?t.pop():R.call(t,n,1),!0)},J.prototype.get=function(e){var t=this.__data__,n=K(t,e);return n<0?void 0:t[n][1]},J.prototype.has=function(e){return K(this.__data__,e)>-1},J.prototype.set=function(e,t){var n=this.__data__,r=K(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},M.prototype.clear=function(){this.__data__={hash:new $,map:new(C||J),string:new $}},M.prototype.delete=function(e){return B(this,e).delete(e)},M.prototype.get=function(e){return B(this,e).get(e)},M.prototype.has=function(e){return B(this,e).has(e)},M.prototype.set=function(e,t){return B(this,e).set(e,t),this};var z=V((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Z(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return h.test(e)&&n.push(""),e.replace(g,(function(e,t,r,o){n.push(r?o.replace(v,"$1"):t||e)})),n}));function H(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function V(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=e.apply(this,r);return n.cache=i.set(o,a),a};return n.cache=new(V.Cache||M),n}V.Cache=M;var W=Array.isArray;function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Z(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==U.call(e)}var Q=function(e,t,n){var r=null==e?void 0:N(e,t);return void 0===r?n:r},X="/v1/auth/accesskey/exchange",Y="/v1/auth/otp/verify",ee="/v1/auth/otp/signin",te="/v1/auth/otp/signup",ne={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},re="/v1/auth/otp/signup-in",oe="/v1/auth/magiclink/verify",ie="/v1/auth/magiclink/signin",ae="/v1/auth/magiclink/signup",se={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ce="/v1/auth/magiclink/signup-in",ue="/v1/auth/enchantedlink/verify",le="/v1/auth/enchantedlink/signin",pe="/v1/auth/enchantedlink/signup",de="/v1/auth/enchantedlink/pending-session",fe={email:"/v1/auth/enchantedlink/update/email"},he="/v1/auth/enchantedlink/signup-in",ge="/v1/auth/oauth/authorize",ve="/v1/auth/oauth/exchange",ye="/v1/auth/saml/authorize",be="/v1/auth/saml/exchange",we="/v1/auth/totp/verify",me="/v1/auth/totp/signup",ke="/v1/user/totp/update",Oe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ie={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},je={start:"/v1/auth/webauthn/signup-in/start"},_e={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Se="/v1/flow/start",xe="/v1/flow/next";const Pe=()=>{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 Ue;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(Ue||(Ue={}));const Te=(...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,r])=>(e[n]=r,e)),e),e}),{})),Ee=e=>void 0===e?void 0:JSON.stringify(e),Re=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ce=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const a=((e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>Pe().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),Pe().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r),s=async r=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:p,method:d,token:f}=s,h=await a((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:p}),{headers:Te(Re(t,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.30"},(null==n?void 0:n.baseHeaders)||{},l),method:d,body:Ee(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:r}={})=>s({path:e,headers:t,queryParams:n,body:void 0,method:Ue.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Ue.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Ue.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:Ue.delete,token:o})}};function Ae(e,t,n){var r;let o=qe(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const i=o[n];return Array.isArray(i)?i:[]}function qe(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s(e)}function De(e){const{exp:t}=qe(e);return(new Date).getTime()/1e3>t}function $e(e,t){return Ae(e,t,"permissions")}function Je(e,t){return Ae(e,t,"roles")}const Me=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ke(e){const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.clone().json();return t.ok?n.data=r:n.error=r,n}const Ne=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Le=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Be=e=>t=>e.test(t),Fe=Be(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ze=Be(/^\+[1-9]{1}[0-9]{3,14}$/),He=Ne(Fe,'"{val}" is not a valid email'),Ve=Ne(ze,'"{val}" is not a valid phone number'),We=Ne((1,e=>e.length>=1),"Minimum length is 1");const Ge=Ne((e=>"string"==typeof e),"Input is not a string"),Ze=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Le(...e).validate(n[t]))),t(...n)),Qe=e=>[Ge(`"${e}" must be a string`),We(`"${e}" must not be empty`)],Xe=e=>[Ge(`"${e}" must be a string`),He()],Ye=e=>[Ge(`"${e}" must be a string`),Ve()],et=Ze(Qe("accessKey")),tt=e=>({exchange:et((t=>Ke(e.post(X,{},{token:t}))))});var nt,rt,ot,it,at;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(nt||(nt={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(rt||(rt={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ot||(ot={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(it||(it={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(at||(at={}));const st=Qe("identifier"),ct=Ze(st,Qe("code")),ut=Ze(st),lt=Ze(st,Ye("phone")),pt=Ze(st,Xe("email")),dt=e=>({verify:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r)=>Ke(e.post(Me(Y,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ut(((t,r,o)=>Ke(e.post(Me(ee,n),{externalId:t,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ut(((t,r)=>Ke(e.post(Me(te,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ut((t=>Ke(e.post(Me(re,n),{externalId:t}))))})),{}),update:{email:pt(((t,n,r)=>Ke(e.post(ne.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(nt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:lt(((t,r,o)=>Ke(e.post(Me(ne.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),ft=Qe("identifier"),ht=Qe("uri"),gt=Ze(Qe("token")),vt=Ze(ft,ht),yt=Ze(ft,Ye("phone"),ht),bt=Ze(ft,Xe("email"),ht),wt=e=>({verify:gt((t=>Ke(e.post(oe,{token:t})))),signIn:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,r,o,i)=>Ke(e.post(Me(ie,n),{externalId:t,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,r,o)=>Ke(e.post(Me(ae,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(rt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,r)=>Ke(e.post(Me(ce,n),{externalId:t,URI:r}))))})),{}),update:{email:bt(((t,n,r,o)=>Ke(e.post(se.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(nt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:yt(((t,r,o,i)=>Ke(e.post(Me(se.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})}}),mt=Qe("identifier"),kt=Qe("uri"),Ot=Ze(Qe("token")),It=Ze(mt,kt),jt=Ze(Qe("pendingRef")),_t=Ze(mt,Xe("email"),kt),St=e=>({verify:Ot((t=>Ke(e.post(ue,{token:t})))),signIn:It(((t,n,r,o)=>Ke(e.post(Me(le,rt.email),{externalId:t,URI:n,loginOptions:r},{token:o})))),signUpOrIn:It(((t,n)=>Ke(e.post(Me(he,rt.email),{externalId:t,URI:n})))),signUp:It(((t,n,r)=>Ke(e.post(Me(pe,rt.email),{externalId:t,URI:n,user:r})))),waitForSession:jt(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let a;const s=setInterval((async()=>{const n=await e.post(de,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(Ke(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:_t(((t,n,r,o)=>Ke(e.post(fe.email,{externalId:t,email:n,URI:r},{token:o}))))}});var xt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(xt||(xt={}));const Pt=Ze(Qe("code")),Ut=e=>({start:Object.keys(xt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={},o,i)=>{const a=await e.post(ge,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!r||!a.ok)return Ke(Promise.resolve(a));const{url:s}=await a.json();window.location.href=s}})),{}),exchange:Pt((t=>Ke(e.post(ve,{code:t}))))}),Tt=Ze(Qe("flowId")),Et=Ze(Qe("executionId"),Qe("stepId"),Qe("interactionId")),Rt=e=>({start:Tt(((t,n)=>Ke(e.post(Se,{flowId:t,options:n})))),next:Et(((t,n,r,o)=>Ke(e.post(xe,{executionId:t,stepId:n,interactionId:r,input:o}))))}),Ct=Ze(Qe("tenant")),At=Ze(Qe("code")),qt=e=>({start:Ct((async(t,n,{redirect:r=!1}={},o,i)=>{const a=await e.post(ye,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!r||!a.ok)return Ke(Promise.resolve(a));const{url:s}=await a.json();window.location.href=s})),exchange:At((t=>Ke(e.post(be,{code:t}))))}),Dt=Qe("identifier"),$t=Ze(Dt,Qe("code")),Jt=Ze(Dt),Mt=Ze(Dt),Kt=e=>({signUp:Jt(((t,n)=>Ke(e.post(me,{externalId:t,user:n})))),verify:$t(((t,n,r,o)=>Ke(e.post(we,{externalId:t,code:n,loginOptions:r},{token:o})))),update:Mt(((t,n)=>Ke(e.post(ke,{externalId:t},{token:n}))))}),Nt=Qe("identifier"),Lt=Qe("origin"),Bt=Ze(Nt,Lt,Qe("name")),Ft=Ze(Nt,Lt),zt=Ze(Nt,Lt,Qe("token")),Ht=Ze(Qe("transactionId"),Qe("response")),Vt=e=>({signUp:{start:Bt(((t,n,r)=>Ke(e.post(Oe.start,{user:{externalId:t,name:r},origin:n})))),finish:Ht(((t,n)=>Ke(e.post(Oe.finish,{transactionId:t,response:n}))))},signIn:{start:Ft(((t,n,r,o)=>Ke(e.post(Ie.start,{externalId:t,origin:n,loginOptions:r},{token:o})))),finish:Ht(((t,n)=>Ke(e.post(Ie.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ft(((t,n)=>Ke(e.post(je.start,{externalId:t,origin:n}))))},update:{start:zt(((t,n,r)=>Ke(e.post(_e.start,{externalId:t,origin:n},{token:r})))),finish:Ht(((t,n)=>Ke(e.post(_e.finish,{transactionId:t,response:n}))))}}),Wt=Ze(Qe("token"));var Gt;const Zt=Ze([("projectId",Gt=Qe("projectId"),Ne(((e,t)=>e=>Le(...t).validate(Q(e,"projectId")))(0,Gt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Ce({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:tt(i),otp:dt(i),magicLink:wt(i),enchantedLink:St(i),oauth:Ut(i),saml:qt(i),totp:Kt(i),webauthn:Vt(i),flow:Rt(i),refresh:e=>Ke(i.post("/v1/auth/refresh",{},{token:e})),logout:e=>Ke(i.post("/v1/auth/logout",{},{token:e})),logoutAll:e=>Ke(i.post("/v1/auth/logoutall",{},{token:e})),me:e=>Ke(i.get("/v1/auth/me",{token:e})),isJwtExpired:Wt(De),getJwtPermissions:Wt($e),getJwtRoles:Wt(Je),httpClient:i};var i}));Zt.DeliveryMethods=rt;const Qt="undefined"!=typeof window,Xt=Qt&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",Yt=Qt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",en="vsid",tn="vrid";function nn(e,t){var n=[];return function(e,t){var n,r,o=(r=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r}(e),{current:function(){return r[0]},postpone:function(){var e=r.shift();void 0!==e&&r.push(e)},exclude:function(){r.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),a=o.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"Blocked by CSP"===t||"9319"===t}(e)?o.postpone():o.exclude();var t,r=o.current();if(void 0===r)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return s(r,n+1)}))}))};return s(a,0)}(e,(function(e){var r=new Date,o=function(){return n.push({url:e,startedAt:r,finishedAt:new Date})},i=t(e);return i.then(o,o),i})).then((function(e){return[e,{attempts:n}]}))}var rn="Failed to load the JS script of the agent";function on(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,a=void 0===i?o:i,s=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return nn(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.1"):e}))}(String(e),t)}))}(c,a),an).catch(cn)})).then((function(t){var n=t[0],r=t[1];return n.load(e(e({},s),{ldi:r}))}))}function an(e){return function(e,t,n,r){var o,i=document,a="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=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(),o)return function(){throw new Error("Blocked by CSP")}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(rn))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)})).then(sn)}function sn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error("9319");return n}function cn(e){throw e instanceof Error&&"9319"===e.message?new Error(rn):e}const un=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],ln=e=>{const t=on({apiKey:e||Xt,endpoint:Yt});return{get:async()=>{try{let e=sessionStorage.getItem(en);e||(e=un(en)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(en,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(tn,r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var pn,dn,fn,hn,gn;const vn=e=>Object.assign({},e);class yn{constructor(e){pn.add(this),dn.set(this,void 0),fn.set(this,{}),hn.set(this,0),r(this,dn,e,"f")}get current(){return vn(n(this,dn,"f"))}update(e){const t=e;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],r=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(e[o]!==t[o])return!1}return!0})(n(this,dn,"f"),t)){const e=n(this,dn,"f");r(this,dn,t,"f"),Object.freeze(n(this,dn,"f")),setTimeout((()=>{Object.values(n(this,fn,"f")).forEach((n=>n(vn(t),e)))}),0)}}subscribe(e){r(this,hn,n(this,hn,"f")+1,"f"),n(this,fn,"f")[n(this,hn,"f")]=e;const t=n(this,hn,"f");return()=>n(this,pn,"m",gn).call(this,t.toString())}unsubscribeAll(){r(this,fn,{},"f")}}
/*! js-cookie v3.0.1 | MIT */
function tn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}Zt=new WeakMap,Vt=new WeakMap,Qt=new WeakMap,Gt=new WeakSet,Xt=function(e){!!n(this,Vt,"f")[e]&&delete n(this,Vt,"f")[e]};var nn=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=tn({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var i in o)o[i]&&(a+="; "+i,!0!==o[i]&&(a+="="+o[i].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+a}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var a=n[o].split("="),i=a.slice(1).join("=");try{var s=decodeURIComponent(a[0]);if(r[s]=t.read(i,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",tn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,tn({},this.attributes,t))},withConverter:function(t){return e(tn({},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 rn="DSR";let on=[];function an(e,t,n){const r=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(r){let t;for(;t=on.pop();)clearTimeout(t);const o=r.getTime()-2e4-(new Date).getTime(),a=setTimeout((()=>{e(n)}),o);on.push(a)}}function sn(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:r}){e&&nn.set("DS",e,{path:t,domain:n,expires:r,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem(rn,e)}(t)}function cn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem(rn):""}async function un(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pn(n.publicKey.challenge),n.publicKey.user.id=pn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=pn(e.id)})),n}(e),n=await navigator.credentials.create(t);return r=n,JSON.stringify(Object.assign(Object.assign({},r),{rawId:dn(r.rawId),response:Object.assign(Object.assign({},r.response),{attestationObject:dn(r.response.attestationObject),clientDataJSON:dn(r.response.clientDataJSON)})}));var r}async function ln(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=pn(e.id)})),n}(e),n=await navigator.credentials.get(t);return r=n,JSON.stringify(Object.assign(Object.assign({},r),{rawId:dn(r.rawId),response:Object.assign(Object.assign({},r.response),{authenticatorData:dn(r.response.authenticatorData),clientDataJSON:dn(r.response.clientDataJSON),signature:dn(r.response.signature),userHandle:r.response.userHandle?dn(r.response.userHandle):void 0})}));var r}function pn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function dn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const hn="undefined"!=typeof window;return e=>{var{autoRefresh:n=!0,persistTokens:r=!0}=e,o=t(e,["autoRefresh","persistTokens"]);hn?Wt(o.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const a=o;let i,s;const c=new en({sessionToken:""}),u=new en({});a.hooks={beforeRequest:e=>null==i?void 0:i(e),afterRequest:(e,t)=>null==s?void 0:s(e,t)};const l=Nt(a),p=Object.assign(Object.assign({},l),{webauthn:(d=l,{async signUp(e,t){const n=await d.webauthn.signUp.start(e,window.location.origin,t),r=await un(n.data.options);return await d.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(e){const t=await d.webauthn.signIn.start(e,window.location.origin),n=await ln(t.data.options);return await d.webauthn.signIn.finish(t.data.transactionId,n)},async signUpOrIn(e){var t;const n=await d.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=n.data)||void 0===t?void 0:t.create){const e=await un(n.data.options);return await d.webauthn.signUp.finish(n.data.transactionId,e)}{const e=await ln(n.data.options);return await d.webauthn.signIn.finish(n.data.transactionId,e)}},async update(e,t){const n=await d.webauthn.update.start(e,window.location.origin,t),r=await un(n.data.options);return await d.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:un,get:ln}}),onSessionTokenChange:e=>{var t;const n=null===(t=c.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),c.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=u.current;return t&&Object.entries(t).length>0&&e(t),u.subscribe((t=>{e(t)}))}});var d;return n&&["logout","logoutAll"].forEach((e=>{const t=l[e];p[e]=(...e)=>{const n=cn(),r=[(null==e?void 0:e.shift())||n,...e],o=t(...r);return localStorage&&localStorage.removeItem(rn),nn.remove("DS"),c.update({sessionToken:""}),o}})),i=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{[Kt]:sessionStorage.getItem(Kt)||"",[Lt]:sessionStorage.getItem(Lt)||""})),!e.token&&r&&(e.token=cn()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.8"}),e},p.me=async(...e)=>{var t;const n=await l.me(...e);if(n.ok){const e=await(null===(t=n.response)||void 0===t?void 0:t.clone().json());u.update(e)}return n},(n||r)&&(s=(e,o)=>{!async function(e,n,r,o){try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const a=await(null==n?void 0:n.json());if(a){const n=function(e){return(null==e?void 0:e.authInfo)||e||{}}(a),{sessionJwt:i,refreshJwt:s,user:c}=n,u=t(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&sn(i,s,u),i&&r.sessionToken.update({sessionToken:i}),c&&r.user.update(c),i&&s&&o.autoRefresh&&an(e,i,s)}}catch(e){console.error("Could not set tokens from body",e)}}(p.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&cn()&&p.refresh(),p}}));
function bn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}dn=new WeakMap,fn=new WeakMap,hn=new WeakMap,pn=new WeakSet,gn=function(e){!!n(this,fn,"f")[e]&&delete n(this,fn,"f")[e]};var wn=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=bn({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in o)o[a]&&(i+="; "+a,!0!==o[a]&&(i+="="+o[a].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",bn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,bn({},this.attributes,t))},withConverter:function(t){return e(bn({},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 mn="DSR";let kn=[];function On(e,t,n){const r=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(r){let t;for(;t=kn.pop();)clearTimeout(t);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(n)}),o);kn.push(i)}}function In(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:r}){e&&wn.set("DS",e,{path:t,domain:n,expires:r,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem(mn,e)}(t)}function jn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem(mn):""}async function _n(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Pn(n.publicKey.challenge),n.publicKey.user.id=Pn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Pn(e.id)})),n}(e),n=await navigator.credentials.create(t);return r=n,JSON.stringify(Object.assign(Object.assign({},r),{rawId:Un(r.rawId),response:Object.assign(Object.assign({},r.response),{attestationObject:Un(r.response.attestationObject),clientDataJSON:Un(r.response.clientDataJSON)})}));var r}async function Sn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Pn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Pn(e.id)})),n}(e),n=await navigator.credentials.get(t);return r=n,JSON.stringify(Object.assign(Object.assign({},r),{rawId:Un(r.rawId),response:Object.assign(Object.assign({},r.response),{authenticatorData:Un(r.response.authenticatorData),clientDataJSON:Un(r.response.clientDataJSON),signature:Un(r.response.signature),userHandle:r.response.userHandle?Un(r.response.userHandle):void 0})}));var r}async function xn(e=!1){const t=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Pn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Un(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}return e=>{var{autoRefresh:n=!0,persistTokens:r=!0}=e,o=t(e,["autoRefresh","persistTokens"]);Qt?ln(o.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const i=o;let a,s;const c=new yn({sessionToken:""}),u=new yn({});i.hooks={beforeRequest:e=>null==a?void 0:a(e),afterRequest:(e,t)=>null==s?void 0:s(e,t)};const l=Zt(i),p=Object.assign(Object.assign({},l),{webauthn:(d=l,{async signUp(e,t){const n=await d.webauthn.signUp.start(e,window.location.origin,t),r=await _n(n.data.options);return await d.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(e){const t=await d.webauthn.signIn.start(e,window.location.origin),n=await Sn(t.data.options);return await d.webauthn.signIn.finish(t.data.transactionId,n)},async signUpOrIn(e){var t;const n=await d.webauthn.signUpOrIn.start(e,window.location.origin);if(null===(t=n.data)||void 0===t?void 0:t.create){const e=await _n(n.data.options);return await d.webauthn.signUp.finish(n.data.transactionId,e)}{const e=await Sn(n.data.options);return await d.webauthn.signIn.finish(n.data.transactionId,e)}},async update(e,t){const n=await d.webauthn.update.start(e,window.location.origin,t),r=await _n(n.data.options);return await d.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:_n,get:Sn,isSupported:xn}}),onSessionTokenChange:e=>{var t;const n=null===(t=c.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),c.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=u.current;return t&&Object.entries(t).length>0&&e(t),u.subscribe((t=>{e(t)}))}});var d;return Qt?(n&&["logout","logoutAll"].forEach((e=>{const t=l[e];p[e]=(...e)=>{const n=jn(),r=[(null==e?void 0:e.shift())||n,...e],o=t(...r);return localStorage&&localStorage.removeItem(mn),wn.remove("DS"),c.update({sessionToken:""}),o}})),a=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{[en]:sessionStorage.getItem(en)||"",[tn]:sessionStorage.getItem(tn)||""})),!e.token&&r&&(e.token=jn()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.9"}),e},p.me=async(...e)=>{var t;const n=await l.me(...e);if(n.ok){const e=await(null===(t=n.response)||void 0===t?void 0:t.clone().json());u.update(e)}return n},(n||r)&&(s=(e,o)=>{!async function(e,n,r,o){try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const i=await(null==n?void 0:n.json());if(i){const n=function(e){return(null==e?void 0:e.authInfo)||e||{}}(i),{sessionJwt:a,refreshJwt:s,user:c}=n,u=t(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&In(a,s,u),a&&r.sessionToken.update({sessionToken:a}),c&&r.user.update(c),a&&s&&o.autoRefresh&&On(e,a,s)}}catch(e){console.error("Could not set tokens from body",e)}}(p.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&jn()&&p.refresh(),p):(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"),p)}}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@descope/web-js-sdk",
"version": "0.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"main": "dist/cjs/index.cjs.js",

@@ -44,3 +44,3 @@ "module": "dist/index.esm.js",

"@open-wc/rollup-plugin-html": "1.2.5",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-commonjs": "^23.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",

@@ -60,5 +60,5 @@ "@rollup/plugin-replace": "^4.0.0",

"eslint-plugin-jest": "26.9.0",
"eslint-plugin-jest-dom": "4.0.2",
"eslint-plugin-jest-dom": "4.0.3",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-n": "15.3.0",
"eslint-plugin-n": "15.5.1",
"eslint-plugin-no-only-tests": "3.1.0",

@@ -90,4 +90,4 @@ "eslint-plugin-prefer-arrow": "1.2.3",

"dependencies": {
"@descope/core-js-sdk": "0.0.41-alpha.27",
"@fingerprintjs/fingerprintjs-pro": "3.7.1",
"@descope/core-js-sdk": "0.0.41-alpha.30",
"@fingerprintjs/fingerprintjs-pro": "3.8.1",
"js-cookie": "3.0.1"

@@ -94,0 +94,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc