@descope/web-js-sdk 0.1.0-alpha.4 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).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,m="object"==typeof self&&self&&self.Object===Object&&self,w=b||m||Function("return this")();var O,j=Array.prototype,k=Function.prototype,I=Object.prototype,_=w["__core-js_shared__"],x=(O=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",S=k.toString,P=I.hasOwnProperty,U=I.toString,R=RegExp("^"+S.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=w.Symbol,C=j.splice,T=F(w,"Map"),D=F(Object,"create"),q=E?E.prototype:void 0,A=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 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 f.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():C.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(T||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 A?A.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||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],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(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",ie="/v1/auth/magiclink/verify",ae="/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/email"},le="/v1/auth/magiclink/signup-in",pe="/v1/auth/oauth/authorize",de="/v1/auth/saml/authorize",fe="/v1/auth/totp/verify",he="/v1/auth/totp/signup",ge="/v1/user/totp/update",ve={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ye={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},be={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},me="/v1/flow/start",we="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(Q||(Q={}));const Oe=()=>{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")}},je=(...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}),{})),ke=e=>void 0===e?void 0:JSON.stringify(e),Ie=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},_e=({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=>Oe().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)),Oe().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:je(Ie(t,f),(null==n?void 0:n.baseHeaders)||{},l),method:d,body:ke(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: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 xe(e){const{exp:t}=Ce(e);return(new Date).getTime()/1e3>t}function Se(e,t){return Ee(e,t,"permissions")}function Pe(e,t){return Ee(e,t,"roles")}const Ue=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Re(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}function Ee(e,t,n){var r;let o=Ce(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const i=o[n];return Array.isArray(i)?i:[]}function Ce(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s(e)}const Te=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),De=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),qe=e=>t=>e.test(t),Ae=qe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),$e=qe(/^\+[1-9]{1}[0-9]{3,14}$/),Je=Te(Ae,'"{val}" is not a valid email'),Me=Te($e,'"{val}" is not a valid phone number'),Ne=Te((1,e=>e.length>=1),"Minimum length is 1");const Ke=Te((e=>"string"==typeof e),"Input is not a string"),Le=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>De(...e).validate(n[t]))),t(...n)),Be=e=>[Ke(`"${e}" must be a string`),Ne(`"${e}" must not be empty`)],Fe=e=>[Ke(`"${e}" must be a string`),Je()],ze=e=>[Ke(`"${e}" must be a string`),Me()],He=Le(Be("accessKey")),We=e=>({exchange:He((t=>Re(e.get(Y,{token:t}))))});var Ge,Ze,Ve,Qe,Xe;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Ge||(Ge={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Ze||(Ze={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ve||(Ve={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Qe||(Qe={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Xe||(Xe={}));const Ye=Be("identifier"),et=Le(Ye,Be("code")),tt=Le(Ye),nt=Le(Ye,ze("phone")),rt=Le(Ye,Fe("email")),ot=e=>({verify:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:et(((t,r)=>Re(e.post(Ue(ee,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tt((t=>Re(e.post(Ue(te,n),{externalId:t}))))})),{}),signUp:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tt(((t,r)=>Re(e.post(Ue(ne,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tt((t=>Re(e.post(Ue(oe,n),{externalId:t}))))})),{}),update:{email:rt(((t,n,r)=>Re(e.post(re.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nt(((t,r,o)=>Re(e.post(Ue(re.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),it=Be("identifier"),at=Be("uri"),st=Le(Be("token")),ct=Le(it,at),ut=Le(Be("pendingRef")),lt=Le(it,ze("phone"),at),pt=Le(it,Fe("email"),at),dt=e=>({verify:st((t=>Re(e.post(ie,{token:t})))),signIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r)=>Re(e.post(Ue(ae,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r)=>Re(e.post(Ue(le,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r,o)=>Re(e.post(Ue(se,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:ut(((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(ce,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(Re(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:pt(((t,n,r,o)=>Re(e.post(ue.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:lt(((t,r,o,i)=>Re(e.post(Ue(ue.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),ft=e=>({verify:st((t=>Re(e.post(ie,{token:t})))),signIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r)=>Re(e.post(Ue(ae,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r,o)=>Re(e.post(Ue(se,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Ze).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ct(((t,r)=>Re(e.post(Ue(le,n),{externalId:t,URI:r}))))})),{}),update:{email:pt(((t,n,r,o)=>Re(e.post(ue.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(Ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:lt(((t,r,o,i)=>Re(e.post(Ue(ue.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:dt(e)}),ht=Le(Be("code")),gt=e=>({exchange:ht((t=>Re(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var vt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(vt||(vt={}));const yt=e=>Object.assign({start:Object.keys(vt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.get(pe,{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return Re(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},gt(e)),bt=Le(Be("flowId")),mt=Le(Be("executionId"),Be("stepId"),Be("interactionId")),wt=e=>({start:bt((t=>Re(e.post(me,{flowId:t})))),next:mt(((t,n,r,o)=>Re(e.post(we,{executionId:t,stepId:n,interactionId:r,input:o}))))}),Ot=Le(Be("tenant")),jt=e=>Object.assign({start:Ot((async(t,n,{redirect:r=!1}={})=>{const o=await e.get(de,{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return Re(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},gt(e)),kt=Be("identifier"),It=Le(kt,Be("code")),_t=Le(kt),xt=Le(kt),St=e=>({signUp:_t(((t,n)=>Re(e.post(he,{externalId:t,user:n})))),verify:It(((t,n)=>Re(e.post(fe,{externalId:t,code:n})))),update:xt(((t,n)=>Re(e.post(ge,{externalId:t},{token:n}))))}),Pt=Be("identifier"),Ut=Be("origin"),Rt=Le(Pt,Ut,Be("name")),Et=Le(Pt,Ut),Ct=Le(Pt,Ut,Be("token")),Tt=Le(Be("transactionId"),Be("response")),Dt=e=>({signUp:{start:Rt(((t,n,r)=>Re(e.post(ve.start,{user:{externalId:t,name:r},origin:n})))),finish:Tt(((t,n)=>Re(e.post(ve.finish,{transactionId:t,response:n}))))},signIn:{start:Et(((t,n)=>Re(e.post(ye.start,{externalId:t,origin:n})))),finish:Tt(((t,n)=>Re(e.post(ye.finish,{transactionId:t,response:n}))))},update:{start:Ct(((t,n,r)=>Re(e.post(be.start,{externalId:t,origin:n},{token:r})))),finish:Tt(((t,n)=>Re(e.post(be.finish,{transactionId:t,response:n}))))}}),qt=Le(Be("token"));var At;const $t=Le([("projectId",At=Be("projectId"),Te(((e,t)=>e=>De(...t).validate(X(e,"projectId")))(0,At))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=_e({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:We(i),otp:ot(i),magicLink:ft(i),oauth:yt(i),saml:jt(i),totp:St(i),webauthn:Dt(i),flow:wt(i),refresh:e=>Re(i.get("/v1/auth/refresh",{token:e})),logout:e=>Re(i.get("/v1/auth/logoutall",{token:e})),me:e=>Re(i.get("/v1/auth/me",{token:e})),isJwtExpired:qt(xe),getJwtPermissions:qt(Se),getJwtRoles:qt(Pe),httpClient:i};var i}));$t.DeliveryMethods=Ze;const Jt="vsid",Mt="vrid";function Nt(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 Nt(e,t,n+1)}))}))}var Kt="Failed to load the JS script of the agent";function Lt(n){var r,o=n.scriptUrlPattern,i=n.token,a=n.apiKey,s=void 0===a?i:a,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 Nt({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,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}))}(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)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Kt))},r.async=!0,r.src=e,i.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(Kt);return r.load(e(e({},c),{ldi:{attempts:l}}))}))}const Bt=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Ft=e=>{const t=Lt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Jt);e||(e=Bt(Jt)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Jt,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Mt,r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var zt,Ht,Wt,Gt,Zt;const Vt=e=>"string"==typeof e?e:Object.assign({},e);class Qt{constructor(e){zt.add(this),Ht.set(this,void 0),Wt.set(this,{}),Gt.set(this,0),r(this,Ht,e,"f")}get current(){return Vt(n(this,Ht,"f"))}update(e){let t=e;if("object"==typeof e&&"object"==typeof n(this,Ht,"f")&&(t=Object.assign(Object.assign({},n(this,Ht,"f")),e)),!((e,t)=>{if("string"==typeof e)return 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,Ht,"f"),t)){const e=n(this,Ht,"f");r(this,Ht,t,"f"),Object.freeze(n(this,Ht,"f")),setTimeout((()=>{Object.values(n(this,Wt,"f")).forEach((n=>n(Vt(t),e)))}),0)}}subscribe(e){var t;r(this,Gt,n(this,Gt,"f")+1,"f"),n(this,Wt,"f")[n(this,Gt,"f")]=e,((t=n(this,Ht,"f"))&&"string"!=typeof t?0===Object.entries(t).length:!t)||e(Vt(n(this,Ht,"f")));const o=n(this,Gt,"f");return()=>n(this,zt,"m",Zt).call(this,o.toString())}unsubscribeAll(){r(this,Wt,{},"f")}}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).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)\]/,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"),q=T?T.prototype:void 0,A=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 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 A?A.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],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(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",ie="/v1/auth/magiclink/verify",ae="/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: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=>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 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:_e(Se(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.26"},(null==n?void 0:n.baseHeaders)||{},l),method:d,body:xe(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: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 i=o[n];return Array.isArray(i)?i:[]}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 qe(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 Ae=(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=Ae(Me,'"{val}" is not a valid email'),Le=Ae(Ne,'"{val}" is not a valid phone number'),Be=Ae((1,e=>e.length>=1),"Minimum length is 1");const Fe=Ae((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=>qe(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),it=ze(nt,Ge("phone")),at=ze(nt,We("email")),st=e=>({verify:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:rt(((t,r)=>qe(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)=>qe(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)=>qe(e.post(De(ne,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ot((t=>qe(e.post(De(oe,n),{externalId:t}))))})),{}),update:{email:at(((t,n,r)=>qe(e.post(re.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Qe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:it(((t,r,o)=>qe(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=>qe(e.post(ie,{token:t})))),signIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o,i)=>qe(e.post(De(ae,n),{externalId:t,URI:r,crossDevice:!0,loginOptions:o},{token:i}))))})),{}),signUpOrIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r)=>qe(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)=>qe(e.post(De(se,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:dt(((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(ce,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(qe(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:ft(((t,n,r,o)=>qe(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,i)=>qe(e.post(De(ue.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),vt=e=>({verify:lt((t=>qe(e.post(ie,{token:t})))),signIn:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o,i)=>qe(e.post(De(ae,n),{externalId:t,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,r,o)=>qe(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)=>qe(e.post(De(le,n),{externalId:t,URI:r}))))})),{}),update:{email:ft(((t,n,r,o)=>qe(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,i)=>qe(e.post(De(ue.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},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,i)=>{const a=await e.post(pe,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!r||!a.ok)return qe(Promise.resolve(a));const{url:s}=await a.json();window.location.href=s}})),{}),exchange:bt((t=>qe(e.post(de,{code:t}))))}),mt=ze(He("flowId")),Ot=ze(He("executionId"),He("stepId"),He("interactionId")),kt=e=>({start:mt(((t,n)=>qe(e.post(ke,{flowId:t,options:n})))),next:Ot(((t,n,r,o)=>qe(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,i)=>{const a=await e.post(he,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!r||!a.ok)return qe(Promise.resolve(a));const{url:s}=await a.json();window.location.href=s})),exchange:It((t=>qe(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)=>qe(e.post(ve,{externalId:t,user:n})))),verify:St(((t,n,r,o)=>qe(e.post(ge,{externalId:t,code:n,loginOptions:r},{token:o})))),update:Ut(((t,n)=>qe(e.post(ye,{externalId:t},{token:n}))))}),Tt=He("identifier"),Et=He("origin"),Ct=ze(Tt,Et,He("name")),Dt=ze(Tt,Et),qt=ze(Tt,Et,He("token")),At=ze(He("transactionId"),He("response")),$t=e=>({signUp:{start:Ct(((t,n,r)=>qe(e.post(be.start,{user:{externalId:t,name:r},origin:n})))),finish:At(((t,n)=>qe(e.post(be.finish,{transactionId:t,response:n}))))},signIn:{start:Dt(((t,n,r,o)=>qe(e.post(we.start,{externalId:t,origin:n,loginOptions:r},{token:o})))),finish:At(((t,n)=>qe(e.post(we.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Dt(((t,n)=>qe(e.post(me.start,{externalId:t,origin:n}))))},update:{start:qt(((t,n,r)=>qe(e.post(Oe.start,{externalId:t,origin:n},{token:r})))),finish:At(((t,n)=>qe(e.post(Oe.finish,{transactionId:t,response:n}))))}}),Jt=ze(He("token"));var Mt;const Nt=ze([("projectId",Mt=He("projectId"),Ae(((e,t)=>e=>$e(...t).validate(X(e,"projectId")))(0,Mt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Pe({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:Ve(i),otp:st(i),magicLink:vt(i),oauth:wt(i),saml:_t(i),totp:Rt(i),webauthn:$t(i),flow:kt(i),refresh:e=>qe(i.post("/v1/auth/refresh",{},{token:e})),logout:e=>qe(i.post("/v1/auth/logoutall",{},{token:e})),deleteCookies:e=>qe(i.post("/v1/auth/deletecookies",{},{token:e})),me:e=>qe(i.get("/v1/auth/me",{token:e})),isJwtExpired:Jt(Te),getJwtPermissions:Jt(Ee),getJwtRoles:Jt(Ce),httpClient:i};var i}));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,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 Bt(e,t,n+1)}))}))}var Ft="Failed to load the JS script of the agent";function zt(n){var r,o=n.scriptUrlPattern,i=n.token,a=n.apiKey,s=void 0===a?i:a,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,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}))}(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)},i=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,i.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")}}
2
2
  /*! js-cookie v3.0.1 | MIT */
3
- function Xt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}Ht=new WeakMap,Wt=new WeakMap,Gt=new WeakMap,zt=new WeakSet,Zt=function(e){!!n(this,Wt,"f")[e]&&delete n(this,Wt,"f")[e]};var Yt=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=Xt({},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,"",Xt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Xt({},this.attributes,t))},withConverter:function(t){return e(Xt({},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 en="DSR";let tn=[];function nn(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=tn.pop();)clearTimeout(t);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(n)}),o);tn.push(i)}}function rn(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:r}){e&&Yt.set("DS",e,{path:t,domain:n,expires:r,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem(en,e)}(t)}function on(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem(en):""}async function an(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=cn(n.publicKey.challenge),n.publicKey.user.id=cn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=cn(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=cn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=cn(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}function cn(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,"")}const ln="undefined"!=typeof window;return e=>{var{autoRefresh:n=!0,persistTokens:r=!0}=e,o=t(e,["autoRefresh","persistTokens"]);ln?Ft(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 Qt(""),u=new Qt({});i.hooks={beforeRequest:e=>null==a?void 0:a(e),afterRequest:(e,t)=>null==s?void 0:s(e,t)};const l=$t(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 an(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 update(e,t){const n=await d.webauthn.update.start(e,window.location.origin,t),r=await an(n.data.options);return await d.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:an,get:sn}}),onSessionTokenChange:c.subscribe,onUserChange:u.subscribe});var d;return n&&(p.logout=(...e)=>{const t=on(),n=[(null==e?void 0:e.shift())||t,...e],r=l.logout(...n);return localStorage&&localStorage.removeItem(en),Yt.remove("DS"),r}),a=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{[Jt]:sessionStorage.getItem(Jt)||"",[Mt]:sessionStorage.getItem(Mt)||""})),!e.token&&r&&(e.token=on()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.4"}),e},(n||r)&&(s=(e,o)=>{!async function(e,n,r,o){try{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&&rn(a,s,u),r.sessionToken.update(a),r.user.update(c),a&&s&&o.autoRefresh&&nn(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&&p.refresh(),p}}));
3
+ 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 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,"",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(),i=setTimeout((()=>{e(n)}),o);on.push(i)}}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 i=o;let a,s;const c=new en({sessionToken:""}),u=new en({});i.hooks={beforeRequest:e=>null==a?void 0:a(e),afterRequest:(e,t)=>null==s?void 0:s(e,t)};const l=Nt(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 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&&(p.logout=(...e)=>{const t=cn(),n=[(null==e?void 0:e.shift())||t,...e],r=l.logout(...n);return localStorage&&localStorage.removeItem(rn),nn.remove("DS"),r}),a=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.6"}),e},(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&&sn(a,s,u),a&&r.sessionToken.update({sessionToken:a}),c&&r.user.update(c),a&&s&&o.autoRefresh&&an(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&&p.refresh(),p}}));
4
4
  //# sourceMappingURL=index.umd.js.map