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.5 to 0.0.1-alpha.6

2

dist/index.umd.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e){this.message=e}n.prototype=new Error,n.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=t.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 o(e){this.message=e}function i(e,t){if("string"!=typeof e)throw new o("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(r(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 r(t)}}(e.split(".")[n]))}catch(e){throw new o("Invalid token specified: "+e.message)}}o.prototype=new Error,o.prototype.name="InvalidTokenError";var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s="__lodash_hash_undefined__",c="[object Function]",u="[object GeneratorFunction]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p=/^\w*$/,d=/^\./,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,h=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,v="object"==typeof a&&a&&a.Object===Object&&a,y="object"==typeof self&&self&&self.Object===Object&&self,m=v||y||Function("return this")();var b,w=Array.prototype,j=Function.prototype,I=Object.prototype,k=m["__core-js_shared__"],O=(b=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"",_=j.toString,x=I.hasOwnProperty,P=I.toString,S=RegExp("^"+_.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=m.Symbol,R=w.splice,E=z(m,"Map"),C=z(Object,"create"),D=U?U.prototype:void 0,T=D?D.toString:void 0;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 $(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 A(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,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 L(e,t){var n;t=function(e,t){if(H(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||Z(e))return!0;return p.test(e)||!l.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:H(n=t)?n:J(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[N(t[r++])];return r&&r==o?e:void 0}function B(e){if(!G(e)||(t=e,O&&O in t))return!1;var t,n=function(e){var t=G(e)?P.call(e):"";return t==c||t==u}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?S:g;return n.test(function(e){if(null!=e){try{return _.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function F(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 z(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return B(n)?n:void 0}q.prototype.clear=function(){this.__data__=C?C(null):{}},q.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},q.prototype.get=function(e){var t=this.__data__;if(C){var n=t[e];return n===s?void 0:n}return x.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return C?void 0!==t[e]:x.call(t,e)},q.prototype.set=function(e,t){return this.__data__[e]=C&&void 0===t?s:t,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(e){var t=this.__data__,n=M(t,e);return!(n<0)&&(n==t.length-1?t.pop():R.call(t,n,1),!0)},$.prototype.get=function(e){var t=this.__data__,n=M(t,e);return n<0?void 0:t[n][1]},$.prototype.has=function(e){return M(this.__data__,e)>-1},$.prototype.set=function(e,t){var n=this.__data__,r=M(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},A.prototype.clear=function(){this.__data__={hash:new q,map:new(E||$),string:new q}},A.prototype.delete=function(e){return F(this,e).delete(e)},A.prototype.get=function(e){return F(this,e).get(e)},A.prototype.has=function(e){return F(this,e).has(e)},A.prototype.set=function(e,t){return F(this,e).set(e,t),this};var J=K((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Z(e))return T?T.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return d.test(e)&&n.push(""),e.replace(f,(function(e,t,r,o){n.push(r?o.replace(h,"$1"):t||e)})),n}));function N(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function K(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(K.Cache||A),n}K.Cache=A;var H=Array.isArray;function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Z(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==P.call(e)}var V,Q=function(e,t,n){var r=null==e?void 0:L(e,t);return void 0===r?n:r},W="/v1/auth/otp/verify",X="/v1/auth/otp/signin",Y="/v1/auth/otp/signup",ee={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},te="/v1/auth/otp/signup-in",ne="/v1/auth/magiclink/verify",re="/v1/auth/magiclink/signin",oe="/v1/auth/magiclink/signup",ie="/v1/auth/magiclink/pending-session",ae={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},se="/v1/auth/magiclink/signup-in",ce="/v1/auth/oauth/authorize",ue="/v1/auth/saml/authorize",le="/v1/auth/totp/verify",pe="/v1/auth/totp/signup",de="/v1/user/totp/update",fe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},he={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ge={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ve="/v1/flow/start",ye="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(V||(V={}));const me=()=>{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")}},be=(...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}),{})),we=e=>void 0===e?void 0:JSON.stringify(e),je=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ie=({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=>me().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)),me().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:be(je(t,f),(null==n?void 0:n.baseHeaders)||{},l),method:d,body:we(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:V.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.delete,token:o})}},ke=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=i(e);return(new Date).getTime()/1e3>t},Oe=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),_e=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 xe,Pe,Se;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(xe||(xe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Pe||(Pe={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Se||(Se={}));const Ue=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Re=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ee=e=>t=>e.test(t),Ce=Ee(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),De=Ee(/^\+[1-9]{1}[0-9]{3,14}$/),Te=Ue(Ce,'"{val}" is not a valid email'),qe=Ue(De,'"{val}" is not a valid phone number'),$e=Ue((1,e=>e.length>=1),"Minimum length is 1");const Ae=Ue((e=>"string"==typeof e),"Input is not a string"),Me=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Re(...e).validate(n[t]))),t(...n)),Le=e=>[Ae(`"${e}" must be a string`),$e(`"${e}" must not be empty`)],Be=e=>[Ae(`"${e}" must be a string`),Te()],Fe=e=>[Ae(`"${e}" must be a string`),qe()];var ze;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ze||(ze={}));const Je=Le("identifier"),Ne=Me(Je,Le("code")),Ke=Me(Je),He=Me(Je,Fe("phone")),Ge=Me(Je,Be("email")),Ze=e=>({verify:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ne(((t,r)=>_e(e.post(Oe(W,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke((t=>_e(e.post(Oe(X,n),{externalId:t}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,r)=>_e(e.post(Oe(Y,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke((t=>_e(e.post(Oe(te,n),{externalId:t}))))})),{}),update:{email:Ge(((t,n,r)=>_e(e.post(ee.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,r,o)=>_e(e.post(Oe(ee.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),Ve=Le("identifier"),Qe=Le("uri"),We=Me(Le("token")),Xe=Me(Ve,Qe),Ye=Me(Le("pendingRef")),et=Me(Ve,Fe("phone"),Qe),tt=Me(Ve,Be("email"),Qe),nt=e=>({verify:We((t=>_e(e.post(ne,{token:t})))),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(re,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(se,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o)=>_e(e.post(Oe(oe,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:Ye(((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(ie,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(_e(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:tt(((t,n,r,o)=>_e(e.post(ae.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:et(((t,r,o,i)=>_e(e.post(Oe(ae.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),rt=e=>({verify:We((t=>_e(e.post(ne,{token:t})))),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(re,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o)=>_e(e.post(Oe(oe,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(se,n),{externalId:t,URI:r}))))})),{}),update:{email:tt(((t,n,r,o)=>_e(e.post(ae.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:et(((t,r,o,i)=>_e(e.post(Oe(ae.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:nt(e)}),ot=Me(Le("code")),it=e=>({exchange:ot((t=>_e(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var at;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(at||(at={}));const st=e=>Object.assign({start:Object.keys(at).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.get(ce,{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return _e(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},it(e)),ct=Me(Le("flowId")),ut=Me(Le("executionId"),Le("stepId"),Le("actionId")),lt=e=>({start:ct((t=>_e(e.post(ve,{flowId:t})))),next:ut(((t,n,r,o)=>_e(e.post(ye,{executionId:t,stepId:n,interactionId:r,input:o}))))}),pt=Me(Le("tenant")),dt=e=>Object.assign({start:pt((async(t,n,{redirect:r=!1}={})=>{const o=await e.get(ue,{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return _e(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},it(e)),ft=Le("identifier"),ht=Me(ft,Le("code")),gt=Me(ft),vt=Me(ft),yt=e=>({signUp:gt(((t,n)=>_e(e.post(pe,{externalId:t,user:n})))),verify:ht(((t,n)=>_e(e.post(le,{externalId:t,code:n})))),update:vt(((t,n)=>_e(e.post(de,{externalId:t},{token:n}))))}),mt=Le("identifier"),bt=Le("origin"),wt=Me(mt,bt,Le("name")),jt=Me(mt,bt),It=Me(mt,bt,Le("token")),kt=Me(Le("transactionId"),Le("response")),Ot=e=>({signUp:{start:wt(((t,n,r)=>_e(e.post(fe.start,{user:{externalId:t,name:r},origin:n})))),finish:kt(((t,n)=>_e(e.post(fe.finish,{transactionId:t,response:n}))))},signIn:{start:jt(((t,n)=>_e(e.post(he.start,{externalId:t,origin:n})))),finish:kt(((t,n)=>_e(e.post(he.finish,{transactionId:t,response:n}))))},update:{start:It(((t,n,r)=>_e(e.post(ge.start,{externalId:t,origin:n},{token:r})))),finish:kt(((t,n)=>_e(e.post(ge.finish,{transactionId:t,response:n}))))}}),_t=Me(Le("token"));var xt;const Pt=Me([("projectId",xt=Le("projectId"),Ue(((e,t)=>e=>Re(...t).validate(Q(e,"projectId")))(0,xt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Ie({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{otp:Ze(i),magicLink:rt(i),oauth:st(i),saml:dt(i),totp:yt(i),webauthn:Ot(i),flow:lt(i),refresh:e=>_e(i.get("/v1/auth/refresh",{token:e})),logout:e=>_e(i.get("/v1/auth/logoutall",{token:e})),isJwtExpired:_t(ke),httpClient:i};var i}));function St(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 St(e,t,n+1)}))}))}Pt.DeliveryMethods=Pe;var Ut="Failed to load the JS script of the agent";function Rt(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 St({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(Ut))},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(Ut);return r.load(e(e({},c),{ldi:{attempts:l}}))}))}const Et="vsid",Ct="vrid",Dt=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Tt=e=>{const t=Rt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Et);e||(e=Dt(Et)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Et,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Ct,r.requestId)}catch(e){global.FB_DEBUG&&console.error(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";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){this.message=e}n.prototype=new Error,n.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=t.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 o(e){this.message=e}function i(e,t){if("string"!=typeof e)throw new o("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(r(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 r(t)}}(e.split(".")[n]))}catch(e){throw new o("Invalid token specified: "+e.message)}}o.prototype=new Error,o.prototype.name="InvalidTokenError";var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s="__lodash_hash_undefined__",c="[object Function]",u="[object GeneratorFunction]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p=/^\w*$/,d=/^\./,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,h=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,v="object"==typeof a&&a&&a.Object===Object&&a,y="object"==typeof self&&self&&self.Object===Object&&self,m=v||y||Function("return this")();var b,w=Array.prototype,j=Function.prototype,I=Object.prototype,k=m["__core-js_shared__"],O=(b=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"",_=j.toString,x=I.hasOwnProperty,P=I.toString,S=RegExp("^"+_.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=m.Symbol,R=w.splice,E=z(m,"Map"),C=z(Object,"create"),D=U?U.prototype:void 0,T=D?D.toString:void 0;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 $(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 A(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,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 L(e,t){var n;t=function(e,t){if(H(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||Z(e))return!0;return p.test(e)||!l.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:H(n=t)?n:J(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[N(t[r++])];return r&&r==o?e:void 0}function B(e){if(!G(e)||(t=e,O&&O in t))return!1;var t,n=function(e){var t=G(e)?P.call(e):"";return t==c||t==u}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?S:g;return n.test(function(e){if(null!=e){try{return _.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function F(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 z(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return B(n)?n:void 0}q.prototype.clear=function(){this.__data__=C?C(null):{}},q.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},q.prototype.get=function(e){var t=this.__data__;if(C){var n=t[e];return n===s?void 0:n}return x.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return C?void 0!==t[e]:x.call(t,e)},q.prototype.set=function(e,t){return this.__data__[e]=C&&void 0===t?s:t,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(e){var t=this.__data__,n=M(t,e);return!(n<0)&&(n==t.length-1?t.pop():R.call(t,n,1),!0)},$.prototype.get=function(e){var t=this.__data__,n=M(t,e);return n<0?void 0:t[n][1]},$.prototype.has=function(e){return M(this.__data__,e)>-1},$.prototype.set=function(e,t){var n=this.__data__,r=M(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},A.prototype.clear=function(){this.__data__={hash:new q,map:new(E||$),string:new q}},A.prototype.delete=function(e){return F(this,e).delete(e)},A.prototype.get=function(e){return F(this,e).get(e)},A.prototype.has=function(e){return F(this,e).has(e)},A.prototype.set=function(e,t){return F(this,e).set(e,t),this};var J=K((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Z(e))return T?T.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return d.test(e)&&n.push(""),e.replace(f,(function(e,t,r,o){n.push(r?o.replace(h,"$1"):t||e)})),n}));function N(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function K(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(K.Cache||A),n}K.Cache=A;var H=Array.isArray;function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Z(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==P.call(e)}var V,Q=function(e,t,n){var r=null==e?void 0:L(e,t);return void 0===r?n:r},W="/v1/auth/otp/verify",X="/v1/auth/otp/signin",Y="/v1/auth/otp/signup",ee={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},te="/v1/auth/otp/signup-in",ne="/v1/auth/magiclink/verify",re="/v1/auth/magiclink/signin",oe="/v1/auth/magiclink/signup",ie="/v1/auth/magiclink/pending-session",ae={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},se="/v1/auth/magiclink/signup-in",ce="/v1/auth/oauth/authorize",ue="/v1/auth/saml/authorize",le="/v1/auth/totp/verify",pe="/v1/auth/totp/signup",de="/v1/user/totp/update",fe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},he={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ge={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ve="/v1/flow/start",ye="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(V||(V={}));const me=()=>{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")}},be=(...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}),{})),we=e=>void 0===e?void 0:JSON.stringify(e),je=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ie=({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=>me().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)),me().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:be(je(t,f),(null==n?void 0:n.baseHeaders)||{},l),method:d,body:we(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:V.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:V.delete,token:o})}},ke=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=i(e);return(new Date).getTime()/1e3>t},Oe=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),_e=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 xe,Pe,Se;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(xe||(xe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Pe||(Pe={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Se||(Se={}));const Ue=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Re=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ee=e=>t=>e.test(t),Ce=Ee(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),De=Ee(/^\+[1-9]{1}[0-9]{3,14}$/),Te=Ue(Ce,'"{val}" is not a valid email'),qe=Ue(De,'"{val}" is not a valid phone number'),$e=Ue((1,e=>e.length>=1),"Minimum length is 1");const Ae=Ue((e=>"string"==typeof e),"Input is not a string"),Me=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Re(...e).validate(n[t]))),t(...n)),Le=e=>[Ae(`"${e}" must be a string`),$e(`"${e}" must not be empty`)],Be=e=>[Ae(`"${e}" must be a string`),Te()],Fe=e=>[Ae(`"${e}" must be a string`),qe()];var ze;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ze||(ze={}));const Je=Le("identifier"),Ne=Me(Je,Le("code")),Ke=Me(Je),He=Me(Je,Fe("phone")),Ge=Me(Je,Be("email")),Ze=e=>({verify:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ne(((t,r)=>_e(e.post(Oe(W,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke((t=>_e(e.post(Oe(X,n),{externalId:t}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,r)=>_e(e.post(Oe(Y,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke((t=>_e(e.post(Oe(te,n),{externalId:t}))))})),{}),update:{email:Ge(((t,n,r)=>_e(e.post(ee.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,r,o)=>_e(e.post(Oe(ee.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),Ve=Le("identifier"),Qe=Le("uri"),We=Me(Le("token")),Xe=Me(Ve,Qe),Ye=Me(Le("pendingRef")),et=Me(Ve,Fe("phone"),Qe),tt=Me(Ve,Be("email"),Qe),nt=e=>({verify:We((t=>_e(e.post(ne,{token:t})))),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(re,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(se,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o)=>_e(e.post(Oe(oe,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:Ye(((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(ie,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(_e(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:tt(((t,n,r,o)=>_e(e.post(ae.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:et(((t,r,o,i)=>_e(e.post(Oe(ae.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),rt=e=>({verify:We((t=>_e(e.post(ne,{token:t})))),signIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(re,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o)=>_e(e.post(Oe(oe,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r)=>_e(e.post(Oe(se,n),{externalId:t,URI:r}))))})),{}),update:{email:tt(((t,n,r,o)=>_e(e.post(ae.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:et(((t,r,o,i)=>_e(e.post(Oe(ae.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:nt(e)}),ot=Me(Le("code")),it=e=>({exchange:ot((t=>_e(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var at;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(at||(at={}));const st=e=>Object.assign({start:Object.keys(at).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.get(ce,{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return _e(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},it(e)),ct=Me(Le("flowId")),ut=Me(Le("executionId"),Le("stepId"),Le("interactionId")),lt=e=>({start:ct((t=>_e(e.post(ve,{flowId:t})))),next:ut(((t,n,r,o)=>_e(e.post(ye,{executionId:t,stepId:n,interactionId:r,input:o}))))}),pt=Me(Le("tenant")),dt=e=>Object.assign({start:pt((async(t,n,{redirect:r=!1}={})=>{const o=await e.get(ue,{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return _e(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},it(e)),ft=Le("identifier"),ht=Me(ft,Le("code")),gt=Me(ft),vt=Me(ft),yt=e=>({signUp:gt(((t,n)=>_e(e.post(pe,{externalId:t,user:n})))),verify:ht(((t,n)=>_e(e.post(le,{externalId:t,code:n})))),update:vt(((t,n)=>_e(e.post(de,{externalId:t},{token:n}))))}),mt=Le("identifier"),bt=Le("origin"),wt=Me(mt,bt,Le("name")),jt=Me(mt,bt),It=Me(mt,bt,Le("token")),kt=Me(Le("transactionId"),Le("response")),Ot=e=>({signUp:{start:wt(((t,n,r)=>_e(e.post(fe.start,{user:{externalId:t,name:r},origin:n})))),finish:kt(((t,n)=>_e(e.post(fe.finish,{transactionId:t,response:n}))))},signIn:{start:jt(((t,n)=>_e(e.post(he.start,{externalId:t,origin:n})))),finish:kt(((t,n)=>_e(e.post(he.finish,{transactionId:t,response:n}))))},update:{start:It(((t,n,r)=>_e(e.post(ge.start,{externalId:t,origin:n},{token:r})))),finish:kt(((t,n)=>_e(e.post(ge.finish,{transactionId:t,response:n}))))}}),_t=Me(Le("token"));var xt;const Pt=Me([("projectId",xt=Le("projectId"),Ue(((e,t)=>e=>Re(...t).validate(Q(e,"projectId")))(0,xt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Ie({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{otp:Ze(i),magicLink:rt(i),oauth:st(i),saml:dt(i),totp:yt(i),webauthn:Ot(i),flow:lt(i),refresh:e=>_e(i.get("/v1/auth/refresh",{token:e})),logout:e=>_e(i.get("/v1/auth/logoutall",{token:e})),isJwtExpired:_t(ke),httpClient:i};var i}));function St(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 St(e,t,n+1)}))}))}Pt.DeliveryMethods=Pe;var Ut="Failed to load the JS script of the agent";function Rt(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 St({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(Ut))},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(Ut);return r.load(e(e({},c),{ldi:{attempts:l}}))}))}const Et="vsid",Ct="vrid",Dt=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Tt=e=>{const t=Rt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Et);e||(e=Dt(Et)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Et,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Ct,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 $t=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 At="DSR";let Mt=[];function Lt(e,t){const n=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(n){let t;for(;t=Mt.pop();)clearTimeout(t);const r=n.getTime()-2e4-(new Date).getTime(),o=setTimeout((()=>{const t=Ft();t&&e(t)}),r);Mt.push(o)}}function Bt(e){const{sessionJwt:t,refreshJwt:n}=e||{};return function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:r}){e&&$t.set("DS",e,{path:t,domain:n,expires:r,sameSite:"None",secure:!0})}(t,e||{}),function(e){localStorage&&e&&localStorage.setItem(At,e)}(n),t}function Ft(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem(At):""}return e=>{var{persistTokens:n=!0}=e,r=t(e,["persistTokens"]);Tt(r.fpKey).get().catch((()=>null));const o=r;let i;if(o.hooks={beforeRequest:e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{[Et]:sessionStorage.getItem(Et)||"",[Ct]:sessionStorage.getItem(Ct)||""})),n&&!e.token&&(e.token=Ft()),e}},n&&(o.hooks.afterRequest=async(e,t)=>{!async function(e,t,n){try{const t=await(null==n?void 0:n.json());if(t){const n=Bt((null==t?void 0:t.authInfo)||t);n&&Lt(e,n)}}catch(e){console.error("Could not set tokens from body",e)}}(i.refresh,0,t)}),i=Pt(r),n){const e=i.logout;i.logout=(...t)=>{localStorage&&localStorage.removeItem(At),$t.remove("DS");return e(...t)}}return i}}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@descope/web-js-sdk",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.6",
"main": "dist/cjs/index.cjs.js",

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

"dependencies": {
"@descope/core-js-sdk": "^0.0.41-alpha.16",
"@descope/core-js-sdk": "^0.0.41-alpha.17",
"@fingerprintjs/fingerprintjs-pro": "^3.7.1",

@@ -80,0 +80,0 @@ "js-cookie": "^3.0.1"

@@ -6,3 +6,2 @@ # @descope/web-js-sdk

## Usage
### Install the package

@@ -9,0 +8,0 @@

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