@descope/core-js-sdk
Advanced tools
Comparing version 0.0.41-alpha.39 to 0.0.41-alpha.40
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jwt-decode"),t=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e),a=n(t),i={exchange:"/v1/auth/accesskey/exchange"},o={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},p={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},d={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},c={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},l={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},h="/v1/auth/refresh",g="/v1/auth/logout",v="/v1/auth/logoutall",f="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};const k=()=>{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")}},I=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>k().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),k().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const y=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,s])=>(e[n]=s,e)),e),e}),{})),O=e=>void 0===e?void 0:JSON.stringify(e),x=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},w=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=I(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:p,headers:d,queryParams:c,method:l,token:h}=r,g=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:c}),{headers:y(x(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.39"},(null==n?void 0:n.baseHeaders)||{},d),method:l,body:O(p),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:a}),hooks:a}};function j(e,t,n){var s;let a=U(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function U(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=U(e);return(new Date).getTime()/1e3>t}function R(e,t){return j(e,t,"permissions")}function q(e,t){return j(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,s}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),T=e=>t=>e.test(t),A=T(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),L=T(/^\+[1-9]{1}[0-9]{3,14}$/),z=M(A,'"{val}" is not a valid email'),J=M(L,'"{val}" is not a valid phone number'),H=M((C=1,e=>e.length>=C),"Minimum length is 1");var C;const D=M((e=>"string"==typeof e),"Input is not a string"),N=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Z=e=>[D(`"${e}" must be a string`),H(`"${e}" must not be empty`)],_=e=>[D(`"${e}" must be a string`),z()],B=e=>[D(`"${e}" must be a string`),J()],K=N(Z("accessKey")),F=e=>({exchange:K((t=>E(e.post(i.exchange,{},{token:t}))))});var G,W,Q,V,X;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(W||(W={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Q||(Q={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(X||(X={}));const Y=Z("identifier"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),ae=e=>({verify:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>E(e.post($(o.verify,n),{code:s,externalId:t}))))})),{}),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,a)=>E(e.post($(o.signIn,n),{externalId:t,loginOptions:s},{token:a}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>E(e.post($(o.signUp,n),{externalId:t,user:s}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>E(e.post($(o.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:se(((t,n,s)=>E(e.post(o.update.email,{externalId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,a)=>E(e.post($(o.update.phone,n),{externalId:t,phone:s},{token:a}))))})),{})}}),ie=Z("identifier"),oe=Z("uri"),re=N(Z("token")),ue=N(ie,oe),pe=N(ie,B("phone"),oe),de=N(ie,_("email"),oe),ce=e=>({verify:re((t=>E(e.post(r.verify,{token:t})))),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,a,i)=>E(e.post($(r.signIn,n),{externalId:t,URI:s,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,a)=>E(e.post($(r.signUp,n),{externalId:t,URI:s,user:a}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>E(e.post($(r.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:de(((t,n,s,a)=>E(e.post(r.update.email,{externalId:t,email:n,URI:s},{token:a})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,a,i)=>E(e.post($(r.update.phone,n),{externalId:t,phone:s,URI:a},{token:i}))))})),{})}}),le=Z("identifier"),he=Z("uri"),ge=N(Z("token")),ve=N(le,he),fe=N(Z("pendingRef")),me=N(le,_("email"),he),ke=e=>({verify:ge((t=>E(e.post(u.verify,{token:t})))),signIn:ve(((t,n,s,a)=>E(e.post($(u.signIn,W.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:ve(((t,n)=>E(e.post($(u.signUpOrIn,W.email),{externalId:t,URI:n})))),signUp:ve(((t,n,s)=>E(e.post($(u.signUp,W.email),{externalId:t,URI:n,user:s})))),waitForSession:fe(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let o;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),o&&clearTimeout(o),s(E(Promise.resolve(n))))}),a);o=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,a)=>E(e.post(u.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var Ie;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(Ie||(Ie={}));const be=N(Z("code")),ye=e=>({start:Object.keys(Ie).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const o=await e.post(p.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!o.ok)return E(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r}})),{}),exchange:be((t=>E(e.post(p.exchange,{code:t}))))}),Oe=N(Z("flowId")),xe=N(Z("executionId"),Z("stepId"),Z("interactionId")),we=e=>({start:Oe(((t,n,s,a)=>E(e.post(m.start,{flowId:t,options:n,interactionId:s,input:a})))),next:xe(((t,n,s,a)=>E(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),je=N(Z("tenant")),Ue=N(Z("code")),Pe=e=>({start:je((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(d.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return E(Promise.resolve(o));const{url:r}=await o.json();window.location.href=r})),exchange:Ue((t=>E(e.post(d.exchange,{code:t}))))}),Re=Z("identifier"),qe=N(Re,Z("code")),$e=N(Re),Ee=N(Re),Me=e=>({signUp:$e(((t,n)=>E(e.post(c.signUp,{externalId:t,user:n})))),verify:qe(((t,n,s,a)=>E(e.post(c.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Ee(((t,n)=>E(e.post(c.update,{externalId:t},{token:n}))))}),Se=Z("identifier"),Te=Z("origin"),Ae=N(Se,Te,Z("name")),Le=N(Se,Te),ze=N(Se,Te,Z("token")),Je=N(Z("transactionId"),Z("response")),He=e=>({signUp:{start:Ae(((t,n,s)=>E(e.post(l.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Je(((t,n)=>E(e.post(l.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Le(((t,n,s,a)=>E(e.post(l.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Je(((t,n)=>E(e.post(l.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Le(((t,n)=>E(e.post(l.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:ze(((t,n,s)=>E(e.post(l.update.start,{externalId:t,origin:n},{token:s})))),finish:Je(((t,n)=>E(e.post(l.update.finish,{transactionId:t,response:n}))))}}),Ce=N(Z("token"));var De,Ne;var Ze=N([(De="projectId",Ne=Z("projectId"),M(((e,t)=>n=>S(...t).validate(a.default(n,e)))(De,Ne))())])((e=>t=>{var n,s;const a=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==a?void 0:a.reduce(((e,t)=>t(e)),e),afterRequest:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=w({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:F(i),otp:ae(i),magicLink:ce(i),enchantedLink:ke(i),oauth:ye(i),saml:Pe(i),totp:Me(i),webauthn:He(i),flow:we(i),refresh:e=>E(i.post(h,{},{token:e})),logout:e=>E(i.post(g,{},{token:e})),logoutAll:e=>E(i.post(v,{},{token:e})),me:e=>E(i.get(f,{token:e})),isJwtExpired:Ce(P),getJwtPermissions:Ce(R),getJwtRoles:Ce(q),httpClient:i};var i})));var _e=Object.assign(Ze,{DeliveryMethods:W});exports.addHooksToConfig=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var a;return n[s]=[].concat((null===(a=e.hooks)||void 0===a?void 0:a[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},exports.default=_e,exports.transformResponse=E,exports.wrapWith=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let a=s.shift(),i=e;for(;s.length>0;){if(i=i[a],!a||!i)throw Error(`Invalid path "${t}", "${a}" is missing or has no value`);a=s.shift()}if("function"!=typeof i[a])throw Error(`"${t}" is not a function`);const o=i[a];i[a]=n(o)})),e); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jwt-decode"),t=require("lodash.get");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e),o=n(t),i={exchange:"/v1/auth/accesskey/exchange"},a={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},r={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},u={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},p={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},d={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},c={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},l={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},g="/v1/auth/refresh",h="/v1/auth/logout",v="/v1/auth/logoutall",f="/v1/auth/me",m={start:"/v1/flow/start",next:"/v1/flow/next"};const I=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},k=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>I().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),I().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(b||(b={}));const y=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,s])=>(e[n]=s,e)),e),e}),{})),O=e=>void 0===e?void 0:JSON.stringify(e),w=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=k(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:p,headers:d,queryParams:c,method:l,token:g}=r,h=await a((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:c}),{headers:y(w(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.40"},(null==n?void 0:n.baseHeaders)||{},d),method:l,body:O(p),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:b.delete,token:o}),hooks:o}};function U(e,t,n){var s;let o=x(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return s.default(e)}function P(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function R(e,t){return U(e,t,"permissions")}function q(e,t){return U(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function E(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const M=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),T=e=>t=>e.test(t),A=T(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),L=T(/^\+[1-9]{1}[0-9]{3,14}$/),z=M(A,'"{val}" is not a valid email'),J=M(L,'"{val}" is not a valid phone number'),H=M((C=1,e=>e.length>=C),"Minimum length is 1");var C;const D=M((e=>"string"==typeof e),"Input is not a string"),N=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Z=e=>[D(`"${e}" must be a string`),H(`"${e}" must not be empty`)],_=e=>[D(`"${e}" must be a string`),z()],B=e=>[D(`"${e}" must be a string`),J()],K=N(Z("accessKey")),F=e=>({exchange:K((t=>E(e.post(i.exchange,{},{token:t}))))});var G,W,Q,V,X;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(G||(G={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(W||(W={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Q||(Q={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(V||(V={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(X||(X={}));const Y=Z("loginId"),ee=N(Y,Z("code")),te=N(Y),ne=N(Y,B("phone")),se=N(Y,_("email")),oe=e=>({verify:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ee(((t,s)=>E(e.post($(a.verify,n),{code:s,loginId:t}))))})),{}),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s,o)=>E(e.post($(a.signIn,n),{loginId:t,loginOptions:s},{token:o}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te(((t,s)=>E(e.post($(a.signUp,n),{loginId:t,user:s}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:te((t=>E(e.post($(a.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:se(((t,n,s)=>E(e.post(a.update.email,{loginId:t,email:n},{token:s})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ne(((t,s,o)=>E(e.post($(a.update.phone,n),{loginId:t,phone:s},{token:o}))))})),{})}}),ie=Z("loginId"),ae=Z("uri"),re=N(Z("token")),ue=N(ie,ae),pe=N(ie,B("phone"),ae),de=N(ie,_("email"),ae),ce=e=>({verify:re((t=>E(e.post(r.verify,{token:t})))),signIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o,i)=>E(e.post($(r.signIn,n),{loginId:t,URI:s,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s,o)=>E(e.post($(r.signUp,n),{loginId:t,URI:s,user:o}))))})),{}),signUpOrIn:Object.keys(W).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ue(((t,s)=>E(e.post($(r.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:de(((t,n,s,o)=>E(e.post(r.update.email,{loginId:t,email:n,URI:s},{token:o})))),phone:Object.keys(G).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pe(((t,s,o,i)=>E(e.post($(r.update.phone,n),{loginId:t,phone:s,URI:o},{token:i}))))})),{})}}),le=Z("loginId"),ge=Z("uri"),he=N(Z("token")),ve=N(le,ge),fe=N(Z("pendingRef")),me=N(le,_("email"),ge),Ie=e=>({verify:he((t=>E(e.post(u.verify,{token:t})))),signIn:ve(((t,n,s,o)=>E(e.post($(u.signIn,W.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:ve(((t,n)=>E(e.post($(u.signUpOrIn,W.email),{loginId:t,URI:n})))),signUp:ve(((t,n,s)=>E(e.post($(u.signUp,W.email),{loginId:t,URI:n,user:s})))),waitForSession:fe(((t,n)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let a;const r=setInterval((async()=>{const n=await e.post(u.session,{pendingRef:t});n.ok&&(clearInterval(r),a&&clearTimeout(a),s(E(Promise.resolve(n))))}),o);a=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(r)}),i)})))),update:{email:me(((t,n,s,o)=>E(e.post(u.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var ke;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(ke||(ke={}));const be=N(Z("code")),ye=e=>({start:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const a=await e.post(p.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r}})),{}),exchange:be((t=>E(e.post(p.exchange,{code:t}))))}),Oe=N(Z("flowId")),we=N(Z("executionId"),Z("stepId"),Z("interactionId")),je=e=>({start:Oe(((t,n,s,o)=>E(e.post(m.start,{flowId:t,options:n,interactionId:s,input:o})))),next:we(((t,n,s,o)=>E(e.post(m.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Ue=N(Z("tenant")),xe=N(Z("code")),Pe=e=>({start:Ue((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(d.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return E(Promise.resolve(a));const{url:r}=await a.json();window.location.href=r})),exchange:xe((t=>E(e.post(d.exchange,{code:t}))))}),Re=Z("loginId"),qe=N(Re,Z("code")),$e=N(Re),Ee=N(Re),Me=e=>({signUp:$e(((t,n)=>E(e.post(c.signUp,{loginId:t,user:n})))),verify:qe(((t,n,s,o)=>E(e.post(c.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Ee(((t,n)=>E(e.post(c.update,{loginId:t},{token:n}))))}),Se=Z("loginId"),Te=Z("origin"),Ae=N(Se,Te,Z("name")),Le=N(Se,Te),ze=N(Se,Te,Z("token")),Je=N(Z("transactionId"),Z("response")),He=e=>({signUp:{start:Ae(((t,n,s)=>E(e.post(l.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Je(((t,n)=>E(e.post(l.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Le(((t,n,s,o)=>E(e.post(l.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Je(((t,n)=>E(e.post(l.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Le(((t,n)=>E(e.post(l.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:ze(((t,n,s)=>E(e.post(l.update.start,{loginId:t,origin:n},{token:s})))),finish:Je(((t,n)=>E(e.post(l.update.finish,{transactionId:t,response:n}))))}}),Ce=N(Z("token"));var De,Ne;var Ze=N([(De="projectId",Ne=Z("projectId"),M(((e,t)=>n=>S(...t).validate(o.default(n,e)))(De,Ne))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o})=>{return i=j({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o}),{accessKey:F(i),otp:oe(i),magicLink:ce(i),enchantedLink:Ie(i),oauth:ye(i),saml:Pe(i),totp:Me(i),webauthn:He(i),flow:je(i),refresh:e=>E(i.post(g,{},{token:e})),logout:e=>E(i.post(h,{},{token:e})),logoutAll:e=>E(i.post(v,{},{token:e})),me:e=>E(i.get(f,{token:e})),isJwtExpired:Ce(P),getJwtPermissions:Ce(R),getJwtRoles:Ce(q),httpClient:i};var i})));var _e=Object.assign(Ze,{DeliveryMethods:W});exports.addHooksToConfig=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},exports.default=_e,exports.transformResponse=E,exports.wrapWith=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e); | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -8,3 +8,3 @@ declare type SdkFn$1 = (...args: any[]) => Promise<SdkResponse<ResponseData>>; | ||
oauthProvider?: string; | ||
externalId?: string; | ||
loginId?: string; | ||
}; | ||
@@ -144,4 +144,4 @@ declare type AuthMethod = 'otp' | 'magiclink' | 'social' | 'sso' | 'webauthn' | 'totp'; | ||
declare type EnchantedLinkSignInFn = (identifier: string, uri: string) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
declare type EnchantedLinkSignUpFn = (identifier: string, uri: string, user?: User) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
declare type EnchantedLinkSignInFn = (loginId: string, uri: string) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
declare type EnchantedLinkSignUpFn = (loginId: string, uri: string, user?: User) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
/** Polling configuration for session waiting */ | ||
@@ -153,5 +153,5 @@ declare type WaitForSessionConfig = { | ||
declare type SignInFn = (identifier: string, uri: string) => Promise<SdkResponse<never>>; | ||
declare type SignUpFn = (identifier: string, uri: string, user?: User) => Promise<SdkResponse<never>>; | ||
declare type UpdatePhoneFn = (identifier: string, phone: string) => Promise<SdkResponse<never>>; | ||
declare type SignInFn = (loginId: string, uri: string) => Promise<SdkResponse<never>>; | ||
declare type SignUpFn = (loginId: string, uri: string, user?: User) => Promise<SdkResponse<never>>; | ||
declare type UpdatePhoneFn = (loginId: string, phone: string) => Promise<SdkResponse<never>>; | ||
@@ -295,4 +295,4 @@ /** Request configuration including headers, query params and token */ | ||
* | ||
* const userIdentifier = 'identifier'; | ||
* sdk.otp.signIn.email(userIdentifier); | ||
* const userLoginId = 'loginId'; | ||
* sdk.otp.signIn.email(userLoginId); | ||
* const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail); | ||
@@ -317,9 +317,9 @@ * ``` | ||
otp: { | ||
verify: Deliveries<(identifier: string, code: string) => Promise<SdkResponse<JWTResponse>>>; | ||
signIn: Deliveries<(identifier: string) => Promise<SdkResponse<never>>>; | ||
signUp: Deliveries<(identifier: string, user?: User) => Promise<SdkResponse<never>>>; | ||
signUpOrIn: Deliveries<(identifier: string) => Promise<SdkResponse<never>>>; | ||
verify: Deliveries<(loginId: string, code: string) => Promise<SdkResponse<JWTResponse>>>; | ||
signIn: Deliveries<(loginId: string) => Promise<SdkResponse<never>>>; | ||
signUp: Deliveries<(loginId: string, user?: User) => Promise<SdkResponse<never>>>; | ||
signUpOrIn: Deliveries<(loginId: string) => Promise<SdkResponse<never>>>; | ||
update: { | ||
email: (identifier: string, email: string, token?: string) => Promise<SdkResponse<never>>; | ||
phone: Deliveries<(identifier: string, phone: string) => Promise<SdkResponse<never>>>; | ||
email: (loginId: string, email: string, token?: string) => Promise<SdkResponse<never>>; | ||
phone: Deliveries<(loginId: string, phone: string) => Promise<SdkResponse<never>>>; | ||
}; | ||
@@ -333,3 +333,3 @@ }; | ||
update: { | ||
email: (identifier: string, email: string, uri: string, token?: string) => Promise<SdkResponse<never>>; | ||
email: (loginId: string, email: string, uri: string, token?: string) => Promise<SdkResponse<never>>; | ||
phone: Deliveries<UpdatePhoneFn>; | ||
@@ -345,3 +345,3 @@ }; | ||
update: { | ||
email: (identifier: string, email: string, uri: string, token?: string) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
email: (loginId: string, email: string, uri: string, token?: string) => Promise<SdkResponse<EnchantedLinkResponse>>; | ||
}; | ||
@@ -393,20 +393,20 @@ }; | ||
totp: { | ||
signUp: (identifier: string, user?: User) => Promise<SdkResponse<TOTPResponse>>; | ||
verify: (identifier: string, code: string, loginOptions?: LoginOptions, token?: string) => Promise<SdkResponse<JWTResponse>>; | ||
update: (identifier: string, token?: string) => Promise<SdkResponse<TOTPResponse>>; | ||
signUp: (loginId: string, user?: User) => Promise<SdkResponse<TOTPResponse>>; | ||
verify: (loginId: string, code: string, loginOptions?: LoginOptions, token?: string) => Promise<SdkResponse<JWTResponse>>; | ||
update: (loginId: string, token?: string) => Promise<SdkResponse<TOTPResponse>>; | ||
}; | ||
webauthn: { | ||
signUp: { | ||
start: (identifier: string, origin: string, name: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
start: (loginId: string, origin: string, name: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
finish: (transactionId: string, response: string) => Promise<SdkResponse<JWTResponse>>; | ||
}; | ||
signIn: { | ||
start: (identifier: string, origin: string, loginOptions?: LoginOptions, token?: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
start: (loginId: string, origin: string, loginOptions?: LoginOptions, token?: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
finish: (transactionId: string, response: string) => Promise<SdkResponse<JWTResponse>>; | ||
}; | ||
signUpOrIn: { | ||
start: (identifier: string, origin: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
start: (loginId: string, origin: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
}; | ||
update: { | ||
start: (identifier: string, origin: string, token: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
start: (loginId: string, origin: string, token: string) => Promise<SdkResponse<WebAuthnStartResponse>>; | ||
finish: (transactionId: string, response: string) => Promise<SdkResponse<ResponseData>>; | ||
@@ -413,0 +413,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import e from"jwt-decode";import t from"lodash.get";var n={exchange:"/v1/auth/accesskey/exchange"},s={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},a={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},o={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},u={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},c={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},p="/v1/auth/refresh",d="/v1/auth/logout",l="/v1/auth/logoutall",h="/v1/auth/me",g={start:"/v1/flow/start",next:"/v1/flow/next"};const v=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>v().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),v().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var m;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(m||(m={}));const k=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,s])=>(e[n]=s,e)),e),e}),{})),I=e=>void 0===e?void 0:JSON.stringify(e),b=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:a,cookiePolicy:i})=>{const o=f(s),r=async s=>{const r=(null==a?void 0:a.beforeRequest)?a.beforeRequest(s):s,{path:u,body:c,headers:p,queryParams:d,method:l,token:h}=r,g=await o((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:d}),{headers:k(b(t,h),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.39"},(null==n?void 0:n.baseHeaders)||{},p),method:l,body:I(c),credentials:i||"include"});return(null==a?void 0:a.afterRequest)&&a.afterRequest(s,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:m.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.post,token:a}),put:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.put,token:a}),delete:(e,t,{headers:n,queryParams:s,token:a}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.delete,token:a}),hooks:a}};function O(e,t,n){var s;let a=w(e);t&&(a=null===(s=a.tenants)||void 0===s?void 0:s[t]);const i=a[n];return Array.isArray(i)?i:[]}function w(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function x(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function j(e,t){return O(e,t,"permissions")}function U(e,t){return O(e,t,"roles")}const P=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function R(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},a=await n.clone().json();return n.ok?s.data=t?t(a):a:s.error=a,s}const q=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),E=e=>t=>e.test(t),M=E(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),S=E(/^\+[1-9]{1}[0-9]{3,14}$/),A=q(M,'"{val}" is not a valid email'),T=q(S,'"{val}" is not a valid phone number'),L=q((z=1,e=>e.length>=z),"Minimum length is 1");var z;const J=q((e=>"string"==typeof e),"Input is not a string"),H=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>$(...e).validate(n[t]))),t(...n)),C=e=>[J(`"${e}" must be a string`),L(`"${e}" must not be empty`)],D=e=>[J(`"${e}" must be a string`),A()],N=e=>[J(`"${e}" must be a string`),T()],Z=H(C("accessKey")),B=e=>({exchange:Z((t=>R(e.post(n.exchange,{},{token:t}))))});var K,F,G,_,Q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(F||(F={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(_||(_={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Q||(Q={}));const V=C("identifier"),W=H(V,C("code")),X=H(V),Y=H(V,N("phone")),ee=H(V,D("email")),te=e=>({verify:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,a)=>R(e.post(P(s.verify,n),{code:a,externalId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a,i)=>R(e.post(P(s.signIn,n),{externalId:t,loginOptions:a},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,a)=>R(e.post(P(s.signUp,n),{externalId:t,user:a}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{externalId:t}))))})),{}),update:{email:ee(((t,n,a)=>R(e.post(s.update.email,{externalId:t,email:n},{token:a})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,a,i)=>R(e.post(P(s.update.phone,n),{externalId:t,phone:a},{token:i}))))})),{})}}),ne=C("identifier"),se=C("uri"),ae=H(C("token")),ie=H(ne,se),oe=H(ne,N("phone"),se),re=H(ne,D("email"),se),ue=e=>({verify:ae((t=>R(e.post(a.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,o)=>R(e.post(P(a.signIn,n),{externalId:t,URI:s,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(a.signUp,n),{externalId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s)=>R(e.post(P(a.signUpOrIn,n),{externalId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(e.post(a.update.email,{externalId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oe(((t,s,i,o)=>R(e.post(P(a.update.phone,n),{externalId:t,phone:s,URI:i},{token:o}))))})),{})}}),ce=C("identifier"),pe=C("uri"),de=H(C("token")),le=H(ce,pe),he=H(C("pendingRef")),ge=H(ce,D("email"),pe),ve=e=>({verify:de((t=>R(e.post(i.verify,{token:t})))),signIn:le(((t,n,s,a)=>R(e.post(P(i.signIn,F.email),{externalId:t,URI:n,loginOptions:s},{token:a})))),signUpOrIn:le(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{externalId:t,URI:n})))),signUp:le(((t,n,s)=>R(e.post(P(i.signUp,F.email),{externalId:t,URI:n,user:s})))),waitForSession:he(((t,n)=>new Promise((s=>{const{pollingIntervalMs:a,timeoutMs:o}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||6e5,6e5)}))(n);let r;const u=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(u),r&&clearTimeout(r),s(R(Promise.resolve(n))))}),a);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${o}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),o)})))),update:{email:ge(((t,n,s,a)=>R(e.post(i.update.email,{externalId:t,email:n,URI:s},{token:a}))))}});var fe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(fe||(fe={}));const me=H(C("code")),ke=e=>({start:Object.keys(fe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},a,i)=>{const r=await e.post(o.start,a||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return R(Promise.resolve(r));const{url:u}=await r.json();window.location.href=u}})),{}),exchange:me((t=>R(e.post(o.exchange,{code:t}))))}),Ie=H(C("flowId")),be=H(C("executionId"),C("stepId"),C("interactionId")),ye=e=>({start:Ie(((t,n,s,a)=>R(e.post(g.start,{flowId:t,options:n,interactionId:s,input:a})))),next:be(((t,n,s,a)=>R(e.post(g.next,{executionId:t,stepId:n,interactionId:s,input:a}))))}),Oe=H(C("tenant")),we=H(C("code")),xe=e=>({start:Oe((async(t,n,{redirect:s=!1}={},a,i)=>{const o=await e.post(r.start,a||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!o.ok)return R(Promise.resolve(o));const{url:u}=await o.json();window.location.href=u})),exchange:we((t=>R(e.post(r.exchange,{code:t}))))}),je=C("identifier"),Ue=H(je,C("code")),Pe=H(je),Re=H(je),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{externalId:t,user:n})))),verify:Ue(((t,n,s,a)=>R(e.post(u.verify,{externalId:t,code:n,loginOptions:s},{token:a})))),update:Re(((t,n)=>R(e.post(u.update,{externalId:t},{token:n}))))}),$e=C("identifier"),Ee=C("origin"),Me=H($e,Ee,C("name")),Se=H($e,Ee),Ae=H($e,Ee,C("token")),Te=H(C("transactionId"),C("response")),Le=e=>({signUp:{start:Me(((t,n,s)=>R(e.post(c.signUp.start,{user:{externalId:t,name:s},origin:n})))),finish:Te(((t,n)=>R(e.post(c.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Se(((t,n,s,a)=>R(e.post(c.signIn.start,{externalId:t,origin:n,loginOptions:s},{token:a})))),finish:Te(((t,n)=>R(e.post(c.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Se(((t,n)=>R(e.post(c.signUpOrIn.start,{externalId:t,origin:n}))))},update:{start:Ae(((t,n,s)=>R(e.post(c.update.start,{externalId:t,origin:n},{token:s})))),finish:Te(((t,n)=>R(e.post(c.update.finish,{transactionId:t,response:n}))))}}),ze=H(C("token"));var Je,He;var Ce=H([(Je="projectId",He=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(Je,He))())])((e=>t=>{var n,s;const a=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==a?void 0:a.reduce(((e,t)=>t(e)),e),afterRequest:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:a})=>{return i=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:a}),{accessKey:B(i),otp:te(i),magicLink:ue(i),enchantedLink:ve(i),oauth:ke(i),saml:xe(i),totp:qe(i),webauthn:Le(i),flow:ye(i),refresh:e=>R(i.post(p,{},{token:e})),logout:e=>R(i.post(d,{},{token:e})),logoutAll:e=>R(i.post(l,{},{token:e})),me:e=>R(i.get(h,{token:e})),isJwtExpired:ze(x),getJwtPermissions:ze(j),getJwtRoles:ze(U),httpClient:i};var i})));const De=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let a=s.shift(),i=e;for(;s.length>0;){if(i=i[a],!a||!i)throw Error(`Invalid path "${t}", "${a}" is missing or has no value`);a=s.shift()}if("function"!=typeof i[a])throw Error(`"${t}" is not a function`);const o=i[a];i[a]=n(o)})),e),Ne=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var a;return n[s]=[].concat((null===(a=e.hooks)||void 0===a?void 0:a[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e};var Ze=Object.assign(Ce,{DeliveryMethods:F});export{Ne as addHooksToConfig,Ze as default,R as transformResponse,De as wrapWith}; | ||
import e from"jwt-decode";import t from"lodash.get";var n={exchange:"/v1/auth/accesskey/exchange"},s={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},o={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},i={verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},a={start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange"},r={start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},u={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},c={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},p="/v1/auth/refresh",l="/v1/auth/logout",d="/v1/auth/logoutall",g="/v1/auth/me",h={start:"/v1/flow/start",next:"/v1/flow/next"};const v=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>v().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await(e.clone?e.clone().text():e.text());return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),v().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n};var m;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(m||(m={}));const I=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,s])=>(e[n]=s,e)),e),e}),{})),k=e=>void 0===e?void 0:JSON.stringify(e),b=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},y=({baseUrl:e,projectId:t,baseConfig:n,logger:s,hooks:o,cookiePolicy:i})=>{const a=f(s),r=async s=>{const r=(null==o?void 0:o.beforeRequest)?o.beforeRequest(s):s,{path:u,body:c,headers:p,queryParams:l,method:d,token:g}=r,h=await a((({path:e,baseUrl:t,queryParams:n})=>{const s=new URL(e,t);return n&&(s.search=new URLSearchParams(n).toString()),s})({path:u,baseUrl:e,queryParams:l}),{headers:I(b(t,g),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.40"},(null==n?void 0:n.baseHeaders)||{},p),method:d,body:k(c),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(s,null==h?void 0:h.clone()),h};return{get:(e,{headers:t,queryParams:n,token:s}={})=>r({path:e,headers:t,queryParams:n,body:void 0,method:m.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.post,token:o}),put:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.put,token:o}),delete:(e,t,{headers:n,queryParams:s,token:o}={})=>r({path:e,headers:n,queryParams:s,body:t,method:m.delete,token:o}),hooks:o}};function O(e,t,n){var s;let o=w(e);t&&(o=null===(s=o.tenants)||void 0===s?void 0:s[t]);const i=o[n];return Array.isArray(i)?i:[]}function w(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return e(t)}function j(e){const{exp:t}=w(e);return(new Date).getTime()/1e3>t}function U(e,t){return O(e,t,"permissions")}function x(e,t){return O(e,t,"roles")}const P=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function R(e,t){const n=await e,s={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?s.data=t?t(o):o:s.error=o,s}const q=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),E=e=>t=>e.test(t),M=E(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),S=E(/^\+[1-9]{1}[0-9]{3,14}$/),A=q(M,'"{val}" is not a valid email'),T=q(S,'"{val}" is not a valid phone number'),L=q((z=1,e=>e.length>=z),"Minimum length is 1");var z;const J=q((e=>"string"==typeof e),"Input is not a string"),H=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>$(...e).validate(n[t]))),t(...n)),C=e=>[J(`"${e}" must be a string`),L(`"${e}" must not be empty`)],D=e=>[J(`"${e}" must be a string`),A()],N=e=>[J(`"${e}" must be a string`),T()],Z=H(C("accessKey")),B=e=>({exchange:Z((t=>R(e.post(n.exchange,{},{token:t}))))});var K,F,G,_,Q;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(K||(K={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(F||(F={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(G||(G={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(_||(_={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Q||(Q={}));const V=C("loginId"),W=H(V,C("code")),X=H(V),Y=H(V,N("phone")),ee=H(V,D("email")),te=e=>({verify:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:W(((t,o)=>R(e.post(P(s.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o,i)=>R(e.post(P(s.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X(((t,o)=>R(e.post(P(s.signUp,n),{loginId:t,user:o}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:X((t=>R(e.post(P(s.signUpOrIn,n),{loginId:t}))))})),{}),update:{email:ee(((t,n,o)=>R(e.post(s.update.email,{loginId:t,email:n},{token:o})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Y(((t,o,i)=>R(e.post(P(s.update.phone,n),{loginId:t,phone:o},{token:i}))))})),{})}}),ne=C("loginId"),se=C("uri"),oe=H(C("token")),ie=H(ne,se),ae=H(ne,N("phone"),se),re=H(ne,D("email"),se),ue=e=>({verify:oe((t=>R(e.post(o.verify,{token:t})))),signIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i,a)=>R(e.post(P(o.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:a}))))})),{}),signUp:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s,i)=>R(e.post(P(o.signUp,n),{loginId:t,URI:s,user:i}))))})),{}),signUpOrIn:Object.keys(F).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ie(((t,s)=>R(e.post(P(o.signUpOrIn,n),{loginId:t,URI:s}))))})),{}),update:{email:re(((t,n,s,i)=>R(e.post(o.update.email,{loginId:t,email:n,URI:s},{token:i})))),phone:Object.keys(K).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ae(((t,s,i,a)=>R(e.post(P(o.update.phone,n),{loginId:t,phone:s,URI:i},{token:a}))))})),{})}}),ce=C("loginId"),pe=C("uri"),le=H(C("token")),de=H(ce,pe),ge=H(C("pendingRef")),he=H(ce,D("email"),pe),ve=e=>({verify:le((t=>R(e.post(i.verify,{token:t})))),signIn:de(((t,n,s,o)=>R(e.post(P(i.signIn,F.email),{loginId:t,URI:n,loginOptions:s},{token:o})))),signUpOrIn:de(((t,n)=>R(e.post(P(i.signUpOrIn,F.email),{loginId:t,URI:n})))),signUp:de(((t,n,s)=>R(e.post(P(i.signUp,F.email),{loginId:t,URI:n,user:s})))),waitForSession:ge(((t,n)=>new Promise((s=>{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 r;const u=setInterval((async()=>{const n=await e.post(i.session,{pendingRef:t});n.ok&&(clearInterval(u),r&&clearTimeout(r),s(R(Promise.resolve(n))))}),o);r=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${a}ms`,errorCode:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:he(((t,n,s,o)=>R(e.post(i.update.email,{loginId:t,email:n,URI:s},{token:o}))))}});var fe;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(fe||(fe={}));const me=H(C("code")),Ie=e=>({start:Object.keys(fe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:s=!1}={},o,i)=>{const r=await e.post(a.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i});if(!s||!r.ok)return R(Promise.resolve(r));const{url:u}=await r.json();window.location.href=u}})),{}),exchange:me((t=>R(e.post(a.exchange,{code:t}))))}),ke=H(C("flowId")),be=H(C("executionId"),C("stepId"),C("interactionId")),ye=e=>({start:ke(((t,n,s,o)=>R(e.post(h.start,{flowId:t,options:n,interactionId:s,input:o})))),next:be(((t,n,s,o)=>R(e.post(h.next,{executionId:t,stepId:n,interactionId:s,input:o}))))}),Oe=H(C("tenant")),we=H(C("code")),je=e=>({start:Oe((async(t,n,{redirect:s=!1}={},o,i)=>{const a=await e.post(r.start,o||{},{queryParams:{tenant:t,redirectURL:n},token:i});if(!s||!a.ok)return R(Promise.resolve(a));const{url:u}=await a.json();window.location.href=u})),exchange:we((t=>R(e.post(r.exchange,{code:t}))))}),Ue=C("loginId"),xe=H(Ue,C("code")),Pe=H(Ue),Re=H(Ue),qe=e=>({signUp:Pe(((t,n)=>R(e.post(u.signUp,{loginId:t,user:n})))),verify:xe(((t,n,s,o)=>R(e.post(u.verify,{loginId:t,code:n,loginOptions:s},{token:o})))),update:Re(((t,n)=>R(e.post(u.update,{loginId:t},{token:n}))))}),$e=C("loginId"),Ee=C("origin"),Me=H($e,Ee,C("name")),Se=H($e,Ee),Ae=H($e,Ee,C("token")),Te=H(C("transactionId"),C("response")),Le=e=>({signUp:{start:Me(((t,n,s)=>R(e.post(c.signUp.start,{user:{loginId:t,name:s},origin:n})))),finish:Te(((t,n)=>R(e.post(c.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Se(((t,n,s,o)=>R(e.post(c.signIn.start,{loginId:t,origin:n,loginOptions:s},{token:o})))),finish:Te(((t,n)=>R(e.post(c.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Se(((t,n)=>R(e.post(c.signUpOrIn.start,{loginId:t,origin:n}))))},update:{start:Ae(((t,n,s)=>R(e.post(c.update.start,{loginId:t,origin:n},{token:s})))),finish:Te(((t,n)=>R(e.post(c.update.finish,{transactionId:t,response:n}))))}}),ze=H(C("token"));var Je,He;var Ce=H([(Je="projectId",He=C("projectId"),q(((e,n)=>s=>$(...n).validate(t(s,e)))(Je,He))())])((e=>t=>{var n,s;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]),i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>null==o?void 0:o.reduce(((e,t)=>t(e)),e),afterRequest:(e,t)=>{null==i||i.forEach((n=>n(e,null==t?void 0:t.clone())))}}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:o})=>{return i=y({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:s,cookiePolicy:o}),{accessKey:B(i),otp:te(i),magicLink:ue(i),enchantedLink:ve(i),oauth:Ie(i),saml:je(i),totp:qe(i),webauthn:Le(i),flow:ye(i),refresh:e=>R(i.post(p,{},{token:e})),logout:e=>R(i.post(l,{},{token:e})),logoutAll:e=>R(i.post(d,{},{token:e})),me:e=>R(i.get(g,{token:e})),isJwtExpired:ze(j),getJwtPermissions:ze(U),getJwtRoles:ze(x),httpClient:i};var i})));const De=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let o=s.shift(),i=e;for(;s.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=s.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const a=i[o];i[o]=n(a)})),e),Ne=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var o;return n[s]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e};var Ze=Object.assign(Ce,{DeliveryMethods:F});export{Ne as addHooksToConfig,Ze as default,R as transformResponse,De as wrapWith}; | ||
//# sourceMappingURL=index.esm.js.map |
{ | ||
"name": "@descope/core-js-sdk", | ||
"version": "0.0.41-alpha.39", | ||
"version": "0.0.41-alpha.40", | ||
"main": "dist/cjs/index.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.esm.js", |
@@ -21,5 +21,5 @@ # @descope/core-js-sdk | ||
const userIdentifier = 'identifier'; | ||
const loginId = 'loginId'; | ||
sdk.otp.signIn.email(userIdentifier); | ||
sdk.otp.signIn.email(loginId); | ||
``` |
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
188822
517