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

@descope/core-js-sdk

Package Overview
Dependencies
Maintainers
4
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.41-alpha.26 to 0.0.41-alpha.27

2

dist/cjs/index.cjs.js

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

"use strict";var e=require("jwt-decode"),t=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e),a=n(t),i={exchange:"/v1/auth/accesskey/exchange"},o={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},c={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},p={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},d={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},l="/v1/auth/refresh",g="/v1/auth/logoutall",h="/v1/auth/deletecookies",v="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};var f;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(f||(f={}));const b=()=>{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")}},y=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>b().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),b().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n},I=(...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,s])=>(e[n]=s,e)),e),e}),{})),k=e=>void 0===e?void 0:JSON.stringify(e),O=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=y(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:c,headers:p,queryParams:d,method:l,token:g}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:d}),{headers:I(O(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.26"},(null==n?void 0:n.baseHeaders)||{},p),method:l,body:k(c),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:f.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.delete,token:a})}};function x(e,t,n){var s;let a=w(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function w(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function U(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function P(e,t){return x(e,t,"permissions")}function R(e,t){return x(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function $(e){const t=await e,n={code:t.status,ok:t.ok,response:t},s=await t.clone().json();return t.ok?n.data=s:n.error=s,n}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),E=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),S=e=>t=>e.test(t),T=S(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),A=S(/^\+[1-9]{1}[0-9]{3,14}$/),D=M(T,'"{val}" is not a valid email'),z=M(A,'"{val}" is not a valid phone number'),J=M((L=1,e=>e.length>=L),"Minimum length is 1");var L;const H=M((e=>"string"==typeof e),"Input is not a string"),C=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>E(...e).validate(n[t]))),t(...n)),N=e=>[H(`"${e}" must be a string`),J(`"${e}" must not be empty`)],Z=e=>[H(`"${e}" must be a string`),D()],B=e=>[H(`"${e}" must be a string`),z()],K=C(N("accessKey")),F=e=>({exchange:K((t=>$(e.post(i.exchange,{},{token:t}))))});var G,_,Q,V,W;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(_||(_={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Q||(Q={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(W||(W={}));const X=N("identifier"),Y=C(X,N("code")),ee=C(X),te=C(X,B("phone")),ne=C(X,Z("email")),se=e=>({verify:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,s)=>$(e.post(q(o.verify,n),{code:s,externalId:t}))))})),{}),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s,a)=>$(e.post(q(o.signIn,n),{externalId:t,loginOptions:s},{token:a}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>$(e.post(q(o.signUp,n),{externalId:t,user:s}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee((t=>$(e.post(q(o.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:ne(((t,n,s)=>$(e.post(o.update.email,{externalId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,a)=>$(e.post(q(o.update.phone,n),{externalId:t,phone:s},{token:a}))))})),{})}}),ae=N("identifier"),ie=N("uri"),oe=C(N("token")),re=C(ae,ie),ue=C(N("pendingRef")),ce=C(ae,B("phone"),ie),pe=C(ae,Z("email"),ie),de=e=>({verify:oe((t=>$(e.post(r.verify,{token:t})))),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a,i)=>$(e.post(q(r.signIn,n),{externalId:t,URI:s,crossDevice:!0,loginOptions:a},{token:i}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s)=>$(e.post(q(r.signUpOrIn,n),{externalId:t,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a)=>$(e.post(q(r.signUp,n),{externalId:t,URI:s,user:a,crossDevice:!0}))))})),{}),waitForSession:ue(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let o;const u=setInterval((async()=>{const n=await e.post(r.session,{pendingRef:t});n.ok&&(clearInterval(u),o&&clearTimeout(o),s($(Promise.resolve(n))))}),a);o=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(u)}),i)})))),update:{email:pe(((t,n,s,a)=>$(e.post(r.update.email,{externalId:t,email:n,URI:s,crossDevice:!0},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ce(((t,s,a,i)=>$(e.post(q(r.update.phone,n),{externalId:t,phone:s,URI:a,crossDevice:!0},{token:i}))))})),{})}}),le=e=>({verify:oe((t=>$(e.post(r.verify,{token:t})))),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a,i)=>$(e.post(q(r.signIn,n),{externalId:t,URI:s,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a)=>$(e.post(q(r.signUp,n),{externalId:t,URI:s,user:a}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s)=>$(e.post(q(r.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:pe(((t,n,s,a)=>$(e.post(r.update.email,{externalId:t,email:n,URI:s},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ce(((t,s,a,i)=>$(e.post(q(r.update.phone,n),{externalId:t,phone:s,URI:a},{token:i}))))})),{})},crossDevice:de(e)});var ge;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ge||(ge={}));const he=C(N("code")),ve=e=>({start:Object.keys(ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const o=await e.post(u.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!o.ok)return $(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r}})),{}),exchange:he((t=>$(e.post(u.exchange,{code:t}))))}),me=C(N("flowId")),fe=C(N("executionId"),N("stepId"),N("interactionId")),be=e=>({start:me(((t,n)=>$(e.post(m.start,{flowId:t,options:n})))),next:fe(((t,n,s,a)=>$(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),ye=C(N("tenant")),Ie=C(N("code")),ke=e=>({start:ye((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(c.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return $(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r})),exchange:Ie((t=>$(e.post(c.exchange,{code:t}))))}),Oe=N("identifier"),je=C(Oe,N("code")),xe=C(Oe),we=C(Oe),Ue=e=>({signUp:xe(((t,n)=>$(e.post(p.signUp,{externalId:t,user:n})))),verify:je(((t,n,s,a)=>$(e.post(p.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:we(((t,n)=>$(e.post(p.update,{externalId:t},{token:n}))))}),Pe=N("identifier"),Re=N("origin"),qe=C(Pe,Re,N("name")),$e=C(Pe,Re),Me=C(Pe,Re,N("token")),Ee=C(N("transactionId"),N("response")),Se=e=>({signUp:{start:qe(((t,n,s)=>$(e.post(d.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Ee(((t,n)=>$(e.post(d.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:$e(((t,n,s,a)=>$(e.post(d.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Ee(((t,n)=>$(e.post(d.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:$e(((t,n)=>$(e.post(d.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Me(((t,n,s)=>$(e.post(d.update.start,{externalId:t,origin:n},{token:s})))),finish:Ee(((t,n)=>$(e.post(d.update.finish,{transactionId:t,response:n}))))}}),Te=C(N("token"));var Ae,De;const ze=C([(Ae="projectId",De=N("projectId"),M(((e,t)=>n=>E(...t).validate(a.default(n,e)))(Ae,De))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=j({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:F(i),otp:se(i),magicLink:le(i),oauth:ve(i),saml:ke(i),totp:Ue(i),webauthn:Se(i),flow:be(i),refresh:e=>$(i.post(l,{},{token:e})),logout:e=>$(i.post(g,{},{token:e})),deleteCookies:e=>$(i.post(h,{},{token:e})),me:e=>$(i.get(v,{token:e})),isJwtExpired:Te(U),getJwtPermissions:Te(P),getJwtRoles:Te(R),httpClient:i};var i}));ze.DeliveryMethods=_,module.exports=ze;
"use strict";var e=require("jwt-decode"),t=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e),a=n(t),i={exchange:"/v1/auth/accesskey/exchange"},o={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},c={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},p={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},d={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},l="/v1/auth/refresh",g="/v1/auth/logout",h="/v1/auth/logoutall",v="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};var f;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(f||(f={}));const b=()=>{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")}},y=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>b().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),b().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n},I=(...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,s])=>(e[n]=s,e)),e),e}),{})),k=e=>void 0===e?void 0:JSON.stringify(e),O=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=y(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:c,headers:p,queryParams:d,method:l,token:g}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:d}),{headers:I(O(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.27"},(null==n?void 0:n.baseHeaders)||{},p),method:l,body:k(c),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:f.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.delete,token:a})}};function x(e,t,n){var s;let a=w(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function w(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function U(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function P(e,t){return x(e,t,"permissions")}function R(e,t){return x(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function $(e){const t=await e,n={code:t.status,ok:t.ok,response:t},s=await t.clone().json();return t.ok?n.data=s:n.error=s,n}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),E=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),S=e=>t=>e.test(t),A=S(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),T=S(/^\+[1-9]{1}[0-9]{3,14}$/),D=M(A,'"{val}" is not a valid email'),z=M(T,'"{val}" is not a valid phone number'),J=M((L=1,e=>e.length>=L),"Minimum length is 1");var L;const H=M((e=>"string"==typeof e),"Input is not a string"),N=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>E(...e).validate(n[t]))),t(...n)),Z=e=>[H(`"${e}" must be a string`),J(`"${e}" must not be empty`)],B=e=>[H(`"${e}" must be a string`),D()],C=e=>[H(`"${e}" must be a string`),z()],K=N(Z("accessKey")),F=e=>({exchange:K((t=>$(e.post(i.exchange,{},{token:t}))))});var G,_,Q,V,W;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(_||(_={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Q||(Q={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(W||(W={}));const X=Z("identifier"),Y=N(X,Z("code")),ee=N(X),te=N(X,C("phone")),ne=N(X,B("email")),se=e=>({verify:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,s)=>$(e.post(q(o.verify,n),{code:s,externalId:t}))))})),{}),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s,a)=>$(e.post(q(o.signIn,n),{externalId:t,loginOptions:s},{token:a}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>$(e.post(q(o.signUp,n),{externalId:t,user:s}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee((t=>$(e.post(q(o.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:ne(((t,n,s)=>$(e.post(o.update.email,{externalId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,a)=>$(e.post(q(o.update.phone,n),{externalId:t,phone:s},{token:a}))))})),{})}}),ae=Z("identifier"),ie=Z("uri"),oe=N(Z("token")),re=N(ae,ie),ue=N(Z("pendingRef")),ce=N(ae,C("phone"),ie),pe=N(ae,B("email"),ie),de=e=>({verify:oe((t=>$(e.post(r.verify,{token:t})))),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a,i)=>$(e.post(q(r.signIn,n),{externalId:t,URI:s,crossDevice:!0,loginOptions:a},{token:i}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s)=>$(e.post(q(r.signUpOrIn,n),{externalId:t,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a)=>$(e.post(q(r.signUp,n),{externalId:t,URI:s,user:a,crossDevice:!0}))))})),{}),waitForSession:ue(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let o;const u=setInterval((async()=>{const n=await e.post(r.session,{pendingRef:t});n.ok&&(clearInterval(u),o&&clearTimeout(o),s($(Promise.resolve(n))))}),a);o=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(u)}),i)})))),update:{email:pe(((t,n,s,a)=>$(e.post(r.update.email,{externalId:t,email:n,URI:s,crossDevice:!0},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ce(((t,s,a,i)=>$(e.post(q(r.update.phone,n),{externalId:t,phone:s,URI:a,crossDevice:!0},{token:i}))))})),{})}}),le=e=>({verify:oe((t=>$(e.post(r.verify,{token:t})))),signIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a,i)=>$(e.post(q(r.signIn,n),{externalId:t,URI:s,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s,a)=>$(e.post(q(r.signUp,n),{externalId:t,URI:s,user:a}))))})),{}),signUpOrIn:Object.keys(_).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:re(((t,s)=>$(e.post(q(r.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:pe(((t,n,s,a)=>$(e.post(r.update.email,{externalId:t,email:n,URI:s},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ce(((t,s,a,i)=>$(e.post(q(r.update.phone,n),{externalId:t,phone:s,URI:a},{token:i}))))})),{})},crossDevice:de(e)});var ge;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ge||(ge={}));const he=N(Z("code")),ve=e=>({start:Object.keys(ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const o=await e.post(u.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!o.ok)return $(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r}})),{}),exchange:he((t=>$(e.post(u.exchange,{code:t}))))}),me=N(Z("flowId")),fe=N(Z("executionId"),Z("stepId"),Z("interactionId")),be=e=>({start:me(((t,n)=>$(e.post(m.start,{flowId:t,options:n})))),next:fe(((t,n,s,a)=>$(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),ye=N(Z("tenant")),Ie=N(Z("code")),ke=e=>({start:ye((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(c.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return $(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r})),exchange:Ie((t=>$(e.post(c.exchange,{code:t}))))}),Oe=Z("identifier"),je=N(Oe,Z("code")),xe=N(Oe),we=N(Oe),Ue=e=>({signUp:xe(((t,n)=>$(e.post(p.signUp,{externalId:t,user:n})))),verify:je(((t,n,s,a)=>$(e.post(p.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:we(((t,n)=>$(e.post(p.update,{externalId:t},{token:n}))))}),Pe=Z("identifier"),Re=Z("origin"),qe=N(Pe,Re,Z("name")),$e=N(Pe,Re),Me=N(Pe,Re,Z("token")),Ee=N(Z("transactionId"),Z("response")),Se=e=>({signUp:{start:qe(((t,n,s)=>$(e.post(d.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Ee(((t,n)=>$(e.post(d.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:$e(((t,n,s,a)=>$(e.post(d.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Ee(((t,n)=>$(e.post(d.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:$e(((t,n)=>$(e.post(d.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Me(((t,n,s)=>$(e.post(d.update.start,{externalId:t,origin:n},{token:s})))),finish:Ee(((t,n)=>$(e.post(d.update.finish,{transactionId:t,response:n}))))}}),Ae=N(Z("token"));var Te,De;const ze=N([(Te="projectId",De=Z("projectId"),M(((e,t)=>n=>E(...t).validate(a.default(n,e)))(Te,De))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=j({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:F(i),otp:se(i),magicLink:le(i),oauth:ve(i),saml:ke(i),totp:Ue(i),webauthn:Se(i),flow:be(i),refresh:e=>$(i.post(l,{},{token:e})),logout:e=>$(i.post(g,{},{token:e})),logoutAll:e=>$(i.post(h,{},{token:e})),me:e=>$(i.get(v,{token:e})),isJwtExpired:Ae(U),getJwtPermissions:Ae(P),getJwtRoles:Ae(R),httpClient:i};var i}));ze.DeliveryMethods=_,module.exports=ze;
//# sourceMappingURL=index.cjs.js.map

@@ -312,3 +312,3 @@ declare type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;

logout: (token?: string) => Promise<SdkResponse<never>>;
deleteCookies: (token?: string) => Promise<SdkResponse<never>>;
logoutAll: (token?: string) => Promise<SdkResponse<never>>;
me: (token?: string) => Promise<SdkResponse<UserResponse>>;

@@ -315,0 +315,0 @@ isJwtExpired: (token: string) => boolean;

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

import e from"jwt-decode";import t from"lodash.get";var n={exchange:"/v1/auth/accesskey/exchange"},s={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},a={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},o={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},r={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},c={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},p="/v1/auth/refresh",u="/v1/auth/logoutall",d="/v1/auth/deletecookies",g="/v1/auth/me",l={start:"/v1/flow/start",next:"/v1/flow/next"};var h;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(h||(h={}));const m=()=>{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")}},v=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>m().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),m().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n},f=(...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,s])=>(e[n]=s,e)),e),e}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),I=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=v(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:c,body:p,headers:u,queryParams:d,method:g,token:l}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:c,baseUrl:e,queryParams:d}),{headers:f(I(t,l),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.26"},(null==n?void 0:n.baseHeaders)||{},u),method:g,body:b(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:h.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.delete,token:a})}};function k(e,t,n){var s;let a=O(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function O(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function j(e){const{exp:t}=O(e);return(new Date).getTime()/1e3>t}function x(e,t){return k(e,t,"permissions")}function w(e,t){return k(e,t,"roles")}const U=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function P(e){const t=await e,n={code:t.status,ok:t.ok,response:t},s=await t.clone().json();return t.ok?n.data=s:n.error=s,n}const R=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),$=e=>t=>e.test(t),M=$(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),E=$(/^\+[1-9]{1}[0-9]{3,14}$/),S=R(M,'"{val}" is not a valid email'),T=R(E,'"{val}" is not a valid phone number'),A=R((D=1,e=>e.length>=D),"Minimum length is 1");var D;const z=R((e=>"string"==typeof e),"Input is not a string"),J=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>q(...e).validate(n[t]))),t(...n)),L=e=>[z(`"${e}" must be a string`),A(`"${e}" must not be empty`)],H=e=>[z(`"${e}" must be a string`),S()],C=e=>[z(`"${e}" must be a string`),T()],N=J(L("accessKey")),Z=e=>({exchange:N((t=>P(e.post(n.exchange,{},{token:t}))))});var B,K,F,G,_;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(B||(B={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(F||(F={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(_||(_={}));const Q=L("identifier"),V=J(Q,L("code")),W=J(Q),X=J(Q,C("phone")),Y=J(Q,H("email")),ee=e=>({verify:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:V(((t,a)=>P(e.post(U(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,a,i)=>P(e.post(U(s.signIn,n),{externalId:t,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,a)=>P(e.post(U(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W((t=>P(e.post(U(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:Y(((t,n,a)=>P(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(B).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a,i)=>P(e.post(U(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),te=L("identifier"),ne=L("uri"),se=J(L("token")),ae=J(te,ne),ie=J(L("pendingRef")),oe=J(te,C("phone"),ne),re=J(te,H("email"),ne),ce=e=>({verify:se((t=>P(e.post(a.verify,{token:t})))),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i,o)=>P(e.post(U(a.signIn,n),{externalId:t,URI:s,crossDevice:!0,loginOptions:i},{token:o}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s)=>P(e.post(U(a.signUpOrIn,n),{externalId:t,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i)=>P(e.post(U(a.signUp,n),{externalId:t,URI:s,user:i,crossDevice:!0}))))})),{}),waitForSession:ie(((t,n)=>new Promise((s=>{const{pollingIntervalMs:i,timeoutMs:o}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let r;const c=setInterval((async()=>{const n=await e.post(a.session,{pendingRef:t});n.ok&&(clearInterval(c),r&&clearTimeout(r),s(P(Promise.resolve(n))))}),i);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${o}ms`,code:"0"},ok:!1}),clearInterval(c)}),o)})))),update:{email:re(((t,n,s,i)=>P(e.post(a.update.email,{externalId:t,email:n,URI:s,crossDevice:!0},{token:i})))),phone:Object.keys(B).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>P(e.post(U(a.update.phone,n),{externalId:t,phone:s,URI:i,crossDevice:!0},{token:o}))))})),{})}}),pe=e=>({verify:se((t=>P(e.post(a.verify,{token:t})))),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i,o)=>P(e.post(U(a.signIn,n),{externalId:t,URI:s,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i)=>P(e.post(U(a.signUp,n),{externalId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s)=>P(e.post(U(a.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>P(e.post(a.update.email,{externalId:t,email:n,URI:s},{token:i})))),phone:Object.keys(B).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>P(e.post(U(a.update.phone,n),{externalId:t,phone:s,URI:i},{token:o}))))})),{})},crossDevice:ce(e)});var ue;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ue||(ue={}));const de=J(L("code")),ge=e=>({start:Object.keys(ue).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,o)=>{const r=await e.post(i.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o});if(!s||!r.ok)return P(Promise.resolve(r));const{url:c}=await r.json();window.location.href=c}})),{}),exchange:de((t=>P(e.post(i.exchange,{code:t}))))}),le=J(L("flowId")),he=J(L("executionId"),L("stepId"),L("interactionId")),me=e=>({start:le(((t,n)=>P(e.post(l.start,{flowId:t,options:n})))),next:he(((t,n,s,a)=>P(e.post(l.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),ve=J(L("tenant")),fe=J(L("code")),be=e=>({start:ve((async(t,n,{redirect:s=!1}={},a,i)=>{const r=await e.post(o.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!r.ok)return P(Promise.resolve(r));const{url:c}=await r.json();window.location.href=c})),exchange:fe((t=>P(e.post(o.exchange,{code:t}))))}),Ie=L("identifier"),ye=J(Ie,L("code")),ke=J(Ie),Oe=J(Ie),je=e=>({signUp:ke(((t,n)=>P(e.post(r.signUp,{externalId:t,user:n})))),verify:ye(((t,n,s,a)=>P(e.post(r.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Oe(((t,n)=>P(e.post(r.update,{externalId:t},{token:n}))))}),xe=L("identifier"),we=L("origin"),Ue=J(xe,we,L("name")),Pe=J(xe,we),Re=J(xe,we,L("token")),qe=J(L("transactionId"),L("response")),$e=e=>({signUp:{start:Ue(((t,n,s)=>P(e.post(c.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:qe(((t,n)=>P(e.post(c.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Pe(((t,n,s,a)=>P(e.post(c.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:qe(((t,n)=>P(e.post(c.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Pe(((t,n)=>P(e.post(c.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Re(((t,n,s)=>P(e.post(c.update.start,{externalId:t,origin:n},{token:s})))),finish:qe(((t,n)=>P(e.post(c.update.finish,{transactionId:t,response:n}))))}}),Me=J(L("token"));var Ee,Se;const Te=J([(Ee="projectId",Se=L("projectId"),R(((e,n)=>s=>q(...n).validate(t(s,e)))(Ee,Se))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:Z(i),otp:ee(i),magicLink:pe(i),oauth:ge(i),saml:be(i),totp:je(i),webauthn:$e(i),flow:me(i),refresh:e=>P(i.post(p,{},{token:e})),logout:e=>P(i.post(u,{},{token:e})),deleteCookies:e=>P(i.post(d,{},{token:e})),me:e=>P(i.get(g,{token:e})),isJwtExpired:Me(j),getJwtPermissions:Me(x),getJwtRoles:Me(w),httpClient:i};var i}));Te.DeliveryMethods=K;export{Te as default};
import e from"jwt-decode";import t from"lodash.get";var n={exchange:"/v1/auth/accesskey/exchange"},s={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},a={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},o={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},r={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},c={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},u="/v1/auth/refresh",p="/v1/auth/logout",d="/v1/auth/logoutall",g="/v1/auth/me",l={start:"/v1/flow/start",next:"/v1/flow/next"};var h;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(h||(h={}));const m=()=>{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")}},v=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>m().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),m().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n},f=(...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,s])=>(e[n]=s,e)),e),e}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),I=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=v(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:c,body:u,headers:p,queryParams:d,method:g,token:l}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:c,baseUrl:e,queryParams:d}),{headers:f(I(t,l),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.27"},(null==n?void 0:n.baseHeaders)||{},p),method:g,body:b(u),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:h.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:h.delete,token:a})}};function k(e,t,n){var s;let a=O(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function O(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function j(e){const{exp:t}=O(e);return(new Date).getTime()/1e3>t}function x(e,t){return k(e,t,"permissions")}function w(e,t){return k(e,t,"roles")}const U=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function P(e){const t=await e,n={code:t.status,ok:t.ok,response:t},s=await t.clone().json();return t.ok?n.data=s:n.error=s,n}const R=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),$=e=>t=>e.test(t),M=$(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),E=$(/^\+[1-9]{1}[0-9]{3,14}$/),S=R(M,'"{val}" is not a valid email'),A=R(E,'"{val}" is not a valid phone number'),T=R((D=1,e=>e.length>=D),"Minimum length is 1");var D;const z=R((e=>"string"==typeof e),"Input is not a string"),J=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>q(...e).validate(n[t]))),t(...n)),L=e=>[z(`"${e}" must be a string`),T(`"${e}" must not be empty`)],H=e=>[z(`"${e}" must be a string`),S()],N=e=>[z(`"${e}" must be a string`),A()],Z=J(L("accessKey")),B=e=>({exchange:Z((t=>P(e.post(n.exchange,{},{token:t}))))});var C,K,F,G,_;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(C||(C={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(F||(F={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(_||(_={}));const Q=L("identifier"),V=J(Q,L("code")),W=J(Q),X=J(Q,N("phone")),Y=J(Q,H("email")),ee=e=>({verify:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:V(((t,a)=>P(e.post(U(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,a,i)=>P(e.post(U(s.signIn,n),{externalId:t,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,a)=>P(e.post(U(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W((t=>P(e.post(U(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:Y(((t,n,a)=>P(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(C).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a,i)=>P(e.post(U(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),te=L("identifier"),ne=L("uri"),se=J(L("token")),ae=J(te,ne),ie=J(L("pendingRef")),oe=J(te,N("phone"),ne),re=J(te,H("email"),ne),ce=e=>({verify:se((t=>P(e.post(a.verify,{token:t})))),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i,o)=>P(e.post(U(a.signIn,n),{externalId:t,URI:s,crossDevice:!0,loginOptions:i},{token:o}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s)=>P(e.post(U(a.signUpOrIn,n),{externalId:t,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i)=>P(e.post(U(a.signUp,n),{externalId:t,URI:s,user:i,crossDevice:!0}))))})),{}),waitForSession:ie(((t,n)=>new Promise((s=>{const{pollingIntervalMs:i,timeoutMs:o}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let r;const c=setInterval((async()=>{const n=await e.post(a.session,{pendingRef:t});n.ok&&(clearInterval(c),r&&clearTimeout(r),s(P(Promise.resolve(n))))}),i);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${o}ms`,code:"0"},ok:!1}),clearInterval(c)}),o)})))),update:{email:re(((t,n,s,i)=>P(e.post(a.update.email,{externalId:t,email:n,URI:s,crossDevice:!0},{token:i})))),phone:Object.keys(C).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>P(e.post(U(a.update.phone,n),{externalId:t,phone:s,URI:i,crossDevice:!0},{token:o}))))})),{})}}),ue=e=>({verify:se((t=>P(e.post(a.verify,{token:t})))),signIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i,o)=>P(e.post(U(a.signIn,n),{externalId:t,URI:s,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i)=>P(e.post(U(a.signUp,n),{externalId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s)=>P(e.post(U(a.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>P(e.post(a.update.email,{externalId:t,email:n,URI:s},{token:i})))),phone:Object.keys(C).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>P(e.post(U(a.update.phone,n),{externalId:t,phone:s,URI:i},{token:o}))))})),{})},crossDevice:ce(e)});var pe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(pe||(pe={}));const de=J(L("code")),ge=e=>({start:Object.keys(pe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,o)=>{const r=await e.post(i.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o});if(!s||!r.ok)return P(Promise.resolve(r));const{url:c}=await r.json();window.location.href=c}})),{}),exchange:de((t=>P(e.post(i.exchange,{code:t}))))}),le=J(L("flowId")),he=J(L("executionId"),L("stepId"),L("interactionId")),me=e=>({start:le(((t,n)=>P(e.post(l.start,{flowId:t,options:n})))),next:he(((t,n,s,a)=>P(e.post(l.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),ve=J(L("tenant")),fe=J(L("code")),be=e=>({start:ve((async(t,n,{redirect:s=!1}={},a,i)=>{const r=await e.post(o.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!r.ok)return P(Promise.resolve(r));const{url:c}=await r.json();window.location.href=c})),exchange:fe((t=>P(e.post(o.exchange,{code:t}))))}),Ie=L("identifier"),ye=J(Ie,L("code")),ke=J(Ie),Oe=J(Ie),je=e=>({signUp:ke(((t,n)=>P(e.post(r.signUp,{externalId:t,user:n})))),verify:ye(((t,n,s,a)=>P(e.post(r.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Oe(((t,n)=>P(e.post(r.update,{externalId:t},{token:n}))))}),xe=L("identifier"),we=L("origin"),Ue=J(xe,we,L("name")),Pe=J(xe,we),Re=J(xe,we,L("token")),qe=J(L("transactionId"),L("response")),$e=e=>({signUp:{start:Ue(((t,n,s)=>P(e.post(c.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:qe(((t,n)=>P(e.post(c.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Pe(((t,n,s,a)=>P(e.post(c.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:qe(((t,n)=>P(e.post(c.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Pe(((t,n)=>P(e.post(c.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Re(((t,n,s)=>P(e.post(c.update.start,{externalId:t,origin:n},{token:s})))),finish:qe(((t,n)=>P(e.post(c.update.finish,{transactionId:t,response:n}))))}}),Me=J(L("token"));var Ee,Se;const Ae=J([(Ee="projectId",Se=L("projectId"),R(((e,n)=>s=>q(...n).validate(t(s,e)))(Ee,Se))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:B(i),otp:ee(i),magicLink:ue(i),oauth:ge(i),saml:be(i),totp:je(i),webauthn:$e(i),flow:me(i),refresh:e=>P(i.post(u,{},{token:e})),logout:e=>P(i.post(p,{},{token:e})),logoutAll:e=>P(i.post(d,{},{token:e})),me:e=>P(i.get(g,{token:e})),isJwtExpired:Me(j),getJwtPermissions:Me(x),getJwtRoles:Me(w),httpClient:i};var i}));Ae.DeliveryMethods=K;export{Ae as default};
//# sourceMappingURL=index.esm.js.map

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

!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={exchange:"/v1/auth/accesskey/exchange"},t={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},n={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},r={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},o={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},s={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},i={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},a="/v1/auth/refresh",c="/v1/auth/logoutall",u="/v1/auth/deletecookies",p="/v1/auth/me",l={start:"/v1/flow/start",next:"/v1/flow/next"};const d=1e3,h=6e5;var g;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(g||(g={}));const f=()=>{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")}},v=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>f().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)),f().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n},y=(...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}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),m=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},I=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:s})=>{const i=v(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:p,queryParams:l,method:d,token:h}=a,g=await i((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:l}),{headers:y(m(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.26"},(null==n?void 0:n.baseHeaders)||{},p),method:d,body:b(u),credentials:s||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:r}={})=>a({path:e,headers:t,queryParams:n,body:void 0,method:g.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.delete,token:o})}};function k(e){this.message=e}k.prototype=new Error,k.prototype.name="InvalidCharacterError";var w="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new k("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,i="";r=t.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?i+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return i};function O(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(w(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 w(t)}}function j(e){this.message=e}function _(e,t,n){var r;let o=x(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const s=o[n];return Array.isArray(s)?s:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return function(e,t){if("string"!=typeof e)throw new j("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(O(e.split(".")[n]))}catch(e){throw new j("Invalid token specified: "+e.message)}}(e)}function U(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function P(e,t){return _(e,t,"permissions")}function R(e,t){return _(e,t,"roles")}j.prototype=new Error,j.prototype.name="InvalidTokenError";const S=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function $(e){const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.clone().json();return t.ok?n.data=r:n.error=r,n}const E=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A="__lodash_hash_undefined__",M="[object Function]",C="[object GeneratorFunction]",D=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,z=/^\./,L=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,F=/\\(\\)?/g,H=/^\[object .+?Constructor\]$/,N="object"==typeof T&&T&&T.Object===Object&&T,Z="object"==typeof self&&self&&self.Object===Object&&self,B=N||Z||Function("return this")();var G,K=Array.prototype,Q=Function.prototype,V=Object.prototype,W=B["__core-js_shared__"],X=(G=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",Y=Q.toString,ee=V.hasOwnProperty,te=V.toString,ne=RegExp("^"+Y.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=B.Symbol,oe=K.splice,se=ve(B,"Map"),ie=ve(Object,"create"),ae=re?re.prototype:void 0,ce=ae?ae.toString:void 0;function ue(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 pe(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 le(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 de(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 he(e,t){var n;t=function(e,t){if(Ie(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||we(e))return!0;return J.test(e)||!D.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Ie(n=t)?n:ye(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[be(t[r++])];return r&&r==o?e:void 0}function ge(e){if(!ke(e)||(t=e,X&&X in t))return!1;var t,n=function(e){var t=ke(e)?te.call(e):"";return t==M||t==C}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?ne:H;return n.test(function(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function fe(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 ve(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return ge(n)?n:void 0}ue.prototype.clear=function(){this.__data__=ie?ie(null):{}},ue.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ue.prototype.get=function(e){var t=this.__data__;if(ie){var n=t[e];return n===A?void 0:n}return ee.call(t,e)?t[e]:void 0},ue.prototype.has=function(e){var t=this.__data__;return ie?void 0!==t[e]:ee.call(t,e)},ue.prototype.set=function(e,t){return this.__data__[e]=ie&&void 0===t?A:t,this},pe.prototype.clear=function(){this.__data__=[]},pe.prototype.delete=function(e){var t=this.__data__,n=de(t,e);return!(n<0)&&(n==t.length-1?t.pop():oe.call(t,n,1),!0)},pe.prototype.get=function(e){var t=this.__data__,n=de(t,e);return n<0?void 0:t[n][1]},pe.prototype.has=function(e){return de(this.__data__,e)>-1},pe.prototype.set=function(e,t){var n=this.__data__,r=de(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},le.prototype.clear=function(){this.__data__={hash:new ue,map:new(se||pe),string:new ue}},le.prototype.delete=function(e){return fe(this,e).delete(e)},le.prototype.get=function(e){return fe(this,e).get(e)},le.prototype.has=function(e){return fe(this,e).has(e)},le.prototype.set=function(e,t){return fe(this,e).set(e,t),this};var ye=me((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(we(e))return ce?ce.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return z.test(e)&&n.push(""),e.replace(L,(function(e,t,r,o){n.push(r?o.replace(F,"$1"):t||e)})),n}));function be(e){if("string"==typeof e||we(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function me(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],s=n.cache;if(s.has(o))return s.get(o);var i=e.apply(this,r);return n.cache=s.set(o,i),i};return n.cache=new(me.Cache||le),n}me.Cache=le;var Ie=Array.isArray;function ke(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function we(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==te.call(e)}var Oe=function(e,t,n){var r=null==e?void 0:he(e,t);return void 0===r?n:r};const je=e=>t=>e.test(t),_e=je(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),xe=je(/^\+[1-9]{1}[0-9]{3,14}$/),Ue=E(_e,'"{val}" is not a valid email'),Pe=E(xe,'"{val}" is not a valid phone number'),Re=E((Se=1,e=>e.length>=Se),"Minimum length is 1");var Se;const $e=E((e=>"string"==typeof e),"Input is not a string"),Ee=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>q(...e).validate(n[t]))),t(...n)),qe=e=>[$e(`"${e}" must be a string`),Re(`"${e}" must not be empty`)],Te=e=>[$e(`"${e}" must be a string`),Ue()],Ae=e=>[$e(`"${e}" must be a string`),Pe()],Me=Ee(qe("accessKey")),Ce=t=>({exchange:Me((n=>$(t.post(e.exchange,{},{token:n}))))});var De,Je,ze,Le,Fe;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(De||(De={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Je||(Je={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ze||(ze={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Le||(Le={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Fe||(Fe={}));const He=qe("identifier"),Ne=Ee(He,qe("code")),Ze=Ee(He),Be=Ee(He,Ae("phone")),Ge=Ee(He,Te("email")),Ke=e=>({verify:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>$(e.post(S(t.verify,r),{code:o,externalId:n}))))})),{}),signIn:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,o,s)=>$(e.post(S(t.signIn,r),{externalId:n,loginOptions:o},{token:s}))))})),{}),signUp:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,o)=>$(e.post(S(t.signUp,r),{externalId:n,user:o}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze((n=>$(e.post(S(t.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:Ge(((n,r,o)=>$(e.post(t.update.email,{externalId:n,email:r},{token:o})))),phone:Object.keys(De).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,s)=>$(e.post(S(t.update.phone,r),{externalId:n,phone:o},{token:s}))))})),{})}}),Qe=qe("identifier"),Ve=qe("uri"),We=Ee(qe("token")),Xe=Ee(Qe,Ve),Ye=Ee(qe("pendingRef")),et=Ee(Qe,Ae("phone"),Ve),tt=Ee(Qe,Te("email"),Ve),nt=e=>({verify:We((t=>$(e.post(n.verify,{token:t})))),signIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s,i)=>$(e.post(S(n.signIn,r),{externalId:t,URI:o,crossDevice:!0,loginOptions:s},{token:i}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o)=>$(e.post(S(n.signUpOrIn,r),{externalId:t,URI:o,crossDevice:!0}))))})),{}),signUp:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s)=>$(e.post(S(n.signUp,r),{externalId:t,URI:o,user:s,crossDevice:!0}))))})),{}),waitForSession:Ye(((t,r)=>new Promise((o=>{const{pollingIntervalMs:s,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||d,d),timeoutMs:Math.min(t||h,h)}))(r);let a;const c=setInterval((async()=>{const r=await e.post(n.session,{pendingRef:t});r.ok&&(clearInterval(c),a&&clearTimeout(a),o($(Promise.resolve(r))))}),s);a=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(c)}),i)})))),update:{email:tt(((t,r,o,s)=>$(e.post(n.update.email,{externalId:t,email:r,URI:o,crossDevice:!0},{token:s})))),phone:Object.keys(De).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:et(((t,o,s,i)=>$(e.post(S(n.update.phone,r),{externalId:t,phone:o,URI:s,crossDevice:!0},{token:i}))))})),{})}}),rt=e=>({verify:We((t=>$(e.post(n.verify,{token:t})))),signIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s,i)=>$(e.post(S(n.signIn,r),{externalId:t,URI:o,loginOptions:s},{token:i}))))})),{}),signUp:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s)=>$(e.post(S(n.signUp,r),{externalId:t,URI:o,user:s}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o)=>$(e.post(S(n.signUpOrIn,r),{externalId:t,URI:o}))))})),{}),update:{email:tt(((t,r,o,s)=>$(e.post(n.update.email,{externalId:t,email:r,URI:o},{token:s})))),phone:Object.keys(De).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:et(((t,o,s,i)=>$(e.post(S(n.update.phone,r),{externalId:t,phone:o,URI:s},{token:i}))))})),{})},crossDevice:nt(e)});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 st=Ee(qe("code")),it=e=>({start:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:o=!1}={},s,i)=>{const a=await e.post(r.start,s||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!o||!a.ok)return $(Promise.resolve(a));const{url:c}=await a.json();window.location.href=c}})),{}),exchange:st((t=>$(e.post(r.exchange,{code:t}))))}),at=Ee(qe("flowId")),ct=Ee(qe("executionId"),qe("stepId"),qe("interactionId")),ut=e=>({start:at(((t,n)=>$(e.post(l.start,{flowId:t,options:n})))),next:ct(((t,n,r,o)=>$(e.post(l.next,{executionId:t,stepId:n,interactionId:r,input:o}))))}),pt=Ee(qe("tenant")),lt=Ee(qe("code")),dt=e=>({start:pt((async(t,n,{redirect:r=!1}={},s,i)=>{const a=await e.post(o.start,s||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!r||!a.ok)return $(Promise.resolve(a));const{url:c}=await a.json();window.location.href=c})),exchange:lt((t=>$(e.post(o.exchange,{code:t}))))}),ht=qe("identifier"),gt=Ee(ht,qe("code")),ft=Ee(ht),vt=Ee(ht),yt=e=>({signUp:ft(((t,n)=>$(e.post(s.signUp,{externalId:t,user:n})))),verify:gt(((t,n,r,o)=>$(e.post(s.verify,{externalId:t,code:n,loginOptions:r},{token:o})))),update:vt(((t,n)=>$(e.post(s.update,{externalId:t},{token:n}))))}),bt=qe("identifier"),mt=qe("origin"),It=Ee(bt,mt,qe("name")),kt=Ee(bt,mt),wt=Ee(bt,mt,qe("token")),Ot=Ee(qe("transactionId"),qe("response")),jt=e=>({signUp:{start:It(((t,n,r)=>$(e.post(i.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:Ot(((t,n)=>$(e.post(i.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:kt(((t,n,r,o)=>$(e.post(i.signIn.start,{externalId:t,origin:n,loginOptions:r},{token:o})))),finish:Ot(((t,n)=>$(e.post(i.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:kt(((t,n)=>$(e.post(i.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:wt(((t,n,r)=>$(e.post(i.update.start,{externalId:t,origin:n},{token:r})))),finish:Ot(((t,n)=>$(e.post(i.update.finish,{transactionId:t,response:n}))))}}),_t=Ee(qe("token"));var xt,Ut;const Pt=Ee([(xt="projectId",Ut=qe("projectId"),E(((e,t)=>n=>q(...t).validate(Oe(n,e)))(xt,Ut))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return s=I({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:Ce(s),otp:Ke(s),magicLink:rt(s),oauth:it(s),saml:dt(s),totp:yt(s),webauthn:jt(s),flow:ut(s),refresh:e=>$(s.post(a,{},{token:e})),logout:e=>$(s.post(c,{},{token:e})),deleteCookies:e=>$(s.post(u,{},{token:e})),me:e=>$(s.get(p,{token:e})),isJwtExpired:_t(U),getJwtPermissions:_t(P),getJwtRoles:_t(R),httpClient:s};var s}));return Pt.DeliveryMethods=Je,Pt}));
!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={exchange:"/v1/auth/accesskey/exchange"},t={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},n={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},r={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},o={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},s={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},i={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},a="/v1/auth/refresh",c="/v1/auth/logout",u="/v1/auth/logoutall",p="/v1/auth/me",l={start:"/v1/flow/start",next:"/v1/flow/next"};const d=1e3,h=6e5;var g;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(g||(g={}));const f=()=>{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")}},v=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>f().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)),f().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n},y=(...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}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),m=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},I=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:s})=>{const i=v(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:p,queryParams:l,method:d,token:h}=a,g=await i((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:l}),{headers:y(m(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.27"},(null==n?void 0:n.baseHeaders)||{},p),method:d,body:b(u),credentials:s||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:r}={})=>a({path:e,headers:t,queryParams:n,body:void 0,method:g.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:g.delete,token:o})}};function k(e){this.message=e}k.prototype=new Error,k.prototype.name="InvalidCharacterError";var w="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new k("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,i="";r=t.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?i+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return i};function O(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(w(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 w(t)}}function j(e){this.message=e}function _(e,t,n){var r;let o=x(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const s=o[n];return Array.isArray(s)?s:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return function(e,t){if("string"!=typeof e)throw new j("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(O(e.split(".")[n]))}catch(e){throw new j("Invalid token specified: "+e.message)}}(e)}function U(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function P(e,t){return _(e,t,"permissions")}function R(e,t){return _(e,t,"roles")}j.prototype=new Error,j.prototype.name="InvalidTokenError";const S=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function $(e){const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.clone().json();return t.ok?n.data=r:n.error=r,n}const E=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A="__lodash_hash_undefined__",M="[object Function]",C="[object GeneratorFunction]",D=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,z=/^\./,L=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,F=/\\(\\)?/g,H=/^\[object .+?Constructor\]$/,N="object"==typeof T&&T&&T.Object===Object&&T,Z="object"==typeof self&&self&&self.Object===Object&&self,B=N||Z||Function("return this")();var G,K=Array.prototype,Q=Function.prototype,V=Object.prototype,W=B["__core-js_shared__"],X=(G=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",Y=Q.toString,ee=V.hasOwnProperty,te=V.toString,ne=RegExp("^"+Y.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=B.Symbol,oe=K.splice,se=ve(B,"Map"),ie=ve(Object,"create"),ae=re?re.prototype:void 0,ce=ae?ae.toString:void 0;function ue(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 pe(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 le(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 de(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 he(e,t){var n;t=function(e,t){if(Ie(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||we(e))return!0;return J.test(e)||!D.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Ie(n=t)?n:ye(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[be(t[r++])];return r&&r==o?e:void 0}function ge(e){if(!ke(e)||(t=e,X&&X in t))return!1;var t,n=function(e){var t=ke(e)?te.call(e):"";return t==M||t==C}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?ne:H;return n.test(function(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function fe(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 ve(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return ge(n)?n:void 0}ue.prototype.clear=function(){this.__data__=ie?ie(null):{}},ue.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ue.prototype.get=function(e){var t=this.__data__;if(ie){var n=t[e];return n===A?void 0:n}return ee.call(t,e)?t[e]:void 0},ue.prototype.has=function(e){var t=this.__data__;return ie?void 0!==t[e]:ee.call(t,e)},ue.prototype.set=function(e,t){return this.__data__[e]=ie&&void 0===t?A:t,this},pe.prototype.clear=function(){this.__data__=[]},pe.prototype.delete=function(e){var t=this.__data__,n=de(t,e);return!(n<0)&&(n==t.length-1?t.pop():oe.call(t,n,1),!0)},pe.prototype.get=function(e){var t=this.__data__,n=de(t,e);return n<0?void 0:t[n][1]},pe.prototype.has=function(e){return de(this.__data__,e)>-1},pe.prototype.set=function(e,t){var n=this.__data__,r=de(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},le.prototype.clear=function(){this.__data__={hash:new ue,map:new(se||pe),string:new ue}},le.prototype.delete=function(e){return fe(this,e).delete(e)},le.prototype.get=function(e){return fe(this,e).get(e)},le.prototype.has=function(e){return fe(this,e).has(e)},le.prototype.set=function(e,t){return fe(this,e).set(e,t),this};var ye=me((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(we(e))return ce?ce.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return z.test(e)&&n.push(""),e.replace(L,(function(e,t,r,o){n.push(r?o.replace(F,"$1"):t||e)})),n}));function be(e){if("string"==typeof e||we(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function me(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],s=n.cache;if(s.has(o))return s.get(o);var i=e.apply(this,r);return n.cache=s.set(o,i),i};return n.cache=new(me.Cache||le),n}me.Cache=le;var Ie=Array.isArray;function ke(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function we(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==te.call(e)}var Oe=function(e,t,n){var r=null==e?void 0:he(e,t);return void 0===r?n:r};const je=e=>t=>e.test(t),_e=je(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),xe=je(/^\+[1-9]{1}[0-9]{3,14}$/),Ue=E(_e,'"{val}" is not a valid email'),Pe=E(xe,'"{val}" is not a valid phone number'),Re=E((Se=1,e=>e.length>=Se),"Minimum length is 1");var Se;const $e=E((e=>"string"==typeof e),"Input is not a string"),Ee=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>q(...e).validate(n[t]))),t(...n)),qe=e=>[$e(`"${e}" must be a string`),Re(`"${e}" must not be empty`)],Te=e=>[$e(`"${e}" must be a string`),Ue()],Ae=e=>[$e(`"${e}" must be a string`),Pe()],Me=Ee(qe("accessKey")),Ce=t=>({exchange:Me((n=>$(t.post(e.exchange,{},{token:n}))))});var De,Je,ze,Le,Fe;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(De||(De={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Je||(Je={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ze||(ze={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(Le||(Le={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Fe||(Fe={}));const He=qe("identifier"),Ne=Ee(He,qe("code")),Ze=Ee(He),Be=Ee(He,Ae("phone")),Ge=Ee(He,Te("email")),Ke=e=>({verify:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>$(e.post(S(t.verify,r),{code:o,externalId:n}))))})),{}),signIn:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,o,s)=>$(e.post(S(t.signIn,r),{externalId:n,loginOptions:o},{token:s}))))})),{}),signUp:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,o)=>$(e.post(S(t.signUp,r),{externalId:n,user:o}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze((n=>$(e.post(S(t.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:Ge(((n,r,o)=>$(e.post(t.update.email,{externalId:n,email:r},{token:o})))),phone:Object.keys(De).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,s)=>$(e.post(S(t.update.phone,r),{externalId:n,phone:o},{token:s}))))})),{})}}),Qe=qe("identifier"),Ve=qe("uri"),We=Ee(qe("token")),Xe=Ee(Qe,Ve),Ye=Ee(qe("pendingRef")),et=Ee(Qe,Ae("phone"),Ve),tt=Ee(Qe,Te("email"),Ve),nt=e=>({verify:We((t=>$(e.post(n.verify,{token:t})))),signIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s,i)=>$(e.post(S(n.signIn,r),{externalId:t,URI:o,crossDevice:!0,loginOptions:s},{token:i}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o)=>$(e.post(S(n.signUpOrIn,r),{externalId:t,URI:o,crossDevice:!0}))))})),{}),signUp:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s)=>$(e.post(S(n.signUp,r),{externalId:t,URI:o,user:s,crossDevice:!0}))))})),{}),waitForSession:Ye(((t,r)=>new Promise((o=>{const{pollingIntervalMs:s,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||d,d),timeoutMs:Math.min(t||h,h)}))(r);let a;const c=setInterval((async()=>{const r=await e.post(n.session,{pendingRef:t});r.ok&&(clearInterval(c),a&&clearTimeout(a),o($(Promise.resolve(r))))}),s);a=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(c)}),i)})))),update:{email:tt(((t,r,o,s)=>$(e.post(n.update.email,{externalId:t,email:r,URI:o,crossDevice:!0},{token:s})))),phone:Object.keys(De).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:et(((t,o,s,i)=>$(e.post(S(n.update.phone,r),{externalId:t,phone:o,URI:s,crossDevice:!0},{token:i}))))})),{})}}),rt=e=>({verify:We((t=>$(e.post(n.verify,{token:t})))),signIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s,i)=>$(e.post(S(n.signIn,r),{externalId:t,URI:o,loginOptions:s},{token:i}))))})),{}),signUp:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o,s)=>$(e.post(S(n.signUp,r),{externalId:t,URI:o,user:s}))))})),{}),signUpOrIn:Object.keys(Je).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:Xe(((t,o)=>$(e.post(S(n.signUpOrIn,r),{externalId:t,URI:o}))))})),{}),update:{email:tt(((t,r,o,s)=>$(e.post(n.update.email,{externalId:t,email:r,URI:o},{token:s})))),phone:Object.keys(De).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:et(((t,o,s,i)=>$(e.post(S(n.update.phone,r),{externalId:t,phone:o,URI:s},{token:i}))))})),{})},crossDevice:nt(e)});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 st=Ee(qe("code")),it=e=>({start:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:o=!1}={},s,i)=>{const a=await e.post(r.start,s||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!o||!a.ok)return $(Promise.resolve(a));const{url:c}=await a.json();window.location.href=c}})),{}),exchange:st((t=>$(e.post(r.exchange,{code:t}))))}),at=Ee(qe("flowId")),ct=Ee(qe("executionId"),qe("stepId"),qe("interactionId")),ut=e=>({start:at(((t,n)=>$(e.post(l.start,{flowId:t,options:n})))),next:ct(((t,n,r,o)=>$(e.post(l.next,{executionId:t,stepId:n,interactionId:r,input:o}))))}),pt=Ee(qe("tenant")),lt=Ee(qe("code")),dt=e=>({start:pt((async(t,n,{redirect:r=!1}={},s,i)=>{const a=await e.post(o.start,s||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!r||!a.ok)return $(Promise.resolve(a));const{url:c}=await a.json();window.location.href=c})),exchange:lt((t=>$(e.post(o.exchange,{code:t}))))}),ht=qe("identifier"),gt=Ee(ht,qe("code")),ft=Ee(ht),vt=Ee(ht),yt=e=>({signUp:ft(((t,n)=>$(e.post(s.signUp,{externalId:t,user:n})))),verify:gt(((t,n,r,o)=>$(e.post(s.verify,{externalId:t,code:n,loginOptions:r},{token:o})))),update:vt(((t,n)=>$(e.post(s.update,{externalId:t},{token:n}))))}),bt=qe("identifier"),mt=qe("origin"),It=Ee(bt,mt,qe("name")),kt=Ee(bt,mt),wt=Ee(bt,mt,qe("token")),Ot=Ee(qe("transactionId"),qe("response")),jt=e=>({signUp:{start:It(((t,n,r)=>$(e.post(i.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:Ot(((t,n)=>$(e.post(i.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:kt(((t,n,r,o)=>$(e.post(i.signIn.start,{externalId:t,origin:n,loginOptions:r},{token:o})))),finish:Ot(((t,n)=>$(e.post(i.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:kt(((t,n)=>$(e.post(i.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:wt(((t,n,r)=>$(e.post(i.update.start,{externalId:t,origin:n},{token:r})))),finish:Ot(((t,n)=>$(e.post(i.update.finish,{transactionId:t,response:n}))))}}),_t=Ee(qe("token"));var xt,Ut;const Pt=Ee([(xt="projectId",Ut=qe("projectId"),E(((e,t)=>n=>q(...t).validate(Oe(n,e)))(xt,Ut))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return s=I({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:Ce(s),otp:Ke(s),magicLink:rt(s),oauth:it(s),saml:dt(s),totp:yt(s),webauthn:jt(s),flow:ut(s),refresh:e=>$(s.post(a,{},{token:e})),logout:e=>$(s.post(c,{},{token:e})),logoutAll:e=>$(s.post(u,{},{token:e})),me:e=>$(s.get(p,{token:e})),isJwtExpired:_t(U),getJwtPermissions:_t(P),getJwtRoles:_t(R),httpClient:s};var s}));return Pt.DeliveryMethods=Je,Pt}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@descope/core-js-sdk",
"version": "0.0.41-alpha.26",
"version": "0.0.41-alpha.27",
"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