New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@descope/web-component

Package Overview
Dependencies
Maintainers
4
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@descope/web-component - npm Package Compare versions

Comparing version 0.1.0-alpha.3 to 0.1.0-alpha.4

2

dist/descope-wc.js

@@ -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,w=/\\(\\)?/g,y=/^\[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=F(O,"Map"),M=F(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:y;return n.test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function H(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 F(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 H(this,e).delete(e)},J.prototype.get=function(e){return H(this,e).get(e)},J.prototype.has=function(e){return H(this,e).has(e)},J.prototype.set=function(e,t){return H(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(w,"$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",we="/v1/auth/totp/signup",ye="/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 He=Le((e=>"string"==typeof e),"Input is not a string"),Fe=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ne(...e).validate(n[t]))),t(...n)),ze=e=>[He(`"${e}" must be a string`),Be(`"${e}" must not be empty`)],Ge=e=>[He(`"${e}" must be a string`),Ke()],Ze=e=>[He(`"${e}" must be a string`),We()],Ve=Fe(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=Fe(rt,ze("code")),it=Fe(rt),st=Fe(rt,Ze("phone")),at=Fe(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=Fe(ze("token")),ht=Fe(ut,lt),pt=Fe(ze("pendingRef")),ft=Fe(ut,Ze("phone"),lt),gt=Fe(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 wt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(wt||(wt={}));const yt=Fe(ze("code")),mt=e=>({start:Object.keys(wt).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:yt(((t,n,r)=>Me(e.post(fe,{code:t,loginOptions:n},{token:r}))))}),kt=Fe(ze("flowId")),Ot=Fe(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=Fe(ze("tenant")),xt=Fe(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=Fe(_t,ze("code")),Ut=Fe(_t),Pt=Fe(_t),Rt=e=>({signUp:Ut(((t,n)=>Me(e.post(we,{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(ye,{externalId:t},{token:n}))))}),Ct=ze("identifier"),Tt=ze("origin"),At=Fe(Ct,Tt,ze("name")),Dt=Fe(Ct,Tt),Mt=Fe(Ct,Tt,ze("token")),Lt=Fe(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=Fe(ze("token"));var $t;const Jt=Fe([("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 Ht={exports:{}},Ft={exports:{}};Ft.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=Ft.exports}(Ht);var zt=l(Ht.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",wn="webauthnCreate",yn="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){return n(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw new Error(e);return t.text()}))}!function(e){e.backward="backward",e.forward="forward"}(In||(In={}));function xn(e,t,n){const r=new URL(pn);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,`${t}.${n}`),r.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(`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,Hn,Fn,zn,Gn,Zn,Vn,Qn,Xn,Yn,er,tr,nr,rr,or,ir,sr,ar,cr,ur,lr;!function(e){e.waiting="waiting",e.completed="completed",e.failed="failed",e.running="running"}(Jn||(Jn={}));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(),Kn.add(this),Wn.set(this,!1),Bn.set(this,new Dn),Hn.set(this,new Dn),Fn.set(this,new Dn({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",er).bind(this)}),Qn.set(this,void 0),ir.set(this,(e=>{if(r(this,Kn,"m",nr).call(this,e))return;const{executionId:t,stepId:n,status:o,action:i,screen:s,redirect:a,authInfo:c,error:u,webauthn:l}=e.data;r(this,Kn,"m",tr).call(this,o,u,c)||r(this,Bn,"f").update({stepId:n,executionId:t,action:i,redirectUrl:null==a?void 0:a.url,screenId:null==s?void 0:s.id,screenState:null==s?void 0:s.state,webauthnTransactionId:null==l?void 0:l.transactionId,webauthnOptions:null==l?void 0:l.options})})),r(this,Kn,"m",Xn).call(this),r(this,Bn,"f").subscribe(r(this,Kn,"m",or).bind(this)),r(this,Hn,"f").subscribe(r(this,Kn,"m",ar).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",lr).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,Bn,"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,Vn,"f").popstate),r(this,zn,"f").onkeydown=e=>{if("Enter"===e.key){e.preventDefault();const t=r(this,zn,"f").querySelectorAll("button");1===t.length&&t[0].click()}}}}disconnectedCallback(){r(this,Bn,"f").unsubscribeAll(),r(this,Hn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,Vn,"f").popstate)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&r(this,Wn,"f")&&t!==n&&hr.observedAttributes.includes(e)){r(this,Kn,"m",Yn).call(this);const o=null===t;r(this,Bn,"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}}))}}}Wn=new WeakMap,Bn=new WeakMap,Hn=new WeakMap,Fn=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Zn=new WeakMap,Vn=new WeakMap,Qn=new WeakMap,ir=new WeakMap,Kn=new WeakSet,Xn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dr.content.cloneNode(!0)),o(this,zn,this.shadowRoot.querySelector("form"),"f"),o(this,Gn,this.shadowRoot.querySelector("style"),"f")},Yn=function(){const e=["base-url"];hr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[t])throw Error(`${t} cannot be empty`)}))},er=function(){const{stepId:e,executionId:t}=_n();r(this,Bn,"f").update({stepId:e,executionId:t})},tr=function(e,t,n){switch(e){case Jn.failed:return Un(),r(this,Kn,"m",ur).call(this,"error",t),!0;case Jn.completed:return Un(),r(this,Kn,"m",ur).call(this,"success",n),!0;default:return!1}},nr=function(e){return(null==e?void 0:e.ok)||r(this,Kn,"m",ur).call(this,"error",null==e?void 0:e.error),!(null==e?void 0:e.ok)},rr=function(e,t){o(this,Qn,hn({projectId:e,baseUrl:t}),"f");const i=r(this,Qn,"f").flow.next;r(this,Qn,"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})}}))},or=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:w}=e,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",rr).call(this,s,c)}if(!l){if(!a)return;const e=yield r(this,Qn,"f").flow.start(a);return void r(this,ir,"f").call(this,e)}if(i("token")&&g||i("code")&&v){const e=yield r(this,Qn,"f").flow.next(l,u,"submit",{token:g,exchangeCode:v});return En(e.data.executionId,e.data.stepId),r(this,ir,"f").call(this,e),void r(this,Bn,"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===wn||d===yn){if(!b||!w)return void console.error("Did not get webauthn transaction id or options");const e=d===wn?yield Ln(w):yield Nn(w),t=yield r(this,Qn,"f").flow.next(l,u,"submit",{transactionId:b,response:e});return void r(this,ir,"f").call(this,t)}if(d===bn&&o(this,Zn,setInterval((()=>n(this,void 0,void 0,(function*(){const e=yield r(this,Qn,"f").flow.next(l,u,"submit",{});r(this,ir,"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")};(y||i("executionId")||i("stepId"))&&(m.next=(...e)=>r(this,Qn,"f").flow.next(l,u,...e)),r(this,Hn,"f").update(m)}))},sr=function(e){r(this,zn,"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,ir,"f").call(this,d)}))},ar=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);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,zn,"f").replaceChildren(c),r(this,Kn,"m",sr).call(this,i),r(this,Kn,"m",ur).call(this,"page-updated",{})};o?r(this,Kn,"m",cr).call(this,l,o):l()}))},cr=function(e,t){r(this,zn,"f").addEventListener("transitionend",(()=>{r(this,zn,"f").classList.remove("fade-out"),e()}),{once:!0});const n=t===In.forward?"slide-forward":"slide-backward";Array.from(r(this,zn,"f").getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),r(this,zn,"f").classList.add("fade-out")},ur=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},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),this.shadowRoot.appendChild(e)}))},customElements.define("descope-wc",hr)}();
!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,w=/\\(\\)?/g,y=/^\[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=F(O,"Map"),M=F(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:y;return n.test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function H(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 F(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 H(this,e).delete(e)},J.prototype.get=function(e){return H(this,e).get(e)},J.prototype.has=function(e){return H(this,e).has(e)},J.prototype.set=function(e,t){return H(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(w,"$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",we="/v1/auth/totp/signup",ye="/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 He=Le((e=>"string"==typeof e),"Input is not a string"),Fe=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ne(...e).validate(n[t]))),t(...n)),ze=e=>[He(`"${e}" must be a string`),Be(`"${e}" must not be empty`)],Ge=e=>[He(`"${e}" must be a string`),Ke()],Ze=e=>[He(`"${e}" must be a string`),We()],Ve=Fe(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=Fe(rt,ze("code")),it=Fe(rt),st=Fe(rt,Ze("phone")),at=Fe(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=Fe(ze("token")),ht=Fe(ut,lt),pt=Fe(ze("pendingRef")),ft=Fe(ut,Ze("phone"),lt),gt=Fe(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 wt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(wt||(wt={}));const yt=Fe(ze("code")),mt=e=>({start:Object.keys(wt).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:yt(((t,n,r)=>Me(e.post(fe,{code:t,loginOptions:n},{token:r}))))}),kt=Fe(ze("flowId")),Ot=Fe(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=Fe(ze("tenant")),xt=Fe(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=Fe(_t,ze("code")),Ut=Fe(_t),Pt=Fe(_t),Rt=e=>({signUp:Ut(((t,n)=>Me(e.post(we,{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(ye,{externalId:t},{token:n}))))}),Ct=ze("identifier"),Tt=ze("origin"),At=Fe(Ct,Tt,ze("name")),Dt=Fe(Ct,Tt),Mt=Fe(Ct,Tt,ze("token")),Lt=Fe(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=Fe(ze("token"));var $t;const Jt=Fe([("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 Ht={exports:{}},Ft={exports:{}};Ft.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=Ft.exports}(Ht);var zt=l(Ht.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",wn="webauthnCreate",yn="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){return n(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw new Error(e);return t.text()}))}!function(e){e.backward="backward",e.forward="forward"}(In||(In={}));function xn(e,t,n){const r=new URL(pn);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,`${t}.${n}`),r.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(`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,Hn,Fn,zn,Gn,Zn,Vn,Qn,Xn,Yn,er,tr,nr,rr,or,ir,sr,ar,cr,ur,lr;!function(e){e.waiting="waiting",e.completed="completed",e.failed="failed",e.running="running"}(Jn||(Jn={}));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(),Kn.add(this),Wn.set(this,!1),Bn.set(this,new Dn),Hn.set(this,new Dn),Fn.set(this,new Dn({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",er).bind(this)}),Qn.set(this,void 0),ir.set(this,(e=>{if(r(this,Kn,"m",nr).call(this,e))return;const{executionId:t,stepId:n,status:o,action:i,screen:s,redirect:a,authInfo:c,error:u,webauthn:l}=e.data;r(this,Kn,"m",tr).call(this,o,u,c)||r(this,Bn,"f").update({stepId:n,executionId:t,action:i,redirectUrl:null==a?void 0:a.url,screenId:null==s?void 0:s.id,screenState:null==s?void 0:s.state,webauthnTransactionId:null==l?void 0:l.transactionId,webauthnOptions:null==l?void 0:l.options})})),r(this,Kn,"m",Xn).call(this),r(this,Bn,"f").subscribe(r(this,Kn,"m",or).bind(this)),r(this,Hn,"f").subscribe(r(this,Kn,"m",ar).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",lr).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,Bn,"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,Vn,"f").popstate),r(this,zn,"f").onkeydown=e=>{if("Enter"===e.key){e.preventDefault();const t=r(this,zn,"f").querySelectorAll("button");1===t.length&&t[0].click()}}}}disconnectedCallback(){r(this,Bn,"f").unsubscribeAll(),r(this,Hn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,Vn,"f").popstate)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&r(this,Wn,"f")&&t!==n&&hr.observedAttributes.includes(e)){r(this,Kn,"m",Yn).call(this);const o=null===t;r(this,Bn,"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}}))}}}Wn=new WeakMap,Bn=new WeakMap,Hn=new WeakMap,Fn=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Zn=new WeakMap,Vn=new WeakMap,Qn=new WeakMap,ir=new WeakMap,Kn=new WeakSet,Xn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dr.content.cloneNode(!0)),o(this,zn,this.shadowRoot.querySelector("form"),"f"),o(this,Gn,this.shadowRoot.querySelector("style"),"f")},Yn=function(){const e=["base-url"];hr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[t])throw Error(`${t} cannot be empty`)}))},er=function(){const{stepId:e,executionId:t}=_n();r(this,Bn,"f").update({stepId:e,executionId:t})},tr=function(e,t,n){switch(e){case Jn.failed:return Un(),r(this,Kn,"m",ur).call(this,"error",t),!0;case Jn.completed:return Un(),r(this,Kn,"m",ur).call(this,"success",n),!0;default:return!1}},nr=function(e){return(null==e?void 0:e.ok)||r(this,Kn,"m",ur).call(this,"error",null==e?void 0:e.error),!(null==e?void 0:e.ok)},rr=function(e,t){o(this,Qn,hn({projectId:e,baseUrl:t,autoRefresh:!1}),"f");const i=r(this,Qn,"f").flow.next;r(this,Qn,"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})}}))},or=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:w}=e,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",rr).call(this,s,c)}if(!l){if(!a)return;const e=yield r(this,Qn,"f").flow.start(a);return void r(this,ir,"f").call(this,e)}if(i("token")&&g||i("code")&&v){const e=yield r(this,Qn,"f").flow.next(l,u,"submit",{token:g,exchangeCode:v});return En(e.data.executionId,e.data.stepId),r(this,ir,"f").call(this,e),void r(this,Bn,"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===wn||d===yn){if(!b||!w)return void console.error("Did not get webauthn transaction id or options");const e=d===wn?yield Ln(w):yield Nn(w),t=yield r(this,Qn,"f").flow.next(l,u,"submit",{transactionId:b,response:e});return void r(this,ir,"f").call(this,t)}if(d===bn&&o(this,Zn,setInterval((()=>n(this,void 0,void 0,(function*(){const e=yield r(this,Qn,"f").flow.next(l,u,"submit",{});r(this,ir,"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")};(y||i("executionId")||i("stepId"))&&(m.next=(...e)=>r(this,Qn,"f").flow.next(l,u,...e)),r(this,Hn,"f").update(m)}))},sr=function(e){r(this,zn,"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,ir,"f").call(this,d)}))},ar=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);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,zn,"f").replaceChildren(c),r(this,Kn,"m",sr).call(this,i),r(this,Kn,"m",ur).call(this,"page-updated",{})};o?r(this,Kn,"m",cr).call(this,l,o):l()}))},cr=function(e,t){r(this,zn,"f").addEventListener("transitionend",(()=>{r(this,zn,"f").classList.remove("fade-out"),e()}),{once:!0});const n=t===In.forward?"slide-forward":"slide-backward";Array.from(r(this,zn,"f").getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),r(this,zn,"f").classList.add("fade-out")},ur=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},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),this.shadowRoot.appendChild(e)}))},customElements.define("descope-wc",hr)}();
{
"name": "@descope/web-component",
"version": "0.1.0-alpha.3",
"version": "0.1.0-alpha.4",
"main": "dist/descope-wc",

@@ -5,0 +5,0 @@ "types": "dist/descope-wc.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc