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