@descope/core-js-sdk 0.0.41-alpha.45 → 0.0.41-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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),o=n(t),i={exchange:"/v1/auth/accesskey/exchange"},a={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",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={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"},d={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},c={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},l={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},p={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"}},g="/v1/auth/refresh",h="/v1/auth/logout",v="/v1/auth/logoutall",f="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};const 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")}},k=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{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 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}),{})),O=e=>void 0===e?void 0:JSON.stringify(e),w=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=k(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:d,headers:c,queryParams:l,method:p,token:g}=r,h=await a((({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:l}),{headers:y(w(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.45"},(null==n?void 0:n.baseHeaders)||{},c),method:p,body:O(d),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.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:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:o}),hooks:o}};function U(e,t,n){var s;let o=x(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function R(e,t){return U(e,t,"permissions")}function q(e,t){return U(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const M=(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)}),T=e=>t=>e.test(t),A=T(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),L=T(/^\+[1-9]{1}[0-9]{3,14}$/),z=M(A,'"{val}" is not a valid email'),J=M(L,'"{val}" is not a valid phone number'),H=M((C=1,e=>e.length>=C),"Minimum length is 1");var C;const D=M((e=>"string"==typeof e),"Input is not a string"),N=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Z=e=>[D(`"${e}" must be a string`),H(`"${e}" must not be empty`)],_=e=>[D(`"${e}" must be a string`),z()],B=e=>[D(`"${e}" must be a string`),J()],K=N(Z("accessKey")),F=e=>({exchange:K((t=>E(e.post(i.exchange,{},{token:t}))))});var G,W,Q,V,X;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(W||(W={})),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"}(X||(X={}));const Y=Z("loginId"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),oe=e=>({verify:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>E(e.post($(a.verify,n),{code:s,loginId:t}))))})),{}),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,o)=>E(e.post($(a.signIn,n),{loginId:t,loginOptions:s},{token:o}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>E(e.post($(a.signUp,n),{loginId:t,user:s}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>E(e.post($(a.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:se(((t,n,s)=>E(e.post(a.update.email,{loginId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,o)=>E(e.post($(a.update.phone,n),{loginId:t,phone:s},{token:o}))))})),{})}}),ie=Z("loginId"),ae=Z("uri"),re=N(Z("token")),ue=N(ie,ae),de=N(ie,B("phone"),ae),ce=N(ie,_("email"),ae),le=e=>({verify:re((t=>E(e.post(r.verify,{token:t})))),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o,i)=>E(e.post($(r.signIn,n),{loginId:t,URI:s,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o)=>E(e.post($(r.signUp,n),{loginId:t,URI:s,user:o}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>E(e.post($(r.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:ce(((t,n,s,o)=>E(e.post(r.update.email,{loginId:t,email:n,URI:s},{token:o})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,o,i)=>E(e.post($(r.update.phone,n),{loginId:t,phone:s,URI:o},{token:i}))))})),{})}}),pe=Z("loginId"),ge=Z("uri"),he=N(Z("token")),ve=N(pe,ge),fe=N(Z("pendingRef")),me=N(pe,_("email"),ge),Ie=e=>({verify:he((t=>E(e.post(u.verify,{token:t})))),signIn:ve(((t,n,s,o)=>E(e.post($(u.signIn,W.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:ve(((t,n)=>E(e.post($(u.signUpOrIn,W.email),{loginId:t,URI:n})))),signUp:ve(((t,n,s)=>E(e.post($(u.signUp,W.email),{loginId:t,URI:n,user:s})))),waitForSession:fe(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let a;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),a&&clearTimeout(a),s(E(Promise.resolve(n))))}),o);a=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,o)=>E(e.post(u.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var ke;!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"}(ke||(ke={}));const be=N(Z("code")),ye=e=>({start:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const a=await e.post(d.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r}})),{}),exchange:be((t=>E(e.post(d.exchange,{code:t}))))}),Oe=N(Z("flowId")),we=N(Z("executionId"),Z("stepId"),Z("interactionId")),je=e=>({start:Oe(((t,n,s,o)=>E(e.post(m.start,{flowId:t,options:n,interactionId:s,input:o})))),next:we(((t,n,s,o)=>E(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Ue=N(Z("tenant")),xe=N(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(c.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r})),exchange:xe((t=>E(e.post(c.exchange,{code:t}))))}),Re=Z("loginId"),qe=N(Re,Z("code")),$e=N(Re),Ee=N(Re),Me=e=>({signUp:$e(((t,n)=>E(e.post(l.signUp,{loginId:t,user:n})))),verify:qe(((t,n,s,o)=>E(e.post(l.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Ee(((t,n)=>E(e.post(l.update,{loginId:t},{token:n}))))}),Se=[D(`"${"loginId"}" must be a string`)];const Te=Z("loginId"),Ae=Z("origin"),Le=N(Te,Ae,Z("name")),ze=N(Te,Ae),Je=N(Se,Ae),He=N(Te,Ae,Z("token")),Ce=N(Z("transactionId"),Z("response")),De=e=>({signUp:{start:Le(((t,n,s)=>E(e.post(p.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Ce(((t,n)=>E(e.post(p.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Je(((t,n,s,o)=>E(e.post(p.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Ce(((t,n)=>E(e.post(p.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:ze(((t,n)=>E(e.post(p.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:He(((t,n,s)=>E(e.post(p.update.start,{loginId:t,origin:n},{token:s})))),finish:Ce(((t,n)=>E(e.post(p.update.finish,{transactionId:t,response:n}))))}}),Ne=N(Z("token"));var Ze,_e;var Be=N([(Ze="projectId",_e=Z("projectId"),M(((e,t)=>n=>S(...t).validate(o.default(n,e)))(Ze,_e))())])((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:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o})=>{return i=j({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o}),{accessKey:F(i),otp:oe(i),magicLink:le(i),enchantedLink:Ie(i),oauth:ye(i),saml:Pe(i),totp:Me(i),webauthn:De(i),flow:je(i),refresh:e=>E(i.post(g,{},{token:e})),logout:e=>E(i.post(h,{},{token:e})),logoutAll:e=>E(i.post(v,{},{token:e})),me:e=>E(i.get(f,{token:e})),isJwtExpired:Ne(P),getJwtPermissions:Ne(R),getJwtRoles:Ne(q),httpClient:i};var i})));var Ke=Object.assign(Be,{DeliveryMethods:W});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=Ke,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);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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),o=n(t),i={exchange:"/v1/auth/accesskey/exchange"},a={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",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={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"},d={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},c={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},l={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},p={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"}},g="/v1/auth/refresh",h="/v1/auth/logout",v="/v1/auth/logoutall",f="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};const 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")}},k=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{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 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}),{})),O=e=>void 0===e?void 0:JSON.stringify(e),w=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=k(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:d,headers:c,queryParams:l,method:p,token:g}=r,h=await a((({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:l}),{headers:y(w(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.46"},(null==n?void 0:n.baseHeaders)||{},c),method:p,body:O(d),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.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:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:o}),hooks:o}};function U(e,t,n){var s;let o=x(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function R(e,t){return U(e,t,"permissions")}function q(e,t){return U(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const M=(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)}),T=e=>t=>e.test(t),A=T(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),H=T(/^\+[1-9]{1}[0-9]{3,14}$/),L=M(A,'"{val}" is not a valid email'),z=M(H,'"{val}" is not a valid phone number'),J=M((C=1,e=>e.length>=C),"Minimum length is 1");var C;const D=M((e=>"string"==typeof e),"Input is not a string"),N=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Z=e=>[D(`"${e}" must be a string`),J(`"${e}" must not be empty`)],_=e=>[D(`"${e}" must be a string`),L()],B=e=>[D(`"${e}" must be a string`),z()],K=N(Z("accessKey")),F=e=>({exchange:K((t=>E(e.post(i.exchange,{},{token:t}))))});var G,W,Q,V,X;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(W||(W={})),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"}(X||(X={}));const Y=Z("loginId"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),oe=e=>({verify:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>E(e.post($(a.verify,n),{code:s,loginId:t}))))})),{}),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,o)=>E(e.post($(a.signIn,n),{loginId:t,loginOptions:s},{token:o}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>E(e.post($(a.signUp,n),{loginId:t,user:s}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>E(e.post($(a.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:se(((t,n,s)=>E(e.post(a.update.email,{loginId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,o)=>E(e.post($(a.update.phone,n),{loginId:t,phone:s},{token:o}))))})),{})}}),ie=Z("loginId"),ae=Z("uri"),re=N(Z("token")),ue=N(ie,ae),de=N(ie,B("phone"),ae),ce=N(ie,_("email"),ae),le=e=>({verify:re((t=>E(e.post(r.verify,{token:t})))),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o,i)=>E(e.post($(r.signIn,n),{loginId:t,URI:s,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o)=>E(e.post($(r.signUp,n),{loginId:t,URI:s,user:o}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>E(e.post($(r.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:ce(((t,n,s,o)=>E(e.post(r.update.email,{loginId:t,email:n,URI:s},{token:o})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:de(((t,s,o,i)=>E(e.post($(r.update.phone,n),{loginId:t,phone:s,URI:o},{token:i}))))})),{})}}),pe=Z("loginId"),ge=Z("uri"),he=N(Z("token")),ve=N(pe,ge),fe=N(Z("pendingRef")),me=N(pe,_("email"),ge),Ie=e=>({verify:he((t=>E(e.post(u.verify,{token:t})))),signIn:ve(((t,n,s,o)=>E(e.post($(u.signIn,W.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:ve(((t,n)=>E(e.post($(u.signUpOrIn,W.email),{loginId:t,URI:n})))),signUp:ve(((t,n,s)=>E(e.post($(u.signUp,W.email),{loginId:t,URI:n,user:s})))),waitForSession:fe(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let a;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),a&&clearTimeout(a),s(E(Promise.resolve(n))))}),o);a=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,o)=>E(e.post(u.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var ke;!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"}(ke||(ke={}));const be=N(Z("code")),ye=e=>({start:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const a=await e.post(d.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r}})),{}),exchange:be((t=>E(e.post(d.exchange,{code:t}))))}),Oe=N(Z("flowId")),we=N(Z("executionId"),Z("stepId"),Z("interactionId")),je=e=>({start:Oe(((t,n,s,o)=>E(e.post(m.start,{flowId:t,options:n,interactionId:s,input:o})))),next:we(((t,n,s,o)=>E(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Ue=N(Z("tenant")),xe=N(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(c.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r})),exchange:xe((t=>E(e.post(c.exchange,{code:t}))))}),Re=Z("loginId"),qe=N(Re,Z("code")),$e=N(Re),Ee=N(Re),Me=e=>({signUp:$e(((t,n)=>E(e.post(l.signUp,{loginId:t,user:n})))),verify:qe(((t,n,s,o)=>E(e.post(l.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Ee(((t,n)=>E(e.post(l.update,{loginId:t},{token:n}))))}),Se=[D(`"${"loginId"}" must be a string`)];const Te=Z("loginId"),Ae=Z("origin"),He=N(Te,Ae,Z("name")),Le=N(Te,Ae),ze=N(Se,Ae),Je=N(Te,Ae,Z("token")),Ce=N(Z("transactionId"),Z("response")),De=e=>({signUp:{start:He(((t,n,s)=>E(e.post(p.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Ce(((t,n)=>E(e.post(p.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ze(((t,n,s,o)=>E(e.post(p.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Ce(((t,n)=>E(e.post(p.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Le(((t,n)=>E(e.post(p.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Je(((t,n,s)=>E(e.post(p.update.start,{loginId:t,origin:n},{token:s})))),finish:Ce(((t,n)=>E(e.post(p.update.finish,{transactionId:t,response:n}))))}}),Ne=N(Z("token"));var Ze,_e;var Be=N([(Ze="projectId",_e=Z("projectId"),M(((e,t)=>n=>S(...t).validate(o.default(n,e)))(Ze,_e))())])((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:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={}})=>{return a=j({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i}}),{accessKey:F(a),otp:oe(a),magicLink:le(a),enchantedLink:Ie(a),oauth:ye(a),saml:Pe(a),totp:Me(a),webauthn:De(a),flow:je(a),refresh:e=>E(a.post(g,{},{token:e})),logout:e=>E(a.post(h,{},{token:e})),logoutAll:e=>E(a.post(v,{},{token:e})),me:e=>E(a.get(f,{token:e})),isJwtExpired:Ne(P),getJwtPermissions:Ne(R),getJwtRoles:Ne(q),httpClient:a};var a})));var Ke=Object.assign(Be,{DeliveryMethods:W});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=Ke,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);
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/constants/apiPaths.ts","../../src/constants/index.ts","../../src/httpClient/helpers/createFetchLogger.ts","../../src/httpClient/types.ts","../../src/httpClient/urlBuilder.ts","../../src/httpClient/utils.ts","../../src/httpClient/index.ts","../../src/sdk/helpers/index.ts","../../src/sdk/validations/core.ts","../../src/sdk/validations/validators.ts","../../src/sdk/validations/index.ts","../../src/sdk/accesskey.ts","../../src/sdk/types.ts","../../src/sdk/otp.ts","../../src/sdk/magicLink/validations.ts","../../src/sdk/magicLink/index.ts","../../src/sdk/enchantedLink/validations.ts","../../src/sdk/enchantedLink/index.ts","../../src/sdk/oauth/types.ts","../../src/sdk/oauth/index.ts","../../src/sdk/flow.ts","../../src/sdk/saml.ts","../../src/sdk/totp.ts","../../src/sdk/webauthn.ts","../../src/sdk/index.ts","../../src/createSdk.ts","../../src/index.ts","../../src/utils/index.ts","../../src/utils/wrapWith/index.ts"],"sourcesContent":["/** API paths for the Descope service APIs */\nexport default {\n\taccessKey: {\n\t\texchange: '/v1/auth/accesskey/exchange'\n\t},\n\totp: {\n\t\tverify: '/v1/auth/otp/verify',\n\t\tsignIn: '/v1/auth/otp/signin',\n\t\tsignUp: '/v1/auth/otp/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/otp/update/email',\n\t\t\tphone: '/v1/auth/otp/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/otp/signup-in'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/magiclink/signin',\n\t\tsignUp: '/v1/auth/magiclink/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\tenchantedLink: {\n\t\tverify: '/v1/auth/enchantedlink/verify',\n\t\tsignIn: '/v1/auth/enchantedlink/signin',\n\t\tsignUp: '/v1/auth/enchantedlink/signup',\n\t\tsession: '/v1/auth/enchantedlink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/enchantedlink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/enchantedlink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize',\n\t\texchange: '/v1/auth/oauth/exchange'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize',\n\t\texchange: '/v1/auth/saml/exchange'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/totp/verify',\n\t\tsignUp: '/v1/auth/totp/signup',\n\t\tupdate: '/v1/auth/totp/update'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/auth/webauthn/signup/start',\n\t\t\tfinish: '/v1/auth/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/auth/webauthn/signin/start',\n\t\t\tfinish: '/v1/auth/webauthn/signin/finish'\n\t\t},\n\t\tsignUpOrIn: {\n\t\t\tstart: '/v1/auth/webauthn/signup-in/start'\n\t\t},\n\t\tupdate: {\n\t\t\tstart: 'v1/auth/webauthn/update/start',\n\t\t\tfinish: '/v1/auth/webauthn/update/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logout',\n\tlogoutAll: '/v1/auth/logoutall',\n\tme: '/v1/auth/me',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t}\n};\n","/** Default Descope API URL */\nexport const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\n/** Default magic link polling interval for checking if the user clicked on the magic link */\nexport const ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\n/** Default maximum time we are willing to wait for the magic link to be clicked */\nexport const ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\n/** API paths to the Descope service */\nexport { default as apiPaths } from './apiPaths';\n","import { Logger } from '../../sdk/types';\n\n/** Build a log message around HTTP calls */\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\n/** Log the request object */\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\n/** Log the response object */\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await (resp.clone ? resp.clone().text() : resp.text());\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\n/**\n * Create a fetch with a logger wrapped around it if a logger is given\n * @param logger Logger to send the logs to\n * @param receivedFetch Fetch to be used or built-in fetch if not provided\n *\n */\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","import { Logger } from '../sdk/types';\n\n/** Request configuration including headers, query params and token */\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\n/** HTTP methods we use in the client */\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\n/** HTTP Client type that implements the HTTP method calls. Descopers can provide their own HTTP client although required only in rare cases. */\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\thooks?: Hooks;\n};\n\n/** Parameters for the HTTP client. Defaults should work for most cases. */\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** For before-request hook allows overriding parts of the request */\nexport type RequestConfig = {\n\tpath: string;\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\tbody?: any;\n\tmethod: HTTPMethods;\n\ttoken?: string;\n};\n\nexport type BeforeRequest = (config: RequestConfig) => RequestConfig;\nexport type AfterRequest = (req: RequestConfig, res: Response) => void;\n\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: BeforeRequest;\n\tafterRequest?: AfterRequest;\n};\n","/** Build URL with given parts */\nexport const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\n/** Merge the given list of headers into a single Headers object */\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\n/** Serialize the body to JSON */\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import createFetchLogger from './helpers/createFetchLogger';\nimport { CreateHttpClientConfig, HttpClient, HTTPMethods, RequestConfig } from './types';\nimport { urlBuilder } from './urlBuilder';\nimport { mergeHeaders, serializeBody } from './utils';\n\n/**\n * Create a Bearer authorization header with concatenated projectId and token\n * @param projectId The project id to use in the header\n * @param token Token to be concatenated. Defaults to empty.\n */\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token) {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\ndeclare const BUILD_VERSION: string;\n\n/**\n * Create descope custom headers\n */\nconst createDescopeHeaders = () => {\n\treturn {\n\t\t'x-descope-sdk-name': 'core-js',\n\t\t'x-descope-sdk-version': BUILD_VERSION\n\t};\n};\n\n/**\n * Create the HTTP client used to send HTTP requests to the Descope API\n *\n * @param CreateHttpClientConfig Configuration for the client\n */\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n\tcookiePolicy\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = async (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\tconst res = await fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tcreateDescopeHeaders(),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body),\n\t\t\tcredentials: cookiePolicy || 'include'\n\t\t});\n\n\t\tif (hooks?.afterRequest) {\n\t\t\thooks.afterRequest(config, res?.clone());\n\t\t}\n\n\t\treturn res;\n\t};\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token }),\n\t\thooks\n\t};\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { ResponseData, SdkResponse } from '../types';\n\nfunction getJwtAuthorizationItems(token: string, tenant: string, claim: string): string[] {\n\tlet claims: any = parseJwt(token);\n\tif (tenant) {\n\t\tclaims = claims.tenants?.[tenant];\n\t}\n\tconst items = claims[claim];\n\treturn Array.isArray(items) ? items : [];\n}\n\nfunction parseJwt(token: string): JwtPayload {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\treturn jwtDecode(token);\n}\n\n/**\n * Checks if the given JWT is still valid but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function isJwtExpired(token: string): boolean {\n\tconst { exp } = parseJwt(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\treturn currentTime > exp;\n}\n\n/**\n * Returns the list of permissions granted in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtPermissions(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'permissions');\n}\n\n/**\n * Returns the list of roles specified in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtRoles(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'roles');\n}\n\n/** Joins path parts making sure there is only one path separator between parts */\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\n/** Transform the Promise Response to our internal SdkResponse implementation\n * @param response The Response promise from fetch\n * @param transform Optionally transform the response JSON to another type\n */\nexport async function transformResponse<T extends ResponseData, S extends ResponseData = T>(\n\tresponse: Promise<Response>,\n\ttransform?: (data: T) => S\n): Promise<SdkResponse<S>> {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse<S> = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.clone().json();\n\n\tif (!resp.ok) {\n\t\tret.error = data;\n\t} else if (transform) {\n\t\tret.data = transform(data);\n\t} else {\n\t\tret.data = <S>data;\n\t}\n\n\treturn ret;\n}\n","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const string = (fieldName: string) => [isString(`\"${fieldName}\" must be a string`)];\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { ExchangeAccessKeyResponse, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('accessKey'));\n\nconst withAccessKeys = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(accessKey: string): Promise<SdkResponse<ExchangeAccessKeyResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.accessKey.exchange, {}, { token: accessKey }))\n\t)\n});\n\nexport default withAccessKeys;\n","type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;\n\ntype DeviceInfo = {\n\twebAuthnSupport?: boolean;\n};\n\ntype LocalUser = {\n\tauthMethod?: AuthMethod;\n\toauthProvider?: string;\n\tloginId?: string;\n};\n\ntype AuthMethod = 'otp' | 'magiclink' | 'social' | 'sso' | 'webauthn' | 'totp';\n\n/** User base details from Descope API */\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\n/** User extended details from Descope API */\nexport type UserResponse = User & {\n\tloginIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n\tpicture?: string;\n};\n\n/** Login options to be added to the different authentication methods */\nexport type LoginOptions = {\n\tstepup?: boolean;\n\tmfa?: boolean;\n\tcustomClaims?: Record<string, any>;\n};\n\n/** Authentication info result from the various JWT validations */\nexport type JWTResponse = {\n\tsessionJwt: string;\n\trefreshJwt?: string;\n\tcookieDomain?: string;\n\tcookiePath?: string;\n\tcookieMaxAge?: number;\n\tcookieExpiration?: number;\n\tuser?: UserResponse;\n\tfirstSeen?: boolean;\n};\n\n/** Authentication info result from exchanging access keys for a session */\nexport type ExchangeAccessKeyResponse = {\n\tkeyId: string;\n\tsessionJwt: string;\n\texpiration: number;\n};\n\n/** The response returned from the various start webauthn functions */\nexport type WebAuthnStartResponse = {\n\ttransactionId: string;\n\toptions: string;\n\tcreate: boolean;\n};\n\n/** Enchanted link response */\nexport type EnchantedLinkResponse = {\n\t/** Pending reference URL to poll while waiting for user to click magic link */\n\tpendingRef: string;\n\t/** Link id, on which link the user should click */\n\tlinkId: string;\n};\n\n/** URL response to redirect user in case of OAuth or SSO */\nexport type URLResponse = {\n\turl: string;\n};\n\n/** TOTP response with the TOTP details */\nexport type TOTPResponse = {\n\tprovisioningURL: string;\n\timage: string;\n\tkey: string;\n};\n\n/** Phone delivery methods which are currently supported */\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All delivery methods currently supported */\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All flow execution statuses\n * - waiting - flow execution is waiting for user interaction\n * - running - flow execution is currently running\n * - completed - flow execution completed successfully\n * - failed - flow execution failed\n */\nexport enum FlowStatus {\n\twaiting = 'waiting',\n\trunning = 'running',\n\tcompleted = 'completed',\n\tfailed = 'failed'\n}\n\n/** All flow response action\n * - screen - next action is to render screen\n * - poll - next action is poll for next after timeout\n * - redirect - next action is to redirect (redirection details in 'redirect' attribute)\n * - webauthnCreate/webauthnGet - next action is to prompt webauthn (details in 'webauthn' attribute)\n * - none - no next action\n */\nexport type FlowAction = 'screen' | 'poll' | 'redirect' | 'webauthnCreate' | 'webauthnGet' | 'none';\n\n/** Flow response with flow execution details */\nexport type FlowResponse = {\n\t// current execution identifier\n\texecutionId: string;\n\t// current step identifier\n\tstepId: string;\n\t// flow execution status\n\tstatus: FlowStatus;\n\t// the next required action\n\taction: FlowAction;\n\t// screen data - if action is 'screen'\n\tscreen?: {\n\t\t// screen identifier\n\t\tid: string;\n\t\t// extra dynamic state required for rendering screen\n\t\tstate: Record<string, any>;\n\t};\n\t// redirect data - if action is 'redirect'\n\tredirect?: {\n\t\turl: string;\n\t};\n\t// webauthn data - if action is one of 'webauthnCreate', 'webauthnGet'\n\twebauthn?: {\n\t\ttransactionId: string;\n\t\toptions: string;\n\t\tcreate: boolean;\n\t};\n\t// an error that occurred during flow execution, used for debugging / integrating\n\terror?: {\n\t\tcode: string;\n\t\tdescription: string;\n\t\tmessage: string;\n\t};\n\t// authentication information response, if response is authenticated\n\tauthInfo?: JWTResponse;\n};\n\nexport type Options = {\n\tredirectUrl?: string;\n\ttenant?: string;\n\tdeviceInfo?: DeviceInfo;\n\tlastUser?: LocalUser;\n};\n\nexport type ResponseData = Record<string, any>;\n\n/**\n * Response from our SDK calls which includes the result (ok, code, error).\n * The relevant data is provided in the more specific interfaces extending SdkResponse.\n */\nexport type SdkResponse<T extends ResponseData> = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\terrorCode: string;\n\t\terrorDescription?: string;\n\t};\n\tdata?: T;\n};\n\n/** Different delivery method */\nexport type Deliveries<T extends SdkFn> = Record<keyof typeof DeliveryMethods, T>;\n\n/** The different routes (actions) we can do */\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\n/** Logger type that supports the given levels (debug, log, error) */\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveries,\n\tUser,\n\tSdkResponse,\n\tJWTResponse,\n\tDeliveryPhone,\n\tLoginOptions\n} from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (loginId: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (loginId: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (loginId: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (loginId: string, phone: string) => Promise<SdkResponse<never>>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(loginIdValidations);\nconst withUpdatePhoneValidations = withValidations(loginIdValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(loginIdValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(loginId: string, code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.otp.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { loginId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.otp.update.email, { loginId, email }, { token }))\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(loginId: string, phone: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveryPhone,\n\tSdkResponse,\n\tJWTResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tURI: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, URI, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { loginId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, uri: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.magicLink.update.email, { loginId, email, URI: uri }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(\n\t\t\t\t\t\tloginId: string,\n\t\t\t\t\t\tphone: string,\n\t\t\t\t\t\turi: string,\n\t\t\t\t\t\ttoken?: string\n\t\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLink;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tSdkResponse,\n\tJWTResponse,\n\tEnchantedLinkResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { EnchantedLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations\n} from './validations';\n\n/** Polling configuration with defaults and normalizing checks */\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withEnchantedLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<never>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.enchantedLink.verify, { token }))\n\t),\n\n\tsignIn: withSignValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tURI: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(\n\t\t\t\t\tpathJoin(apiPaths.enchantedLink.signIn, DeliveryMethods.email),\n\t\t\t\t\t{\n\t\t\t\t\t\tloginId,\n\t\t\t\t\t\tURI,\n\t\t\t\t\t\tloginOptions\n\t\t\t\t\t},\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUpOrIn: withSignValidations(\n\t\t(loginId: string, URI: string): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUpOrIn, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUp: withSignValidations(\n\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUp, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI,\n\t\t\t\t\tuser\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse<JWTResponse>> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.enchantedLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tmessage: `Session polling timeout exceeded: ${timeoutMs}ms`,\n\t\t\t\t\t\t\terrorCode: '0'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\temail: string,\n\t\t\t\turi: string,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.enchantedLink.update.email,\n\t\t\t\t\t\t{ loginId, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withEnchantedLink;\n","import { SdkResponse, URLResponse, JWTResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple',\n\tdiscord = 'discord',\n\tlinkedin = 'linkedin'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\ntype VerifyFn = (code: string) => Promise<SdkResponse<JWTResponse>>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from '../types';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\nimport { stringNonEmpty, withValidations } from '../validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (\n\t\t\t\tredirectUrl?: string,\n\t\t\t\t{ redirect = false } = {},\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t) => {\n\t\t\t\tconst resp = await httpClient.post(apiPaths.oauth.start, loginOptions || {}, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) },\n\t\t\t\t\ttoken\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok)\n\t\t\t\t\treturn transformResponse<SdkResponse<URLResponse>>(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.oauth.exchange, { code }))\n\t)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { FlowResponse, Options, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('interactionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations(\n\t\t(\n\t\t\tflowId: string,\n\t\t\toptions?: Options,\n\t\t\tinteractionId?: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.start, { flowId, options, interactionId, input })\n\t\t\t)\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tinteractionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, interactionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (\n\t\t\ttenantNameOrEmail: string,\n\t\t\tredirectUrl?: string,\n\t\t\t{ redirect = false } = {},\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t) => {\n\t\t\tconst resp = await httpClient.post(apiPaths.saml.start, loginOptions || {}, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl },\n\t\t\t\ttoken\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.saml.exchange, { code }))\n\t)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse, JWTResponse, TOTPResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(loginIdValidations);\nconst withUpdateValidations = withValidations(loginIdValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(loginId: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { loginId, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tcode: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.verify, { loginId, code, loginOptions }, { token })\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(loginId: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.update, { loginId }, { token }))\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport {\n\tSdkResponse,\n\tResponseData,\n\tLoginOptions,\n\tJWTResponse,\n\tWebAuthnStartResponse\n} from './types';\nimport { string, stringNonEmpty, withValidations } from './validations';\n\nconst loginIdStringValidations = string('loginId');\nconst loginIdNonEmptyValidations = stringNonEmpty('loginId');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignUpOrInStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations\n);\nconst withSignInStartValidations = withValidations(loginIdStringValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tname: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.signIn.start,\n\t\t\t\t\t\t{ loginId, origin, loginOptions },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignUpOrIn: {\n\t\tstart: withSignUpOrInStartValidations(\n\t\t\t(loginId: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.webauthn.signUpOrIn.start, { loginId, origin }))\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\ttoken: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.start, { loginId, origin }, { token })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<ResponseData>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withAccessKeys from './accesskey';\nimport withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport { isJwtExpired, getJwtPermissions, getJwtRoles, transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport withEnchantedLink from './enchantedLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\nimport { UserResponse, JWTResponse } from './types';\n\nconst withJwtValidations = withValidations(stringNonEmpty('token'));\n\n/** Returns Descope SDK with all available operations */\nexport default (httpClient: HttpClient) => ({\n\taccessKey: withAccessKeys(httpClient),\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\tenchantedLink: withEnchantedLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) =>\n\t\ttransformResponse<JWTResponse>(httpClient.post(apiPaths.refresh, {}, { token })),\n\tlogout: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logout, {}, { token })),\n\tlogoutAll: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logoutAll, {}, { token })),\n\tme: (token?: string) => transformResponse<UserResponse>(httpClient.get(apiPaths.me, { token })),\n\tisJwtExpired: withJwtValidations(isJwtExpired),\n\tgetJwtPermissions: withJwtValidations(getJwtPermissions),\n\tgetJwtRoles: withJwtValidations(getJwtRoles),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport { AfterRequest, BeforeRequest, Hooks } from './httpClient/types';\nimport createSdk from './sdk';\nimport { Logger } from './sdk/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Add the ability to pass multiple hooks instead of one when creating an SDK instance */\nconst withMultipleHooks =\n\t<T extends object>(createSdk: (config: SdkConfig) => T) =>\n\t(\n\t\tconfig: Omit<SdkConfig, 'hooks'> & {\n\t\t\thooks?: {\n\t\t\t\tbeforeRequest?: BeforeRequest | BeforeRequest[];\n\t\t\t\tafterRequest?: AfterRequest | AfterRequest[];\n\t\t\t};\n\t\t}\n\t) => {\n\t\tconst beforeRequestHooks = [].concat(config.hooks?.beforeRequest || []);\n\t\tconst afterRequestHooks = [].concat(config.hooks?.afterRequest || []);\n\n\t\tconst beforeRequest: BeforeRequest = (config) =>\n\t\t\tbeforeRequestHooks?.reduce((acc, fn) => fn(acc), config);\n\t\tconst afterRequest: AfterRequest = (req, res) => {\n\t\t\tafterRequestHooks?.forEach((fn) => fn(req, res?.clone()));\n\t\t};\n\n\t\treturn createSdk({ ...config, hooks: { beforeRequest, afterRequest } });\n\t};\n\n/** Descope SDK client */\nexport default withSdkConfigValidations(\n\twithMultipleHooks(({ projectId, logger, baseUrl, hooks, cookiePolicy }: SdkConfig) =>\n\t\tcreateSdk(\n\t\t\tcreateHttpClient({\n\t\t\t\tbaseUrl: baseUrl || DEFAULT_BASE_API_URL,\n\t\t\t\tprojectId,\n\t\t\t\tlogger,\n\t\t\t\thooks,\n\t\t\t\tcookiePolicy\n\t\t\t})\n\t\t)\n\t)\n);\n","import createSdk from './createSdk';\nimport { HTTPMethods, RequestConfig } from './httpClient/types';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods } from './sdk/types';\n\n/** Descope SDK client with delivery methods enum.\n *\n * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}\n * @example Usage\n *\n * ```js\n * import descopeSdk from '@descope/core-js-sdk';\n *\n * const myProjectId = 'xxx';\n * const sdk = descopeSdk({ projectId: myProjectId });\n *\n * const userLoginId = 'loginId';\n * sdk.otp.signIn.email(userLoginId);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(createSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport type {\n\tEnchantedLinkResponse,\n\tExchangeAccessKeyResponse,\n\tFlowAction,\n\tFlowResponse,\n\tFlowStatus,\n\tJWTResponse,\n\tResponseData,\n\tSdkResponse,\n\tTOTPResponse,\n\tURLResponse,\n\tUserResponse\n} from './sdk/types';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\nexport type { HTTPMethods, RequestConfig };\n\n/** Type to restrict to valid delivery methods */\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\n/** Type to restrict to valid OAuth providers */\nexport type OAuthProvider = keyof typeof OAuthProviders;\n","import { SdkConfig } from '../types';\n\nexport { default as wrapWith } from './wrapWith';\nexport type { SdkFnWrapper } from './wrapWith/types';\n\n/**\n * Add hooks to an existing core-sdk config\n */\nexport const addHooksToConfig = <Config extends SdkConfig>(\n\tconfig: Config,\n\thooks: Config['hooks']\n): Config => {\n\t['beforeRequest', 'afterRequest'].reduce((acc, key) => {\n\t\tacc[key] = [].concat(config.hooks?.[key] || []).concat(hooks?.[key] || []);\n\n\t\treturn acc;\n\t}, (config.hooks ??= {}));\n\n\treturn config;\n};\n","/* eslint-disable import/exports-last */\nimport { ResponseData } from '../../sdk/types';\nimport { SdkFnWrapper, ReplacePaths, SdkFnsPaths } from './types';\n\n/**\n * A wrapper function that allows to wrap multiple Sdk function\n * @param obj: The Sdk instance you want to wrap\n * @param paths: A readonly list of paths of the functions you want to wrap\n * @param wrapper: Your wrapper function, it should gets an Sdk function and return a new Sdk function\n * @returns a mutated instance of the Sdk with updated type definitions based on your wrapper return type\n *\n * Usage example:\n *\n * // Assuming this is our SDK instance\n * const sdk = {\n * me: (token) => {...}\n * flow: {\n * start: (...params) => {...}\n * next: (...params) => {...}\n * }\n * ...\n * }\n *\n * // This is our wrapper\n * const wrapper = (sdkFn) => async (...args) => {\n * const sdkResponse = await sdkFn(...args)\n *\n * // Modify return value\n * return {...sdkResponse, data: {...sdkResponse.data, myCustomAttribute: 'hello'}}\n * }\n *\n * // And those are the paths we want to wrap\n * const paths = ['flow.start', 'flow.next'] as const // You MUST add as const!\n *\n * // We can wrap our SDK functions with the wrapper we created in this way\n * const newlyTypedSdk = wrapWith(sdk, paths, wrapper)\n *\n * Now the 2 wrapped functions will have the updated type based on the wrapper return value\n */\n\nconst wrapWith = <\n\tObj extends object,\n\tPaths extends ReadonlyArray<SdkFnsPaths<Obj>>,\n\tWrapperData extends ResponseData\n>(\n\tobj: Obj,\n\tpaths: Paths,\n\twrapper: SdkFnWrapper<WrapperData>\n): ReplacePaths<Obj, Paths, WrapperData> => {\n\tpaths.forEach((path) => {\n\t\tconst sections = path.split('.');\n\t\tlet section = sections.shift();\n\t\tlet currentRef: Record<string, any> = obj;\n\n\t\twhile (sections.length > 0) {\n\t\t\tcurrentRef = currentRef[section];\n\n\t\t\tif (!section || !currentRef) {\n\t\t\t\tthrow Error(`Invalid path \"${path}\", \"${section}\" is missing or has no value`);\n\t\t\t}\n\n\t\t\tsection = sections.shift();\n\t\t}\n\n\t\tif (typeof currentRef[section] !== 'function') {\n\t\t\tthrow Error(`\"${path}\" is not a function`);\n\t\t}\n\t\tconst origFn = currentRef[section];\n\t\tcurrentRef[section] = wrapper(origFn);\n\t});\n\n\treturn obj as any;\n};\n\nexport default wrapWith;\n"],"names":["apiPaths","exchange","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","clone","text","Promise","resolve","json","parse","statusText","buildResponseLog","HTTPMethods","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","cookiePolicy","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","res","URL","search","URLSearchParams","urlBuilder","baseHeaders","credentials","afterRequest","get","post","put","delete","getJwtAuthorizationItems","tenant","claim","claims","parseJwt","tenants","_a","items","jwtDecode","isJwtExpired","exp","Date","getTime","getJwtPermissions","getJwtRoles","pathJoin","replace","transformResponse","response","transform","ret","code","data","error","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","withExchangeValidations","withAccessKeys","httpClient","accessKey","DeliveryPhone","DeliveryMethods","FlowStatus","Routes","loginIdValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","loginId","loginOptions","user","uriValidations","withMagicLink","URI","uri","withWaitForSessionValidations","withEnchantedLink","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","errorCode","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","options","interactionId","input","executionId","stepId","withSaml","tenantNameOrEmail","withSignUpValidations","withUpdateValidations","withTotp","loginIdStringValidations","loginIdNonEmptyValidations","originValidations","withSignUpStartValidations","withSignUpOrInStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","createSdk","validatePathValue","withSdkConfigValidations","beforeRequestHooks","concat","afterRequestHooks","_b","req","withMultipleHooks","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me","index","obj","paths","wrapper","sections","split","section","shift","currentRef","origFn"],"mappings":"kNACeA,EACH,CACVC,SAAU,+BAFGD,EAIT,CACJE,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BAZCR,EAcH,CACVE,OAAQ,4BACRC,OAAQ,4BACR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,CAAA,EAAI,CAAE8E,WACpEkL,GAAKlL,GAAmB4C,EAAgCuC,EAAW5D,IAAIrG,EAAa,CAAE8E,WACtFoC,aAAcwH,GAAmBxH,GACjCI,kBAAmBoH,GAAmBpH,GACtCC,YAAamH,GAAmBnH,GAChC0C,cApBc,IAACA,CCqCb,KClCH,IAAegG,GAAA/O,OAAO4J,OAAO8D,GAAW,CAAExE,6CCbV,CAC/B5E,EACAJ,WAQA,MANA,CAAC,gBAAiB,gBAAgBpB,QAAO,CAACC,EAAK3B,WAG9C,OAFA2B,EAAI3B,GAAO,GAAG0M,QAAmB,UAAZxJ,EAAOJ,aAAK,IAAA2B,OAAA,EAAAA,EAAGzE,KAAQ,IAAI0M,QAAO5J,aAAA,EAAAA,EAAQ9C,KAAQ,IAEhE2B,CAAG,GACK,QAAb8C,EAACvB,EAAOJ,aAAK,IAAA2B,EAAAA,EAAZvB,EAAOJ,MAAU,CAAA,GAEdI,CAAM,kECsBG,CAKhB0K,EACAC,EACAC,KAEAD,EAAM3H,SAAS7C,IACd,MAAM0K,EAAW1K,EAAK2K,MAAM,KAC5B,IAAIC,EAAUF,EAASG,QACnBC,EAAkCP,EAEtC,KAAOG,EAASjH,OAAS,GAAG,CAG3B,GAFAqH,EAAaA,EAAWF,IAEnBA,IAAYE,EAChB,MAAM5N,MAAM,iBAAiB8C,QAAW4K,iCAGzCA,EAAUF,EAASG,OACnB,CAED,GAAmC,mBAAxBC,EAAWF,GACrB,MAAM1N,MAAM,IAAI8C,wBAEjB,MAAM+K,EAASD,EAAWF,GAC1BE,EAAWF,GAAWH,EAAQM,EAAO,IAG/BR"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/constants/apiPaths.ts","../../src/constants/index.ts","../../src/httpClient/helpers/createFetchLogger.ts","../../src/httpClient/types.ts","../../src/httpClient/urlBuilder.ts","../../src/httpClient/utils.ts","../../src/httpClient/index.ts","../../src/sdk/helpers/index.ts","../../src/sdk/validations/core.ts","../../src/sdk/validations/validators.ts","../../src/sdk/validations/index.ts","../../src/sdk/accesskey.ts","../../src/sdk/types.ts","../../src/sdk/otp.ts","../../src/sdk/magicLink/validations.ts","../../src/sdk/magicLink/index.ts","../../src/sdk/enchantedLink/validations.ts","../../src/sdk/enchantedLink/index.ts","../../src/sdk/oauth/types.ts","../../src/sdk/oauth/index.ts","../../src/sdk/flow.ts","../../src/sdk/saml.ts","../../src/sdk/totp.ts","../../src/sdk/webauthn.ts","../../src/sdk/index.ts","../../src/createSdk.ts","../../src/index.ts","../../src/utils/index.ts","../../src/utils/wrapWith/index.ts"],"sourcesContent":["/** API paths for the Descope service APIs */\nexport default {\n\taccessKey: {\n\t\texchange: '/v1/auth/accesskey/exchange'\n\t},\n\totp: {\n\t\tverify: '/v1/auth/otp/verify',\n\t\tsignIn: '/v1/auth/otp/signin',\n\t\tsignUp: '/v1/auth/otp/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/otp/update/email',\n\t\t\tphone: '/v1/auth/otp/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/otp/signup-in'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/magiclink/signin',\n\t\tsignUp: '/v1/auth/magiclink/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\tenchantedLink: {\n\t\tverify: '/v1/auth/enchantedlink/verify',\n\t\tsignIn: '/v1/auth/enchantedlink/signin',\n\t\tsignUp: '/v1/auth/enchantedlink/signup',\n\t\tsession: '/v1/auth/enchantedlink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/enchantedlink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/enchantedlink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize',\n\t\texchange: '/v1/auth/oauth/exchange'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize',\n\t\texchange: '/v1/auth/saml/exchange'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/totp/verify',\n\t\tsignUp: '/v1/auth/totp/signup',\n\t\tupdate: '/v1/auth/totp/update'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/auth/webauthn/signup/start',\n\t\t\tfinish: '/v1/auth/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/auth/webauthn/signin/start',\n\t\t\tfinish: '/v1/auth/webauthn/signin/finish'\n\t\t},\n\t\tsignUpOrIn: {\n\t\t\tstart: '/v1/auth/webauthn/signup-in/start'\n\t\t},\n\t\tupdate: {\n\t\t\tstart: 'v1/auth/webauthn/update/start',\n\t\t\tfinish: '/v1/auth/webauthn/update/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logout',\n\tlogoutAll: '/v1/auth/logoutall',\n\tme: '/v1/auth/me',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t}\n};\n","/** Default Descope API URL */\nexport const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\n/** Default magic link polling interval for checking if the user clicked on the magic link */\nexport const ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\n/** Default maximum time we are willing to wait for the magic link to be clicked */\nexport const ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\n/** API paths to the Descope service */\nexport { default as apiPaths } from './apiPaths';\n","import { Logger } from '../../sdk/types';\n\n/** Build a log message around HTTP calls */\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\n/** Log the request object */\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\n/** Log the response object */\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await (resp.clone ? resp.clone().text() : resp.text());\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\n/**\n * Create a fetch with a logger wrapped around it if a logger is given\n * @param logger Logger to send the logs to\n * @param receivedFetch Fetch to be used or built-in fetch if not provided\n *\n */\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","import { Logger } from '../sdk/types';\n\n/** Request configuration including headers, query params and token */\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\n/** HTTP methods we use in the client */\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\n/** HTTP Client type that implements the HTTP method calls. Descopers can provide their own HTTP client although required only in rare cases. */\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\thooks?: Hooks;\n};\n\n/** Parameters for the HTTP client. Defaults should work for most cases. */\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** For before-request hook allows overriding parts of the request */\nexport type RequestConfig = {\n\tpath: string;\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\tbody?: any;\n\tmethod: HTTPMethods;\n\ttoken?: string;\n};\n\nexport type BeforeRequest = (config: RequestConfig) => RequestConfig;\nexport type AfterRequest = (req: RequestConfig, res: Response) => void;\n\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: BeforeRequest;\n\tafterRequest?: AfterRequest;\n};\n","/** Build URL with given parts */\nexport const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\n/** Merge the given list of headers into a single Headers object */\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\n/** Serialize the body to JSON */\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import createFetchLogger from './helpers/createFetchLogger';\nimport { CreateHttpClientConfig, HttpClient, HTTPMethods, RequestConfig } from './types';\nimport { urlBuilder } from './urlBuilder';\nimport { mergeHeaders, serializeBody } from './utils';\n\n/**\n * Create a Bearer authorization header with concatenated projectId and token\n * @param projectId The project id to use in the header\n * @param token Token to be concatenated. Defaults to empty.\n */\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token) {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\ndeclare const BUILD_VERSION: string;\n\n/**\n * Create descope custom headers\n */\nconst createDescopeHeaders = () => {\n\treturn {\n\t\t'x-descope-sdk-name': 'core-js',\n\t\t'x-descope-sdk-version': BUILD_VERSION\n\t};\n};\n\n/**\n * Create the HTTP client used to send HTTP requests to the Descope API\n *\n * @param CreateHttpClientConfig Configuration for the client\n */\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n\tcookiePolicy\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = async (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\tconst res = await fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tcreateDescopeHeaders(),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body),\n\t\t\tcredentials: cookiePolicy || 'include'\n\t\t});\n\n\t\tif (hooks?.afterRequest) {\n\t\t\thooks.afterRequest(config, res?.clone());\n\t\t}\n\n\t\treturn res;\n\t};\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token }),\n\t\thooks\n\t};\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { ResponseData, SdkResponse } from '../types';\n\nfunction getJwtAuthorizationItems(token: string, tenant: string, claim: string): string[] {\n\tlet claims: any = parseJwt(token);\n\tif (tenant) {\n\t\tclaims = claims.tenants?.[tenant];\n\t}\n\tconst items = claims[claim];\n\treturn Array.isArray(items) ? items : [];\n}\n\nfunction parseJwt(token: string): JwtPayload {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\treturn jwtDecode(token);\n}\n\n/**\n * Checks if the given JWT is still valid but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function isJwtExpired(token: string): boolean {\n\tconst { exp } = parseJwt(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\treturn currentTime > exp;\n}\n\n/**\n * Returns the list of permissions granted in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtPermissions(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'permissions');\n}\n\n/**\n * Returns the list of roles specified in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtRoles(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'roles');\n}\n\n/** Joins path parts making sure there is only one path separator between parts */\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\n/** Transform the Promise Response to our internal SdkResponse implementation\n * @param response The Response promise from fetch\n * @param transform Optionally transform the response JSON to another type\n */\nexport async function transformResponse<T extends ResponseData, S extends ResponseData = T>(\n\tresponse: Promise<Response>,\n\ttransform?: (data: T) => S\n): Promise<SdkResponse<S>> {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse<S> = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.clone().json();\n\n\tif (!resp.ok) {\n\t\tret.error = data;\n\t} else if (transform) {\n\t\tret.data = transform(data);\n\t} else {\n\t\tret.data = <S>data;\n\t}\n\n\treturn ret;\n}\n","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const string = (fieldName: string) => [isString(`\"${fieldName}\" must be a string`)];\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { ExchangeAccessKeyResponse, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('accessKey'));\n\nconst withAccessKeys = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(accessKey: string): Promise<SdkResponse<ExchangeAccessKeyResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.accessKey.exchange, {}, { token: accessKey }))\n\t)\n});\n\nexport default withAccessKeys;\n","type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;\n\ntype DeviceInfo = {\n\twebAuthnSupport?: boolean;\n};\n\ntype LocalUser = {\n\tauthMethod?: AuthMethod;\n\toauthProvider?: string;\n\tloginId?: string;\n};\n\ntype AuthMethod = 'otp' | 'magiclink' | 'social' | 'sso' | 'webauthn' | 'totp';\n\n/** User base details from Descope API */\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\n/** User extended details from Descope API */\nexport type UserResponse = User & {\n\tloginIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n\tpicture?: string;\n};\n\n/** Login options to be added to the different authentication methods */\nexport type LoginOptions = {\n\tstepup?: boolean;\n\tmfa?: boolean;\n\tcustomClaims?: Record<string, any>;\n};\n\n/** Authentication info result from the various JWT validations */\nexport type JWTResponse = {\n\tsessionJwt: string;\n\trefreshJwt?: string;\n\tcookieDomain?: string;\n\tcookiePath?: string;\n\tcookieMaxAge?: number;\n\tcookieExpiration?: number;\n\tuser?: UserResponse;\n\tfirstSeen?: boolean;\n};\n\n/** Authentication info result from exchanging access keys for a session */\nexport type ExchangeAccessKeyResponse = {\n\tkeyId: string;\n\tsessionJwt: string;\n\texpiration: number;\n};\n\n/** The response returned from the various start webauthn functions */\nexport type WebAuthnStartResponse = {\n\ttransactionId: string;\n\toptions: string;\n\tcreate: boolean;\n};\n\n/** Enchanted link response */\nexport type EnchantedLinkResponse = {\n\t/** Pending reference URL to poll while waiting for user to click magic link */\n\tpendingRef: string;\n\t/** Link id, on which link the user should click */\n\tlinkId: string;\n};\n\n/** URL response to redirect user in case of OAuth or SSO */\nexport type URLResponse = {\n\turl: string;\n};\n\n/** TOTP response with the TOTP details */\nexport type TOTPResponse = {\n\tprovisioningURL: string;\n\timage: string;\n\tkey: string;\n};\n\n/** Phone delivery methods which are currently supported */\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All delivery methods currently supported */\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All flow execution statuses\n * - waiting - flow execution is waiting for user interaction\n * - running - flow execution is currently running\n * - completed - flow execution completed successfully\n * - failed - flow execution failed\n */\nexport enum FlowStatus {\n\twaiting = 'waiting',\n\trunning = 'running',\n\tcompleted = 'completed',\n\tfailed = 'failed'\n}\n\n/** All flow response action\n * - screen - next action is to render screen\n * - poll - next action is poll for next after timeout\n * - redirect - next action is to redirect (redirection details in 'redirect' attribute)\n * - webauthnCreate/webauthnGet - next action is to prompt webauthn (details in 'webauthn' attribute)\n * - none - no next action\n */\nexport type FlowAction = 'screen' | 'poll' | 'redirect' | 'webauthnCreate' | 'webauthnGet' | 'none';\n\n/** Flow response with flow execution details */\nexport type FlowResponse = {\n\t// current execution identifier\n\texecutionId: string;\n\t// current step identifier\n\tstepId: string;\n\t// flow execution status\n\tstatus: FlowStatus;\n\t// the next required action\n\taction: FlowAction;\n\t// screen data - if action is 'screen'\n\tscreen?: {\n\t\t// screen identifier\n\t\tid: string;\n\t\t// extra dynamic state required for rendering screen\n\t\tstate: Record<string, any>;\n\t};\n\t// redirect data - if action is 'redirect'\n\tredirect?: {\n\t\turl: string;\n\t};\n\t// webauthn data - if action is one of 'webauthnCreate', 'webauthnGet'\n\twebauthn?: {\n\t\ttransactionId: string;\n\t\toptions: string;\n\t\tcreate: boolean;\n\t};\n\t// an error that occurred during flow execution, used for debugging / integrating\n\terror?: {\n\t\tcode: string;\n\t\tdescription: string;\n\t\tmessage: string;\n\t};\n\t// authentication information response, if response is authenticated\n\tauthInfo?: JWTResponse;\n};\n\nexport type Options = {\n\tredirectUrl?: string;\n\ttenant?: string;\n\tdeviceInfo?: DeviceInfo;\n\tlastUser?: LocalUser;\n};\n\nexport type ResponseData = Record<string, any>;\n\n/**\n * Response from our SDK calls which includes the result (ok, code, error).\n * The relevant data is provided in the more specific interfaces extending SdkResponse.\n */\nexport type SdkResponse<T extends ResponseData> = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\terrorCode: string;\n\t\terrorDescription?: string;\n\t};\n\tdata?: T;\n};\n\n/** Different delivery method */\nexport type Deliveries<T extends SdkFn> = Record<keyof typeof DeliveryMethods, T>;\n\n/** The different routes (actions) we can do */\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\n/** Logger type that supports the given levels (debug, log, error) */\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveries,\n\tUser,\n\tSdkResponse,\n\tJWTResponse,\n\tDeliveryPhone,\n\tLoginOptions\n} from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (loginId: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (loginId: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (loginId: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (loginId: string, phone: string) => Promise<SdkResponse<never>>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(loginIdValidations);\nconst withUpdatePhoneValidations = withValidations(loginIdValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(loginIdValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(loginId: string, code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.otp.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { loginId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.otp.update.email, { loginId, email }, { token }))\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(loginId: string, phone: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveryPhone,\n\tSdkResponse,\n\tJWTResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tURI: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, URI, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { loginId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, uri: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.magicLink.update.email, { loginId, email, URI: uri }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(\n\t\t\t\t\t\tloginId: string,\n\t\t\t\t\t\tphone: string,\n\t\t\t\t\t\turi: string,\n\t\t\t\t\t\ttoken?: string\n\t\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLink;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tSdkResponse,\n\tJWTResponse,\n\tEnchantedLinkResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { EnchantedLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations\n} from './validations';\n\n/** Polling configuration with defaults and normalizing checks */\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withEnchantedLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<never>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.enchantedLink.verify, { token }))\n\t),\n\n\tsignIn: withSignValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tURI: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(\n\t\t\t\t\tpathJoin(apiPaths.enchantedLink.signIn, DeliveryMethods.email),\n\t\t\t\t\t{\n\t\t\t\t\t\tloginId,\n\t\t\t\t\t\tURI,\n\t\t\t\t\t\tloginOptions\n\t\t\t\t\t},\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUpOrIn: withSignValidations(\n\t\t(loginId: string, URI: string): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUpOrIn, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUp: withSignValidations(\n\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUp, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI,\n\t\t\t\t\tuser\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse<JWTResponse>> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.enchantedLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tmessage: `Session polling timeout exceeded: ${timeoutMs}ms`,\n\t\t\t\t\t\t\terrorCode: '0'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\temail: string,\n\t\t\t\turi: string,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.enchantedLink.update.email,\n\t\t\t\t\t\t{ loginId, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withEnchantedLink;\n","import { SdkResponse, URLResponse, JWTResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple',\n\tdiscord = 'discord',\n\tlinkedin = 'linkedin'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\ntype VerifyFn = (code: string) => Promise<SdkResponse<JWTResponse>>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from '../types';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\nimport { stringNonEmpty, withValidations } from '../validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (\n\t\t\t\tredirectUrl?: string,\n\t\t\t\t{ redirect = false } = {},\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t) => {\n\t\t\t\tconst resp = await httpClient.post(apiPaths.oauth.start, loginOptions || {}, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) },\n\t\t\t\t\ttoken\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok)\n\t\t\t\t\treturn transformResponse<SdkResponse<URLResponse>>(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.oauth.exchange, { code }))\n\t)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { FlowResponse, Options, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('interactionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations(\n\t\t(\n\t\t\tflowId: string,\n\t\t\toptions?: Options,\n\t\t\tinteractionId?: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.start, { flowId, options, interactionId, input })\n\t\t\t)\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tinteractionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, interactionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (\n\t\t\ttenantNameOrEmail: string,\n\t\t\tredirectUrl?: string,\n\t\t\t{ redirect = false } = {},\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t) => {\n\t\t\tconst resp = await httpClient.post(apiPaths.saml.start, loginOptions || {}, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl },\n\t\t\t\ttoken\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.saml.exchange, { code }))\n\t)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse, JWTResponse, TOTPResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(loginIdValidations);\nconst withUpdateValidations = withValidations(loginIdValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(loginId: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { loginId, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tcode: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.verify, { loginId, code, loginOptions }, { token })\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(loginId: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.update, { loginId }, { token }))\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport {\n\tSdkResponse,\n\tResponseData,\n\tLoginOptions,\n\tJWTResponse,\n\tWebAuthnStartResponse\n} from './types';\nimport { string, stringNonEmpty, withValidations } from './validations';\n\nconst loginIdStringValidations = string('loginId');\nconst loginIdNonEmptyValidations = stringNonEmpty('loginId');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignUpOrInStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations\n);\nconst withSignInStartValidations = withValidations(loginIdStringValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tname: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.signIn.start,\n\t\t\t\t\t\t{ loginId, origin, loginOptions },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignUpOrIn: {\n\t\tstart: withSignUpOrInStartValidations(\n\t\t\t(loginId: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.webauthn.signUpOrIn.start, { loginId, origin }))\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\ttoken: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.start, { loginId, origin }, { token })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<ResponseData>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withAccessKeys from './accesskey';\nimport withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport { isJwtExpired, getJwtPermissions, getJwtRoles, transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport withEnchantedLink from './enchantedLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\nimport { UserResponse, JWTResponse } from './types';\n\nconst withJwtValidations = withValidations(stringNonEmpty('token'));\n\n/** Returns Descope SDK with all available operations */\nexport default (httpClient: HttpClient) => ({\n\taccessKey: withAccessKeys(httpClient),\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\tenchantedLink: withEnchantedLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) =>\n\t\ttransformResponse<JWTResponse>(httpClient.post(apiPaths.refresh, {}, { token })),\n\tlogout: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logout, {}, { token })),\n\tlogoutAll: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logoutAll, {}, { token })),\n\tme: (token?: string) => transformResponse<UserResponse>(httpClient.get(apiPaths.me, { token })),\n\tisJwtExpired: withJwtValidations(isJwtExpired),\n\tgetJwtPermissions: withJwtValidations(getJwtPermissions),\n\tgetJwtRoles: withJwtValidations(getJwtRoles),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport { AfterRequest, BeforeRequest, Hooks } from './httpClient/types';\nimport createSdk from './sdk';\nimport { Logger } from './sdk/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n\tbaseHeaders?: HeadersInit;\n};\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Add the ability to pass multiple hooks instead of one when creating an SDK instance */\nconst withMultipleHooks =\n\t<T extends object>(createSdk: (config: SdkConfig) => T) =>\n\t(\n\t\tconfig: Omit<SdkConfig, 'hooks'> & {\n\t\t\thooks?: {\n\t\t\t\tbeforeRequest?: BeforeRequest | BeforeRequest[];\n\t\t\t\tafterRequest?: AfterRequest | AfterRequest[];\n\t\t\t};\n\t\t}\n\t) => {\n\t\tconst beforeRequestHooks = [].concat(config.hooks?.beforeRequest || []);\n\t\tconst afterRequestHooks = [].concat(config.hooks?.afterRequest || []);\n\n\t\tconst beforeRequest: BeforeRequest = (config) =>\n\t\t\tbeforeRequestHooks?.reduce((acc, fn) => fn(acc), config);\n\t\tconst afterRequest: AfterRequest = (req, res) => {\n\t\t\tafterRequestHooks?.forEach((fn) => fn(req, res?.clone()));\n\t\t};\n\n\t\treturn createSdk({ ...config, hooks: { beforeRequest, afterRequest } });\n\t};\n\n/** Descope SDK client */\nexport default withSdkConfigValidations(\n\twithMultipleHooks(\n\t\t({ projectId, logger, baseUrl, hooks, cookiePolicy, baseHeaders = {} }: SdkConfig) =>\n\t\t\tcreateSdk(\n\t\t\t\tcreateHttpClient({\n\t\t\t\t\tbaseUrl: baseUrl || DEFAULT_BASE_API_URL,\n\t\t\t\t\tprojectId,\n\t\t\t\t\tlogger,\n\t\t\t\t\thooks,\n\t\t\t\t\tcookiePolicy,\n\t\t\t\t\tbaseConfig: { baseHeaders }\n\t\t\t\t})\n\t\t\t)\n\t)\n);\n","import createSdk from './createSdk';\nimport { HTTPMethods, RequestConfig } from './httpClient/types';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods } from './sdk/types';\n\n/** Descope SDK client with delivery methods enum.\n *\n * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}\n * @example Usage\n *\n * ```js\n * import descopeSdk from '@descope/core-js-sdk';\n *\n * const myProjectId = 'xxx';\n * const sdk = descopeSdk({ projectId: myProjectId });\n *\n * const userLoginId = 'loginId';\n * sdk.otp.signIn.email(userLoginId);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(createSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport type {\n\tEnchantedLinkResponse,\n\tExchangeAccessKeyResponse,\n\tFlowAction,\n\tFlowResponse,\n\tFlowStatus,\n\tJWTResponse,\n\tResponseData,\n\tSdkResponse,\n\tTOTPResponse,\n\tURLResponse,\n\tUserResponse\n} from './sdk/types';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\nexport type { HTTPMethods, RequestConfig };\n\n/** Type to restrict to valid delivery methods */\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\n/** Type to restrict to valid OAuth providers */\nexport type OAuthProvider = keyof typeof OAuthProviders;\n","import { SdkConfig } from '../types';\n\nexport { default as wrapWith } from './wrapWith';\nexport type { SdkFnWrapper } from './wrapWith/types';\n\n/**\n * Add hooks to an existing core-sdk config\n */\nexport const addHooksToConfig = <Config extends SdkConfig>(\n\tconfig: Config,\n\thooks: Config['hooks']\n): Config => {\n\t['beforeRequest', 'afterRequest'].reduce((acc, key) => {\n\t\tacc[key] = [].concat(config.hooks?.[key] || []).concat(hooks?.[key] || []);\n\n\t\treturn acc;\n\t}, (config.hooks ??= {}));\n\n\treturn config;\n};\n","/* eslint-disable import/exports-last */\nimport { ResponseData } from '../../sdk/types';\nimport { SdkFnWrapper, ReplacePaths, SdkFnsPaths } from './types';\n\n/**\n * A wrapper function that allows to wrap multiple Sdk function\n * @param obj: The Sdk instance you want to wrap\n * @param paths: A readonly list of paths of the functions you want to wrap\n * @param wrapper: Your wrapper function, it should gets an Sdk function and return a new Sdk function\n * @returns a mutated instance of the Sdk with updated type definitions based on your wrapper return type\n *\n * Usage example:\n *\n * // Assuming this is our SDK instance\n * const sdk = {\n * me: (token) => {...}\n * flow: {\n * start: (...params) => {...}\n * next: (...params) => {...}\n * }\n * ...\n * }\n *\n * // This is our wrapper\n * const wrapper = (sdkFn) => async (...args) => {\n * const sdkResponse = await sdkFn(...args)\n *\n * // Modify return value\n * return {...sdkResponse, data: {...sdkResponse.data, myCustomAttribute: 'hello'}}\n * }\n *\n * // And those are the paths we want to wrap\n * const paths = ['flow.start', 'flow.next'] as const // You MUST add as const!\n *\n * // We can wrap our SDK functions with the wrapper we created in this way\n * const newlyTypedSdk = wrapWith(sdk, paths, wrapper)\n *\n * Now the 2 wrapped functions will have the updated type based on the wrapper return value\n */\n\nconst wrapWith = <\n\tObj extends object,\n\tPaths extends ReadonlyArray<SdkFnsPaths<Obj>>,\n\tWrapperData extends ResponseData\n>(\n\tobj: Obj,\n\tpaths: Paths,\n\twrapper: SdkFnWrapper<WrapperData>\n): ReplacePaths<Obj, Paths, WrapperData> => {\n\tpaths.forEach((path) => {\n\t\tconst sections = path.split('.');\n\t\tlet section = sections.shift();\n\t\tlet currentRef: Record<string, any> = obj;\n\n\t\twhile (sections.length > 0) {\n\t\t\tcurrentRef = currentRef[section];\n\n\t\t\tif (!section || !currentRef) {\n\t\t\t\tthrow Error(`Invalid path \"${path}\", \"${section}\" is missing or has no value`);\n\t\t\t}\n\n\t\t\tsection = sections.shift();\n\t\t}\n\n\t\tif (typeof currentRef[section] !== 'function') {\n\t\t\tthrow Error(`\"${path}\" is not a function`);\n\t\t}\n\t\tconst origFn = currentRef[section];\n\t\tcurrentRef[section] = wrapper(origFn);\n\t});\n\n\treturn obj as any;\n};\n\nexport default wrapWith;\n"],"names":["apiPaths","exchange","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","clone","text","Promise","resolve","json","parse","statusText","buildResponseLog","HTTPMethods","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","cookiePolicy","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","res","URL","search","URLSearchParams","urlBuilder","baseHeaders","credentials","afterRequest","get","post","put","delete","getJwtAuthorizationItems","tenant","claim","claims","parseJwt","tenants","_a","items","jwtDecode","isJwtExpired","exp","Date","getTime","getJwtPermissions","getJwtRoles","pathJoin","replace","transformResponse","response","transform","ret","code","data","error","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","withExchangeValidations","withAccessKeys","httpClient","accessKey","DeliveryPhone","DeliveryMethods","FlowStatus","Routes","loginIdValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","loginId","loginOptions","user","uriValidations","withMagicLink","URI","uri","withWaitForSessionValidations","withEnchantedLink","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","errorCode","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","options","interactionId","input","executionId","stepId","withSaml","tenantNameOrEmail","withSignUpValidations","withUpdateValidations","withTotp","loginIdStringValidations","loginIdNonEmptyValidations","originValidations","withSignUpStartValidations","withSignUpOrInStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","createSdk","validatePathValue","withSdkConfigValidations","beforeRequestHooks","concat","afterRequestHooks","_b","req","withMultipleHooks","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me","index","obj","paths","wrapper","sections","split","section","shift","currentRef","origFn"],"mappings":"kNACeA,EACH,CACVC,SAAU,+BAFGD,EAIT,CACJE,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BAZCR,EAcH,CACVE,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,gCAtBCR,EAwBC,CACdE,OAAQ,gCACRC,OAAQ,gCACRC,OAAQ,gCACRK,QAAS,yCACTJ,OAAQ,CACPC,MAAO,uCAERE,WAAY,oCAhCCR,EAkCP,CACNU,MAAO,2BACPT,SAAU,2BApCGD,EAsCR,CACLU,MAAO,0BACPT,SAAU,0BAxCGD,EA0CR,CACLE,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA7CKL,EA+CJ,CACTI,OAAQ,CACPM,MAAO,iCACPC,OAAQ,mCAETR,OAAQ,CACPO,MAAO,iCACPC,OAAQ,mCAETH,WAAY,CACXE,MAAO,qCAERL,OAAQ,CACPK,MAAO,gCACPC,OAAQ,oCA7DIX,EAgEL,mBAhEKA,EAiEN,kBAjEMA,EAkEH,qBAlEGA,EAmEV,cAnEUA,EAoER,CACLU,MAAO,iBACPE,KAAM,iBCtED,MCEDC,EAAiB,KACtB,MAAMC,EAOF,CAAA,EAEJ,MAAO,CACNC,QAAQA,GACP,MAAMC,EACsB,mBAApBD,EAAQE,QAAyBC,OAAOC,YAAYJ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,IAAIC,EAAUF,EAASG,QACnBC,EAAkCP,EAEtC,KAAOG,EAASjH,OAAS,GAAG,CAG3B,GAFAqH,EAAaA,EAAWF,IAEnBA,IAAYE,EAChB,MAAM5N,MAAM,iBAAiB8C,QAAW4K,iCAGzCA,EAAUF,EAASG,OACnB,CAED,GAAmC,mBAAxBC,EAAWF,GACrB,MAAM1N,MAAM,IAAI8C,wBAEjB,MAAM+K,EAASD,EAAWF,GAC1BE,EAAWF,GAAWH,EAAQM,EAAO,IAG/BR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -279,6 +279,7 @@ declare const addHooksToConfig: <Config extends Omit<{
|
|
|
279
279
|
baseUrl?: string;
|
|
280
280
|
hooks?: Hooks;
|
|
281
281
|
cookiePolicy?: RequestCredentials;
|
|
282
|
+
baseHeaders?: HeadersInit;
|
|
282
283
|
}, "hooks"> & {
|
|
283
284
|
hooks?: {
|
|
284
285
|
beforeRequest?: BeforeRequest | BeforeRequest[];
|
|
@@ -308,6 +309,7 @@ declare const _default: ((config: Omit<{
|
|
|
308
309
|
baseUrl?: string;
|
|
309
310
|
hooks?: Hooks;
|
|
310
311
|
cookiePolicy?: RequestCredentials;
|
|
312
|
+
baseHeaders?: HeadersInit;
|
|
311
313
|
}, "hooks"> & {
|
|
312
314
|
hooks?: {
|
|
313
315
|
beforeRequest?: BeforeRequest | BeforeRequest[];
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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"},u={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/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"}},d="/v1/auth/refresh",l="/v1/auth/logout",p="/v1/auth/logoutall",g="/v1/auth/me",h={start:"/v1/flow/start",next:"/v1/flow/next"};const v=()=>{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")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>v().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)),v().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var m;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(m||(m={}));const 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),b=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=f(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:c,headers:d,queryParams:l,method:p,token:g}=r,h=await a((({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:l}),{headers:I(b(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.45"},(null==n?void 0:n.baseHeaders)||{},d),method:p,body:k(c),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.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:m.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.delete,token:o}),hooks:o}};function O(e,t,n){var s;let o=w(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function w(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function j(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function U(e,t){return O(e,t,"permissions")}function x(e,t){return O(e,t,"roles")}const P=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function R(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const q=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),E=e=>t=>e.test(t),M=E(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),S=E(/^\+[1-9]{1}[0-9]{3,14}$/),A=q(M,'"{val}" is not a valid email'),T=q(S,'"{val}" is not a valid phone number'),L=q((z=1,e=>e.length>=z),"Minimum length is 1");var z;const J=q((e=>"string"==typeof e),"Input is not a string"),H=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>$(...e).validate(n[t]))),t(...n)),C=e=>[J(`"${e}" must be a string`),L(`"${e}" must not be empty`)],D=e=>[J(`"${e}" must be a string`),A()],N=e=>[J(`"${e}" must be a string`),T()],Z=H(C("accessKey")),B=e=>({exchange:Z((t=>R(e.post(n.exchange,{},{token:t}))))});var K,F,G,_,Q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(F||(F={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(_||(_={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Q||(Q={}));const V=C("loginId"),W=H(V,C("code")),X=H(V),Y=H(V,N("phone")),ee=H(V,D("email")),te=e=>({verify:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,o)=>R(e.post(P(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o,i)=>R(e.post(P(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o)=>R(e.post(P(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:ee(((t,n,o)=>R(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,o,i)=>R(e.post(P(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),ne=C("loginId"),se=C("uri"),oe=H(C("token")),ie=H(ne,se),ae=H(ne,N("phone"),se),re=H(ne,D("email"),se),ue=e=>({verify:oe((t=>R(e.post(o.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,a)=>R(e.post(P(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s)=>R(e.post(P(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(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]:ae(((t,s,i,a)=>R(e.post(P(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}}),ce=C("loginId"),de=C("uri"),le=H(C("token")),pe=H(ce,de),ge=H(C("pendingRef")),he=H(ce,D("email"),de),ve=e=>({verify:le((t=>R(e.post(i.verify,{token:t})))),signIn:pe(((t,n,s,o)=>R(e.post(P(i.signIn,F.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:pe(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{loginId:t,URI:n})))),signUp:pe(((t,n,s)=>R(e.post(P(i.signUp,F.email),{loginId:t,URI:n,user:s})))),waitForSession:ge(((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 u=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(u),r&&clearTimeout(r),s(R(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:he(((t,n,s,o)=>R(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var fe;!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"}(fe||(fe={}));const me=H(C("code")),Ie=e=>({start:Object.keys(fe).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 R(Promise.resolve(r));const{url:u}=await r.json();window.location.href=u}})),{}),exchange:me((t=>R(e.post(a.exchange,{code:t}))))}),ke=H(C("flowId")),be=H(C("executionId"),C("stepId"),C("interactionId")),ye=e=>({start:ke(((t,n,s,o)=>R(e.post(h.start,{flowId:t,options:n,interactionId:s,input:o})))),next:be(((t,n,s,o)=>R(e.post(h.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Oe=H(C("tenant")),we=H(C("code")),je=e=>({start:Oe((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 R(Promise.resolve(a));const{url:u}=await a.json();window.location.href=u})),exchange:we((t=>R(e.post(r.exchange,{code:t}))))}),Ue=C("loginId"),xe=H(Ue,C("code")),Pe=H(Ue),Re=H(Ue),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{loginId:t,user:n})))),verify:xe(((t,n,s,o)=>R(e.post(u.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Re(((t,n)=>R(e.post(u.update,{loginId:t},{token:n}))))}),$e=[J(`"${"loginId"}" must be a string`)];const Ee=C("loginId"),Me=C("origin"),Se=H(Ee,Me,C("name")),Ae=H(Ee,Me),Te=H($e,Me),Le=H(Ee,Me,C("token")),ze=H(C("transactionId"),C("response")),Je=e=>({signUp:{start:Se(((t,n,s)=>R(e.post(c.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:ze(((t,n)=>R(e.post(c.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Te(((t,n,s,o)=>R(e.post(c.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:ze(((t,n)=>R(e.post(c.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ae(((t,n)=>R(e.post(c.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Le(((t,n,s)=>R(e.post(c.update.start,{loginId:t,origin:n},{token:s})))),finish:ze(((t,n)=>R(e.post(c.update.finish,{transactionId:t,response:n}))))}}),He=H(C("token"));var Ce,De;var Ne=H([(Ce="projectId",De=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(Ce,De))())])((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:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o})=>{return i=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o}),{accessKey:B(i),otp:te(i),magicLink:ue(i),enchantedLink:ve(i),oauth:Ie(i),saml:je(i),totp:qe(i),webauthn:Je(i),flow:ye(i),refresh:e=>R(i.post(d,{},{token:e})),logout:e=>R(i.post(l,{},{token:e})),logoutAll:e=>R(i.post(p,{},{token:e})),me:e=>R(i.get(g,{token:e})),isJwtExpired:He(j),getJwtPermissions:He(U),getJwtRoles:He(x),httpClient:i};var i})));const Ze=(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),Be=(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 Ke=Object.assign(Ne,{DeliveryMethods:F});export{Be as addHooksToConfig,Ke as default,R as transformResponse,Ze as wrapWith};
|
|
1
|
+
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"},u={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/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"}},c="/v1/auth/refresh",l="/v1/auth/logout",p="/v1/auth/logoutall",g="/v1/auth/me",h={start:"/v1/flow/start",next:"/v1/flow/next"};const v=()=>{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")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>v().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)),v().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var m;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(m||(m={}));const 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),b=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=f(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:d,headers:c,queryParams:l,method:p,token:g}=r,h=await a((({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:l}),{headers:I(b(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.46"},(null==n?void 0:n.baseHeaders)||{},c),method:p,body:k(d),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.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:m.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.delete,token:o}),hooks:o}};function O(e,t,n){var s;let o=w(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function w(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function j(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function U(e,t){return O(e,t,"permissions")}function x(e,t){return O(e,t,"roles")}const P=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function R(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const q=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),E=e=>t=>e.test(t),M=E(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),S=E(/^\+[1-9]{1}[0-9]{3,14}$/),A=q(M,'"{val}" is not a valid email'),T=q(S,'"{val}" is not a valid phone number'),L=q((z=1,e=>e.length>=z),"Minimum length is 1");var z;const H=q((e=>"string"==typeof e),"Input is not a string"),J=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>$(...e).validate(n[t]))),t(...n)),C=e=>[H(`"${e}" must be a string`),L(`"${e}" must not be empty`)],D=e=>[H(`"${e}" must be a string`),A()],N=e=>[H(`"${e}" must be a string`),T()],Z=J(C("accessKey")),B=e=>({exchange:Z((t=>R(e.post(n.exchange,{},{token:t}))))});var K,F,G,_,Q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(F||(F={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(_||(_={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Q||(Q={}));const V=C("loginId"),W=J(V,C("code")),X=J(V),Y=J(V,N("phone")),ee=J(V,D("email")),te=e=>({verify:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,o)=>R(e.post(P(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o,i)=>R(e.post(P(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o)=>R(e.post(P(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:ee(((t,n,o)=>R(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,o,i)=>R(e.post(P(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),ne=C("loginId"),se=C("uri"),oe=J(C("token")),ie=J(ne,se),ae=J(ne,N("phone"),se),re=J(ne,D("email"),se),ue=e=>({verify:oe((t=>R(e.post(o.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,a)=>R(e.post(P(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s)=>R(e.post(P(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(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]:ae(((t,s,i,a)=>R(e.post(P(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}}),de=C("loginId"),ce=C("uri"),le=J(C("token")),pe=J(de,ce),ge=J(C("pendingRef")),he=J(de,D("email"),ce),ve=e=>({verify:le((t=>R(e.post(i.verify,{token:t})))),signIn:pe(((t,n,s,o)=>R(e.post(P(i.signIn,F.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:pe(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{loginId:t,URI:n})))),signUp:pe(((t,n,s)=>R(e.post(P(i.signUp,F.email),{loginId:t,URI:n,user:s})))),waitForSession:ge(((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 u=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(u),r&&clearTimeout(r),s(R(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:he(((t,n,s,o)=>R(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var fe;!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"}(fe||(fe={}));const me=J(C("code")),Ie=e=>({start:Object.keys(fe).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 R(Promise.resolve(r));const{url:u}=await r.json();window.location.href=u}})),{}),exchange:me((t=>R(e.post(a.exchange,{code:t}))))}),ke=J(C("flowId")),be=J(C("executionId"),C("stepId"),C("interactionId")),ye=e=>({start:ke(((t,n,s,o)=>R(e.post(h.start,{flowId:t,options:n,interactionId:s,input:o})))),next:be(((t,n,s,o)=>R(e.post(h.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Oe=J(C("tenant")),we=J(C("code")),je=e=>({start:Oe((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 R(Promise.resolve(a));const{url:u}=await a.json();window.location.href=u})),exchange:we((t=>R(e.post(r.exchange,{code:t}))))}),Ue=C("loginId"),xe=J(Ue,C("code")),Pe=J(Ue),Re=J(Ue),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{loginId:t,user:n})))),verify:xe(((t,n,s,o)=>R(e.post(u.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Re(((t,n)=>R(e.post(u.update,{loginId:t},{token:n}))))}),$e=[H(`"${"loginId"}" must be a string`)];const Ee=C("loginId"),Me=C("origin"),Se=J(Ee,Me,C("name")),Ae=J(Ee,Me),Te=J($e,Me),Le=J(Ee,Me,C("token")),ze=J(C("transactionId"),C("response")),He=e=>({signUp:{start:Se(((t,n,s)=>R(e.post(d.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:ze(((t,n)=>R(e.post(d.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Te(((t,n,s,o)=>R(e.post(d.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:ze(((t,n)=>R(e.post(d.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ae(((t,n)=>R(e.post(d.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Le(((t,n,s)=>R(e.post(d.update.start,{loginId:t,origin:n},{token:s})))),finish:ze(((t,n)=>R(e.post(d.update.finish,{transactionId:t,response:n}))))}}),Je=J(C("token"));var Ce,De;var Ne=J([(Ce="projectId",De=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(Ce,De))())])((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:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o,baseHeaders:i={}})=>{return a=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o,baseConfig:{baseHeaders:i}}),{accessKey:B(a),otp:te(a),magicLink:ue(a),enchantedLink:ve(a),oauth:Ie(a),saml:je(a),totp:qe(a),webauthn:He(a),flow:ye(a),refresh:e=>R(a.post(c,{},{token:e})),logout:e=>R(a.post(l,{},{token:e})),logoutAll:e=>R(a.post(p,{},{token:e})),me:e=>R(a.get(g,{token:e})),isJwtExpired:Je(j),getJwtPermissions:Je(U),getJwtRoles:Je(x),httpClient:a};var a})));const Ze=(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),Be=(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 Ke=Object.assign(Ne,{DeliveryMethods:F});export{Be as addHooksToConfig,Ke as default,R as transformResponse,Ze as wrapWith};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/constants/index.ts","../src/httpClient/helpers/createFetchLogger.ts","../src/httpClient/types.ts","../src/httpClient/urlBuilder.ts","../src/httpClient/utils.ts","../src/httpClient/index.ts","../src/sdk/helpers/index.ts","../src/sdk/validations/core.ts","../src/sdk/validations/validators.ts","../src/sdk/validations/index.ts","../src/sdk/accesskey.ts","../src/sdk/types.ts","../src/sdk/otp.ts","../src/sdk/magicLink/validations.ts","../src/sdk/magicLink/index.ts","../src/sdk/enchantedLink/validations.ts","../src/sdk/enchantedLink/index.ts","../src/sdk/oauth/types.ts","../src/sdk/oauth/index.ts","../src/sdk/flow.ts","../src/sdk/saml.ts","../src/sdk/totp.ts","../src/sdk/webauthn.ts","../src/sdk/index.ts","../src/createSdk.ts","../src/utils/wrapWith/index.ts","../src/utils/index.ts","../src/index.ts"],"sourcesContent":["/** API paths for the Descope service APIs */\nexport default {\n\taccessKey: {\n\t\texchange: '/v1/auth/accesskey/exchange'\n\t},\n\totp: {\n\t\tverify: '/v1/auth/otp/verify',\n\t\tsignIn: '/v1/auth/otp/signin',\n\t\tsignUp: '/v1/auth/otp/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/otp/update/email',\n\t\t\tphone: '/v1/auth/otp/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/otp/signup-in'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/magiclink/signin',\n\t\tsignUp: '/v1/auth/magiclink/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\tenchantedLink: {\n\t\tverify: '/v1/auth/enchantedlink/verify',\n\t\tsignIn: '/v1/auth/enchantedlink/signin',\n\t\tsignUp: '/v1/auth/enchantedlink/signup',\n\t\tsession: '/v1/auth/enchantedlink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/enchantedlink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/enchantedlink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize',\n\t\texchange: '/v1/auth/oauth/exchange'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize',\n\t\texchange: '/v1/auth/saml/exchange'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/totp/verify',\n\t\tsignUp: '/v1/auth/totp/signup',\n\t\tupdate: '/v1/auth/totp/update'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/auth/webauthn/signup/start',\n\t\t\tfinish: '/v1/auth/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/auth/webauthn/signin/start',\n\t\t\tfinish: '/v1/auth/webauthn/signin/finish'\n\t\t},\n\t\tsignUpOrIn: {\n\t\t\tstart: '/v1/auth/webauthn/signup-in/start'\n\t\t},\n\t\tupdate: {\n\t\t\tstart: 'v1/auth/webauthn/update/start',\n\t\t\tfinish: '/v1/auth/webauthn/update/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logout',\n\tlogoutAll: '/v1/auth/logoutall',\n\tme: '/v1/auth/me',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t}\n};\n","/** Default Descope API URL */\nexport const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\n/** Default magic link polling interval for checking if the user clicked on the magic link */\nexport const ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\n/** Default maximum time we are willing to wait for the magic link to be clicked */\nexport const ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\n/** API paths to the Descope service */\nexport { default as apiPaths } from './apiPaths';\n","import { Logger } from '../../sdk/types';\n\n/** Build a log message around HTTP calls */\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\n/** Log the request object */\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\n/** Log the response object */\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await (resp.clone ? resp.clone().text() : resp.text());\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\n/**\n * Create a fetch with a logger wrapped around it if a logger is given\n * @param logger Logger to send the logs to\n * @param receivedFetch Fetch to be used or built-in fetch if not provided\n *\n */\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","import { Logger } from '../sdk/types';\n\n/** Request configuration including headers, query params and token */\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\n/** HTTP methods we use in the client */\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\n/** HTTP Client type that implements the HTTP method calls. Descopers can provide their own HTTP client although required only in rare cases. */\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\thooks?: Hooks;\n};\n\n/** Parameters for the HTTP client. Defaults should work for most cases. */\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** For before-request hook allows overriding parts of the request */\nexport type RequestConfig = {\n\tpath: string;\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\tbody?: any;\n\tmethod: HTTPMethods;\n\ttoken?: string;\n};\n\nexport type BeforeRequest = (config: RequestConfig) => RequestConfig;\nexport type AfterRequest = (req: RequestConfig, res: Response) => void;\n\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: BeforeRequest;\n\tafterRequest?: AfterRequest;\n};\n","/** Build URL with given parts */\nexport const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\n/** Merge the given list of headers into a single Headers object */\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\n/** Serialize the body to JSON */\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import createFetchLogger from './helpers/createFetchLogger';\nimport { CreateHttpClientConfig, HttpClient, HTTPMethods, RequestConfig } from './types';\nimport { urlBuilder } from './urlBuilder';\nimport { mergeHeaders, serializeBody } from './utils';\n\n/**\n * Create a Bearer authorization header with concatenated projectId and token\n * @param projectId The project id to use in the header\n * @param token Token to be concatenated. Defaults to empty.\n */\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token) {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\ndeclare const BUILD_VERSION: string;\n\n/**\n * Create descope custom headers\n */\nconst createDescopeHeaders = () => {\n\treturn {\n\t\t'x-descope-sdk-name': 'core-js',\n\t\t'x-descope-sdk-version': BUILD_VERSION\n\t};\n};\n\n/**\n * Create the HTTP client used to send HTTP requests to the Descope API\n *\n * @param CreateHttpClientConfig Configuration for the client\n */\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n\tcookiePolicy\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = async (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\tconst res = await fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tcreateDescopeHeaders(),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body),\n\t\t\tcredentials: cookiePolicy || 'include'\n\t\t});\n\n\t\tif (hooks?.afterRequest) {\n\t\t\thooks.afterRequest(config, res?.clone());\n\t\t}\n\n\t\treturn res;\n\t};\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token }),\n\t\thooks\n\t};\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { ResponseData, SdkResponse } from '../types';\n\nfunction getJwtAuthorizationItems(token: string, tenant: string, claim: string): string[] {\n\tlet claims: any = parseJwt(token);\n\tif (tenant) {\n\t\tclaims = claims.tenants?.[tenant];\n\t}\n\tconst items = claims[claim];\n\treturn Array.isArray(items) ? items : [];\n}\n\nfunction parseJwt(token: string): JwtPayload {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\treturn jwtDecode(token);\n}\n\n/**\n * Checks if the given JWT is still valid but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function isJwtExpired(token: string): boolean {\n\tconst { exp } = parseJwt(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\treturn currentTime > exp;\n}\n\n/**\n * Returns the list of permissions granted in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtPermissions(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'permissions');\n}\n\n/**\n * Returns the list of roles specified in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtRoles(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'roles');\n}\n\n/** Joins path parts making sure there is only one path separator between parts */\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\n/** Transform the Promise Response to our internal SdkResponse implementation\n * @param response The Response promise from fetch\n * @param transform Optionally transform the response JSON to another type\n */\nexport async function transformResponse<T extends ResponseData, S extends ResponseData = T>(\n\tresponse: Promise<Response>,\n\ttransform?: (data: T) => S\n): Promise<SdkResponse<S>> {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse<S> = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.clone().json();\n\n\tif (!resp.ok) {\n\t\tret.error = data;\n\t} else if (transform) {\n\t\tret.data = transform(data);\n\t} else {\n\t\tret.data = <S>data;\n\t}\n\n\treturn ret;\n}\n","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const string = (fieldName: string) => [isString(`\"${fieldName}\" must be a string`)];\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { ExchangeAccessKeyResponse, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('accessKey'));\n\nconst withAccessKeys = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(accessKey: string): Promise<SdkResponse<ExchangeAccessKeyResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.accessKey.exchange, {}, { token: accessKey }))\n\t)\n});\n\nexport default withAccessKeys;\n","type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;\n\ntype DeviceInfo = {\n\twebAuthnSupport?: boolean;\n};\n\ntype LocalUser = {\n\tauthMethod?: AuthMethod;\n\toauthProvider?: string;\n\tloginId?: string;\n};\n\ntype AuthMethod = 'otp' | 'magiclink' | 'social' | 'sso' | 'webauthn' | 'totp';\n\n/** User base details from Descope API */\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\n/** User extended details from Descope API */\nexport type UserResponse = User & {\n\tloginIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n\tpicture?: string;\n};\n\n/** Login options to be added to the different authentication methods */\nexport type LoginOptions = {\n\tstepup?: boolean;\n\tmfa?: boolean;\n\tcustomClaims?: Record<string, any>;\n};\n\n/** Authentication info result from the various JWT validations */\nexport type JWTResponse = {\n\tsessionJwt: string;\n\trefreshJwt?: string;\n\tcookieDomain?: string;\n\tcookiePath?: string;\n\tcookieMaxAge?: number;\n\tcookieExpiration?: number;\n\tuser?: UserResponse;\n\tfirstSeen?: boolean;\n};\n\n/** Authentication info result from exchanging access keys for a session */\nexport type ExchangeAccessKeyResponse = {\n\tkeyId: string;\n\tsessionJwt: string;\n\texpiration: number;\n};\n\n/** The response returned from the various start webauthn functions */\nexport type WebAuthnStartResponse = {\n\ttransactionId: string;\n\toptions: string;\n\tcreate: boolean;\n};\n\n/** Enchanted link response */\nexport type EnchantedLinkResponse = {\n\t/** Pending reference URL to poll while waiting for user to click magic link */\n\tpendingRef: string;\n\t/** Link id, on which link the user should click */\n\tlinkId: string;\n};\n\n/** URL response to redirect user in case of OAuth or SSO */\nexport type URLResponse = {\n\turl: string;\n};\n\n/** TOTP response with the TOTP details */\nexport type TOTPResponse = {\n\tprovisioningURL: string;\n\timage: string;\n\tkey: string;\n};\n\n/** Phone delivery methods which are currently supported */\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All delivery methods currently supported */\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All flow execution statuses\n * - waiting - flow execution is waiting for user interaction\n * - running - flow execution is currently running\n * - completed - flow execution completed successfully\n * - failed - flow execution failed\n */\nexport enum FlowStatus {\n\twaiting = 'waiting',\n\trunning = 'running',\n\tcompleted = 'completed',\n\tfailed = 'failed'\n}\n\n/** All flow response action\n * - screen - next action is to render screen\n * - poll - next action is poll for next after timeout\n * - redirect - next action is to redirect (redirection details in 'redirect' attribute)\n * - webauthnCreate/webauthnGet - next action is to prompt webauthn (details in 'webauthn' attribute)\n * - none - no next action\n */\nexport type FlowAction = 'screen' | 'poll' | 'redirect' | 'webauthnCreate' | 'webauthnGet' | 'none';\n\n/** Flow response with flow execution details */\nexport type FlowResponse = {\n\t// current execution identifier\n\texecutionId: string;\n\t// current step identifier\n\tstepId: string;\n\t// flow execution status\n\tstatus: FlowStatus;\n\t// the next required action\n\taction: FlowAction;\n\t// screen data - if action is 'screen'\n\tscreen?: {\n\t\t// screen identifier\n\t\tid: string;\n\t\t// extra dynamic state required for rendering screen\n\t\tstate: Record<string, any>;\n\t};\n\t// redirect data - if action is 'redirect'\n\tredirect?: {\n\t\turl: string;\n\t};\n\t// webauthn data - if action is one of 'webauthnCreate', 'webauthnGet'\n\twebauthn?: {\n\t\ttransactionId: string;\n\t\toptions: string;\n\t\tcreate: boolean;\n\t};\n\t// an error that occurred during flow execution, used for debugging / integrating\n\terror?: {\n\t\tcode: string;\n\t\tdescription: string;\n\t\tmessage: string;\n\t};\n\t// authentication information response, if response is authenticated\n\tauthInfo?: JWTResponse;\n};\n\nexport type Options = {\n\tredirectUrl?: string;\n\ttenant?: string;\n\tdeviceInfo?: DeviceInfo;\n\tlastUser?: LocalUser;\n};\n\nexport type ResponseData = Record<string, any>;\n\n/**\n * Response from our SDK calls which includes the result (ok, code, error).\n * The relevant data is provided in the more specific interfaces extending SdkResponse.\n */\nexport type SdkResponse<T extends ResponseData> = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\terrorCode: string;\n\t\terrorDescription?: string;\n\t};\n\tdata?: T;\n};\n\n/** Different delivery method */\nexport type Deliveries<T extends SdkFn> = Record<keyof typeof DeliveryMethods, T>;\n\n/** The different routes (actions) we can do */\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\n/** Logger type that supports the given levels (debug, log, error) */\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveries,\n\tUser,\n\tSdkResponse,\n\tJWTResponse,\n\tDeliveryPhone,\n\tLoginOptions\n} from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (loginId: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (loginId: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (loginId: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (loginId: string, phone: string) => Promise<SdkResponse<never>>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(loginIdValidations);\nconst withUpdatePhoneValidations = withValidations(loginIdValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(loginIdValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(loginId: string, code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.otp.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { loginId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.otp.update.email, { loginId, email }, { token }))\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(loginId: string, phone: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveryPhone,\n\tSdkResponse,\n\tJWTResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tURI: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, URI, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { loginId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, uri: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.magicLink.update.email, { loginId, email, URI: uri }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(\n\t\t\t\t\t\tloginId: string,\n\t\t\t\t\t\tphone: string,\n\t\t\t\t\t\turi: string,\n\t\t\t\t\t\ttoken?: string\n\t\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLink;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tSdkResponse,\n\tJWTResponse,\n\tEnchantedLinkResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { EnchantedLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations\n} from './validations';\n\n/** Polling configuration with defaults and normalizing checks */\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withEnchantedLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<never>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.enchantedLink.verify, { token }))\n\t),\n\n\tsignIn: withSignValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tURI: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(\n\t\t\t\t\tpathJoin(apiPaths.enchantedLink.signIn, DeliveryMethods.email),\n\t\t\t\t\t{\n\t\t\t\t\t\tloginId,\n\t\t\t\t\t\tURI,\n\t\t\t\t\t\tloginOptions\n\t\t\t\t\t},\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUpOrIn: withSignValidations(\n\t\t(loginId: string, URI: string): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUpOrIn, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUp: withSignValidations(\n\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUp, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI,\n\t\t\t\t\tuser\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse<JWTResponse>> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.enchantedLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tmessage: `Session polling timeout exceeded: ${timeoutMs}ms`,\n\t\t\t\t\t\t\terrorCode: '0'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\temail: string,\n\t\t\t\turi: string,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.enchantedLink.update.email,\n\t\t\t\t\t\t{ loginId, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withEnchantedLink;\n","import { SdkResponse, URLResponse, JWTResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple',\n\tdiscord = 'discord',\n\tlinkedin = 'linkedin'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\ntype VerifyFn = (code: string) => Promise<SdkResponse<JWTResponse>>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from '../types';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\nimport { stringNonEmpty, withValidations } from '../validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (\n\t\t\t\tredirectUrl?: string,\n\t\t\t\t{ redirect = false } = {},\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t) => {\n\t\t\t\tconst resp = await httpClient.post(apiPaths.oauth.start, loginOptions || {}, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) },\n\t\t\t\t\ttoken\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok)\n\t\t\t\t\treturn transformResponse<SdkResponse<URLResponse>>(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.oauth.exchange, { code }))\n\t)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { FlowResponse, Options, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('interactionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations(\n\t\t(\n\t\t\tflowId: string,\n\t\t\toptions?: Options,\n\t\t\tinteractionId?: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.start, { flowId, options, interactionId, input })\n\t\t\t)\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tinteractionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, interactionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (\n\t\t\ttenantNameOrEmail: string,\n\t\t\tredirectUrl?: string,\n\t\t\t{ redirect = false } = {},\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t) => {\n\t\t\tconst resp = await httpClient.post(apiPaths.saml.start, loginOptions || {}, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl },\n\t\t\t\ttoken\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.saml.exchange, { code }))\n\t)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse, JWTResponse, TOTPResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(loginIdValidations);\nconst withUpdateValidations = withValidations(loginIdValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(loginId: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { loginId, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tcode: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.verify, { loginId, code, loginOptions }, { token })\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(loginId: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.update, { loginId }, { token }))\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport {\n\tSdkResponse,\n\tResponseData,\n\tLoginOptions,\n\tJWTResponse,\n\tWebAuthnStartResponse\n} from './types';\nimport { string, stringNonEmpty, withValidations } from './validations';\n\nconst loginIdStringValidations = string('loginId');\nconst loginIdNonEmptyValidations = stringNonEmpty('loginId');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignUpOrInStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations\n);\nconst withSignInStartValidations = withValidations(loginIdStringValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tname: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.signIn.start,\n\t\t\t\t\t\t{ loginId, origin, loginOptions },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignUpOrIn: {\n\t\tstart: withSignUpOrInStartValidations(\n\t\t\t(loginId: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.webauthn.signUpOrIn.start, { loginId, origin }))\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\ttoken: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.start, { loginId, origin }, { token })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<ResponseData>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withAccessKeys from './accesskey';\nimport withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport { isJwtExpired, getJwtPermissions, getJwtRoles, transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport withEnchantedLink from './enchantedLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\nimport { UserResponse, JWTResponse } from './types';\n\nconst withJwtValidations = withValidations(stringNonEmpty('token'));\n\n/** Returns Descope SDK with all available operations */\nexport default (httpClient: HttpClient) => ({\n\taccessKey: withAccessKeys(httpClient),\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\tenchantedLink: withEnchantedLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) =>\n\t\ttransformResponse<JWTResponse>(httpClient.post(apiPaths.refresh, {}, { token })),\n\tlogout: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logout, {}, { token })),\n\tlogoutAll: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logoutAll, {}, { token })),\n\tme: (token?: string) => transformResponse<UserResponse>(httpClient.get(apiPaths.me, { token })),\n\tisJwtExpired: withJwtValidations(isJwtExpired),\n\tgetJwtPermissions: withJwtValidations(getJwtPermissions),\n\tgetJwtRoles: withJwtValidations(getJwtRoles),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport { AfterRequest, BeforeRequest, Hooks } from './httpClient/types';\nimport createSdk from './sdk';\nimport { Logger } from './sdk/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Add the ability to pass multiple hooks instead of one when creating an SDK instance */\nconst withMultipleHooks =\n\t<T extends object>(createSdk: (config: SdkConfig) => T) =>\n\t(\n\t\tconfig: Omit<SdkConfig, 'hooks'> & {\n\t\t\thooks?: {\n\t\t\t\tbeforeRequest?: BeforeRequest | BeforeRequest[];\n\t\t\t\tafterRequest?: AfterRequest | AfterRequest[];\n\t\t\t};\n\t\t}\n\t) => {\n\t\tconst beforeRequestHooks = [].concat(config.hooks?.beforeRequest || []);\n\t\tconst afterRequestHooks = [].concat(config.hooks?.afterRequest || []);\n\n\t\tconst beforeRequest: BeforeRequest = (config) =>\n\t\t\tbeforeRequestHooks?.reduce((acc, fn) => fn(acc), config);\n\t\tconst afterRequest: AfterRequest = (req, res) => {\n\t\t\tafterRequestHooks?.forEach((fn) => fn(req, res?.clone()));\n\t\t};\n\n\t\treturn createSdk({ ...config, hooks: { beforeRequest, afterRequest } });\n\t};\n\n/** Descope SDK client */\nexport default withSdkConfigValidations(\n\twithMultipleHooks(({ projectId, logger, baseUrl, hooks, cookiePolicy }: SdkConfig) =>\n\t\tcreateSdk(\n\t\t\tcreateHttpClient({\n\t\t\t\tbaseUrl: baseUrl || DEFAULT_BASE_API_URL,\n\t\t\t\tprojectId,\n\t\t\t\tlogger,\n\t\t\t\thooks,\n\t\t\t\tcookiePolicy\n\t\t\t})\n\t\t)\n\t)\n);\n","/* eslint-disable import/exports-last */\nimport { ResponseData } from '../../sdk/types';\nimport { SdkFnWrapper, ReplacePaths, SdkFnsPaths } from './types';\n\n/**\n * A wrapper function that allows to wrap multiple Sdk function\n * @param obj: The Sdk instance you want to wrap\n * @param paths: A readonly list of paths of the functions you want to wrap\n * @param wrapper: Your wrapper function, it should gets an Sdk function and return a new Sdk function\n * @returns a mutated instance of the Sdk with updated type definitions based on your wrapper return type\n *\n * Usage example:\n *\n * // Assuming this is our SDK instance\n * const sdk = {\n * me: (token) => {...}\n * flow: {\n * start: (...params) => {...}\n * next: (...params) => {...}\n * }\n * ...\n * }\n *\n * // This is our wrapper\n * const wrapper = (sdkFn) => async (...args) => {\n * const sdkResponse = await sdkFn(...args)\n *\n * // Modify return value\n * return {...sdkResponse, data: {...sdkResponse.data, myCustomAttribute: 'hello'}}\n * }\n *\n * // And those are the paths we want to wrap\n * const paths = ['flow.start', 'flow.next'] as const // You MUST add as const!\n *\n * // We can wrap our SDK functions with the wrapper we created in this way\n * const newlyTypedSdk = wrapWith(sdk, paths, wrapper)\n *\n * Now the 2 wrapped functions will have the updated type based on the wrapper return value\n */\n\nconst wrapWith = <\n\tObj extends object,\n\tPaths extends ReadonlyArray<SdkFnsPaths<Obj>>,\n\tWrapperData extends ResponseData\n>(\n\tobj: Obj,\n\tpaths: Paths,\n\twrapper: SdkFnWrapper<WrapperData>\n): ReplacePaths<Obj, Paths, WrapperData> => {\n\tpaths.forEach((path) => {\n\t\tconst sections = path.split('.');\n\t\tlet section = sections.shift();\n\t\tlet currentRef: Record<string, any> = obj;\n\n\t\twhile (sections.length > 0) {\n\t\t\tcurrentRef = currentRef[section];\n\n\t\t\tif (!section || !currentRef) {\n\t\t\t\tthrow Error(`Invalid path \"${path}\", \"${section}\" is missing or has no value`);\n\t\t\t}\n\n\t\t\tsection = sections.shift();\n\t\t}\n\n\t\tif (typeof currentRef[section] !== 'function') {\n\t\t\tthrow Error(`\"${path}\" is not a function`);\n\t\t}\n\t\tconst origFn = currentRef[section];\n\t\tcurrentRef[section] = wrapper(origFn);\n\t});\n\n\treturn obj as any;\n};\n\nexport default wrapWith;\n","import { SdkConfig } from '../types';\n\nexport { default as wrapWith } from './wrapWith';\nexport type { SdkFnWrapper } from './wrapWith/types';\n\n/**\n * Add hooks to an existing core-sdk config\n */\nexport const addHooksToConfig = <Config extends SdkConfig>(\n\tconfig: Config,\n\thooks: Config['hooks']\n): Config => {\n\t['beforeRequest', 'afterRequest'].reduce((acc, key) => {\n\t\tacc[key] = [].concat(config.hooks?.[key] || []).concat(hooks?.[key] || []);\n\n\t\treturn acc;\n\t}, (config.hooks ??= {}));\n\n\treturn config;\n};\n","import createSdk from './createSdk';\nimport { HTTPMethods, RequestConfig } from './httpClient/types';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods } from './sdk/types';\n\n/** Descope SDK client with delivery methods enum.\n *\n * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}\n * @example Usage\n *\n * ```js\n * import descopeSdk from '@descope/core-js-sdk';\n *\n * const myProjectId = 'xxx';\n * const sdk = descopeSdk({ projectId: myProjectId });\n *\n * const userLoginId = 'loginId';\n * sdk.otp.signIn.email(userLoginId);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(createSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport type {\n\tEnchantedLinkResponse,\n\tExchangeAccessKeyResponse,\n\tFlowAction,\n\tFlowResponse,\n\tFlowStatus,\n\tJWTResponse,\n\tResponseData,\n\tSdkResponse,\n\tTOTPResponse,\n\tURLResponse,\n\tUserResponse\n} from './sdk/types';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\nexport type { HTTPMethods, RequestConfig };\n\n/** Type to restrict to valid delivery methods */\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\n/** Type to restrict to valid OAuth providers */\nexport type OAuthProvider = keyof typeof OAuthProviders;\n"],"names":["apiPaths","exchange","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","clone","text","Promise","resolve","json","parse","statusText","buildResponseLog","HTTPMethods","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","cookiePolicy","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","res","URL","search","URLSearchParams","urlBuilder","baseHeaders","credentials","afterRequest","get","post","put","delete","getJwtAuthorizationItems","tenant","claim","claims","parseJwt","tenants","_a","items","jwtDecode","isJwtExpired","exp","Date","getTime","getJwtPermissions","getJwtRoles","pathJoin","replace","transformResponse","response","transform","ret","code","data","error","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","withExchangeValidations","withAccessKeys","httpClient","accessKey","DeliveryPhone","DeliveryMethods","FlowStatus","Routes","loginIdValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","loginId","loginOptions","user","uriValidations","withMagicLink","URI","uri","withWaitForSessionValidations","withEnchantedLink","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","errorCode","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","options","interactionId","input","executionId","stepId","withSaml","tenantNameOrEmail","withSignUpValidations","withUpdateValidations","withTotp","loginIdStringValidations","loginIdNonEmptyValidations","originValidations","withSignUpStartValidations","withSignUpOrInStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","createSdk","validatePathValue","withSdkConfigValidations","beforeRequestHooks","concat","afterRequestHooks","_b","req","withMultipleHooks","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me","wrapWith","obj","paths","wrapper","sections","split","section","shift","currentRef","origFn","addHooksToConfig","index"],"mappings":"oDACA,IAAeA,EACH,CACVC,SAAU,+BAFGD,EAIT,CACJE,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BAZCR,EAcH,CACVE,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,gCAtBCR,EAwBC,CACdE,OAAQ,gCACRC,OAAQ,gCACRC,OAAQ,gCACRK,QAAS,yCACTJ,OAAQ,CACPC,MAAO,uCAERE,WAAY,oCAhCCR,EAkCP,CACNU,MAAO,2BACPT,SAAU,2BApCGD,EAsCR,CACLU,MAAO,0BACPT,SAAU,0BAxCGD,EA0CR,CACLE,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA7CKL,EA+CJ,CACTI,OAAQ,CACPM,MAAO,iCACPC,OAAQ,mCAETR,OAAQ,CACPO,MAAO,iCACPC,OAAQ,mCAETH,WAAY,CACXE,MAAO,qCAERL,OAAQ,CACPK,MAAO,gCACPC,OAAQ,oCA7DIX,EAgEL,mBAhEKA,EAiEN,kBAjEMA,EAkEH,qBAlEGA,EAmEV,cAnEUA,EAoER,CACLU,MAAO,iBACPE,KAAM,iBCtED,MCEDC,EAAiB,KACtB,MAAMC,EAOF,CAAA,EAEJ,MAAO,CACNC,QAAQA,GACP,MAAMC,EACsB,mBAApBD,EAAQE,QAAyBC,OAAOC,YAAYJ,EAAQE,WAAaF,EAGjF,OAFAD,EAAIM,QAAUC,KAAKC,UAAUN,GAEtBO,IACP,EAEDC,KAAKA,GAEJ,OADAV,EAAIW,KAAOD,EACJD,IACP,EAEDG,IAAIA,GAEH,OADAZ,EAAIa,IAAMD,EAAIE,WACPL,IACP,EA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EAAAA,EAAZvB,EAAOJ,MAAU,CAAA,GAEdI,CAAM,ECGd,IAAeoL,GAAA1P,OAAO4J,OAAO8D,GAAW,CAAExE"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/constants/index.ts","../src/httpClient/helpers/createFetchLogger.ts","../src/httpClient/types.ts","../src/httpClient/urlBuilder.ts","../src/httpClient/utils.ts","../src/httpClient/index.ts","../src/sdk/helpers/index.ts","../src/sdk/validations/core.ts","../src/sdk/validations/validators.ts","../src/sdk/validations/index.ts","../src/sdk/accesskey.ts","../src/sdk/types.ts","../src/sdk/otp.ts","../src/sdk/magicLink/validations.ts","../src/sdk/magicLink/index.ts","../src/sdk/enchantedLink/validations.ts","../src/sdk/enchantedLink/index.ts","../src/sdk/oauth/types.ts","../src/sdk/oauth/index.ts","../src/sdk/flow.ts","../src/sdk/saml.ts","../src/sdk/totp.ts","../src/sdk/webauthn.ts","../src/sdk/index.ts","../src/createSdk.ts","../src/utils/wrapWith/index.ts","../src/utils/index.ts","../src/index.ts"],"sourcesContent":["/** API paths for the Descope service APIs */\nexport default {\n\taccessKey: {\n\t\texchange: '/v1/auth/accesskey/exchange'\n\t},\n\totp: {\n\t\tverify: '/v1/auth/otp/verify',\n\t\tsignIn: '/v1/auth/otp/signin',\n\t\tsignUp: '/v1/auth/otp/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/otp/update/email',\n\t\t\tphone: '/v1/auth/otp/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/otp/signup-in'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/magiclink/signin',\n\t\tsignUp: '/v1/auth/magiclink/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\tenchantedLink: {\n\t\tverify: '/v1/auth/enchantedlink/verify',\n\t\tsignIn: '/v1/auth/enchantedlink/signin',\n\t\tsignUp: '/v1/auth/enchantedlink/signup',\n\t\tsession: '/v1/auth/enchantedlink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/enchantedlink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/enchantedlink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize',\n\t\texchange: '/v1/auth/oauth/exchange'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize',\n\t\texchange: '/v1/auth/saml/exchange'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/totp/verify',\n\t\tsignUp: '/v1/auth/totp/signup',\n\t\tupdate: '/v1/auth/totp/update'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/auth/webauthn/signup/start',\n\t\t\tfinish: '/v1/auth/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/auth/webauthn/signin/start',\n\t\t\tfinish: '/v1/auth/webauthn/signin/finish'\n\t\t},\n\t\tsignUpOrIn: {\n\t\t\tstart: '/v1/auth/webauthn/signup-in/start'\n\t\t},\n\t\tupdate: {\n\t\t\tstart: 'v1/auth/webauthn/update/start',\n\t\t\tfinish: '/v1/auth/webauthn/update/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logout',\n\tlogoutAll: '/v1/auth/logoutall',\n\tme: '/v1/auth/me',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t}\n};\n","/** Default Descope API URL */\nexport const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\n/** Default magic link polling interval for checking if the user clicked on the magic link */\nexport const ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\n/** Default maximum time we are willing to wait for the magic link to be clicked */\nexport const ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\n/** API paths to the Descope service */\nexport { default as apiPaths } from './apiPaths';\n","import { Logger } from '../../sdk/types';\n\n/** Build a log message around HTTP calls */\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\n/** Log the request object */\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\n/** Log the response object */\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await (resp.clone ? resp.clone().text() : resp.text());\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\n/**\n * Create a fetch with a logger wrapped around it if a logger is given\n * @param logger Logger to send the logs to\n * @param receivedFetch Fetch to be used or built-in fetch if not provided\n *\n */\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","import { Logger } from '../sdk/types';\n\n/** Request configuration including headers, query params and token */\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\n/** HTTP methods we use in the client */\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\n/** HTTP Client type that implements the HTTP method calls. Descopers can provide their own HTTP client although required only in rare cases. */\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\thooks?: Hooks;\n};\n\n/** Parameters for the HTTP client. Defaults should work for most cases. */\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n};\n\n/** For before-request hook allows overriding parts of the request */\nexport type RequestConfig = {\n\tpath: string;\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\tbody?: any;\n\tmethod: HTTPMethods;\n\ttoken?: string;\n};\n\nexport type BeforeRequest = (config: RequestConfig) => RequestConfig;\nexport type AfterRequest = (req: RequestConfig, res: Response) => void;\n\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: BeforeRequest;\n\tafterRequest?: AfterRequest;\n};\n","/** Build URL with given parts */\nexport const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\n/** Merge the given list of headers into a single Headers object */\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\n/** Serialize the body to JSON */\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import createFetchLogger from './helpers/createFetchLogger';\nimport { CreateHttpClientConfig, HttpClient, HTTPMethods, RequestConfig } from './types';\nimport { urlBuilder } from './urlBuilder';\nimport { mergeHeaders, serializeBody } from './utils';\n\n/**\n * Create a Bearer authorization header with concatenated projectId and token\n * @param projectId The project id to use in the header\n * @param token Token to be concatenated. Defaults to empty.\n */\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token) {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\ndeclare const BUILD_VERSION: string;\n\n/**\n * Create descope custom headers\n */\nconst createDescopeHeaders = () => {\n\treturn {\n\t\t'x-descope-sdk-name': 'core-js',\n\t\t'x-descope-sdk-version': BUILD_VERSION\n\t};\n};\n\n/**\n * Create the HTTP client used to send HTTP requests to the Descope API\n *\n * @param CreateHttpClientConfig Configuration for the client\n */\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n\tcookiePolicy\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = async (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\tconst res = await fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tcreateDescopeHeaders(),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body),\n\t\t\tcredentials: cookiePolicy || 'include'\n\t\t});\n\n\t\tif (hooks?.afterRequest) {\n\t\t\thooks.afterRequest(config, res?.clone());\n\t\t}\n\n\t\treturn res;\n\t};\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token }),\n\t\thooks\n\t};\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { ResponseData, SdkResponse } from '../types';\n\nfunction getJwtAuthorizationItems(token: string, tenant: string, claim: string): string[] {\n\tlet claims: any = parseJwt(token);\n\tif (tenant) {\n\t\tclaims = claims.tenants?.[tenant];\n\t}\n\tconst items = claims[claim];\n\treturn Array.isArray(items) ? items : [];\n}\n\nfunction parseJwt(token: string): JwtPayload {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\treturn jwtDecode(token);\n}\n\n/**\n * Checks if the given JWT is still valid but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function isJwtExpired(token: string): boolean {\n\tconst { exp } = parseJwt(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\treturn currentTime > exp;\n}\n\n/**\n * Returns the list of permissions granted in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtPermissions(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'permissions');\n}\n\n/**\n * Returns the list of roles specified in the given JWT but DOES NOT check for signature\n *\n * @param token JWT token\n */\nexport function getJwtRoles(token: string, tenant?: string): string[] {\n\treturn getJwtAuthorizationItems(token, tenant, 'roles');\n}\n\n/** Joins path parts making sure there is only one path separator between parts */\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\n/** Transform the Promise Response to our internal SdkResponse implementation\n * @param response The Response promise from fetch\n * @param transform Optionally transform the response JSON to another type\n */\nexport async function transformResponse<T extends ResponseData, S extends ResponseData = T>(\n\tresponse: Promise<Response>,\n\ttransform?: (data: T) => S\n): Promise<SdkResponse<S>> {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse<S> = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.clone().json();\n\n\tif (!resp.ok) {\n\t\tret.error = data;\n\t} else if (transform) {\n\t\tret.data = transform(data);\n\t} else {\n\t\tret.data = <S>data;\n\t}\n\n\treturn ret;\n}\n","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const string = (fieldName: string) => [isString(`\"${fieldName}\" must be a string`)];\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { ExchangeAccessKeyResponse, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('accessKey'));\n\nconst withAccessKeys = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(accessKey: string): Promise<SdkResponse<ExchangeAccessKeyResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.accessKey.exchange, {}, { token: accessKey }))\n\t)\n});\n\nexport default withAccessKeys;\n","type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;\n\ntype DeviceInfo = {\n\twebAuthnSupport?: boolean;\n};\n\ntype LocalUser = {\n\tauthMethod?: AuthMethod;\n\toauthProvider?: string;\n\tloginId?: string;\n};\n\ntype AuthMethod = 'otp' | 'magiclink' | 'social' | 'sso' | 'webauthn' | 'totp';\n\n/** User base details from Descope API */\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\n/** User extended details from Descope API */\nexport type UserResponse = User & {\n\tloginIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n\tpicture?: string;\n};\n\n/** Login options to be added to the different authentication methods */\nexport type LoginOptions = {\n\tstepup?: boolean;\n\tmfa?: boolean;\n\tcustomClaims?: Record<string, any>;\n};\n\n/** Authentication info result from the various JWT validations */\nexport type JWTResponse = {\n\tsessionJwt: string;\n\trefreshJwt?: string;\n\tcookieDomain?: string;\n\tcookiePath?: string;\n\tcookieMaxAge?: number;\n\tcookieExpiration?: number;\n\tuser?: UserResponse;\n\tfirstSeen?: boolean;\n};\n\n/** Authentication info result from exchanging access keys for a session */\nexport type ExchangeAccessKeyResponse = {\n\tkeyId: string;\n\tsessionJwt: string;\n\texpiration: number;\n};\n\n/** The response returned from the various start webauthn functions */\nexport type WebAuthnStartResponse = {\n\ttransactionId: string;\n\toptions: string;\n\tcreate: boolean;\n};\n\n/** Enchanted link response */\nexport type EnchantedLinkResponse = {\n\t/** Pending reference URL to poll while waiting for user to click magic link */\n\tpendingRef: string;\n\t/** Link id, on which link the user should click */\n\tlinkId: string;\n};\n\n/** URL response to redirect user in case of OAuth or SSO */\nexport type URLResponse = {\n\turl: string;\n};\n\n/** TOTP response with the TOTP details */\nexport type TOTPResponse = {\n\tprovisioningURL: string;\n\timage: string;\n\tkey: string;\n};\n\n/** Phone delivery methods which are currently supported */\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All delivery methods currently supported */\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\n/** All flow execution statuses\n * - waiting - flow execution is waiting for user interaction\n * - running - flow execution is currently running\n * - completed - flow execution completed successfully\n * - failed - flow execution failed\n */\nexport enum FlowStatus {\n\twaiting = 'waiting',\n\trunning = 'running',\n\tcompleted = 'completed',\n\tfailed = 'failed'\n}\n\n/** All flow response action\n * - screen - next action is to render screen\n * - poll - next action is poll for next after timeout\n * - redirect - next action is to redirect (redirection details in 'redirect' attribute)\n * - webauthnCreate/webauthnGet - next action is to prompt webauthn (details in 'webauthn' attribute)\n * - none - no next action\n */\nexport type FlowAction = 'screen' | 'poll' | 'redirect' | 'webauthnCreate' | 'webauthnGet' | 'none';\n\n/** Flow response with flow execution details */\nexport type FlowResponse = {\n\t// current execution identifier\n\texecutionId: string;\n\t// current step identifier\n\tstepId: string;\n\t// flow execution status\n\tstatus: FlowStatus;\n\t// the next required action\n\taction: FlowAction;\n\t// screen data - if action is 'screen'\n\tscreen?: {\n\t\t// screen identifier\n\t\tid: string;\n\t\t// extra dynamic state required for rendering screen\n\t\tstate: Record<string, any>;\n\t};\n\t// redirect data - if action is 'redirect'\n\tredirect?: {\n\t\turl: string;\n\t};\n\t// webauthn data - if action is one of 'webauthnCreate', 'webauthnGet'\n\twebauthn?: {\n\t\ttransactionId: string;\n\t\toptions: string;\n\t\tcreate: boolean;\n\t};\n\t// an error that occurred during flow execution, used for debugging / integrating\n\terror?: {\n\t\tcode: string;\n\t\tdescription: string;\n\t\tmessage: string;\n\t};\n\t// authentication information response, if response is authenticated\n\tauthInfo?: JWTResponse;\n};\n\nexport type Options = {\n\tredirectUrl?: string;\n\ttenant?: string;\n\tdeviceInfo?: DeviceInfo;\n\tlastUser?: LocalUser;\n};\n\nexport type ResponseData = Record<string, any>;\n\n/**\n * Response from our SDK calls which includes the result (ok, code, error).\n * The relevant data is provided in the more specific interfaces extending SdkResponse.\n */\nexport type SdkResponse<T extends ResponseData> = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\terrorCode: string;\n\t\terrorDescription?: string;\n\t};\n\tdata?: T;\n};\n\n/** Different delivery method */\nexport type Deliveries<T extends SdkFn> = Record<keyof typeof DeliveryMethods, T>;\n\n/** The different routes (actions) we can do */\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\n/** Logger type that supports the given levels (debug, log, error) */\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveries,\n\tUser,\n\tSdkResponse,\n\tJWTResponse,\n\tDeliveryPhone,\n\tLoginOptions\n} from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (loginId: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (loginId: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (loginId: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (loginId: string, phone: string) => Promise<SdkResponse<never>>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(loginIdValidations);\nconst withUpdatePhoneValidations = withValidations(loginIdValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(loginIdValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(loginId: string, code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.otp.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { loginId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { loginId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.otp.update.email, { loginId, email }, { token }))\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(loginId: string, phone: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tDeliveryPhone,\n\tSdkResponse,\n\tJWTResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(\n\t\t\t\t\tloginId: string,\n\t\t\t\t\tURI: string,\n\t\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\t\ttoken?: string\n\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.signIn, delivery),\n\t\t\t\t\t\t\t{ loginId, URI, loginOptions },\n\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(loginId: string, URI: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { loginId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(loginId: string, email: string, uri: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.magicLink.update.email, { loginId, email, URI: uri }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(\n\t\t\t\t\t\tloginId: string,\n\t\t\t\t\t\tphone: string,\n\t\t\t\t\t\turi: string,\n\t\t\t\t\t\ttoken?: string\n\t\t\t\t\t): Promise<SdkResponse<never>> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ loginId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLink;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const loginIdValidations = stringNonEmpty('loginId');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(loginIdValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tloginIdValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tloginIdValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport {\n\tDeliveryMethods,\n\tSdkResponse,\n\tJWTResponse,\n\tEnchantedLinkResponse,\n\tUser,\n\tLoginOptions\n} from '../types';\nimport { EnchantedLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations\n} from './validations';\n\n/** Polling configuration with defaults and normalizing checks */\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || ENCHANTED_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tENCHANTED_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || ENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tENCHANTED_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withEnchantedLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse<never>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.enchantedLink.verify, { token }))\n\t),\n\n\tsignIn: withSignValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tURI: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(\n\t\t\t\t\tpathJoin(apiPaths.enchantedLink.signIn, DeliveryMethods.email),\n\t\t\t\t\t{\n\t\t\t\t\t\tloginId,\n\t\t\t\t\t\tURI,\n\t\t\t\t\t\tloginOptions\n\t\t\t\t\t},\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUpOrIn: withSignValidations(\n\t\t(loginId: string, URI: string): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUpOrIn, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signIn],\n\n\tsignUp: withSignValidations(\n\t\t(loginId: string, URI: string, user?: User): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(pathJoin(apiPaths.enchantedLink.signUp, DeliveryMethods.email), {\n\t\t\t\t\tloginId,\n\t\t\t\t\tURI,\n\t\t\t\t\tuser\n\t\t\t\t})\n\t\t\t)\n\t) as EnchantedLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse<JWTResponse>> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.enchantedLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tmessage: `Session polling timeout exceeded: ${timeoutMs}ms`,\n\t\t\t\t\t\t\terrorCode: '0'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\temail: string,\n\t\t\t\turi: string,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<EnchantedLinkResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.enchantedLink.update.email,\n\t\t\t\t\t\t{ loginId, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withEnchantedLink;\n","import { SdkResponse, URLResponse, JWTResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple',\n\tdiscord = 'discord',\n\tlinkedin = 'linkedin'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\ntype VerifyFn = (code: string) => Promise<SdkResponse<JWTResponse>>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from '../types';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\nimport { stringNonEmpty, withValidations } from '../validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (\n\t\t\t\tredirectUrl?: string,\n\t\t\t\t{ redirect = false } = {},\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t) => {\n\t\t\t\tconst resp = await httpClient.post(apiPaths.oauth.start, loginOptions || {}, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) },\n\t\t\t\t\ttoken\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok)\n\t\t\t\t\treturn transformResponse<SdkResponse<URLResponse>>(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.oauth.exchange, { code }))\n\t)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { FlowResponse, Options, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('interactionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations(\n\t\t(\n\t\t\tflowId: string,\n\t\t\toptions?: Options,\n\t\t\tinteractionId?: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.start, { flowId, options, interactionId, input })\n\t\t\t)\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tinteractionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t): Promise<SdkResponse<FlowResponse>> => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, interactionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse, URLResponse, JWTResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse<URLResponse>>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (\n\t\t\ttenantNameOrEmail: string,\n\t\t\tredirectUrl?: string,\n\t\t\t{ redirect = false } = {},\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t) => {\n\t\t\tconst resp = await httpClient.post(apiPaths.saml.start, loginOptions || {}, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl },\n\t\t\t\ttoken\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.saml.exchange, { code }))\n\t)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse, JWTResponse, TOTPResponse, LoginOptions } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst loginIdValidations = stringNonEmpty('loginId');\nconst withVerifyValidations = withValidations(loginIdValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(loginIdValidations);\nconst withUpdateValidations = withValidations(loginIdValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(loginId: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { loginId, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tloginId: string,\n\t\t\tcode: string,\n\t\t\tloginOptions?: LoginOptions,\n\t\t\ttoken?: string\n\t\t): Promise<SdkResponse<JWTResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.verify, { loginId, code, loginOptions }, { token })\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(loginId: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.update, { loginId }, { token }))\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport {\n\tSdkResponse,\n\tResponseData,\n\tLoginOptions,\n\tJWTResponse,\n\tWebAuthnStartResponse\n} from './types';\nimport { string, stringNonEmpty, withValidations } from './validations';\n\nconst loginIdStringValidations = string('loginId');\nconst loginIdNonEmptyValidations = stringNonEmpty('loginId');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignUpOrInStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations\n);\nconst withSignInStartValidations = withValidations(loginIdStringValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tloginIdNonEmptyValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tname: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\tloginId,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\tloginOptions?: LoginOptions,\n\t\t\t\ttoken?: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.signIn.start,\n\t\t\t\t\t\t{ loginId, origin, loginOptions },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<JWTResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignUpOrIn: {\n\t\tstart: withSignUpOrInStartValidations(\n\t\t\t(loginId: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(httpClient.post(apiPaths.webauthn.signUpOrIn.start, { loginId, origin }))\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tloginId: string,\n\t\t\t\torigin: string,\n\t\t\t\ttoken: string\n\t\t\t): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.start, { loginId, origin }, { token })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse<ResponseData>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withAccessKeys from './accesskey';\nimport withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport { isJwtExpired, getJwtPermissions, getJwtRoles, transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport withEnchantedLink from './enchantedLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\nimport { UserResponse, JWTResponse } from './types';\n\nconst withJwtValidations = withValidations(stringNonEmpty('token'));\n\n/** Returns Descope SDK with all available operations */\nexport default (httpClient: HttpClient) => ({\n\taccessKey: withAccessKeys(httpClient),\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\tenchantedLink: withEnchantedLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) =>\n\t\ttransformResponse<JWTResponse>(httpClient.post(apiPaths.refresh, {}, { token })),\n\tlogout: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logout, {}, { token })),\n\tlogoutAll: (token?: string) =>\n\t\ttransformResponse<never>(httpClient.post(apiPaths.logoutAll, {}, { token })),\n\tme: (token?: string) => transformResponse<UserResponse>(httpClient.get(apiPaths.me, { token })),\n\tisJwtExpired: withJwtValidations(isJwtExpired),\n\tgetJwtPermissions: withJwtValidations(getJwtPermissions),\n\tgetJwtRoles: withJwtValidations(getJwtRoles),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport { AfterRequest, BeforeRequest, Hooks } from './httpClient/types';\nimport createSdk from './sdk';\nimport { Logger } from './sdk/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\n\tbaseHeaders?: HeadersInit;\n};\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Add the ability to pass multiple hooks instead of one when creating an SDK instance */\nconst withMultipleHooks =\n\t<T extends object>(createSdk: (config: SdkConfig) => T) =>\n\t(\n\t\tconfig: Omit<SdkConfig, 'hooks'> & {\n\t\t\thooks?: {\n\t\t\t\tbeforeRequest?: BeforeRequest | BeforeRequest[];\n\t\t\t\tafterRequest?: AfterRequest | AfterRequest[];\n\t\t\t};\n\t\t}\n\t) => {\n\t\tconst beforeRequestHooks = [].concat(config.hooks?.beforeRequest || []);\n\t\tconst afterRequestHooks = [].concat(config.hooks?.afterRequest || []);\n\n\t\tconst beforeRequest: BeforeRequest = (config) =>\n\t\t\tbeforeRequestHooks?.reduce((acc, fn) => fn(acc), config);\n\t\tconst afterRequest: AfterRequest = (req, res) => {\n\t\t\tafterRequestHooks?.forEach((fn) => fn(req, res?.clone()));\n\t\t};\n\n\t\treturn createSdk({ ...config, hooks: { beforeRequest, afterRequest } });\n\t};\n\n/** Descope SDK client */\nexport default withSdkConfigValidations(\n\twithMultipleHooks(\n\t\t({ projectId, logger, baseUrl, hooks, cookiePolicy, baseHeaders = {} }: SdkConfig) =>\n\t\t\tcreateSdk(\n\t\t\t\tcreateHttpClient({\n\t\t\t\t\tbaseUrl: baseUrl || DEFAULT_BASE_API_URL,\n\t\t\t\t\tprojectId,\n\t\t\t\t\tlogger,\n\t\t\t\t\thooks,\n\t\t\t\t\tcookiePolicy,\n\t\t\t\t\tbaseConfig: { baseHeaders }\n\t\t\t\t})\n\t\t\t)\n\t)\n);\n","/* eslint-disable import/exports-last */\nimport { ResponseData } from '../../sdk/types';\nimport { SdkFnWrapper, ReplacePaths, SdkFnsPaths } from './types';\n\n/**\n * A wrapper function that allows to wrap multiple Sdk function\n * @param obj: The Sdk instance you want to wrap\n * @param paths: A readonly list of paths of the functions you want to wrap\n * @param wrapper: Your wrapper function, it should gets an Sdk function and return a new Sdk function\n * @returns a mutated instance of the Sdk with updated type definitions based on your wrapper return type\n *\n * Usage example:\n *\n * // Assuming this is our SDK instance\n * const sdk = {\n * me: (token) => {...}\n * flow: {\n * start: (...params) => {...}\n * next: (...params) => {...}\n * }\n * ...\n * }\n *\n * // This is our wrapper\n * const wrapper = (sdkFn) => async (...args) => {\n * const sdkResponse = await sdkFn(...args)\n *\n * // Modify return value\n * return {...sdkResponse, data: {...sdkResponse.data, myCustomAttribute: 'hello'}}\n * }\n *\n * // And those are the paths we want to wrap\n * const paths = ['flow.start', 'flow.next'] as const // You MUST add as const!\n *\n * // We can wrap our SDK functions with the wrapper we created in this way\n * const newlyTypedSdk = wrapWith(sdk, paths, wrapper)\n *\n * Now the 2 wrapped functions will have the updated type based on the wrapper return value\n */\n\nconst wrapWith = <\n\tObj extends object,\n\tPaths extends ReadonlyArray<SdkFnsPaths<Obj>>,\n\tWrapperData extends ResponseData\n>(\n\tobj: Obj,\n\tpaths: Paths,\n\twrapper: SdkFnWrapper<WrapperData>\n): ReplacePaths<Obj, Paths, WrapperData> => {\n\tpaths.forEach((path) => {\n\t\tconst sections = path.split('.');\n\t\tlet section = sections.shift();\n\t\tlet currentRef: Record<string, any> = obj;\n\n\t\twhile (sections.length > 0) {\n\t\t\tcurrentRef = currentRef[section];\n\n\t\t\tif (!section || !currentRef) {\n\t\t\t\tthrow Error(`Invalid path \"${path}\", \"${section}\" is missing or has no value`);\n\t\t\t}\n\n\t\t\tsection = sections.shift();\n\t\t}\n\n\t\tif (typeof currentRef[section] !== 'function') {\n\t\t\tthrow Error(`\"${path}\" is not a function`);\n\t\t}\n\t\tconst origFn = currentRef[section];\n\t\tcurrentRef[section] = wrapper(origFn);\n\t});\n\n\treturn obj as any;\n};\n\nexport default wrapWith;\n","import { SdkConfig } from '../types';\n\nexport { default as wrapWith } from './wrapWith';\nexport type { SdkFnWrapper } from './wrapWith/types';\n\n/**\n * Add hooks to an existing core-sdk config\n */\nexport const addHooksToConfig = <Config extends SdkConfig>(\n\tconfig: Config,\n\thooks: Config['hooks']\n): Config => {\n\t['beforeRequest', 'afterRequest'].reduce((acc, key) => {\n\t\tacc[key] = [].concat(config.hooks?.[key] || []).concat(hooks?.[key] || []);\n\n\t\treturn acc;\n\t}, (config.hooks ??= {}));\n\n\treturn config;\n};\n","import createSdk from './createSdk';\nimport { HTTPMethods, RequestConfig } from './httpClient/types';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods } from './sdk/types';\n\n/** Descope SDK client with delivery methods enum.\n *\n * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}\n * @example Usage\n *\n * ```js\n * import descopeSdk from '@descope/core-js-sdk';\n *\n * const myProjectId = 'xxx';\n * const sdk = descopeSdk({ projectId: myProjectId });\n *\n * const userLoginId = 'loginId';\n * sdk.otp.signIn.email(userLoginId);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(createSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport type {\n\tEnchantedLinkResponse,\n\tExchangeAccessKeyResponse,\n\tFlowAction,\n\tFlowResponse,\n\tFlowStatus,\n\tJWTResponse,\n\tResponseData,\n\tSdkResponse,\n\tTOTPResponse,\n\tURLResponse,\n\tUserResponse\n} from './sdk/types';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\nexport type { HTTPMethods, RequestConfig };\n\n/** Type to restrict to valid delivery methods */\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\n/** Type to restrict to valid OAuth providers */\nexport type OAuthProvider = keyof typeof OAuthProviders;\n"],"names":["apiPaths","exchange","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","clone","text","Promise","resolve","json","parse","statusText","buildResponseLog","HTTPMethods","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","cookiePolicy","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","res","URL","search","URLSearchParams","urlBuilder","baseHeaders","credentials","afterRequest","get","post","put","delete","getJwtAuthorizationItems","tenant","claim","claims","parseJwt","tenants","_a","items","jwtDecode","isJwtExpired","exp","Date","getTime","getJwtPermissions","getJwtRoles","pathJoin","replace","transformResponse","response","transform","ret","code","data","error","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","withExchangeValidations","withAccessKeys","httpClient","accessKey","DeliveryPhone","DeliveryMethods","FlowStatus","Routes","loginIdValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","loginId","loginOptions","user","uriValidations","withMagicLink","URI","uri","withWaitForSessionValidations","withEnchantedLink","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","errorCode","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","options","interactionId","input","executionId","stepId","withSaml","tenantNameOrEmail","withSignUpValidations","withUpdateValidations","withTotp","loginIdStringValidations","loginIdNonEmptyValidations","originValidations","withSignUpStartValidations","withSignUpOrInStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","createSdk","validatePathValue","withSdkConfigValidations","beforeRequestHooks","concat","afterRequestHooks","_b","req","withMultipleHooks","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me","wrapWith","obj","paths","wrapper","sections","split","section","shift","currentRef","origFn","addHooksToConfig","index"],"mappings":"oDACA,IAAeA,EACH,CACVC,SAAU,+BAFGD,EAIT,CACJE,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BAZCR,EAcH,CACVE,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,gCAtBCR,EAwBC,CACdE,OAAQ,gCACRC,OAAQ,gCACRC,OAAQ,gCACRK,QAAS,yCACTJ,OAAQ,CACPC,MAAO,uCAERE,WAAY,oCAhCCR,EAkCP,CACNU,MAAO,2BACPT,SAAU,2BApCGD,EAsCR,CACLU,MAAO,0BACPT,SAAU,0BAxCGD,EA0CR,CACLE,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA7CKL,EA+CJ,CACTI,OAAQ,CACPM,MAAO,iCACPC,OAAQ,mCAETR,OAAQ,CACPO,MAA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AFAqH,EAAaA,EAAWF,IAEnBA,IAAYE,EAChB,MAAM5N,MAAM,iBAAiB8C,QAAW4K,iCAGzCA,EAAUF,EAASG,OACnB,CAED,GAAmC,mBAAxBC,EAAWF,GACrB,MAAM1N,MAAM,IAAI8C,wBAEjB,MAAM+K,EAASD,EAAWF,GAC1BE,EAAWF,GAAWH,EAAQM,EAAO,IAG/BR,GC/DKS,GAAmB,CAC/BnL,EACAJ,WAQA,MANA,CAAC,gBAAiB,gBAAgBpB,QAAO,CAACC,EAAK3B,WAG9C,OAFA2B,EAAI3B,GAAO,GAAG0M,QAAmB,UAAZxJ,EAAOJ,aAAK,IAAA2B,OAAA,EAAAA,EAAGzE,KAAQ,IAAI0M,QAAO5J,aAAA,EAAAA,EAAQ9C,KAAQ,IAEhE2B,CAAG,GACK,QAAb8C,EAACvB,EAAOJ,aAAK,IAAA2B,EAAAA,EAAZvB,EAAOJ,MAAU,CAAA,GAEdI,CAAM,ECGd,IAAeoL,GAAA1P,OAAO4J,OAAO8D,GAAW,CAAExE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/core-js-sdk",
|
|
3
|
-
"version": "0.0.41-alpha.
|
|
3
|
+
"version": "0.0.41-alpha.46",
|
|
4
4
|
"main": "dist/cjs/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"esbuild": "^0.16.0",
|
|
52
52
|
"eslint": "8.26.0",
|
|
53
53
|
"eslint-config-airbnb-typescript": "17.0.0",
|
|
54
|
-
"eslint-config-prettier": "8.
|
|
54
|
+
"eslint-config-prettier": "8.6.0",
|
|
55
55
|
"eslint-config-standard": "17.0.0",
|
|
56
56
|
"eslint-import-resolver-typescript": "3.5.2",
|
|
57
57
|
"eslint-plugin-import": "2.26.0",
|
|
58
|
-
"eslint-plugin-jest": "27.
|
|
58
|
+
"eslint-plugin-jest": "27.2.0",
|
|
59
59
|
"eslint-plugin-jest-dom": "4.0.3",
|
|
60
60
|
"eslint-plugin-jest-formatting": "3.1.0",
|
|
61
61
|
"eslint-plugin-n": "15.6.0",
|