@descope/core-js-sdk
Advanced tools
Comparing version 0.0.41-alpha.6 to 0.0.41-alpha.7
@@ -1,2 +0,2 @@ | ||
"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}),{})),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="")=>({Authorization:`Basic ${btoa(`${e}:${t}`)}`}),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: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),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}))))}),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: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}));module.exports=Re; | ||
"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; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
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="")=>({Authorization:`Basic ${btoa(`${e}:${t}`)}`}),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),$=R(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),q=R(/^\+[1-9]{1}[0-9]{3,14}$/),E=w($,'"{val}" is not a valid email'),M=w(q,'"{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}; | ||
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}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";var e={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"},t={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"},n={start:"/v1/oauth/authorize"},r={start:"/v1/auth/saml/authorize"},o={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},i={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"}},s="/v1/auth/refresh",a="/v1/auth/logoutall",c={start:"/v1/flow/start",next:"/v1/flow/next"},u="/v1/auth/exchange";const d=1e3,p=6e5;function l(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}const f=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},h=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?(...t)=>l(void 0,void 0,void 0,(function*(){e.log((e=>f().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=yield n(...t);return e[r.ok?"log":"error"](yield(e=>l(void 0,void 0,void 0,(function*(){const t=yield e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),f().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})))(r)),r})):n},g=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),v=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 b=(e,t="")=>({Authorization:`Basic ${btoa(`${e}:${t}`)}`}),m=({baseUrl:e,projectId:t,baseConfig:n,logger:r})=>{const o=h(r),i=({path:r,body:i,headers:s,queryParams:a,method:c,token:u})=>o((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:r,baseUrl:e,queryParams:a}),{headers:g(b(t,u),(null==n?void 0:n.baseHeaders)||{},s),method:c,body:v(i)});return{get:(e,{headers:t,queryParams:n,token:r}={})=>i({path:e,headers:t,queryParams:n,body:void 0,method:y.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.delete,token:o})}};function I(e){this.message=e}I.prototype=new Error,I.prototype.name="InvalidCharacterError";var j="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new I("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,s="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?s+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function O(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(j(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return j(t)}}function k(e){this.message=e}k.prototype=new Error,k.prototype.name="InvalidTokenError";const w=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=function(e,t){if("string"!=typeof e)throw new k("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(O(e.split(".")[n]))}catch(e){throw new k("Invalid token specified: "+e.message)}}(e);return(new Date).getTime()/1e3>t},_=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),U=e=>l(void 0,void 0,void 0,(function*(){const t=yield e,n={code:t.status,ok:t.ok,response:t},r=yield t.json();return t.ok?n.data=r:n.error=r,n}));var x,P,$;!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"}($||($={}));const S=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),R=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},T="__lodash_hash_undefined__",q="[object Function]",A="[object GeneratorFunction]",M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,D=/^\./,z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,L=/\\(\\)?/g,F=/^\[object .+?Constructor\]$/,J="object"==typeof E&&E&&E.Object===Object&&E,H="object"==typeof self&&self&&self.Object===Object&&self,N=J||H||Function("return this")();var Z,B=Array.prototype,G=Function.prototype,K=Object.prototype,Q=N["__core-js_shared__"],V=(Z=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+Z:"",W=G.toString,X=K.hasOwnProperty,Y=K.toString,ee=RegExp("^"+W.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),te=N.Symbol,ne=B.splice,re=he(N,"Map"),oe=he(Object,"create"),ie=te?te.prototype:void 0,se=ie?ie.toString:void 0;function ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ce(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ue(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function de(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function pe(e,t){var n;t=function(e,t){if(be(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||Ie(e))return!0;return C.test(e)||!M.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:be(n=t)?n:ge(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[ve(t[r++])];return r&&r==o?e:void 0}function le(e){if(!me(e)||(t=e,V&&V in t))return!1;var t,n=function(e){var t=me(e)?Y.call(e):"";return t==q||t==A}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?ee:F;return n.test(function(e){if(null!=e){try{return W.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function fe(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function he(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return le(n)?n:void 0}ae.prototype.clear=function(){this.__data__=oe?oe(null):{}},ae.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ae.prototype.get=function(e){var t=this.__data__;if(oe){var n=t[e];return n===T?void 0:n}return X.call(t,e)?t[e]:void 0},ae.prototype.has=function(e){var t=this.__data__;return oe?void 0!==t[e]:X.call(t,e)},ae.prototype.set=function(e,t){return this.__data__[e]=oe&&void 0===t?T:t,this},ce.prototype.clear=function(){this.__data__=[]},ce.prototype.delete=function(e){var t=this.__data__,n=de(t,e);return!(n<0)&&(n==t.length-1?t.pop():ne.call(t,n,1),!0)},ce.prototype.get=function(e){var t=this.__data__,n=de(t,e);return n<0?void 0:t[n][1]},ce.prototype.has=function(e){return de(this.__data__,e)>-1},ce.prototype.set=function(e,t){var n=this.__data__,r=de(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ue.prototype.clear=function(){this.__data__={hash:new ae,map:new(re||ce),string:new ae}},ue.prototype.delete=function(e){return fe(this,e).delete(e)},ue.prototype.get=function(e){return fe(this,e).get(e)},ue.prototype.has=function(e){return fe(this,e).has(e)},ue.prototype.set=function(e,t){return fe(this,e).set(e,t),this};var ge=ye((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Ie(e))return se?se.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return D.test(e)&&n.push(""),e.replace(z,(function(e,t,r,o){n.push(r?o.replace(L,"$1"):t||e)})),n}));function ve(e){if("string"==typeof e||Ie(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ye(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ye.Cache||ue),n}ye.Cache=ue;var be=Array.isArray;function me(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==Y.call(e)}var je=function(e,t,n){var r=null==e?void 0:pe(e,t);return void 0===r?n:r};const Oe=e=>t=>e.test(t),ke=Oe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),we=Oe(/^\+[1-9]{1}[0-9]{3,14}$/),_e=S(ke,'"{val}" is not a valid email'),Ue=S(we,'"{val}" is not a valid phone number'),xe=S((Pe=1,e=>e.length>=Pe),"Minimum length is 1");var Pe;const $e=S((e=>"string"==typeof e),"Input is not a string"),Se=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>R(...e).validate(n[t]))),t(...n)),Re=e=>[$e(`"${e}" must be a string`),xe(`"${e}" must not be empty`)],Ee=e=>[$e(`"${e}" must be a string`),_e()],Te=e=>[$e(`"${e}" must be a string`),Ue()];var qe;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(qe||(qe={}));const Ae=Re("identifier"),Me=Se(Ae,Re("code")),Ce=Se(Ae),De=Se(Ae,Te("phone")),ze=Se(Ae,Ee("email")),Le=t=>({verify:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Me(((n,o)=>U(t.post(_(e.verify,r),{code:o,externalId:n}))))})),{}),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce((n=>U(t.post(_(e.signIn,r),{externalId:n}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce(((n,o)=>U(t.post(_(e.signUp,r),{externalId:n,user:o}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce((n=>U(t.post(_(e.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:ze(((n,r,o)=>U(t.post(e.update.email,{externalId:n,email:r},{token:o})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:De(((n,o,i)=>U(t.post(_(e.update.phone,r),{externalId:n,phone:o},{token:i}))))})),{})}}),Fe=Re("identifier"),Je=Re("uri"),He=Se(Re("token")),Ne=Se(Fe,Je),Ze=Se(Re("pendingRef")),Be=Se(Fe,Te("phone"),Je),Ge=Se(Fe,Ee("email"),Je),Ke=e=>({verify:He((n=>U(e.post(t.verify,{token:n})))),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signIn,r),{externalId:n,URI:o,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signUpOrIn,r),{externalId:n,URI:o,crossDevice:!0}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o,i)=>U(e.post(_(t.signUp,r),{externalId:n,URI:o,user:i,crossDevice:!0}))))})),{}),waitForSession:Ze(((n,r)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:s}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||d,d),timeoutMs:Math.min(t||p,p)}))(r);let a;const c=setInterval((()=>l(void 0,void 0,void 0,(function*(){const r=yield e.post(t.session,{pendingRef:n});r.ok&&(clearInterval(c),a&&clearTimeout(a),o(U(Promise.resolve(r))))}))),i);a=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${s}ms`,code:"0"},ok:!1}),clearInterval(c)}),s)})))),update:{email:Ge(((n,r,o,i)=>U(e.post(t.update.email,{externalId:n,email:r,URI:o,crossDevice:!0},{token:i})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,i,s)=>U(e.post(_(t.update.phone,r),{externalId:n,phone:o,URI:i,crossDevice:!0},{token:s}))))})),{})}}),Qe=e=>({verify:He((n=>U(e.post(t.verify,{token:n})))),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signIn,r),{externalId:n,URI:o}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o,i)=>U(e.post(_(t.signUp,r),{externalId:n,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signUpOrIn,r),{externalId:n,URI:o}))))})),{}),update:{email:Ge(((n,r,o,i)=>U(e.post(t.update.email,{externalId:n,email:r,URI:o},{token:i})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,i,s)=>U(e.post(_(t.update.phone,r),{externalId:n,phone:o,URI:i},{token:s}))))})),{})},crossDevice:Ke(e)}),Ve=Se(Re("code")),We=e=>({exchange:Ve((t=>U(e.get(u,{queryParams:{code:t}}))))});var Xe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(Xe||(Xe={}));const Ye=e=>Object.assign({start:Object.keys(Xe).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:(t,{redirect:o=!1}={})=>l(void 0,void 0,void 0,(function*(){const i=yield e.get(n.start,{queryParams:{provider:r,redirectURL:t}});if(!o||!i.ok)return U(Promise.resolve(i));const{url:s}=yield i.json();window.location.href=s}))})),{})},We(e)),et=Se(Re("flowId")),tt=Se(Re("executionId"),Re("stepId"),Re("actionId")),nt=e=>({start:et((t=>U(e.post(c.start,{flowId:t})))),next:tt(((t,n,r,o)=>U(e.post(c.next,{executionId:t,stepId:n,actionId:r,input:o}))))}),rt=Se(Re("tenant")),ot=e=>Object.assign({start:rt(((t,n,{redirect:o=!1}={})=>l(void 0,void 0,void 0,(function*(){const i=yield e.get(r.start,{queryParams:{tenant:t,redirectURL:n}});if(!o||!i.ok)return U(Promise.resolve(i));const{url:s}=yield i.json();window.location.href=s}))))},We(e)),it=Re("identifier"),st=Se(it,Re("code")),at=Se(it),ct=Se(it),ut=e=>({signUp:at(((t,n)=>U(e.post(o.signUp,{externalId:t,user:n})))),verify:st(((t,n)=>U(e.post(o.verify,{externalId:t,code:n})))),update:ct(((t,n)=>U(e.post(o.update,{externalId:t},{token:n}))))}),dt=Re("identifier"),pt=Re("origin"),lt=Se(dt,pt,Re("name")),ft=Se(dt,pt),ht=Se(dt,pt,Re("token")),gt=Se(Re("transactionId"),Re("response")),vt=e=>({signUp:{start:lt(((t,n,r)=>U(e.post(i.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:gt(((t,n)=>U(e.post(i.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ft(((t,n)=>U(e.post(i.signIn.start,{externalId:t,origin:n})))),finish:gt(((t,n)=>U(e.post(i.signIn.finish,{transactionId:t,response:n}))))},add:{start:ht(((t,n,r)=>U(e.post(i.add.start,{externalId:t,origin:n},{token:r})))),finish:gt(((t,n)=>U(e.post(i.add.finish,{transactionId:t,response:n}))))}}),yt=Se(Re("token"));var bt,mt;return Se([(bt="projectId",mt=Re("projectId"),S(((e,t)=>n=>R(...t).validate(je(n,e)))(bt,mt))())])((({projectId:e,logger:t,baseUrl:n})=>{return r=m({baseUrl:n||"https://api.descope.com",projectId:e,logger:t}),{otp:Le(r),magicLink:Qe(r),oauth:Ye(r),saml:ot(r),totp:ut(r),webauthn:vt(r),flow:nt(r),refresh:e=>U(r.get(s,{token:e})),logout:e=>U(r.get(a,{token:e})),isJwtExpired:yt(w),httpClient:r};var r}))})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";var e={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"},t={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"},n={start:"/v1/oauth/authorize"},r={start:"/v1/auth/saml/authorize"},o={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},i={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"}},s="/v1/auth/refresh",a="/v1/auth/logoutall",c={start:"/v1/flow/start",next:"/v1/flow/next"},u="/v1/auth/exchange";const d=1e3,p=6e5;function l(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}const f=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},h=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?(...t)=>l(void 0,void 0,void 0,(function*(){e.log((e=>f().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=yield n(...t);return e[r.ok?"log":"error"](yield(e=>l(void 0,void 0,void 0,(function*(){const t=yield e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),f().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})))(r)),r})):n},g=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),v=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 b=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},m=({baseUrl:e,projectId:t,baseConfig:n,logger:r})=>{const o=h(r),i=({path:r,body:i,headers:s,queryParams:a,method:c,token:u})=>o((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:r,baseUrl:e,queryParams:a}),{headers:g(b(t,u),(null==n?void 0:n.baseHeaders)||{},s),method:c,body:v(i)});return{get:(e,{headers:t,queryParams:n,token:r}={})=>i({path:e,headers:t,queryParams:n,body:void 0,method:y.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>i({path:e,headers:n,queryParams:r,body:t,method:y.delete,token:o})}};function I(e){this.message=e}I.prototype=new Error,I.prototype.name="InvalidCharacterError";var j="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new I("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,s="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?s+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function O(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(j(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return j(t)}}function k(e){this.message=e}k.prototype=new Error,k.prototype.name="InvalidTokenError";const w=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=function(e,t){if("string"!=typeof e)throw new k("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(O(e.split(".")[n]))}catch(e){throw new k("Invalid token specified: "+e.message)}}(e);return(new Date).getTime()/1e3>t},_=(...e)=>e.join("/").replaceAll(/\/{2,}/g,"/"),U=e=>l(void 0,void 0,void 0,(function*(){const t=yield e,n={code:t.status,ok:t.ok,response:t},r=yield t.json();return t.ok?n.data=r:n.error=r,n}));var x,P,S;!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"}(S||(S={}));const $=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),R=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},T="__lodash_hash_undefined__",q="[object Function]",A="[object GeneratorFunction]",M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,D=/^\./,z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,L=/\\(\\)?/g,F=/^\[object .+?Constructor\]$/,J="object"==typeof E&&E&&E.Object===Object&&E,H="object"==typeof self&&self&&self.Object===Object&&self,N=J||H||Function("return this")();var Z,B=Array.prototype,G=Function.prototype,K=Object.prototype,Q=N["__core-js_shared__"],V=(Z=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+Z:"",W=G.toString,X=K.hasOwnProperty,Y=K.toString,ee=RegExp("^"+W.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),te=N.Symbol,ne=B.splice,re=he(N,"Map"),oe=he(Object,"create"),ie=te?te.prototype:void 0,se=ie?ie.toString:void 0;function ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ce(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ue(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function de(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function pe(e,t){var n;t=function(e,t){if(be(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||Ie(e))return!0;return C.test(e)||!M.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:be(n=t)?n:ge(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[ve(t[r++])];return r&&r==o?e:void 0}function le(e){if(!me(e)||(t=e,V&&V in t))return!1;var t,n=function(e){var t=me(e)?Y.call(e):"";return t==q||t==A}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?ee:F;return n.test(function(e){if(null!=e){try{return W.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function fe(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function he(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return le(n)?n:void 0}ae.prototype.clear=function(){this.__data__=oe?oe(null):{}},ae.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ae.prototype.get=function(e){var t=this.__data__;if(oe){var n=t[e];return n===T?void 0:n}return X.call(t,e)?t[e]:void 0},ae.prototype.has=function(e){var t=this.__data__;return oe?void 0!==t[e]:X.call(t,e)},ae.prototype.set=function(e,t){return this.__data__[e]=oe&&void 0===t?T:t,this},ce.prototype.clear=function(){this.__data__=[]},ce.prototype.delete=function(e){var t=this.__data__,n=de(t,e);return!(n<0)&&(n==t.length-1?t.pop():ne.call(t,n,1),!0)},ce.prototype.get=function(e){var t=this.__data__,n=de(t,e);return n<0?void 0:t[n][1]},ce.prototype.has=function(e){return de(this.__data__,e)>-1},ce.prototype.set=function(e,t){var n=this.__data__,r=de(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ue.prototype.clear=function(){this.__data__={hash:new ae,map:new(re||ce),string:new ae}},ue.prototype.delete=function(e){return fe(this,e).delete(e)},ue.prototype.get=function(e){return fe(this,e).get(e)},ue.prototype.has=function(e){return fe(this,e).has(e)},ue.prototype.set=function(e,t){return fe(this,e).set(e,t),this};var ge=ye((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(Ie(e))return se?se.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return D.test(e)&&n.push(""),e.replace(z,(function(e,t,r,o){n.push(r?o.replace(L,"$1"):t||e)})),n}));function ve(e){if("string"==typeof e||Ie(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ye(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ye.Cache||ue),n}ye.Cache=ue;var be=Array.isArray;function me(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==Y.call(e)}var je=function(e,t,n){var r=null==e?void 0:pe(e,t);return void 0===r?n:r};const Oe=e=>t=>e.test(t),ke=Oe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),we=Oe(/^\+[1-9]{1}[0-9]{3,14}$/),_e=$(ke,'"{val}" is not a valid email'),Ue=$(we,'"{val}" is not a valid phone number'),xe=$((Pe=1,e=>e.length>=Pe),"Minimum length is 1");var Pe;const Se=$((e=>"string"==typeof e),"Input is not a string"),$e=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>R(...e).validate(n[t]))),t(...n)),Re=e=>[Se(`"${e}" must be a string`),xe(`"${e}" must not be empty`)],Ee=e=>[Se(`"${e}" must be a string`),_e()],Te=e=>[Se(`"${e}" must be a string`),Ue()];var qe;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(qe||(qe={}));const Ae=Re("identifier"),Me=$e(Ae,Re("code")),Ce=$e(Ae),De=$e(Ae,Te("phone")),ze=$e(Ae,Ee("email")),Le=t=>({verify:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Me(((n,o)=>U(t.post(_(e.verify,r),{code:o,externalId:n}))))})),{}),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce((n=>U(t.post(_(e.signIn,r),{externalId:n}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce(((n,o)=>U(t.post(_(e.signUp,r),{externalId:n,user:o}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce((n=>U(t.post(_(e.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:ze(((n,r,o)=>U(t.post(e.update.email,{externalId:n,email:r},{token:o})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:De(((n,o,i)=>U(t.post(_(e.update.phone,r),{externalId:n,phone:o},{token:i}))))})),{})}}),Fe=Re("identifier"),Je=Re("uri"),He=$e(Re("token")),Ne=$e(Fe,Je),Ze=$e(Re("pendingRef")),Be=$e(Fe,Te("phone"),Je),Ge=$e(Fe,Ee("email"),Je),Ke=e=>({verify:He((n=>U(e.post(t.verify,{token:n})))),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signIn,r),{externalId:n,URI:o,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signUpOrIn,r),{externalId:n,URI:o,crossDevice:!0}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o,i)=>U(e.post(_(t.signUp,r),{externalId:n,URI:o,user:i,crossDevice:!0}))))})),{}),waitForSession:Ze(((n,r)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:s}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||d,d),timeoutMs:Math.min(t||p,p)}))(r);let a;const c=setInterval((()=>l(void 0,void 0,void 0,(function*(){const r=yield e.post(t.session,{pendingRef:n});r.ok&&(clearInterval(c),a&&clearTimeout(a),o(U(Promise.resolve(r))))}))),i);a=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${s}ms`,code:"0"},ok:!1}),clearInterval(c)}),s)})))),update:{email:Ge(((n,r,o,i)=>U(e.post(t.update.email,{externalId:n,email:r,URI:o,crossDevice:!0},{token:i})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,i,s)=>U(e.post(_(t.update.phone,r),{externalId:n,phone:o,URI:i,crossDevice:!0},{token:s}))))})),{})}}),Qe=e=>({verify:He((n=>U(e.post(t.verify,{token:n})))),signIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signIn,r),{externalId:n,URI:o}))))})),{}),signUp:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o,i)=>U(e.post(_(t.signUp,r),{externalId:n,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(P).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ne(((n,o)=>U(e.post(_(t.signUpOrIn,r),{externalId:n,URI:o}))))})),{}),update:{email:Ge(((n,r,o,i)=>U(e.post(t.update.email,{externalId:n,email:r,URI:o},{token:i})))),phone:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Be(((n,o,i,s)=>U(e.post(_(t.update.phone,r),{externalId:n,phone:o,URI:i},{token:s}))))})),{})},crossDevice:Ke(e)}),Ve=$e(Re("code")),We=e=>({exchange:Ve((t=>U(e.get(u,{queryParams:{code:t}}))))});var Xe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(Xe||(Xe={}));const Ye=e=>Object.assign({start:Object.keys(Xe).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:(t,{redirect:o=!1}={})=>l(void 0,void 0,void 0,(function*(){const i=yield e.get(n.start,{queryParams:{provider:r,redirectURL:t}});if(!o||!i.ok)return U(Promise.resolve(i));const{url:s}=yield i.json();window.location.href=s}))})),{})},We(e)),et=$e(Re("flowId")),tt=$e(Re("executionId"),Re("stepId"),Re("actionId")),nt=e=>({start:et((t=>U(e.post(c.start,{flowId:t})))),next:tt(((t,n,r,o)=>U(e.post(c.next,{executionId:t,stepId:n,actionId:r,input:o}))))}),rt=$e(Re("tenant")),ot=e=>Object.assign({start:rt(((t,n,{redirect:o=!1}={})=>l(void 0,void 0,void 0,(function*(){const i=yield e.get(r.start,{queryParams:{tenant:t,redirectURL:n}});if(!o||!i.ok)return U(Promise.resolve(i));const{url:s}=yield i.json();window.location.href=s}))))},We(e)),it=Re("identifier"),st=$e(it,Re("code")),at=$e(it),ct=$e(it),ut=e=>({signUp:at(((t,n)=>U(e.post(o.signUp,{externalId:t,user:n})))),verify:st(((t,n)=>U(e.post(o.verify,{externalId:t,code:n})))),update:ct(((t,n)=>U(e.post(o.update,{externalId:t},{token:n}))))}),dt=Re("identifier"),pt=Re("origin"),lt=$e(dt,pt,Re("name")),ft=$e(dt,pt),ht=$e(dt,pt,Re("token")),gt=$e(Re("transactionId"),Re("response")),vt=e=>({signUp:{start:lt(((t,n,r)=>U(e.post(i.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:gt(((t,n)=>U(e.post(i.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ft(((t,n)=>U(e.post(i.signIn.start,{externalId:t,origin:n})))),finish:gt(((t,n)=>U(e.post(i.signIn.finish,{transactionId:t,response:n}))))},add:{start:ht(((t,n,r)=>U(e.post(i.add.start,{externalId:t,origin:n},{token:r})))),finish:gt(((t,n)=>U(e.post(i.add.finish,{transactionId:t,response:n}))))}}),yt=$e(Re("token"));var bt,mt;return $e([(bt="projectId",mt=Re("projectId"),$(((e,t)=>n=>R(...t).validate(je(n,e)))(bt,mt))())])((({projectId:e,logger:t,baseUrl:n})=>{return r=m({baseUrl:n||"https://api.descope.com",projectId:e,logger:t}),{otp:Le(r),magicLink:Qe(r),oauth:Ye(r),saml:ot(r),totp:ut(r),webauthn:vt(r),flow:nt(r),refresh:e=>U(r.get(s,{token:e})),logout:e=>U(r.get(a,{token:e})),isJwtExpired:yt(w),httpClient:r};var r}))})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@descope/core-js-sdk", | ||
"version": "0.0.41-alpha.6", | ||
"version": "0.0.41-alpha.7", | ||
"main": "dist/index.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.esm.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
244100
10