@descope/web-component
Advanced tools
Comparing version 0.1.0-alpha.9 to 0.1.0-alpha.10
@@ -1,1 +0,1 @@ | ||
!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","tenant"]}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}get tenant(){return this.getAttribute("tenant")||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"],tenant:this.tenant,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","tenant"];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,tenant:u,stepId:l,executionId:d,action:h,screenId:p,screenState:f,redirectUrl:g,token:v,code:b,webauthnTransactionId:w,webauthnOptions:y}=t,m=i("projectId")||i("baseUrl");if(r(this,Zn,"f")&&(clearInterval(r(this,Zn,"f")),o(this,Zn,null,"f")),m){if(!s)return;r(this,Kn,"m",er).call(this,s,c)}if(!d){if(!a)return;const t=yield r(this,Qn,"f").flow.start(a,{tenant:u,redirectUrl:window.location.href});return void r(this,rr,"f").call(this,t)}if(i("token")&&v||i("code")&&b){const t=yield r(this,Qn,"f").flow.next(d,l,"submit",{token:v,exchangeCode:b});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(h===bn)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(h===yn||h===mn){if(!w||!y)return void console.error("Did not get webauthn transaction id or options");const t=h===yn?yield Nn(y):yield qn(y),e=yield r(this,Qn,"f").flow.next(d,l,"submit",{transactionId:w,response:t});return void r(this,rr,"f").call(this,e)}if(h===wn&&o(this,Zn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,Qn,"f").flow.next(d,l,"submit",{});r(this,rr,"f").call(this,t)}))),2e3),"f"),!p)return void console.error("Refreshing the page during a flow is not supported yet");const k={direction:_n(+l,+e.stepId),screenState:f,htmlUrl:Sn(s,`${p}.html`)};(m||i("executionId")||i("stepId"))&&(k.next=(...t)=>r(this,Qn,"f").flow.next(d,l,...t)),r(this,Fn,"f").update(k)}))},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)}(); | ||
!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.27"},(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/logout",{},{token:t})),logoutAll:t=>Lt(i.post("/v1/auth/logoutall",{},{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&&["logout","logoutAll"].forEach((t=>{const e=l[t];d[t]=(...t)=>{const n=an(),r=[(null==t?void 0:t.shift())||n,...t],o=e(...r);return localStorage&&localStorage.removeItem("DSR"),Ge.remove("DS"),c.update({sessionToken:""}),o}})),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.8"}),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&&an()&&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)=>{var n;((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('[data-type="totp-link"]').forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((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","tenant"]}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}get tenant(){return this.getAttribute("tenant")||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"],tenant:this.tenant,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","tenant"];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,tenant:u,stepId:l,executionId:d,action:h,screenId:p,screenState:f,redirectUrl:g,token:v,code:b,webauthnTransactionId:w,webauthnOptions:y}=t,m=i("projectId")||i("baseUrl");if(r(this,Zn,"f")&&(clearInterval(r(this,Zn,"f")),o(this,Zn,null,"f")),m){if(!s)return;r(this,Kn,"m",er).call(this,s,c)}if(!d){if(!a)return;const t=yield r(this,Qn,"f").flow.start(a,{tenant:u,redirectUrl:window.location.href});return void r(this,rr,"f").call(this,t)}if(i("token")&&v||i("code")&&b){const t=yield r(this,Qn,"f").flow.next(d,l,"submit",{token:v,exchangeCode:b});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(h===bn)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(h===yn||h===mn){if(!w||!y)return void console.error("Did not get webauthn transaction id or options");const t=h===yn?yield Nn(y):yield qn(y),e=yield r(this,Qn,"f").flow.next(d,l,"submit",{transactionId:w,response:t});return void r(this,rr,"f").call(this,e)}if(h===wn&&o(this,Zn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,Qn,"f").flow.next(d,l,"submit",{});r(this,rr,"f").call(this,t)}))),2e3),"f"),!p)return void console.error("Refreshing the page during a flow is not supported yet");const k={direction:_n(+l,+e.stepId),screenState:f,htmlUrl:Sn(s,`${p}.html`)};(m||i("executionId")||i("stepId"))&&(k.next=(...t)=>r(this,Qn,"f").flow.next(d,l,...t)),r(this,Fn,"f").update(k)}))},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=()=>{var t;!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);((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(c.querySelector("div"),null===(t=null==s?void 0:s.totp)||void 0===t?void 0:t.image);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.9", | ||
"version": "0.1.0-alpha.10", | ||
"main": "dist/descope-wc", | ||
@@ -8,3 +8,4 @@ "types": "dist/descope-wc.d.ts", | ||
"scripts": { | ||
"start": "rollup -c rollup.config.app.js -w", | ||
"start": "rollup -c rollup.config.app.serve.js -w", | ||
"build-app": "rollup -c rollup.config.app.js", | ||
"build": "rollup -c", | ||
@@ -78,3 +79,3 @@ "test": "jest", | ||
"dependencies": { | ||
"@descope/web-js-sdk": "0.1.0-alpha.7" | ||
"@descope/web-js-sdk": "0.1.0-alpha.8" | ||
}, | ||
@@ -81,0 +82,0 @@ "overrides": { |
@@ -50,5 +50,5 @@ # @descope/web-component | ||
- Install dependencies - `npm i` | ||
- Edit the `src/app/index.html` - replace `<project-id>` and `<project-id>` with your project and a flow | ||
- Edit the `src/app/index.html` - replace `<project-id>` and `<project-id>` or set `DESCOPE_PROJECT_ID` env variable with your project and a flow | ||
- Run application - `npm run start` | ||
_TODO: we should host this file so it can be included without installing the package, once we will publish it to a public registry, we can also use unpkg.com/ to serve it_ |
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
46523
174
+ Added@descope/core-js-sdk@0.0.41-alpha.27(transitive)
+ Added@descope/web-js-sdk@0.1.0-alpha.8(transitive)
- Removed@descope/core-js-sdk@0.0.41-alpha.26(transitive)
- Removed@descope/web-js-sdk@0.1.0-alpha.7(transitive)