@descope/core-js-sdk 0.0.41-alpha.15 → 0.0.41-alpha.16
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/README.md +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("jwt-decode"),t=require("lodash.get");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=s(e),a=s(t),i={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},signUpOrIn:"/v1/auth/magiclink/signup-in"},o={start:"/v1/auth/oauth/authorize"},u={start:"/v1/auth/saml/authorize"},c={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},d={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},p="/v1/auth/refresh",l="/v1/auth/logoutall",g={start:"/v1/flow/start",next:"/v1/flow/next"},h="/v1/auth/exchange";var v;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(v||(v={}));const m=()=>{const e={};return{headers(t){const s="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(s),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")}},b=(e,t)=>{const s=t||fetch;if(!s)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 n=await s(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),m().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(n)),n}:s},f=(...e)=>new Headers(e.reduce(((e,t)=>{const s=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return s.reduce(((t,[s,n])=>(e[s]=n,e)),e),e}),{})),y=e=>void 0===e?void 0:JSON.stringify(e),I=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},k=({baseUrl:e,projectId:t,baseConfig:s,logger:n,hooks:a,cookiePolicy:i})=>{const r=b(n),o=async n=>{const o=(null==a?void 0:a.beforeRequest)?a.beforeRequest(n):n,{path:u,body:c,headers:d,queryParams:p,method:l,token:g}=o,h=await r((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:u,baseUrl:e,queryParams:p}),{headers:f(I(t,g),(null==s?void 0:s.baseHeaders)||{},d),method:l,body:y(c),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(n,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:s,token:n}={})=>o({path:e,headers:t,queryParams:s,body:void 0,method:v.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.post,token:a}),put:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.put,token:a}),delete:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.delete,token:a})}},j=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=n.default(e);return(new Date).getTime()/1e3>t},O=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),U=async e=>{const t=await e,s={code:t.status,ok:t.ok,response:t},n=await t.json();return t.ok?s.data=n:s.error=n,s};var w,x,P;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(w||(w={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(P||(P={}));const R=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),$=e=>t=>e.test(t),M=$(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),E=$(/^\+[1-9]{1}[0-9]{3,14}$/),S=R(M,'"{val}" is not a valid email'),T=R(E,'"{val}" is not a valid phone number'),D=R((A=1,e=>e.length>=A),"Minimum length is 1");var A;const z=R((e=>"string"==typeof e),"Input is not a string"),L=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>q(...e).validate(s[t]))),t(...s)),H=e=>[z(`"${e}" must be a string`),D(`"${e}" must not be empty`)],J=e=>[z(`"${e}" must be a string`),S()],N=e=>[z(`"${e}" must be a string`),T()];var Z;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Z||(Z={}));const B=H("identifier"),C=L(B,H("code")),F=L(B),G=L(B,N("phone")),_=L(B,J("email")),K=e=>({verify:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,n)=>U(e.post(O(i.verify,s),{code:n,externalId:t}))))})),{}),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>U(e.post(O(i.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F(((t,n)=>U(e.post(O(i.signUp,s),{externalId:t,user:n}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>U(e.post(O(i.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:_(((t,s,n)=>U(e.post(i.update.email,{externalId:t,email:s},{token:n})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:G(((t,n,a)=>U(e.post(O(i.update.phone,s),{externalId:t,phone:n},{token:a}))))})),{})}}),Q=H("identifier"),V=H("uri"),W=L(H("token")),X=L(Q,V),Y=L(H("pendingRef")),ee=L(Q,N("phone"),V),te=L(Q,J("email"),V),se=e=>({verify:W((t=>U(e.post(r.verify,{token:t})))),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signIn,s),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signUpOrIn,s),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,a)=>U(e.post(O(r.signUp,s),{externalId:t,URI:n,user:a,crossDevice:!0}))))})),{}),waitForSession:Y(((t,s)=>new Promise((n=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(s);let o;const u=setInterval((async()=>{const s=await e.post(r.session,{pendingRef:t});s.ok&&(clearInterval(u),o&&clearTimeout(o),n(U(Promise.resolve(s))))}),a);o=setTimeout((()=>{n({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(u)}),i)})))),update:{email:te(((t,s,n,a)=>U(e.post(r.update.email,{externalId:t,email:s,URI:n,crossDevice:!0},{token:a})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:ee(((t,n,a,i)=>U(e.post(O(r.update.phone,s),{externalId:t,phone:n,URI:a,crossDevice:!0},{token:i}))))})),{})}}),ne=e=>({verify:W((t=>U(e.post(r.verify,{token:t})))),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,a)=>U(e.post(O(r.signUp,s),{externalId:t,URI:n,user:a}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:te(((t,s,n,a)=>U(e.post(r.update.email,{externalId:t,email:s,URI:n},{token:a})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:ee(((t,n,a,i)=>U(e.post(O(r.update.phone,s),{externalId:t,phone:n,URI:a},{token:i}))))})),{})},crossDevice:se(e)}),ae=L(H("code")),ie=e=>({exchange:ae((t=>U(e.get(h,{queryParams:{code:t}}))))});var re;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(re||(re={}));const oe=e=>Object.assign({start:Object.keys(re).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:async(t,{redirect:n=!1}={})=>{const a=await e.get(o.start,{queryParams:Object.assign({provider:s},t&&{redirectURL:t})});if(!n||!a.ok)return U(Promise.resolve(a));const{url:i}=await a.json();window.location.href=i}})),{})},ie(e)),ue=L(H("flowId")),ce=L(H("executionId"),H("stepId"),H("actionId")),de=e=>({start:ue((t=>U(e.post(g.start,{flowId:t})))),next:ce(((t,s,n,a)=>U(e.post(g.next,{executionId:t,stepId:s,actionId:n,input:a}))))}),pe=L(H("tenant")),le=e=>Object.assign({start:pe((async(t,s,{redirect:n=!1}={})=>{const a=await e.get(u.start,{queryParams:{tenant:t,redirectURL:s}});if(!n||!a.ok)return U(Promise.resolve(a));const{url:i}=await a.json();window.location.href=i}))},ie(e)),ge=H("identifier"),he=L(ge,H("code")),ve=L(ge),me=L(ge),be=e=>({signUp:ve(((t,s)=>U(e.post(c.signUp,{externalId:t,user:s})))),verify:he(((t,s)=>U(e.post(c.verify,{externalId:t,code:s})))),update:me(((t,s)=>U(e.post(c.update,{externalId:t},{token:s}))))}),fe=H("identifier"),ye=H("origin"),Ie=L(fe,ye,H("name")),ke=L(fe,ye),je=L(fe,ye,H("token")),Oe=L(H("transactionId"),H("response")),Ue=e=>({signUp:{start:Ie(((t,s,n)=>U(e.post(d.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:Oe(((t,s)=>U(e.post(d.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:ke(((t,s)=>U(e.post(d.signIn.start,{externalId:t,origin:s})))),finish:Oe(((t,s)=>U(e.post(d.signIn.finish,{transactionId:t,response:s}))))},update:{start:je(((t,s,n)=>U(e.post(d.update.start,{externalId:t,origin:s},{token:n})))),finish:Oe(((t,s)=>U(e.post(d.update.finish,{transactionId:t,response:s}))))}}),we=L(H("token"));var xe,Pe;const Re=L([(xe="projectId",Pe=H("projectId"),R(((e,t)=>s=>q(...t).validate(a.default(s,e)))(xe,Pe))())])((({projectId:e,logger:t,baseUrl:s,hooks:n,cookiePolicy:a})=>{return i=k({baseUrl:s||"https://api.descope.com",projectId:e,logger:t,hooks:n,cookiePolicy:a}),{otp:K(i),magicLink:ne(i),oauth:oe(i),saml:le(i),totp:be(i),webauthn:Ue(i),flow:de(i),refresh:e=>U(i.get(p,{token:e})),logout:e=>U(i.get(l,{token:e})),isJwtExpired:we(j),httpClient:i};var i}));Re.DeliveryMethods=x,module.exports=Re;
|
|
1
|
+
"use strict";var e=require("jwt-decode"),t=require("lodash.get");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=s(e),a=s(t),i={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},signUpOrIn:"/v1/auth/magiclink/signup-in"},o={start:"/v1/auth/oauth/authorize"},u={start:"/v1/auth/saml/authorize"},c={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},d={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},p="/v1/auth/refresh",l="/v1/auth/logoutall",g={start:"/v1/flow/start",next:"/v1/flow/next"},h="/v1/auth/exchange";var v;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(v||(v={}));const m=()=>{const e={};return{headers(t){const s="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(s),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")}},b=(e,t)=>{const s=t||fetch;if(!s)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 n=await s(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),m().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(n)),n}:s},f=(...e)=>new Headers(e.reduce(((e,t)=>{const s=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return s.reduce(((t,[s,n])=>(e[s]=n,e)),e),e}),{})),y=e=>void 0===e?void 0:JSON.stringify(e),I=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},k=({baseUrl:e,projectId:t,baseConfig:s,logger:n,hooks:a,cookiePolicy:i})=>{const r=b(n),o=async n=>{const o=(null==a?void 0:a.beforeRequest)?a.beforeRequest(n):n,{path:u,body:c,headers:d,queryParams:p,method:l,token:g}=o,h=await r((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:u,baseUrl:e,queryParams:p}),{headers:f(I(t,g),(null==s?void 0:s.baseHeaders)||{},d),method:l,body:y(c),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(n,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:s,token:n}={})=>o({path:e,headers:t,queryParams:s,body:void 0,method:v.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.post,token:a}),put:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.put,token:a}),delete:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:v.delete,token:a})}},j=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=n.default(e);return(new Date).getTime()/1e3>t},O=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),U=async e=>{const t=await e,s={code:t.status,ok:t.ok,response:t},n=await t.json();return t.ok?s.data=n:s.error=n,s};var w,x,P;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(w||(w={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(P||(P={}));const R=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),q=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),$=e=>t=>e.test(t),M=$(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),E=$(/^\+[1-9]{1}[0-9]{3,14}$/),S=R(M,'"{val}" is not a valid email'),T=R(E,'"{val}" is not a valid phone number'),D=R((A=1,e=>e.length>=A),"Minimum length is 1");var A;const z=R((e=>"string"==typeof e),"Input is not a string"),L=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>q(...e).validate(s[t]))),t(...s)),H=e=>[z(`"${e}" must be a string`),D(`"${e}" must not be empty`)],J=e=>[z(`"${e}" must be a string`),S()],N=e=>[z(`"${e}" must be a string`),T()];var Z;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Z||(Z={}));const B=H("identifier"),C=L(B,H("code")),F=L(B),G=L(B,N("phone")),_=L(B,J("email")),K=e=>({verify:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,n)=>U(e.post(O(i.verify,s),{code:n,externalId:t}))))})),{}),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>U(e.post(O(i.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F(((t,n)=>U(e.post(O(i.signUp,s),{externalId:t,user:n}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>U(e.post(O(i.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:_(((t,s,n)=>U(e.post(i.update.email,{externalId:t,email:s},{token:n})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:G(((t,n,a)=>U(e.post(O(i.update.phone,s),{externalId:t,phone:n},{token:a}))))})),{})}}),Q=H("identifier"),V=H("uri"),W=L(H("token")),X=L(Q,V),Y=L(H("pendingRef")),ee=L(Q,N("phone"),V),te=L(Q,J("email"),V),se=e=>({verify:W((t=>U(e.post(r.verify,{token:t})))),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signIn,s),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signUpOrIn,s),{externalId:t,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,a)=>U(e.post(O(r.signUp,s),{externalId:t,URI:n,user:a,crossDevice:!0}))))})),{}),waitForSession:Y(((t,s)=>new Promise((n=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(s);let o;const u=setInterval((async()=>{const s=await e.post(r.session,{pendingRef:t});s.ok&&(clearInterval(u),o&&clearTimeout(o),n(U(Promise.resolve(s))))}),a);o=setTimeout((()=>{n({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(u)}),i)})))),update:{email:te(((t,s,n,a)=>U(e.post(r.update.email,{externalId:t,email:s,URI:n,crossDevice:!0},{token:a})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:ee(((t,n,a,i)=>U(e.post(O(r.update.phone,s),{externalId:t,phone:n,URI:a,crossDevice:!0},{token:i}))))})),{})}}),ne=e=>({verify:W((t=>U(e.post(r.verify,{token:t})))),signIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,a)=>U(e.post(O(r.signUp,s),{externalId:t,URI:n,user:a}))))})),{}),signUpOrIn:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n)=>U(e.post(O(r.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:te(((t,s,n,a)=>U(e.post(r.update.email,{externalId:t,email:s,URI:n},{token:a})))),phone:Object.keys(w).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:ee(((t,n,a,i)=>U(e.post(O(r.update.phone,s),{externalId:t,phone:n,URI:a},{token:i}))))})),{})},crossDevice:se(e)}),ae=L(H("code")),ie=e=>({exchange:ae((t=>U(e.get(h,{queryParams:{code:t}}))))});var re;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(re||(re={}));const oe=e=>Object.assign({start:Object.keys(re).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:async(t,{redirect:n=!1}={})=>{const a=await e.get(o.start,{queryParams:Object.assign({provider:s},t&&{redirectURL:t})});if(!n||!a.ok)return U(Promise.resolve(a));const{url:i}=await a.json();window.location.href=i}})),{})},ie(e)),ue=L(H("flowId")),ce=L(H("executionId"),H("stepId"),H("actionId")),de=e=>({start:ue((t=>U(e.post(g.start,{flowId:t})))),next:ce(((t,s,n,a)=>U(e.post(g.next,{executionId:t,stepId:s,interactionId:n,input:a}))))}),pe=L(H("tenant")),le=e=>Object.assign({start:pe((async(t,s,{redirect:n=!1}={})=>{const a=await e.get(u.start,{queryParams:{tenant:t,redirectURL:s}});if(!n||!a.ok)return U(Promise.resolve(a));const{url:i}=await a.json();window.location.href=i}))},ie(e)),ge=H("identifier"),he=L(ge,H("code")),ve=L(ge),me=L(ge),be=e=>({signUp:ve(((t,s)=>U(e.post(c.signUp,{externalId:t,user:s})))),verify:he(((t,s)=>U(e.post(c.verify,{externalId:t,code:s})))),update:me(((t,s)=>U(e.post(c.update,{externalId:t},{token:s}))))}),fe=H("identifier"),ye=H("origin"),Ie=L(fe,ye,H("name")),ke=L(fe,ye),je=L(fe,ye,H("token")),Oe=L(H("transactionId"),H("response")),Ue=e=>({signUp:{start:Ie(((t,s,n)=>U(e.post(d.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:Oe(((t,s)=>U(e.post(d.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:ke(((t,s)=>U(e.post(d.signIn.start,{externalId:t,origin:s})))),finish:Oe(((t,s)=>U(e.post(d.signIn.finish,{transactionId:t,response:s}))))},update:{start:je(((t,s,n)=>U(e.post(d.update.start,{externalId:t,origin:s},{token:n})))),finish:Oe(((t,s)=>U(e.post(d.update.finish,{transactionId:t,response:s}))))}}),we=L(H("token"));var xe,Pe;const Re=L([(xe="projectId",Pe=H("projectId"),R(((e,t)=>s=>q(...t).validate(a.default(s,e)))(xe,Pe))())])((({projectId:e,logger:t,baseUrl:s,hooks:n,cookiePolicy:a})=>{return i=k({baseUrl:s||"https://api.descope.com",projectId:e,logger:t,hooks:n,cookiePolicy:a}),{otp:K(i),magicLink:ne(i),oauth:oe(i),saml:le(i),totp:be(i),webauthn:Ue(i),flow:de(i),refresh:e=>U(i.get(p,{token:e})),logout:e=>U(i.get(l,{token:e})),isJwtExpired:we(j),httpClient:i};var i}));Re.DeliveryMethods=x,module.exports=Re;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/constants/apiPaths.ts","../../src/httpClient/types.ts","../../src/httpClient/helpers/createFetchLogger.ts","../../src/httpClient/utils.ts","../../src/httpClient/index.ts","../../src/httpClient/urlBuilder.ts","../../src/sdk/helpers/index.ts","../../src/sdk/types.ts","../../src/sdk/validations/core.ts","../../src/sdk/validations/validators.ts","../../src/sdk/validations/index.ts","../../src/sdk/otp.ts","../../src/sdk/magicLink/validations.ts","../../src/sdk/magicLink/crossDevice.ts","../../src/constants/index.ts","../../src/sdk/magicLink/index.ts","../../src/sdk/exchange.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":["export default {\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\tsession: '/v1/auth/magiclink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\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\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/logoutall',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t},\n\texchange: '/v1/auth/exchange'\n};\n","import { Logger } from '../sdk/types';\n\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\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\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials\n};\n\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 Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n\tafterRequest?: (req: RequestConfig, res: Response) => void;\n}\n","import { Logger } from '../../sdk/types';\n\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\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\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await 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\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","/* 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\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\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import { urlBuilder } from './urlBuilder';\nimport { CreateHttpClientConfig, HttpClient, RequestConfig, HTTPMethods } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\nimport { mergeHeaders, serializeBody } from './utils';\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\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\t\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\t\t\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\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};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","export 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","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { SdkResponse } from '../types';\n\nconst isJwtExpired = (token: string) => {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\n\tconst { exp }: JwtPayload = jwtDecode(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\n\treturn currentTime > exp;\n};\n\nexport default isJwtExpired;\n\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\nexport const transformResponse = async (response: Promise<Response>): Promise<SdkResponse> => {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.json();\n\n\tif (resp.ok) {\n\t\tret.data = data;\n\t} else {\n\t\tret.error = data;\n\t}\n\n\treturn ret;\n};\n","type SdkFn = (...args: any[]) => Promise<SdkResponse>;\n\ninterface UserResponse extends User {\n\texternalIds: string[];\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n};\n\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\nexport interface AuthInfo {\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\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport type Deliveries<T extends SdkFn> = Record<DeliveryMethods, T>;\n\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\nexport type SdkResponse = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\tcode: string;\n\t};\n\tdata?: any;\n};\n\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\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 { pathJoin, transformResponse } from './helpers';\nimport { DeliveryMethods, Deliveries, User, SdkResponse, DeliveryPhone } 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>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse>;\ntype UpdatePhoneFn = (identifier: string, phone: string) => Promise<SdkResponse>;\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> =>\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(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signIn, 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\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> =>\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> =>\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> =>\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> =>\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 {\n\tapiPaths,\n\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport { MagicLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = MAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || MAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withMagicLinkCrossDevice = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\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(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\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\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> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\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> =>\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\tcrossDevice: true\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\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse> =>\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.magicLink.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: { message: `Session polling timeout exceeded: ${timeoutMs}ms`, code: '0' },\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(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\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, crossDevice: true },\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(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\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, crossDevice: true },\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 withMagicLinkCrossDevice;\n","export const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\nexport const MAGIC_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\nexport const MAGIC_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\nexport { default as apiPaths } from './apiPaths';\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport withMagicLinkCrossDevice from './crossDevice';\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> =>\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(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, 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\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> =>\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> =>\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(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\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(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\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\tcrossDevice: withMagicLinkCrossDevice(httpClient)\n});\n\nexport default withMagicLink;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withExchange = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.get(apiPaths.exchange, { queryParams: { code } }))\n\t)\n});\n\nexport default withExchange;\n","import { SdkResponse } 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>;\ntype VerifyFn = (code: string) => Promise<SdkResponse>;\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 withExchange from '../exchange';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\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 (redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\t\tconst resp = await httpClient.get(apiPaths.oauth.start, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) }\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok) return transformResponse(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\n\t...withExchange(httpClient)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('actionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tactionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t) => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, 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 withExchange from './exchange';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (tenantNameOrEmail: string, redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\tconst resp = await httpClient.get(apiPaths.saml.start, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl }\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\n\t...withExchange(httpClient)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse } 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> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(identifier: string, code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.verify, { externalId: identifier, code }))\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse> =>\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 { SdkResponse } 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(identifier: string, origin: string, name: string): Promise<SdkResponse> =>\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> =>\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(identifier: string, origin: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\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\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(identifier: string, origin: string, token: string): Promise<SdkResponse> =>\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> =>\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 withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport isJwtExpired, { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\n\nconst withValidateValidations = withValidations(stringNonEmpty('token'));\n\nexport default (httpClient: HttpClient) => ({\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(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) => transformResponse(httpClient.get(apiPaths.refresh, { token })),\n\tlogout: (token?: string) => transformResponse(httpClient.get(apiPaths.logout, { token })),\n\tisJwtExpired: withValidateValidations(isJwtExpired),\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 } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\nconst sdk = withSdkConfigValidations(\n\t({ projectId, logger, baseUrl, hooks, cookiePolicy }: { projectId: string; logger?: Logger; baseUrl?: string; hooks?: Hooks; cookiePolicy?: RequestCredentials }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger, hooks, cookiePolicy }))\n);\n\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\nexport type OAuthProvider = keyof typeof OAuthProviders;\nexport type { HTTPMethods };\nexport type { SdkResponse, AuthInfo } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","HTTPMethods","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","text","Promise","resolve","json","parse","statusText","buildResponseLog","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","clone","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replace","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","httpClient","delivery","assign","externalId","user","identifier","uriValidations","withWaitForSessionValidations","withMagicLinkCrossDevice","URI","crossDevice","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","uri","withMagicLink","withExchangeValidations","withExchange","exchange","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","executionId","stepId","actionId","input","withSaml","tenantNameOrEmail","tenant","withSignUpValidations","withUpdateValidations","withTotp","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"2JAAeA,EACT,CACJC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BATCP,EAWH,CACVC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRK,QAAS,qCACTJ,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,gCApBCP,EAsBP,CACNS,MAAO,4BAvBMT,EAyBR,CACLS,MAAO,2BA1BMT,EA4BR,CACLC,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA/BKJ,EAiCJ,CACTG,OAAQ,CACPM,MAAO,iCACPC,OAAQ,mCAETR,OAAQ,CACPO,MAAO,iCACPC,OAAQ,mCAETN,OAAQ,CACPK,MAAO,gCACPC,OAAQ,oCA5CIV,EA+CL,mBA/CKA,EAgDN,qBAhDMA,EAiDR,CACLS,MAAO,iBACPE,KAAM,iBAnDOX,EAqDJ,oBC7CX,IAAYY,GAAZ,SAAYA,GACXA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,IAAA,KACA,CALD,CAAYA,IAAAA,EAKX,CAAA,ICX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CAC3C6I,IAAKrE,EAAQC,GACbqE,UAAW3C,GAAc1B,GACzBsE,MAAOvC,GAAU/B,GACjBuE,KAAMxB,GAAS/C,GACfwE,KAAMpB,GAASpD,GACfyE,SAAUf,GAAa1D,GACvB0E,KAAMjC,GAASzC,GACf2E,QAAU3J,GAAmBmC,EAAkB6C,EAAWxD,IAAIpG,EAAkB,CAAE4E,WAClF4J,OAAS5J,GAAmBmC,EAAkB6C,EAAWxD,IAAIpG,EAAiB,CAAE4E,WAChF4B,aAAckH,GAAwBlH,GACtCoD,cAXc,IAACA,CCCmG,IAKnHgE,GAAkBtG,gBAAkBA"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/constants/apiPaths.ts","../../src/httpClient/types.ts","../../src/httpClient/helpers/createFetchLogger.ts","../../src/httpClient/utils.ts","../../src/httpClient/index.ts","../../src/httpClient/urlBuilder.ts","../../src/sdk/helpers/index.ts","../../src/sdk/types.ts","../../src/sdk/validations/core.ts","../../src/sdk/validations/validators.ts","../../src/sdk/validations/index.ts","../../src/sdk/otp.ts","../../src/sdk/magicLink/validations.ts","../../src/sdk/magicLink/crossDevice.ts","../../src/constants/index.ts","../../src/sdk/magicLink/index.ts","../../src/sdk/exchange.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":["export default {\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\tsession: '/v1/auth/magiclink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\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\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/logoutall',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t},\n\texchange: '/v1/auth/exchange'\n};\n","import { Logger } from '../sdk/types';\n\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\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\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n\tcookiePolicy?: RequestCredentials\n};\n\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 Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n\tafterRequest?: (req: RequestConfig, res: Response) => void;\n}\n","import { Logger } from '../../sdk/types';\n\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\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\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await 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\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","/* 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\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\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import { urlBuilder } from './urlBuilder';\nimport { CreateHttpClientConfig, HttpClient, RequestConfig, HTTPMethods } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\nimport { mergeHeaders, serializeBody } from './utils';\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\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\t\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\t\t\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\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};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","export 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","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { SdkResponse } from '../types';\n\nconst isJwtExpired = (token: string) => {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\n\tconst { exp }: JwtPayload = jwtDecode(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\n\treturn currentTime > exp;\n};\n\nexport default isJwtExpired;\n\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\nexport const transformResponse = async (response: Promise<Response>): Promise<SdkResponse> => {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.json();\n\n\tif (resp.ok) {\n\t\tret.data = data;\n\t} else {\n\t\tret.error = data;\n\t}\n\n\treturn ret;\n};\n","type SdkFn = (...args: any[]) => Promise<SdkResponse>;\n\ninterface UserResponse extends User {\n\texternalIds: string[];\n\tverifiedEmail?: boolean;\n\tverifiedPhone?: boolean;\n};\n\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\nexport interface AuthInfo {\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\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport type Deliveries<T extends SdkFn> = Record<DeliveryMethods, T>;\n\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\nexport type SdkResponse = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\tcode: string;\n\t};\n\tdata?: any;\n};\n\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;\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 { pathJoin, transformResponse } from './helpers';\nimport { DeliveryMethods, Deliveries, User, SdkResponse, DeliveryPhone } 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>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse>;\ntype UpdatePhoneFn = (identifier: string, phone: string) => Promise<SdkResponse>;\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> =>\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(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signIn, 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\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> =>\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> =>\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> =>\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> =>\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 {\n\tapiPaths,\n\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport { MagicLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = MAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || MAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withMagicLinkCrossDevice = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\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(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\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\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> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\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> =>\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\tcrossDevice: true\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\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse> =>\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.magicLink.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: { message: `Session polling timeout exceeded: ${timeoutMs}ms`, code: '0' },\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(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\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, crossDevice: true },\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(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\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, crossDevice: true },\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 withMagicLinkCrossDevice;\n","export const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\nexport const MAGIC_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\nexport const MAGIC_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\nexport { default as apiPaths } from './apiPaths';\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport withMagicLinkCrossDevice from './crossDevice';\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> =>\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(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, 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\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> =>\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> =>\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(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\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(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\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\tcrossDevice: withMagicLinkCrossDevice(httpClient)\n});\n\nexport default withMagicLink;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withExchange = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.get(apiPaths.exchange, { queryParams: { code } }))\n\t)\n});\n\nexport default withExchange;\n","import { SdkResponse } 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>;\ntype VerifyFn = (code: string) => Promise<SdkResponse>;\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 withExchange from '../exchange';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\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 (redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\t\tconst resp = await httpClient.get(apiPaths.oauth.start, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) }\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok) return transformResponse(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\n\t...withExchange(httpClient)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('actionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\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) => {\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 withExchange from './exchange';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (tenantNameOrEmail: string, redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\tconst resp = await httpClient.get(apiPaths.saml.start, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl }\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\n\t...withExchange(httpClient)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse } 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> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(identifier: string, code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.verify, { externalId: identifier, code }))\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse> =>\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 { SdkResponse } 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(identifier: string, origin: string, name: string): Promise<SdkResponse> =>\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> =>\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(identifier: string, origin: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\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\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(identifier: string, origin: string, token: string): Promise<SdkResponse> =>\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> =>\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 withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport isJwtExpired, { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\n\nconst withValidateValidations = withValidations(stringNonEmpty('token'));\n\nexport default (httpClient: HttpClient) => ({\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(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) => transformResponse(httpClient.get(apiPaths.refresh, { token })),\n\tlogout: (token?: string) => transformResponse(httpClient.get(apiPaths.logout, { token })),\n\tisJwtExpired: withValidateValidations(isJwtExpired),\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 } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\nconst sdk = withSdkConfigValidations(\n\t({ projectId, logger, baseUrl, hooks, cookiePolicy }: { projectId: string; logger?: Logger; baseUrl?: string; hooks?: Hooks; cookiePolicy?: RequestCredentials }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger, hooks, cookiePolicy }))\n);\n\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\nexport type OAuthProvider = keyof typeof OAuthProviders;\nexport type { HTTPMethods };\nexport type { SdkResponse, AuthInfo } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","HTTPMethods","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","text","Promise","resolve","json","parse","statusText","buildResponseLog","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","clone","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replace","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","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","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","httpClient","delivery","assign","externalId","user","identifier","uriValidations","withWaitForSessionValidations","withMagicLinkCrossDevice","URI","crossDevice","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","uri","withMagicLink","withExchangeValidations","withExchange","exchange","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","executionId","stepId","interactionId","input","withSaml","tenantNameOrEmail","tenant","withSignUpValidations","withUpdateValidations","withTotp","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"2JAAeA,EACT,CACJC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,0BATCP,EAWH,CACVC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRK,QAAS,qCACTJ,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,gCApBCP,EAsBP,CACNS,MAAO,4BAvBMT,EAyBR,CACLS,MAAO,2BA1BMT,EA4BR,CACLC,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA/BKJ,EAiCJ,C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eR3C,MAKMC,GAT2B/E,EAAgB,EfYpBpD,GeXf,YfW6BkI,GeXhBzE,EAAe,afYzC1B,EATyB,EAAC/B,EAAckI,IAAwBhG,GAChEC,KAAoB+F,GAAO7F,SAAS1B,EAAAA,QAAIuB,EAAKlC,IAQ7BoI,CAAkBpI,GAAMkI,IAAxCnG,KeTWsG,EACX,EAAGnJ,YAAWlC,SAAQuC,UAASE,QAAOC,mBACrC4I,ODDcnE,ECCJ7E,EAAiB,CAAEC,QAASA,GVfJ,0BUeqCL,YAAWlC,SAAQyC,QAAOC,iBDDvD,CAC3C6I,IAAKrE,EAAQC,GACbqE,UAAW3C,GAAc1B,GACzBsE,MAAOvC,GAAU/B,GACjBuE,KAAMxB,GAAS/C,GACfwE,KAAMpB,GAASpD,GACfyE,SAAUf,GAAa1D,GACvB0E,KAAMjC,GAASzC,GACf2E,QAAU3J,GAAmBmC,EAAkB6C,EAAWxD,IAAIpG,EAAkB,CAAE4E,WAClF4J,OAAS5J,GAAmBmC,EAAkB6C,EAAWxD,IAAIpG,EAAiB,CAAE4E,WAChF4B,aAAckH,GAAwBlH,GACtCoD,cAXc,IAACA,CCCmG,IAKnHgE,GAAkBtG,gBAAkBA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ declare const sdkWithAttributes: ((args_0: {
|
|
|
190
190
|
};
|
|
191
191
|
flow: {
|
|
192
192
|
start: (flowId: string) => Promise<SdkResponse>;
|
|
193
|
-
next: (executionId: string, stepId: string,
|
|
193
|
+
next: (executionId: string, stepId: string, interactionId: string, input?: Record<string, FormDataEntryValue>) => Promise<SdkResponse>;
|
|
194
194
|
};
|
|
195
195
|
refresh: (token?: string) => Promise<SdkResponse>;
|
|
196
196
|
logout: (token?: string) => Promise<SdkResponse>;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"jwt-decode";import t from"lodash.get";var 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"},n={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},signUpOrIn:"/v1/auth/magiclink/signup-in"},a={start:"/v1/auth/oauth/authorize"},i={start:"/v1/auth/saml/authorize"},r={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},o={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"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},u="/v1/auth/refresh",p="/v1/auth/logoutall",c={start:"/v1/flow/start",next:"/v1/flow/next"},d="/v1/auth/exchange";var l;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(l||(l={}));const g=()=>{const e={};return{headers(t){const s="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(s),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")}},h=(e,t)=>{const s=t||fetch;if(!s)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>g().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const n=await s(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),g().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(n)),n}:s},m=(...e)=>new Headers(e.reduce(((e,t)=>{const s=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return s.reduce(((t,[s,n])=>(e[s]=n,e)),e),e}),{})),v=e=>void 0===e?void 0:JSON.stringify(e),b=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},f=({baseUrl:e,projectId:t,baseConfig:s,logger:n,hooks:a,cookiePolicy:i})=>{const r=h(n),o=async n=>{const o=(null==a?void 0:a.beforeRequest)?a.beforeRequest(n):n,{path:u,body:p,headers:c,queryParams:d,method:l,token:g}=o,h=await r((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:u,baseUrl:e,queryParams:d}),{headers:m(b(t,g),(null==s?void 0:s.baseHeaders)||{},c),method:l,body:v(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(n,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:s,token:n}={})=>o({path:e,headers:t,queryParams:s,body:void 0,method:l.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.post,token:a}),put:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.put,token:a}),delete:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.delete,token:a})}},I=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:s}=e(t);return(new Date).getTime()/1e3>s},y=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),k=async e=>{const t=await e,s={code:t.status,ok:t.ok,response:t},n=await t.json();return t.ok?s.data=n:s.error=n,s};var j,O,U;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(j||(j={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(O||(O={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(U||(U={}));const w=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),x=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),P=e=>t=>e.test(t),R=P(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),q=P(/^\+[1-9]{1}[0-9]{3,14}$/),$=w(R,'"{val}" is not a valid email'),M=w(q,'"{val}" is not a valid phone number'),E=w((S=1,e=>e.length>=S),"Minimum length is 1");var S;const T=w((e=>"string"==typeof e),"Input is not a string"),D=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>x(...e).validate(s[t]))),t(...s)),A=e=>[T(`"${e}" must be a string`),E(`"${e}" must not be empty`)],z=e=>[T(`"${e}" must be a string`),$()],L=e=>[T(`"${e}" must be a string`),M()];var H;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(H||(H={}));const J=A("identifier"),N=D(J,A("code")),Z=D(J),B=D(J,L("phone")),C=D(J,z("email")),F=e=>({verify:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:N(((t,a)=>k(e.post(y(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z((t=>k(e.post(y(s.signIn,n),{externalId:t}))))})),{}),signUp:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z(((t,a)=>k(e.post(y(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z((t=>k(e.post(y(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:C(((t,n,a)=>k(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(j).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:B(((t,a,i)=>k(e.post(y(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),G=A("identifier"),_=A("uri"),K=D(A("token")),Q=D(G,_),V=D(A("pendingRef")),W=D(G,L("phone"),_),X=D(G,z("email"),_),Y=e=>({verify:K((t=>k(e.post(n.verify,{token:t})))),signIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signIn,s),{externalId:t,URI:a,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signUpOrIn,s),{externalId:t,URI:a,crossDevice:!0}))))})),{}),signUp:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a,i)=>k(e.post(y(n.signUp,s),{externalId:t,URI:a,user:i,crossDevice:!0}))))})),{}),waitForSession:V(((t,s)=>new Promise((a=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(s);let o;const u=setInterval((async()=>{const s=await e.post(n.session,{pendingRef:t});s.ok&&(clearInterval(u),o&&clearTimeout(o),a(k(Promise.resolve(s))))}),i);o=setTimeout((()=>{a({error:{message:`Session polling timeout exceeded: ${r}ms`,code:"0"},ok:!1}),clearInterval(u)}),r)})))),update:{email:X(((t,s,a,i)=>k(e.post(n.update.email,{externalId:t,email:s,URI:a,crossDevice:!0},{token:i})))),phone:Object.keys(j).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:W(((t,a,i,r)=>k(e.post(y(n.update.phone,s),{externalId:t,phone:a,URI:i,crossDevice:!0},{token:r}))))})),{})}}),ee=e=>({verify:K((t=>k(e.post(n.verify,{token:t})))),signIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signIn,s),{externalId:t,URI:a}))))})),{}),signUp:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a,i)=>k(e.post(y(n.signUp,s),{externalId:t,URI:a,user:i}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signUpOrIn,s),{externalId:t,URI:a}))))})),{}),update:{email:X(((t,s,a,i)=>k(e.post(n.update.email,{externalId:t,email:s,URI:a},{token:i})))),phone:Object.keys(j).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:W(((t,a,i,r)=>k(e.post(y(n.update.phone,s),{externalId:t,phone:a,URI:i},{token:r}))))})),{})},crossDevice:Y(e)}),te=D(A("code")),se=e=>({exchange:te((t=>k(e.get(d,{queryParams:{code:t}}))))});var ne;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ne||(ne={}));const ae=e=>Object.assign({start:Object.keys(ne).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:async(t,{redirect:n=!1}={})=>{const i=await e.get(a.start,{queryParams:Object.assign({provider:s},t&&{redirectURL:t})});if(!n||!i.ok)return k(Promise.resolve(i));const{url:r}=await i.json();window.location.href=r}})),{})},se(e)),ie=D(A("flowId")),re=D(A("executionId"),A("stepId"),A("actionId")),oe=e=>({start:ie((t=>k(e.post(c.start,{flowId:t})))),next:re(((t,s,n,a)=>k(e.post(c.next,{executionId:t,stepId:s,actionId:n,input:a}))))}),ue=D(A("tenant")),pe=e=>Object.assign({start:ue((async(t,s,{redirect:n=!1}={})=>{const a=await e.get(i.start,{queryParams:{tenant:t,redirectURL:s}});if(!n||!a.ok)return k(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r}))},se(e)),ce=A("identifier"),de=D(ce,A("code")),le=D(ce),ge=D(ce),he=e=>({signUp:le(((t,s)=>k(e.post(r.signUp,{externalId:t,user:s})))),verify:de(((t,s)=>k(e.post(r.verify,{externalId:t,code:s})))),update:ge(((t,s)=>k(e.post(r.update,{externalId:t},{token:s}))))}),me=A("identifier"),ve=A("origin"),be=D(me,ve,A("name")),fe=D(me,ve),Ie=D(me,ve,A("token")),ye=D(A("transactionId"),A("response")),ke=e=>({signUp:{start:be(((t,s,n)=>k(e.post(o.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:ye(((t,s)=>k(e.post(o.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:fe(((t,s)=>k(e.post(o.signIn.start,{externalId:t,origin:s})))),finish:ye(((t,s)=>k(e.post(o.signIn.finish,{transactionId:t,response:s}))))},update:{start:Ie(((t,s,n)=>k(e.post(o.update.start,{externalId:t,origin:s},{token:n})))),finish:ye(((t,s)=>k(e.post(o.update.finish,{transactionId:t,response:s}))))}}),je=D(A("token"));var Oe,Ue;const we=D([(Oe="projectId",Ue=A("projectId"),w(((e,s)=>n=>x(...s).validate(t(n,e)))(Oe,Ue))())])((({projectId:e,logger:t,baseUrl:s,hooks:n,cookiePolicy:a})=>{return i=f({baseUrl:s||"https://api.descope.com",projectId:e,logger:t,hooks:n,cookiePolicy:a}),{otp:F(i),magicLink:ee(i),oauth:ae(i),saml:pe(i),totp:he(i),webauthn:ke(i),flow:oe(i),refresh:e=>k(i.get(u,{token:e})),logout:e=>k(i.get(p,{token:e})),isJwtExpired:je(I),httpClient:i};var i}));we.DeliveryMethods=O;export{we as default};
|
|
1
|
+
import e from"jwt-decode";import t from"lodash.get";var 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"},n={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},signUpOrIn:"/v1/auth/magiclink/signup-in"},a={start:"/v1/auth/oauth/authorize"},i={start:"/v1/auth/saml/authorize"},r={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},o={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"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},u="/v1/auth/refresh",p="/v1/auth/logoutall",c={start:"/v1/flow/start",next:"/v1/flow/next"},d="/v1/auth/exchange";var l;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(l||(l={}));const g=()=>{const e={};return{headers(t){const s="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(s),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")}},h=(e,t)=>{const s=t||fetch;if(!s)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>g().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const n=await s(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),g().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(n)),n}:s},m=(...e)=>new Headers(e.reduce(((e,t)=>{const s=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return s.reduce(((t,[s,n])=>(e[s]=n,e)),e),e}),{})),v=e=>void 0===e?void 0:JSON.stringify(e),b=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},f=({baseUrl:e,projectId:t,baseConfig:s,logger:n,hooks:a,cookiePolicy:i})=>{const r=h(n),o=async n=>{const o=(null==a?void 0:a.beforeRequest)?a.beforeRequest(n):n,{path:u,body:p,headers:c,queryParams:d,method:l,token:g}=o,h=await r((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:u,baseUrl:e,queryParams:d}),{headers:m(b(t,g),(null==s?void 0:s.baseHeaders)||{},c),method:l,body:v(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(n,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:s,token:n}={})=>o({path:e,headers:t,queryParams:s,body:void 0,method:l.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.post,token:a}),put:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.put,token:a}),delete:(e,t,{headers:s,queryParams:n,token:a}={})=>o({path:e,headers:s,queryParams:n,body:t,method:l.delete,token:a})}},I=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:s}=e(t);return(new Date).getTime()/1e3>s},y=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),k=async e=>{const t=await e,s={code:t.status,ok:t.ok,response:t},n=await t.json();return t.ok?s.data=n:s.error=n,s};var j,O,U;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(j||(j={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(O||(O={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(U||(U={}));const w=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),x=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),P=e=>t=>e.test(t),R=P(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),q=P(/^\+[1-9]{1}[0-9]{3,14}$/),$=w(R,'"{val}" is not a valid email'),M=w(q,'"{val}" is not a valid phone number'),E=w((S=1,e=>e.length>=S),"Minimum length is 1");var S;const T=w((e=>"string"==typeof e),"Input is not a string"),D=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>x(...e).validate(s[t]))),t(...s)),A=e=>[T(`"${e}" must be a string`),E(`"${e}" must not be empty`)],z=e=>[T(`"${e}" must be a string`),$()],L=e=>[T(`"${e}" must be a string`),M()];var H;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(H||(H={}));const J=A("identifier"),N=D(J,A("code")),Z=D(J),B=D(J,L("phone")),C=D(J,z("email")),F=e=>({verify:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:N(((t,a)=>k(e.post(y(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z((t=>k(e.post(y(s.signIn,n),{externalId:t}))))})),{}),signUp:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z(((t,a)=>k(e.post(y(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Z((t=>k(e.post(y(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:C(((t,n,a)=>k(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(j).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:B(((t,a,i)=>k(e.post(y(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),G=A("identifier"),_=A("uri"),K=D(A("token")),Q=D(G,_),V=D(A("pendingRef")),W=D(G,L("phone"),_),X=D(G,z("email"),_),Y=e=>({verify:K((t=>k(e.post(n.verify,{token:t})))),signIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signIn,s),{externalId:t,URI:a,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signUpOrIn,s),{externalId:t,URI:a,crossDevice:!0}))))})),{}),signUp:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a,i)=>k(e.post(y(n.signUp,s),{externalId:t,URI:a,user:i,crossDevice:!0}))))})),{}),waitForSession:V(((t,s)=>new Promise((a=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(s);let o;const u=setInterval((async()=>{const s=await e.post(n.session,{pendingRef:t});s.ok&&(clearInterval(u),o&&clearTimeout(o),a(k(Promise.resolve(s))))}),i);o=setTimeout((()=>{a({error:{message:`Session polling timeout exceeded: ${r}ms`,code:"0"},ok:!1}),clearInterval(u)}),r)})))),update:{email:X(((t,s,a,i)=>k(e.post(n.update.email,{externalId:t,email:s,URI:a,crossDevice:!0},{token:i})))),phone:Object.keys(j).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:W(((t,a,i,r)=>k(e.post(y(n.update.phone,s),{externalId:t,phone:a,URI:i,crossDevice:!0},{token:r}))))})),{})}}),ee=e=>({verify:K((t=>k(e.post(n.verify,{token:t})))),signIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signIn,s),{externalId:t,URI:a}))))})),{}),signUp:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a,i)=>k(e.post(y(n.signUp,s),{externalId:t,URI:a,user:i}))))})),{}),signUpOrIn:Object.keys(O).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Q(((t,a)=>k(e.post(y(n.signUpOrIn,s),{externalId:t,URI:a}))))})),{}),update:{email:X(((t,s,a,i)=>k(e.post(n.update.email,{externalId:t,email:s,URI:a},{token:i})))),phone:Object.keys(j).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:W(((t,a,i,r)=>k(e.post(y(n.update.phone,s),{externalId:t,phone:a,URI:i},{token:r}))))})),{})},crossDevice:Y(e)}),te=D(A("code")),se=e=>({exchange:te((t=>k(e.get(d,{queryParams:{code:t}}))))});var ne;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ne||(ne={}));const ae=e=>Object.assign({start:Object.keys(ne).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:async(t,{redirect:n=!1}={})=>{const i=await e.get(a.start,{queryParams:Object.assign({provider:s},t&&{redirectURL:t})});if(!n||!i.ok)return k(Promise.resolve(i));const{url:r}=await i.json();window.location.href=r}})),{})},se(e)),ie=D(A("flowId")),re=D(A("executionId"),A("stepId"),A("actionId")),oe=e=>({start:ie((t=>k(e.post(c.start,{flowId:t})))),next:re(((t,s,n,a)=>k(e.post(c.next,{executionId:t,stepId:s,interactionId:n,input:a}))))}),ue=D(A("tenant")),pe=e=>Object.assign({start:ue((async(t,s,{redirect:n=!1}={})=>{const a=await e.get(i.start,{queryParams:{tenant:t,redirectURL:s}});if(!n||!a.ok)return k(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r}))},se(e)),ce=A("identifier"),de=D(ce,A("code")),le=D(ce),ge=D(ce),he=e=>({signUp:le(((t,s)=>k(e.post(r.signUp,{externalId:t,user:s})))),verify:de(((t,s)=>k(e.post(r.verify,{externalId:t,code:s})))),update:ge(((t,s)=>k(e.post(r.update,{externalId:t},{token:s}))))}),me=A("identifier"),ve=A("origin"),be=D(me,ve,A("name")),fe=D(me,ve),Ie=D(me,ve,A("token")),ye=D(A("transactionId"),A("response")),ke=e=>({signUp:{start:be(((t,s,n)=>k(e.post(o.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:ye(((t,s)=>k(e.post(o.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:fe(((t,s)=>k(e.post(o.signIn.start,{externalId:t,origin:s})))),finish:ye(((t,s)=>k(e.post(o.signIn.finish,{transactionId:t,response:s}))))},update:{start:Ie(((t,s,n)=>k(e.post(o.update.start,{externalId:t,origin:s},{token:n})))),finish:ye(((t,s)=>k(e.post(o.update.finish,{transactionId:t,response:s}))))}}),je=D(A("token"));var Oe,Ue;const we=D([(Oe="projectId",Ue=A("projectId"),w(((e,s)=>n=>x(...s).validate(t(n,e)))(Oe,Ue))())])((({projectId:e,logger:t,baseUrl:s,hooks:n,cookiePolicy:a})=>{return i=f({baseUrl:s||"https://api.descope.com",projectId:e,logger:t,hooks:n,cookiePolicy:a}),{otp:F(i),magicLink:ee(i),oauth:ae(i),saml:pe(i),totp:he(i),webauthn:ke(i),flow:oe(i),refresh:e=>k(i.get(u,{token:e})),logout:e=>k(i.get(p,{token:e})),isJwtExpired:je(I),httpClient:i};var i}));we.DeliveryMethods=O;export{we as default};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|