@descope/web-component 0.1.0-alpha.19 → 0.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,_ as n,a as t}from"./descope-wc-
|
|
1
|
+
import{S as e,_ as n,a as t}from"./descope-wc-0b46edba.js";const s=(e,n,t,s={})=>{var i,o,l,a;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o:0)),Math.min(Math.max(t,("all"===s.top?e.offsetHeight:null!==(l=s.top)&&void 0!==l?l:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(a=s.bottom)&&void 0!==a?a:0))]};var i,o,l,a,r,d,c,h,p,g;const f=document.createElement("template");f.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class m extends HTMLElement{constructor(){super(),i.add(this),o.set(this,new e({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:n(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),t(this,l,this.shadowRoot.querySelector(".debugger"),"f"),t(this,a,n(this,l,"f").querySelector(".content"),"f"),t(this,r,n(this,l,"f").querySelector(".header"),"f")}updateData(e){n(this,o,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){var e;((e,n,t)=>{let i=0,o=0,l=0,a=0;function r(n){n.preventDefault(),i=l-n.clientX,o=a-n.clientY,l=n.clientX,a=n.clientY;const[r,d]=s(e,e.offsetLeft-i,e.offsetTop-o,t);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,a=e.clientY,document.onmouseup=d,document.onmousemove=r}n?n.onmousedown=c:e.onmousedown=c})(n(this,l,"f"),n(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,d,"f").resize),(e=n(this,l,"f")).onmousemove=n=>{(n.target.w&&n.target.w!==n.target.offsetWidth||n.target.h&&n.target.h!==n.target.offsetHeight)&&e.onresize(n),n.target.w=n.target.offsetWidth,n.target.h=n.target.offsetHeight},n(this,l,"f").onresize=n(this,i,"m",p).bind(this),n(this,o,"f").subscribe(n(this,i,"m",c).bind(this))}disconnectedCallback(){n(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(e){n(this,i,"m",h).call(this,e),n(this,i,"m",p).call(this)},h=function(e){n(this,a,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},p=function(){n(this,a,"f").querySelectorAll(".msg").forEach((e=>{const n=e.querySelector(".msg_desc"),t=n.scrollWidth>n.clientWidth,s=n.clientHeight>20;t||s?(e.classList.add("collapsible"),e.onclick=n=>{n.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},g=function(){const[e,t]=s(n(this,l,"f"),Number.parseInt(n(this,l,"f").style.left,10),Number.parseInt(n(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,l,"f").style.top=`${t}px`,n(this,l,"f").style.left=`${e}px`},customElements.define("descope-debugger",m);export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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 l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d="[object GeneratorFunction]",h=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p=/^\w*$/,f=/^\./,v=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g=/\\(\\)?/g,b=/^\[object .+?Constructor\]$/,w="object"==typeof l&&l&&l.Object===Object&&l,m="object"==typeof self&&self&&self.Object===Object&&self,y=w||m||Function("return this")();var k,I=Array.prototype,O=Function.prototype,j=Object.prototype,S=y["__core-js_shared__"],x=(k=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"",_=O.toString,E=j.hasOwnProperty,U=j.toString,C=RegExp("^"+_.call(E).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=y.Symbol,A=I.splice,R=B(y,"Map"),T=B(Object,"create"),D=P?P.prototype:void 0,M=D?D.toString:void 0;function L(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 N(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 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,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 J(t,e){var n;e=function(t,e){if(G(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Z(t))return!0;return p.test(t)||!h.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:G(n=e)?n:F(n);for(var r=0,o=e.length;null!=t&&r<o;)t=t[H(e[r++])];return r&&r==o?t:void 0}function K(t){if(!V(t)||(e=t,x&&x in e))return!1;var e,n=function(t){var e=V(t)?U.call(t):"";return"[object Function]"==e||e==d}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?C:b;return n.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function W(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 B(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return K(n)?n:void 0}L.prototype.clear=function(){this.__data__=T?T(null):{}},L.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},L.prototype.get=function(t){var e=this.__data__;if(T){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return E.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return T?void 0!==e[t]:E.call(e,t)},L.prototype.set=function(t,e){return this.__data__[t]=T&&void 0===e?"__lodash_hash_undefined__":e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=$(e,t);return!(n<0)&&(n==e.length-1?e.pop():A.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=$(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return $(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=$(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},q.prototype.clear=function(){this.__data__={hash:new L,map:new(R||N),string:new L}},q.prototype.delete=function(t){return W(this,t).delete(t)},q.prototype.get=function(t){return W(this,t).get(t)},q.prototype.has=function(t){return W(this,t).has(t)},q.prototype.set=function(t,e){return W(this,t).set(t,e),this};var F=z((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Z(t))return M?M.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return f.test(t)&&n.push(""),t.replace(v,(function(t,e,r,o){n.push(r?o.replace(g,"$1"):e||t)})),n}));function H(t){if("string"==typeof t||Z(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-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||q),n}z.Cache=q;var G=Array.isArray;function V(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Z(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==U.call(t)}var Q=function(t,e,n){var r=null==t?void 0:J(t,e);return void 0===r?n:r},X="/v1/auth/accesskey/exchange",Y="/v1/auth/otp/verify",tt="/v1/auth/otp/signin",et="/v1/auth/otp/signup",nt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},rt="/v1/auth/otp/signup-in",ot="/v1/auth/magiclink/verify",it="/v1/auth/magiclink/signin",st="/v1/auth/magiclink/signup",at={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ct="/v1/auth/magiclink/signup-in",lt="/v1/auth/enchantedlink/verify",ut="/v1/auth/enchantedlink/signin",dt="/v1/auth/enchantedlink/signup",ht="/v1/auth/enchantedlink/pending-session",pt={email:"/v1/auth/enchantedlink/update/email"},ft="/v1/auth/enchantedlink/signup-in",vt="/v1/auth/oauth/authorize",gt="/v1/auth/oauth/exchange",bt="/v1/auth/saml/authorize",wt="/v1/auth/saml/exchange",mt="/v1/auth/totp/verify",yt="/v1/auth/totp/signup",kt="/v1/user/totp/update",It={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ot={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},jt={start:"/v1/auth/webauthn/signup-in/start"},St={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},xt="/v1/flow/start",_t="/v1/flow/next";const Et=()=>{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")}};var Ut;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ut||(Ut={}));const Ct=(...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}),{})),Pt=t=>void 0===t?void 0:JSON.stringify(t),At=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Rt=({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=>Et().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.clone?t.clone().text():t.text());return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),Et().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:l,headers:u,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:Ct(At(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.34"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Pt(l),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:Ut.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.post,token:o}),put:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.put,token:o}),delete:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.delete,token:o})}};function Tt(t,e,n){var r;let o=Dt(t);e&&(o=null===(r=o.tenants)||void 0===r?void 0:r[e]);const i=o[n];return Array.isArray(i)?i:[]}function Dt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Mt(t){const{exp:e}=Dt(t);return(new Date).getTime()/1e3>e}function Lt(t,e){return Tt(t,e,"permissions")}function Nt(t,e){return Tt(t,e,"roles")}const qt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function $t(t,e){const n=await t,r={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?r.data=e?e(o):o:r.error=o,r}const Jt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Kt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Wt=t=>e=>t.test(e),Bt=Wt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ft=Wt(/^\+[1-9]{1}[0-9]{3,14}$/),Ht=Jt(Bt,'"{val}" is not a valid email'),zt=Jt(Ft,'"{val}" is not a valid phone number'),Gt=Jt((1,t=>t.length>=1),"Minimum length is 1");const Vt=Jt((t=>"string"==typeof t),"Input is not a string"),Zt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Kt(...t).validate(n[e]))),e(...n)),Qt=t=>[Vt(`"${t}" must be a string`),Gt(`"${t}" must not be empty`)],Xt=t=>[Vt(`"${t}" must be a string`),Ht()],Yt=t=>[Vt(`"${t}" must be a string`),zt()],te=Zt(Qt("accessKey")),ee=t=>({exchange:te((e=>$t(t.post(X,{},{token:e}))))});var ne,re,oe,ie,se;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ne||(ne={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(re||(re={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(oe||(oe={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ie||(ie={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(se||(se={}));const ae=Qt("identifier"),ce=Zt(ae,Qt("code")),le=Zt(ae),ue=Zt(ae,Yt("phone")),de=Zt(ae,Xt("email")),he=t=>({verify:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ce(((e,r)=>$t(t.post(qt(Y,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r,o)=>$t(t.post(qt(tt,n),{externalId:e,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>$t(t.post(qt(et,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le((e=>$t(t.post(qt(rt,n),{externalId:e}))))})),{}),update:{email:de(((e,n,r)=>$t(t.post(nt.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(ne).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,r,o)=>$t(t.post(qt(nt.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),pe=Qt("identifier"),fe=Qt("uri"),ve=Zt(Qt("token")),ge=Zt(pe,fe),be=Zt(pe,Yt("phone"),fe),we=Zt(pe,Xt("email"),fe),me=t=>({verify:ve((e=>$t(t.post(ot,{token:e})))),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>$t(t.post(qt(it,n),{externalId:e,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o)=>$t(t.post(qt(st,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r)=>$t(t.post(qt(ct,n),{externalId:e,URI:r}))))})),{}),update:{email:we(((e,n,r,o)=>$t(t.post(at.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(ne).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,r,o,i)=>$t(t.post(qt(at.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})}}),ye=Qt("identifier"),ke=Qt("uri"),Ie=Zt(Qt("token")),Oe=Zt(ye,ke),je=Zt(Qt("pendingRef")),Se=Zt(ye,Xt("email"),ke),xe=t=>({verify:Ie((e=>$t(t.post(lt,{token:e})))),signIn:Oe(((e,n,r,o)=>$t(t.post(qt(ut,re.email),{externalId:e,URI:n,loginOptions:r},{token:o})))),signUpOrIn:Oe(((e,n)=>$t(t.post(qt(ft,re.email),{externalId:e,URI:n})))),signUp:Oe(((e,n,r)=>$t(t.post(qt(dt,re.email),{externalId:e,URI:n,user:r})))),waitForSession:je(((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(ht,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r($t(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Se(((e,n,r,o)=>$t(t.post(pt.email,{externalId:e,email:n,URI:r},{token:o}))))}});var _e;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(_e||(_e={}));const Ee=Zt(Qt("code")),Ue=t=>({start:Object.keys(_e).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={},o,i)=>{const s=await t.post(vt,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!r||!s.ok)return $t(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Ee((e=>$t(t.post(gt,{code:e}))))}),Ce=Zt(Qt("flowId")),Pe=Zt(Qt("executionId"),Qt("stepId"),Qt("interactionId")),Ae=t=>({start:Ce(((e,n,r,o)=>$t(t.post(xt,{flowId:e,options:o,interactionId:n,input:r})))),next:Pe(((e,n,r,o)=>$t(t.post(_t,{executionId:e,stepId:n,interactionId:r,input:o}))))}),Re=Zt(Qt("tenant")),Te=Zt(Qt("code")),De=t=>({start:Re((async(e,n,{redirect:r=!1}={},o,i)=>{const s=await t.post(bt,o||{},{queryParams:{tenant:e,redirectURL:n},token:i});if(!r||!s.ok)return $t(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Te((e=>$t(t.post(wt,{code:e}))))}),Me=Qt("identifier"),Le=Zt(Me,Qt("code")),Ne=Zt(Me),qe=Zt(Me),$e=t=>({signUp:Ne(((e,n)=>$t(t.post(yt,{externalId:e,user:n})))),verify:Le(((e,n,r,o)=>$t(t.post(mt,{externalId:e,code:n,loginOptions:r},{token:o})))),update:qe(((e,n)=>$t(t.post(kt,{externalId:e},{token:n}))))}),Je=Qt("identifier"),Ke=Qt("origin"),We=Zt(Je,Ke,Qt("name")),Be=Zt(Je,Ke),Fe=Zt(Je,Ke,Qt("token")),He=Zt(Qt("transactionId"),Qt("response")),ze=t=>({signUp:{start:We(((e,n,r)=>$t(t.post(It.start,{user:{externalId:e,name:r},origin:n})))),finish:He(((e,n)=>$t(t.post(It.finish,{transactionId:e,response:n}))))},signIn:{start:Be(((e,n,r,o)=>$t(t.post(Ot.start,{externalId:e,origin:n,loginOptions:r},{token:o})))),finish:He(((e,n)=>$t(t.post(Ot.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Be(((e,n)=>$t(t.post(jt.start,{externalId:e,origin:n}))))},update:{start:Fe(((e,n,r)=>$t(t.post(St.start,{externalId:e,origin:n},{token:r})))),finish:He(((e,n)=>$t(t.post(St.finish,{transactionId:e,response:n}))))}}),Ge=Zt(Qt("token"));var Ve;const Ze=Zt([("projectId",Ve=Qt("projectId"),Jt(((t,e)=>t=>Kt(...e).validate(Q(t,"projectId")))(0,Ve))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Rt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{accessKey:ee(i),otp:he(i),magicLink:me(i),enchantedLink:xe(i),oauth:Ue(i),saml:De(i),totp:$e(i),webauthn:ze(i),flow:Ae(i),refresh:t=>$t(i.post("/v1/auth/refresh",{},{token:t})),logout:t=>$t(i.post("/v1/auth/logout",{},{token:t})),logoutAll:t=>$t(i.post("/v1/auth/logoutall",{},{token:t})),me:t=>$t(i.get("/v1/auth/me",{token:t})),isJwtExpired:Ge(Mt),getJwtPermissions:Ge(Lt),getJwtRoles:Ge(Nt),httpClient:i};var i}));function Qe(t,e){var n=[];return function(t,e){var n,r,o=(r=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}(t),{current:function(){return r[0]},postpone:function(){var t=r.shift();void 0!==t&&r.push(t)},exclude:function(){r.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=o.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return"Blocked by CSP"===e||"9319"===e}(t)?o.postpone():o.exclude();var e,r=o.current();if(void 0===r)throw t;return(e=i(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(r,n+1)}))}))};return a(s,0)}(t,(function(t){var r=new Date,o=function(){return n.push({url:t,startedAt:r,finishedAt:new Date})},i=e(t);return i.then(o,o),i})).then((function(t){return[t,{attempts:n}]}))}Ze.DeliveryMethods=re;var Xe="Failed to load the JS script of the agent";function Ye(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=e(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");return Qe(function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.8.1"):t}))}(String(t),e)}))}(c,s),tn).catch(nn)})).then((function(e){var n=e[0],r=e[1];return n.load(t(t({},a),{ldi:r}))}))}function tn(t){return 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(){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(Xe))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)})).then(en)}function en(){var t=window,e="__fpjs_p_l_b",n=t[e];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)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error("9319");return n}function nn(t){throw t instanceof Error&&"9319"===t.message?new Error(Xe):t}var rn={exports:{}},on={exports:{}};on.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:"/"})}();var sn=u(rn.exports=on.exports);const an="undefined"!=typeof window,cn=an&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",ln=an&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",un=(t="",e="")=>({vsid:t,vrid:e}),dn=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},hn=async t=>{try{if(dn())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Ye({apiKey:t||cn,endpoint:ln}),r=await n,{requestId:o}=await r.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(un(e,o))}catch(t){global.FB_DEBUG&&console.error(t)}};var pn,fn,vn,gn,bn;const wn=t=>Object.assign({},t);class mn{constructor(t){pn.add(this),fn.set(this,void 0),vn.set(this,{}),gn.set(this,0),o(this,fn,t,"f")}get current(){return wn(r(this,fn,"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,fn,"f"),e)){const t=r(this,fn,"f");o(this,fn,e,"f"),Object.freeze(r(this,fn,"f")),setTimeout((()=>{Object.values(r(this,vn,"f")).forEach((n=>n(wn(e),t)))}),0)}}subscribe(t){o(this,gn,r(this,gn,"f")+1,"f"),r(this,vn,"f")[r(this,gn,"f")]=t;const e=r(this,gn,"f");return()=>r(this,pn,"m",bn).call(this,e.toString())}unsubscribeAll(){o(this,vn,{},"f")}}fn=new WeakMap,vn=new WeakMap,gn=new WeakMap,pn=new WeakSet,bn=function(t){r(this,vn,"f")[t]&&delete r(this,vn,"f")[t]};let yn=[];function kn(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=yn.pop();)clearTimeout(e);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{t(n)}),o);yn.push(i)}}function In(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&sn.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 On(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function jn(t){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);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:En(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:En(n.response.attestationObject),clientDataJSON:En(n.response.clientDataJSON)})}));var n}async function Sn(t){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);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:En(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:En(n.response.authenticatorData),clientDataJSON:En(n.response.clientDataJSON),signature:En(n.response.signature),userHandle:n.response.userHandle?En(n.response.userHandle):void 0})}));var n}async function xn(t=!1){if(!an)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function _n(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function En(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const Un="undefined"!=typeof window&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Cn="redirect",Pn="poll",An="webauthnCreate",Rn="webauthnGet";function Tn(t){return new URLSearchParams(window.location.search).get(t)}function Dn(t){if(window.history.replaceState&&Tn(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 Mn;function Ln(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"}(Mn||(Mn={}));function Nn(t,e){const n=new URL(Un);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function qn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Mn.forward:t<e?Mn.backward:void 0}const $n=()=>{const[t="",e=""]=(Tn("descope-login-flow")||"").split("_");return{executionId:t,stepId:e}};function Jn(){Dn("descope-login-flow")}const Kn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Wn,Bn,Fn;function Hn(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(!Hn(i,s))return!1}else if(i!==s)return!1}return!0}class zn{constructor(t={}){Wn.set(this,void 0),Bn.set(this,{}),Fn.set(this,0),o(this,Wn,t,"f")}get current(){return Object.assign({},r(this,Wn,"f"))}update(t){const e="function"==typeof t?t(r(this,Wn,"f")):t,n=Object.assign(Object.assign({},r(this,Wn,"f")),e);if(!Hn(r(this,Wn,"f"),n)){const t=r(this,Wn,"f");o(this,Wn,n,"f"),Object.freeze(r(this,Wn,"f")),setTimeout((()=>{Object.values(r(this,Bn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,Fn,r(this,Fn,"f")+1,"f"),r(this,Bn,"f")[r(this,Fn,"f")]=t,r(this,Fn,"f").toString()}unsubscribe(t){const e=!!r(this,Bn,"f")[t];return e&&delete r(this,Bn,"f")[t],e}unsubscribeAll(){return o(this,Bn,{},"f"),!0}}Wn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap;const Gn=(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 Vn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),n.publicKey.user.id=Qn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:Xn(r.rawId),type:r.type,response:{attestationObject:Xn(r.response.attestationObject),clientDataJSON:Xn(r.response.clientDataJSON)}});var r}))}function Zn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:Xn(r.rawId),type:r.type,response:{authenticatorData:Xn(r.response.authenticatorData),clientDataJSON:Xn(r.response.clientDataJSON),signature:Xn(r.response.signature),userHandle:Xn(r.response.userHandle)}});var r}))}function Qn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Xn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var Yn,tr,er,nr,rr,or,ir,sr,ar,cr,lr,ur,dr,hr,pr,fr,vr,gr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,xr,_r,Er;const Ur=document.createElement("template");Ur.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\tform[data-theme] {\n\t\t\tbackground-color: transparent;\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 Cr extends HTMLElement{constructor(){super(),Yn.add(this),tr.set(this,!1),er.set(this,new zn),nr.set(this,new zn),rr.set(this,new zn({isLoading:!1})),or.set(this,void 0),ir.set(this,void 0),sr.set(this,void 0),ar.set(this,void 0),cr.set(this,{popstate:r(this,Yn,"m",pr).bind(this)}),lr.set(this,void 0),ur.set(this,void 0),wr.set(this,(t=>{var e,n,o,i,s;if(!(null==t?void 0:t.ok))return r(this,Yn,"m",Ir).call(this,"error",null==t?void 0:t.error),void r(this,Yn,"m",Er).call(this,{title:null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorDescription,description:null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.message});const a=null===(s=null===(i=null===(o=t.data)||void 0===o?void 0:o.screen)||void 0===i?void 0:i.state)||void 0===s?void 0:s.errorText;a&&r(this,Yn,"m",Er).call(this,{title:a});const{status:c,authInfo:l}=t.data;if("completed"===c)return void r(this,Yn,"m",Ir).call(this,"success",l);const{executionId:u,stepId:d,action:h,screen:p,redirect:f,webauthn:v}=t.data;r(this,er,"f").update({stepId:d,executionId:u,action:h,redirectUrl:null==f?void 0:f.url,screenId:null==p?void 0:p.id,screenState:null==p?void 0:p.state,webauthnTransactionId:null==v?void 0:v.transactionId,webauthnOptions:null==v?void 0:v.options})})),Or.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=Nn(this["project-id"],"config.json");try{t=yield Ln(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),r(this,Yn,"m",dr).call(this),r(this,er,"f").subscribe(r(this,Yn,"m",br).bind(this)),r(this,nr,"f").subscribe(r(this,Yn,"m",yr).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug"]}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}get debug(){return"true"===this.getAttribute("debug")}get theme(){var t,e;const n=this.getAttribute("theme");if(n)return n;return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){o(this,tr,!0,"f"),r(this,Yn,"m",hr).call(this),r(this,Yn,"m",xr).call(this);const t=yield r(this,Or,"f").call(this),e=this["flow-id"];o(this,ur,((t,e)=>{var n;return(null===(n=null==t?void 0:t.flows)||void 0===n?void 0:n[e])||{}})(t,e),"f"),r(this,Yn,"m",Sr).call(this,t),r(this,Yn,"m",gr).call(this),r(this,Yn,"m",_r).call(this);const{executionId:n,stepId:i}=$n();(n||i)&&Jn();const s=Tn("t")||void 0;s&&Dn("t");const a=Tn("code")||void 0;a&&Dn("code"),r(this,er,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],tenant:this.tenant,stepId:i,executionId:n,token:s,code:a}),window.addEventListener("popstate",r(this,cr,"f").popstate),r(this,or,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=r(this,or,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}))}disconnectedCallback(){r(this,er,"f").unsubscribeAll(),r(this,nr,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,cr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,tr,"f")){if(e!==n&&Cr.observedAttributes.includes(t)){r(this,Yn,"m",hr).call(this);const o=null===e;r(this,er,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,Jn()),{[Kn(t)]:n,stepId:i,executionId:s}}))}"debug"===t&&r(this,Yn,"m",_r).call(this)}}}tr=new WeakMap,er=new WeakMap,nr=new WeakMap,rr=new WeakMap,or=new WeakMap,ir=new WeakMap,sr=new WeakMap,ar=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,wr=new WeakMap,Or=new WeakMap,Yn=new WeakSet,dr=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ur.content.cloneNode(!0)),o(this,or,this.shadowRoot.querySelector("form"),"f"),o(this,ir,this.shadowRoot.querySelector("style"),"f")},hr=function(){const t=["base-url","tenant","theme","debug"];if(Cr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},pr=function(){const{stepId:t,executionId:e}=$n();r(this,er,"f").update({stepId:t,executionId:e})},fr=function(t){return(...e)=>n(this,void 0,void 0,(function*(){r(this,rr,"f").update({isLoading:!0});try{return yield t(...e)}finally{r(this,rr,"f").update({isLoading:!1})}}))},vr=function(t,n){o(this,lr,(t=>{var{autoRefresh:n=!0,persistTokens:r=!0,fpKey:o,fpLoad:i}=t,s=e(t,["autoRefresh","persistTokens","fpKey","fpLoad"]);an?i&&hn(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const a=s;let c,l;const u=new mn({sessionToken:""}),d=new mn({});a.hooks={beforeRequest:t=>null==c?void 0:c(t),afterRequest:(t,e)=>null==l?void 0:l(t,e)};const h=Ze(a),p=(f=h,{async signUp(t,e){const n=await f.webauthn.signUp.start(t,window.location.origin,e),r=await jn(n.data.options);return await f.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(t){const e=await f.webauthn.signIn.start(t,window.location.origin),n=await Sn(e.data.options);return await f.webauthn.signIn.finish(e.data.transactionId,n)},async signUpOrIn(t){var e;const n=await f.webauthn.signUpOrIn.start(t,window.location.origin);if(null===(e=n.data)||void 0===e?void 0:e.create){const t=await jn(n.data.options);return await f.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await Sn(n.data.options);return await f.webauthn.signIn.finish(n.data.transactionId,t)}},async update(t,e){const n=await f.webauthn.update.start(t,window.location.origin,e),r=await jn(n.data.options);return await f.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:jn,get:Sn,isSupported:xn}});var f;const v=Object.assign(Object.assign({},h),{flow:Object.assign(Object.assign({},h.flow),{start:async(t,e,n,r)=>{const o=await p.helpers.isSupported(),i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dls_last_user_external_id"),s={tenant:null==r?void 0:r.tenant,redirectUrl:window.location.href,deviceInfo:{webAuthnSupport:o}};return i&&(s.lastUser={externalId:i}),h.flow.start(t,e,n,s)}}),webauthn:p,onSessionTokenChange:t=>{var e;const n=null===(e=u.current)||void 0===e?void 0:e.sessionToken;return n&&t(n),u.subscribe((({sessionToken:e})=>{t(e)}))},onUserChange:t=>{const e=d.current;return e&&Object.entries(e).length>0&&t(e),d.subscribe((e=>{t(e)}))},getRefreshToken:On});return an?(n&&["logout","logoutAll"].forEach((t=>{const e=h[t];v[t]=(...t)=>{const n=On(),r=[(null==t?void 0:t.shift())||n,...t],o=e(...r);return localStorage&&localStorage.removeItem("DSR"),sn.remove("DS"),an&&(null===localStorage||void 0===localStorage||localStorage.removeItem("dls_last_user_external_id")),u.update({sessionToken:""}),o}})),c=t=>(t.body&&(t.body.fpData=dn(!0)||un()),!t.token&&r&&(t.token=On()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.14"}),t),v.me=async(...t)=>{var e;const n=await h.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());d.update(t)}return n},(n||r)&&(l=(t,o)=>{!async function(t,n,r,o){var i;try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const s=await(null==n?void 0:n.json());if(s){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(s),{sessionJwt:a,refreshJwt:c,user:l}=n,u=e(n,["sessionJwt","refreshJwt","user"]);if(o.persistTokens&&In(a,c,u),a&&r.sessionToken.update({sessionToken:a}),l){const t=null===(i=null==l?void 0:l.externalIds)||void 0===i?void 0:i[0];an&&t&&(null===localStorage||void 0===localStorage||localStorage.setItem("dls_last_user_external_id",t)),r.user.update(l)}a&&c&&o.autoRefresh&&kn(t,a,c)}}catch(t){console.error("Could not set tokens from body",t)}}(v.refresh,o,{sessionToken:u,user:d},{autoRefresh:n,persistTokens:r})}),n&&On()&&v.refresh(),v):(console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),v)})({projectId:t,baseUrl:n,autoRefresh:!1,fpLoad:!0}),"f");const i=r(this,lr,"f").flow.next;r(this,lr,"f").flow.next=r(this,Yn,"m",fr).call(this,i)},gr=function(){r(this,or,"f").setAttribute("data-theme",this.theme)},br=function(t,e,i){var s;return n(this,void 0,void 0,(function*(){const{projectId:a,flowId:c,baseUrl:l,tenant:u,stepId:d,executionId:h,action:p,screenId:f,screenState:v,redirectUrl:g,token:b,code:w,webauthnTransactionId:m,webauthnOptions:y}=t,k=i("projectId")||i("baseUrl");if(r(this,ar,"f")&&(clearInterval(r(this,ar,"f")),o(this,ar,null,"f")),k){if(!a)return;r(this,Yn,"m",vr).call(this,a,l)}if(!h){if(!c)return;const t=null===(s=r(this,ur,"f"))||void 0===s?void 0:s.startScreenId;if(t){const e={htmlUrl:Nn(a,`${t}.html`)};return r(this,nr,"f").update(e),void(r(this,lr,"f").flow.start=r(this,Yn,"m",fr).call(this,r(this,lr,"f").flow.start))}const e=yield r(this,lr,"f").flow.start(c,"",null,{tenant:u});return void r(this,wr,"f").call(this,e)}if(i("token")&&b||i("code")&&w){const t=yield r(this,lr,"f").flow.next(h,d,"submit",{token:b,exchangeCode:w});return r(this,wr,"f").call(this,t),void r(this,er,"f").update({token:void 0,code:void 0})}if(p===Cn)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(p===An||p===Rn){if(!m||!y)return void console.error("Did not get webauthn transaction id or options");const t=p===An?yield Vn(y):yield Zn(y),e=yield r(this,lr,"f").flow.next(h,d,"submit",{transactionId:m,response:t});return void r(this,wr,"f").call(this,e)}if(p===Pn&&o(this,ar,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,lr,"f").flow.next(h,d,"submit",{});r(this,wr,"f").call(this,t)}))),2e3),"f"),!f)return void console.error("Refreshing the page during a flow is not supported yet");const I={direction:qn(+d,+e.stepId),screenState:v,htmlUrl:Nn(a,`${f}.html`)};(k||i("executionId")||i("stepId"))&&(I.next=(...t)=>r(this,lr,"f").flow.next(h,d,...t)),r(this,nr,"f").update(I)}))},mr=function(t){r(this,or,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const o=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),i=r(this,rr,"f").subscribe((({isLoading:t})=>{var n,o,s,a;t?null===(o=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,rr,"f").unsubscribe(i),null===(a=null===(s=e.submitter)||void 0===s?void 0:s.classList)||void 0===a||a.remove("loading"))}));e.preventDefault();const s=Object.fromEntries(new FormData(e.target).entries()),a=(c=e.submitter,Array.from((null==c?void 0:c.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 c;const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:window.location.origin});let u;const{executionId:d,tenant:h,flowId:p}=r(this,er,"f").current;u=d?yield t(o,l):yield r(this,lr,"f").flow.start(p,o,l,{tenant:h}),r(this,wr,"f").call(this,u)}))},yr=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 Ln(e,"text");const c=a.content.cloneNode(!0),l=(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),u=()=>{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),Gn(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{l.forEach((t=>t()))}catch(t){console.error(t)}r(this,or,"f").replaceChildren(c),r(this,Yn,"m",mr).call(this,i),r(this,Yn,"m",Ir).call(this,"page-updated",{})};o?r(this,Yn,"m",kr).call(this,u,o):u()}))},kr=function(t,e){r(this,or,"f").addEventListener("transitionend",(()=>{r(this,or,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===Mn.forward?"slide-forward":"slide-backward";Array.from(r(this,or,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,or,"f").classList.add("fade-out")},Ir=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},jr=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},Sr=function(t){var e,n,o,i;null===(i=null===(o=null===(n=null===(e=null==t?void 0:t.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===n?void 0:n.typography)||void 0===o?void 0:o.fontFamilies)||void 0===i||i.forEach((t=>{r(this,Yn,"m",jr).call(this,t.url)}))},xr=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=Nn(this["project-id"],"theme.css");t.innerText=yield Ln(e,"text"),this.shadowRoot.appendChild(t)}))},_r=function(){var t;return n(this,void 0,void 0,(function*(){this.debug?(yield import("./debugger-wc-ff97cdb6.js"),o(this,sr,document.createElement("descope-debugger"),"f"),Object.assign(r(this,sr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(r(this,sr,"f"))):(null===(t=r(this,sr,"f"))||void 0===t||t.remove(),o(this,sr,null,"f"))}))},Er=function({title:t,description:e=""}){var n;t&&this.debug&&(null===(n=r(this,sr,"f"))||void 0===n||n.updateData({title:t,description:e}))},customElements.define("descope-wc",Cr);export{Cr as D,zn as S,r as _,o as a};
|
package/dist/descope-wc.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{D as default}from"./descope-wc-
|
|
1
|
+
export{D as default}from"./descope-wc-0b46edba.js";
|
package/dist/descope-wc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}function r(t){this.message=t}r.prototype=new Error,r.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 r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);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 l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(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=/^\./,m=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,w=/^\[object .+?Constructor\]$/,y="object"==typeof l&&l&&l.Object===Object&&l,k="object"==typeof self&&self&&self.Object===Object&&self,x=y||k||Function("return this")();var I,O=Array.prototype,j=Function.prototype,S=Object.prototype,_=x["__core-js_shared__"],E=(I=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",C=j.toString,U=S.hasOwnProperty,A=S.toString,P=RegExp("^"+C.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),R=x.Symbol,T=O.splice,L=z(x,"Map"),M=z(Object,"create"),D=R?R.prototype:void 0,N=D?D.toString:void 0;function $(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function q(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function W(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function J(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function K(t,e){var n;e=function(t,e){if(G(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Y(t))return!0;return g.test(t)||!f.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:G(n=e)?n:B(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Z(e[o++])];return o&&o==i?t:void 0}function F(t){if(!V(t)||(e=t,E&&E in e))return!1;var e,n=function(t){var e=V(t)?A.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)?P:w;return n.test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function H(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return F(n)?n:void 0}$.prototype.clear=function(){this.__data__=M?M(null):{}},$.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},$.prototype.get=function(t){var e=this.__data__;if(M){var n=e[t];return n===d?void 0:n}return U.call(e,t)?e[t]:void 0},$.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:U.call(e,t)},$.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},q.prototype.clear=function(){this.__data__=[]},q.prototype.delete=function(t){var e=this.__data__,n=J(e,t);return!(n<0)&&(n==e.length-1?e.pop():T.call(e,n,1),!0)},q.prototype.get=function(t){var e=this.__data__,n=J(e,t);return n<0?void 0:e[n][1]},q.prototype.has=function(t){return J(this.__data__,t)>-1},q.prototype.set=function(t,e){var n=this.__data__,o=J(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},W.prototype.clear=function(){this.__data__={hash:new $,map:new(L||q),string:new $}},W.prototype.delete=function(t){return H(this,t).delete(t)},W.prototype.get=function(t){return H(this,t).get(t)},W.prototype.has=function(t){return H(this,t).has(t)},W.prototype.set=function(t,e){return H(this,t).set(t,e),this};var B=X((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Y(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(m,(function(t,e,o,i){n.push(o?i.replace(b,"$1"):e||t)})),n}));function Z(t){if("string"==typeof t||Y(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function X(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new(X.Cache||W),n}X.Cache=W;var G=Array.isArray;function V(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Y(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==A.call(t)}var Q=function(t,e,n){var o=null==t?void 0:K(t,e);return void 0===o?n:o},tt="/v1/auth/accesskey/exchange",et="/v1/auth/otp/verify",nt="/v1/auth/otp/signin",ot="/v1/auth/otp/signup",it={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},rt="/v1/auth/otp/signup-in",st="/v1/auth/magiclink/verify",at="/v1/auth/magiclink/signin",ct="/v1/auth/magiclink/signup",lt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ut="/v1/auth/magiclink/signup-in",dt="/v1/auth/enchantedlink/verify",ht="/v1/auth/enchantedlink/signin",pt="/v1/auth/enchantedlink/signup",ft="/v1/auth/enchantedlink/pending-session",gt={email:"/v1/auth/enchantedlink/update/email"},vt="/v1/auth/enchantedlink/signup-in",mt="/v1/auth/oauth/authorize",bt="/v1/auth/oauth/exchange",wt="/v1/auth/saml/authorize",yt="/v1/auth/saml/exchange",kt="/v1/auth/totp/verify",xt="/v1/auth/totp/signup",It="/v1/user/totp/update",Ot={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},jt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},St={start:"/v1/auth/webauthn/signup-in/start"},_t={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Et="/v1/flow/start",Ct="/v1/flow/next";const Ut=()=>{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")}};var At;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(At||(At={}));const Pt=(...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,o])=>(t[n]=o,t)),t),t}),{})),Rt=t=>void 0===t?void 0:JSON.stringify(t),Tt=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Lt=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r})=>{const s=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>Ut().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await(t.clone?t.clone().text():t.text());return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),Ut().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o),a=async o=>{const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:l,headers:u,queryParams:d,method:h,token:p}=a,f=await s((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:c,baseUrl:t,queryParams:d}),{headers:Pt(Tt(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.34"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Rt(l),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>a({path:t,headers:e,queryParams:n,body:void 0,method:At.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.delete,token:i})}};function Mt(t,e,n){var o;let i=Dt(t);e&&(i=null===(o=i.tenants)||void 0===o?void 0:o[e]);const r=i[n];return Array.isArray(r)?r:[]}function Dt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Nt(t){const{exp:e}=Dt(t);return(new Date).getTime()/1e3>e}function $t(t,e){return Mt(t,e,"permissions")}function qt(t,e){return Mt(t,e,"roles")}const Wt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Jt(t,e){const n=await t,o={code:n.status,ok:n.ok,response:n},i=await n.clone().json();return n.ok?o.data=e?e(i):i:o.error=i,o}const Kt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ft=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ht=t=>e=>t.test(e),zt=Ht(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Bt=Ht(/^\+[1-9]{1}[0-9]{3,14}$/),Zt=Kt(zt,'"{val}" is not a valid email'),Xt=Kt(Bt,'"{val}" is not a valid phone number'),Gt=Kt((1,t=>t.length>=1),"Minimum length is 1");const Vt=Kt((t=>"string"==typeof t),"Input is not a string"),Yt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ft(...t).validate(n[e]))),e(...n)),Qt=t=>[Vt(`"${t}" must be a string`),Gt(`"${t}" must not be empty`)],te=t=>[Vt(`"${t}" must be a string`),Zt()],ee=t=>[Vt(`"${t}" must be a string`),Xt()],ne=Yt(Qt("accessKey")),oe=t=>({exchange:ne((e=>Jt(t.post(tt,{},{token:e}))))});var ie,re,se,ae,ce;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ie||(ie={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(re||(re={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(se||(se={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ae||(ae={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(ce||(ce={}));const le=Qt("identifier"),ue=Yt(le,Qt("code")),de=Yt(le),he=Yt(le,ee("phone")),pe=Yt(le,te("email")),fe=t=>({verify:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o)=>Jt(t.post(Wt(et,n),{code:o,externalId:e}))))})),{}),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o,i)=>Jt(t.post(Wt(nt,n),{externalId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o)=>Jt(t.post(Wt(ot,n),{externalId:e,user:o}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de((e=>Jt(t.post(Wt(rt,n),{externalId:e}))))})),{}),update:{email:pe(((e,n,o)=>Jt(t.post(it.email,{externalId:e,email:n},{token:o})))),phone:Object.keys(ie).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i)=>Jt(t.post(Wt(it.phone,n),{externalId:e,phone:o},{token:i}))))})),{})}}),ge=Qt("identifier"),ve=Qt("uri"),me=Yt(Qt("token")),be=Yt(ge,ve),we=Yt(ge,ee("phone"),ve),ye=Yt(ge,te("email"),ve),ke=t=>({verify:me((e=>Jt(t.post(st,{token:e})))),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o,i,r)=>Jt(t.post(Wt(at,n),{externalId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o,i)=>Jt(t.post(Wt(ct,n),{externalId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o)=>Jt(t.post(Wt(ut,n),{externalId:e,URI:o}))))})),{}),update:{email:ye(((e,n,o,i)=>Jt(t.post(lt.email,{externalId:e,email:n,URI:o},{token:i})))),phone:Object.keys(ie).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:we(((e,o,i,r)=>Jt(t.post(Wt(lt.phone,n),{externalId:e,phone:o,URI:i},{token:r}))))})),{})}}),xe=Qt("identifier"),Ie=Qt("uri"),Oe=Yt(Qt("token")),je=Yt(xe,Ie),Se=Yt(Qt("pendingRef")),_e=Yt(xe,te("email"),Ie),Ee=t=>({verify:Oe((e=>Jt(t.post(dt,{token:e})))),signIn:je(((e,n,o,i)=>Jt(t.post(Wt(ht,re.email),{externalId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:je(((e,n)=>Jt(t.post(Wt(vt,re.email),{externalId:e,URI:n})))),signUp:je(((e,n,o)=>Jt(t.post(Wt(pt,re.email),{externalId:e,URI:n,user:o})))),waitForSession:Se(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({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(ft,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:_e(((e,n,o,i)=>Jt(t.post(gt.email,{externalId:e,email:n,URI:o},{token:i}))))}});var Ce;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(Ce||(Ce={}));const Ue=Yt(Qt("code")),Ae=t=>({start:Object.keys(Ce).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},i,r)=>{const s=await t.post(mt,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r});if(!o||!s.ok)return Jt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Ue((e=>Jt(t.post(bt,{code:e}))))}),Pe=Yt(Qt("flowId")),Re=Yt(Qt("executionId"),Qt("stepId"),Qt("interactionId")),Te=t=>({start:Pe(((e,n,o,i)=>Jt(t.post(Et,{flowId:e,options:i,interactionId:n,input:o})))),next:Re(((e,n,o,i)=>Jt(t.post(Ct,{executionId:e,stepId:n,interactionId:o,input:i}))))}),Le=Yt(Qt("tenant")),Me=Yt(Qt("code")),De=t=>({start:Le((async(e,n,{redirect:o=!1}={},i,r)=>{const s=await t.post(wt,i||{},{queryParams:{tenant:e,redirectURL:n},token:r});if(!o||!s.ok)return Jt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Me((e=>Jt(t.post(yt,{code:e}))))}),Ne=Qt("identifier"),$e=Yt(Ne,Qt("code")),qe=Yt(Ne),We=Yt(Ne),Je=t=>({signUp:qe(((e,n)=>Jt(t.post(xt,{externalId:e,user:n})))),verify:$e(((e,n,o,i)=>Jt(t.post(kt,{externalId:e,code:n,loginOptions:o},{token:i})))),update:We(((e,n)=>Jt(t.post(It,{externalId:e},{token:n}))))}),Ke=Qt("identifier"),Fe=Qt("origin"),He=Yt(Ke,Fe,Qt("name")),ze=Yt(Ke,Fe),Be=Yt(Ke,Fe,Qt("token")),Ze=Yt(Qt("transactionId"),Qt("response")),Xe=t=>({signUp:{start:He(((e,n,o)=>Jt(t.post(Ot.start,{user:{externalId:e,name:o},origin:n})))),finish:Ze(((e,n)=>Jt(t.post(Ot.finish,{transactionId:e,response:n}))))},signIn:{start:ze(((e,n,o,i)=>Jt(t.post(jt.start,{externalId:e,origin:n,loginOptions:o},{token:i})))),finish:Ze(((e,n)=>Jt(t.post(jt.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:ze(((e,n)=>Jt(t.post(St.start,{externalId:e,origin:n}))))},update:{start:Be(((e,n,o)=>Jt(t.post(_t.start,{externalId:e,origin:n},{token:o})))),finish:Ze(((e,n)=>Jt(t.post(_t.finish,{transactionId:e,response:n}))))}}),Ge=Yt(Qt("token"));var Ve;const Ye=Yt([("projectId",Ve=Qt("projectId"),Kt(((t,e)=>t=>Ft(...e).validate(Q(t,"projectId")))(0,Ve))())])((({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i})=>{return r=Lt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i}),{accessKey:oe(r),otp:fe(r),magicLink:ke(r),enchantedLink:Ee(r),oauth:Ae(r),saml:De(r),totp:Je(r),webauthn:Xe(r),flow:Te(r),refresh:t=>Jt(r.post("/v1/auth/refresh",{},{token:t})),logout:t=>Jt(r.post("/v1/auth/logout",{},{token:t})),logoutAll:t=>Jt(r.post("/v1/auth/logoutall",{},{token:t})),me:t=>Jt(r.get("/v1/auth/me",{token:t})),isJwtExpired:Ge(Nt),getJwtPermissions:Ge($t),getJwtRoles:Ge(qt),httpClient:r};var r}));function Qe(t,e){var n=[];return function(t,e){var n,o,i=(o=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),i=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,i++)o[i]=r[s];return o}(t),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return"Blocked by CSP"===e||"9319"===e}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}Ye.DeliveryMethods=re;var tn="Failed to load the JS script of the agent";function en(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");return Qe(function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.8.1"):t}))}(String(t),e)}))}(c,s),nn).catch(rn)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function nn(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,c())};r.addEventListener(s,a);var c=function(){return r.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(),i)return function(){throw new Error("Blocked by CSP")}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(tn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(on)}function on(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error("9319");return n}function rn(t){throw t instanceof Error&&"9319"===t.message?new Error(tn):t}var sn={exports:{}},an={exports:{}};an.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}function e(n,o){function i(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=t({},o,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in r)r[a]&&(s+="; "+a,!0!==r[a]&&(s+="="+r[a].split(";")[0]));return document.cookie=e+"="+n.write(i,e)+s}}function r(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],o={},i=0;i<e.length;i++){var r=e[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=n.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}}return Object.create({set:i,get:r,remove:function(e,n){i(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(o)},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=an.exports}(sn);var cn=u(sn.exports);const ln="undefined"!=typeof window,un=ln&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",dn=ln&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",hn=t=>{const e=en({apiKey:t||un,endpoint:dn});return{get:async()=>{try{let t=sessionStorage.getItem("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,o=await n.get({linkedId:t});sessionStorage.setItem("vrid",o.requestId)}catch(t){global.FB_DEBUG&&console.error(t)}}}};var pn,fn,gn,vn,mn;const bn=t=>Object.assign({},t);class wn{constructor(t){pn.add(this),fn.set(this,void 0),gn.set(this,{}),vn.set(this,0),i(this,fn,t,"f")}get current(){return bn(o(this,fn,"f"))}update(t){const e=t;if(!((t,e)=>{const n=t&&Object.getOwnPropertyNames(t)||[],o=e&&Object.getOwnPropertyNames(e)||[];if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o];if(t[i]!==e[i])return!1}return!0})(o(this,fn,"f"),e)){const t=o(this,fn,"f");i(this,fn,e,"f"),Object.freeze(o(this,fn,"f")),setTimeout((()=>{Object.values(o(this,gn,"f")).forEach((n=>n(bn(e),t)))}),0)}}subscribe(t){i(this,vn,o(this,vn,"f")+1,"f"),o(this,gn,"f")[o(this,vn,"f")]=t;const e=o(this,vn,"f");return()=>o(this,pn,"m",mn).call(this,e.toString())}unsubscribeAll(){i(this,gn,{},"f")}}fn=new WeakMap,gn=new WeakMap,vn=new WeakMap,pn=new WeakSet,mn=function(t){o(this,gn,"f")[t]&&delete o(this,gn,"f")[t]};let yn=[];function kn(t,e,n){const o=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(o){let e;for(;e=yn.pop();)clearTimeout(e);const i=o.getTime()-2e4-(new Date).getTime(),r=setTimeout((()=>{t(n)}),i);yn.push(r)}}function xn(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:o}){t&&cn.set("DS",t,{path:e,domain:n,expires:o,sameSite:"None",secure:!0})}(t,n),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(e)}function In(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function On(t){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);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:En(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:En(n.response.attestationObject),clientDataJSON:En(n.response.clientDataJSON)})}));var n}async function jn(t){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);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:En(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:En(n.response.authenticatorData),clientDataJSON:En(n.response.clientDataJSON),signature:En(n.response.signature),userHandle:n.response.userHandle?En(n.response.userHandle):void 0})}));var n}async function Sn(t=!1){if(!ln)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function _n(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function En(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const Cn="undefined"!=typeof window&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Un="descope-login-flow",An="code",Pn="redirect",Rn="poll",Tn="webauthnCreate",Ln="webauthnGet";function Mn(t){return new URLSearchParams(window.location.search).get(t)}function Dn(t){if(window.history.replaceState&&Mn(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 Nn;function $n(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"}(Nn||(Nn={}));function qn(t,e){const n=new URL(Cn);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function Wn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Nn.forward:t<e?Nn.backward:void 0}const Jn=()=>{const[t="",e=""]=(Mn(Un)||"").split("_");return{executionId:t,stepId:e}};function Kn(){Dn(Un)}const Fn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Hn,zn,Bn;function Zn(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if("object"==typeof r&&"object"==typeof s){if(!Zn(r,s))return!1}else if(r!==s)return!1}return!0}class Xn{constructor(t={}){Hn.set(this,void 0),zn.set(this,{}),Bn.set(this,0),i(this,Hn,t,"f")}get current(){return Object.assign({},o(this,Hn,"f"))}update(t){const e="function"==typeof t?t(o(this,Hn,"f")):t,n=Object.assign(Object.assign({},o(this,Hn,"f")),e);if(!Zn(o(this,Hn,"f"),n)){const t=o(this,Hn,"f");i(this,Hn,n,"f"),Object.freeze(o(this,Hn,"f")),setTimeout((()=>{Object.values(o(this,zn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return i(this,Bn,o(this,Bn,"f")+1,"f"),o(this,zn,"f")[o(this,Bn,"f")]=t,o(this,Bn,"f").toString()}unsubscribe(t){const e=!!o(this,zn,"f")[t];return e&&delete o(this,zn,"f")[t],e}unsubscribeAll(){return i(this,zn,{},"f"),!0}}Hn=new WeakMap,zn=new WeakMap,Bn=new WeakMap;const Gn=(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 o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)};function Vn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),n.publicKey.user.id=Qn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return o=n,JSON.stringify({id:o.id,rawId:to(o.rawId),type:o.type,response:{attestationObject:to(o.response.attestationObject),clientDataJSON:to(o.response.clientDataJSON)}});var o}))}function Yn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return o=n,JSON.stringify({id:o.id,rawId:to(o.rawId),type:o.type,response:{authenticatorData:to(o.response.authenticatorData),clientDataJSON:to(o.response.clientDataJSON),signature:to(o.response.signature),userHandle:to(o.response.userHandle)}});var o}))}function Qn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function to(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const eo=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var no,oo,io,ro,so,ao,co,lo,uo,ho,po,fo,go,vo,mo,bo,wo,yo,ko,xo,Io,Oo,jo,So,_o,Eo,Co,Uo,Ao,Po;const Ro=document.createElement("template");Ro.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\tform[data-theme] {\n\t\t\tbackground-color: transparent;\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 To extends HTMLElement{constructor(){super(),no.add(this),oo.set(this,!1),io.set(this,new Xn),ro.set(this,new Xn),so.set(this,new Xn({isLoading:!1})),ao.set(this,void 0),co.set(this,void 0),lo.set(this,void 0),uo.set(this,void 0),ho.set(this,{popstate:o(this,no,"m",mo).bind(this)}),po.set(this,void 0),fo.set(this,void 0),xo.set(this,(t=>{var e,n,i,r,s;if(!(null==t?void 0:t.ok))return o(this,no,"m",So).call(this,"error",null==t?void 0:t.error),void o(this,no,"m",Po).call(this,{title:null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorDescription,description:null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.message});const a=null===(s=null===(r=null===(i=t.data)||void 0===i?void 0:i.screen)||void 0===r?void 0:r.state)||void 0===s?void 0:s.errorText;a&&o(this,no,"m",Po).call(this,{title:a});const{status:c,authInfo:l}=t.data;if("completed"===c)return void o(this,no,"m",So).call(this,"success",l);const{executionId:u,stepId:d,action:h,screen:p,redirect:f,webauthn:g}=t.data;o(this,io,"f").update({stepId:d,executionId:u,action:h,redirectUrl:null==f?void 0:f.url,screenId:null==p?void 0:p.id,screenState:null==p?void 0:p.state,webauthnTransactionId:null==g?void 0:g.transactionId,webauthnOptions:null==g?void 0:g.options})})),_o.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=qn(this["project-id"],"config.json");try{t=yield $n(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),o(this,no,"m",go).call(this),o(this,io,"f").subscribe(o(this,no,"m",ko).bind(this)),o(this,ro,"f").subscribe(o(this,no,"m",Oo).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug"]}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}get debug(){return"true"===this.getAttribute("debug")}get theme(){var t,e;const n=this.getAttribute("theme");if(n)return n;return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){i(this,oo,!0,"f"),o(this,no,"m",vo).call(this),o(this,no,"m",Uo).call(this);const t=yield o(this,_o,"f").call(this),e=this["flow-id"];i(this,fo,((t,e)=>{var n;return(null===(n=null==t?void 0:t.flows)||void 0===n?void 0:n[e])||{}})(t,e),"f"),o(this,no,"m",Co).call(this,t),o(this,no,"m",yo).call(this),o(this,no,"m",Ao).call(this);const{executionId:n,stepId:r}=Jn();(n||r)&&Kn();const s=Mn("t")||void 0;s&&Dn("t");const a=Mn(An)||void 0;a&&Dn(An),o(this,io,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],tenant:this.tenant,stepId:r,executionId:n,token:s,code:a}),window.addEventListener("popstate",o(this,ho,"f").popstate),o(this,ao,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=o(this,ao,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}))}disconnectedCallback(){o(this,io,"f").unsubscribeAll(),o(this,ro,"f").unsubscribeAll(),window.removeEventListener("popstate",o(this,ho,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,oo,"f")){if(e!==n&&To.observedAttributes.includes(t)){o(this,no,"m",vo).call(this);const i=null===e;o(this,io,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Kn()),{[Fn(t)]:n,stepId:r,executionId:s}}))}"debug"===t&&o(this,no,"m",Ao).call(this)}}}var Lo,Mo,Do,No,$o,qo,Wo,Jo,Ko,Fo;oo=new WeakMap,io=new WeakMap,ro=new WeakMap,so=new WeakMap,ao=new WeakMap,co=new WeakMap,lo=new WeakMap,uo=new WeakMap,ho=new WeakMap,po=new WeakMap,fo=new WeakMap,xo=new WeakMap,_o=new WeakMap,no=new WeakSet,go=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ro.content.cloneNode(!0)),i(this,ao,this.shadowRoot.querySelector("form"),"f"),i(this,co,this.shadowRoot.querySelector("style"),"f")},vo=function(){const t=["base-url","tenant","theme","debug"];if(To.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},mo=function(){const{stepId:t,executionId:e}=Jn();o(this,io,"f").update({stepId:t,executionId:e})},bo=function(t){return(...e)=>n(this,void 0,void 0,(function*(){o(this,so,"f").update({isLoading:!0});try{return yield t(...e)}finally{o(this,so,"f").update({isLoading:!1})}}))},wo=function(t,n){i(this,po,(t=>{var{autoRefresh:n=!0,persistTokens:o=!0}=t,i=e(t,["autoRefresh","persistTokens"]);ln?hn(i.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const r=i;let s,a;const c=new wn({sessionToken:""}),l=new wn({});r.hooks={beforeRequest:t=>null==s?void 0:s(t),afterRequest:(t,e)=>null==a?void 0:a(t,e)};const u=Ye(r),d=(h=u,{async signUp(t,e){const n=await h.webauthn.signUp.start(t,window.location.origin,e),o=await On(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,o)},async signIn(t){const e=await h.webauthn.signIn.start(t,window.location.origin),n=await jn(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 On(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await jn(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),o=await On(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,o)},helpers:{create:On,get:jn,isSupported:Sn}});var h;const p=Object.assign(Object.assign({},u),{flow:Object.assign(Object.assign({},u.flow),{start:async(t,e,n,o)=>{const i=await d.helpers.isSupported(),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dls_last_user_external_id"),s={tenant:null==o?void 0:o.tenant,redirectUrl:window.location.href,deviceInfo:{webAuthnSupport:i}};return r&&(s.lastUser={externalId:r}),u.flow.start(t,e,n,s)}}),webauthn:d,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=l.current;return e&&Object.entries(e).length>0&&t(e),l.subscribe((e=>{t(e)}))},getRefreshToken:In});return ln?(n&&["logout","logoutAll"].forEach((t=>{const e=u[t];p[t]=(...t)=>{const n=In(),o=[(null==t?void 0:t.shift())||n,...t],i=e(...o);return localStorage&&localStorage.removeItem("DSR"),cn.remove("DS"),ln&&(null===localStorage||void 0===localStorage||localStorage.removeItem("dls_last_user_external_id")),c.update({sessionToken:""}),i}})),s=t=>{if(t.body){const e={vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""};t.body.fpData=e}return!t.token&&o&&(t.token=In()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.13"}),t},p.me=async(...t)=>{var e;const n=await u.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());l.update(t)}return n},(n||o)&&(a=(t,i)=>{!async function(t,n,o,i){var r;try{if(401===n.status)return o.sessionToken.update({sessionToken:""}),void o.user.update({});const s=await(null==n?void 0:n.json());if(s){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(s),{sessionJwt:a,refreshJwt:c,user:l}=n,u=e(n,["sessionJwt","refreshJwt","user"]);if(i.persistTokens&&xn(a,c,u),a&&o.sessionToken.update({sessionToken:a}),l){const t=null===(r=null==l?void 0:l.externalIds)||void 0===r?void 0:r[0];ln&&t&&(null===localStorage||void 0===localStorage||localStorage.setItem("dls_last_user_external_id",t)),o.user.update(l)}a&&c&&i.autoRefresh&&kn(t,a,c)}}catch(t){console.error("Could not set tokens from body",t)}}(p.refresh,i,{sessionToken:c,user:l},{autoRefresh:n,persistTokens:o})}),n&&In()&&p.refresh(),p):(console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),p)})({projectId:t,baseUrl:n,autoRefresh:!1}),"f");const r=o(this,po,"f").flow.next;o(this,po,"f").flow.next=o(this,no,"m",bo).call(this,r)},yo=function(){o(this,ao,"f").setAttribute("data-theme",this.theme)},ko=function(t,e,r){var s;return n(this,void 0,void 0,(function*(){const{projectId:a,flowId:c,baseUrl:l,tenant:u,stepId:d,executionId:h,action:p,screenId:f,screenState:g,redirectUrl:v,token:m,code:b,webauthnTransactionId:w,webauthnOptions:y}=t,k=r("projectId")||r("baseUrl");if(o(this,uo,"f")&&(clearInterval(o(this,uo,"f")),i(this,uo,null,"f")),k){if(!a)return;o(this,no,"m",wo).call(this,a,l)}if(!h){if(!c)return;const t=null===(s=o(this,fo,"f"))||void 0===s?void 0:s.startScreenId;if(t){const e={htmlUrl:qn(a,`${t}.html`)};return o(this,ro,"f").update(e),void(o(this,po,"f").flow.start=o(this,no,"m",bo).call(this,o(this,po,"f").flow.start))}const e=yield o(this,po,"f").flow.start(c,"",null,{tenant:u});return void o(this,xo,"f").call(this,e)}if(r("token")&&m||r("code")&&b){const t=yield o(this,po,"f").flow.next(h,d,"submit",{token:m,exchangeCode:b});return o(this,xo,"f").call(this,t),void o(this,io,"f").update({token:void 0,code:void 0})}if(p===Pn)return v?void window.location.assign(v):void console.error("Did not get redirect url");if(p===Tn||p===Ln){if(!w||!y)return void console.error("Did not get webauthn transaction id or options");const t=p===Tn?yield Vn(y):yield Yn(y),e=yield o(this,po,"f").flow.next(h,d,"submit",{transactionId:w,response:t});return void o(this,xo,"f").call(this,e)}if(p===Rn&&i(this,uo,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield o(this,po,"f").flow.next(h,d,"submit",{});o(this,xo,"f").call(this,t)}))),2e3),"f"),!f)return void console.error("Refreshing the page during a flow is not supported yet");const x={direction:Wn(+d,+e.stepId),screenState:g,htmlUrl:qn(a,`${f}.html`)};(k||r("executionId")||r("stepId"))&&(x.next=(...t)=>o(this,po,"f").flow.next(h,d,...t)),o(this,ro,"f").update(x)}))},Io=function(t){o(this,ao,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const i=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),r=o(this,so,"f").subscribe((({isLoading:t})=>{var n,i,s,a;t?null===(i=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===i||i.add("loading"):(o(this,so,"f").unsubscribe(r),null===(a=null===(s=e.submitter)||void 0===s?void 0:s.classList)||void 0===a||a.remove("loading"))}));e.preventDefault();const s=Object.fromEntries(new FormData(e.target).entries()),a=(c=e.submitter,Array.from((null==c?void 0:c.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{}));var c;const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:window.location.origin});let u;const{executionId:d,tenant:h,flowId:p}=o(this,io,"f").current;u=d?yield t(i,l):yield o(this,po,"f").flow.start(p,i,l,{tenant:h}),o(this,xo,"f").call(this,u)}))},Oo=function(t){return n(this,void 0,void 0,(function*(){const{htmlUrl:e,validations:n={},direction:i,next:r,screenState:s}=t,a=document.createElement("template");a.innerHTML=yield $n(e,"text");const c=a.content.cloneNode(!0),l=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const o=e.getAttribute("data-id"),i=null===(n=t.getElementById(o))||void 0===n?void 0:n.innerHTML,r=Function(i).bind(e.previousSibling);return e.remove(),r}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(c),u=()=>{var t;!function(t,e){Object.entries(e).forEach((([e,n])=>{const o=t.getElementById(e);if(!o)throw new Error(`Cannot find element with id: ${e}`);Object.entries(n).forEach((([t,e])=>{o.setAttribute(t,e.toString()),o.addEventListener("blur",(()=>o.classList.add("touched")),{once:!0})}))}))}(c,n),Gn(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{l.forEach((t=>t()))}catch(t){console.error(t)}o(this,ao,"f").replaceChildren(c),o(this,no,"m",Io).call(this,r),o(this,no,"m",So).call(this,"page-updated",{})};i?o(this,no,"m",jo).call(this,u,i):u()}))},jo=function(t,e){o(this,ao,"f").addEventListener("transitionend",(()=>{o(this,ao,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===Nn.forward?"slide-forward":"slide-backward";Array.from(o(this,ao,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),o(this,ao,"f").classList.add("fade-out")},So=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},Eo=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},Co=function(t){var e,n,i,r;null===(r=null===(i=null===(n=null===(e=null==t?void 0:t.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===n?void 0:n.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>{o(this,no,"m",Eo).call(this,t.url)}))},Uo=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=qn(this["project-id"],"theme.css");t.innerText=yield $n(e,"text"),this.shadowRoot.appendChild(t)}))},Ao=function(){var t;return n(this,void 0,void 0,(function*(){this.debug?(yield Promise.resolve().then((function(){return Bo})),i(this,lo,document.createElement("descope-debugger"),"f"),Object.assign(o(this,lo,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,lo,"f"))):(null===(t=o(this,lo,"f"))||void 0===t||t.remove(),i(this,lo,null,"f"))}))},Po=function({title:t,description:e=""}){var n;t&&this.debug&&(null===(n=o(this,lo,"f"))||void 0===n||n.updateData({title:t,description:e}))},customElements.define("descope-wc",To);const Ho=document.createElement("template");Ho.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class zo extends HTMLElement{constructor(){super(),Lo.add(this),Mo.set(this,new Xn({messages:[]})),Do.set(this,void 0),No.set(this,void 0),$o.set(this,void 0),qo.set(this,{resize:o(this,Lo,"m",Fo).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ho.content.cloneNode(!0)),i(this,Do,this.shadowRoot.querySelector(".debugger"),"f"),i(this,No,o(this,Do,"f").querySelector(".content"),"f"),i(this,$o,o(this,Do,"f").querySelector(".header"),"f")}updateData(t){o(this,Mo,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,c]=eo(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${c}px`,t.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=c,document.onmousemove=a}e?e.onmousedown=l:t.onmousedown=l})(o(this,Do,"f"),o(this,$o,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,qo,"f").resize),(t=o(this,Do,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,Do,"f").onresize=o(this,Lo,"m",Ko).bind(this),o(this,Mo,"f").subscribe(o(this,Lo,"m",Wo).bind(this))}disconnectedCallback(){o(this,Mo,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,qo,"f").resize)}}Mo=new WeakMap,Do=new WeakMap,No=new WeakMap,$o=new WeakMap,qo=new WeakMap,Lo=new WeakSet,Wo=function(t){o(this,Lo,"m",Jo).call(this,t),o(this,Lo,"m",Ko).call(this)},Jo=function(t){o(this,No,"f").innerHTML=t.messages.map((t=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ko=function(){o(this,No,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Fo=function(){const[t,e]=eo(o(this,Do,"f"),Number.parseInt(o(this,Do,"f").style.left,10),Number.parseInt(o(this,Do,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Do,"f").style.top=`${e}px`,o(this,Do,"f").style.left=`${t}px`},customElements.define("descope-debugger",zo);var Bo=Object.freeze({__proto__:null,default:zo})}();
|
|
1
|
+
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}function r(t){this.message=t}r.prototype=new Error,r.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 r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);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 l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(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=/^\./,m=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,w=/^\[object .+?Constructor\]$/,y="object"==typeof l&&l&&l.Object===Object&&l,k="object"==typeof self&&self&&self.Object===Object&&self,x=y||k||Function("return this")();var I,O=Array.prototype,j=Function.prototype,S=Object.prototype,_=x["__core-js_shared__"],E=(I=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",C=j.toString,U=S.hasOwnProperty,A=S.toString,P=RegExp("^"+C.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=x.Symbol,L=O.splice,R=z(x,"Map"),M=z(Object,"create"),D=T?T.prototype:void 0,N=D?D.toString:void 0;function $(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function q(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function W(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function J(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function K(t,e){var n;e=function(t,e){if(G(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Y(t))return!0;return g.test(t)||!f.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:G(n=e)?n:B(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Z(e[o++])];return o&&o==i?t:void 0}function F(t){if(!V(t)||(e=t,E&&E in e))return!1;var e,n=function(t){var e=V(t)?A.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)?P:w;return n.test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function H(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return F(n)?n:void 0}$.prototype.clear=function(){this.__data__=M?M(null):{}},$.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},$.prototype.get=function(t){var e=this.__data__;if(M){var n=e[t];return n===d?void 0:n}return U.call(e,t)?e[t]:void 0},$.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:U.call(e,t)},$.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},q.prototype.clear=function(){this.__data__=[]},q.prototype.delete=function(t){var e=this.__data__,n=J(e,t);return!(n<0)&&(n==e.length-1?e.pop():L.call(e,n,1),!0)},q.prototype.get=function(t){var e=this.__data__,n=J(e,t);return n<0?void 0:e[n][1]},q.prototype.has=function(t){return J(this.__data__,t)>-1},q.prototype.set=function(t,e){var n=this.__data__,o=J(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},W.prototype.clear=function(){this.__data__={hash:new $,map:new(R||q),string:new $}},W.prototype.delete=function(t){return H(this,t).delete(t)},W.prototype.get=function(t){return H(this,t).get(t)},W.prototype.has=function(t){return H(this,t).has(t)},W.prototype.set=function(t,e){return H(this,t).set(t,e),this};var B=X((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Y(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(m,(function(t,e,o,i){n.push(o?i.replace(b,"$1"):e||t)})),n}));function Z(t){if("string"==typeof t||Y(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function X(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new(X.Cache||W),n}X.Cache=W;var G=Array.isArray;function V(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Y(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==A.call(t)}var Q=function(t,e,n){var o=null==t?void 0:K(t,e);return void 0===o?n:o},tt="/v1/auth/accesskey/exchange",et="/v1/auth/otp/verify",nt="/v1/auth/otp/signin",ot="/v1/auth/otp/signup",it={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},rt="/v1/auth/otp/signup-in",st="/v1/auth/magiclink/verify",at="/v1/auth/magiclink/signin",ct="/v1/auth/magiclink/signup",lt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ut="/v1/auth/magiclink/signup-in",dt="/v1/auth/enchantedlink/verify",ht="/v1/auth/enchantedlink/signin",pt="/v1/auth/enchantedlink/signup",ft="/v1/auth/enchantedlink/pending-session",gt={email:"/v1/auth/enchantedlink/update/email"},vt="/v1/auth/enchantedlink/signup-in",mt="/v1/auth/oauth/authorize",bt="/v1/auth/oauth/exchange",wt="/v1/auth/saml/authorize",yt="/v1/auth/saml/exchange",kt="/v1/auth/totp/verify",xt="/v1/auth/totp/signup",It="/v1/user/totp/update",Ot={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},jt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},St={start:"/v1/auth/webauthn/signup-in/start"},_t={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Et="/v1/flow/start",Ct="/v1/flow/next";const Ut=()=>{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")}};var At;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(At||(At={}));const Pt=(...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,o])=>(t[n]=o,t)),t),t}),{})),Tt=t=>void 0===t?void 0:JSON.stringify(t),Lt=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Rt=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r})=>{const s=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>Ut().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await(t.clone?t.clone().text():t.text());return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),Ut().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o),a=async o=>{const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:l,headers:u,queryParams:d,method:h,token:p}=a,f=await s((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:c,baseUrl:t,queryParams:d}),{headers:Pt(Lt(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.34"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Tt(l),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>a({path:t,headers:e,queryParams:n,body:void 0,method:At.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>a({path:t,headers:n,queryParams:o,body:e,method:At.delete,token:i})}};function Mt(t,e,n){var o;let i=Dt(t);e&&(i=null===(o=i.tenants)||void 0===o?void 0:o[e]);const r=i[n];return Array.isArray(r)?r:[]}function Dt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Nt(t){const{exp:e}=Dt(t);return(new Date).getTime()/1e3>e}function $t(t,e){return Mt(t,e,"permissions")}function qt(t,e){return Mt(t,e,"roles")}const Wt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Jt(t,e){const n=await t,o={code:n.status,ok:n.ok,response:n},i=await n.clone().json();return n.ok?o.data=e?e(i):i:o.error=i,o}const Kt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ft=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ht=t=>e=>t.test(e),zt=Ht(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Bt=Ht(/^\+[1-9]{1}[0-9]{3,14}$/),Zt=Kt(zt,'"{val}" is not a valid email'),Xt=Kt(Bt,'"{val}" is not a valid phone number'),Gt=Kt((1,t=>t.length>=1),"Minimum length is 1");const Vt=Kt((t=>"string"==typeof t),"Input is not a string"),Yt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ft(...t).validate(n[e]))),e(...n)),Qt=t=>[Vt(`"${t}" must be a string`),Gt(`"${t}" must not be empty`)],te=t=>[Vt(`"${t}" must be a string`),Zt()],ee=t=>[Vt(`"${t}" must be a string`),Xt()],ne=Yt(Qt("accessKey")),oe=t=>({exchange:ne((e=>Jt(t.post(tt,{},{token:e}))))});var ie,re,se,ae,ce;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ie||(ie={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(re||(re={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(se||(se={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ae||(ae={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(ce||(ce={}));const le=Qt("identifier"),ue=Yt(le,Qt("code")),de=Yt(le),he=Yt(le,ee("phone")),pe=Yt(le,te("email")),fe=t=>({verify:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o)=>Jt(t.post(Wt(et,n),{code:o,externalId:e}))))})),{}),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o,i)=>Jt(t.post(Wt(nt,n),{externalId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o)=>Jt(t.post(Wt(ot,n),{externalId:e,user:o}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de((e=>Jt(t.post(Wt(rt,n),{externalId:e}))))})),{}),update:{email:pe(((e,n,o)=>Jt(t.post(it.email,{externalId:e,email:n},{token:o})))),phone:Object.keys(ie).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i)=>Jt(t.post(Wt(it.phone,n),{externalId:e,phone:o},{token:i}))))})),{})}}),ge=Qt("identifier"),ve=Qt("uri"),me=Yt(Qt("token")),be=Yt(ge,ve),we=Yt(ge,ee("phone"),ve),ye=Yt(ge,te("email"),ve),ke=t=>({verify:me((e=>Jt(t.post(st,{token:e})))),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o,i,r)=>Jt(t.post(Wt(at,n),{externalId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o,i)=>Jt(t.post(Wt(ct,n),{externalId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,o)=>Jt(t.post(Wt(ut,n),{externalId:e,URI:o}))))})),{}),update:{email:ye(((e,n,o,i)=>Jt(t.post(lt.email,{externalId:e,email:n,URI:o},{token:i})))),phone:Object.keys(ie).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:we(((e,o,i,r)=>Jt(t.post(Wt(lt.phone,n),{externalId:e,phone:o,URI:i},{token:r}))))})),{})}}),xe=Qt("identifier"),Ie=Qt("uri"),Oe=Yt(Qt("token")),je=Yt(xe,Ie),Se=Yt(Qt("pendingRef")),_e=Yt(xe,te("email"),Ie),Ee=t=>({verify:Oe((e=>Jt(t.post(dt,{token:e})))),signIn:je(((e,n,o,i)=>Jt(t.post(Wt(ht,re.email),{externalId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:je(((e,n)=>Jt(t.post(Wt(vt,re.email),{externalId:e,URI:n})))),signUp:je(((e,n,o)=>Jt(t.post(Wt(pt,re.email),{externalId:e,URI:n,user:o})))),waitForSession:Se(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({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(ft,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{message:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:_e(((e,n,o,i)=>Jt(t.post(gt.email,{externalId:e,email:n,URI:o},{token:i}))))}});var Ce;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(Ce||(Ce={}));const Ue=Yt(Qt("code")),Ae=t=>({start:Object.keys(Ce).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},i,r)=>{const s=await t.post(mt,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r});if(!o||!s.ok)return Jt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Ue((e=>Jt(t.post(bt,{code:e}))))}),Pe=Yt(Qt("flowId")),Te=Yt(Qt("executionId"),Qt("stepId"),Qt("interactionId")),Le=t=>({start:Pe(((e,n,o,i)=>Jt(t.post(Et,{flowId:e,options:i,interactionId:n,input:o})))),next:Te(((e,n,o,i)=>Jt(t.post(Ct,{executionId:e,stepId:n,interactionId:o,input:i}))))}),Re=Yt(Qt("tenant")),Me=Yt(Qt("code")),De=t=>({start:Re((async(e,n,{redirect:o=!1}={},i,r)=>{const s=await t.post(wt,i||{},{queryParams:{tenant:e,redirectURL:n},token:r});if(!o||!s.ok)return Jt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Me((e=>Jt(t.post(yt,{code:e}))))}),Ne=Qt("identifier"),$e=Yt(Ne,Qt("code")),qe=Yt(Ne),We=Yt(Ne),Je=t=>({signUp:qe(((e,n)=>Jt(t.post(xt,{externalId:e,user:n})))),verify:$e(((e,n,o,i)=>Jt(t.post(kt,{externalId:e,code:n,loginOptions:o},{token:i})))),update:We(((e,n)=>Jt(t.post(It,{externalId:e},{token:n}))))}),Ke=Qt("identifier"),Fe=Qt("origin"),He=Yt(Ke,Fe,Qt("name")),ze=Yt(Ke,Fe),Be=Yt(Ke,Fe,Qt("token")),Ze=Yt(Qt("transactionId"),Qt("response")),Xe=t=>({signUp:{start:He(((e,n,o)=>Jt(t.post(Ot.start,{user:{externalId:e,name:o},origin:n})))),finish:Ze(((e,n)=>Jt(t.post(Ot.finish,{transactionId:e,response:n}))))},signIn:{start:ze(((e,n,o,i)=>Jt(t.post(jt.start,{externalId:e,origin:n,loginOptions:o},{token:i})))),finish:Ze(((e,n)=>Jt(t.post(jt.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:ze(((e,n)=>Jt(t.post(St.start,{externalId:e,origin:n}))))},update:{start:Be(((e,n,o)=>Jt(t.post(_t.start,{externalId:e,origin:n},{token:o})))),finish:Ze(((e,n)=>Jt(t.post(_t.finish,{transactionId:e,response:n}))))}}),Ge=Yt(Qt("token"));var Ve;const Ye=Yt([("projectId",Ve=Qt("projectId"),Kt(((t,e)=>t=>Ft(...e).validate(Q(t,"projectId")))(0,Ve))())])((({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i})=>{return r=Rt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i}),{accessKey:oe(r),otp:fe(r),magicLink:ke(r),enchantedLink:Ee(r),oauth:Ae(r),saml:De(r),totp:Je(r),webauthn:Xe(r),flow:Le(r),refresh:t=>Jt(r.post("/v1/auth/refresh",{},{token:t})),logout:t=>Jt(r.post("/v1/auth/logout",{},{token:t})),logoutAll:t=>Jt(r.post("/v1/auth/logoutall",{},{token:t})),me:t=>Jt(r.get("/v1/auth/me",{token:t})),isJwtExpired:Ge(Nt),getJwtPermissions:Ge($t),getJwtRoles:Ge(qt),httpClient:r};var r}));function Qe(t,e){var n=[];return function(t,e){var n,o,i=(o=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),i=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,i++)o[i]=r[s];return o}(t),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return"Blocked by CSP"===e||"9319"===e}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}Ye.DeliveryMethods=re;var tn="Failed to load the JS script of the agent";function en(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");return Qe(function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.8.1"):t}))}(String(t),e)}))}(c,s),nn).catch(rn)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function nn(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,c())};r.addEventListener(s,a);var c=function(){return r.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(),i)return function(){throw new Error("Blocked by CSP")}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(tn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(on)}function on(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error("9319");return n}function rn(t){throw t instanceof Error&&"9319"===t.message?new Error(tn):t}var sn={exports:{}},an={exports:{}};an.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}function e(n,o){function i(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=t({},o,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in r)r[a]&&(s+="; "+a,!0!==r[a]&&(s+="="+r[a].split(";")[0]));return document.cookie=e+"="+n.write(i,e)+s}}function r(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],o={},i=0;i<e.length;i++){var r=e[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=n.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}}return Object.create({set:i,get:r,remove:function(e,n){i(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(o)},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=an.exports}(sn);var cn=u(sn.exports);const ln="undefined"!=typeof window,un=ln&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",dn=ln&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",hn=(t="",e="")=>({vsid:t,vrid:e}),pn=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},fn=async t=>{try{if(pn())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=en({apiKey:t||un,endpoint:dn}),o=await n,{requestId:i}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(hn(e,i))}catch(t){global.FB_DEBUG&&console.error(t)}};var gn,vn,mn,bn,wn;const yn=t=>Object.assign({},t);class kn{constructor(t){gn.add(this),vn.set(this,void 0),mn.set(this,{}),bn.set(this,0),i(this,vn,t,"f")}get current(){return yn(o(this,vn,"f"))}update(t){const e=t;if(!((t,e)=>{const n=t&&Object.getOwnPropertyNames(t)||[],o=e&&Object.getOwnPropertyNames(e)||[];if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o];if(t[i]!==e[i])return!1}return!0})(o(this,vn,"f"),e)){const t=o(this,vn,"f");i(this,vn,e,"f"),Object.freeze(o(this,vn,"f")),setTimeout((()=>{Object.values(o(this,mn,"f")).forEach((n=>n(yn(e),t)))}),0)}}subscribe(t){i(this,bn,o(this,bn,"f")+1,"f"),o(this,mn,"f")[o(this,bn,"f")]=t;const e=o(this,bn,"f");return()=>o(this,gn,"m",wn).call(this,e.toString())}unsubscribeAll(){i(this,mn,{},"f")}}vn=new WeakMap,mn=new WeakMap,bn=new WeakMap,gn=new WeakSet,wn=function(t){o(this,mn,"f")[t]&&delete o(this,mn,"f")[t]};let xn=[];function In(t,e,n){const o=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(o){let e;for(;e=xn.pop();)clearTimeout(e);const i=o.getTime()-2e4-(new Date).getTime(),r=setTimeout((()=>{t(n)}),i);xn.push(r)}}function On(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:o}){t&&cn.set("DS",t,{path:e,domain:n,expires:o,sameSite:"None",secure:!0})}(t,n),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(e)}function jn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function Sn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Cn(n.publicKey.challenge),n.publicKey.user.id=Cn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Cn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:Un(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:Un(n.response.attestationObject),clientDataJSON:Un(n.response.clientDataJSON)})}));var n}async function _n(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Cn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Cn(t.id)})),n}(t);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:Un(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:Un(n.response.authenticatorData),clientDataJSON:Un(n.response.clientDataJSON),signature:Un(n.response.signature),userHandle:n.response.userHandle?Un(n.response.userHandle):void 0})}));var n}async function En(t=!1){if(!ln)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Cn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Un(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const An="undefined"!=typeof window&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Pn="descope-login-flow",Tn="code",Ln="redirect",Rn="poll",Mn="webauthnCreate",Dn="webauthnGet";function Nn(t){return new URLSearchParams(window.location.search).get(t)}function $n(t){if(window.history.replaceState&&Nn(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 qn;function Wn(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"}(qn||(qn={}));function Jn(t,e){const n=new URL(An);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function Kn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?qn.forward:t<e?qn.backward:void 0}const Fn=()=>{const[t="",e=""]=(Nn(Pn)||"").split("_");return{executionId:t,stepId:e}};function Hn(){$n(Pn)}const zn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Bn,Zn,Xn;function Gn(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if("object"==typeof r&&"object"==typeof s){if(!Gn(r,s))return!1}else if(r!==s)return!1}return!0}class Vn{constructor(t={}){Bn.set(this,void 0),Zn.set(this,{}),Xn.set(this,0),i(this,Bn,t,"f")}get current(){return Object.assign({},o(this,Bn,"f"))}update(t){const e="function"==typeof t?t(o(this,Bn,"f")):t,n=Object.assign(Object.assign({},o(this,Bn,"f")),e);if(!Gn(o(this,Bn,"f"),n)){const t=o(this,Bn,"f");i(this,Bn,n,"f"),Object.freeze(o(this,Bn,"f")),setTimeout((()=>{Object.values(o(this,Zn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return i(this,Xn,o(this,Xn,"f")+1,"f"),o(this,Zn,"f")[o(this,Xn,"f")]=t,o(this,Xn,"f").toString()}unsubscribe(t){const e=!!o(this,Zn,"f")[t];return e&&delete o(this,Zn,"f")[t],e}unsubscribeAll(){return i(this,Zn,{},"f"),!0}}Bn=new WeakMap,Zn=new WeakMap,Xn=new WeakMap;const Yn=(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 o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)};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=eo(n.publicKey.challenge),n.publicKey.user.id=eo(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=eo(t.id)})),n}(t),n=yield navigator.credentials.create(e);return o=n,JSON.stringify({id:o.id,rawId:no(o.rawId),type:o.type,response:{attestationObject:no(o.response.attestationObject),clientDataJSON:no(o.response.clientDataJSON)}});var o}))}function to(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=eo(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=eo(t.id)})),n}(t),n=yield navigator.credentials.get(e);return o=n,JSON.stringify({id:o.id,rawId:no(o.rawId),type:o.type,response:{authenticatorData:no(o.response.authenticatorData),clientDataJSON:no(o.response.clientDataJSON),signature:no(o.response.signature),userHandle:no(o.response.userHandle)}});var o}))}function eo(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function no(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const oo=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var io,ro,so,ao,co,lo,uo,ho,po,fo,go,vo,mo,bo,wo,yo,ko,xo,Io,Oo,jo,So,_o,Eo,Co,Uo,Ao,Po,To,Lo;const Ro=document.createElement("template");Ro.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\tform[data-theme] {\n\t\t\tbackground-color: transparent;\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 Mo extends HTMLElement{constructor(){super(),io.add(this),ro.set(this,!1),so.set(this,new Vn),ao.set(this,new Vn),co.set(this,new Vn({isLoading:!1})),lo.set(this,void 0),uo.set(this,void 0),ho.set(this,void 0),po.set(this,void 0),fo.set(this,{popstate:o(this,io,"m",wo).bind(this)}),go.set(this,void 0),vo.set(this,void 0),Oo.set(this,(t=>{var e,n,i,r,s;if(!(null==t?void 0:t.ok))return o(this,io,"m",Eo).call(this,"error",null==t?void 0:t.error),void o(this,io,"m",Lo).call(this,{title:null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorDescription,description:null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.message});const a=null===(s=null===(r=null===(i=t.data)||void 0===i?void 0:i.screen)||void 0===r?void 0:r.state)||void 0===s?void 0:s.errorText;a&&o(this,io,"m",Lo).call(this,{title:a});const{status:c,authInfo:l}=t.data;if("completed"===c)return void o(this,io,"m",Eo).call(this,"success",l);const{executionId:u,stepId:d,action:h,screen:p,redirect:f,webauthn:g}=t.data;o(this,so,"f").update({stepId:d,executionId:u,action:h,redirectUrl:null==f?void 0:f.url,screenId:null==p?void 0:p.id,screenState:null==p?void 0:p.state,webauthnTransactionId:null==g?void 0:g.transactionId,webauthnOptions:null==g?void 0:g.options})})),Co.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=Jn(this["project-id"],"config.json");try{t=yield Wn(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),o(this,io,"m",mo).call(this),o(this,so,"f").subscribe(o(this,io,"m",Io).bind(this)),o(this,ao,"f").subscribe(o(this,io,"m",So).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug"]}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}get debug(){return"true"===this.getAttribute("debug")}get theme(){var t,e;const n=this.getAttribute("theme");if(n)return n;return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){i(this,ro,!0,"f"),o(this,io,"m",bo).call(this),o(this,io,"m",Po).call(this);const t=yield o(this,Co,"f").call(this),e=this["flow-id"];i(this,vo,((t,e)=>{var n;return(null===(n=null==t?void 0:t.flows)||void 0===n?void 0:n[e])||{}})(t,e),"f"),o(this,io,"m",Ao).call(this,t),o(this,io,"m",xo).call(this),o(this,io,"m",To).call(this);const{executionId:n,stepId:r}=Fn();(n||r)&&Hn();const s=Nn("t")||void 0;s&&$n("t");const a=Nn(Tn)||void 0;a&&$n(Tn),o(this,so,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],tenant:this.tenant,stepId:r,executionId:n,token:s,code:a}),window.addEventListener("popstate",o(this,fo,"f").popstate),o(this,lo,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=o(this,lo,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}))}disconnectedCallback(){o(this,so,"f").unsubscribeAll(),o(this,ao,"f").unsubscribeAll(),window.removeEventListener("popstate",o(this,fo,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,ro,"f")){if(e!==n&&Mo.observedAttributes.includes(t)){o(this,io,"m",bo).call(this);const i=null===e;o(this,so,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Hn()),{[zn(t)]:n,stepId:r,executionId:s}}))}"debug"===t&&o(this,io,"m",To).call(this)}}}var Do,No,$o,qo,Wo,Jo,Ko,Fo,Ho,zo;ro=new WeakMap,so=new WeakMap,ao=new WeakMap,co=new WeakMap,lo=new WeakMap,uo=new WeakMap,ho=new WeakMap,po=new WeakMap,fo=new WeakMap,go=new WeakMap,vo=new WeakMap,Oo=new WeakMap,Co=new WeakMap,io=new WeakSet,mo=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ro.content.cloneNode(!0)),i(this,lo,this.shadowRoot.querySelector("form"),"f"),i(this,uo,this.shadowRoot.querySelector("style"),"f")},bo=function(){const t=["base-url","tenant","theme","debug"];if(Mo.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},wo=function(){const{stepId:t,executionId:e}=Fn();o(this,so,"f").update({stepId:t,executionId:e})},yo=function(t){return(...e)=>n(this,void 0,void 0,(function*(){o(this,co,"f").update({isLoading:!0});try{return yield t(...e)}finally{o(this,co,"f").update({isLoading:!1})}}))},ko=function(t,n){i(this,go,(t=>{var{autoRefresh:n=!0,persistTokens:o=!0,fpKey:i,fpLoad:r}=t,s=e(t,["autoRefresh","persistTokens","fpKey","fpLoad"]);ln?r&&fn(i).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const a=s;let c,l;const u=new kn({sessionToken:""}),d=new kn({});a.hooks={beforeRequest:t=>null==c?void 0:c(t),afterRequest:(t,e)=>null==l?void 0:l(t,e)};const h=Ye(a),p=(f=h,{async signUp(t,e){const n=await f.webauthn.signUp.start(t,window.location.origin,e),o=await Sn(n.data.options);return await f.webauthn.signUp.finish(n.data.transactionId,o)},async signIn(t){const e=await f.webauthn.signIn.start(t,window.location.origin),n=await _n(e.data.options);return await f.webauthn.signIn.finish(e.data.transactionId,n)},async signUpOrIn(t){var e;const n=await f.webauthn.signUpOrIn.start(t,window.location.origin);if(null===(e=n.data)||void 0===e?void 0:e.create){const t=await Sn(n.data.options);return await f.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await _n(n.data.options);return await f.webauthn.signIn.finish(n.data.transactionId,t)}},async update(t,e){const n=await f.webauthn.update.start(t,window.location.origin,e),o=await Sn(n.data.options);return await f.webauthn.update.finish(n.data.transactionId,o)},helpers:{create:Sn,get:_n,isSupported:En}});var f;const g=Object.assign(Object.assign({},h),{flow:Object.assign(Object.assign({},h.flow),{start:async(t,e,n,o)=>{const i=await p.helpers.isSupported(),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dls_last_user_external_id"),s={tenant:null==o?void 0:o.tenant,redirectUrl:window.location.href,deviceInfo:{webAuthnSupport:i}};return r&&(s.lastUser={externalId:r}),h.flow.start(t,e,n,s)}}),webauthn:p,onSessionTokenChange:t=>{var e;const n=null===(e=u.current)||void 0===e?void 0:e.sessionToken;return n&&t(n),u.subscribe((({sessionToken:e})=>{t(e)}))},onUserChange:t=>{const e=d.current;return e&&Object.entries(e).length>0&&t(e),d.subscribe((e=>{t(e)}))},getRefreshToken:jn});return ln?(n&&["logout","logoutAll"].forEach((t=>{const e=h[t];g[t]=(...t)=>{const n=jn(),o=[(null==t?void 0:t.shift())||n,...t],i=e(...o);return localStorage&&localStorage.removeItem("DSR"),cn.remove("DS"),ln&&(null===localStorage||void 0===localStorage||localStorage.removeItem("dls_last_user_external_id")),u.update({sessionToken:""}),i}})),c=t=>(t.body&&(t.body.fpData=pn(!0)||hn()),!t.token&&o&&(t.token=jn()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.14"}),t),g.me=async(...t)=>{var e;const n=await h.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());d.update(t)}return n},(n||o)&&(l=(t,i)=>{!async function(t,n,o,i){var r;try{if(401===n.status)return o.sessionToken.update({sessionToken:""}),void o.user.update({});const s=await(null==n?void 0:n.json());if(s){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(s),{sessionJwt:a,refreshJwt:c,user:l}=n,u=e(n,["sessionJwt","refreshJwt","user"]);if(i.persistTokens&&On(a,c,u),a&&o.sessionToken.update({sessionToken:a}),l){const t=null===(r=null==l?void 0:l.externalIds)||void 0===r?void 0:r[0];ln&&t&&(null===localStorage||void 0===localStorage||localStorage.setItem("dls_last_user_external_id",t)),o.user.update(l)}a&&c&&i.autoRefresh&&In(t,a,c)}}catch(t){console.error("Could not set tokens from body",t)}}(g.refresh,i,{sessionToken:u,user:d},{autoRefresh:n,persistTokens:o})}),n&&jn()&&g.refresh(),g):(console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),g)})({projectId:t,baseUrl:n,autoRefresh:!1,fpLoad:!0}),"f");const r=o(this,go,"f").flow.next;o(this,go,"f").flow.next=o(this,io,"m",yo).call(this,r)},xo=function(){o(this,lo,"f").setAttribute("data-theme",this.theme)},Io=function(t,e,r){var s;return n(this,void 0,void 0,(function*(){const{projectId:a,flowId:c,baseUrl:l,tenant:u,stepId:d,executionId:h,action:p,screenId:f,screenState:g,redirectUrl:v,token:m,code:b,webauthnTransactionId:w,webauthnOptions:y}=t,k=r("projectId")||r("baseUrl");if(o(this,po,"f")&&(clearInterval(o(this,po,"f")),i(this,po,null,"f")),k){if(!a)return;o(this,io,"m",ko).call(this,a,l)}if(!h){if(!c)return;const t=null===(s=o(this,vo,"f"))||void 0===s?void 0:s.startScreenId;if(t){const e={htmlUrl:Jn(a,`${t}.html`)};return o(this,ao,"f").update(e),void(o(this,go,"f").flow.start=o(this,io,"m",yo).call(this,o(this,go,"f").flow.start))}const e=yield o(this,go,"f").flow.start(c,"",null,{tenant:u});return void o(this,Oo,"f").call(this,e)}if(r("token")&&m||r("code")&&b){const t=yield o(this,go,"f").flow.next(h,d,"submit",{token:m,exchangeCode:b});return o(this,Oo,"f").call(this,t),void o(this,so,"f").update({token:void 0,code:void 0})}if(p===Ln)return v?void window.location.assign(v):void console.error("Did not get redirect url");if(p===Mn||p===Dn){if(!w||!y)return void console.error("Did not get webauthn transaction id or options");const t=p===Mn?yield Qn(y):yield to(y),e=yield o(this,go,"f").flow.next(h,d,"submit",{transactionId:w,response:t});return void o(this,Oo,"f").call(this,e)}if(p===Rn&&i(this,po,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield o(this,go,"f").flow.next(h,d,"submit",{});o(this,Oo,"f").call(this,t)}))),2e3),"f"),!f)return void console.error("Refreshing the page during a flow is not supported yet");const x={direction:Kn(+d,+e.stepId),screenState:g,htmlUrl:Jn(a,`${f}.html`)};(k||r("executionId")||r("stepId"))&&(x.next=(...t)=>o(this,go,"f").flow.next(h,d,...t)),o(this,ao,"f").update(x)}))},jo=function(t){o(this,lo,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const i=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),r=o(this,co,"f").subscribe((({isLoading:t})=>{var n,i,s,a;t?null===(i=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===i||i.add("loading"):(o(this,co,"f").unsubscribe(r),null===(a=null===(s=e.submitter)||void 0===s?void 0:s.classList)||void 0===a||a.remove("loading"))}));e.preventDefault();const s=Object.fromEntries(new FormData(e.target).entries()),a=(c=e.submitter,Array.from((null==c?void 0:c.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{}));var c;const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:window.location.origin});let u;const{executionId:d,tenant:h,flowId:p}=o(this,so,"f").current;u=d?yield t(i,l):yield o(this,go,"f").flow.start(p,i,l,{tenant:h}),o(this,Oo,"f").call(this,u)}))},So=function(t){return n(this,void 0,void 0,(function*(){const{htmlUrl:e,validations:n={},direction:i,next:r,screenState:s}=t,a=document.createElement("template");a.innerHTML=yield Wn(e,"text");const c=a.content.cloneNode(!0),l=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const o=e.getAttribute("data-id"),i=null===(n=t.getElementById(o))||void 0===n?void 0:n.innerHTML,r=Function(i).bind(e.previousSibling);return e.remove(),r}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(c),u=()=>{var t;!function(t,e){Object.entries(e).forEach((([e,n])=>{const o=t.getElementById(e);if(!o)throw new Error(`Cannot find element with id: ${e}`);Object.entries(n).forEach((([t,e])=>{o.setAttribute(t,e.toString()),o.addEventListener("blur",(()=>o.classList.add("touched")),{once:!0})}))}))}(c,n),Yn(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{l.forEach((t=>t()))}catch(t){console.error(t)}o(this,lo,"f").replaceChildren(c),o(this,io,"m",jo).call(this,r),o(this,io,"m",Eo).call(this,"page-updated",{})};i?o(this,io,"m",_o).call(this,u,i):u()}))},_o=function(t,e){o(this,lo,"f").addEventListener("transitionend",(()=>{o(this,lo,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===qn.forward?"slide-forward":"slide-backward";Array.from(o(this,lo,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),o(this,lo,"f").classList.add("fade-out")},Eo=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},Uo=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},Ao=function(t){var e,n,i,r;null===(r=null===(i=null===(n=null===(e=null==t?void 0:t.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===n?void 0:n.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>{o(this,io,"m",Uo).call(this,t.url)}))},Po=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=Jn(this["project-id"],"theme.css");t.innerText=yield Wn(e,"text"),this.shadowRoot.appendChild(t)}))},To=function(){var t;return n(this,void 0,void 0,(function*(){this.debug?(yield Promise.resolve().then((function(){return Xo})),i(this,ho,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ho,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,ho,"f"))):(null===(t=o(this,ho,"f"))||void 0===t||t.remove(),i(this,ho,null,"f"))}))},Lo=function({title:t,description:e=""}){var n;t&&this.debug&&(null===(n=o(this,ho,"f"))||void 0===n||n.updateData({title:t,description:e}))},customElements.define("descope-wc",Mo);const Bo=document.createElement("template");Bo.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class Zo extends HTMLElement{constructor(){super(),Do.add(this),No.set(this,new Vn({messages:[]})),$o.set(this,void 0),qo.set(this,void 0),Wo.set(this,void 0),Jo.set(this,{resize:o(this,Do,"m",zo).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bo.content.cloneNode(!0)),i(this,$o,this.shadowRoot.querySelector(".debugger"),"f"),i(this,qo,o(this,$o,"f").querySelector(".content"),"f"),i(this,Wo,o(this,$o,"f").querySelector(".header"),"f")}updateData(t){o(this,No,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,c]=oo(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${c}px`,t.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=c,document.onmousemove=a}e?e.onmousedown=l:t.onmousedown=l})(o(this,$o,"f"),o(this,Wo,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Jo,"f").resize),(t=o(this,$o,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,$o,"f").onresize=o(this,Do,"m",Ho).bind(this),o(this,No,"f").subscribe(o(this,Do,"m",Ko).bind(this))}disconnectedCallback(){o(this,No,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Jo,"f").resize)}}No=new WeakMap,$o=new WeakMap,qo=new WeakMap,Wo=new WeakMap,Jo=new WeakMap,Do=new WeakSet,Ko=function(t){o(this,Do,"m",Fo).call(this,t),o(this,Do,"m",Ho).call(this)},Fo=function(t){o(this,qo,"f").innerHTML=t.messages.map((t=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ho=function(){o(this,qo,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},zo=function(){const[t,e]=oo(o(this,$o,"f"),Number.parseInt(o(this,$o,"f").style.left,10),Number.parseInt(o(this,$o,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,$o,"f").style.top=`${e}px`,o(this,$o,"f").style.left=`${t}px`},customElements.define("descope-debugger",Zo);var Xo=Object.freeze({__proto__:null,default:Zo})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
4
|
"main": "dist/descope-wc.js",
|
|
5
5
|
"module": "dist/descope-wc.esm.js",
|
|
6
6
|
"types": "dist/descope-wc.d.ts",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"typescript": "^4.5.3"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@descope/web-js-sdk": "0.1.0-alpha.
|
|
80
|
+
"@descope/web-js-sdk": "0.1.0-alpha.14"
|
|
81
81
|
},
|
|
82
82
|
"overrides": {
|
|
83
83
|
"terser": "5.16.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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 l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d="[object GeneratorFunction]",h=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p=/^\w*$/,f=/^\./,v=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g=/\\(\\)?/g,b=/^\[object .+?Constructor\]$/,w="object"==typeof l&&l&&l.Object===Object&&l,m="object"==typeof self&&self&&self.Object===Object&&self,y=w||m||Function("return this")();var k,I=Array.prototype,O=Function.prototype,j=Object.prototype,S=y["__core-js_shared__"],x=(k=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"",_=O.toString,E=j.hasOwnProperty,U=j.toString,C=RegExp("^"+_.call(E).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=y.Symbol,A=I.splice,R=B(y,"Map"),T=B(Object,"create"),M=P?P.prototype:void 0,D=M?M.toString:void 0;function L(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 N(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 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,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 J(t,e){var n;e=function(t,e){if(G(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Z(t))return!0;return p.test(t)||!h.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:G(n=e)?n:F(n);for(var r=0,o=e.length;null!=t&&r<o;)t=t[H(e[r++])];return r&&r==o?t:void 0}function K(t){if(!V(t)||(e=t,x&&x in e))return!1;var e,n=function(t){var e=V(t)?U.call(t):"";return"[object Function]"==e||e==d}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?C:b;return n.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function W(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 B(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return K(n)?n:void 0}L.prototype.clear=function(){this.__data__=T?T(null):{}},L.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},L.prototype.get=function(t){var e=this.__data__;if(T){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return E.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return T?void 0!==e[t]:E.call(e,t)},L.prototype.set=function(t,e){return this.__data__[t]=T&&void 0===e?"__lodash_hash_undefined__":e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=$(e,t);return!(n<0)&&(n==e.length-1?e.pop():A.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=$(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return $(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=$(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},q.prototype.clear=function(){this.__data__={hash:new L,map:new(R||N),string:new L}},q.prototype.delete=function(t){return W(this,t).delete(t)},q.prototype.get=function(t){return W(this,t).get(t)},q.prototype.has=function(t){return W(this,t).has(t)},q.prototype.set=function(t,e){return W(this,t).set(t,e),this};var F=z((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Z(t))return D?D.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return f.test(t)&&n.push(""),t.replace(v,(function(t,e,r,o){n.push(r?o.replace(g,"$1"):e||t)})),n}));function H(t){if("string"==typeof t||Z(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-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||q),n}z.Cache=q;var G=Array.isArray;function V(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Z(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==U.call(t)}var Q=function(t,e,n){var r=null==t?void 0:J(t,e);return void 0===r?n:r},X="/v1/auth/accesskey/exchange",Y="/v1/auth/otp/verify",tt="/v1/auth/otp/signin",et="/v1/auth/otp/signup",nt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},rt="/v1/auth/otp/signup-in",ot="/v1/auth/magiclink/verify",it="/v1/auth/magiclink/signin",st="/v1/auth/magiclink/signup",at={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ct="/v1/auth/magiclink/signup-in",lt="/v1/auth/enchantedlink/verify",ut="/v1/auth/enchantedlink/signin",dt="/v1/auth/enchantedlink/signup",ht="/v1/auth/enchantedlink/pending-session",pt={email:"/v1/auth/enchantedlink/update/email"},ft="/v1/auth/enchantedlink/signup-in",vt="/v1/auth/oauth/authorize",gt="/v1/auth/oauth/exchange",bt="/v1/auth/saml/authorize",wt="/v1/auth/saml/exchange",mt="/v1/auth/totp/verify",yt="/v1/auth/totp/signup",kt="/v1/user/totp/update",It={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ot={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},jt={start:"/v1/auth/webauthn/signup-in/start"},St={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},xt="/v1/flow/start",_t="/v1/flow/next";const Et=()=>{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")}};var Ut;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ut||(Ut={}));const Ct=(...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}),{})),Pt=t=>void 0===t?void 0:JSON.stringify(t),At=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Rt=({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=>Et().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.clone?t.clone().text():t.text());return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),Et().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:l,headers:u,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:Ct(At(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.34"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Pt(l),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:Ut.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.post,token:o}),put:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.put,token:o}),delete:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Ut.delete,token:o})}};function Tt(t,e,n){var r;let o=Mt(t);e&&(o=null===(r=o.tenants)||void 0===r?void 0:r[e]);const i=o[n];return Array.isArray(i)?i:[]}function Mt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Dt(t){const{exp:e}=Mt(t);return(new Date).getTime()/1e3>e}function Lt(t,e){return Tt(t,e,"permissions")}function Nt(t,e){return Tt(t,e,"roles")}const qt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function $t(t,e){const n=await t,r={code:n.status,ok:n.ok,response:n},o=await n.clone().json();return n.ok?r.data=e?e(o):o:r.error=o,r}const Jt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Kt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Wt=t=>e=>t.test(e),Bt=Wt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ft=Wt(/^\+[1-9]{1}[0-9]{3,14}$/),Ht=Jt(Bt,'"{val}" is not a valid email'),zt=Jt(Ft,'"{val}" is not a valid phone number'),Gt=Jt((1,t=>t.length>=1),"Minimum length is 1");const Vt=Jt((t=>"string"==typeof t),"Input is not a string"),Zt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Kt(...t).validate(n[e]))),e(...n)),Qt=t=>[Vt(`"${t}" must be a string`),Gt(`"${t}" must not be empty`)],Xt=t=>[Vt(`"${t}" must be a string`),Ht()],Yt=t=>[Vt(`"${t}" must be a string`),zt()],te=Zt(Qt("accessKey")),ee=t=>({exchange:te((e=>$t(t.post(X,{},{token:e}))))});var ne,re,oe,ie,se;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ne||(ne={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(re||(re={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(oe||(oe={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ie||(ie={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(se||(se={}));const ae=Qt("identifier"),ce=Zt(ae,Qt("code")),le=Zt(ae),ue=Zt(ae,Yt("phone")),de=Zt(ae,Xt("email")),he=t=>({verify:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ce(((e,r)=>$t(t.post(qt(Y,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r,o)=>$t(t.post(qt(tt,n),{externalId:e,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>$t(t.post(qt(et,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le((e=>$t(t.post(qt(rt,n),{externalId:e}))))})),{}),update:{email:de(((e,n,r)=>$t(t.post(nt.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(ne).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,r,o)=>$t(t.post(qt(nt.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),pe=Qt("identifier"),fe=Qt("uri"),ve=Zt(Qt("token")),ge=Zt(pe,fe),be=Zt(pe,Yt("phone"),fe),we=Zt(pe,Xt("email"),fe),me=t=>({verify:ve((e=>$t(t.post(ot,{token:e})))),signIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>$t(t.post(qt(it,n),{externalId:e,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o)=>$t(t.post(qt(st,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(re).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r)=>$t(t.post(qt(ct,n),{externalId:e,URI:r}))))})),{}),update:{email:we(((e,n,r,o)=>$t(t.post(at.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(ne).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:be(((e,r,o,i)=>$t(t.post(qt(at.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})}}),ye=Qt("identifier"),ke=Qt("uri"),Ie=Zt(Qt("token")),Oe=Zt(ye,ke),je=Zt(Qt("pendingRef")),Se=Zt(ye,Xt("email"),ke),xe=t=>({verify:Ie((e=>$t(t.post(lt,{token:e})))),signIn:Oe(((e,n,r,o)=>$t(t.post(qt(ut,re.email),{externalId:e,URI:n,loginOptions:r},{token:o})))),signUpOrIn:Oe(((e,n)=>$t(t.post(qt(ft,re.email),{externalId:e,URI:n})))),signUp:Oe(((e,n,r)=>$t(t.post(qt(dt,re.email),{externalId:e,URI:n,user:r})))),waitForSession:je(((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(ht,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r($t(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Se(((e,n,r,o)=>$t(t.post(pt.email,{externalId:e,email:n,URI:r},{token:o}))))}});var _e;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(_e||(_e={}));const Ee=Zt(Qt("code")),Ue=t=>({start:Object.keys(_e).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={},o,i)=>{const s=await t.post(vt,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!r||!s.ok)return $t(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Ee((e=>$t(t.post(gt,{code:e}))))}),Ce=Zt(Qt("flowId")),Pe=Zt(Qt("executionId"),Qt("stepId"),Qt("interactionId")),Ae=t=>({start:Ce(((e,n,r,o)=>$t(t.post(xt,{flowId:e,options:o,interactionId:n,input:r})))),next:Pe(((e,n,r,o)=>$t(t.post(_t,{executionId:e,stepId:n,interactionId:r,input:o}))))}),Re=Zt(Qt("tenant")),Te=Zt(Qt("code")),Me=t=>({start:Re((async(e,n,{redirect:r=!1}={},o,i)=>{const s=await t.post(bt,o||{},{queryParams:{tenant:e,redirectURL:n},token:i});if(!r||!s.ok)return $t(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Te((e=>$t(t.post(wt,{code:e}))))}),De=Qt("identifier"),Le=Zt(De,Qt("code")),Ne=Zt(De),qe=Zt(De),$e=t=>({signUp:Ne(((e,n)=>$t(t.post(yt,{externalId:e,user:n})))),verify:Le(((e,n,r,o)=>$t(t.post(mt,{externalId:e,code:n,loginOptions:r},{token:o})))),update:qe(((e,n)=>$t(t.post(kt,{externalId:e},{token:n}))))}),Je=Qt("identifier"),Ke=Qt("origin"),We=Zt(Je,Ke,Qt("name")),Be=Zt(Je,Ke),Fe=Zt(Je,Ke,Qt("token")),He=Zt(Qt("transactionId"),Qt("response")),ze=t=>({signUp:{start:We(((e,n,r)=>$t(t.post(It.start,{user:{externalId:e,name:r},origin:n})))),finish:He(((e,n)=>$t(t.post(It.finish,{transactionId:e,response:n}))))},signIn:{start:Be(((e,n,r,o)=>$t(t.post(Ot.start,{externalId:e,origin:n,loginOptions:r},{token:o})))),finish:He(((e,n)=>$t(t.post(Ot.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Be(((e,n)=>$t(t.post(jt.start,{externalId:e,origin:n}))))},update:{start:Fe(((e,n,r)=>$t(t.post(St.start,{externalId:e,origin:n},{token:r})))),finish:He(((e,n)=>$t(t.post(St.finish,{transactionId:e,response:n}))))}}),Ge=Zt(Qt("token"));var Ve;const Ze=Zt([("projectId",Ve=Qt("projectId"),Jt(((t,e)=>t=>Kt(...e).validate(Q(t,"projectId")))(0,Ve))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Rt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{accessKey:ee(i),otp:he(i),magicLink:me(i),enchantedLink:xe(i),oauth:Ue(i),saml:Me(i),totp:$e(i),webauthn:ze(i),flow:Ae(i),refresh:t=>$t(i.post("/v1/auth/refresh",{},{token:t})),logout:t=>$t(i.post("/v1/auth/logout",{},{token:t})),logoutAll:t=>$t(i.post("/v1/auth/logoutall",{},{token:t})),me:t=>$t(i.get("/v1/auth/me",{token:t})),isJwtExpired:Ge(Dt),getJwtPermissions:Ge(Lt),getJwtRoles:Ge(Nt),httpClient:i};var i}));function Qe(t,e){var n=[];return function(t,e){var n,r,o=(r=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}(t),{current:function(){return r[0]},postpone:function(){var t=r.shift();void 0!==t&&r.push(t)},exclude:function(){r.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=o.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return"Blocked by CSP"===e||"9319"===e}(t)?o.postpone():o.exclude();var e,r=o.current();if(void 0===r)throw t;return(e=i(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(r,n+1)}))}))};return a(s,0)}(t,(function(t){var r=new Date,o=function(){return n.push({url:t,startedAt:r,finishedAt:new Date})},i=e(t);return i.then(o,o),i})).then((function(t){return[t,{attempts:n}]}))}Ze.DeliveryMethods=re;var Xe="Failed to load the JS script of the agent";function Ye(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=e(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");return Qe(function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.8.1"):t}))}(String(t),e)}))}(c,s),tn).catch(nn)})).then((function(e){var n=e[0],r=e[1];return n.load(t(t({},a),{ldi:r}))}))}function tn(t){return 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(){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(Xe))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)})).then(en)}function en(){var t=window,e="__fpjs_p_l_b",n=t[e];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)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error("9319");return n}function nn(t){throw t instanceof Error&&"9319"===t.message?new Error(Xe):t}var rn={exports:{}},on={exports:{}};on.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:"/"})}();var sn=u(rn.exports=on.exports);const an="undefined"!=typeof window,cn=an&&localStorage.getItem("fingerprint.public.key")||"A9aCLRHzKCv3uL69oqDr",ln=an&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",un=t=>{const e=Ye({apiKey:t||cn,endpoint:ln});return{get:async()=>{try{let t=sessionStorage.getItem("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 dn,hn,pn,fn,vn;const gn=t=>Object.assign({},t);class bn{constructor(t){dn.add(this),hn.set(this,void 0),pn.set(this,{}),fn.set(this,0),o(this,hn,t,"f")}get current(){return gn(r(this,hn,"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,hn,"f"),e)){const t=r(this,hn,"f");o(this,hn,e,"f"),Object.freeze(r(this,hn,"f")),setTimeout((()=>{Object.values(r(this,pn,"f")).forEach((n=>n(gn(e),t)))}),0)}}subscribe(t){o(this,fn,r(this,fn,"f")+1,"f"),r(this,pn,"f")[r(this,fn,"f")]=t;const e=r(this,fn,"f");return()=>r(this,dn,"m",vn).call(this,e.toString())}unsubscribeAll(){o(this,pn,{},"f")}}hn=new WeakMap,pn=new WeakMap,fn=new WeakMap,dn=new WeakSet,vn=function(t){r(this,pn,"f")[t]&&delete r(this,pn,"f")[t]};let wn=[];function mn(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=wn.pop();)clearTimeout(e);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{t(n)}),o);wn.push(i)}}function yn(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&sn.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 kn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function In(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Sn(n.publicKey.challenge),n.publicKey.user.id=Sn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Sn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:xn(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:xn(n.response.attestationObject),clientDataJSON:xn(n.response.clientDataJSON)})}));var n}async function On(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Sn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Sn(t.id)})),n}(t);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:xn(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:xn(n.response.authenticatorData),clientDataJSON:xn(n.response.clientDataJSON),signature:xn(n.response.signature),userHandle:n.response.userHandle?xn(n.response.userHandle):void 0})}));var n}async function jn(t=!1){if(!an)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Sn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function xn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const _n="undefined"!=typeof window&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",En="redirect",Un="poll",Cn="webauthnCreate",Pn="webauthnGet";function An(t){return new URLSearchParams(window.location.search).get(t)}function Rn(t){if(window.history.replaceState&&An(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 Tn;function Mn(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"}(Tn||(Tn={}));function Dn(t,e){const n=new URL(_n);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function Ln(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Tn.forward:t<e?Tn.backward:void 0}const Nn=()=>{const[t="",e=""]=(An("descope-login-flow")||"").split("_");return{executionId:t,stepId:e}};function qn(){Rn("descope-login-flow")}const $n=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Jn,Kn,Wn;function Bn(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(!Bn(i,s))return!1}else if(i!==s)return!1}return!0}class Fn{constructor(t={}){Jn.set(this,void 0),Kn.set(this,{}),Wn.set(this,0),o(this,Jn,t,"f")}get current(){return Object.assign({},r(this,Jn,"f"))}update(t){const e="function"==typeof t?t(r(this,Jn,"f")):t,n=Object.assign(Object.assign({},r(this,Jn,"f")),e);if(!Bn(r(this,Jn,"f"),n)){const t=r(this,Jn,"f");o(this,Jn,n,"f"),Object.freeze(r(this,Jn,"f")),setTimeout((()=>{Object.values(r(this,Kn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,Wn,r(this,Wn,"f")+1,"f"),r(this,Kn,"f")[r(this,Wn,"f")]=t,r(this,Wn,"f").toString()}unsubscribe(t){const e=!!r(this,Kn,"f")[t];return e&&delete r(this,Kn,"f")[t],e}unsubscribeAll(){return o(this,Kn,{},"f"),!0}}Jn=new WeakMap,Kn=new WeakMap,Wn=new WeakMap;const Hn=(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 zn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),n.publicKey.user.id=Vn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:Zn(r.rawId),type:r.type,response:{attestationObject:Zn(r.response.attestationObject),clientDataJSON:Zn(r.response.clientDataJSON)}});var r}))}function Gn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:Zn(r.rawId),type:r.type,response:{authenticatorData:Zn(r.response.authenticatorData),clientDataJSON:Zn(r.response.clientDataJSON),signature:Zn(r.response.signature),userHandle:Zn(r.response.userHandle)}});var r}))}function Vn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Zn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var Qn,Xn,Yn,tr,er,nr,rr,or,ir,sr,ar,cr,lr,ur,dr,hr,pr,fr,vr,gr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,xr;const _r=document.createElement("template");_r.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\tform[data-theme] {\n\t\t\tbackground-color: transparent;\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 Er extends HTMLElement{constructor(){super(),Qn.add(this),Xn.set(this,!1),Yn.set(this,new Fn),tr.set(this,new Fn),er.set(this,new Fn({isLoading:!1})),nr.set(this,void 0),rr.set(this,void 0),or.set(this,void 0),ir.set(this,void 0),sr.set(this,{popstate:r(this,Qn,"m",dr).bind(this)}),ar.set(this,void 0),cr.set(this,void 0),gr.set(this,(t=>{var e,n,o,i,s;if(!(null==t?void 0:t.ok))return r(this,Qn,"m",yr).call(this,"error",null==t?void 0:t.error),void r(this,Qn,"m",xr).call(this,{title:null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorDescription,description:null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.message});const a=null===(s=null===(i=null===(o=t.data)||void 0===o?void 0:o.screen)||void 0===i?void 0:i.state)||void 0===s?void 0:s.errorText;a&&r(this,Qn,"m",xr).call(this,{title:a});const{status:c,authInfo:l}=t.data;if("completed"===c)return void r(this,Qn,"m",yr).call(this,"success",l);const{executionId:u,stepId:d,action:h,screen:p,redirect:f,webauthn:v}=t.data;r(this,Yn,"f").update({stepId:d,executionId:u,action:h,redirectUrl:null==f?void 0:f.url,screenId:null==p?void 0:p.id,screenState:null==p?void 0:p.state,webauthnTransactionId:null==v?void 0:v.transactionId,webauthnOptions:null==v?void 0:v.options})})),kr.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=Dn(this["project-id"],"config.json");try{t=yield Mn(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),r(this,Qn,"m",lr).call(this),r(this,Yn,"f").subscribe(r(this,Qn,"m",vr).bind(this)),r(this,tr,"f").subscribe(r(this,Qn,"m",wr).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug"]}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}get debug(){return"true"===this.getAttribute("debug")}get theme(){var t,e;const n=this.getAttribute("theme");if(n)return n;return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){o(this,Xn,!0,"f"),r(this,Qn,"m",ur).call(this),r(this,Qn,"m",jr).call(this);const t=yield r(this,kr,"f").call(this),e=this["flow-id"];o(this,cr,((t,e)=>{var n;return(null===(n=null==t?void 0:t.flows)||void 0===n?void 0:n[e])||{}})(t,e),"f"),r(this,Qn,"m",Or).call(this,t),r(this,Qn,"m",fr).call(this),r(this,Qn,"m",Sr).call(this);const{executionId:n,stepId:i}=Nn();(n||i)&&qn();const s=An("t")||void 0;s&&Rn("t");const a=An("code")||void 0;a&&Rn("code"),r(this,Yn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],tenant:this.tenant,stepId:i,executionId:n,token:s,code:a}),window.addEventListener("popstate",r(this,sr,"f").popstate),r(this,nr,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=r(this,nr,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}))}disconnectedCallback(){r(this,Yn,"f").unsubscribeAll(),r(this,tr,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,sr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,Xn,"f")){if(e!==n&&Er.observedAttributes.includes(t)){r(this,Qn,"m",ur).call(this);const o=null===e;r(this,Yn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,qn()),{[$n(t)]:n,stepId:i,executionId:s}}))}"debug"===t&&r(this,Qn,"m",Sr).call(this)}}}Xn=new WeakMap,Yn=new WeakMap,tr=new WeakMap,er=new WeakMap,nr=new WeakMap,rr=new WeakMap,or=new WeakMap,ir=new WeakMap,sr=new WeakMap,ar=new WeakMap,cr=new WeakMap,gr=new WeakMap,kr=new WeakMap,Qn=new WeakSet,lr=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(_r.content.cloneNode(!0)),o(this,nr,this.shadowRoot.querySelector("form"),"f"),o(this,rr,this.shadowRoot.querySelector("style"),"f")},ur=function(){const t=["base-url","tenant","theme","debug"];if(Er.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},dr=function(){const{stepId:t,executionId:e}=Nn();r(this,Yn,"f").update({stepId:t,executionId:e})},hr=function(t){return(...e)=>n(this,void 0,void 0,(function*(){r(this,er,"f").update({isLoading:!0});try{return yield t(...e)}finally{r(this,er,"f").update({isLoading:!1})}}))},pr=function(t,n){o(this,ar,(t=>{var{autoRefresh:n=!0,persistTokens:r=!0}=t,o=e(t,["autoRefresh","persistTokens"]);an?un(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 bn({sessionToken:""}),l=new bn({});i.hooks={beforeRequest:t=>null==s?void 0:s(t),afterRequest:(t,e)=>null==a?void 0:a(t,e)};const u=Ze(i),d=(h=u,{async signUp(t,e){const n=await h.webauthn.signUp.start(t,window.location.origin,e),r=await In(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 On(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 In(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await On(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 In(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:In,get:On,isSupported:jn}});var h;const p=Object.assign(Object.assign({},u),{flow:Object.assign(Object.assign({},u.flow),{start:async(t,e,n,r)=>{const o=await d.helpers.isSupported(),i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dls_last_user_external_id"),s={tenant:null==r?void 0:r.tenant,redirectUrl:window.location.href,deviceInfo:{webAuthnSupport:o}};return i&&(s.lastUser={externalId:i}),u.flow.start(t,e,n,s)}}),webauthn:d,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=l.current;return e&&Object.entries(e).length>0&&t(e),l.subscribe((e=>{t(e)}))},getRefreshToken:kn});return an?(n&&["logout","logoutAll"].forEach((t=>{const e=u[t];p[t]=(...t)=>{const n=kn(),r=[(null==t?void 0:t.shift())||n,...t],o=e(...r);return localStorage&&localStorage.removeItem("DSR"),sn.remove("DS"),an&&(null===localStorage||void 0===localStorage||localStorage.removeItem("dls_last_user_external_id")),c.update({sessionToken:""}),o}})),s=t=>{if(t.body){const e={vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""};t.body.fpData=e}return!t.token&&r&&(t.token=kn()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.13"}),t},p.me=async(...t)=>{var e;const n=await u.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());l.update(t)}return n},(n||r)&&(a=(t,o)=>{!async function(t,n,r,o){var i;try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const s=await(null==n?void 0:n.json());if(s){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(s),{sessionJwt:a,refreshJwt:c,user:l}=n,u=e(n,["sessionJwt","refreshJwt","user"]);if(o.persistTokens&&yn(a,c,u),a&&r.sessionToken.update({sessionToken:a}),l){const t=null===(i=null==l?void 0:l.externalIds)||void 0===i?void 0:i[0];an&&t&&(null===localStorage||void 0===localStorage||localStorage.setItem("dls_last_user_external_id",t)),r.user.update(l)}a&&c&&o.autoRefresh&&mn(t,a,c)}}catch(t){console.error("Could not set tokens from body",t)}}(p.refresh,o,{sessionToken:c,user:l},{autoRefresh:n,persistTokens:r})}),n&&kn()&&p.refresh(),p):(console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),p)})({projectId:t,baseUrl:n,autoRefresh:!1}),"f");const i=r(this,ar,"f").flow.next;r(this,ar,"f").flow.next=r(this,Qn,"m",hr).call(this,i)},fr=function(){r(this,nr,"f").setAttribute("data-theme",this.theme)},vr=function(t,e,i){var s;return n(this,void 0,void 0,(function*(){const{projectId:a,flowId:c,baseUrl:l,tenant:u,stepId:d,executionId:h,action:p,screenId:f,screenState:v,redirectUrl:g,token:b,code:w,webauthnTransactionId:m,webauthnOptions:y}=t,k=i("projectId")||i("baseUrl");if(r(this,ir,"f")&&(clearInterval(r(this,ir,"f")),o(this,ir,null,"f")),k){if(!a)return;r(this,Qn,"m",pr).call(this,a,l)}if(!h){if(!c)return;const t=null===(s=r(this,cr,"f"))||void 0===s?void 0:s.startScreenId;if(t){const e={htmlUrl:Dn(a,`${t}.html`)};return r(this,tr,"f").update(e),void(r(this,ar,"f").flow.start=r(this,Qn,"m",hr).call(this,r(this,ar,"f").flow.start))}const e=yield r(this,ar,"f").flow.start(c,"",null,{tenant:u});return void r(this,gr,"f").call(this,e)}if(i("token")&&b||i("code")&&w){const t=yield r(this,ar,"f").flow.next(h,d,"submit",{token:b,exchangeCode:w});return r(this,gr,"f").call(this,t),void r(this,Yn,"f").update({token:void 0,code:void 0})}if(p===En)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(p===Cn||p===Pn){if(!m||!y)return void console.error("Did not get webauthn transaction id or options");const t=p===Cn?yield zn(y):yield Gn(y),e=yield r(this,ar,"f").flow.next(h,d,"submit",{transactionId:m,response:t});return void r(this,gr,"f").call(this,e)}if(p===Un&&o(this,ir,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,ar,"f").flow.next(h,d,"submit",{});r(this,gr,"f").call(this,t)}))),2e3),"f"),!f)return void console.error("Refreshing the page during a flow is not supported yet");const I={direction:Ln(+d,+e.stepId),screenState:v,htmlUrl:Dn(a,`${f}.html`)};(k||i("executionId")||i("stepId"))&&(I.next=(...t)=>r(this,ar,"f").flow.next(h,d,...t)),r(this,tr,"f").update(I)}))},br=function(t){r(this,nr,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const o=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),i=r(this,er,"f").subscribe((({isLoading:t})=>{var n,o,s,a;t?null===(o=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,er,"f").unsubscribe(i),null===(a=null===(s=e.submitter)||void 0===s?void 0:s.classList)||void 0===a||a.remove("loading"))}));e.preventDefault();const s=Object.fromEntries(new FormData(e.target).entries()),a=(c=e.submitter,Array.from((null==c?void 0:c.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 c;const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:window.location.origin});let u;const{executionId:d,tenant:h,flowId:p}=r(this,Yn,"f").current;u=d?yield t(o,l):yield r(this,ar,"f").flow.start(p,o,l,{tenant:h}),r(this,gr,"f").call(this,u)}))},wr=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 Mn(e,"text");const c=a.content.cloneNode(!0),l=(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),u=()=>{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),Hn(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{l.forEach((t=>t()))}catch(t){console.error(t)}r(this,nr,"f").replaceChildren(c),r(this,Qn,"m",br).call(this,i),r(this,Qn,"m",yr).call(this,"page-updated",{})};o?r(this,Qn,"m",mr).call(this,u,o):u()}))},mr=function(t,e){r(this,nr,"f").addEventListener("transitionend",(()=>{r(this,nr,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===Tn.forward?"slide-forward":"slide-backward";Array.from(r(this,nr,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,nr,"f").classList.add("fade-out")},yr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},Ir=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},Or=function(t){var e,n,o,i;null===(i=null===(o=null===(n=null===(e=null==t?void 0:t.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===n?void 0:n.typography)||void 0===o?void 0:o.fontFamilies)||void 0===i||i.forEach((t=>{r(this,Qn,"m",Ir).call(this,t.url)}))},jr=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=Dn(this["project-id"],"theme.css");t.innerText=yield Mn(e,"text"),this.shadowRoot.appendChild(t)}))},Sr=function(){var t;return n(this,void 0,void 0,(function*(){this.debug?(yield import("./debugger-wc-c91bd366.js"),o(this,or,document.createElement("descope-debugger"),"f"),Object.assign(r(this,or,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(r(this,or,"f"))):(null===(t=r(this,or,"f"))||void 0===t||t.remove(),o(this,or,null,"f"))}))},xr=function({title:t,description:e=""}){var n;t&&this.debug&&(null===(n=r(this,or,"f"))||void 0===n||n.updateData({title:t,description:e}))},customElements.define("descope-wc",Er);export{Er as D,Fn as S,r as _,o as a};
|