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

2

dist/cjs/index.cjs.js

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

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

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

fpKey?: string;
disableTokensStorage?: boolean;
persistTokens?: boolean;
};
declare const _default: (args: WebJSSDKArgs) => {
declare const _default: ({ persistTokens, ...args }: WebJSSDKArgs) => {
otp: {

@@ -11,0 +11,0 @@ verify: {

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

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

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var t="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=n.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function n(e){this.message=e}function r(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(function(e){var n=e.replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(t(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(n)}catch(e){return t(n)}}(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i="__lodash_hash_undefined__",a="[object Function]",s="[object GeneratorFunction]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,u=/^\w*$/,l=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,h=/^\[object .+?Constructor\]$/,f="object"==typeof o&&o&&o.Object===Object&&o,g="object"==typeof self&&self&&self.Object===Object&&self,v=f||g||Function("return this")();var y,b=Array.prototype,m=Function.prototype,w=Object.prototype,j=v["__core-js_shared__"],k=(y=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+y:"",I=m.toString,O=w.hasOwnProperty,_=w.toString,x=RegExp("^"+I.call(O).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=v.Symbol,S=b.splice,U=B(v,"Map"),R=B(Object,"create"),E=P?P.prototype:void 0,C=E?E.toString:void 0;function D(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function q(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function T(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function A(e,t){var n;t=function(e,t){if(K(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||H(e))return!0;return u.test(e)||!c.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:K(n=t)?n:F(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[z(t[r++])];return r&&r==o?e:void 0}function M(e){if(!N(e)||(t=e,k&&k in t))return!1;var t,n=function(e){var t=N(e)?_.call(e):"";return t==a||t==s}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?x:h;return n.test(function(e){if(null!=e){try{return I.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function L(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function B(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return M(n)?n:void 0}D.prototype.clear=function(){this.__data__=R?R(null):{}},D.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},D.prototype.get=function(e){var t=this.__data__;if(R){var n=t[e];return n===i?void 0:n}return O.call(t,e)?t[e]:void 0},D.prototype.has=function(e){var t=this.__data__;return R?void 0!==t[e]:O.call(t,e)},D.prototype.set=function(e,t){return this.__data__[e]=R&&void 0===t?i:t,this},q.prototype.clear=function(){this.__data__=[]},q.prototype.delete=function(e){var t=this.__data__,n=$(t,e);return!(n<0)&&(n==t.length-1?t.pop():S.call(t,n,1),!0)},q.prototype.get=function(e){var t=this.__data__,n=$(t,e);return n<0?void 0:t[n][1]},q.prototype.has=function(e){return $(this.__data__,e)>-1},q.prototype.set=function(e,t){var n=this.__data__,r=$(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new D,map:new(U||q),string:new D}},T.prototype.delete=function(e){return L(this,e).delete(e)},T.prototype.get=function(e){return L(this,e).get(e)},T.prototype.has=function(e){return L(this,e).has(e)},T.prototype.set=function(e,t){return L(this,e).set(e,t),this};var F=J((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(H(e))return C?C.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return l.test(e)&&n.push(""),e.replace(p,(function(e,t,r,o){n.push(r?o.replace(d,"$1"):t||e)})),n}));function z(e){if("string"==typeof e||H(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function J(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=e.apply(this,r);return n.cache=i.set(o,a),a};return n.cache=new(J.Cache||T),n}J.Cache=T;var K=Array.isArray;function N(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function H(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==_.call(e)}var G,Z=function(e,t,n){var r=null==e?void 0:A(e,t);return void 0===r?n:r},V="/v1/auth/otp/verify",Q="/v1/auth/otp/signin",W="/v1/auth/otp/signup",X={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Y="/v1/auth/otp/signup-in",ee="/v1/auth/magiclink/verify",te="/v1/auth/magiclink/signin",ne="/v1/auth/magiclink/signup",re="/v1/auth/magiclink/pending-session",oe={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},ie="/v1/auth/magiclink/signup-in",ae="/v1/auth/oauth/authorize",se="/v1/auth/saml/authorize",ce="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",le="/v1/user/totp/update",pe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},de={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},he={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},fe="/v1/flow/start",ge="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(G||(G={}));const ve=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},ye=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),be=e=>void 0===e?void 0:JSON.stringify(e),me=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},we=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const a=((e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>ve().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),ve().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r),s=async r=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:p,method:d,token:h}=s,f=await a((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:p}),{headers:ye(me(t,h),(null==n?void 0:n.baseHeaders)||{},l),method:d,body:be(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(e,{headers:t,queryParams:n,token:r}={})=>s({path:e,headers:t,queryParams:n,body:void 0,method:G.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>s({path:e,headers:n,queryParams:r,body:t,method:G.delete,token:o})}},je=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=r(e);return(new Date).getTime()/1e3>t},ke=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),Ie=async e=>{const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.json();return t.ok?n.data=r:n.error=r,n};var Oe,_e,xe;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Oe||(Oe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(_e||(_e={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(xe||(xe={}));const Pe=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Se=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ue=e=>t=>e.test(t),Re=Ue(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ee=Ue(/^\+[1-9]{1}[0-9]{3,14}$/),Ce=Pe(Re,'"{val}" is not a valid email'),De=Pe(Ee,'"{val}" is not a valid phone number'),qe=Pe((1,e=>e.length>=1),"Minimum length is 1");const Te=Pe((e=>"string"==typeof e),"Input is not a string"),$e=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Se(...e).validate(n[t]))),t(...n)),Ae=e=>[Te(`"${e}" must be a string`),qe(`"${e}" must not be empty`)],Me=e=>[Te(`"${e}" must be a string`),Ce()],Le=e=>[Te(`"${e}" must be a string`),De()];var Be;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Be||(Be={}));const Fe=Ae("identifier"),ze=$e(Fe,Ae("code")),Je=$e(Fe),Ke=$e(Fe,Le("phone")),Ne=$e(Fe,Me("email")),He=e=>({verify:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ze(((t,r)=>Ie(e.post(ke(V,n),{code:r,externalId:t}))))})),{}),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je((t=>Ie(e.post(ke(Q,n),{externalId:t}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je(((t,r)=>Ie(e.post(ke(W,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Je((t=>Ie(e.post(ke(Y,n),{externalId:t}))))})),{}),update:{email:Ne(((t,n,r)=>Ie(e.post(X.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,r,o)=>Ie(e.post(ke(X.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),Ge=Ae("identifier"),Ze=Ae("uri"),Ve=$e(Ae("token")),Qe=$e(Ge,Ze),We=$e(Ae("pendingRef")),Xe=$e(Ge,Le("phone"),Ze),Ye=$e(Ge,Me("email"),Ze),et=e=>({verify:Ve((t=>Ie(e.post(ee,{token:t})))),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(te,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(ie,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r,o)=>Ie(e.post(ke(ne,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:We(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let a;const s=setInterval((async()=>{const n=await e.post(re,{pendingRef:t});n.ok&&(clearInterval(s),a&&clearTimeout(a),r(Ie(Promise.resolve(n))))}),o);a=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(s)}),i)})))),update:{email:Ye(((t,n,r,o)=>Ie(e.post(oe.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o,i)=>Ie(e.post(ke(oe.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),tt=e=>({verify:Ve((t=>Ie(e.post(ee,{token:t})))),signIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(te,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r,o)=>Ie(e.post(ke(ne,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(_e).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,r)=>Ie(e.post(ke(ie,n),{externalId:t,URI:r}))))})),{}),update:{email:Ye(((t,n,r,o)=>Ie(e.post(oe.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xe(((t,r,o,i)=>Ie(e.post(ke(oe.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:et(e)}),nt=$e(Ae("code")),rt=e=>({exchange:nt((t=>Ie(e.get("/v1/auth/exchange",{queryParams:{code:t}}))))});var ot;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ot||(ot={}));const it=e=>Object.assign({start:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.get(ae,{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return Ie(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},rt(e)),at=$e(Ae("flowId")),st=$e(Ae("executionId"),Ae("stepId"),Ae("actionId")),ct=e=>({start:at((t=>Ie(e.post(fe,{flowId:t})))),next:st(((t,n,r,o)=>Ie(e.post(ge,{executionId:t,stepId:n,interactionId:r,input:o}))))}),ut=$e(Ae("tenant")),lt=e=>Object.assign({start:ut((async(t,n,{redirect:r=!1}={})=>{const o=await e.get(se,{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return Ie(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},rt(e)),pt=Ae("identifier"),dt=$e(pt,Ae("code")),ht=$e(pt),ft=$e(pt),gt=e=>({signUp:ht(((t,n)=>Ie(e.post(ue,{externalId:t,user:n})))),verify:dt(((t,n)=>Ie(e.post(ce,{externalId:t,code:n})))),update:ft(((t,n)=>Ie(e.post(le,{externalId:t},{token:n}))))}),vt=Ae("identifier"),yt=Ae("origin"),bt=$e(vt,yt,Ae("name")),mt=$e(vt,yt),wt=$e(vt,yt,Ae("token")),jt=$e(Ae("transactionId"),Ae("response")),kt=e=>({signUp:{start:bt(((t,n,r)=>Ie(e.post(pe.start,{user:{externalId:t,name:r},origin:n})))),finish:jt(((t,n)=>Ie(e.post(pe.finish,{transactionId:t,response:n}))))},signIn:{start:mt(((t,n)=>Ie(e.post(de.start,{externalId:t,origin:n})))),finish:jt(((t,n)=>Ie(e.post(de.finish,{transactionId:t,response:n}))))},update:{start:wt(((t,n,r)=>Ie(e.post(he.start,{externalId:t,origin:n},{token:r})))),finish:jt(((t,n)=>Ie(e.post(he.finish,{transactionId:t,response:n}))))}}),It=$e(Ae("token"));var Ot;const _t=$e([("projectId",Ot=Ae("projectId"),Pe(((e,t)=>e=>Se(...t).validate(Z(e,"projectId")))(0,Ot))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=we({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{otp:He(i),magicLink:tt(i),oauth:it(i),saml:lt(i),totp:gt(i),webauthn:kt(i),flow:ct(i),refresh:e=>Ie(i.get("/v1/auth/refresh",{token:e})),logout:e=>Ie(i.get("/v1/auth/logoutall",{token:e})),isJwtExpired:It(je),httpClient:i};var i}));_t.DeliveryMethods=_e;var xt=function(){return xt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},xt.apply(this,arguments)};function Pt(e,t,n){return void 0===n&&(n=0),t(n).catch((function(r){if(n>=e.maxRetries||!e.shouldRetry(r))throw r;var o,i,a,s,c=(o=e.baseDelay,i=e.maxDelay,a=e.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,a)));return(s=c,new Promise((function(e){return setTimeout(e,s)}))).then((function(){return Pt(e,t,n+1)}))}))}var St="Failed to load the JS script of the agent";function Ut(e){var t,n=e.scriptUrlPattern,r=e.token,o=e.apiKey,i=void 0===o?r:o,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["scriptUrlPattern","token","apiKey"]),s=(t=e,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(t,"scriptUrlPattern")?n:void 0),c=[];return Promise.resolve().then((function(){if(!i||"string"!=typeof i)throw new Error("API key required");return Pt({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(e){return!(e instanceof Error&&"Blocked by CSP"===e.message)}},(function(){var e,t=new Date,n=function(){return c.push({startedAt:t,finishedAt:new Date})},r=function(e,t,n,r){var o,i=document,a="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,c())};i.addEventListener(a,s);var c=function(){return i.removeEventListener(a,s)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),o)return function(){throw new Error("Blocked by CSP")}();throw e}))}))}(e=function(e,t){void 0===t&&(t="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.7.1"):t}))}(i,s),(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(St))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}));return r.then(n,n),r}))})).then((function(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(St);return n.load(xt(xt({},a),{ldi:{attempts:c}}))}))}const Rt="vsid",Et="vrid",Ct=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e],Dt=e=>{const t=Ut({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem(Rt);e||(e=Ct(Rt)),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem(Rt,e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem(Et,r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};
!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=/^\./,h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,f=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,v="object"==typeof a&&a&&a.Object===Object&&a,y="object"==typeof self&&self&&self.Object===Object&&self,b=v||y||Function("return this")();var m,w=Array.prototype,j=Function.prototype,k=Object.prototype,I=b["__core-js_shared__"],O=(m=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+m:"",_=j.toString,x=k.hasOwnProperty,P=k.toString,U=RegExp("^"+_.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=b.Symbol,R=w.splice,E=z(b,"Map"),C=z(Object,"create"),D=S?S.prototype:void 0,q=D?D.toString:void 0;function T(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $(e){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[K(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)?U: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}T.prototype.clear=function(){this.__data__=C?C(null):{}},T.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},T.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},T.prototype.has=function(e){var t=this.__data__;return C?void 0!==t[e]:x.call(t,e)},T.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 T,map:new(E||$),string:new T}},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=N((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Z(e))return q?q.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(h,(function(e,t,r,o){n.push(r?o.replace(f,"$1"):t||e)})),n}));function K(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function N(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(N.Cache||A),n}N.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",he={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},fe={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 be=()=>{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")}},me=(...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}`}},ke=({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=>be().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)),be().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:me(je(t,h),(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==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: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})}},Ie=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,Ue;!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"}(Ue||(Ue={}));const Se=(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}$/),qe=Se(Ce,'"{val}" is not a valid email'),Te=Se(De,'"{val}" is not a valid phone number'),$e=Se((1,e=>e.length>=1),"Minimum length is 1");const Ae=Se((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`),qe()],Fe=e=>[Ae(`"${e}" must be a string`),Te()];var ze;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ze||(ze={}));const Je=Le("identifier"),Ke=Me(Je,Le("code")),Ne=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]:Ke(((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]:Ne((t=>_e(e.post(Oe(X,n),{externalId:t}))))})),{}),signUp:Object.keys(Pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ne(((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]:Ne((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)),ht=Le("identifier"),ft=Me(ht,Le("code")),gt=Me(ht),vt=Me(ht),yt=e=>({signUp:gt(((t,n)=>_e(e.post(pe,{externalId:t,user:n})))),verify:ft(((t,n)=>_e(e.post(le,{externalId:t,code:n})))),update:vt(((t,n)=>_e(e.post(de,{externalId:t},{token:n}))))}),bt=Le("identifier"),mt=Le("origin"),wt=Me(bt,mt,Le("name")),jt=Me(bt,mt),kt=Me(bt,mt,Le("token")),It=Me(Le("transactionId"),Le("response")),Ot=e=>({signUp:{start:wt(((t,n,r)=>_e(e.post(he.start,{user:{externalId:t,name:r},origin:n})))),finish:It(((t,n)=>_e(e.post(he.finish,{transactionId:t,response:n}))))},signIn:{start:jt(((t,n)=>_e(e.post(fe.start,{externalId:t,origin:n})))),finish:It(((t,n)=>_e(e.post(fe.finish,{transactionId:t,response:n}))))},update:{start:kt(((t,n,r)=>_e(e.post(ge.start,{externalId:t,origin:n},{token:r})))),finish:It(((t,n)=>_e(e.post(ge.finish,{transactionId:t,response:n}))))}}),_t=Me(Le("token"));var xt;const Pt=Me([("projectId",xt=Le("projectId"),Se(((e,t)=>e=>Re(...t).validate(Q(e,"projectId")))(0,xt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=ke({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(Ie),httpClient:i};var i}));function Ut(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 Ut(e,t,n+1)}))}))}Pt.DeliveryMethods=Pe;var St="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 Ut({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(St))},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(St);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],qt=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 Tt=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=qt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var a in o)o[a]&&(i+="; "+a,!0!==o[a]&&(i+="="+o[a].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",qt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,qt({},this.attributes,t))},withConverter:function(t){return e(qt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const $t=async e=>{try{const t=await(null==e?void 0:e.json());!function(e){const{sessionJwt:t,refreshJwt:n,cookieDomain:r,cookiePath:o,cookieExpiration:i}=e||{};t&&Tt.set("DS",t,{path:o,domain:r,expires:i,secure:!0}),n&&localStorage.setItem("DSR",n)}((null==t?void 0:t.authInfo)||t)}catch(e){console.error("Could not set tokens from body")}};return e=>{Dt(e.fpKey).get().catch((()=>null));const t=e;return t.hooks={beforeRequest:t=>{var n;return t.queryParams=(n=t.queryParams,Object.assign(Object.assign({},n),{[Rt]:sessionStorage.getItem(Rt)||"",[Et]:sessionStorage.getItem(Et)||""})),e.disableTokensStorage||t.token||(t.token=localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""),t}},e.disableTokensStorage||(t.hooks.afterRequest=async(e,t)=>{$t(t)}),_t(e)}}));
function Tt(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=Tt({},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,"",Tt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Tt({},this.attributes,t))},withConverter:function(t){return e(Tt({},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=async e=>{try{const t=await(null==e?void 0:e.json());!function(e){const{sessionJwt:t,refreshJwt:n,cookieDomain:r,cookiePath:o,cookieExpiration:i}=e||{};t&&$t.set("DS",t,{path:o,domain:r,expires:i,secure:!0}),n&&localStorage&&localStorage.setItem("DSR",n)}((null==t?void 0:t.authInfo)||t)}catch(e){console.error("Could not set tokens from body")}};return e=>{var{persistTokens:n=!0}=e,r=t(e,["persistTokens"]);qt(r.fpKey).get().catch((()=>null));const o=r;return 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=localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""),e}},n&&(o.hooks.afterRequest=async(e,t)=>{At(t)}),Pt(r)}}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@descope/web-js-sdk",
"version": "0.0.1-alpha.3",
"version": "0.0.1-alpha.4",
"main": "dist/cjs/index.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/index.esm.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc