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.0.1-alpha.2 to 0.0.1-alpha.3

2

dist/cjs/index.cjs.js

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

"use strict";var e=require("@descope/core-js-sdk"),t=require("@fingerprintjs/fingerprintjs-pro"),r=require("ksuid");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(e),o=s(r);const i=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e];module.exports=e=>{(e=>{const r=t.load({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=i("vsid")),e||(e=(await o.default.random()).string),sessionStorage.setItem("vsid",e);const t=await r,s=await t.get({linkedId:e});sessionStorage.setItem("vrid",s.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}})(e.fpKey).get().catch((()=>null));return e.hooks={beforeRequest:e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),e}},a.default(e)};
"use strict";var e=require("@descope/core-js-sdk"),t=require("@fingerprintjs/fingerprintjs-pro"),o=require("js-cookie");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=s(e),a=s(o);const n=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],i=e=>{const o=t.load({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=n("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 t=await o,s=await t.get({linkedId:e});sessionStorage.setItem("vrid",s.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};const c=async e=>{try{const t=await(null==e?void 0:e.json());!function(e){const{sessionJwt:t,refreshJwt:o,cookieDomain:s,cookiePath:r,cookieExpiration:n}=e||{};t&&a.default.set("DS",t,{path:r,domain:s,expires:n,secure:!0}),o&&localStorage.setItem("DSR",o)}((null==t?void 0:t.authInfo)||t)}catch(e){console.error("Could not set tokens from body")}};module.exports=e=>{i(e.fpKey).get().catch((()=>null));const t=e;return t.hooks={beforeRequest:t=>{var o;return t.queryParams=(o=t.queryParams,Object.assign(Object.assign({},o),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),e.disableTokensStorage||t.token||(t.token=localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""),t}},e.disableTokensStorage||(t.hooks.afterRequest=async(e,t)=>{c(t)}),r.default(e)};
//# sourceMappingURL=index.cjs.js.map

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

fpKey?: string;
disableTokensStorage?: boolean;
};

@@ -192,3 +193,3 @@ declare const _default: (args: WebJSSDKArgs) => {

};
add: {
update: {
start: (identifier: string, origin: string, token: string) => Promise<_descope_core_js_sdk.SdkResponse>;

@@ -200,3 +201,3 @@ finish: (transactionId: string, response: string) => Promise<_descope_core_js_sdk.SdkResponse>;

start: (flowId: string) => Promise<_descope_core_js_sdk.SdkResponse>;
next: (executionId: string, stepId: string, actionId: string, input?: Record<string, FormDataEntryValue>) => Promise<_descope_core_js_sdk.SdkResponse>;
next: (executionId: string, stepId: string, interactionId: string, input?: Record<string, FormDataEntryValue>) => Promise<_descope_core_js_sdk.SdkResponse>;
};

@@ -203,0 +204,0 @@ refresh: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse>;

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

import e from"@descope/core-js-sdk";import{load as t}from"@fingerprintjs/fingerprintjs-pro";import r from"ksuid";const s=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e];var o=o=>{(e=>{const o=t({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=s("vsid")),e||(e=(await r.random()).string),sessionStorage.setItem("vsid",e);const t=await o,a=await t.get({linkedId:e});sessionStorage.setItem("vrid",a.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}})(o.fpKey).get().catch((()=>null));return o.hooks={beforeRequest:e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),e}},e(o)};export{o as default};
import e from"@descope/core-js-sdk";import{load as o}from"@fingerprintjs/fingerprintjs-pro";import t from"js-cookie";const s=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,o)=>e.get(o.toString())})[e],r=e=>{const t=o({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=s("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 o=await t,r=await o.get({linkedId:e});sessionStorage.setItem("vrid",r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};const a=async e=>{try{const o=await(null==e?void 0:e.json());!function(e){const{sessionJwt:o,refreshJwt:s,cookieDomain:r,cookiePath:a,cookieExpiration:n}=e||{};o&&t.set("DS",o,{path:a,domain:r,expires:n,secure:!0}),s&&localStorage.setItem("DSR",s)}((null==o?void 0:o.authInfo)||o)}catch(e){console.error("Could not set tokens from body")}};var n=o=>{r(o.fpKey).get().catch((()=>null));const t=o;return t.hooks={beforeRequest:e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),o.disableTokensStorage||e.token||(e.token=localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""),e}},o.disableTokensStorage||(t.hooks.afterRequest=async(e,o)=>{a(o)}),e(o)};export{n as default};
//# sourceMappingURL=index.esm.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("crypto"),require("util")):"function"==typeof define&&define.amd?define(["crypto","util"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t(e.require$$0,e.require$$1)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),o=r(t);function a(e){this.message=e}a.prototype=new Error,a.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 a("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,s="";n=t.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?s+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};function s(e){this.message=e}function c(e,t){if("string"!=typeof e)throw new s("Invalid token specified");var r=!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 r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return i(t)}}(e.split(".")[r]))}catch(e){throw new s("Invalid token specified: "+e.message)}}s.prototype=new Error,s.prototype.name="InvalidTokenError";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l="__lodash_hash_undefined__",d="[object Function]",p="[object GeneratorFunction]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,g=/^\./,y=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,v=/\\(\\)?/g,m=/^\[object .+?Constructor\]$/,b="object"==typeof u&&u&&u.Object===Object&&u,w="object"==typeof self&&self&&self.Object===Object&&self,I=b||w||Function("return this")();var O,j=Array.prototype,k=Function.prototype,_=Object.prototype,P=I["__core-js_shared__"],S=(O=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",x=k.toString,U=_.hasOwnProperty,E=_.toString,R=RegExp("^"+x.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D=I.Symbol,$=j.splice,T=z(I,"Map"),q=z(Object,"create"),M=D?D.prototype:void 0,B=M?M.toString:void 0;function C(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function A(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function L(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function N(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function K(e,t){var r;t=function(e,t){if(Z(e))return!1;var r=typeof e;if("number"==r||"symbol"==r||"boolean"==r||null==e||Q(e))return!0;return h.test(e)||!f.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Z(r=t)?r:J(r);for(var n=0,o=t.length;null!=e&&n<o;)e=e[G(t[n++])];return n&&n==o?e:void 0}function F(e){if(!W(e)||(t=e,S&&S in t))return!1;var t,r=function(e){var t=W(e)?E.call(e):"";return t==d||t==p}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?R:m;return r.test(function(e){if(null!=e){try{return x.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function V(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function z(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return F(r)?r:void 0}C.prototype.clear=function(){this.__data__=q?q(null):{}},C.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},C.prototype.get=function(e){var t=this.__data__;if(q){var r=t[e];return r===l?void 0:r}return U.call(t,e)?t[e]:void 0},C.prototype.has=function(e){var t=this.__data__;return q?void 0!==t[e]:U.call(t,e)},C.prototype.set=function(e,t){return this.__data__[e]=q&&void 0===t?l:t,this},A.prototype.clear=function(){this.__data__=[]},A.prototype.delete=function(e){var t=this.__data__,r=N(t,e);return!(r<0)&&(r==t.length-1?t.pop():$.call(t,r,1),!0)},A.prototype.get=function(e){var t=this.__data__,r=N(t,e);return r<0?void 0:t[r][1]},A.prototype.has=function(e){return N(this.__data__,e)>-1},A.prototype.set=function(e,t){var r=this.__data__,n=N(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},L.prototype.clear=function(){this.__data__={hash:new C,map:new(T||A),string:new C}},L.prototype.delete=function(e){return V(this,e).delete(e)},L.prototype.get=function(e){return V(this,e).get(e)},L.prototype.has=function(e){return V(this,e).has(e)},L.prototype.set=function(e,t){return V(this,e).set(e,t),this};var J=H((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Q(e))return B?B.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var r=[];return g.test(e)&&r.push(""),e.replace(y,(function(e,t,n,o){r.push(n?o.replace(v,"$1"):t||e)})),r}));function G(e){if("string"==typeof e||Q(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function H(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=e.apply(this,n);return r.cache=a.set(o,i),i};return r.cache=new(H.Cache||L),r}H.Cache=L;var Z=Array.isArray;function W(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Q(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==E.call(e)}var X,Y=function(e,t,r){var n=null==e?void 0:K(e,t);return void 0===n?r:n},ee="/v1/auth/code/verify",te="/v1/auth/signin/otp",re="/v1/auth/signup/otp",ne={email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},oe="/v1/auth/sign-up-or-in/otp",ae="/v1/auth/magiclink/verify",ie="/v1/auth/signin/magiclink",se="/v1/auth/signup/magiclink",ce="/v1/auth/magiclink/session",ue={email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},le="/v1/auth/sign-up-or-in/magiclink",de="/v1/oauth/authorize",pe="/v1/auth/saml/authorize",fe="/v1/auth/verify/totp",he="/v1/auth/signup/totp",ge="/v1/user/update/totp",ye={start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},ve={start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},me={start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"},be="/v1/flow/start",we="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(X||(X={}));const Ie=()=>{const e={};return{headers(t){const r="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(r),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")}},Oe=(...e)=>new Headers(e.reduce(((e,t)=>{const r=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return r.reduce(((t,[r,n])=>(e[r]=n,e)),e),e}),{})),je=e=>void 0===e?void 0:JSON.stringify(e),ke=(e,t="")=>{let r=e;return""!==t&&(r=r+":"+t),{Authorization:`Bearer ${r}`}},_e=({baseUrl:e,projectId:t,baseConfig:r,logger:n,hooks:o})=>{const a=((e,t)=>{const r=t||fetch;if(!r)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 n=await r(...t);return e[n.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()})(n)),n}:r})(n),i=n=>{const i=(null==o?void 0:o.beforeRequest)?o.beforeRequest(n):n,{path:s,body:c,headers:u,queryParams:l,method:d,token:p}=i;return a((({path:e,baseUrl:t,queryParams:r})=>{const n=new URL(e,t);return r&&(n.search=new URLSearchParams(r).toString()),n})({path:s,baseUrl:e,queryParams:l}),{headers:Oe(ke(t,p),(null==r?void 0:r.baseHeaders)||{},u),method:d,body:je(c)})};return{get:(e,{headers:t,queryParams:r,token:n}={})=>i({path:e,headers:t,queryParams:r,body:void 0,method:X.get,token:n}),post:(e,t,{headers:r,queryParams:n,token:o}={})=>i({path:e,headers:r,queryParams:n,body:t,method:X.post,token:o}),put:(e,t,{headers:r,queryParams:n,token:o}={})=>i({path:e,headers:r,queryParams:n,body:t,method:X.put,token:o}),delete:(e,t,{headers:r,queryParams:n,token:o}={})=>i({path:e,headers:r,queryParams:n,body:t,method:X.delete,token:o})}},Pe=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=c(e);return(new Date).getTime()/1e3>t},Se=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),xe=async e=>{const t=await e,r={code:t.status,ok:t.ok,response:t},n=await t.json();return t.ok?r.data=n:r.error=n,r};var Ue,Ee,Re;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Ue||(Ue={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Ee||(Ee={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Re||(Re={}));const De=(e,t)=>(r=t)=>t=>!e(t)&&r.replace("{val}",t),$e=(...e)=>({validate:t=>(e.forEach((e=>{const r=e(t);if(r)throw new Error(r)})),!0)}),Te=e=>t=>e.test(t),qe=Te(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Me=Te(/^\+[1-9]{1}[0-9]{3,14}$/),Be=De(qe,'"{val}" is not a valid email'),Ce=De(Me,'"{val}" is not a valid phone number'),Ae=De((1,e=>e.length>=1),"Minimum length is 1");const Le=De((e=>"string"==typeof e),"Input is not a string"),Ne=(...e)=>t=>(...r)=>(e.forEach(((e,t)=>$e(...e).validate(r[t]))),t(...r)),Ke=e=>[Le(`"${e}" must be a string`),Ae(`"${e}" must not be empty`)],Fe=e=>[Le(`"${e}" must be a string`),Be()],Ve=e=>[Le(`"${e}" must be a string`),Ce()];var ze;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ze||(ze={}));const Je=Ke("identifier"),Ge=Ne(Je,Ke("code")),He=Ne(Je),Ze=Ne(Je,Ve("phone")),We=Ne(Je,Fe("email")),Qe=e=>({verify:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Ge(((t,n)=>xe(e.post(Se(ee,r),{code:n,externalId:t}))))})),{}),signIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:He((t=>xe(e.post(Se(te,r),{externalId:t}))))})),{}),signUp:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:He(((t,n)=>xe(e.post(Se(re,r),{externalId:t,user:n}))))})),{}),signUpOrIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:He((t=>xe(e.post(Se(oe,r),{externalId:t}))))})),{}),update:{email:We(((t,r,n)=>xe(e.post(ne.email,{externalId:t,email:r},{token:n})))),phone:Object.keys(Ue).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Ze(((t,n,o)=>xe(e.post(Se(ne.phone,r),{externalId:t,phone:n},{token:o}))))})),{})}}),Xe=Ke("identifier"),Ye=Ke("uri"),et=Ne(Ke("token")),tt=Ne(Xe,Ye),rt=Ne(Ke("pendingRef")),nt=Ne(Xe,Ve("phone"),Ye),ot=Ne(Xe,Fe("email"),Ye),at=e=>({verify:et((t=>xe(e.post(ae,{token:t})))),signIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n)=>xe(e.post(Se(ie,r),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n)=>xe(e.post(Se(le,r),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n,o)=>xe(e.post(Se(se,r),{externalId:t,URI:n,user:o,crossDevice:!0}))))})),{}),waitForSession:rt(((t,r)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(r);let i;const s=setInterval((async()=>{const r=await e.post(ce,{pendingRef:t});r.ok&&(clearInterval(s),i&&clearTimeout(i),n(xe(Promise.resolve(r))))}),o);i=setTimeout((()=>{n({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(s)}),a)})))),update:{email:ot(((t,r,n,o)=>xe(e.post(ue.email,{externalId:t,email:r,URI:n,crossDevice:!0},{token:o})))),phone:Object.keys(Ue).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:nt(((t,n,o,a)=>xe(e.post(Se(ue.phone,r),{externalId:t,phone:n,URI:o,crossDevice:!0},{token:a}))))})),{})}}),it=e=>({verify:et((t=>xe(e.post(ae,{token:t})))),signIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n)=>xe(e.post(Se(ie,r),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n,o)=>xe(e.post(Se(se,r),{externalId:t,URI:n,user:o}))))})),{}),signUpOrIn:Object.keys(Ee).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:tt(((t,n)=>xe(e.post(Se(le,r),{externalId:t,URI:n}))))})),{}),update:{email:ot(((t,r,n,o)=>xe(e.post(ue.email,{externalId:t,email:r,URI:n},{token:o})))),phone:Object.keys(Ue).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:nt(((t,n,o,a)=>xe(e.post(Se(ue.phone,r),{externalId:t,phone:n,URI:o},{token:a}))))})),{})},crossDevice:at(e)}),st=Ne(Ke("code")),ct=e=>({exchange:st((t=>xe(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var ut;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ut||(ut={}));const lt=e=>Object.assign({start:Object.keys(ut).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:async(t,{redirect:n=!1}={})=>{const o=await e.get(de,{queryParams:Object.assign({provider:r},t&&{redirectURL:t})});if(!n||!o.ok)return xe(Promise.resolve(o));const{url:a}=await o.json();window.location.href=a}})),{})},ct(e)),dt=Ne(Ke("flowId")),pt=Ne(Ke("executionId"),Ke("stepId"),Ke("actionId")),ft=e=>({start:dt((t=>xe(e.post(be,{flowId:t})))),next:pt(((t,r,n,o)=>xe(e.post(we,{executionId:t,stepId:r,actionId:n,input:o}))))}),ht=Ne(Ke("tenant")),gt=e=>Object.assign({start:ht((async(t,r,{redirect:n=!1}={})=>{const o=await e.get(pe,{queryParams:{tenant:t,redirectURL:r}});if(!n||!o.ok)return xe(Promise.resolve(o));const{url:a}=await o.json();window.location.href=a}))},ct(e)),yt=Ke("identifier"),vt=Ne(yt,Ke("code")),mt=Ne(yt),bt=Ne(yt),wt=e=>({signUp:mt(((t,r)=>xe(e.post(he,{externalId:t,user:r})))),verify:vt(((t,r)=>xe(e.post(fe,{externalId:t,code:r})))),update:bt(((t,r)=>xe(e.post(ge,{externalId:t},{token:r}))))}),It=Ke("identifier"),Ot=Ke("origin"),jt=Ne(It,Ot,Ke("name")),kt=Ne(It,Ot),_t=Ne(It,Ot,Ke("token")),Pt=Ne(Ke("transactionId"),Ke("response")),St=e=>({signUp:{start:jt(((t,r,n)=>xe(e.post(ye.start,{user:{externalId:t,name:n},origin:r})))),finish:Pt(((t,r)=>xe(e.post(ye.finish,{transactionId:t,response:r}))))},signIn:{start:kt(((t,r)=>xe(e.post(ve.start,{externalId:t,origin:r})))),finish:Pt(((t,r)=>xe(e.post(ve.finish,{transactionId:t,response:r}))))},add:{start:_t(((t,r,n)=>xe(e.post(me.start,{externalId:t,origin:r},{token:n})))),finish:Pt(((t,r)=>xe(e.post(me.finish,{transactionId:t,response:r}))))}}),xt=Ne(Ke("token"));var Ut;const Et=Ne([("projectId",Ut=Ke("projectId"),De(((e,t)=>e=>$e(...t).validate(Y(e,"projectId")))(0,Ut))())])((({projectId:e,logger:t,baseUrl:r,hooks:n})=>{return o=_e({baseUrl:r||"https://api.descope.com",projectId:e,logger:t,hooks:n}),{otp:Qe(o),magicLink:it(o),oauth:lt(o),saml:gt(o),totp:wt(o),webauthn:St(o),flow:ft(o),refresh:e=>xe(o.get("/v1/auth/refresh",{token:e})),logout:e=>xe(o.get("/v1/auth/logoutall",{token:e})),isJwtExpired:xt(Pe),httpClient:o};var o}));Et.DeliveryMethods=Ee;var Rt=function(){return Rt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Rt.apply(this,arguments)};function Dt(e,t,r){return void 0===r&&(r=0),t(r).catch((function(n){if(r>=e.maxRetries||!e.shouldRetry(n))throw n;var o,a,i,s,c=(o=e.baseDelay,a=e.maxDelay,i=e.baseDelay*Math.pow(2,r),Math.max(o,Math.min(a,i)));return(s=c,new Promise((function(e){return setTimeout(e,s)}))).then((function(){return Dt(e,t,r+1)}))}))}var $t="Failed to load the JS script of the agent";function Tt(e){var t,r=e.scriptUrlPattern,n=e.token,o=e.apiKey,a=void 0===o?n:o,i=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["scriptUrlPattern","token","apiKey"]),s=(t=e,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(t,"scriptUrlPattern")?r:void 0),c=[];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return Dt({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(e){return!(e instanceof Error&&"Blocked by CSP"===e.message)}},(function(){var e,t=new Date,r=function(){return c.push({startedAt:t,finishedAt:new Date})},n=function(e,t,r,n){var o,a=document,i="securitypolicyviolation",s=function(t){var r=new URL(e,location.href),n=t.blockedURI;n!==r.href&&n!==r.protocol.slice(0,-1)&&n!==r.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 r=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?r(e):"<loaderVersion>"===t?r("3.7.1"):t}))}(a,s),(function(){return function(e){return new Promise((function(t,r){var n=document.createElement("script"),o=function(){var e;return null===(e=n.parentNode)||void 0===e?void 0:e.removeChild(n)},a=document.head||document.getElementsByTagName("head")[0];n.onload=function(){o(),t()},n.onerror=function(){o(),r(new Error($t))},n.async=!0,n.src=e,a.appendChild(n)}))}(e)}));return n.then(r,r),n}))})).then((function(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(e,t){var r,n=null===(r=Object.getOwnPropertyDescriptor)||void 0===r?void 0:r.call(Object,e,t);(null==n?void 0:n.configurable)?delete e[t]:n&&!n.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==r?void 0:r.load))throw new Error($t);return r.load(Rt(Rt({},i),{ldi:{attempts:c}}))}))}var qt={};const Mt=(e,t,r)=>Math.ceil(e.length*Math.log2(t)/Math.log2(r));var Bt=function(e,{from:t,to:r,fixedLength:n=null}){const o=null===n?Mt(e,t,r):n,a=new Array(o);let i=o,s=e;for(;s.length>0;){if(0===i)throw new RangeError(`Fixed length of ${n} is too small, expected at least ${Mt(e,t,r)}`);const o=[];let c=0;for(const e of s){const n=e+c*t,a=Math.floor(n/r);c=n%r,(o.length>0||a>0)&&o.push(a)}a[--i]=c,s=o}if(null===n)return i>0?a.slice(i):a;for(;i>0;)a[--i]=0;return a};const Ct=Bt;qt.encode=function(e,t){return Ct(e,{from:256,to:62,fixedLength:t}).map((e=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[e])).join("")},qt.decode=function(e,t){const r=Array.from(e,(e=>{const t=e.charCodeAt(0);return t<58?t-48:t<91?t-55:t-61}));return Buffer.from(Ct(r,{from:62,to:256,fixedLength:t}))};const{randomBytes:At}=n.default,{inspect:{custom:Lt},promisify:Nt}=o.default,Kt=qt,Ft=Nt(At),Vt=14e11,zt=5694967295e3,Jt=20,Gt=`Valid KSUID timestamps must be in milliseconds since ${new Date(0).toISOString()},\n no earlier than ${new Date(Vt).toISOString()} and no later than ${new Date(zt).toISOString()}\n`.trim().replace(/(\n|\s)+/g," ").replace(/\.000Z/g,"Z");function Ht(e,t){const r=Math.floor((e-Vt)/1e3),n=Buffer.allocUnsafe(4);return n.writeUInt32BE(r,0),Buffer.concat([n,t],Jt)}const Zt=new WeakMap;class Wt{constructor(e){if(!Wt.isValid(e))throw new TypeError("Valid KSUID buffers are 20 bytes");Zt.set(this,e),Object.defineProperty(this,"buffer",{enumerable:!0,get:()=>Buffer.from(e)})}get raw(){return Buffer.from(Zt.get(this).slice(0))}get date(){return new Date(1e3*this.timestamp+Vt)}get timestamp(){return Zt.get(this).readUInt32BE(0)}get payload(){const e=Zt.get(this).slice(4,Jt);return Buffer.from(e)}get string(){return Kt.encode(Zt.get(this),27).padStart(27,"0")}compare(e){return Zt.has(e)?Zt.get(this).compare(Zt.get(e),0,Jt):0}equals(e){return this===e||Zt.has(e)&&0===this.compare(e)}toString(){return`${this[Symbol.toStringTag]} { ${this.string} }`}toJSON(){return this.string}[Lt](){return this.toString()}static async random(e=Date.now()){const t=await Ft(16);return new Wt(Ht(Number(e),t))}static randomSync(e=Date.now()){const t=At(16);return new Wt(Ht(Number(e),t))}static fromParts(e,t){if(!Number.isInteger(e)||e<Vt||e>zt)throw new TypeError(Gt);if(!Buffer.isBuffer(t)||16!==t.byteLength)throw new TypeError("Valid KSUID payloads are 16 bytes");return new Wt(Ht(e,t))}static isValid(e){return Buffer.isBuffer(e)&&e.byteLength===Jt}static parse(e){if(27!==e.length)throw new TypeError("Valid encoded KSUIDs are 27 characters");const t=Kt.decode(e,Jt);if(t.byteLength===Jt)return new Wt(t);const r=Buffer.allocUnsafe(Jt),n=Jt-t.byteLength;return r.fill(0,0,n),t.copy(r,n),new Wt(r)}}Object.defineProperty(Wt.prototype,Symbol.toStringTag,{value:"KSUID"}),Object.defineProperty(Wt,"MAX_STRING_ENCODED",{value:"aWgEPTl1tmebfsQzFP4bxwgy80V"}),Object.defineProperty(Wt,"MIN_STRING_ENCODED",{value:"000000000000000000000000000"});var Qt=Wt;const Xt="vsid",Yt="vrid",er=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e];return e=>{(e=>{const t=Tt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Xt);e||(e=er(Xt)),e||(e=(await Qt.random()).string),sessionStorage.setItem(Xt,e);const r=await t,n=await r.get({linkedId:e});sessionStorage.setItem(Yt,n.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}})(e.fpKey).get().catch((()=>null));return e.hooks={beforeRequest:e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{[Xt]:sessionStorage.getItem(Xt)||"",[Yt]:sessionStorage.getItem(Yt)||""})),e}},Et(e)}}));
!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";function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var t="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=n.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function n(e){this.message=e}function r(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(function(e){var n=e.replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(t(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(n)}catch(e){return t(n)}}(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i="__lodash_hash_undefined__",a="[object Function]",s="[object GeneratorFunction]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,u=/^\w*$/,l=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,h=/^\[object .+?Constructor\]$/,f="object"==typeof o&&o&&o.Object===Object&&o,g="object"==typeof self&&self&&self.Object===Object&&self,v=f||g||Function("return this")();var y,b=Array.prototype,m=Function.prototype,w=Object.prototype,j=v["__core-js_shared__"],k=(y=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+y:"",I=m.toString,O=w.hasOwnProperty,_=w.toString,x=RegExp("^"+I.call(O).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=v.Symbol,S=b.splice,U=B(v,"Map"),R=B(Object,"create"),E=P?P.prototype:void 0,C=E?E.toString:void 0;function D(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 q(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 T(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 $(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 A(e,t){var n;t=function(e,t){if(K(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||H(e))return!0;return u.test(e)||!c.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:K(n=t)?n:F(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[z(t[r++])];return r&&r==o?e:void 0}function M(e){if(!N(e)||(t=e,k&&k in t))return!1;var t,n=function(e){var t=N(e)?_.call(e):"";return t==a||t==s}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?x:h;return n.test(function(e){if(null!=e){try{return I.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function L(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 B(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return M(n)?n:void 0}D.prototype.clear=function(){this.__data__=R?R(null):{}},D.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},D.prototype.get=function(e){var t=this.__data__;if(R){var n=t[e];return n===i?void 0:n}return O.call(t,e)?t[e]:void 0},D.prototype.has=function(e){var t=this.__data__;return R?void 0!==t[e]:O.call(t,e)},D.prototype.set=function(e,t){return this.__data__[e]=R&&void 0===t?i:t,this},q.prototype.clear=function(){this.__data__=[]},q.prototype.delete=function(e){var t=this.__data__,n=$(t,e);return!(n<0)&&(n==t.length-1?t.pop():S.call(t,n,1),!0)},q.prototype.get=function(e){var t=this.__data__,n=$(t,e);return n<0?void 0:t[n][1]},q.prototype.has=function(e){return $(this.__data__,e)>-1},q.prototype.set=function(e,t){var n=this.__data__,r=$(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new D,map:new(U||q),string:new D}},T.prototype.delete=function(e){return L(this,e).delete(e)},T.prototype.get=function(e){return L(this,e).get(e)},T.prototype.has=function(e){return L(this,e).has(e)},T.prototype.set=function(e,t){return L(this,e).set(e,t),this};var F=J((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(H(e))return C?C.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return l.test(e)&&n.push(""),e.replace(p,(function(e,t,r,o){n.push(r?o.replace(d,"$1"):t||e)})),n}));function z(e){if("string"==typeof e||H(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function J(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(J.Cache||T),n}J.Cache=T;var K=Array.isArray;function N(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function H(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==_.call(e)}var G,Z=function(e,t,n){var r=null==e?void 0:A(e,t);return void 0===r?n:r},V="/v1/auth/otp/verify",Q="/v1/auth/otp/signin",W="/v1/auth/otp/signup",X={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Y="/v1/auth/otp/signup-in",ee="/v1/auth/magiclink/verify",te="/v1/auth/magiclink/signin",ne="/v1/auth/magiclink/signup",re="/v1/auth/magiclink/pending-session",oe={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},ie="/v1/auth/magiclink/signup-in",ae="/v1/auth/oauth/authorize",se="/v1/auth/saml/authorize",ce="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",le="/v1/user/totp/update",pe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},de={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},he={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},fe="/v1/flow/start",ge="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(G||(G={}));const ve=()=>{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")}},ye=(...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}),{})),be=e=>void 0===e?void 0:JSON.stringify(e),me=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},we=({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=>ve().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)),ve().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 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:ye(me(t,h),(null==n?void 0:n.baseHeaders)||{},l),method:d,body:be(u),credentials:i||"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:G.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.delete,token:o})}},je=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=r(e);return(new Date).getTime()/1e3>t},ke=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),Ie=async e=>{const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.json();return t.ok?n.data=r:n.error=r,n};var Oe,_e,xe;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Oe||(Oe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(_e||(_e={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(xe||(xe={}));const Pe=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Se=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ue=e=>t=>e.test(t),Re=Ue(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ee=Ue(/^\+[1-9]{1}[0-9]{3,14}$/),Ce=Pe(Re,'"{val}" is not a valid email'),De=Pe(Ee,'"{val}" is not a valid phone number'),qe=Pe((1,e=>e.length>=1),"Minimum length is 1");const Te=Pe((e=>"string"==typeof e),"Input is not a string"),$e=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Se(...e).validate(n[t]))),t(...n)),Ae=e=>[Te(`"${e}" must be a string`),qe(`"${e}" must not be empty`)],Me=e=>[Te(`"${e}" must be a string`),Ce()],Le=e=>[Te(`"${e}" must be a string`),De()];var Be;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Be||(Be={}));const Fe=Ae("identifier"),ze=$e(Fe,Ae("code")),Je=$e(Fe),Ke=$e(Fe,Le("phone")),Ne=$e(Fe,Me("email")),He=e=>({verify:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ze(((t,r)=>Ie(e.post(ke(V,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je((t=>Ie(e.post(ke(Q,n),{externalId:t}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je(((t,r)=>Ie(e.post(ke(W,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je((t=>Ie(e.post(ke(Y,n),{externalId:t}))))})),{}),update:{email:Ne(((t,n,r)=>Ie(e.post(X.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,r,o)=>Ie(e.post(ke(X.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),Ge=Ae("identifier"),Ze=Ae("uri"),Ve=$e(Ae("token")),Qe=$e(Ge,Ze),We=$e(Ae("pendingRef")),Xe=$e(Ge,Le("phone"),Ze),Ye=$e(Ge,Me("email"),Ze),et=e=>({verify:Ve((t=>Ie(e.post(ee,{token:t})))),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(te,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(ie,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r,o)=>Ie(e.post(ke(ne,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:We(((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(re,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(Ie(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:Ye(((t,n,r,o)=>Ie(e.post(oe.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o,i)=>Ie(e.post(ke(oe.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),tt=e=>({verify:Ve((t=>Ie(e.post(ee,{token:t})))),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(te,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r,o)=>Ie(e.post(ke(ne,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(ie,n),{externalId:t,URI:r}))))})),{}),update:{email:Ye(((t,n,r,o)=>Ie(e.post(oe.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o,i)=>Ie(e.post(ke(oe.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:et(e)}),nt=$e(Ae("code")),rt=e=>({exchange:nt((t=>Ie(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var ot;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ot||(ot={}));const it=e=>Object.assign({start:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.get(ae,{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return Ie(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},rt(e)),at=$e(Ae("flowId")),st=$e(Ae("executionId"),Ae("stepId"),Ae("actionId")),ct=e=>({start:at((t=>Ie(e.post(fe,{flowId:t})))),next:st(((t,n,r,o)=>Ie(e.post(ge,{executionId:t,stepId:n,interactionId:r,input:o}))))}),ut=$e(Ae("tenant")),lt=e=>Object.assign({start:ut((async(t,n,{redirect:r=!1}={})=>{const o=await e.get(se,{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return Ie(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},rt(e)),pt=Ae("identifier"),dt=$e(pt,Ae("code")),ht=$e(pt),ft=$e(pt),gt=e=>({signUp:ht(((t,n)=>Ie(e.post(ue,{externalId:t,user:n})))),verify:dt(((t,n)=>Ie(e.post(ce,{externalId:t,code:n})))),update:ft(((t,n)=>Ie(e.post(le,{externalId:t},{token:n}))))}),vt=Ae("identifier"),yt=Ae("origin"),bt=$e(vt,yt,Ae("name")),mt=$e(vt,yt),wt=$e(vt,yt,Ae("token")),jt=$e(Ae("transactionId"),Ae("response")),kt=e=>({signUp:{start:bt(((t,n,r)=>Ie(e.post(pe.start,{user:{externalId:t,name:r},origin:n})))),finish:jt(((t,n)=>Ie(e.post(pe.finish,{transactionId:t,response:n}))))},signIn:{start:mt(((t,n)=>Ie(e.post(de.start,{externalId:t,origin:n})))),finish:jt(((t,n)=>Ie(e.post(de.finish,{transactionId:t,response:n}))))},update:{start:wt(((t,n,r)=>Ie(e.post(he.start,{externalId:t,origin:n},{token:r})))),finish:jt(((t,n)=>Ie(e.post(he.finish,{transactionId:t,response:n}))))}}),It=$e(Ae("token"));var Ot;const _t=$e([("projectId",Ot=Ae("projectId"),Pe(((e,t)=>e=>Se(...t).validate(Z(e,"projectId")))(0,Ot))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=we({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{otp:He(i),magicLink:tt(i),oauth:it(i),saml:lt(i),totp:gt(i),webauthn:kt(i),flow:ct(i),refresh:e=>Ie(i.get("/v1/auth/refresh",{token:e})),logout:e=>Ie(i.get("/v1/auth/logoutall",{token:e})),isJwtExpired:It(je),httpClient:i};var i}));_t.DeliveryMethods=_e;var xt=function(){return xt=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},xt.apply(this,arguments)};function Pt(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,i,a,s,c=(o=e.baseDelay,i=e.maxDelay,a=e.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,a)));return(s=c,new Promise((function(e){return setTimeout(e,s)}))).then((function(){return Pt(e,t,n+1)}))}))}var St="Failed to load the JS script of the agent";function Ut(e){var t,n=e.scriptUrlPattern,r=e.token,o=e.apiKey,i=void 0===o?r:o,a=function(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}(e,["scriptUrlPattern","token","apiKey"]),s=(t=e,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(t,"scriptUrlPattern")?n:void 0),c=[];return Promise.resolve().then((function(){if(!i||"string"!=typeof i)throw new Error("API key required");return Pt({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 c.push({startedAt:t,finishedAt:new Date})},r=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(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}))}(i,s),(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(St))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}));return r.then(n,n),r}))})).then((function(){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(St);return n.load(xt(xt({},a),{ldi:{attempts:c}}))}))}const Rt="vsid",Et="vrid",Ct=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Dt=e=>{const t=Ut({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Rt);e||(e=Ct(Rt)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Rt,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Et,r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};
/*! js-cookie v3.0.1 | MIT */
function qt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var Tt=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=qt({},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,"",qt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,qt({},this.attributes,t))},withConverter:function(t){return e(qt({},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 $t=async e=>{try{const t=await(null==e?void 0:e.json());!function(e){const{sessionJwt:t,refreshJwt:n,cookieDomain:r,cookiePath:o,cookieExpiration:i}=e||{};t&&Tt.set("DS",t,{path:o,domain:r,expires:i,secure:!0}),n&&localStorage.setItem("DSR",n)}((null==t?void 0:t.authInfo)||t)}catch(e){console.error("Could not set tokens from body")}};return e=>{Dt(e.fpKey).get().catch((()=>null));const t=e;return t.hooks={beforeRequest:t=>{var n;return t.queryParams=(n=t.queryParams,Object.assign(Object.assign({},n),{[Rt]:sessionStorage.getItem(Rt)||"",[Et]:sessionStorage.getItem(Et)||""})),e.disableTokensStorage||t.token||(t.token=localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""),t}},e.disableTokensStorage||(t.hooks.afterRequest=async(e,t)=>{$t(t)}),_t(e)}}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@descope/web-js-sdk",
"version": "0.0.1-alpha.2",
"version": "0.0.1-alpha.3",
"main": "dist/cjs/index.cjs.js",

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

"@types/jest": "^27.0.2",
"@types/js-cookie": "^3.0.2",
"@types/lodash.get": "^4.4.7",

@@ -77,5 +78,5 @@ "@typescript-eslint/parser": "^5.33.1",

"dependencies": {
"@descope/core-js-sdk": "^0.0.41-alpha.12",
"@descope/core-js-sdk": "^0.0.41-alpha.16",
"@fingerprintjs/fingerprintjs-pro": "^3.7.1",
"ksuid": "^3.0.0"
"js-cookie": "^3.0.1"
},

@@ -82,0 +83,0 @@ "overrides": {

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