@descope/core-js-sdk 0.0.41-alpha.35 → 0.0.41-alpha.36
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 +78 -16
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
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),a=n(t),i={exchange:"/v1/auth/accesskey/exchange"},o={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",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"},p={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},d={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},c={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},l={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")}},y=(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 k;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(k||(k={}));const b=(...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),x=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},w=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=y(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:p,headers:d,queryParams:c,method:l,token:g}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:c}),{headers:b(x(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.35"},(null==n?void 0:n.baseHeaders)||{},d),method:l,body:O(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:k.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:k.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:k.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:k.delete,token:a})}};function U(e,t,n){var s;let a=j(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function j(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=j(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 M(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,s}const E=(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)}),A=e=>t=>e.test(t),T=A(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),L=A(/^\+[1-9]{1}[0-9]{3,14}$/),z=E(T,'"{val}" is not a valid email'),J=E(L,'"{val}" is not a valid phone number'),H=E((C=1,e=>e.length>=C),"Minimum length is 1");var C;const D=E((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=>M(e.post(i.exchange,{},{token:t}))))});var G,Q,V,W,X;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Q||(Q={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(W||(W={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(X||(X={}));const Y=Z("identifier"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),ae=e=>({verify:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>M(e.post($(o.verify,n),{code:s,externalId:t}))))})),{}),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,a)=>M(e.post($(o.signIn,n),{externalId:t,loginOptions:s},{token:a}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>M(e.post($(o.signUp,n),{externalId:t,user:s}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>M(e.post($(o.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:se(((t,n,s)=>M(e.post(o.update.email,{externalId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,a)=>M(e.post($(o.update.phone,n),{externalId:t,phone:s},{token:a}))))})),{})}}),ie=Z("identifier"),oe=Z("uri"),re=N(Z("token")),ue=N(ie,oe),pe=N(ie,B("phone"),oe),de=N(ie,_("email"),oe),ce=e=>({verify:re((t=>M(e.post(r.verify,{token:t})))),signIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,a,i)=>M(e.post($(r.signIn,n),{externalId:t,URI:s,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,a)=>M(e.post($(r.signUp,n),{externalId:t,URI:s,user:a}))))})),{}),signUpOrIn:Object.keys(Q).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>M(e.post($(r.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:de(((t,n,s,a)=>M(e.post(r.update.email,{externalId:t,email:n,URI:s},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,a,i)=>M(e.post($(r.update.phone,n),{externalId:t,phone:s,URI:a},{token:i}))))})),{})}}),le=Z("identifier"),ge=Z("uri"),he=N(Z("token")),ve=N(le,ge),fe=N(Z("pendingRef")),me=N(le,_("email"),ge),Ie=e=>({verify:he((t=>M(e.post(u.verify,{token:t})))),signIn:ve(((t,n,s,a)=>M(e.post($(u.signIn,Q.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:ve(((t,n)=>M(e.post($(u.signUpOrIn,Q.email),{externalId:t,URI:n})))),signUp:ve(((t,n,s)=>M(e.post($(u.signUp,Q.email),{externalId:t,URI:n,user:s})))),waitForSession:fe(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let o;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),o&&clearTimeout(o),s(M(Promise.resolve(n))))}),a);o=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,a)=>M(e.post(u.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var ye;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ye||(ye={}));const ke=N(Z("code")),be=e=>({start:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const o=await e.post(p.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!o.ok)return M(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r}})),{}),exchange:ke((t=>M(e.post(p.exchange,{code:t}))))}),Oe=N(Z("flowId")),xe=N(Z("executionId"),Z("stepId"),Z("interactionId")),we=e=>({start:Oe(((t,n,s,a)=>M(e.post(m.start,{flowId:t,options:n,interactionId:s,input:a})))),next:xe(((t,n,s,a)=>M(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),Ue=N(Z("tenant")),je=N(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(d.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return M(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r})),exchange:je((t=>M(e.post(d.exchange,{code:t}))))}),Re=Z("identifier"),qe=N(Re,Z("code")),$e=N(Re),Me=N(Re),Ee=e=>({signUp:$e(((t,n)=>M(e.post(c.signUp,{externalId:t,user:n})))),verify:qe(((t,n,s,a)=>M(e.post(c.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Me(((t,n)=>M(e.post(c.update,{externalId:t},{token:n}))))}),Se=Z("identifier"),Ae=Z("origin"),Te=N(Se,Ae,Z("name")),Le=N(Se,Ae),ze=N(Se,Ae,Z("token")),Je=N(Z("transactionId"),Z("response")),He=e=>({signUp:{start:Te(((t,n,s)=>M(e.post(l.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Je(((t,n)=>M(e.post(l.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Le(((t,n,s,a)=>M(e.post(l.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Je(((t,n)=>M(e.post(l.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Le(((t,n)=>M(e.post(l.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:ze(((t,n,s)=>M(e.post(l.update.start,{externalId:t,origin:n},{token:s})))),finish:Je(((t,n)=>M(e.post(l.update.finish,{transactionId:t,response:n}))))}}),Ce=N(Z("token"));var De,Ne;const Ze=N([(De="projectId",Ne=Z("projectId"),E(((e,t)=>n=>S(...t).validate(a.default(n,e)))(De,Ne))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=w({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:F(i),otp:ae(i),magicLink:ce(i),enchantedLink:Ie(i),oauth:be(i),saml:Pe(i),totp:Ee(i),webauthn:He(i),flow:we(i),refresh:e=>M(i.post(g,{},{token:e})),logout:e=>M(i.post(h,{},{token:e})),logoutAll:e=>M(i.post(v,{},{token:e})),me:e=>M(i.get(f,{token:e})),isJwtExpired:Ce(P),getJwtPermissions:Ce(R),getJwtRoles:Ce(q),httpClient:i};var i}));Ze.DeliveryMethods=Q,exports.default=Ze,exports.transformResponse=M;
|
|
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),a=n(t),i={exchange:"/v1/auth/accesskey/exchange"},o={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",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"},p={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},c={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},d={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},l={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"}},h="/v1/auth/refresh",g="/v1/auth/logout",f="/v1/auth/logoutall",v="/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 y;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(y||(y={}));const b=(...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),x=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},w=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=k(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:p,headers:c,queryParams:d,method:l,token:h}=r,g=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:d}),{headers:b(x(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.36"},(null==n?void 0:n.baseHeaders)||{},c),method:l,body:O(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:y.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:y.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:y.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:y.delete,token:a}),hooks:a}};function j(e,t,n){var s;let a=U(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function U(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=U(e);return(new Date).getTime()/1e3>t}function R(e,t){return j(e,t,"permissions")}function q(e,t){return j(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},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,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)}),A=e=>t=>e.test(t),T=A(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),L=A(/^\+[1-9]{1}[0-9]{3,14}$/),z=M(T,'"{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("identifier"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),ae=e=>({verify:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>E(e.post($(o.verify,n),{code:s,externalId:t}))))})),{}),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,a)=>E(e.post($(o.signIn,n),{externalId:t,loginOptions:s},{token:a}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>E(e.post($(o.signUp,n),{externalId:t,user:s}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>E(e.post($(o.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:se(((t,n,s)=>E(e.post(o.update.email,{externalId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,a)=>E(e.post($(o.update.phone,n),{externalId:t,phone:s},{token:a}))))})),{})}}),ie=Z("identifier"),oe=Z("uri"),re=N(Z("token")),ue=N(ie,oe),pe=N(ie,B("phone"),oe),ce=N(ie,_("email"),oe),de=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,a,i)=>E(e.post($(r.signIn,n),{externalId:t,URI:s,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,a)=>E(e.post($(r.signUp,n),{externalId:t,URI:s,user:a}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>E(e.post($(r.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:ce(((t,n,s,a)=>E(e.post(r.update.email,{externalId:t,email:n,URI:s},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,a,i)=>E(e.post($(r.update.phone,n),{externalId:t,phone:s,URI:a},{token:i}))))})),{})}}),le=Z("identifier"),he=Z("uri"),ge=N(Z("token")),fe=N(le,he),ve=N(Z("pendingRef")),me=N(le,_("email"),he),Ie=e=>({verify:ge((t=>E(e.post(u.verify,{token:t})))),signIn:fe(((t,n,s,a)=>E(e.post($(u.signIn,W.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:fe(((t,n)=>E(e.post($(u.signUpOrIn,W.email),{externalId:t,URI:n})))),signUp:fe(((t,n,s)=>E(e.post($(u.signUp,W.email),{externalId:t,URI:n,user:s})))),waitForSession:ve(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let o;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),o&&clearTimeout(o),s(E(Promise.resolve(n))))}),a);o=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,a)=>E(e.post(u.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var ke;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ke||(ke={}));const ye=N(Z("code")),be=e=>({start:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const o=await e.post(p.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!o.ok)return E(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r}})),{}),exchange:ye((t=>E(e.post(p.exchange,{code:t}))))}),Oe=N(Z("flowId")),xe=N(Z("executionId"),Z("stepId"),Z("interactionId")),we=e=>({start:Oe(((t,n,s,a)=>E(e.post(m.start,{flowId:t,options:n,interactionId:s,input:a})))),next:xe(((t,n,s,a)=>E(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),je=N(Z("tenant")),Ue=N(Z("code")),Pe=e=>({start:je((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(c.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return E(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r})),exchange:Ue((t=>E(e.post(c.exchange,{code:t}))))}),Re=Z("identifier"),qe=N(Re,Z("code")),$e=N(Re),Ee=N(Re),Me=e=>({signUp:$e(((t,n)=>E(e.post(d.signUp,{externalId:t,user:n})))),verify:qe(((t,n,s,a)=>E(e.post(d.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Ee(((t,n)=>E(e.post(d.update,{externalId:t},{token:n}))))}),Se=Z("identifier"),Ae=Z("origin"),Te=N(Se,Ae,Z("name")),Le=N(Se,Ae),ze=N(Se,Ae,Z("token")),Je=N(Z("transactionId"),Z("response")),He=e=>({signUp:{start:Te(((t,n,s)=>E(e.post(l.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Je(((t,n)=>E(e.post(l.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Le(((t,n,s,a)=>E(e.post(l.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Je(((t,n)=>E(e.post(l.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Le(((t,n)=>E(e.post(l.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:ze(((t,n,s)=>E(e.post(l.update.start,{externalId:t,origin:n},{token:s})))),finish:Je(((t,n)=>E(e.post(l.update.finish,{transactionId:t,response:n}))))}}),Ce=N(Z("token"));var De,Ne;let Ze=N([(De="projectId",Ne=Z("projectId"),M(((e,t)=>n=>S(...t).validate(a.default(n,e)))(De,Ne))())])((e=>t=>{var n,s;const a=[].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==a?void 0:a.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:a})=>{return i=w({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:F(i),otp:ae(i),magicLink:de(i),enchantedLink:Ie(i),oauth:be(i),saml:Pe(i),totp:Me(i),webauthn:He(i),flow:we(i),refresh:e=>E(i.post(h,{},{token:e})),logout:e=>E(i.post(g,{},{token:e})),logoutAll:e=>E(i.post(f,{},{token:e})),me:e=>E(i.get(v,{token:e})),isJwtExpired:Ce(P),getJwtPermissions:Ce(R),getJwtRoles:Ce(q),httpClient:i};var i})));var _e=Object.assign(Ze,{DeliveryMethods:W});exports.default=_e,exports.transformResponse=E,exports.wrapWith=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let a=s.shift(),i=e;for(;s.length>0;){if(i=i[a],!a||!i)throw Error(`Invalid path "${t}", "${a}" is missing or has no value`);a=s.shift()}if("function"!=typeof i[a])throw Error(`"${t}" is not a function`);const o=i[a];i[a]=n(o)})),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/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/user/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};\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\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n\tafterRequest?: (req: RequestConfig, res: Response) => void;\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};\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 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\texternalId?: 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\texternalIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\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// 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<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 = (identifier: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (identifier: 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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, 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(externalId: 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, externalId })\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\texternalId: 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{ externalId, 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(externalId: 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), { externalId, 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(externalId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\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(identifier: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { 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(externalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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{ externalId, 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(externalId: 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\texternalId,\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(externalId: 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), { externalId, 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(\n\t\t\t\tidentifier: 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<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, 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\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\texternalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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\texternalId,\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(externalId: 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\texternalId,\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(externalId: 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\texternalId,\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\tidentifier: 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{ externalId: identifier, 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}\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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tidentifier: 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(\n\t\t\t\t\tapiPaths.totp.verify,\n\t\t\t\t\t{ externalId: identifier, code, loginOptions },\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\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 { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tidentifierValidations,\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\tidentifier: 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\texternalId: identifier,\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\tidentifier: 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{ externalId: identifier, 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: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUpOrIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tidentifier: 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(\n\t\t\t\t\t\tapiPaths.webauthn.update.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\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<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 createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { Hooks, HTTPMethods, RequestConfig } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Descope SDK client */\nconst sdk = withSdkConfigValidations(\n\t({\n\t\tprojectId,\n\t\tlogger,\n\t\tbaseUrl,\n\t\thooks,\n\t\tcookiePolicy\n\t}: {\n\t\tprojectId: string;\n\t\tlogger?: Logger;\n\t\tbaseUrl?: string;\n\t\thooks?: Hooks;\n\t\tcookiePolicy?: RequestCredentials;\n\t}) =>\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);\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 userIdentifier = 'identifier';\n * sdk.otp.signIn.email(userIdentifier);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport { transformResponse } from './sdk/helpers';\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;\nexport type { HTTPMethods, RequestConfig };\nexport type {\n\tSdkResponse,\n\tResponseData,\n\tJWTResponse,\n\tFlowAction,\n\tFlowStatus,\n\tFlowResponse,\n\tExchangeAccessKeyResponse,\n\tUserResponse,\n\tEnchantedLinkResponse,\n\tURLResponse,\n\tTOTPResponse\n} from './sdk/types';\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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","externalId","loginOptions","user","identifier","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","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me"],"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,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,EAEDM,OAAOA,GAEN,OADAf,EAAIgB,OAASD,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AAKtG,EAAkBK,OAAOM,OAAQ,CAAE4N,gBAAe5G,mBChGjE6G,GAAqBlF,EAAgBK,EAAe,UfM9B,IAAChE,GAAc8I,GgBN3C,MAyCMC,GA9C2BpF,EAAgB,EhBWpB3D,GgBVf,YhBU6B8I,GgBVhB9E,EAAe,ahBWzC1B,EATyB,EAACtC,EAAc8I,IAAwBrG,GAChEC,KAAoBoG,GAAOlG,SAASlC,EAAAA,QAAI+B,EAAKzC,IAQ7BgJ,CAAkBhJ,GAAM8I,IAAxCxG,KgBPW2G,EACX,EACC/J,YACApC,SACAyC,UACAE,QACAC,mBAQAwJ,ODXc5E,ECYbhF,EAAiB,CAChBC,QAASA,GxB9BuB,0BwB+BhCL,YACApC,SACA2C,QACAC,iBDjBwC,CAC3C6E,UAAWF,EAAeC,GAC1B6E,IAAKlE,GAAQX,GACb8E,UAAW3D,GAAcnB,GACzB+E,cAAexD,GAAkBvB,GACjCgF,MAAOxC,GAAUxC,GACjBiF,KAAMxB,GAASzD,GACfkF,KAAMrB,GAAS7D,GACfmF,SAAUhB,GAAanE,GACvBoF,KAAMlC,GAASlD,GACfqF,QAAUxK,GACT4C,EAA+BuC,EAAW3D,KAAKtG,EAAkB,CAAA,EAAI,CAAE8E,WACxEyK,OAASzK,GACR4C,EAAyBuC,EAAW3D,KAAKtG,EAAiB,CAAA,EAAI,CAAE8E,WACjE0K,UAAY1K,GACX4C,EAAyBuC,EAAW3D,KAAKtG,EAAoB,CAAA,EAAI,CAAE8E,WACpE2K,GAAK3K,GAAmB4C,EAAgCuC,EAAW5D,IAAIrG,EAAa,CAAE8E,WACtFoC,aAAcsH,GAAmBtH,GACjCI,kBAAmBkH,GAAmBlH,GACtCC,YAAaiH,GAAmBjH,GAChC0C,cApBc,IAACA,CCmBb,IAqBHyE,GAAkBtE,gBAAkBA"}
|
|
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/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/user/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 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\texternalId?: 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\texternalIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\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// 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<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 = (identifier: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (identifier: 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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, 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(externalId: 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, externalId })\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\texternalId: 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{ externalId, 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(externalId: 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), { externalId, 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(externalId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\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(identifier: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { 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(externalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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{ externalId, 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(externalId: 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\texternalId,\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(externalId: 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), { externalId, 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(\n\t\t\t\tidentifier: 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<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, 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\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\texternalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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\texternalId,\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(externalId: 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\texternalId,\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(externalId: 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\texternalId,\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\tidentifier: 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{ externalId: identifier, 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}\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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tidentifier: 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(\n\t\t\t\t\tapiPaths.totp.verify,\n\t\t\t\t\t{ externalId: identifier, code, loginOptions },\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\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 { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tidentifierValidations,\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\tidentifier: 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\texternalId: identifier,\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\tidentifier: 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{ externalId: identifier, 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: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUpOrIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tidentifier: 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(\n\t\t\t\t\t\tapiPaths.webauthn.update.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\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<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 createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { AfterRequest, BeforeRequest, Hooks, HTTPMethods, RequestConfig } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\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 */\nlet initSdk = 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\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 userIdentifier = 'identifier';\n * sdk.otp.signIn.email(userIdentifier);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(initSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\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;\nexport type { HTTPMethods, RequestConfig };\nexport type {\n\tSdkResponse,\n\tResponseData,\n\tJWTResponse,\n\tFlowAction,\n\tFlowStatus,\n\tFlowResponse,\n\tExchangeAccessKeyResponse,\n\tUserResponse,\n\tEnchantedLinkResponse,\n\tURLResponse,\n\tTOTPResponse\n} from './sdk/types';\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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","externalId","loginOptions","user","identifier","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","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","initSdk","validatePathValue","withSdkConfigValidations","createSdk","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,+BA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AAW3D,KAAKtG,EAAiB,CAAA,EAAI,CAAE8E,WACjEgL,UAAYhL,GACX4C,EAAyBuC,EAAW3D,KAAKtG,EAAoB,CAAA,EAAI,CAAE8E,WACpEiL,GAAKjL,GAAmB4C,EAAgCuC,EAAW5D,IAAIrG,EAAa,CAAE8E,WACtFoC,aAAcsH,GAAmBtH,GACjCI,kBAAmBkH,GAAmBlH,GACtCC,YAAaiH,GAAmBjH,GAChC0C,cApBc,IAACA,CCsCb,KAoBH,IAAe+F,GAAA9O,OAAO4J,OAAO4D,GAAS,CAAEtE,oFCpCvB,CAKhB6F,EACAC,EACAC,KAEAD,EAAM1H,SAAS7C,IACd,MAAMyK,EAAWzK,EAAK0K,MAAM,KAC5B,IAAIC,EAAUF,EAASG,QACnBC,EAAkCP,EAEtC,KAAOG,EAAShH,OAAS,GAAG,CAG3B,GAFAoH,EAAaA,EAAWF,IAEnBA,IAAYE,EAChB,MAAM3N,MAAM,iBAAiB8C,QAAW2K,iCAGzCA,EAAUF,EAASG,OACnB,CAED,GAAmC,mBAAxBC,EAAWF,GACrB,MAAMzN,MAAM,IAAI8C,wBAEjB,MAAM8K,EAASD,EAAWF,GAC1BE,EAAWF,GAAWH,EAAQM,EAAO,IAG/BR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type SdkFn = (...args: any[]) => Promise<SdkResponse<ResponseData>>;
|
|
1
|
+
declare type SdkFn$1 = (...args: any[]) => Promise<SdkResponse<ResponseData>>;
|
|
2
2
|
declare type DeviceInfo = {
|
|
3
3
|
webAuthnSupport?: boolean;
|
|
4
4
|
};
|
|
@@ -136,7 +136,7 @@ declare type SdkResponse<T extends ResponseData> = {
|
|
|
136
136
|
data?: T;
|
|
137
137
|
};
|
|
138
138
|
/** Different delivery method */
|
|
139
|
-
declare type Deliveries<T extends SdkFn> = Record<DeliveryMethods, T>;
|
|
139
|
+
declare type Deliveries<T extends SdkFn$1> = Record<DeliveryMethods, T>;
|
|
140
140
|
/** Logger type that supports the given levels (debug, log, error) */
|
|
141
141
|
declare type Logger = Pick<Console, 'debug' | 'log' | 'error'>;
|
|
142
142
|
|
|
@@ -161,6 +161,7 @@ declare type HttpClient = {
|
|
|
161
161
|
post: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;
|
|
162
162
|
put: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;
|
|
163
163
|
delete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;
|
|
164
|
+
hooks?: Hooks;
|
|
164
165
|
};
|
|
165
166
|
/** For before-request hook allows overriding parts of the request */
|
|
166
167
|
declare type RequestConfig = {
|
|
@@ -173,14 +174,16 @@ declare type RequestConfig = {
|
|
|
173
174
|
method: HTTPMethods;
|
|
174
175
|
token?: string;
|
|
175
176
|
};
|
|
177
|
+
declare type BeforeRequest = (config: RequestConfig) => RequestConfig;
|
|
178
|
+
declare type AfterRequest = (req: RequestConfig, res: Response) => void;
|
|
176
179
|
/** Hooks before and after the request is made */
|
|
177
180
|
declare type Hooks = {
|
|
178
|
-
beforeRequest?:
|
|
179
|
-
afterRequest?:
|
|
181
|
+
beforeRequest?: BeforeRequest;
|
|
182
|
+
afterRequest?: AfterRequest;
|
|
180
183
|
};
|
|
181
184
|
|
|
182
|
-
declare type
|
|
183
|
-
declare type
|
|
185
|
+
declare type EnchantedLinkSignInFn = (identifier: string, uri: string) => Promise<SdkResponse<EnchantedLinkResponse>>;
|
|
186
|
+
declare type EnchantedLinkSignUpFn = (identifier: string, uri: string, user?: User) => Promise<SdkResponse<EnchantedLinkResponse>>;
|
|
184
187
|
/** Polling configuration for session waiting */
|
|
185
188
|
declare type WaitForSessionConfig = {
|
|
186
189
|
pollingIntervalMs: number;
|
|
@@ -206,6 +209,66 @@ declare enum OAuthProviders {
|
|
|
206
209
|
*/
|
|
207
210
|
declare function transformResponse<T extends ResponseData, S extends ResponseData = T>(response: Promise<Response>, transform?: (data: T) => S): Promise<SdkResponse<S>>;
|
|
208
211
|
|
|
212
|
+
declare type IsObject<T> = T extends Array<any> ? false : T extends Function ? false : T extends object ? true : false;
|
|
213
|
+
declare type Tail<T extends ReadonlyArray<string>> = T extends readonly [head: any, ...tail: infer Tail_] ? Tail_ : never;
|
|
214
|
+
declare type Head<T extends ReadonlyArray<string>> = T extends readonly [] ? never : T[0];
|
|
215
|
+
declare type SdkResponseType<F extends SdkFn<ResponseData>> = F extends SdkFn<infer U> ? U : never;
|
|
216
|
+
declare type SdkFnWrapperInternal<F extends SdkFn<ResponseData>, R extends ResponseData> = (fn: (...args: Parameters<F>) => ReturnType<F>) => (...args: Parameters<F>) => Promise<SdkResponse<R extends Record<string, never> ? SdkResponseType<F> : SdkResponseType<F> & R>>;
|
|
217
|
+
declare type PrependDot<T extends string> = [T] extends [never] ? '' : `.${T}`;
|
|
218
|
+
declare type SdkFnsPaths<T extends object> = keyof T extends infer K ? K extends string & keyof T ? IsObject<T> extends false ? never : T[K] extends SdkFn<ResponseData> ? K : IsObject<T[K]> extends false ? never : T[K] extends object ? `${K}${PrependDot<SdkFnsPaths<T[K]>>}` : never : never : never;
|
|
219
|
+
declare type ReplacePaths<Obj extends object, Paths extends ReadonlyArray<string>, WrapperData extends Record<string, any>> = Head<Paths> extends never ? Obj : Tail<Paths> extends ReadonlyArray<string> ? ReplacePaths<ReplacePath<Obj, Head<Paths>, WrapperData>, Tail<Paths>, WrapperData> : ReplacePath<Obj, Head<Paths>, WrapperData>;
|
|
220
|
+
declare type ReplacePath<Obj, Path extends string, WrapperData extends Record<string, any>> = Path extends `${infer Head}.${infer Tail}` ? {
|
|
221
|
+
[Key in keyof Obj]: Key extends Head ? ReplacePath<Obj[Key], Tail, WrapperData> : Obj[Key];
|
|
222
|
+
} : {
|
|
223
|
+
[Key in keyof Obj]: Key extends Path ? Obj[Key] extends SdkFn<ResponseData> ? ReturnType<SdkFnWrapperInternal<Obj[Key], WrapperData>> : Obj[Key] : Obj[Key];
|
|
224
|
+
};
|
|
225
|
+
declare type SdkFn<T extends ResponseData> = (...args: any) => Promise<SdkResponse<T>>;
|
|
226
|
+
declare type SdkFnWrapper<Z extends ResponseData> = <A extends any[], R extends ResponseData>(fn: (...args: A) => Promise<SdkResponse<R>>) => (...args: A) => Promise<SdkResponse<Z extends Record<string, never> ? R : Z & R>>;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* A wrapper function that allows to wrap multiple Sdk function
|
|
230
|
+
* @param obj: The Sdk instance you want to wrap
|
|
231
|
+
* @param paths: A readonly list of paths of the functions you want to wrap
|
|
232
|
+
* @param wrapper: Your wrapper function, it should gets an Sdk function and return a new Sdk function
|
|
233
|
+
* @returns a mutated instance of the Sdk with updated type definitions based on your wrapper return type
|
|
234
|
+
*
|
|
235
|
+
* Usage example:
|
|
236
|
+
*
|
|
237
|
+
* // Assuming this is our SDK instance
|
|
238
|
+
* const sdk = {
|
|
239
|
+
* me: (token) => {...}
|
|
240
|
+
* flow: {
|
|
241
|
+
* start: (...params) => {...}
|
|
242
|
+
* next: (...params) => {...}
|
|
243
|
+
* }
|
|
244
|
+
* ...
|
|
245
|
+
* }
|
|
246
|
+
*
|
|
247
|
+
* // This is our wrapper
|
|
248
|
+
* const wrapper = (sdkFn) => async (...args) => {
|
|
249
|
+
* const sdkResponse = await sdkFn(...args)
|
|
250
|
+
*
|
|
251
|
+
* // Modify return value
|
|
252
|
+
* return {...sdkResponse, data: {...sdkResponse.data, myCustomAttribute: 'hello'}}
|
|
253
|
+
* }
|
|
254
|
+
*
|
|
255
|
+
* // And those are the paths we want to wrap
|
|
256
|
+
* const paths = ['flow.start', 'flow.next'] as const // You MUST add as const!
|
|
257
|
+
*
|
|
258
|
+
* // We can wrap our SDK functions with the wrapper we created in this way
|
|
259
|
+
* const newlyTypedSdk = wrapWith(sdk, paths, wrapper)
|
|
260
|
+
*
|
|
261
|
+
* Now the 2 wrapped functions will have the updated type based on the wrapper return value
|
|
262
|
+
*/
|
|
263
|
+
declare const wrapWith: <Obj extends object, Paths extends readonly SdkFnsPaths<Obj>[], WrapperData extends ResponseData>(obj: Obj, paths: Paths, wrapper: SdkFnWrapper<WrapperData>) => ReplacePaths<Obj, Paths, WrapperData>;
|
|
264
|
+
|
|
265
|
+
declare type SdkConfig = {
|
|
266
|
+
projectId: string;
|
|
267
|
+
logger?: Logger;
|
|
268
|
+
baseUrl?: string;
|
|
269
|
+
hooks?: Hooks;
|
|
270
|
+
cookiePolicy?: RequestCredentials;
|
|
271
|
+
};
|
|
209
272
|
/** Descope SDK client with delivery methods enum.
|
|
210
273
|
*
|
|
211
274
|
* Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}
|
|
@@ -222,12 +285,11 @@ declare function transformResponse<T extends ResponseData, S extends ResponseDat
|
|
|
222
285
|
* const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);
|
|
223
286
|
* ```
|
|
224
287
|
*/
|
|
225
|
-
declare const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
cookiePolicy?: RequestCredentials;
|
|
288
|
+
declare const _default: ((config: Omit<SdkConfig, "hooks"> & {
|
|
289
|
+
hooks?: {
|
|
290
|
+
beforeRequest?: BeforeRequest | BeforeRequest[];
|
|
291
|
+
afterRequest?: AfterRequest | AfterRequest[];
|
|
292
|
+
};
|
|
231
293
|
}) => {
|
|
232
294
|
accessKey: {
|
|
233
295
|
exchange: (accessKey: string) => Promise<SdkResponse<ExchangeAccessKeyResponse>>;
|
|
@@ -254,9 +316,9 @@ declare const sdkWithAttributes: ((args_0: {
|
|
|
254
316
|
};
|
|
255
317
|
enchantedLink: {
|
|
256
318
|
verify: (token: string) => Promise<SdkResponse<never>>;
|
|
257
|
-
signIn:
|
|
258
|
-
signUpOrIn:
|
|
259
|
-
signUp:
|
|
319
|
+
signIn: EnchantedLinkSignInFn;
|
|
320
|
+
signUpOrIn: EnchantedLinkSignInFn;
|
|
321
|
+
signUp: EnchantedLinkSignUpFn;
|
|
260
322
|
waitForSession: (pendingRef: string, config?: WaitForSessionConfig) => Promise<SdkResponse<JWTResponse>>;
|
|
261
323
|
update: {
|
|
262
324
|
email: (identifier: string, email: string, uri: string, token?: string) => Promise<SdkResponse<EnchantedLinkResponse>>;
|
|
@@ -348,4 +410,4 @@ declare type DeliveryMethod = keyof typeof DeliveryMethods;
|
|
|
348
410
|
/** Type to restrict to valid OAuth providers */
|
|
349
411
|
declare type OAuthProvider = keyof typeof OAuthProviders;
|
|
350
412
|
|
|
351
|
-
export { DeliveryMethod, EnchantedLinkResponse, ExchangeAccessKeyResponse, FlowAction, FlowResponse, FlowStatus, HTTPMethods, JWTResponse, OAuthProvider, RequestConfig, ResponseData, SdkResponse, TOTPResponse, URLResponse, UserResponse,
|
|
413
|
+
export { DeliveryMethod, EnchantedLinkResponse, ExchangeAccessKeyResponse, FlowAction, FlowResponse, FlowStatus, HTTPMethods, JWTResponse, OAuthProvider, RequestConfig, ResponseData, SdkFnWrapper, SdkResponse, TOTPResponse, URLResponse, UserResponse, _default as default, transformResponse, wrapWith };
|
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"},a={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"},o={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/user/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"}},d="/v1/auth/refresh",c="/v1/auth/logout",l="/v1/auth/logoutall",g="/v1/auth/me",h={start:"/v1/flow/start",next:"/v1/flow/next"};const m=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},v=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>m().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),m().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var f;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(f||(f={}));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}),{})),y=e=>void 0===e?void 0:JSON.stringify(e),k=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},b=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=v(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:p,headers:d,queryParams:c,method:l,token:g}=r,h=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:c}),{headers:I(k(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.35"},(null==n?void 0:n.baseHeaders)||{},d),method:l,body:y(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:f.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:f.delete,token:a})}};function O(e,t,n){var s;let a=x(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function x(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function w(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function U(e,t){return O(e,t,"permissions")}function j(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},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,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)}),M=e=>t=>e.test(t),E=M(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),S=M(/^\+[1-9]{1}[0-9]{3,14}$/),A=q(E,'"{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("identifier"),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,a)=>R(e.post(P(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a,i)=>R(e.post(P(s.signIn,n),{externalId:t,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a)=>R(e.post(P(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:ee(((t,n,a)=>R(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,a,i)=>R(e.post(P(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),ne=C("identifier"),se=C("uri"),ae=H(C("token")),ie=H(ne,se),oe=H(ne,N("phone"),se),re=H(ne,D("email"),se),ue=e=>({verify:ae((t=>R(e.post(a.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,o)=>R(e.post(P(a.signIn,n),{externalId:t,URI:s,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(a.signUp,n),{externalId: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(a.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(e.post(a.update.email,{externalId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>R(e.post(P(a.update.phone,n),{externalId:t,phone:s,URI:i},{token:o}))))})),{})}}),pe=C("identifier"),de=C("uri"),ce=H(C("token")),le=H(pe,de),ge=H(C("pendingRef")),he=H(pe,D("email"),de),me=e=>({verify:ce((t=>R(e.post(i.verify,{token:t})))),signIn:le(((t,n,s,a)=>R(e.post(P(i.signIn,F.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:le(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{externalId:t,URI:n})))),signUp:le(((t,n,s)=>R(e.post(P(i.signUp,F.email),{externalId:t,URI:n,user:s})))),waitForSession:ge(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:o}=(({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))))}),a);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${o}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),o)})))),update:{email:he(((t,n,s,a)=>R(e.post(i.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var ve;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ve||(ve={}));const fe=H(C("code")),Ie=e=>({start:Object.keys(ve).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const r=await e.post(o.start,a||{},{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:fe((t=>R(e.post(o.exchange,{code:t}))))}),ye=H(C("flowId")),ke=H(C("executionId"),C("stepId"),C("interactionId")),be=e=>({start:ye(((t,n,s,a)=>R(e.post(h.start,{flowId:t,options:n,interactionId:s,input:a})))),next:ke(((t,n,s,a)=>R(e.post(h.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),Oe=H(C("tenant")),xe=H(C("code")),we=e=>({start:Oe((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(r.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return R(Promise.resolve(o));const{url:u}=await o.json();window.location.href=u})),exchange:xe((t=>R(e.post(r.exchange,{code:t}))))}),Ue=C("identifier"),je=H(Ue,C("code")),Pe=H(Ue),Re=H(Ue),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{externalId:t,user:n})))),verify:je(((t,n,s,a)=>R(e.post(u.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Re(((t,n)=>R(e.post(u.update,{externalId:t},{token:n}))))}),$e=C("identifier"),Me=C("origin"),Ee=H($e,Me,C("name")),Se=H($e,Me),Ae=H($e,Me,C("token")),Te=H(C("transactionId"),C("response")),Le=e=>({signUp:{start:Ee(((t,n,s)=>R(e.post(p.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Te(((t,n)=>R(e.post(p.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Se(((t,n,s,a)=>R(e.post(p.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Te(((t,n)=>R(e.post(p.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Se(((t,n)=>R(e.post(p.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Ae(((t,n,s)=>R(e.post(p.update.start,{externalId:t,origin:n},{token:s})))),finish:Te(((t,n)=>R(e.post(p.update.finish,{transactionId:t,response:n}))))}}),ze=H(C("token"));var Je,He;const Ce=H([(Je="projectId",He=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(Je,He))())])((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=b({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:B(i),otp:te(i),magicLink:ue(i),enchantedLink:me(i),oauth:Ie(i),saml:we(i),totp:qe(i),webauthn:Le(i),flow:be(i),refresh:e=>R(i.post(d,{},{token:e})),logout:e=>R(i.post(c,{},{token:e})),logoutAll:e=>R(i.post(l,{},{token:e})),me:e=>R(i.get(g,{token:e})),isJwtExpired:ze(w),getJwtPermissions:ze(U),getJwtRoles:ze(j),httpClient:i};var i}));Ce.DeliveryMethods=F;export{Ce as default,R as transformResponse};
|
|
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"},a={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"},o={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/user/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"}},c="/v1/auth/refresh",d="/v1/auth/logout",l="/v1/auth/logoutall",h="/v1/auth/me",g={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),y=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},b=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=f(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:p,headers:c,queryParams:d,method:l,token:h}=r,g=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:d}),{headers:I(y(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.36"},(null==n?void 0:n.baseHeaders)||{},c),method:l,body:k(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==g?void 0:g.clone()),g};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:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.delete,token:a}),hooks:a}};function O(e,t,n){var s;let a=w(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function w(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function x(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function j(e,t){return O(e,t,"permissions")}function U(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},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,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("identifier"),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,a)=>R(e.post(P(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a,i)=>R(e.post(P(s.signIn,n),{externalId:t,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a)=>R(e.post(P(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:ee(((t,n,a)=>R(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,a,i)=>R(e.post(P(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),ne=C("identifier"),se=C("uri"),ae=H(C("token")),ie=H(ne,se),oe=H(ne,N("phone"),se),re=H(ne,D("email"),se),ue=e=>({verify:ae((t=>R(e.post(a.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,o)=>R(e.post(P(a.signIn,n),{externalId:t,URI:s,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(a.signUp,n),{externalId: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(a.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(e.post(a.update.email,{externalId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>R(e.post(P(a.update.phone,n),{externalId:t,phone:s,URI:i},{token:o}))))})),{})}}),pe=C("identifier"),ce=C("uri"),de=H(C("token")),le=H(pe,ce),he=H(C("pendingRef")),ge=H(pe,D("email"),ce),ve=e=>({verify:de((t=>R(e.post(i.verify,{token:t})))),signIn:le(((t,n,s,a)=>R(e.post(P(i.signIn,F.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:le(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{externalId:t,URI:n})))),signUp:le(((t,n,s)=>R(e.post(P(i.signUp,F.email),{externalId:t,URI:n,user:s})))),waitForSession:he(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:o}=(({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))))}),a);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${o}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),o)})))),update:{email:ge(((t,n,s,a)=>R(e.post(i.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var fe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(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}={},a,i)=>{const r=await e.post(o.start,a||{},{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(o.exchange,{code:t}))))}),ke=H(C("flowId")),ye=H(C("executionId"),C("stepId"),C("interactionId")),be=e=>({start:ke(((t,n,s,a)=>R(e.post(g.start,{flowId:t,options:n,interactionId:s,input:a})))),next:ye(((t,n,s,a)=>R(e.post(g.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),Oe=H(C("tenant")),we=H(C("code")),xe=e=>({start:Oe((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(r.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return R(Promise.resolve(o));const{url:u}=await o.json();window.location.href=u})),exchange:we((t=>R(e.post(r.exchange,{code:t}))))}),je=C("identifier"),Ue=H(je,C("code")),Pe=H(je),Re=H(je),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{externalId:t,user:n})))),verify:Ue(((t,n,s,a)=>R(e.post(u.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Re(((t,n)=>R(e.post(u.update,{externalId:t},{token:n}))))}),$e=C("identifier"),Ee=C("origin"),Me=H($e,Ee,C("name")),Se=H($e,Ee),Ae=H($e,Ee,C("token")),Te=H(C("transactionId"),C("response")),Le=e=>({signUp:{start:Me(((t,n,s)=>R(e.post(p.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Te(((t,n)=>R(e.post(p.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Se(((t,n,s,a)=>R(e.post(p.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Te(((t,n)=>R(e.post(p.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Se(((t,n)=>R(e.post(p.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Ae(((t,n,s)=>R(e.post(p.update.start,{externalId:t,origin:n},{token:s})))),finish:Te(((t,n)=>R(e.post(p.update.finish,{transactionId:t,response:n}))))}}),ze=H(C("token"));const Je=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let a=s.shift(),i=e;for(;s.length>0;){if(i=i[a],!a||!i)throw Error(`Invalid path "${t}", "${a}" is missing or has no value`);a=s.shift()}if("function"!=typeof i[a])throw Error(`"${t}" is not a function`);const o=i[a];i[a]=n(o)})),e);var He,Ce;let De=H([(He="projectId",Ce=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(He,Ce))())])((e=>t=>{var n,s;const a=[].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==a?void 0:a.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:a})=>{return i=b({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:B(i),otp:te(i),magicLink:ue(i),enchantedLink:ve(i),oauth:Ie(i),saml:xe(i),totp:qe(i),webauthn:Le(i),flow:be(i),refresh:e=>R(i.post(c,{},{token:e})),logout:e=>R(i.post(d,{},{token:e})),logoutAll:e=>R(i.post(l,{},{token:e})),me:e=>R(i.get(h,{token:e})),isJwtExpired:ze(x),getJwtPermissions:ze(j),getJwtRoles:ze(U),httpClient:i};var i})));var Ne=Object.assign(De,{DeliveryMethods:F});export{Ne as default,R as transformResponse,Je 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/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/user/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};\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\n/** Hooks before and after the request is made */\nexport type Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n\tafterRequest?: (req: RequestConfig, res: Response) => void;\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};\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 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\texternalId?: 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\texternalIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\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// 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<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 = (identifier: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (identifier: 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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, 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(externalId: 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, externalId })\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\texternalId: 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{ externalId, 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(externalId: 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), { externalId, 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(externalId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\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(identifier: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { 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(externalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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{ externalId, 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(externalId: 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\texternalId,\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(externalId: 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), { externalId, 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(\n\t\t\t\tidentifier: 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<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, 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\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\texternalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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\texternalId,\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(externalId: 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\texternalId,\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(externalId: 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\texternalId,\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\tidentifier: 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{ externalId: identifier, 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}\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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tidentifier: 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(\n\t\t\t\t\tapiPaths.totp.verify,\n\t\t\t\t\t{ externalId: identifier, code, loginOptions },\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\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 { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tidentifierValidations,\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\tidentifier: 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\texternalId: identifier,\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\tidentifier: 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{ externalId: identifier, 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: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUpOrIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tidentifier: 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(\n\t\t\t\t\t\tapiPaths.webauthn.update.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\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<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 createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { Hooks, HTTPMethods, RequestConfig } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\n/** Descope SDK client */\nconst sdk = withSdkConfigValidations(\n\t({\n\t\tprojectId,\n\t\tlogger,\n\t\tbaseUrl,\n\t\thooks,\n\t\tcookiePolicy\n\t}: {\n\t\tprojectId: string;\n\t\tlogger?: Logger;\n\t\tbaseUrl?: string;\n\t\thooks?: Hooks;\n\t\tcookiePolicy?: RequestCredentials;\n\t}) =>\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);\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 userIdentifier = 'identifier';\n * sdk.otp.signIn.email(userIdentifier);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport { transformResponse } from './sdk/helpers';\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;\nexport type { HTTPMethods, RequestConfig };\nexport type {\n\tSdkResponse,\n\tResponseData,\n\tJWTResponse,\n\tFlowAction,\n\tFlowStatus,\n\tFlowResponse,\n\tExchangeAccessKeyResponse,\n\tUserResponse,\n\tEnchantedLinkResponse,\n\tURLResponse,\n\tTOTPResponse\n} from './sdk/types';\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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","externalId","loginOptions","user","identifier","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","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me"],"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,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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/utils/wrapWith/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/user/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 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\texternalId?: 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\texternalIds: string[];\n\tuserId: string;\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\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// 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<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 = (identifier: string, code: string) => Promise<SdkResponse<JWTResponse>>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse<never>>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse<never>>;\ntype UpdatePhoneFn = (identifier: 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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, 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(externalId: 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, externalId })\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\texternalId: 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{ externalId, 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(externalId: 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), { externalId, 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(externalId: string): Promise<SdkResponse<never>> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\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(identifier: string, email: string, token?: string): Promise<SdkResponse<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { 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(externalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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{ externalId, 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(externalId: 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\texternalId,\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(externalId: 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), { externalId, 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(\n\t\t\t\tidentifier: 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<never>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, 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\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\texternalId: 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{ externalId, 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 identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\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\texternalId: 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\texternalId,\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(externalId: 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\texternalId,\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(externalId: 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\texternalId,\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\tidentifier: 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{ externalId: identifier, 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}\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 identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(\n\t\t\tidentifier: 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(\n\t\t\t\t\tapiPaths.totp.verify,\n\t\t\t\t\t{ externalId: identifier, code, loginOptions },\n\t\t\t\t\t{ token }\n\t\t\t\t)\n\t\t\t)\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse<TOTPResponse>> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\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 { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tidentifierValidations,\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\tidentifier: 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\texternalId: identifier,\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\tidentifier: 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{ externalId: identifier, 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: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse<WebAuthnStartResponse>> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUpOrIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(\n\t\t\t\tidentifier: 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(\n\t\t\t\t\t\tapiPaths.webauthn.update.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\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<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","/* 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 { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { AfterRequest, BeforeRequest, Hooks, HTTPMethods, RequestConfig } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\n/** Validate we have non-empty project id */\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\ntype SdkConfig = {\n\tprojectId: string;\n\tlogger?: Logger;\n\tbaseUrl?: string;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials;\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 */\nlet initSdk = 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\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 userIdentifier = 'identifier';\n * sdk.otp.signIn.email(userIdentifier);\n * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);\n * ```\n */\nexport default Object.assign(initSdk, { DeliveryMethods });\n\nexport { transformResponse } from './sdk/helpers';\nexport * from './utils';\nexport type { SdkFnWrapper } from './utils';\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;\nexport type { HTTPMethods, RequestConfig };\nexport type {\n\tSdkResponse,\n\tResponseData,\n\tJWTResponse,\n\tFlowAction,\n\tFlowStatus,\n\tFlowResponse,\n\tExchangeAccessKeyResponse,\n\tUserResponse,\n\tEnchantedLinkResponse,\n\tURLResponse,\n\tTOTPResponse\n} from './sdk/types';\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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","delivery","assign","externalId","loginOptions","user","identifier","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","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withJwtValidations","wrapWith","obj","paths","wrapper","sections","split","section","shift","currentRef","origFn","rules","initSdk","validatePathValue","withSdkConfigValidations","createSdk","beforeRequestHooks","concat","afterRequestHooks","_b","req","withMultipleHooks","otp","magicLink","enchantedLink","oauth","saml","totp","webauthn","flow","refresh","logout","logoutAll","me","index"],"m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AAQyC,UAASE,QAAOC,mBACvDkK,OF9BctF,EE+BbhF,EAAiB,CAChBC,QAASA,GzBjDuB,0ByBkDhCL,YACApC,SACA2C,QACAC,iBFpCwC,CAC3C6E,UAAWF,EAAeC,GAC1B6F,IAAKlF,GAAQX,GACb8F,UAAW3E,GAAcnB,GACzB+F,cAAexE,GAAkBvB,GACjCgG,MAAOxD,GAAUxC,GACjBiG,KAAMxC,GAASzD,GACfkG,KAAMrC,GAAS7D,GACfmG,SAAUhC,GAAanE,GACvBoG,KAAMlD,GAASlD,GACfqG,QAAUxL,GACT4C,EAA+BuC,EAAW3D,KAAKtG,EAAkB,CAAA,EAAI,CAAE8E,WACxEyL,OAASzL,GACR4C,EAAyBuC,EAAW3D,KAAKtG,EAAiB,CAAA,EAAI,CAAE8E,WACjE0L,UAAY1L,GACX4C,EAAyBuC,EAAW3D,KAAKtG,EAAoB,CAAA,EAAI,CAAE8E,WACpE2L,GAAK3L,GAAmB4C,EAAgCuC,EAAW5D,IAAIrG,EAAa,CAAE8E,WACtFoC,aAAcsH,GAAmBtH,GACjCI,kBAAmBkH,GAAmBlH,GACtCC,YAAaiH,GAAmBjH,GAChC0C,cApBc,IAACA,CEsCb,KAoBH,IAAeyG,GAAAxP,OAAO4J,OAAOsE,GAAS,CAAEhF"}
|
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.36",
|
|
4
4
|
"main": "dist/cjs/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"@types/jest": "^27.0.2",
|
|
49
49
|
"@types/lodash.get": "^4.4.7",
|
|
50
50
|
"@typescript-eslint/parser": "^5.33.1",
|
|
51
|
-
"esbuild": "^0.
|
|
51
|
+
"esbuild": "^0.16.0",
|
|
52
52
|
"eslint": "8.26.0",
|
|
53
53
|
"eslint-config-airbnb-typescript": "17.0.0",
|
|
54
54
|
"eslint-config-prettier": "8.5.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.1.
|
|
58
|
+
"eslint-plugin-jest": "27.1.7",
|
|
59
59
|
"eslint-plugin-jest-dom": "4.0.3",
|
|
60
60
|
"eslint-plugin-jest-formatting": "3.1.0",
|
|
61
|
-
"eslint-plugin-n": "15.
|
|
61
|
+
"eslint-plugin-n": "15.6.0",
|
|
62
62
|
"eslint-plugin-no-only-tests": "3.1.0",
|
|
63
63
|
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
64
64
|
"eslint-plugin-prettier": "4.2.1",
|