@descope/web-component
Advanced tools
Comparing version 0.1.0-alpha.7 to 0.1.0-alpha.8
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(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())}))}function r(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function o(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function i(e){this.message=e}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var s="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,s=0,a="";r=t.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function a(e){this.message=e}function c(e,t){if("string"!=typeof e)throw new a("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(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(s(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 s(t)}}(e.split(".")[n]))}catch(e){throw new a("Invalid token specified: "+e.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d="__lodash_hash_undefined__",h="[object Function]",p="[object GeneratorFunction]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,v=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,w=/^\[object .+?Constructor\]$/,m="object"==typeof u&&u&&u.Object===Object&&u,k="object"==typeof self&&self&&self.Object===Object&&self,O=m||k||Function("return this")();var I,j=Array.prototype,x=Function.prototype,S=Object.prototype,_=O["__core-js_shared__"],E=(I=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",U=x.toString,P=S.hasOwnProperty,R=S.toString,C=RegExp("^"+U.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=O.Symbol,A=j.splice,D=H(O,"Map"),M=H(Object,"create"),L=T?T.prototype:void 0,N=L?L.toString:void 0;function q(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 $(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 J(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 K(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 W(e,t){var n;t=function(e,t){if(V(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||X(e))return!0;return g.test(e)||!f.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:V(n=t)?n:z(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[G(t[r++])];return r&&r==o?e:void 0}function B(e){if(!Q(e)||(t=e,E&&E in t))return!1;var t,n=function(e){var t=Q(e)?R.call(e):"";return t==h||t==p}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?C:w;return n.test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function F(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 H(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return B(n)?n:void 0}q.prototype.clear=function(){this.__data__=M?M(null):{}},q.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},q.prototype.get=function(e){var t=this.__data__;if(M){var n=t[e];return n===d?void 0:n}return P.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return M?void 0!==t[e]:P.call(t,e)},q.prototype.set=function(e,t){return this.__data__[e]=M&&void 0===t?d:t,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(e){var t=this.__data__,n=K(t,e);return!(n<0)&&(n==t.length-1?t.pop():A.call(t,n,1),!0)},$.prototype.get=function(e){var t=this.__data__,n=K(t,e);return n<0?void 0:t[n][1]},$.prototype.has=function(e){return K(this.__data__,e)>-1},$.prototype.set=function(e,t){var n=this.__data__,r=K(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},J.prototype.clear=function(){this.__data__={hash:new q,map:new(D||$),string:new q}},J.prototype.delete=function(e){return F(this,e).delete(e)},J.prototype.get=function(e){return F(this,e).get(e)},J.prototype.has=function(e){return F(this,e).has(e)},J.prototype.set=function(e,t){return F(this,e).set(e,t),this};var z=Z((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(X(e))return N?N.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return v.test(e)&&n.push(""),e.replace(b,(function(e,t,r,o){n.push(r?o.replace(y,"$1"):t||e)})),n}));function G(e){if("string"==typeof e||X(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Z(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(Z.Cache||J),n}Z.Cache=J;var V=Array.isArray;function Q(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function X(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==R.call(e)}var Y,ee=function(e,t,n){var r=null==e?void 0:W(e,t);return void 0===r?n:r},te="/v1/auth/accesskey/exchange",ne="/v1/auth/otp/verify",re="/v1/auth/otp/signin",oe="/v1/auth/otp/signup",ie={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},se="/v1/auth/otp/signup-in",ae="/v1/auth/magiclink/verify",ce="/v1/auth/magiclink/signin",ue="/v1/auth/magiclink/signup",le="/v1/auth/magiclink/pending-session",de={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},he="/v1/auth/magiclink/signup-in",pe="/v1/auth/oauth/authorize",fe="/v1/auth/oauth/exchange",ge="/v1/auth/saml/authorize",ve="/v1/auth/saml/exchange",be="/v1/auth/totp/verify",ye="/v1/auth/totp/signup",we="/v1/user/totp/update",me={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ke={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Oe={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Ie="/v1/flow/start",je="/v1/flow/next";!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(Y||(Y={}));const xe=()=>{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")}},Se=(...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}),{})),_e=e=>void 0===e?void 0:JSON.stringify(e),Ee=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ue=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const s=((e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>xe().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)),xe().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:d,method:h,token:p}=a,f=await s((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:e,queryParams:d}),{headers:Se(Ee(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.24"},(null==n?void 0:n.baseHeaders)||{},l),method:h,body:_e(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(e,{headers:t,queryParams:n,token:r}={})=>a({path:e,headers:t,queryParams:n,body:void 0,method:Y.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:Y.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:Y.put,token:o}),delete:(e,t,{headers:n,queryParams:r,token:o}={})=>a({path:e,headers:n,queryParams:r,body:t,method:Y.delete,token:o})}};function Pe(e,t,n){var r;let o=Re(e);t&&(o=null===(r=o.tenants)||void 0===r?void 0:r[t]);const i=o[n];return Array.isArray(i)?i:[]}function Re(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return c(e)}function Ce(e){const{exp:t}=Re(e);return(new Date).getTime()/1e3>t}function Te(e,t){return Pe(e,t,"permissions")}function Ae(e,t){return Pe(e,t,"roles")}const De=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Me(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}const Le=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Ne=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),qe=e=>t=>e.test(t),$e=qe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Je=qe(/^\+[1-9]{1}[0-9]{3,14}$/),Ke=Le($e,'"{val}" is not a valid email'),We=Le(Je,'"{val}" is not a valid phone number'),Be=Le((1,e=>e.length>=1),"Minimum length is 1");const Fe=Le((e=>"string"==typeof e),"Input is not a string"),He=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ne(...e).validate(n[t]))),t(...n)),ze=e=>[Fe(`"${e}" must be a string`),Be(`"${e}" must not be empty`)],Ge=e=>[Fe(`"${e}" must be a string`),Ke()],Ze=e=>[Fe(`"${e}" must be a string`),We()],Ve=He(ze("accessKey")),Qe=e=>({exchange:Ve((t=>Me(e.post(te,{},{token:t}))))});var Xe,Ye,et,tt,nt;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Xe||(Xe={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(Ye||(Ye={})),function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(et||(et={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(tt||(tt={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(nt||(nt={}));const rt=ze("identifier"),ot=He(rt,ze("code")),it=He(rt),st=He(rt,Ze("phone")),at=He(rt,Ge("email")),ct=e=>({verify:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ot(((t,r,o,i)=>Me(e.post(De(ne,n),{code:r,externalId:t,loginOptions:o},{token:i}))))})),{}),signIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:it((t=>Me(e.post(De(re,n),{externalId:t}))))})),{}),signUp:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:it(((t,r)=>Me(e.post(De(oe,n),{externalId:t,user:r}))))})),{}),signUpOrIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:it((t=>Me(e.post(De(se,n),{externalId:t}))))})),{}),update:{email:at(((t,n,r)=>Me(e.post(ie.email,{externalId:t,email:n},{token:r})))),phone:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:st(((t,r,o)=>Me(e.post(De(ie.phone,n),{externalId:t,phone:r},{token:o}))))})),{})}}),ut=ze("identifier"),lt=ze("uri"),dt=He(ze("token")),ht=He(ut,lt),pt=He(ze("pendingRef")),ft=He(ut,Ze("phone"),lt),gt=He(ut,Ge("email"),lt),vt=e=>({verify:dt((t=>Me(e.post(ae,{token:t})))),signIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r)=>Me(e.post(De(ce,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r)=>Me(e.post(De(he,n),{externalId:t,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r,o)=>Me(e.post(De(ue,n),{externalId:t,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:pt(((t,n)=>new Promise((r=>{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 s;const a=setInterval((async()=>{const n=await e.post(le,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Me(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:gt(((t,n,r,o)=>Me(e.post(de.email,{externalId:t,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,r,o,i)=>Me(e.post(De(de.phone,n),{externalId:t,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),bt=e=>({verify:dt((t=>Me(e.post(ae,{token:t})))),signIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r)=>Me(e.post(De(ce,n),{externalId:t,URI:r}))))})),{}),signUp:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r,o)=>Me(e.post(De(ue,n),{externalId:t,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ht(((t,r)=>Me(e.post(De(he,n),{externalId:t,URI:r}))))})),{}),update:{email:gt(((t,n,r,o)=>Me(e.post(de.email,{externalId:t,email:n,URI:r},{token:o})))),phone:Object.keys(Xe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,r,o,i)=>Me(e.post(De(de.phone,n),{externalId:t,phone:r,URI:o},{token:i}))))})),{})},crossDevice:vt(e)});var yt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(yt||(yt={}));const wt=He(ze("code")),mt=e=>({start:Object.keys(yt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:async(t,{redirect:r=!1}={})=>{const o=await e.post(pe,{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t})});if(!r||!o.ok)return Me(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{}),exchange:wt(((t,n,r)=>Me(e.post(fe,{code:t,loginOptions:n},{token:r}))))}),kt=He(ze("flowId")),Ot=He(ze("executionId"),ze("stepId"),ze("interactionId")),It=e=>({start:kt((t=>Me(e.post(Ie,{flowId:t})))),next:Ot(((t,n,r,o)=>Me(e.post(je,{executionId:t,stepId:n,interactionId:r,input:o}))))}),jt=He(ze("tenant")),xt=He(ze("code")),St=e=>({start:jt((async(t,n,{redirect:r=!1}={})=>{const o=await e.post(ge,{},{queryParams:{tenant:t,redirectURL:n}});if(!r||!o.ok)return Me(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i})),exchange:xt(((t,n,r)=>Me(e.post(ve,{code:t,loginOptions:n},{token:r}))))}),_t=ze("identifier"),Et=He(_t,ze("code")),Ut=He(_t),Pt=He(_t),Rt=e=>({signUp:Ut(((t,n)=>Me(e.post(ye,{externalId:t,user:n})))),verify:Et(((t,n,r,o)=>Me(e.post(be,{externalId:t,code:n,loginOptions:r},{token:o})))),update:Pt(((t,n)=>Me(e.post(we,{externalId:t},{token:n}))))}),Ct=ze("identifier"),Tt=ze("origin"),At=He(Ct,Tt,ze("name")),Dt=He(Ct,Tt),Mt=He(Ct,Tt,ze("token")),Lt=He(ze("transactionId"),ze("response")),Nt=e=>({signUp:{start:At(((t,n,r)=>Me(e.post(me.start,{user:{externalId:t,name:r},origin:n})))),finish:Lt(((t,n,r,o)=>Me(e.post(me.finish,{transactionId:t,response:n,loginOptions:r},{token:o}))))},signIn:{start:Dt(((t,n)=>Me(e.post(ke.start,{externalId:t,origin:n})))),finish:Lt(((t,n,r,o)=>Me(e.post(ke.finish,{transactionId:t,response:n,loginOptions:r},{token:o}))))},update:{start:Mt(((t,n,r)=>Me(e.post(Oe.start,{externalId:t,origin:n},{token:r})))),finish:Lt(((t,n)=>Me(e.post(Oe.finish,{transactionId:t,response:n}))))}}),qt=He(ze("token"));var $t;const Jt=He([("projectId",$t=ze("projectId"),Le(((e,t)=>e=>Ne(...t).validate(ee(e,"projectId")))(0,$t))())])((({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Ue({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r,cookiePolicy:o}),{accessKey:Qe(i),otp:ct(i),magicLink:bt(i),oauth:mt(i),saml:St(i),totp:Rt(i),webauthn:Nt(i),flow:It(i),refresh:e=>Me(i.post("/v1/auth/refresh",{},{token:e})),logout:e=>Me(i.post("/v1/auth/logoutall",{},{token:e})),deleteCookies:e=>Me(i.post("/v1/auth/deletecookies",{},{token:e})),me:e=>Me(i.get("/v1/auth/me",{token:e})),isJwtExpired:qt(Ce),getJwtPermissions:qt(Te),getJwtRoles:qt(Ae),httpClient:i};var i}));function Kt(e,t,n){return void 0===n&&(n=0),t(n).catch((function(r){if(n>=e.maxRetries||!e.shouldRetry(r))throw r;var o,i,s,a,c=(o=e.baseDelay,i=e.maxDelay,s=e.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,s)));return(a=c,new Promise((function(e){return setTimeout(e,a)}))).then((function(){return Kt(e,t,n+1)}))}))}Jt.DeliveryMethods=Ye;var Wt="Failed to load the JS script of the agent";function Bt(n){var r,o=n.scriptUrlPattern,i=n.token,s=n.apiKey,a=void 0===s?i:s,c=t(n,["scriptUrlPattern","token","apiKey"]),u=(r=n,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(r,"scriptUrlPattern")?o:void 0),l=[];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return Kt({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(e){return!(e instanceof Error&&"Blocked by CSP"===e.message)}},(function(){var e,t=new Date,n=function(){return l.push({startedAt:t,finishedAt:new Date})},r=function(e,t,n,r){var o,i=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),o)return function(){throw new Error("Blocked by CSP")}();throw e}))}))}(e=function(e,t){void 0===t&&(t="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.7.1"):t}))}(a,u),(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Wt))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}));return r.then(n,n),r}))})).then((function(){var t=window,n="__fpjs_p_l_b",r=t[n];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(t,n),"function"!=typeof(null==r?void 0:r.load))throw new Error(Wt);return r.load(e(e({},c),{ldi:{attempts:l}}))}))}var Ft={exports:{}},Ht={exports:{}};Ht.exports=function(){function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}function t(n,r){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=t+"="+n.write(o,t)+s}}function i(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],r={},o=0;o<t.length;o++){var i=t[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=n.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}}return Object.create({set:o,get:i,remove:function(t,n){o(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}return t({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}(),function(e){e.exports=Ht.exports}(Ft);var zt=l(Ft.exports);const Gt=e=>{const t=Bt({apiKey:e||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let e=sessionStorage.getItem("vsid");e||(e=(e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t.toString())})[e])("vsid")),e||(e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",e);const n=await t,r=await n.get({linkedId:e});sessionStorage.setItem("vrid",r.requestId)}catch(e){global.FB_DEBUG&&console.error(e)}}}};var Zt,Vt,Qt,Xt,Yt;const en=e=>Object.assign({},e);class tn{constructor(e){Zt.add(this),Vt.set(this,void 0),Qt.set(this,{}),Xt.set(this,0),o(this,Vt,e,"f")}get current(){return en(r(this,Vt,"f"))}update(e){const t=e;if(!((e,t)=>{const n=e&&Object.getOwnPropertyNames(e)||[],r=t&&Object.getOwnPropertyNames(t)||[];if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(e[o]!==t[o])return!1}return!0})(r(this,Vt,"f"),t)){const e=r(this,Vt,"f");o(this,Vt,t,"f"),Object.freeze(r(this,Vt,"f")),setTimeout((()=>{Object.values(r(this,Qt,"f")).forEach((n=>n(en(t),e)))}),0)}}subscribe(e){o(this,Xt,r(this,Xt,"f")+1,"f"),r(this,Qt,"f")[r(this,Xt,"f")]=e;const t=r(this,Xt,"f");return()=>r(this,Zt,"m",Yt).call(this,t.toString())}unsubscribeAll(){o(this,Qt,{},"f")}}Vt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakSet,Yt=function(e){r(this,Qt,"f")[e]&&delete r(this,Qt,"f")[e]};let nn=[];function rn(e,t,n){const r=function(e){const t=e.split(".");try{if(3===t.length){const t=JSON.parse(window.atob(e.split(".")[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(e){}return null}(t);if(r){let t;for(;t=nn.pop();)clearTimeout(t);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{e(n)}),o);nn.push(i)}}function on(e,t,n){!function(e,{cookiePath:t,cookieDomain:n,cookieExpiration:r}){e&&zt.set("DS",e,{path:t,domain:n,expires:r,sameSite:"None",secure:!0})}(e,n),function(e){localStorage&&e&&localStorage.setItem("DSR",e)}(t)}function sn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function an(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=un(n.publicKey.challenge),n.publicKey.user.id=un(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=un(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify(Object.assign(Object.assign({},n),{rawId:ln(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:ln(n.response.attestationObject),clientDataJSON:ln(n.response.clientDataJSON)})}));var n}async function cn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=un(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=un(e.id)})),n}(e);return n=await navigator.credentials.get(t),JSON.stringify(Object.assign(Object.assign({},n),{rawId:ln(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:ln(n.response.authenticatorData),clientDataJSON:ln(n.response.clientDataJSON),signature:ln(n.response.signature),userHandle:n.response.userHandle?ln(n.response.userHandle):void 0})}));var n}function un(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ln(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const dn="undefined"!=typeof window;var hn=e=>{var{autoRefresh:n=!0,persistTokens:r=!0}=e,o=t(e,["autoRefresh","persistTokens"]);dn?Gt(o.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const i=o;let s,a;const c=new tn({sessionToken:""}),u=new tn({});i.hooks={beforeRequest:e=>null==s?void 0:s(e),afterRequest:(e,t)=>null==a?void 0:a(e,t)};const l=Jt(i),d=Object.assign(Object.assign({},l),{webauthn:(h=l,{async signUp(e,t){const n=await h.webauthn.signUp.start(e,window.location.origin,t),r=await an(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(e){const t=await h.webauthn.signIn.start(e,window.location.origin),n=await cn(t.data.options);return await h.webauthn.signIn.finish(t.data.transactionId,n)},async update(e,t){const n=await h.webauthn.update.start(e,window.location.origin,t),r=await an(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:an,get:cn}}),onSessionTokenChange:e=>{var t;const n=null===(t=c.current)||void 0===t?void 0:t.sessionToken;return n&&e(n),c.subscribe((({sessionToken:t})=>{e(t)}))},onUserChange:e=>{const t=u.current;return t&&Object.entries(t).length>0&&e(t),u.subscribe((t=>{e(t)}))}});var h;return n&&(d.logout=(...e)=>{const t=sn(),n=[(null==e?void 0:e.shift())||t,...e],r=l.logout(...n);return localStorage&&localStorage.removeItem("DSR"),zt.remove("DS"),r}),s=e=>{var t;return e.queryParams=(t=e.queryParams,Object.assign(Object.assign({},t),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!e.token&&r&&(e.token=sn()),e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.5"}),e},(n||r)&&(a=(e,o)=>{!async function(e,n,r,o){try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const i=await(null==n?void 0:n.json());if(i){const n=function(e){return(null==e?void 0:e.authInfo)||e||{}}(i),{sessionJwt:s,refreshJwt:a,user:c}=n,u=t(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&on(s,a,u),s&&r.sessionToken.update({sessionToken:s}),c&&r.user.update(c),s&&a&&o.autoRefresh&&rn(e,s,a)}}catch(e){console.error("Could not set tokens from body",e)}}(d.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&d.refresh(),d};const pn=(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("base.content.url"))||"https://static.prod.descope.com/pages",fn="descope-login-flow",gn="code",vn="redirect",bn="poll",yn="webauthnCreate",wn="webauthnGet";function mn(e){return new URLSearchParams(window.location.search).get(e)}function kn(){return mn(fn)}function On(e){if(window.history.replaceState&&mn(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}var In;function jn(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e}`);return n[t||"text"]()}))}!function(e){e.backward="backward",e.forward="forward"}(In||(In={}));function xn(e,t){const n=new URL(pn);return n.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(n.pathname,e,t),n.toString()}function Sn(e,t){if(!Number.isNaN(e)&&!Number.isNaN(t))return e>t?In.forward:e<t?In.backward:void 0}const _n=()=>{const[e="",t=""]=(kn()||"").split("_");return{executionId:e,stepId:t}},En=(e,t)=>{!function(e){if(window.history.pushState&&e!==kn()){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.set(fn,e),t.search=n.toString(),window.history.pushState({},"",t.toString())}}([e,t].join("_"))};function Un(){On(fn)}const Pn=e=>e.replace(/-./g,(e=>e[1].toUpperCase()));var Rn,Cn,Tn;function An(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if("object"==typeof i&&"object"==typeof s){if(!An(i,s))return!1}else if(i!==s)return!1}return!0}class Dn{constructor(e={}){Rn.set(this,void 0),Cn.set(this,{}),Tn.set(this,0),o(this,Rn,e,"f")}get current(){return Object.assign({},r(this,Rn,"f"))}update(e){const t="function"==typeof e?e(r(this,Rn,"f")):e,n=Object.assign(Object.assign({},r(this,Rn,"f")),t);if(!An(r(this,Rn,"f"),n)){const e=r(this,Rn,"f");o(this,Rn,n,"f"),Object.freeze(r(this,Rn,"f")),setTimeout((()=>{Object.values(r(this,Cn,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}}subscribe(e){return o(this,Tn,r(this,Tn,"f")+1,"f"),r(this,Cn,"f")[r(this,Tn,"f")]=e,r(this,Tn,"f").toString()}unsubscribe(e){const t=!!r(this,Cn,"f")[e];return t&&delete r(this,Cn,"f")[e],t}unsubscribeAll(){return o(this,Cn,{},"f"),!0}}Rn=new WeakMap,Cn=new WeakMap,Tn=new WeakMap;const Mn=(e,t)=>{((e,t,n="")=>{e.querySelectorAll(`[data-type="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",null==t?void 0:t.errorText),((e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`.descope-input[name="${t}"]`)).forEach((e=>{e.value=n}))}))})(e,null==t?void 0:t.inputs),((e,t)=>{e.querySelectorAll(".descope-text,.descope-link").forEach((e=>{e.textContent=((e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return r=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),r);var r})))(e.textContent,t)}))})(e,t)};function Ln(e){return n(this,void 0,void 0,(function*(){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=qn(n.publicKey.challenge),n.publicKey.user.id=qn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=qn(e.id)})),n}(e),n=yield navigator.credentials.create(t);return r=n,JSON.stringify({id:r.id,rawId:$n(r.rawId),type:r.type,response:{attestationObject:$n(r.response.attestationObject),clientDataJSON:$n(r.response.clientDataJSON)}});var r}))}function Nn(e){return n(this,void 0,void 0,(function*(){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=qn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=qn(e.id)})),n}(e),n=yield navigator.credentials.get(t);return r=n,JSON.stringify({id:r.id,rawId:$n(r.rawId),type:r.type,response:{authenticatorData:$n(r.response.authenticatorData),clientDataJSON:$n(r.response.clientDataJSON),signature:$n(r.response.signature),userHandle:$n(r.response.userHandle)}});var r}))}function qn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function $n(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var Jn,Kn,Wn,Bn,Fn,Hn,zn,Gn,Zn,Vn,Qn,Xn,Yn,er,tr,nr,rr,or,ir,sr,ar,cr,ur,lr;const dr=document.createElement("template");dr.innerHTML="\n\t<style>\n\t\t:host {\n\t\t\tdisplay: inline-block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\tform {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<form></form>\n\t";class hr extends HTMLElement{constructor(){super(),Jn.add(this),Kn.set(this,!1),Wn.set(this,new Dn),Bn.set(this,new Dn),Fn.set(this,new Dn({isLoading:!1})),Hn.set(this,void 0),zn.set(this,void 0),Gn.set(this,void 0),Zn.set(this,{popstate:r(this,Jn,"m",Yn).bind(this)}),Vn.set(this,void 0),nr.set(this,(e=>{if(!(null==e?void 0:e.ok))return Un(),void r(this,Jn,"m",sr).call(this,"error",null==e?void 0:e.error);const{status:t,authInfo:n}=e.data;if("completed"===t)return Un(),void r(this,Jn,"m",sr).call(this,"success",n);const{executionId:o,stepId:i,action:s,screen:a,redirect:c,webauthn:u}=e.data;r(this,Wn,"f").update({stepId:i,executionId:o,action:s,redirectUrl:null==c?void 0:c.url,screenId:null==a?void 0:a.id,screenState:null==a?void 0:a.state,webauthnTransactionId:null==u?void 0:u.transactionId,webauthnOptions:null==u?void 0:u.options})})),ar.set(this,(()=>{let e;return()=>n(this,void 0,void 0,(function*(){if(e)return e;const t=xn(this["project-id"],"config.json");try{e=yield jn(t,"json")}catch(e){console.error("Cannot get config file")}return e}))})()),r(this,Jn,"m",Qn).call(this),r(this,Wn,"f").subscribe(r(this,Jn,"m",tr).bind(this)),r(this,Bn,"f").subscribe(r(this,Jn,"m",or).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url"]}get"project-id"(){return this.getAttribute("project-id")}get"flow-id"(){return this.getAttribute("flow-id")}get"base-url"(){return this.getAttribute("base-url")||void 0}connectedCallback(){if(this.shadowRoot.isConnected){o(this,Kn,!0,"f"),r(this,Jn,"m",Xn).call(this),r(this,Jn,"m",lr).call(this),r(this,Jn,"m",ur).call(this);const{executionId:e,stepId:t}=_n(),n=mn("t")||void 0;n&&On("t");const i=mn(gn)||void 0;i&&On(gn),r(this,Wn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],stepId:t,executionId:e,token:n,code:i}),window.addEventListener("popstate",r(this,Zn,"f").popstate),r(this,Hn,"f").onkeydown=e=>{if("Enter"===e.key){e.preventDefault();const t=r(this,Hn,"f").querySelectorAll("button");1===t.length&&t[0].click()}}}}disconnectedCallback(){r(this,Wn,"f").unsubscribeAll(),r(this,Bn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,Zn,"f").popstate)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&r(this,Kn,"f")&&t!==n&&hr.observedAttributes.includes(e)){r(this,Jn,"m",Xn).call(this);const o=null===t;r(this,Wn,"f").update((({stepId:t,executionId:r})=>{let i=t,s=r;return o||(s=null,i=null,Un()),{[Pn(e)]:n,stepId:i,executionId:s}}))}}}Kn=new WeakMap,Wn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Zn=new WeakMap,Vn=new WeakMap,nr=new WeakMap,ar=new WeakMap,Jn=new WeakSet,Qn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dr.content.cloneNode(!0)),o(this,Hn,this.shadowRoot.querySelector("form"),"f"),o(this,zn,this.shadowRoot.querySelector("style"),"f")},Xn=function(){const e=["base-url"];hr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[t])throw Error(`${t} cannot be empty`)}))},Yn=function(){const{stepId:e,executionId:t}=_n();r(this,Wn,"f").update({stepId:e,executionId:t})},er=function(e,t){o(this,Vn,hn({projectId:e,baseUrl:t,autoRefresh:!1}),"f");const i=r(this,Vn,"f").flow.next;r(this,Vn,"f").flow.next=(...e)=>n(this,void 0,void 0,(function*(){r(this,Fn,"f").update({isLoading:!0});try{return yield i(...e)}finally{r(this,Fn,"f").update({isLoading:!1})}}))},tr=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,stepId:u,executionId:l,action:d,screenId:h,screenState:p,redirectUrl:f,token:g,code:v,webauthnTransactionId:b,webauthnOptions:y}=e,w=i("projectId")||i("baseUrl");if(r(this,Gn,"f")&&(clearInterval(r(this,Gn,"f")),o(this,Gn,null,"f")),w){if(!s)return;r(this,Jn,"m",er).call(this,s,c)}if(!l){if(!a)return;const e=yield r(this,Vn,"f").flow.start(a);return void r(this,nr,"f").call(this,e)}if(i("token")&&g||i("code")&&v){const e=yield r(this,Vn,"f").flow.next(l,u,"submit",{token:g,exchangeCode:v});return En(e.data.executionId,e.data.stepId),r(this,nr,"f").call(this,e),void r(this,Wn,"f").update({token:void 0,code:void 0})}if(d===vn)return f?void window.location.assign(f):void console.error("Did not get redirect url");if(d===yn||d===wn){if(!b||!y)return void console.error("Did not get webauthn transaction id or options");const e=d===yn?yield Ln(y):yield Nn(y),t=yield r(this,Vn,"f").flow.next(l,u,"submit",{transactionId:b,response:e});return void r(this,nr,"f").call(this,t)}if(d===bn&&o(this,Gn,setInterval((()=>n(this,void 0,void 0,(function*(){const e=yield r(this,Vn,"f").flow.next(l,u,"submit",{});r(this,nr,"f").call(this,e)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const m={direction:Sn(+u,+t.stepId),screenState:p,htmlUrl:xn(s,`${h}.html`)};(w||i("executionId")||i("stepId"))&&(m.next=(...e)=>r(this,Vn,"f").flow.next(l,u,...e)),r(this,Bn,"f").update(m)}))},rr=function(e){r(this,Hn,"f").onsubmit=t=>n(this,void 0,void 0,(function*(){var n,o,i;const s=null===(n=t.submitter)||void 0===n?void 0:n.getAttribute("id"),a=r(this,Fn,"f").subscribe((({isLoading:e})=>{var n,o,i,s;e?null===(o=null===(n=t.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,Fn,"f").unsubscribe(a),null===(s=null===(i=t.submitter)||void 0===i?void 0:i.classList)||void 0===s||s.remove("loading"))}));t.preventDefault();const c=Object.fromEntries(new FormData(t.target).entries()),u=(l=t.submitter,Array.from((null==l?void 0:l.attributes)||[]).reduce(((e,t)=>{var n;const r=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return r?Object.assign(e,{[r]:t.value}):e}),{}));var l;const d=yield e(s,Object.assign(Object.assign(Object.assign({},u),c),{origin:window.location.origin}));En(null===(o=d.data)||void 0===o?void 0:o.executionId,null===(i=d.data)||void 0===i?void 0:i.stepId),r(this,nr,"f").call(this,d)}))},or=function(e){return n(this,void 0,void 0,(function*(){const{htmlUrl:t,validations:n={},direction:o,next:i,screenState:s}=e,a=document.createElement("template");a.innerHTML=yield jn(t,"text");const c=a.content.cloneNode(!0),u=(e=>{var t;const n=Array.from(e.querySelectorAll("script[data-id]")).map((t=>{var n;const r=t.getAttribute("data-id"),o=null===(n=e.getElementById(r))||void 0===n?void 0:n.innerHTML,i=Function(o).bind(t.previousSibling);return t.remove(),i}));return null===(t=e.querySelector("scripts"))||void 0===t||t.remove(),n})(c),l=()=>{!function(e,t){Object.entries(t).forEach((([t,n])=>{const r=e.getElementById(t);if(!r)throw new Error(`Cannot find element with id: ${t}`);Object.entries(n).forEach((([e,t])=>{r.setAttribute(e,t.toString()),r.addEventListener("blur",(()=>r.classList.add("touched")),{once:!0})}))}))}(c,n),Mn(c,s);try{u.forEach((e=>e()))}catch(e){console.error(e)}r(this,Hn,"f").replaceChildren(c),r(this,Jn,"m",rr).call(this,i),r(this,Jn,"m",sr).call(this,"page-updated",{})};o?r(this,Jn,"m",ir).call(this,l,o):l()}))},ir=function(e,t){r(this,Hn,"f").addEventListener("transitionend",(()=>{r(this,Hn,"f").classList.remove("fade-out"),e()}),{once:!0});const n=t===In.forward?"slide-forward":"slide-backward";Array.from(r(this,Hn,"f").getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),r(this,Hn,"f").classList.add("fade-out")},sr=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},cr=function(e){if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)},ur=function(){var e,t,o;return n(this,void 0,void 0,(function*(){const n=yield r(this,ar,"f").call(this);null===(o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e.typography)||void 0===t?void 0:t.fontFamilies)||void 0===o||o.forEach((e=>r(this,Jn,"m",cr).call(this,e.url)))}))},lr=function(){return n(this,void 0,void 0,(function*(){const e=document.createElement("style"),t=xn(this["project-id"],"theme.css");e.innerText=yield jn(t,"text"),this.shadowRoot.appendChild(e)}))},customElements.define("descope-wc",hr)}(); | ||
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function n(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function r(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function o(t,e,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(t,n):o?o.value=n:e.set(t,n),n}function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,a="";r=e.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function a(t){this.message=t}function c(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(s(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return s(e)}}(t.split(".")[n]))}catch(t){throw new a("Invalid token specified: "+t.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d="__lodash_hash_undefined__",h="[object Function]",p="[object GeneratorFunction]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,v=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,m="object"==typeof u&&u&&u.Object===Object&&u,k="object"==typeof self&&self&&self.Object===Object&&self,I=m||k||Function("return this")();var O,j=Array.prototype,x=Function.prototype,S=Object.prototype,_=I["__core-js_shared__"],U=(O=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",E=x.toString,P=S.hasOwnProperty,R=S.toString,C=RegExp("^"+E.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=I.Symbol,A=j.splice,D=H(I,"Map"),M=H(Object,"create"),L=T?T.prototype:void 0,N=L?L.toString:void 0;function q(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function $(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function J(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function K(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function W(t,e){var n;e=function(t,e){if(V(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||X(t))return!0;return g.test(t)||!f.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:V(n=e)?n:z(n);for(var r=0,o=e.length;null!=t&&r<o;)t=t[G(e[r++])];return r&&r==o?t:void 0}function B(t){if(!Q(t)||(e=t,U&&U in e))return!1;var e,n=function(t){var e=Q(t)?R.call(t):"";return e==h||e==p}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?C:y;return n.test(function(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function F(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function H(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return B(n)?n:void 0}q.prototype.clear=function(){this.__data__=M?M(null):{}},q.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},q.prototype.get=function(t){var e=this.__data__;if(M){var n=e[t];return n===d?void 0:n}return P.call(e,t)?e[t]:void 0},q.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:P.call(e,t)},q.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(t){var e=this.__data__,n=K(e,t);return!(n<0)&&(n==e.length-1?e.pop():A.call(e,n,1),!0)},$.prototype.get=function(t){var e=this.__data__,n=K(e,t);return n<0?void 0:e[n][1]},$.prototype.has=function(t){return K(this.__data__,t)>-1},$.prototype.set=function(t,e){var n=this.__data__,r=K(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},J.prototype.clear=function(){this.__data__={hash:new q,map:new(D||$),string:new q}},J.prototype.delete=function(t){return F(this,t).delete(t)},J.prototype.get=function(t){return F(this,t).get(t)},J.prototype.has=function(t){return F(this,t).has(t)},J.prototype.set=function(t,e){return F(this,t).set(t,e),this};var z=Z((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(X(t))return N?N.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return v.test(t)&&n.push(""),t.replace(b,(function(t,e,r,o){n.push(r?o.replace(w,"$1"):e||t)})),n}));function G(t){if("string"==typeof t||X(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Z(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(Z.Cache||J),n}Z.Cache=J;var V=Array.isArray;function Q(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function X(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==R.call(t)}var Y,tt=function(t,e,n){var r=null==t?void 0:W(t,e);return void 0===r?n:r},et="/v1/auth/accesskey/exchange",nt="/v1/auth/otp/verify",rt="/v1/auth/otp/signin",ot="/v1/auth/otp/signup",it={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},st="/v1/auth/otp/signup-in",at="/v1/auth/magiclink/verify",ct="/v1/auth/magiclink/signin",ut="/v1/auth/magiclink/signup",lt="/v1/auth/magiclink/pending-session",dt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ht="/v1/auth/magiclink/signup-in",pt="/v1/auth/oauth/authorize",ft="/v1/auth/oauth/exchange",gt="/v1/auth/saml/authorize",vt="/v1/auth/saml/exchange",bt="/v1/auth/totp/verify",wt="/v1/auth/totp/signup",yt="/v1/user/totp/update",mt={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},kt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},It={start:"/v1/auth/webauthn/signup-in/start"},Ot={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},jt="/v1/flow/start",xt="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Y||(Y={}));const St=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}},_t=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,r])=>(t[n]=r,t)),t),t}),{})),Ut=t=>void 0===t?void 0:JSON.stringify(t),Et=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Pt=({baseUrl:t,projectId:e,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const s=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>St().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const r=await n(...e);return t[r.ok?"log":"error"](await(async t=>{const e=await t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),St().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(r)),r}:n})(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:d,method:h,token:p}=a,f=await s((({path:t,baseUrl:e,queryParams:n})=>{const r=new URL(t,e);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:t,queryParams:d}),{headers:_t(Et(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.26"},(null==n?void 0:n.baseHeaders)||{},l),method:h,body:Ut(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:r}={})=>a({path:t,headers:e,queryParams:n,body:void 0,method:Y.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.post,token:o}),put:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.put,token:o}),delete:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.delete,token:o})}};function Rt(t,e,n){var r;let o=Ct(t);e&&(o=null===(r=o.tenants)||void 0===r?void 0:r[e]);const i=o[n];return Array.isArray(i)?i:[]}function Ct(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Tt(t){const{exp:e}=Ct(t);return(new Date).getTime()/1e3>e}function At(t,e){return Rt(t,e,"permissions")}function Dt(t,e){return Rt(t,e,"roles")}const Mt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Lt(t){const e=await t,n={code:e.status,ok:e.ok,response:e},r=await e.clone().json();return e.ok?n.data=r:n.error=r,n}const Nt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),qt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),$t=t=>e=>t.test(e),Jt=$t(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Kt=$t(/^\+[1-9]{1}[0-9]{3,14}$/),Wt=Nt(Jt,'"{val}" is not a valid email'),Bt=Nt(Kt,'"{val}" is not a valid phone number'),Ft=Nt((1,t=>t.length>=1),"Minimum length is 1");const Ht=Nt((t=>"string"==typeof t),"Input is not a string"),zt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>qt(...t).validate(n[e]))),e(...n)),Gt=t=>[Ht(`"${t}" must be a string`),Ft(`"${t}" must not be empty`)],Zt=t=>[Ht(`"${t}" must be a string`),Wt()],Vt=t=>[Ht(`"${t}" must be a string`),Bt()],Qt=zt(Gt("accessKey")),Xt=t=>({exchange:Qt((e=>Lt(t.post(et,{},{token:e}))))});var Yt,te,ee,ne,re;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Yt||(Yt={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(te||(te={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(ee||(ee={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ne||(ne={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(re||(re={}));const oe=Gt("identifier"),ie=zt(oe,Gt("code")),se=zt(oe),ae=zt(oe,Vt("phone")),ce=zt(oe,Zt("email")),ue=t=>({verify:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Lt(t.post(Mt(nt,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,r,o)=>Lt(t.post(Mt(rt,n),{externalId:e,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,r)=>Lt(t.post(Mt(ot,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se((e=>Lt(t.post(Mt(st,n),{externalId:e}))))})),{}),update:{email:ce(((e,n,r)=>Lt(t.post(it.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,r,o)=>Lt(t.post(Mt(it.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),le=Gt("identifier"),de=Gt("uri"),he=zt(Gt("token")),pe=zt(le,de),fe=zt(Gt("pendingRef")),ge=zt(le,Vt("phone"),de),ve=zt(le,Zt("email"),de),be=t=>({verify:he((e=>Lt(t.post(at,{token:e})))),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o,i)=>Lt(t.post(Mt(ct,n),{externalId:e,URI:r,crossDevice:!0,loginOptions:o},{token:i}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r)=>Lt(t.post(Mt(ht,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o)=>Lt(t.post(Mt(ut,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:fe(((e,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||6e5,6e5)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(lt,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Lt(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ve(((e,n,r,o)=>Lt(t.post(dt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>Lt(t.post(Mt(dt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),we=t=>({verify:he((e=>Lt(t.post(at,{token:e})))),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o,i)=>Lt(t.post(Mt(ct,n),{externalId:e,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o)=>Lt(t.post(Mt(ut,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r)=>Lt(t.post(Mt(ht,n),{externalId:e,URI:r}))))})),{}),update:{email:ve(((e,n,r,o)=>Lt(t.post(dt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>Lt(t.post(Mt(dt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:be(t)});var ye;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(ye||(ye={}));const me=zt(Gt("code")),ke=t=>({start:Object.keys(ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={},o,i)=>{const s=await t.post(pt,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!r||!s.ok)return Lt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:me((e=>Lt(t.post(ft,{code:e}))))}),Ie=zt(Gt("flowId")),Oe=zt(Gt("executionId"),Gt("stepId"),Gt("interactionId")),je=t=>({start:Ie(((e,n)=>Lt(t.post(jt,{flowId:e,options:n})))),next:Oe(((e,n,r,o)=>Lt(t.post(xt,{executionId:e,stepId:n,interactionId:r,input:o}))))}),xe=zt(Gt("tenant")),Se=zt(Gt("code")),_e=t=>({start:xe((async(e,n,{redirect:r=!1}={},o,i)=>{const s=await t.post(gt,o||{},{queryParams:{tenant:e,redirectURL:n},token:i});if(!r||!s.ok)return Lt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Se((e=>Lt(t.post(vt,{code:e}))))}),Ue=Gt("identifier"),Ee=zt(Ue,Gt("code")),Pe=zt(Ue),Re=zt(Ue),Ce=t=>({signUp:Pe(((e,n)=>Lt(t.post(wt,{externalId:e,user:n})))),verify:Ee(((e,n,r,o)=>Lt(t.post(bt,{externalId:e,code:n,loginOptions:r},{token:o})))),update:Re(((e,n)=>Lt(t.post(yt,{externalId:e},{token:n}))))}),Te=Gt("identifier"),Ae=Gt("origin"),De=zt(Te,Ae,Gt("name")),Me=zt(Te,Ae),Le=zt(Te,Ae,Gt("token")),Ne=zt(Gt("transactionId"),Gt("response")),qe=t=>({signUp:{start:De(((e,n,r)=>Lt(t.post(mt.start,{user:{externalId:e,name:r},origin:n})))),finish:Ne(((e,n)=>Lt(t.post(mt.finish,{transactionId:e,response:n}))))},signIn:{start:Me(((e,n,r,o)=>Lt(t.post(kt.start,{externalId:e,origin:n,loginOptions:r},{token:o})))),finish:Ne(((e,n)=>Lt(t.post(kt.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Me(((e,n)=>Lt(t.post(It.start,{externalId:e,origin:n}))))},update:{start:Le(((e,n,r)=>Lt(t.post(Ot.start,{externalId:e,origin:n},{token:r})))),finish:Ne(((e,n)=>Lt(t.post(Ot.finish,{transactionId:e,response:n}))))}}),$e=zt(Gt("token"));var Je;const Ke=zt([("projectId",Je=Gt("projectId"),Nt(((t,e)=>t=>qt(...e).validate(tt(t,"projectId")))(0,Je))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Pt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{accessKey:Xt(i),otp:ue(i),magicLink:we(i),oauth:ke(i),saml:_e(i),totp:Ce(i),webauthn:qe(i),flow:je(i),refresh:t=>Lt(i.post("/v1/auth/refresh",{},{token:t})),logout:t=>Lt(i.post("/v1/auth/logoutall",{},{token:t})),deleteCookies:t=>Lt(i.post("/v1/auth/deletecookies",{},{token:t})),me:t=>Lt(i.get("/v1/auth/me",{token:t})),isJwtExpired:$e(Tt),getJwtPermissions:$e(At),getJwtRoles:$e(Dt),httpClient:i};var i}));function We(t,e,n){return void 0===n&&(n=0),e(n).catch((function(r){if(n>=t.maxRetries||!t.shouldRetry(r))throw r;var o,i,s,a,c=(o=t.baseDelay,i=t.maxDelay,s=t.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,s)));return(a=c,new Promise((function(t){return setTimeout(t,a)}))).then((function(){return We(t,e,n+1)}))}))}Ke.DeliveryMethods=te;var Be="Failed to load the JS script of the agent";function Fe(n){var r,o=n.scriptUrlPattern,i=n.token,s=n.apiKey,a=void 0===s?i:s,c=e(n,["scriptUrlPattern","token","apiKey"]),u=(r=n,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(r,"scriptUrlPattern")?o:void 0),l=[];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return We({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(t){return!(t instanceof Error&&"Blocked by CSP"===t.message)}},(function(){var t,e=new Date,n=function(){return l.push({startedAt:e,finishedAt:new Date})},r=function(t,e,n,r){var o,i=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),r=e.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=e,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return c(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(c(),o)return function(){throw new Error("Blocked by CSP")}();throw t}))}))}(t=function(t,e){void 0===e&&(e="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.7.1"):e}))}(a,u),(function(){return function(t){return new Promise((function(e,n){var r=document.createElement("script"),o=function(){var t;return null===(t=r.parentNode)||void 0===t?void 0:t.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),e()},r.onerror=function(){o(),n(new Error(Be))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)}));return r.then(n,n),r}))})).then((function(){var e=window,n="__fpjs_p_l_b",r=e[n];if(function(t,e){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==r?void 0:r.configurable)?delete t[e]:r&&!r.writable||(t[e]=void 0)}(e,n),"function"!=typeof(null==r?void 0:r.load))throw new Error(Be);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var He={exports:{}},ze={exports:{}};ze.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function e(n,r){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=t({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=e+"="+n.write(o,e)+s}}function i(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],r={},o=0;o<e.length;o++){var i=e[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=n.read(s,a),t===a)break}catch(t){}}return t?r[t]:r}}return Object.create({set:o,get:i,remove:function(e,n){o(e,"",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}return e({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}(),function(t){t.exports=ze.exports}(He);var Ge=l(He.exports);const Ze=t=>{const e=Fe({apiKey:t||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let t=sessionStorage.getItem("vsid");t||(t=(t=>new Proxy(new URLSearchParams(window.location.search),{get:(t,e)=>t.get(e.toString())})[t])("vsid")),t||(t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",t);const n=await e,r=await n.get({linkedId:t});sessionStorage.setItem("vrid",r.requestId)}catch(t){global.FB_DEBUG&&console.error(t)}}}};var Ve,Qe,Xe,Ye,tn;const en=t=>Object.assign({},t);class nn{constructor(t){Ve.add(this),Qe.set(this,void 0),Xe.set(this,{}),Ye.set(this,0),o(this,Qe,t,"f")}get current(){return en(r(this,Qe,"f"))}update(t){const e=t;if(!((t,e)=>{const n=t&&Object.getOwnPropertyNames(t)||[],r=e&&Object.getOwnPropertyNames(e)||[];if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==e[o])return!1}return!0})(r(this,Qe,"f"),e)){const t=r(this,Qe,"f");o(this,Qe,e,"f"),Object.freeze(r(this,Qe,"f")),setTimeout((()=>{Object.values(r(this,Xe,"f")).forEach((n=>n(en(e),t)))}),0)}}subscribe(t){o(this,Ye,r(this,Ye,"f")+1,"f"),r(this,Xe,"f")[r(this,Ye,"f")]=t;const e=r(this,Ye,"f");return()=>r(this,Ve,"m",tn).call(this,e.toString())}unsubscribeAll(){o(this,Xe,{},"f")}}Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ve=new WeakSet,tn=function(t){r(this,Xe,"f")[t]&&delete r(this,Xe,"f")[t]};let rn=[];function on(t,e,n){const r=function(t){const e=t.split(".");try{if(3===e.length){const e=JSON.parse(window.atob(t.split(".")[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(t){}return null}(e);if(r){let e;for(;e=rn.pop();)clearTimeout(e);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{t(n)}),o);rn.push(i)}}function sn(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&Ge.set("DS",t,{path:e,domain:n,expires:r,sameSite:"None",secure:!0})}(t,n),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(e)}function an(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function cn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ln(n.publicKey.challenge),n.publicKey.user.id=ln(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ln(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:dn(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:dn(n.response.attestationObject),clientDataJSON:dn(n.response.clientDataJSON)})}));var n}async function un(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ln(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ln(t.id)})),n}(t);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:dn(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:dn(n.response.authenticatorData),clientDataJSON:dn(n.response.clientDataJSON),signature:dn(n.response.signature),userHandle:n.response.userHandle?dn(n.response.userHandle):void 0})}));var n}function ln(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function dn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const hn="undefined"!=typeof window;var pn=t=>{var{autoRefresh:n=!0,persistTokens:r=!0}=t,o=e(t,["autoRefresh","persistTokens"]);hn?Ze(o.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const i=o;let s,a;const c=new nn({sessionToken:""}),u=new nn({});i.hooks={beforeRequest:t=>null==s?void 0:s(t),afterRequest:(t,e)=>null==a?void 0:a(t,e)};const l=Ke(i),d=Object.assign(Object.assign({},l),{webauthn:(h=l,{async signUp(t,e){const n=await h.webauthn.signUp.start(t,window.location.origin,e),r=await cn(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(t){const e=await h.webauthn.signIn.start(t,window.location.origin),n=await un(e.data.options);return await h.webauthn.signIn.finish(e.data.transactionId,n)},async signUpOrIn(t){var e;const n=await h.webauthn.signUpOrIn.start(t,window.location.origin);if(null===(e=n.data)||void 0===e?void 0:e.create){const t=await cn(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await un(n.data.options);return await h.webauthn.signIn.finish(n.data.transactionId,t)}},async update(t,e){const n=await h.webauthn.update.start(t,window.location.origin,e),r=await cn(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:cn,get:un}}),onSessionTokenChange:t=>{var e;const n=null===(e=c.current)||void 0===e?void 0:e.sessionToken;return n&&t(n),c.subscribe((({sessionToken:e})=>{t(e)}))},onUserChange:t=>{const e=u.current;return e&&Object.entries(e).length>0&&t(e),u.subscribe((e=>{t(e)}))}});var h;return n&&(d.logout=(...t)=>{const e=an(),n=[(null==t?void 0:t.shift())||e,...t],r=l.logout(...n);return localStorage&&localStorage.removeItem("DSR"),Ge.remove("DS"),c.update({sessionToken:""}),r}),s=t=>{var e;return t.queryParams=(e=t.queryParams,Object.assign(Object.assign({},e),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!t.token&&r&&(t.token=an()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.7"}),t},d.me=async(...t)=>{var e;const n=await l.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());u.update(t)}return n},(n||r)&&(a=(t,o)=>{!async function(t,n,r,o){try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const i=await(null==n?void 0:n.json());if(i){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(i),{sessionJwt:s,refreshJwt:a,user:c}=n,u=e(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&sn(s,a,u),s&&r.sessionToken.update({sessionToken:s}),c&&r.user.update(c),s&&a&&o.autoRefresh&&on(t,s,a)}}catch(t){console.error("Could not set tokens from body",t)}}(d.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&d.refresh(),d};const fn=(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("base.content.url"))||"https://static.prod.descope.com/pages",gn="descope-login-flow",vn="code",bn="redirect",wn="poll",yn="webauthnCreate",mn="webauthnGet";function kn(t){return new URLSearchParams(window.location.search).get(t)}function In(){return kn(gn)}function On(t){if(window.history.replaceState&&kn(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}var jn;function xn(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t}`);return n[e||"text"]()}))}!function(t){t.backward="backward",t.forward="forward"}(jn||(jn={}));function Sn(t,e){const n=new URL(fn);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,e),n.toString()}function _n(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?jn.forward:t<e?jn.backward:void 0}const Un=()=>{const[t="",e=""]=(In()||"").split("_");return{executionId:t,stepId:e}},En=(t,e)=>{!function(t){if(window.history.pushState&&t!==In()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(gn,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};function Pn(){On(gn)}const Rn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Cn,Tn,An;function Dn(t,e){const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=t[o],s=e[o];if("object"==typeof i&&"object"==typeof s){if(!Dn(i,s))return!1}else if(i!==s)return!1}return!0}class Mn{constructor(t={}){Cn.set(this,void 0),Tn.set(this,{}),An.set(this,0),o(this,Cn,t,"f")}get current(){return Object.assign({},r(this,Cn,"f"))}update(t){const e="function"==typeof t?t(r(this,Cn,"f")):t,n=Object.assign(Object.assign({},r(this,Cn,"f")),e);if(!Dn(r(this,Cn,"f"),n)){const t=r(this,Cn,"f");o(this,Cn,n,"f"),Object.freeze(r(this,Cn,"f")),setTimeout((()=>{Object.values(r(this,Tn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,An,r(this,An,"f")+1,"f"),r(this,Tn,"f")[r(this,An,"f")]=t,r(this,An,"f").toString()}unsubscribe(t){const e=!!r(this,Tn,"f")[t];return e&&delete r(this,Tn,"f")[t],e}unsubscribeAll(){return o(this,Tn,{},"f"),!0}}Cn=new WeakMap,Tn=new WeakMap,An=new WeakMap;const Ln=(t,e)=>{((t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return r=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),r);var r})))(t.textContent,e)}))})(t,e)};function Nn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=$n(n.publicKey.challenge),n.publicKey.user.id=$n(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=$n(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:Jn(r.rawId),type:r.type,response:{attestationObject:Jn(r.response.attestationObject),clientDataJSON:Jn(r.response.clientDataJSON)}});var r}))}function qn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=$n(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=$n(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:Jn(r.rawId),type:r.type,response:{authenticatorData:Jn(r.response.authenticatorData),clientDataJSON:Jn(r.response.clientDataJSON),signature:Jn(r.response.signature),userHandle:Jn(r.response.userHandle)}});var r}))}function $n(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Jn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var Kn,Wn,Bn,Fn,Hn,zn,Gn,Zn,Vn,Qn,Xn,Yn,tr,er,nr,rr,or,ir,sr,ar,cr,ur,lr,dr;const hr=document.createElement("template");hr.innerHTML="\n\t<style>\n\t\t:host {\n\t\t\tdisplay: inline-block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\tform {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<form></form>\n\t";class pr extends HTMLElement{constructor(){super(),Kn.add(this),Wn.set(this,!1),Bn.set(this,new Mn),Fn.set(this,new Mn),Hn.set(this,new Mn({isLoading:!1})),zn.set(this,void 0),Gn.set(this,void 0),Zn.set(this,void 0),Vn.set(this,{popstate:r(this,Kn,"m",tr).bind(this)}),Qn.set(this,void 0),rr.set(this,(t=>{if(!(null==t?void 0:t.ok))return Pn(),void r(this,Kn,"m",ar).call(this,"error",null==t?void 0:t.error);const{status:e,authInfo:n}=t.data;if("completed"===e)return Pn(),void r(this,Kn,"m",ar).call(this,"success",n);const{executionId:o,stepId:i,action:s,screen:a,redirect:c,webauthn:u}=t.data;r(this,Bn,"f").update({stepId:i,executionId:o,action:s,redirectUrl:null==c?void 0:c.url,screenId:null==a?void 0:a.id,screenState:null==a?void 0:a.state,webauthnTransactionId:null==u?void 0:u.transactionId,webauthnOptions:null==u?void 0:u.options})})),cr.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=Sn(this["project-id"],"config.json");try{t=yield xn(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),r(this,Kn,"m",Xn).call(this),r(this,Bn,"f").subscribe(r(this,Kn,"m",nr).bind(this)),r(this,Fn,"f").subscribe(r(this,Kn,"m",ir).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url"]}get"project-id"(){return this.getAttribute("project-id")}get"flow-id"(){return this.getAttribute("flow-id")}get"base-url"(){return this.getAttribute("base-url")||void 0}connectedCallback(){if(this.shadowRoot.isConnected){o(this,Wn,!0,"f"),r(this,Kn,"m",Yn).call(this),r(this,Kn,"m",dr).call(this),r(this,Kn,"m",lr).call(this);const{executionId:t,stepId:e}=Un(),n=kn("t")||void 0;n&&On("t");const i=kn(vn)||void 0;i&&On(vn),r(this,Bn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],stepId:e,executionId:t,token:n,code:i}),window.addEventListener("popstate",r(this,Vn,"f").popstate),r(this,zn,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=r(this,zn,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}disconnectedCallback(){r(this,Bn,"f").unsubscribeAll(),r(this,Fn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,Vn,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,Wn,"f")&&e!==n&&pr.observedAttributes.includes(t)){r(this,Kn,"m",Yn).call(this);const o=null===e;r(this,Bn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,Pn()),{[Rn(t)]:n,stepId:i,executionId:s}}))}}}Wn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Zn=new WeakMap,Vn=new WeakMap,Qn=new WeakMap,rr=new WeakMap,cr=new WeakMap,Kn=new WeakSet,Xn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(hr.content.cloneNode(!0)),o(this,zn,this.shadowRoot.querySelector("form"),"f"),o(this,Gn,this.shadowRoot.querySelector("style"),"f")},Yn=function(){const t=["base-url"];pr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},tr=function(){const{stepId:t,executionId:e}=Un();r(this,Bn,"f").update({stepId:t,executionId:e})},er=function(t,e){o(this,Qn,pn({projectId:t,baseUrl:e,autoRefresh:!1}),"f");const i=r(this,Qn,"f").flow.next;r(this,Qn,"f").flow.next=(...t)=>n(this,void 0,void 0,(function*(){r(this,Hn,"f").update({isLoading:!0});try{return yield i(...t)}finally{r(this,Hn,"f").update({isLoading:!1})}}))},nr=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,stepId:u,executionId:l,action:d,screenId:h,screenState:p,redirectUrl:f,token:g,code:v,webauthnTransactionId:b,webauthnOptions:w}=t,y=i("projectId")||i("baseUrl");if(r(this,Zn,"f")&&(clearInterval(r(this,Zn,"f")),o(this,Zn,null,"f")),y){if(!s)return;r(this,Kn,"m",er).call(this,s,c)}if(!l){if(!a)return;const t=yield r(this,Qn,"f").flow.start(a);return void r(this,rr,"f").call(this,t)}if(i("token")&&g||i("code")&&v){const t=yield r(this,Qn,"f").flow.next(l,u,"submit",{token:g,exchangeCode:v});return En(t.data.executionId,t.data.stepId),r(this,rr,"f").call(this,t),void r(this,Bn,"f").update({token:void 0,code:void 0})}if(d===bn)return f?void window.location.assign(f):void console.error("Did not get redirect url");if(d===yn||d===mn){if(!b||!w)return void console.error("Did not get webauthn transaction id or options");const t=d===yn?yield Nn(w):yield qn(w),e=yield r(this,Qn,"f").flow.next(l,u,"submit",{transactionId:b,response:t});return void r(this,rr,"f").call(this,e)}if(d===wn&&o(this,Zn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,Qn,"f").flow.next(l,u,"submit",{});r(this,rr,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const m={direction:_n(+u,+e.stepId),screenState:p,htmlUrl:Sn(s,`${h}.html`)};(y||i("executionId")||i("stepId"))&&(m.next=(...t)=>r(this,Qn,"f").flow.next(l,u,...t)),r(this,Fn,"f").update(m)}))},or=function(t){r(this,zn,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n,o,i;const s=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),a=r(this,Hn,"f").subscribe((({isLoading:t})=>{var n,o,i,s;t?null===(o=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,Hn,"f").unsubscribe(a),null===(s=null===(i=e.submitter)||void 0===i?void 0:i.classList)||void 0===s||s.remove("loading"))}));e.preventDefault();const c=Object.fromEntries(new FormData(e.target).entries()),u=(l=e.submitter,Array.from((null==l?void 0:l.attributes)||[]).reduce(((t,e)=>{var n;const r=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return r?Object.assign(t,{[r]:e.value}):t}),{}));var l;const d=yield t(s,Object.assign(Object.assign(Object.assign({},u),c),{origin:window.location.origin}));En(null===(o=d.data)||void 0===o?void 0:o.executionId,null===(i=d.data)||void 0===i?void 0:i.stepId),r(this,rr,"f").call(this,d)}))},ir=function(t){return n(this,void 0,void 0,(function*(){const{htmlUrl:e,validations:n={},direction:o,next:i,screenState:s}=t,a=document.createElement("template");a.innerHTML=yield xn(e,"text");const c=a.content.cloneNode(!0),u=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const r=e.getAttribute("data-id"),o=null===(n=t.getElementById(r))||void 0===n?void 0:n.innerHTML,i=Function(o).bind(e.previousSibling);return e.remove(),i}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(c),l=()=>{!function(t,e){Object.entries(e).forEach((([e,n])=>{const r=t.getElementById(e);if(!r)throw new Error(`Cannot find element with id: ${e}`);Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e.toString()),r.addEventListener("blur",(()=>r.classList.add("touched")),{once:!0})}))}))}(c,n),Ln(c,s);try{u.forEach((t=>t()))}catch(t){console.error(t)}r(this,zn,"f").replaceChildren(c),r(this,Kn,"m",or).call(this,i),r(this,Kn,"m",ar).call(this,"page-updated",{})};o?r(this,Kn,"m",sr).call(this,l,o):l()}))},sr=function(t,e){r(this,zn,"f").addEventListener("transitionend",(()=>{r(this,zn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===jn.forward?"slide-forward":"slide-backward";Array.from(r(this,zn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,zn,"f").classList.add("fade-out")},ar=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},ur=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},lr=function(){var t,e,o;return n(this,void 0,void 0,(function*(){const n=yield r(this,cr,"f").call(this);null===(o=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t.typography)||void 0===e?void 0:e.fontFamilies)||void 0===o||o.forEach((t=>r(this,Kn,"m",ur).call(this,t.url)))}))},dr=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=Sn(this["project-id"],"theme.css");t.innerText=yield xn(e,"text"),this.shadowRoot.appendChild(t)}))},customElements.define("descope-wc",pr)}(); |
{ | ||
"name": "@descope/web-component", | ||
"version": "0.1.0-alpha.7", | ||
"version": "0.1.0-alpha.8", | ||
"main": "dist/descope-wc", | ||
@@ -77,3 +77,3 @@ "types": "dist/descope-wc.d.ts", | ||
"dependencies": { | ||
"@descope/web-js-sdk": "0.1.0-alpha.5" | ||
"@descope/web-js-sdk": "0.1.0-alpha.7" | ||
}, | ||
@@ -80,0 +80,0 @@ "overrides": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45839
171
+ Added@descope/core-js-sdk@0.0.41-alpha.26(transitive)
+ Added@descope/web-js-sdk@0.1.0-alpha.7(transitive)
- Removed@descope/core-js-sdk@0.0.41-alpha.24(transitive)
- Removed@descope/web-js-sdk@0.1.0-alpha.5(transitive)