@descope/core-js-sdk 0.0.41-alpha.7 → 0.0.41-alpha.8

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.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("tslib"),t=require("jwt-decode"),s=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=n(t),r=n(s),a={verify:"/v1/auth/code/verify",signIn:"/v1/auth/signin/otp",signUp:"/v1/auth/signup/otp",update:{email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},signUpOrIn:"/v1/auth/sign-up-or-in/otp"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/signin/magiclink",signUp:"/v1/auth/signup/magiclink",session:"/v1/auth/magiclink/session",update:{email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},signUpOrIn:"/v1/auth/sign-up-or-in/magiclink"},d={start:"/v1/oauth/authorize"},u={start:"/v1/auth/saml/authorize"},c={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},p={signUp:{start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},signIn:{start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},add:{start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"}},l="/v1/auth/refresh",g="/v1/auth/logoutall",h={start:"/v1/flow/start",next:"/v1/flow/next"},v="/v1/auth/exchange";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")}},f=(t,s)=>{const n=s||fetch;if(!n)throw new Error("fetch is not defined");return t?(...s)=>e.__awaiter(void 0,void 0,void 0,(function*(){t.log((e=>m().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(s));const i=yield n(...s);return t[i.ok?"log":"error"](yield(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),m().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})))(i)),i})):n},b=(...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}),{})),I=e=>void 0===e?void 0:JSON.stringify(e);var y;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(y||(y={}));const j=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},O=({baseUrl:e,projectId:t,baseConfig:s,logger:n})=>{const i=f(n),r=({path:n,body:r,headers:a,queryParams:o,method:d,token:u})=>i((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:n,baseUrl:e,queryParams:o}),{headers:b(j(t,u),(null==s?void 0:s.baseHeaders)||{},a),method:d,body:I(r)});return{get:(e,{headers:t,queryParams:s,token:n}={})=>r({path:e,headers:t,queryParams:s,body:void 0,method:y.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:y.post,token:i}),put:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:y.put,token:i}),delete:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:y.delete,token:i})}},k=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=i.default(e);return(new Date).getTime()/1e3>t},U=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),w=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t,s={code:e.status,ok:e.ok,response:e},n=yield e.json();return e.ok?s.data=n:s.error=n,s}));var x,P,q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(P||(P={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(q||(q={}));const R=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),$=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),_=e=>t=>e.test(t),E=_(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),M=_(/^\+[1-9]{1}[0-9]{3,14}$/),S=R(E,'"{val}" is not a valid email'),T=R(M,'"{val}" is not a valid phone number'),A=R((D=1,e=>e.length>=D),"Minimum length is 1");var D;const z=R((e=>"string"==typeof e),"Input is not a string"),L=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>$(...e).validate(s[t]))),t(...s)),H=e=>[z(`"${e}" must be a string`),A(`"${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")),K=L(B,J("email")),Q=e=>({verify:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,n)=>w(e.post(U(a.verify,s),{code:n,externalId:t}))))})),{}),signIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>w(e.post(U(a.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F(((t,n)=>w(e.post(U(a.signUp,s),{externalId:t,user:n}))))})),{}),signUpOrIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>w(e.post(U(a.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:K(((t,s,n)=>w(e.post(a.update.email,{externalId:t,email:s},{token:n})))),phone:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:G(((t,n,i)=>w(e.post(U(a.update.phone,s),{externalId:t,phone:n},{token:i}))))})),{})}}),V=H("identifier"),W=H("uri"),X=L(H("token")),Y=L(V,W),ee=L(H("pendingRef")),te=L(V,N("phone"),W),se=L(V,J("email"),W),ne=t=>({verify:X((e=>w(t.post(o.verify,{token:e})))),signIn:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n)=>w(t.post(U(o.signIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n)=>w(t.post(U(o.signUpOrIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n,i)=>w(t.post(U(o.signUp,s),{externalId:e,URI:n,user:i,crossDevice:!0}))))})),{}),waitForSession:ee(((s,n)=>new Promise((i=>{const{pollingIntervalMs:r,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let d;const u=setInterval((()=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(o.session,{pendingRef:s});e.ok&&(clearInterval(u),d&&clearTimeout(d),i(w(Promise.resolve(e))))}))),r);d=setTimeout((()=>{i({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:se(((e,s,n,i)=>w(t.post(o.update.email,{externalId:e,email:s,URI:n,crossDevice:!0},{token:i})))),phone:Object.keys(x).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:te(((e,n,i,r)=>w(t.post(U(o.update.phone,s),{externalId:e,phone:n,URI:i,crossDevice:!0},{token:r}))))})),{})}}),ie=e=>({verify:X((t=>w(e.post(o.verify,{token:t})))),signIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n)=>w(e.post(U(o.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n,i)=>w(e.post(U(o.signUp,s),{externalId:t,URI:n,user:i}))))})),{}),signUpOrIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n)=>w(e.post(U(o.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:se(((t,s,n,i)=>w(e.post(o.update.email,{externalId:t,email:s,URI:n},{token:i})))),phone:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:te(((t,n,i,r)=>w(e.post(U(o.update.phone,s),{externalId:t,phone:n,URI:i},{token:r}))))})),{})},crossDevice:ne(e)}),re=L(H("code")),ae=e=>({exchange:re((t=>w(e.get(v,{queryParams:{code:t}}))))});var oe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(oe||(oe={}));const de=t=>Object.assign({start:Object.keys(oe).reduce(((s,n)=>Object.assign(Object.assign({},s),{[n]:(s,{redirect:i=!1}={})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.get(d.start,{queryParams:{provider:n,redirectURL:s}});if(!i||!e.ok)return w(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))})),{})},ae(t)),ue=L(H("flowId")),ce=L(H("executionId"),H("stepId"),H("actionId")),pe=e=>({start:ue((t=>w(e.post(h.start,{flowId:t})))),next:ce(((t,s,n,i)=>w(e.post(h.next,{executionId:t,stepId:s,actionId:n,input:i}))))}),le=L(H("tenant")),ge=t=>Object.assign({start:le(((s,n,{redirect:i=!1}={})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.get(u.start,{queryParams:{tenant:s,redirectURL:n}});if(!i||!e.ok)return w(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))))},ae(t)),he=H("identifier"),ve=L(he,H("code")),me=L(he),fe=L(he),be=e=>({signUp:me(((t,s)=>w(e.post(c.signUp,{externalId:t,user:s})))),verify:ve(((t,s)=>w(e.post(c.verify,{externalId:t,code:s})))),update:fe(((t,s)=>w(e.post(c.update,{externalId:t},{token:s}))))}),Ie=H("identifier"),ye=H("origin"),je=L(Ie,ye,H("name")),Oe=L(Ie,ye),ke=L(Ie,ye,H("token")),Ue=L(H("transactionId"),H("response")),we=e=>({signUp:{start:je(((t,s,n)=>w(e.post(p.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:Ue(((t,s)=>w(e.post(p.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:Oe(((t,s)=>w(e.post(p.signIn.start,{externalId:t,origin:s})))),finish:Ue(((t,s)=>w(e.post(p.signIn.finish,{transactionId:t,response:s}))))},add:{start:ke(((t,s,n)=>w(e.post(p.add.start,{externalId:t,origin:s},{token:n})))),finish:Ue(((t,s)=>w(e.post(p.add.finish,{transactionId:t,response:s}))))}}),xe=L(H("token"));var Pe,qe,Re=L([(Pe="projectId",qe=H("projectId"),R(((e,t)=>s=>$(...t).validate(r.default(s,e)))(Pe,qe))())])((({projectId:e,logger:t,baseUrl:s})=>{return n=O({baseUrl:s||"https://api.descope.com",projectId:e,logger:t}),{otp:Q(n),magicLink:ie(n),oauth:de(n),saml:ge(n),totp:be(n),webauthn:we(n),flow:pe(n),refresh:e=>w(n.get(l,{token:e})),logout:e=>w(n.get(g,{token:e})),isJwtExpired:xe(k),httpClient:n};var n}));module.exports=Re;
1
+ "use strict";var e=require("tslib"),t=require("jwt-decode"),s=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=n(t),r=n(s),a={verify:"/v1/auth/code/verify",signIn:"/v1/auth/signin/otp",signUp:"/v1/auth/signup/otp",update:{email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},signUpOrIn:"/v1/auth/sign-up-or-in/otp"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/signin/magiclink",signUp:"/v1/auth/signup/magiclink",session:"/v1/auth/magiclink/session",update:{email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},signUpOrIn:"/v1/auth/sign-up-or-in/magiclink"},d={start:"/v1/oauth/authorize"},u={start:"/v1/auth/saml/authorize"},c={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},p={signUp:{start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},signIn:{start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},add:{start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"}},l="/v1/auth/refresh",g="/v1/auth/logoutall",h={start:"/v1/flow/start",next:"/v1/flow/next"},v="/v1/auth/exchange";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=(t,s)=>{const n=s||fetch;if(!n)throw new Error("fetch is not defined");return t?(...s)=>e.__awaiter(void 0,void 0,void 0,(function*(){t.log((e=>m().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(s));const i=yield n(...s);return t[i.ok?"log":"error"](yield(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),m().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})))(i)),i})):n},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);var I;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(I||(I={}));const j=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},O=({baseUrl:e,projectId:t,baseConfig:s,logger:n})=>{const i=b(n),r=({path:n,body:r,headers:a,queryParams:o,method:d,token:u})=>i((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:n,baseUrl:e,queryParams:o}),{headers:f(j(t,u),(null==s?void 0:s.baseHeaders)||{},a),method:d,body:y(r)});return{get:(e,{headers:t,queryParams:s,token:n}={})=>r({path:e,headers:t,queryParams:s,body:void 0,method:I.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:I.post,token:i}),put:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:I.put,token:i}),delete:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:I.delete,token:i})}},k=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=i.default(e);return(new Date).getTime()/1e3>t},U=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),w=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t,s={code:e.status,ok:e.ok,response:e},n=yield e.json();return e.ok?s.data=n:s.error=n,s}));var x,P,q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(P||(P={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(q||(q={}));const R=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),$=(...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)=>$(...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")),K=L(B,J("email")),Q=e=>({verify:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,n)=>w(e.post(U(a.verify,s),{code:n,externalId:t}))))})),{}),signIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>w(e.post(U(a.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F(((t,n)=>w(e.post(U(a.signUp,s),{externalId:t,user:n}))))})),{}),signUpOrIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:F((t=>w(e.post(U(a.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:K(((t,s,n)=>w(e.post(a.update.email,{externalId:t,email:s},{token:n})))),phone:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:G(((t,n,i)=>w(e.post(U(a.update.phone,s),{externalId:t,phone:n},{token:i}))))})),{})}}),V=H("identifier"),W=H("uri"),X=L(H("token")),Y=L(V,W),ee=L(H("pendingRef")),te=L(V,N("phone"),W),se=L(V,J("email"),W),ne=t=>({verify:X((e=>w(t.post(o.verify,{token:e})))),signIn:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n)=>w(t.post(U(o.signIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n)=>w(t.post(U(o.signUpOrIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(P).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:Y(((e,n,i)=>w(t.post(U(o.signUp,s),{externalId:e,URI:n,user:i,crossDevice:!0}))))})),{}),waitForSession:ee(((s,n)=>new Promise((i=>{const{pollingIntervalMs:r,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let d;const u=setInterval((()=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(o.session,{pendingRef:s});e.ok&&(clearInterval(u),d&&clearTimeout(d),i(w(Promise.resolve(e))))}))),r);d=setTimeout((()=>{i({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:se(((e,s,n,i)=>w(t.post(o.update.email,{externalId:e,email:s,URI:n,crossDevice:!0},{token:i})))),phone:Object.keys(x).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:te(((e,n,i,r)=>w(t.post(U(o.update.phone,s),{externalId:e,phone:n,URI:i,crossDevice:!0},{token:r}))))})),{})}}),ie=e=>({verify:X((t=>w(e.post(o.verify,{token:t})))),signIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n)=>w(e.post(U(o.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n,i)=>w(e.post(U(o.signUp,s),{externalId:t,URI:n,user:i}))))})),{}),signUpOrIn:Object.keys(P).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Y(((t,n)=>w(e.post(U(o.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:se(((t,s,n,i)=>w(e.post(o.update.email,{externalId:t,email:s,URI:n},{token:i})))),phone:Object.keys(x).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:te(((t,n,i,r)=>w(e.post(U(o.update.phone,s),{externalId:t,phone:n,URI:i},{token:r}))))})),{})},crossDevice:ne(e)}),re=L(H("code")),ae=e=>({exchange:re((t=>w(e.get(v,{queryParams:{code:t}}))))});var oe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(oe||(oe={}));const de=t=>Object.assign({start:Object.keys(oe).reduce(((s,n)=>Object.assign(Object.assign({},s),{[n]:(s,{redirect:i=!1}={})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.get(d.start,{queryParams:Object.assign({provider:n},s&&{redirectURL:s})});if(!i||!e.ok)return w(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))})),{})},ae(t)),ue=L(H("flowId")),ce=L(H("executionId"),H("stepId"),H("actionId")),pe=e=>({start:ue((t=>w(e.post(h.start,{flowId:t})))),next:ce(((t,s,n,i)=>w(e.post(h.next,{executionId:t,stepId:s,actionId:n,input:i}))))}),le=L(H("tenant")),ge=t=>Object.assign({start:le(((s,n,{redirect:i=!1}={})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.get(u.start,{queryParams:{tenant:s,redirectURL:n}});if(!i||!e.ok)return w(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))))},ae(t)),he=H("identifier"),ve=L(he,H("code")),me=L(he),be=L(he),fe=e=>({signUp:me(((t,s)=>w(e.post(c.signUp,{externalId:t,user:s})))),verify:ve(((t,s)=>w(e.post(c.verify,{externalId:t,code:s})))),update:be(((t,s)=>w(e.post(c.update,{externalId:t},{token:s}))))}),ye=H("identifier"),Ie=H("origin"),je=L(ye,Ie,H("name")),Oe=L(ye,Ie),ke=L(ye,Ie,H("token")),Ue=L(H("transactionId"),H("response")),we=e=>({signUp:{start:je(((t,s,n)=>w(e.post(p.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:Ue(((t,s)=>w(e.post(p.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:Oe(((t,s)=>w(e.post(p.signIn.start,{externalId:t,origin:s})))),finish:Ue(((t,s)=>w(e.post(p.signIn.finish,{transactionId:t,response:s}))))},add:{start:ke(((t,s,n)=>w(e.post(p.add.start,{externalId:t,origin:s},{token:n})))),finish:Ue(((t,s)=>w(e.post(p.add.finish,{transactionId:t,response:s}))))}}),xe=L(H("token"));var Pe,qe;const Re=L([(Pe="projectId",qe=H("projectId"),R(((e,t)=>s=>$(...t).validate(r.default(s,e)))(Pe,qe))())])((({projectId:e,logger:t,baseUrl:s})=>{return n=O({baseUrl:s||"https://api.descope.com",projectId:e,logger:t}),{otp:Q(n),magicLink:ie(n),oauth:de(n),saml:ge(n),totp:fe(n),webauthn:we(n),flow:pe(n),refresh:e=>w(n.get(l,{token:e})),logout:e=>w(n.get(g,{token:e})),isJwtExpired:xe(k),httpClient:n};var n}));Re.DeliveryMethods=P,module.exports=Re;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/constants/apiPaths.ts","../../src/constants/index.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/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/code/verify',\n\t\tsignIn: '/v1/auth/signin/otp',\n\t\tsignUp: '/v1/auth/signup/otp',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/otp',\n\t\t\tphone: '/v1/user/update/phone/otp'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/otp'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/signin/magiclink',\n\t\tsignUp: '/v1/auth/signup/magiclink',\n\t\tsession: '/v1/auth/magiclink/session',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/magiclink',\n\t\t\tphone: '/v1/user/update/phone/magiclink'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/magiclink'\n\t},\n\toauth: {\n\t\tstart: '/v1/oauth/authorize',\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/verify/totp',\n\t\tsignUp: '/v1/auth/signup/totp',\n\t\tupdate: '/v1/user/update/totp'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/webauthn/signup/start',\n\t\t\tfinish: '/v1/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/webauthn/signin/start',\n\t\t\tfinish: '/v1/webauthn/signin/finish'\n\t\t},\n\t\tadd: {\n\t\t\tstart: '/v1/webauthn/device/add/start',\n\t\t\tfinish: '/v1/webauthn/device/add/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","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 { 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 } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\n\nimport { mergeHeaders, serializeBody } from './utils';\n\nenum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\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}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = ({ path, body, headers, queryParams, method, token }) =>\n\t\tfetchWithLogger(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});\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token })\n\t};\n};\n\nexport default createHttpClient;\nexport { HTTPMethods };\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('/').replaceAll(/\\/{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\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\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(identifierValidations, stringPhone('phone'), uriValidations);\nexport const withUpdateEmailValidations = withValidations(identifierValidations, stringEmail('email'), uriValidations);","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","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(stringNonEmpty('executionId'), stringNonEmpty('stepId'), stringNonEmpty('actionId'));\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations((executionId: string, stepId: string, actionId: string, input?: Record<string, FormDataEntryValue>) => {\n\t\treturn transformResponse(\n\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, input })\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 withAddStartValidations = 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\tadd: {\n\t\tstart: withAddStartValidations(\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.add.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.add.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 { 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 }: { projectId: string, logger?: Logger, baseUrl?: string }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger }))\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 { SdkResponse } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","add","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","args","__awaiter","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","HTTPMethods","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","fetchWithLogger","sendRequest","path","queryParams","URL","search","URLSearchParams","urlBuilder","baseHeaders","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replaceAll","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","createValidator","rule","defaultMsg","val","replace","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","config","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","withAddStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"8KAAeA,E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AAoBuD,EAAgBpI,IACpC0B,EACC8C,EAAWxD,KACV7F,EAAkBW,IAAIF,MACtB,CAAE+I,WAAYE,EAAYuD,UAC1B,CAAEpI,aAKNnE,OAAQqM,IACP,CAACI,EAAuB3G,IACvBD,EACC8C,EAAWxD,KAAK7F,EAAkBW,IAAID,OAAQ,CAAEyM,gBAAe3G,mBCnE9D4G,GAA0B9E,EAAgBK,EAAe,UbSnC,IAACtD,GAAcgI,GcT3C,MAKMC,GAT2BhF,EAAgB,EdapBjD,GcZf,YdY6BgI,GcZhB1E,EAAe,adazC3B,EATyB,EAAC3B,EAAcgI,IAAwBlG,GAChEE,KAAoBgG,GAAO9F,SAAS3B,EAAAA,QAAIuB,EAAK9B,IAQ7BkI,CAAkBlI,GAAMgI,IAAxCrG,KcVWwG,EACX,EAAG5I,YAAWnC,SAAQwC,cACrBwI,ODAcpE,ECAJrE,EAAiB,CAAEC,QAASA,GtBdJ,0BsBcqCL,YAAWnC,WDAxC,CAC3CiL,IAAKtE,EAAQC,GACbsE,UAAW3C,GAAc3B,GACzBuE,MAAOvC,GAAUhC,GACjBwE,KAAMxB,GAAShD,GACfyE,KAAMpB,GAASrD,GACf0E,SAAUf,GAAa3D,GACvB2E,KAAMjC,GAAS1C,GACf4E,QAAUpJ,GAAmB0B,EAAkB8C,EAAWzD,IAAI5F,EAAkB,CAAE6E,WAClFqJ,OAASrJ,GAAmB0B,EAAkB8C,EAAWzD,IAAI5F,EAAiB,CAAE6E,WAChFmB,aAAcoH,GAAwBpH,GACtCqD,cAXc,IAACA,CCA8E,IAK9FiE,GAAkBxG,gBAAkBA"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ declare enum OAuthProviders {
53
53
  apple = "apple"
54
54
  }
55
55
 
56
- declare const _default: (args_0: {
56
+ declare const sdkWithAttributes: ((args_0: {
57
57
  projectId: string;
58
58
  logger?: Logger;
59
59
  baseUrl?: string;
@@ -94,32 +94,32 @@ declare const _default: (args_0: {
94
94
  start: {
95
95
  facebook: <B extends {
96
96
  redirect: boolean;
97
- }>(config?: B) => Promise<B extends {
97
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
98
98
  redirect: true;
99
99
  } ? undefined : SdkResponse>;
100
100
  github: <B extends {
101
101
  redirect: boolean;
102
- }>(config?: B) => Promise<B extends {
102
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
103
103
  redirect: true;
104
104
  } ? undefined : SdkResponse>;
105
105
  google: <B extends {
106
106
  redirect: boolean;
107
- }>(config?: B) => Promise<B extends {
107
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
108
108
  redirect: true;
109
109
  } ? undefined : SdkResponse>;
110
110
  microsoft: <B extends {
111
111
  redirect: boolean;
112
- }>(config?: B) => Promise<B extends {
112
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
113
113
  redirect: true;
114
114
  } ? undefined : SdkResponse>;
115
115
  gitlab: <B extends {
116
116
  redirect: boolean;
117
- }>(config?: B) => Promise<B extends {
117
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
118
118
  redirect: true;
119
119
  } ? undefined : SdkResponse>;
120
120
  apple: <B extends {
121
121
  redirect: boolean;
122
- }>(config?: B) => Promise<B extends {
122
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
123
123
  redirect: true;
124
124
  } ? undefined : SdkResponse>;
125
125
  };
@@ -159,9 +159,11 @@ declare const _default: (args_0: {
159
159
  logout: (token?: string) => Promise<SdkResponse>;
160
160
  isJwtExpired: (token: string) => boolean;
161
161
  httpClient: HttpClient;
162
+ }) & {
163
+ DeliveryMethods: typeof DeliveryMethods;
162
164
  };
163
165
 
164
166
  declare type DeliveryMethod = keyof typeof DeliveryMethods;
165
167
  declare type OAuthProvider = keyof typeof OAuthProviders;
166
168
 
167
- export { DeliveryMethod, OAuthProvider, SdkResponse, _default as default };
169
+ export { DeliveryMethod, OAuthProvider, SdkResponse, sdkWithAttributes as default };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{__awaiter as e}from"tslib";import t from"jwt-decode";import s from"lodash.get";var n={verify:"/v1/auth/code/verify",signIn:"/v1/auth/signin/otp",signUp:"/v1/auth/signup/otp",update:{email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},signUpOrIn:"/v1/auth/sign-up-or-in/otp"},i={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/signin/magiclink",signUp:"/v1/auth/signup/magiclink",session:"/v1/auth/magiclink/session",update:{email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},signUpOrIn:"/v1/auth/sign-up-or-in/magiclink"},r={start:"/v1/oauth/authorize"},o={start:"/v1/auth/saml/authorize"},a={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},d={signUp:{start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},signIn:{start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},add:{start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"}},p="/v1/auth/refresh",c="/v1/auth/logoutall",u={start:"/v1/flow/start",next:"/v1/flow/next"},l="/v1/auth/exchange";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=(t,s)=>{const n=s||fetch;if(!n)throw new Error("fetch is not defined");return t?(...s)=>e(void 0,void 0,void 0,(function*(){t.log((e=>g().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(s));const i=yield n(...s);return t[i.ok?"log":"error"](yield(t=>e(void 0,void 0,void 0,(function*(){const e=yield t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),g().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})))(i)),i})):n},v=(...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}),{})),m=e=>void 0===e?void 0:JSON.stringify(e);var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const f=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},I=({baseUrl:e,projectId:t,baseConfig:s,logger:n})=>{const i=h(n),r=({path:n,body:r,headers:o,queryParams:a,method:d,token:p})=>i((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:n,baseUrl:e,queryParams:a}),{headers:v(f(t,p),(null==s?void 0:s.baseHeaders)||{},o),method:d,body:m(r)});return{get:(e,{headers:t,queryParams:s,token:n}={})=>r({path:e,headers:t,queryParams:s,body:void 0,method:b.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.post,token:i}),put:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.put,token:i}),delete:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.delete,token:i})}},y=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:s}=t(e);return(new Date).getTime()/1e3>s},j=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),O=t=>e(void 0,void 0,void 0,(function*(){const e=yield t,s={code:e.status,ok:e.ok,response:e},n=yield e.json();return e.ok?s.data=n:s.error=n,s}));var k,U,x;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(k||(k={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(U||(U={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(x||(x={}));const w=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),P=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),R=e=>t=>e.test(t),q=R(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),$=R(/^\+[1-9]{1}[0-9]{3,14}$/),E=w(q,'"{val}" is not a valid email'),M=w($,'"{val}" is not a valid phone number'),S=w((T=1,e=>e.length>=T),"Minimum length is 1");var T;const A=w((e=>"string"==typeof e),"Input is not a string"),D=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>P(...e).validate(s[t]))),t(...s)),z=e=>[A(`"${e}" must be a string`),S(`"${e}" must not be empty`)],L=e=>[A(`"${e}" must be a string`),E()],H=e=>[A(`"${e}" must be a string`),M()];var J;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(J||(J={}));const N=z("identifier"),Z=D(N,z("code")),B=D(N),C=D(N,H("phone")),F=D(N,L("email")),G=e=>({verify:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Z(((t,i)=>O(e.post(j(n.verify,s),{code:i,externalId:t}))))})),{}),signIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B((t=>O(e.post(j(n.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B(((t,i)=>O(e.post(j(n.signUp,s),{externalId:t,user:i}))))})),{}),signUpOrIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B((t=>O(e.post(j(n.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:F(((t,s,i)=>O(e.post(n.update.email,{externalId:t,email:s},{token:i})))),phone:Object.keys(k).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,i,r)=>O(e.post(j(n.update.phone,s),{externalId:t,phone:i},{token:r}))))})),{})}}),_=z("identifier"),K=z("uri"),Q=D(z("token")),V=D(_,K),W=D(z("pendingRef")),X=D(_,H("phone"),K),Y=D(_,L("email"),K),ee=t=>({verify:Q((e=>O(t.post(i.verify,{token:e})))),signIn:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n)=>O(t.post(j(i.signIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n)=>O(t.post(j(i.signUpOrIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n,r)=>O(t.post(j(i.signUp,s),{externalId:e,URI:n,user:r,crossDevice:!0}))))})),{}),waitForSession:W(((s,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let d;const p=setInterval((()=>e(void 0,void 0,void 0,(function*(){const e=yield t.post(i.session,{pendingRef:s});e.ok&&(clearInterval(p),d&&clearTimeout(d),r(O(Promise.resolve(e))))}))),o);d=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(p)}),a)})))),update:{email:Y(((e,s,n,r)=>O(t.post(i.update.email,{externalId:e,email:s,URI:n,crossDevice:!0},{token:r})))),phone:Object.keys(k).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:X(((e,n,r,o)=>O(t.post(j(i.update.phone,s),{externalId:e,phone:n,URI:r,crossDevice:!0},{token:o}))))})),{})}}),te=e=>({verify:Q((t=>O(e.post(i.verify,{token:t})))),signIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n)=>O(e.post(j(i.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n,r)=>O(e.post(j(i.signUp,s),{externalId:t,URI:n,user:r}))))})),{}),signUpOrIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n)=>O(e.post(j(i.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:Y(((t,s,n,r)=>O(e.post(i.update.email,{externalId:t,email:s,URI:n},{token:r})))),phone:Object.keys(k).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,r,o)=>O(e.post(j(i.update.phone,s),{externalId:t,phone:n,URI:r},{token:o}))))})),{})},crossDevice:ee(e)}),se=D(z("code")),ne=e=>({exchange:se((t=>O(e.get(l,{queryParams:{code:t}}))))});var ie;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ie||(ie={}));const re=t=>Object.assign({start:Object.keys(ie).reduce(((s,n)=>Object.assign(Object.assign({},s),{[n]:(s,{redirect:i=!1}={})=>e(void 0,void 0,void 0,(function*(){const e=yield t.get(r.start,{queryParams:{provider:n,redirectURL:s}});if(!i||!e.ok)return O(Promise.resolve(e));const{url:o}=yield e.json();window.location.href=o}))})),{})},ne(t)),oe=D(z("flowId")),ae=D(z("executionId"),z("stepId"),z("actionId")),de=e=>({start:oe((t=>O(e.post(u.start,{flowId:t})))),next:ae(((t,s,n,i)=>O(e.post(u.next,{executionId:t,stepId:s,actionId:n,input:i}))))}),pe=D(z("tenant")),ce=t=>Object.assign({start:pe(((s,n,{redirect:i=!1}={})=>e(void 0,void 0,void 0,(function*(){const e=yield t.get(o.start,{queryParams:{tenant:s,redirectURL:n}});if(!i||!e.ok)return O(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))))},ne(t)),ue=z("identifier"),le=D(ue,z("code")),ge=D(ue),he=D(ue),ve=e=>({signUp:ge(((t,s)=>O(e.post(a.signUp,{externalId:t,user:s})))),verify:le(((t,s)=>O(e.post(a.verify,{externalId:t,code:s})))),update:he(((t,s)=>O(e.post(a.update,{externalId:t},{token:s}))))}),me=z("identifier"),be=z("origin"),fe=D(me,be,z("name")),Ie=D(me,be),ye=D(me,be,z("token")),je=D(z("transactionId"),z("response")),Oe=e=>({signUp:{start:fe(((t,s,n)=>O(e.post(d.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:je(((t,s)=>O(e.post(d.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:Ie(((t,s)=>O(e.post(d.signIn.start,{externalId:t,origin:s})))),finish:je(((t,s)=>O(e.post(d.signIn.finish,{transactionId:t,response:s}))))},add:{start:ye(((t,s,n)=>O(e.post(d.add.start,{externalId:t,origin:s},{token:n})))),finish:je(((t,s)=>O(e.post(d.add.finish,{transactionId:t,response:s}))))}}),ke=D(z("token"));var Ue,xe,we=D([(Ue="projectId",xe=z("projectId"),w(((e,t)=>n=>P(...t).validate(s(n,e)))(Ue,xe))())])((({projectId:e,logger:t,baseUrl:s})=>{return n=I({baseUrl:s||"https://api.descope.com",projectId:e,logger:t}),{otp:G(n),magicLink:te(n),oauth:re(n),saml:ce(n),totp:ve(n),webauthn:Oe(n),flow:de(n),refresh:e=>O(n.get(p,{token:e})),logout:e=>O(n.get(c,{token:e})),isJwtExpired:ke(y),httpClient:n};var n}));export{we as default};
1
+ import{__awaiter as e}from"tslib";import t from"jwt-decode";import s from"lodash.get";var n={verify:"/v1/auth/code/verify",signIn:"/v1/auth/signin/otp",signUp:"/v1/auth/signup/otp",update:{email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},signUpOrIn:"/v1/auth/sign-up-or-in/otp"},i={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/signin/magiclink",signUp:"/v1/auth/signup/magiclink",session:"/v1/auth/magiclink/session",update:{email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},signUpOrIn:"/v1/auth/sign-up-or-in/magiclink"},r={start:"/v1/oauth/authorize"},o={start:"/v1/auth/saml/authorize"},a={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},d={signUp:{start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},signIn:{start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},add:{start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"}},p="/v1/auth/refresh",c="/v1/auth/logoutall",u={start:"/v1/flow/start",next:"/v1/flow/next"},l="/v1/auth/exchange";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=(t,s)=>{const n=s||fetch;if(!n)throw new Error("fetch is not defined");return t?(...s)=>e(void 0,void 0,void 0,(function*(){t.log((e=>g().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(s));const i=yield n(...s);return t[i.ok?"log":"error"](yield(t=>e(void 0,void 0,void 0,(function*(){const e=yield t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),g().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})))(i)),i})):n},v=(...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}),{})),m=e=>void 0===e?void 0:JSON.stringify(e);var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const f=(e,t="")=>{let s=e;return""!==t&&(s=s+":"+t),{Authorization:`Bearer ${s}`}},I=({baseUrl:e,projectId:t,baseConfig:s,logger:n})=>{const i=h(n),r=({path:n,body:r,headers:o,queryParams:a,method:d,token:p})=>i((({path:e,baseUrl:t,queryParams:s})=>{const n=new URL(e,t);return s&&(n.search=new URLSearchParams(s).toString()),n})({path:n,baseUrl:e,queryParams:a}),{headers:v(f(t,p),(null==s?void 0:s.baseHeaders)||{},o),method:d,body:m(r)});return{get:(e,{headers:t,queryParams:s,token:n}={})=>r({path:e,headers:t,queryParams:s,body:void 0,method:b.get,token:n}),post:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.post,token:i}),put:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.put,token:i}),delete:(e,t,{headers:s,queryParams:n,token:i}={})=>r({path:e,headers:s,queryParams:n,body:t,method:b.delete,token:i})}},y=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:s}=t(e);return(new Date).getTime()/1e3>s},j=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),O=t=>e(void 0,void 0,void 0,(function*(){const e=yield t,s={code:e.status,ok:e.ok,response:e},n=yield e.json();return e.ok?s.data=n:s.error=n,s}));var k,U,x;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(k||(k={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(U||(U={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(x||(x={}));const w=(e,t)=>(s=t)=>t=>!e(t)&&s.replace("{val}",t),P=(...e)=>({validate:t=>(e.forEach((e=>{const s=e(t);if(s)throw new Error(s)})),!0)}),R=e=>t=>e.test(t),q=R(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),$=R(/^\+[1-9]{1}[0-9]{3,14}$/),M=w(q,'"{val}" is not a valid email'),E=w($,'"{val}" is not a valid phone number'),S=w((T=1,e=>e.length>=T),"Minimum length is 1");var T;const D=w((e=>"string"==typeof e),"Input is not a string"),A=(...e)=>t=>(...s)=>(e.forEach(((e,t)=>P(...e).validate(s[t]))),t(...s)),z=e=>[D(`"${e}" must be a string`),S(`"${e}" must not be empty`)],L=e=>[D(`"${e}" must be a string`),M()],H=e=>[D(`"${e}" must be a string`),E()];var J;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(J||(J={}));const N=z("identifier"),Z=A(N,z("code")),B=A(N),C=A(N,H("phone")),F=A(N,L("email")),G=e=>({verify:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:Z(((t,i)=>O(e.post(j(n.verify,s),{code:i,externalId:t}))))})),{}),signIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B((t=>O(e.post(j(n.signIn,s),{externalId:t}))))})),{}),signUp:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B(((t,i)=>O(e.post(j(n.signUp,s),{externalId:t,user:i}))))})),{}),signUpOrIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:B((t=>O(e.post(j(n.signUpOrIn,s),{externalId:t}))))})),{}),update:{email:F(((t,s,i)=>O(e.post(n.update.email,{externalId:t,email:s},{token:i})))),phone:Object.keys(k).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:C(((t,i,r)=>O(e.post(j(n.update.phone,s),{externalId:t,phone:i},{token:r}))))})),{})}}),_=z("identifier"),K=z("uri"),Q=A(z("token")),V=A(_,K),W=A(z("pendingRef")),X=A(_,H("phone"),K),Y=A(_,L("email"),K),ee=t=>({verify:Q((e=>O(t.post(i.verify,{token:e})))),signIn:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n)=>O(t.post(j(i.signIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n)=>O(t.post(j(i.signUpOrIn,s),{externalId:e,URI:n,crossDevice:!0}))))})),{}),signUp:Object.keys(U).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:V(((e,n,r)=>O(t.post(j(i.signUp,s),{externalId:e,URI:n,user:r,crossDevice:!0}))))})),{}),waitForSession:W(((s,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let d;const p=setInterval((()=>e(void 0,void 0,void 0,(function*(){const e=yield t.post(i.session,{pendingRef:s});e.ok&&(clearInterval(p),d&&clearTimeout(d),r(O(Promise.resolve(e))))}))),o);d=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(p)}),a)})))),update:{email:Y(((e,s,n,r)=>O(t.post(i.update.email,{externalId:e,email:s,URI:n,crossDevice:!0},{token:r})))),phone:Object.keys(k).reduce(((e,s)=>Object.assign(Object.assign({},e),{[s]:X(((e,n,r,o)=>O(t.post(j(i.update.phone,s),{externalId:e,phone:n,URI:r,crossDevice:!0},{token:o}))))})),{})}}),te=e=>({verify:Q((t=>O(e.post(i.verify,{token:t})))),signIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n)=>O(e.post(j(i.signIn,s),{externalId:t,URI:n}))))})),{}),signUp:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n,r)=>O(e.post(j(i.signUp,s),{externalId:t,URI:n,user:r}))))})),{}),signUpOrIn:Object.keys(U).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:V(((t,n)=>O(e.post(j(i.signUpOrIn,s),{externalId:t,URI:n}))))})),{}),update:{email:Y(((t,s,n,r)=>O(e.post(i.update.email,{externalId:t,email:s,URI:n},{token:r})))),phone:Object.keys(k).reduce(((t,s)=>Object.assign(Object.assign({},t),{[s]:X(((t,n,r,o)=>O(e.post(j(i.update.phone,s),{externalId:t,phone:n,URI:r},{token:o}))))})),{})},crossDevice:ee(e)}),se=A(z("code")),ne=e=>({exchange:se((t=>O(e.get(l,{queryParams:{code:t}}))))});var ie;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ie||(ie={}));const re=t=>Object.assign({start:Object.keys(ie).reduce(((s,n)=>Object.assign(Object.assign({},s),{[n]:(s,{redirect:i=!1}={})=>e(void 0,void 0,void 0,(function*(){const e=yield t.get(r.start,{queryParams:Object.assign({provider:n},s&&{redirectURL:s})});if(!i||!e.ok)return O(Promise.resolve(e));const{url:o}=yield e.json();window.location.href=o}))})),{})},ne(t)),oe=A(z("flowId")),ae=A(z("executionId"),z("stepId"),z("actionId")),de=e=>({start:oe((t=>O(e.post(u.start,{flowId:t})))),next:ae(((t,s,n,i)=>O(e.post(u.next,{executionId:t,stepId:s,actionId:n,input:i}))))}),pe=A(z("tenant")),ce=t=>Object.assign({start:pe(((s,n,{redirect:i=!1}={})=>e(void 0,void 0,void 0,(function*(){const e=yield t.get(o.start,{queryParams:{tenant:s,redirectURL:n}});if(!i||!e.ok)return O(Promise.resolve(e));const{url:r}=yield e.json();window.location.href=r}))))},ne(t)),ue=z("identifier"),le=A(ue,z("code")),ge=A(ue),he=A(ue),ve=e=>({signUp:ge(((t,s)=>O(e.post(a.signUp,{externalId:t,user:s})))),verify:le(((t,s)=>O(e.post(a.verify,{externalId:t,code:s})))),update:he(((t,s)=>O(e.post(a.update,{externalId:t},{token:s}))))}),me=z("identifier"),be=z("origin"),fe=A(me,be,z("name")),Ie=A(me,be),ye=A(me,be,z("token")),je=A(z("transactionId"),z("response")),Oe=e=>({signUp:{start:fe(((t,s,n)=>O(e.post(d.signUp.start,{user:{externalId:t,name:n},origin:s})))),finish:je(((t,s)=>O(e.post(d.signUp.finish,{transactionId:t,response:s}))))},signIn:{start:Ie(((t,s)=>O(e.post(d.signIn.start,{externalId:t,origin:s})))),finish:je(((t,s)=>O(e.post(d.signIn.finish,{transactionId:t,response:s}))))},add:{start:ye(((t,s,n)=>O(e.post(d.add.start,{externalId:t,origin:s},{token:n})))),finish:je(((t,s)=>O(e.post(d.add.finish,{transactionId:t,response:s}))))}}),ke=A(z("token"));var Ue,xe;const we=A([(Ue="projectId",xe=z("projectId"),w(((e,t)=>n=>P(...t).validate(s(n,e)))(Ue,xe))())])((({projectId:e,logger:t,baseUrl:s})=>{return n=I({baseUrl:s||"https://api.descope.com",projectId:e,logger:t}),{otp:G(n),magicLink:te(n),oauth:re(n),saml:ce(n),totp:ve(n),webauthn:Oe(n),flow:de(n),refresh:e=>O(n.get(p,{token:e})),logout:e=>O(n.get(c,{token:e})),isJwtExpired:ke(y),httpClient:n};var n}));we.DeliveryMethods=U;export{we as default};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/constants/index.ts","../src/httpClient/helpers/createFetchLogger.ts","../src/httpClient/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/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/code/verify',\n\t\tsignIn: '/v1/auth/signin/otp',\n\t\tsignUp: '/v1/auth/signup/otp',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/otp',\n\t\t\tphone: '/v1/user/update/phone/otp'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/otp'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/signin/magiclink',\n\t\tsignUp: '/v1/auth/signup/magiclink',\n\t\tsession: '/v1/auth/magiclink/session',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/magiclink',\n\t\t\tphone: '/v1/user/update/phone/magiclink'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/magiclink'\n\t},\n\toauth: {\n\t\tstart: '/v1/oauth/authorize',\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/verify/totp',\n\t\tsignUp: '/v1/auth/signup/totp',\n\t\tupdate: '/v1/user/update/totp'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/webauthn/signup/start',\n\t\t\tfinish: '/v1/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/webauthn/signin/start',\n\t\t\tfinish: '/v1/webauthn/signin/finish'\n\t\t},\n\t\tadd: {\n\t\t\tstart: '/v1/webauthn/device/add/start',\n\t\t\tfinish: '/v1/webauthn/device/add/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","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 { 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 } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\n\nimport { mergeHeaders, serializeBody } from './utils';\n\nenum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\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}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = ({ path, body, headers, queryParams, method, token }) =>\n\t\tfetchWithLogger(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});\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token })\n\t};\n};\n\nexport default createHttpClient;\nexport { HTTPMethods };\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('/').replaceAll(/\\/{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\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\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(identifierValidations, stringPhone('phone'), uriValidations);\nexport const withUpdateEmailValidations = withValidations(identifierValidations, stringEmail('email'), uriValidations);","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","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\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 }\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(stringNonEmpty('executionId'), stringNonEmpty('stepId'), stringNonEmpty('actionId'));\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations((executionId: string, stepId: string, actionId: string, input?: Record<string, FormDataEntryValue>) => {\n\t\treturn transformResponse(\n\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, input })\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 withAddStartValidations = 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\tadd: {\n\t\tstart: withAddStartValidations(\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.add.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.add.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 { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\nexport default withSdkConfigValidations(\n\t({ projectId, logger, baseUrl }: { projectId: string, logger?: Logger, baseUrl?: string }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger }))\n);\n\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\nexport type OAuthProvider = keyof typeof OAuthProviders;\nexport type { SdkResponse } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","add","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","args","__awaiter","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","HTTPMethods","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","fetchWithLogger","sendRequest","path","queryParams","URL","search","URLSearchParams","urlBuilder","baseHeaders","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replaceAll","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","createValidator","rule","defaultMsg","val","replace","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","config","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","withAddStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","index","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"sFAAA,IAAeA,EACT,CACJC,OAAQ,uBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,8BATCP,EAWH,CACVC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRK,QAAS,6BACTJ,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,oCApBCP,EAsBP,CACNS,MAAO,uBAvBMT,EAyBR,CACLS,MAAO,2BA1BMT,EA4BR,CACLC,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA/BKJ,EAiCJ,CACTG,OAAQ,CACPM,MAAO,4BACPC,OAAQ,8BAETR,OAAQ,CACPO,MAAO,4BACPC,OAAQ,8BAETC,IAAK,CACJF,MAAO,gCACPC,OAAQ,mCA5CIV,EA+CL,mBA/CKA,EAgDN,qBAhDMA,EAiDR,CACLS,MAAO,iBACPG,KAAM,iBAnDOZ,EAqDJ,oBC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c3B,GACzBuE,MAAOvC,GAAUhC,GACjBwE,KAAMxB,GAAShD,GACfyE,KAAMpB,GAASrD,GACf0E,SAAUf,GAAa3D,GACvB2E,KAAMjC,GAAS1C,GACf4E,QAAUpJ,GAAmB0B,EAAkB8C,EAAWzD,IAAI5F,EAAkB,CAAE6E,WAClFqJ,OAASrJ,GAAmB0B,EAAkB8C,EAAWzD,IAAI5F,EAAiB,CAAE6E,WAChFmB,aAAcoH,GAAwBpH,GACtCqD,cAXc,IAACA,CCA8E"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/constants/index.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/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/code/verify',\n\t\tsignIn: '/v1/auth/signin/otp',\n\t\tsignUp: '/v1/auth/signup/otp',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/otp',\n\t\t\tphone: '/v1/user/update/phone/otp'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/otp'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/signin/magiclink',\n\t\tsignUp: '/v1/auth/signup/magiclink',\n\t\tsession: '/v1/auth/magiclink/session',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/magiclink',\n\t\t\tphone: '/v1/user/update/phone/magiclink'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/magiclink'\n\t},\n\toauth: {\n\t\tstart: '/v1/oauth/authorize',\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/verify/totp',\n\t\tsignUp: '/v1/auth/signup/totp',\n\t\tupdate: '/v1/user/update/totp'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/webauthn/signup/start',\n\t\t\tfinish: '/v1/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/webauthn/signin/start',\n\t\t\tfinish: '/v1/webauthn/signin/finish'\n\t\t},\n\t\tadd: {\n\t\t\tstart: '/v1/webauthn/device/add/start',\n\t\t\tfinish: '/v1/webauthn/device/add/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","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 { 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 } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\n\nimport { mergeHeaders, serializeBody } from './utils';\n\nenum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\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}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = ({ path, body, headers, queryParams, method, token }) =>\n\t\tfetchWithLogger(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});\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token })\n\t};\n};\n\nexport default createHttpClient;\nexport { HTTPMethods };\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('/').replaceAll(/\\/{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\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\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(identifierValidations, stringPhone('phone'), uriValidations);\nexport const withUpdateEmailValidations = withValidations(identifierValidations, stringEmail('email'), uriValidations);","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","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(stringNonEmpty('executionId'), stringNonEmpty('stepId'), stringNonEmpty('actionId'));\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations((executionId: string, stepId: string, actionId: string, input?: Record<string, FormDataEntryValue>) => {\n\t\treturn transformResponse(\n\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, input })\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 withAddStartValidations = 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\tadd: {\n\t\tstart: withAddStartValidations(\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.add.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.add.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 { 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 }: { projectId: string, logger?: Logger, baseUrl?: string }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger }))\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 { SdkResponse } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","add","next","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","args","__awaiter","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","HTTPMethods","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","fetchWithLogger","sendRequest","path","queryParams","URL","search","URLSearchParams","urlBuilder","baseHeaders","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replaceAll","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","createValidator","rule","defaultMsg","val","replace","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","config","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","withAddStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"sFAAA,IAAeA,EACT,CACJC,OAAQ,uBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,8BATCP,EAWH,CACVC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRK,QAAS,6BACTJ,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,oCApBCP,EAsBP,CACNS,MAAO,uBAvBMT,EAyBR,CACLS,MAAO,2BA1BMT,EA4BR,CACLC,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA/BKJ,EAiCJ,CACTG,OAAQ,CACPM,MAAO,4BACPC,OAAQ,8BAETR,OAAQ,CACPO,MAAO,4BACPC,OAAQ,8BAETC,IAAK,CACJF,MAAO,gCACPC,OAAQ,mCA5CIV,EA+CL,mBA/CKA,EAgDN,qBAhDMA,EAiDR,CACLS,MAAO,iBACPG,KAAM,iBAnDOZ,EAqDJ,oBCrDJ,MCEDa,EAAiB,KACtB,MAAMC,EAOF,CAAA,EAEJ,MAAO,CACNC,QAAQA,GACP,MAAMC,EACsB,mBAApBD,EAAQE,QAAyBC,OAAOC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