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
209
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 1.0.3 to 1.0.4

2

dist/cjs/index.cjs.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jwt-decode"),t=require("lodash.get"),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"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},a={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},d={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},u={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={signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},l="/v1/auth/refresh",c="/v1/auth/logout",g="/v1/auth/logoutall",h="/v1/auth/me",v={start:"/v1/flow/start",next:"/v1/flow/next"};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")}},m=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>f().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.clone?e.clone().text():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()})(s)),s}:n};var I;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(I||(I={}));const 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,s])=>(e[n]=s,e)),e),e}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),k=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},w=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i,fetch:a})=>{const r=m(s,a),d=async s=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:d,body:u,headers:p,queryParams:l,method:c,token:g}=a,h=await r((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:d,baseUrl:e,queryParams:l}),{headers:y(k(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.3"},(null==n?void 0:n.baseHeaders)||{},p),method:c,body:b(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&await o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:I.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.delete,token:o}),hooks:o}};var O={TOO_MANY_REQUESTS:429};function U(e,t,n){var s;let o=j(e);t&&(o=null===(s=null==o?void 0:o.tenants)||void 0===s?void 0:s[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function j(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function P(e){const{exp:t}=j(e);return(new Date).getTime()/1e3>t}function x(e,t){return U(e,t,"permissions")}function R(e,t){return U(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){var n;const s=await e,o={code:s.status,ok:s.ok,response:s},i=await s.clone().json();return s.ok?o.data=t?t(i):i:(o.error=i,s.status===O.TOO_MANY_REQUESTS&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=s.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const $=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),M=e=>t=>e.test(t),T=M(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),A=M(/^\+[1-9]{1}[0-9]{3,14}$/),H=$(T,'"{val}" is not a valid email'),C=$(A,'"{val}" is not a valid phone number'),L=$((_=1,e=>e.length>=_),"Minimum length is 1");var _;const z=$((e=>"string"==typeof e),"Input is not a string"),J=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),N=e=>[z(`"${e}" must be a string`),L(`"${e}" must not be empty`)],D=e=>[z(`"${e}" must be a string`),H()],Z=e=>[z(`"${e}" must be a string`),C()],B=J(N("accessKey")),F=e=>({exchange:B((t=>E(e.post(n.exchange,{},{token:t}))))});var K,Q,Y,G;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Q||(Q={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Y||(Y={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(G||(G={}));const W=N("loginId"),V=J(N("token")),X=J(W),ee=J(N("pendingRef")),te=J(W,D("email")),ne=e=>({verify:V((t=>E(e.post(i.verify,{token:t})))),signIn:X(((t,n,s,o)=>E(e.post(q(i.signIn,Q.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:X(((t,n)=>E(e.post(q(i.signUpOrIn,Q.email),{loginId:t,URI:n})))),signUp:X(((t,n,s)=>E(e.post(q(i.signUp,Q.email),{loginId:t,URI:n,user:s})))),waitForSession:ee(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let r;const d=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(d),r&&clearTimeout(r),s(E(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(d)}),a)})))),update:{email:te(((t,n,s,o)=>E(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}}),se=J(N("flowId")),oe=J(N("executionId"),N("stepId"),N("interactionId")),ie=e=>({start:se(((t,n,s,o,i)=>E(e.post(v.start,{flowId:t,options:n,conditionInteractionId:s,interactionId:o,input:i})))),next:oe(((t,n,s,o)=>E(e.post(v.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),ae=N("loginId"),re=J(N("token")),de=J(ae),ue=J(ae,Z("phone")),pe=J(ae,D("email")),le=e=>({verify:re((t=>E(e.post(o.verify,{token:t})))),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,i,a)=>E(e.post(q(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,i)=>E(e.post(q(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s)=>E(e.post(q(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:pe(((t,n,s,i)=>E(e.post(o.update.email,{loginId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,i,a)=>E(e.post(q(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}});var ce;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin"}(ce||(ce={}));const ge=J(N("code")),he=e=>({start:Object.keys(ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const r=await e.post(a.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return E(Promise.resolve(r));const{url:d}=await r.json();window.location.href=d}})),{}),exchange:ge((t=>E(e.post(a.exchange,{code:t}))))});var ve;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ve||(ve={}));const fe=N("loginId"),me=J(fe,N("code")),Ie=J(fe),ye=J(fe,Z("phone")),be=J(fe,D("email")),ke=e=>({verify:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:me(((t,o)=>E(e.post(q(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie(((t,o,i)=>E(e.post(q(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie(((t,o)=>E(e.post(q(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie((t=>E(e.post(q(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:be(((t,n,o)=>E(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i)=>E(e.post(q(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),we=J(N("tenant")),Oe=J(N("code")),Ue=e=>({start:we((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(r.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:d}=await a.json();window.location.href=d})),exchange:Oe((t=>E(e.post(r.exchange,{code:t}))))}),je=N("loginId"),Pe=J(je,N("code")),xe=J(je),Re=J(je),qe=e=>({signUp:xe(((t,n)=>E(e.post(d.signUp,{loginId:t,user:n})))),verify:Pe(((t,n,s,o)=>E(e.post(d.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Re(((t,n)=>E(e.post(d.update,{loginId:t},{token:n}))))}),Ee=N("loginId"),$e=N("newPassword"),Se=J(Ee,N("password")),Me=J(Ee),Te=J(Ee,$e),Ae=J(Ee,N("oldPassword"),$e),He=e=>({signUp:Se(((t,n,s)=>E(e.post(p.signUp,{loginId:t,password:n,user:s})))),signIn:Se(((t,n)=>E(e.post(p.signIn,{loginId:t,password:n})))),sendReset:Me(((t,n)=>E(e.post(p.sendReset,{loginId:t,redirectUrl:n})))),update:Te(((t,n,s)=>E(e.post(p.update,{loginId:t,newPassword:n},{token:s})))),replace:Ae(((t,n,s)=>E(e.post(p.replace,{loginId:t,oldPassword:n,newPassword:s})))),policy:()=>E(e.get(p.policy))}),Ce=[z(`"${"loginId"}" must be a string`)];const Le=N("loginId"),_e=N("origin"),ze=J(Le,_e,N("name")),Je=J(Le,_e),Ne=J(Ce,_e),De=J(Le,_e,N("token")),Ze=J(N("transactionId"),N("response")),Be=e=>({signUp:{start:ze(((t,n,s)=>E(e.post(u.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Ze(((t,n)=>E(e.post(u.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Ne(((t,n,s,o)=>E(e.post(u.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Ze(((t,n)=>E(e.post(u.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Je(((t,n)=>E(e.post(u.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:De(((t,n,s)=>E(e.post(u.update.start,{loginId:t,origin:n},{token:s})))),finish:Ze(((t,n)=>E(e.post(u.update.finish,{transactionId:t,response:n}))))}}),Fe=J(N("token"));var Ke,Qe;var Ye=J([(Ke="projectId",Qe=N("projectId"),$(((e,n)=>s=>S(...n).validate(t(s,e)))(Ke,Qe))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:async(e,n)=>{(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={},fetch:a})=>{return r=w({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:F(r),otp:ke(r),magicLink:le(r),enchantedLink:ne(r),oauth:he(r),saml:Ue(r),totp:qe(r),webauthn:Be(r),password:He(r),flow:ie(r),refresh:e=>E(r.post(l,{},{token:e})),logout:e=>E(r.post(c,{},{token:e})),logoutAll:e=>E(r.post(g,{},{token:e})),me:e=>E(r.get(h,{token:e})),isJwtExpired:Fe(P),getJwtPermissions:Fe(x),getJwtRoles:Fe(R),httpClient:r};var r})));var Ge=Object.assign(Ye,{DeliveryMethods:Q});exports.HttpStatusCodes=O,exports.addHooksToConfig=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},exports.default=Ge,exports.transformResponse=E,exports.wrapWith=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e);
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jwt-decode"),t=require("lodash.get"),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"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},a={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},d={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},u={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={signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},l="/v1/auth/refresh",c="/v1/auth/logout",g="/v1/auth/logoutall",h="/v1/auth/me",v={start:"/v1/flow/start",next:"/v1/flow/next"};const f=1e3,m=6e5,I=()=>{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;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>I().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.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),I().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const k=(...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}),{})),w=e=>void 0===e?void 0:JSON.stringify(e),O=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},U=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i,fetch:a})=>{const r=y(s,a),d=async s=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:d,body:u,headers:p,queryParams:l,method:c,token:g}=a,h=await r((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:d,baseUrl:e,queryParams:l}),{headers:k(O(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.4"},(null==n?void 0:n.baseHeaders)||{},p),method:c,body:w(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&await o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:o}),hooks:o}};var j={TOO_MANY_REQUESTS:429};function P(e,t,n){var s;let o=x(e);t&&(o=null===(s=null==o?void 0:o.tenants)||void 0===s?void 0:s[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function x(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function R(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function q(e,t){return P(e,t,"permissions")}function E(e,t){return P(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function S(e,t){var n;const s=await e,o={code:s.status,ok:s.ok,response:s},i=await s.clone().json();return s.ok?o.data=t?t(i):i:(o.error=i,s.status===j.TOO_MANY_REQUESTS&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=s.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),T=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),A=e=>t=>e.test(t),H=A(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),C=A(/^\+[1-9]{1}[0-9]{3,14}$/),L=M(H,'"{val}" is not a valid email'),_=M(C,'"{val}" is not a valid phone number'),z=M((J=1,e=>e.length>=J),"Minimum length is 1");var J;const N=M((e=>"string"==typeof e),"Input is not a string"),D=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>T(...e).validate(n[t]))),t(...n)),Z=e=>[N(`"${e}" must be a string`),z(`"${e}" must not be empty`)],B=e=>[N(`"${e}" must be a string`),L()],F=e=>[N(`"${e}" must be a string`),_()],K=D(Z("accessKey")),Q=e=>({exchange:K((t=>S(e.post(n.exchange,{},{token:t}))))});var Y,G,W,V;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Y||(Y={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(W||(W={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(V||(V={}));const X=Z("loginId"),ee=D(Z("token")),te=D(X),ne=D(Z("pendingRef")),se=D(X,B("email")),oe=e=>({verify:ee((t=>S(e.post(i.verify,{token:t})))),signIn:te(((t,n,s,o)=>S(e.post($(i.signIn,G.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:te(((t,n)=>S(e.post($(i.signUpOrIn,G.email),{loginId:t,URI:n})))),signUp:te(((t,n,s)=>S(e.post($(i.signUp,G.email),{loginId:t,URI:n,user:s})))),waitForSession:ne(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||f,f),timeoutMs:Math.min(t||m,m)}))(n);let r;const d=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(d),r&&clearTimeout(r),s(S(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(d)}),a)})))),update:{email:se(((t,n,s,o)=>S(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}}),ie=D(Z("flowId")),ae=D(Z("executionId"),Z("stepId"),Z("interactionId")),re=e=>({start:ie(((t,n,s,o,i)=>S(e.post(v.start,{flowId:t,options:n,conditionInteractionId:s,interactionId:o,input:i})))),next:ae(((t,n,s,o)=>S(e.post(v.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),de=Z("loginId"),ue=D(Z("token")),pe=D(de),le=D(de,F("phone")),ce=D(de,B("email")),ge=e=>({verify:ue((t=>S(e.post(o.verify,{token:t})))),signIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,i,a)=>S(e.post($(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,i)=>S(e.post($(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s)=>S(e.post($(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:ce(((t,n,s,i)=>S(e.post(o.update.email,{loginId:t,email:n,URI:s},{token:i})))),phone:Object.keys(Y).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:le(((t,s,i,a)=>S(e.post($(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}});var he;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin"}(he||(he={}));const ve=D(Z("code")),fe=e=>({start:Object.keys(he).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const r=await e.post(a.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return S(Promise.resolve(r));const{url:d}=await r.json();window.location.href=d}})),{}),exchange:ve((t=>S(e.post(a.exchange,{code:t}))))});var me;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(me||(me={}));const Ie=Z("loginId"),ye=D(Ie,Z("code")),be=D(Ie),ke=D(Ie,F("phone")),we=D(Ie,B("email")),Oe=e=>({verify:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o)=>S(e.post($(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be(((t,o,i)=>S(e.post($(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be(((t,o)=>S(e.post($(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be((t=>S(e.post($(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:we(((t,n,o)=>S(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(Y).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,o,i)=>S(e.post($(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),Ue=D(Z("tenant")),je=D(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(r.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return S(Promise.resolve(a));const{url:d}=await a.json();window.location.href=d})),exchange:je((t=>S(e.post(r.exchange,{code:t}))))}),xe=Z("loginId"),Re=D(xe,Z("code")),qe=D(xe),Ee=D(xe),$e=e=>({signUp:qe(((t,n)=>S(e.post(d.signUp,{loginId:t,user:n})))),verify:Re(((t,n,s,o)=>S(e.post(d.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Ee(((t,n)=>S(e.post(d.update,{loginId:t},{token:n}))))}),Se=Z("loginId"),Me=Z("newPassword"),Te=D(Se,Z("password")),Ae=D(Se),He=D(Se,Me),Ce=D(Se,Z("oldPassword"),Me),Le=e=>({signUp:Te(((t,n,s)=>S(e.post(p.signUp,{loginId:t,password:n,user:s})))),signIn:Te(((t,n)=>S(e.post(p.signIn,{loginId:t,password:n})))),sendReset:Ae(((t,n)=>S(e.post(p.sendReset,{loginId:t,redirectUrl:n})))),update:He(((t,n,s)=>S(e.post(p.update,{loginId:t,newPassword:n},{token:s})))),replace:Ce(((t,n,s)=>S(e.post(p.replace,{loginId:t,oldPassword:n,newPassword:s})))),policy:()=>S(e.get(p.policy))}),_e=[N(`"${"loginId"}" must be a string`)];const ze=Z("loginId"),Je=Z("origin"),Ne=D(ze,Je,Z("name")),De=D(ze,Je),Ze=D(_e,Je),Be=D(ze,Je,Z("token")),Fe=D(Z("transactionId"),Z("response")),Ke=e=>({signUp:{start:Ne(((t,n,s)=>S(e.post(u.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Fe(((t,n)=>S(e.post(u.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Ze(((t,n,s,o)=>S(e.post(u.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Fe(((t,n)=>S(e.post(u.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:De(((t,n)=>S(e.post(u.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Be(((t,n,s)=>S(e.post(u.update.start,{loginId:t,origin:n},{token:s})))),finish:Fe(((t,n)=>S(e.post(u.update.finish,{transactionId:t,response:n}))))}}),Qe=D(Z("token"));var Ye,Ge;var We=D([(Ye="projectId",Ge=Z("projectId"),M(((e,n)=>s=>T(...n).validate(t(s,e)))(Ye,Ge))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:async(e,n)=>{(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={},fetch:a})=>{return r=U({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:Q(r),otp:Oe(r),magicLink:ge(r),enchantedLink:oe(r),oauth:fe(r),saml:Pe(r),totp:$e(r),webauthn:Ke(r),password:Le(r),flow:re(r),refresh:e=>S(r.post(l,{},{token:e})),logout:e=>S(r.post(c,{},{token:e})),logoutAll:e=>S(r.post(g,{},{token:e})),me:e=>S(r.get(h,{token:e})),isJwtExpired:Qe(R),getJwtPermissions:Qe(q),getJwtRoles:Qe(E),httpClient:r};var r})));var Ve=Object.assign(We,{DeliveryMethods:G});exports.HttpStatusCodes=j,exports.addHooksToConfig=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},exports.default=Ve,exports.transformResponse=S,exports.wrapWith=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e);
//# sourceMappingURL=index.cjs.js.map

@@ -258,3 +258,6 @@ declare type JSONSerializable = string | number | boolean | null | Array<JSONSerializable>;

declare type IsObject<T> = T extends Array<any> ? false : T extends Function ? false : T extends object ? true : false;
declare type Tail<T extends ReadonlyArray<string>> = T extends readonly [head: any, ...tail: infer Tail_] ? Tail_ : never;
declare type Tail<T extends ReadonlyArray<string>> = T extends readonly [
head: any,
...tail: infer Tail_
] ? Tail_ : never;
declare type Head<T extends ReadonlyArray<string>> = T extends readonly [] ? never : T[0];

@@ -261,0 +264,0 @@ declare type SdkResponseType<F extends SdkFn<ResponseData>> = F extends SdkFn<infer U> ? U : never;

@@ -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"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},a={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},d={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},u={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={signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},p="/v1/auth/refresh",c="/v1/auth/logout",g="/v1/auth/logoutall",h="/v1/auth/me",v={start:"/v1/flow/start",next:"/v1/flow/next"};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")}},m=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>f().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.clone?e.clone().text():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()})(s)),s}:n};var I;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(I||(I={}));const 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,s])=>(e[n]=s,e)),e),e}),{})),b=e=>void 0===e?void 0:JSON.stringify(e),k=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},w=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i,fetch:a})=>{const r=m(s,a),d=async s=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:d,body:u,headers:l,queryParams:p,method:c,token:g}=a,h=await r((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:d,baseUrl:e,queryParams:p}),{headers:y(k(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.3"},(null==n?void 0:n.baseHeaders)||{},l),method:c,body:b(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&await o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:I.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:I.delete,token:o}),hooks:o}};var O={TOO_MANY_REQUESTS:429};function U(e,t,n){var s;let o=j(e);t&&(o=null===(s=null==o?void 0:o.tenants)||void 0===s?void 0:s[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function j(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function P(e){const{exp:t}=j(e);return(new Date).getTime()/1e3>t}function R(e,t){return U(e,t,"permissions")}function x(e,t){return U(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){var n;const s=await e,o={code:s.status,ok:s.ok,response:s},i=await s.clone().json();return s.ok?o.data=t?t(i):i:(o.error=i,s.status===O.TOO_MANY_REQUESTS&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=s.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const $=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),M=e=>t=>e.test(t),T=M(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),A=M(/^\+[1-9]{1}[0-9]{3,14}$/),L=$(T,'"{val}" is not a valid email'),z=$(A,'"{val}" is not a valid phone number'),H=$((J=1,e=>e.length>=J),"Minimum length is 1");var J;const N=$((e=>"string"==typeof e),"Input is not a string"),C=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),_=e=>[N(`"${e}" must be a string`),H(`"${e}" must not be empty`)],D=e=>[N(`"${e}" must be a string`),L()],Z=e=>[N(`"${e}" must be a string`),z()],B=C(_("accessKey")),F=e=>({exchange:B((t=>E(e.post(n.exchange,{},{token:t}))))});var K,Q,Y,G;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Q||(Q={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Y||(Y={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(G||(G={}));const V=_("loginId"),W=C(_("token")),X=C(V),ee=C(_("pendingRef")),te=C(V,D("email")),ne=e=>({verify:W((t=>E(e.post(i.verify,{token:t})))),signIn:X(((t,n,s,o)=>E(e.post(q(i.signIn,Q.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:X(((t,n)=>E(e.post(q(i.signUpOrIn,Q.email),{loginId:t,URI:n})))),signUp:X(((t,n,s)=>E(e.post(q(i.signUp,Q.email),{loginId:t,URI:n,user:s})))),waitForSession:ee(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let r;const d=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(d),r&&clearTimeout(r),s(E(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(d)}),a)})))),update:{email:te(((t,n,s,o)=>E(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}}),se=C(_("flowId")),oe=C(_("executionId"),_("stepId"),_("interactionId")),ie=e=>({start:se(((t,n,s,o,i)=>E(e.post(v.start,{flowId:t,options:n,conditionInteractionId:s,interactionId:o,input:i})))),next:oe(((t,n,s,o)=>E(e.post(v.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),ae=_("loginId"),re=C(_("token")),de=C(ae),ue=C(ae,Z("phone")),le=C(ae,D("email")),pe=e=>({verify:re((t=>E(e.post(o.verify,{token:t})))),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,i,a)=>E(e.post(q(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,i)=>E(e.post(q(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s)=>E(e.post(q(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:le(((t,n,s,i)=>E(e.post(o.update.email,{loginId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,i,a)=>E(e.post(q(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}});var ce;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin"}(ce||(ce={}));const ge=C(_("code")),he=e=>({start:Object.keys(ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const r=await e.post(a.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return E(Promise.resolve(r));const{url:d}=await r.json();window.location.href=d}})),{}),exchange:ge((t=>E(e.post(a.exchange,{code:t}))))});var ve;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(ve||(ve={}));const fe=_("loginId"),me=C(fe,_("code")),Ie=C(fe),ye=C(fe,Z("phone")),be=C(fe,D("email")),ke=e=>({verify:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:me(((t,o)=>E(e.post(q(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie(((t,o,i)=>E(e.post(q(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie(((t,o)=>E(e.post(q(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ie((t=>E(e.post(q(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:be(((t,n,o)=>E(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i)=>E(e.post(q(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),we=C(_("tenant")),Oe=C(_("code")),Ue=e=>({start:we((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(r.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:d}=await a.json();window.location.href=d})),exchange:Oe((t=>E(e.post(r.exchange,{code:t}))))}),je=_("loginId"),Pe=C(je,_("code")),Re=C(je),xe=C(je),qe=e=>({signUp:Re(((t,n)=>E(e.post(d.signUp,{loginId:t,user:n})))),verify:Pe(((t,n,s,o)=>E(e.post(d.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:xe(((t,n)=>E(e.post(d.update,{loginId:t},{token:n}))))}),Ee=_("loginId"),$e=_("newPassword"),Se=C(Ee,_("password")),Me=C(Ee),Te=C(Ee,$e),Ae=C(Ee,_("oldPassword"),$e),Le=e=>({signUp:Se(((t,n,s)=>E(e.post(l.signUp,{loginId:t,password:n,user:s})))),signIn:Se(((t,n)=>E(e.post(l.signIn,{loginId:t,password:n})))),sendReset:Me(((t,n)=>E(e.post(l.sendReset,{loginId:t,redirectUrl:n})))),update:Te(((t,n,s)=>E(e.post(l.update,{loginId:t,newPassword:n},{token:s})))),replace:Ae(((t,n,s)=>E(e.post(l.replace,{loginId:t,oldPassword:n,newPassword:s})))),policy:()=>E(e.get(l.policy))}),ze=[N(`"${"loginId"}" must be a string`)];const He=_("loginId"),Je=_("origin"),Ne=C(He,Je,_("name")),Ce=C(He,Je),_e=C(ze,Je),De=C(He,Je,_("token")),Ze=C(_("transactionId"),_("response")),Be=e=>({signUp:{start:Ne(((t,n,s)=>E(e.post(u.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Ze(((t,n)=>E(e.post(u.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:_e(((t,n,s,o)=>E(e.post(u.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Ze(((t,n)=>E(e.post(u.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ce(((t,n)=>E(e.post(u.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:De(((t,n,s)=>E(e.post(u.update.start,{loginId:t,origin:n},{token:s})))),finish:Ze(((t,n)=>E(e.post(u.update.finish,{transactionId:t,response:n}))))}}),Fe=C(_("token"));var Ke,Qe;var Ye=C([(Ke="projectId",Qe=_("projectId"),$(((e,n)=>s=>S(...n).validate(t(s,e)))(Ke,Qe))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:async(e,n)=>{(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={},fetch:a})=>{return r=w({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:F(r),otp:ke(r),magicLink:pe(r),enchantedLink:ne(r),oauth:he(r),saml:Ue(r),totp:qe(r),webauthn:Be(r),password:Le(r),flow:ie(r),refresh:e=>E(r.post(p,{},{token:e})),logout:e=>E(r.post(c,{},{token:e})),logoutAll:e=>E(r.post(g,{},{token:e})),me:e=>E(r.get(h,{token:e})),isJwtExpired:Fe(P),getJwtPermissions:Fe(R),getJwtRoles:Fe(x),httpClient:r};var r})));const Ge=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e),Ve=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e};var We=Object.assign(Ye,{DeliveryMethods:Q});export{O as HttpStatusCodes,Ve as addHooksToConfig,We as default,E as transformResponse,Ge as wrapWith};
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"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},a={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},d={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},u={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={signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},p="/v1/auth/refresh",c="/v1/auth/logout",g="/v1/auth/logoutall",h="/v1/auth/me",v={start:"/v1/flow/start",next:"/v1/flow/next"};const f=1e3,m=6e5,I=()=>{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;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>I().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.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),I().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const k=(...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}),{})),w=e=>void 0===e?void 0:JSON.stringify(e),O=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},U=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i,fetch:a})=>{const r=y(s,a),d=async s=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:d,body:u,headers:l,queryParams:p,method:c,token:g}=a,h=await r((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:d,baseUrl:e,queryParams:p}),{headers:k(O(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.4"},(null==n?void 0:n.baseHeaders)||{},l),method:c,body:w(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&await o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>d({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:o}),hooks:o}};var j={TOO_MANY_REQUESTS:429};function P(e,t,n){var s;let o=R(e);t&&(o=null===(s=null==o?void 0:o.tenants)||void 0===s?void 0:s[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function R(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function x(e){const{exp:t}=R(e);return(new Date).getTime()/1e3>t}function q(e,t){return P(e,t,"permissions")}function E(e,t){return P(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function S(e,t){var n;const s=await e,o={code:s.status,ok:s.ok,response:s},i=await s.clone().json();return s.ok?o.data=t?t(i):i:(o.error=i,s.status===j.TOO_MANY_REQUESTS&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=s.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),T=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),A=e=>t=>e.test(t),L=A(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),z=A(/^\+[1-9]{1}[0-9]{3,14}$/),H=M(L,'"{val}" is not a valid email'),J=M(z,'"{val}" is not a valid phone number'),N=M((C=1,e=>e.length>=C),"Minimum length is 1");var C;const _=M((e=>"string"==typeof e),"Input is not a string"),D=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>T(...e).validate(n[t]))),t(...n)),Z=e=>[_(`"${e}" must be a string`),N(`"${e}" must not be empty`)],B=e=>[_(`"${e}" must be a string`),H()],F=e=>[_(`"${e}" must be a string`),J()],K=D(Z("accessKey")),Q=e=>({exchange:K((t=>S(e.post(n.exchange,{},{token:t}))))});var Y,G,V,W;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Y||(Y={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(W||(W={}));const X=Z("loginId"),ee=D(Z("token")),te=D(X),ne=D(Z("pendingRef")),se=D(X,B("email")),oe=e=>({verify:ee((t=>S(e.post(i.verify,{token:t})))),signIn:te(((t,n,s,o)=>S(e.post($(i.signIn,G.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:te(((t,n)=>S(e.post($(i.signUpOrIn,G.email),{loginId:t,URI:n})))),signUp:te(((t,n,s)=>S(e.post($(i.signUp,G.email),{loginId:t,URI:n,user:s})))),waitForSession:ne(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||f,f),timeoutMs:Math.min(t||m,m)}))(n);let r;const d=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(d),r&&clearTimeout(r),s(S(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(d)}),a)})))),update:{email:se(((t,n,s,o)=>S(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}}),ie=D(Z("flowId")),ae=D(Z("executionId"),Z("stepId"),Z("interactionId")),re=e=>({start:ie(((t,n,s,o,i)=>S(e.post(v.start,{flowId:t,options:n,conditionInteractionId:s,interactionId:o,input:i})))),next:ae(((t,n,s,o)=>S(e.post(v.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),de=Z("loginId"),ue=D(Z("token")),le=D(de),pe=D(de,F("phone")),ce=D(de,B("email")),ge=e=>({verify:ue((t=>S(e.post(o.verify,{token:t})))),signIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:le(((t,s,i,a)=>S(e.post($(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:le(((t,s,i)=>S(e.post($(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:le(((t,s)=>S(e.post($(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:ce(((t,n,s,i)=>S(e.post(o.update.email,{loginId:t,email:n,URI:s},{token:i})))),phone:Object.keys(Y).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,i,a)=>S(e.post($(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}});var he;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin"}(he||(he={}));const ve=D(Z("code")),fe=e=>({start:Object.keys(he).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const r=await e.post(a.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return S(Promise.resolve(r));const{url:d}=await r.json();window.location.href=d}})),{}),exchange:ve((t=>S(e.post(a.exchange,{code:t}))))});var me;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(me||(me={}));const Ie=Z("loginId"),ye=D(Ie,Z("code")),be=D(Ie),ke=D(Ie,F("phone")),we=D(Ie,B("email")),Oe=e=>({verify:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o)=>S(e.post($(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be(((t,o,i)=>S(e.post($(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be(((t,o)=>S(e.post($(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:be((t=>S(e.post($(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:we(((t,n,o)=>S(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(Y).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,o,i)=>S(e.post($(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),Ue=D(Z("tenant")),je=D(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(r.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return S(Promise.resolve(a));const{url:d}=await a.json();window.location.href=d})),exchange:je((t=>S(e.post(r.exchange,{code:t}))))}),Re=Z("loginId"),xe=D(Re,Z("code")),qe=D(Re),Ee=D(Re),$e=e=>({signUp:qe(((t,n)=>S(e.post(d.signUp,{loginId:t,user:n})))),verify:xe(((t,n,s,o)=>S(e.post(d.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Ee(((t,n)=>S(e.post(d.update,{loginId:t},{token:n}))))}),Se=Z("loginId"),Me=Z("newPassword"),Te=D(Se,Z("password")),Ae=D(Se),Le=D(Se,Me),ze=D(Se,Z("oldPassword"),Me),He=e=>({signUp:Te(((t,n,s)=>S(e.post(l.signUp,{loginId:t,password:n,user:s})))),signIn:Te(((t,n)=>S(e.post(l.signIn,{loginId:t,password:n})))),sendReset:Ae(((t,n)=>S(e.post(l.sendReset,{loginId:t,redirectUrl:n})))),update:Le(((t,n,s)=>S(e.post(l.update,{loginId:t,newPassword:n},{token:s})))),replace:ze(((t,n,s)=>S(e.post(l.replace,{loginId:t,oldPassword:n,newPassword:s})))),policy:()=>S(e.get(l.policy))}),Je=[_(`"${"loginId"}" must be a string`)];const Ne=Z("loginId"),Ce=Z("origin"),_e=D(Ne,Ce,Z("name")),De=D(Ne,Ce),Ze=D(Je,Ce),Be=D(Ne,Ce,Z("token")),Fe=D(Z("transactionId"),Z("response")),Ke=e=>({signUp:{start:_e(((t,n,s)=>S(e.post(u.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Fe(((t,n)=>S(e.post(u.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Ze(((t,n,s,o)=>S(e.post(u.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Fe(((t,n)=>S(e.post(u.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:De(((t,n)=>S(e.post(u.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Be(((t,n,s)=>S(e.post(u.update.start,{loginId:t,origin:n},{token:s})))),finish:Fe(((t,n)=>S(e.post(u.update.finish,{transactionId:t,response:n}))))}}),Qe=D(Z("token"));var Ye,Ge;var Ve=D([(Ye="projectId",Ge=Z("projectId"),M(((e,n)=>s=>T(...n).validate(t(s,e)))(Ye,Ge))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:async(e,n)=>{(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={},fetch:a})=>{return r=U({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:a}),{accessKey:Q(r),otp:Oe(r),magicLink:ge(r),enchantedLink:oe(r),oauth:fe(r),saml:Pe(r),totp:$e(r),webauthn:Ke(r),password:He(r),flow:re(r),refresh:e=>S(r.post(p,{},{token:e})),logout:e=>S(r.post(c,{},{token:e})),logoutAll:e=>S(r.post(g,{},{token:e})),me:e=>S(r.get(h,{token:e})),isJwtExpired:Qe(x),getJwtPermissions:Qe(q),getJwtRoles:Qe(E),httpClient:r};var r})));const We=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e),Xe=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e};var et=Object.assign(Ve,{DeliveryMethods:G});export{j as HttpStatusCodes,Xe as addHooksToConfig,et as default,S as transformResponse,We as wrapWith};
//# sourceMappingURL=index.esm.js.map
{
"name": "@descope/core-js-sdk",
"version": "1.0.3",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/core-js-sdk",
"bugs": {
"url": "https://github.com/descope/core-js-sdk/issues",
"email": "help@descope.com"
},
"main": "dist/cjs/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"require": "./dist/cjs/index.cjs.js",
"import": "./dist/index.esm.js"
},
"type": "module",
"description": "Descope JavaScript core SDK",
"scripts": {
"build": "rimraf dist && rollup -c",
"prepare": "husky install",
"test": "jest",
"lint": "eslint src/**/*.* --fix",
"format": "prettier . -w --ignore-path .gitignore",
"format-check": "prettier . --check --ignore-path .gitignore",
"format-lint": "pretty-quick --staged --ignore-path .gitignore && lint-staged",
"prepublishOnly": "npm run build"
},
"lint-staged": {
"+(src|test|examples)/**/*.{js,ts,jsx,tsx}": [
"npm run lint"
]
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/descope/core-js-sdk.git"
},
"files": [
"dist"
],
"keywords": [
"descope",
"authentication"
],
"devDependencies": {
"@open-wc/rollup-plugin-html": "1.2.5",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/jest": "^29.0.0",
"@types/lodash.get": "^4.4.7",
"@typescript-eslint/parser": "^5.33.1",
"esbuild": "^0.17.0",
"eslint": "8.26.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.6.0",
"eslint-config-standard": "17.0.0",
"eslint-import-resolver-typescript": "3.5.3",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-jest-dom": "4.0.3",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-n": "15.6.1",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.1.1",
"husky": "^8.0.1",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.4.3",
"lint-staged": "^13.0.3",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"rimraf": "^4.0.0",
"rollup": "^3.0.0",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-inject-process-env": "^1.3.1",
"rollup-plugin-livereload": "^2.0.5",
"ts-jest": "^29.0.0",
"ts-node": "10.9.1",
"typescript": "^4.5.3"
},
"dependencies": {
"jwt-decode": "3.1.2",
"lodash.get": "4.4.2"
},
"overrides": {
"terser": "^5.14.2"
}
}
"name": "@descope/core-js-sdk",
"version": "1.0.4",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/core-js-sdk",
"bugs": {
"url": "https://github.com/descope/core-js-sdk/issues",
"email": "help@descope.com"
},
"main": "dist/cjs/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"require": "./dist/cjs/index.cjs.js",
"import": "./dist/index.esm.js"
},
"type": "module",
"description": "Descope JavaScript core SDK",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/descope/core-js-sdk.git"
},
"files": [
"dist"
],
"keywords": [
"descope",
"authentication"
],
"devDependencies": {
"@open-wc/rollup-plugin-html": "1.2.5",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/jest": "^29.0.0",
"@types/lodash.get": "^4.4.7",
"@typescript-eslint/parser": "^5.33.1",
"esbuild": "^0.17.0",
"eslint": "8.26.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.7.0",
"eslint-config-standard": "17.0.0",
"eslint-import-resolver-typescript": "3.5.3",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-jest-dom": "4.0.3",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-n": "15.6.1",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.1.1",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.4.3",
"lint-staged": "^13.0.3",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"rimraf": "^4.0.0",
"rollup": "^3.0.0",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-inject-process-env": "^1.3.1",
"rollup-plugin-livereload": "^2.0.5",
"ts-jest": "^29.0.0",
"ts-node": "10.9.1",
"typescript": "^4.5.3"
},
"dependencies": {
"eslint-plugin-jsx-a11y": "^6.7.1",
"jwt-decode": "3.1.2",
"lodash.get": "4.4.2"
},
"overrides": {
"terser": "^5.14.2"
},
"scripts": {
"build": "rimraf dist && rollup -c",
"test": "jest",
"lint": "eslint 'src/**/*.ts'"
}
}
# @descope/core-js-sdk
Descope JavaScript core SDK - Alpha
Descope JavaScript core SDK

@@ -16,6 +16,6 @@ ## Usage

```js
import descopeSdk from '@descope/core-js-sdk';
import createSdk from '@descope/core-js-sdk';
const myProjectId = 'xxx';
const sdk = descopeSdk({ projectId: myProjectId });
const sdk = createSdk({ projectId: myProjectId });

@@ -22,0 +22,0 @@ const loginId = 'loginId';

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