@descope/web-component 3.8.0 → 3.8.1
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{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-
|
|
1
|
+
import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-7bbe2eec.js";import"@descope/web-js-sdk";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 word-wrap: break-word;\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 t({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:e(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),n(this,l,this.shadowRoot.querySelector(".debugger"),"f"),n(this,a,e(this,l,"f").querySelector(".content"),"f"),n(this,r,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,o,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((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})(e(this,l,"f"),e(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e(this,d,"f").resize),(n=e(this,l,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},e(this,l,"f").onresize=e(this,i,"m",p).bind(this),e(this,o,"f").subscribe(e(this,i,"m",c).bind(this))}disconnectedCallback(){e(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(n){e(this,i,"m",h).call(this,n),e(this,i,"m",p).call(this)},h=function(n){e(this,a,"f").innerHTML=n.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(){e(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[n,t]=s(e(this,l,"f"),Number.parseInt(e(this,l,"f").style.left,10),Number.parseInt(e(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e(this,l,"f").style.top=`${t}px`,e(this,l,"f").style.left=`${n}px`},customElements.define("descope-debugger",m);export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import o,{ensureFingerprintIds as n,clearFingerprintData as r}from"@descope/web-js-sdk";const s="undefined"!=typeof localStorage,a=s&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",l="config.json",d="base.ui.components.url",c=s&&localStorage.getItem(d)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",u=s&&localStorage.getItem(d)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",h="descope-login-flow",p="code",f="ra-challenge",g="ra-callback",v="ra-backup-callback",m="ra-initiator",b="data-exclude-field",y="dls_last_auth",w="state_id",I="saml_idp_state_id",k="saml_idp_username",C="sso_app_id",A="oidc_login_hint",S="data-type",x="redirect",E="poll",j="webauthnCreate",U="webauthnGet",O="loadForm",L="submit",T="polling";var W;function R(t){return new URLSearchParams(window.location.search).get(t)}function M(t){if(window.history.replaceState&&R(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function $(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(W||(W={}));function P(t,e,i="v2-beta"){const o=new URL(a);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,i,e),o.toString()}function D(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?W.forward:t<e?W.backward:void 0}const N=()=>{const[t="",e=""]=(R(h)||"").split("_");return{executionId:t,stepId:e}};function q(){M(h)}const F=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),K=()=>{const{executionId:t,stepId:e}=N();(t||e)&&q();const i=R("t")||void 0;i&&M("t");const o=R(p)||void 0;o&&M(p);const n=R("err")||void 0;n&&M("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:R(f),redirectAuthCallbackUrl:R(g),redirectAuthBackupCallbackUri:R(v),redirectAuthInitiator:R(m)};(r||s||a||l)&&(M(f),M(g),M(v),M(m));const d=R(w);d&&M(w);const c=R(I);c&&M(I);const u=R(k);c&&M(k);const h=R(C);h&&M(C);const b=R(A);return b&&M(A),{executionId:t,stepId:e,token:i,code:o,exchangeError:n,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:b}},_=t=>{let e,i;return(...o)=>{return e&&(r=o,(n=e).length===r.length&&n.every(((t,e)=>t===r[e])))||(e=o,i=t(...o)),i;var n,r}};const H=(t,e,i,o,n,r)=>t&&!e&&(t&&!i&&!o)&&(t&&!n)&&(t&&!r),V=t=>null==t?void 0:t.submit(),B=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null};var J,z,G,Q;function X(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const n=i[o],r=t[n],s=e[n];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!X(r,s))return!1}else if(r!==s)return!1}return!0}class Y{constructor(t={},{updateOnlyOnChange:o=!0}={}){J.set(this,void 0),z.set(this,{}),G.set(this,0),Q.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,J,"f")):t,n=Object.assign(Object.assign({},e(this,J,"f")),o);if(!e(this,Q,"f")||!X(e(this,J,"f"),n)){const t=e(this,J,"f");i(this,J,n,"f"),Object.freeze(e(this,J,"f")),setTimeout((()=>{Object.values(e(this,z,"f")).forEach((e=>e(n,t,((t,e)=>i=>t[i]!==e[i])(n,t))))}),0)}},i(this,J,t,"f"),i(this,Q,o,"f")}get current(){return Object.assign({},e(this,J,"f"))}subscribe(t){return i(this,G,e(this,G,"f")+1,"f"),e(this,z,"f")[e(this,G,"f")]=t,e(this,G,"f").toString()}unsubscribe(t){const i=!!e(this,z,"f")[t];return i&&delete e(this,z,"f")[t],i}unsubscribeAll(){return i(this,z,{},"f"),!0}}J=new WeakMap,z=new WeakMap,G=new WeakMap,Q=new WeakMap;const Z=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${b}])`)).forEach((t=>{t.value=i}))}))},tt=(t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),et=(t,e,i,o,n)=>{var r;let s=null==e?void 0:e.errorText;try{s=(null==o?void 0:o({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){n.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${S}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",s),((t,e)=>{t.querySelectorAll(`[${S}="totp-link"]`).forEach((t=>{t.setAttribute("href",e)}))})(t,null===(r=null==e?void 0:e.totp)||void 0===r?void 0:r.provisionUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link").forEach((t=>{t.textContent=tt(t.textContent,e)}))})(t,e),((t,e,i)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const n=e[o];Object.keys(n).forEach((e=>{let o=n[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){i.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,i,n),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=tt(t.value,e)}))}))})(t,e)},it=_((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o,n;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,i=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return i?i.version:0})()>=108;return yield(i=100,o=r,n=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?t(n):e(new Error(`Promise timed out after ${i} ms`))}),i);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ot={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function nt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(y)))}catch(t){}return e}const rt="dls_ab_testing_id",st=document.createElement("template");var at,lt,dt,ct,ut,ht,pt,ft,gt,vt,mt,bt,yt,wt,It,kt,Ct,At,St,xt,Et,jt,Ut,Ot,Lt,Tt,Wt,Rt,Mt,$t,Pt,Dt,Nt,qt,Ft,Kt,_t,Ht,Vt,Bt,Jt,zt,Gt,Qt,Xt,Yt,Zt,te;st.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[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<div id="wc-root"></div>\n\t';class ee extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(o){super(),at.add(this),this.logger=console,lt.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,at,"m",Wt).call(this,t,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)}},dt.set(this,new Y({deferredRedirect:!1})),ct.set(this,new Y),ut.set(this,{}),this.getComponentsContext=()=>e(this,ut,"f"),this.nextRequestStatus=new Y({isLoading:!1}),ht.set(this,void 0),pt.set(this,{popstate:e(this,at,"m",yt).bind(this),visibilitychange:e(this,at,"m",wt).bind(this),componentsContext:e(this,at,"m",Ut).bind(this)}),ft.set(this,void 0),St.set(this,_((()=>t(this,void 0,void 0,(function*(){const t=P(this.projectId,l);try{const{body:e,headers:i}=yield $(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,ft,o,"f"),e(this,at,"m",gt).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const t=JSON.parse(this.getAttribute("form"))||{};return Object.entries(t).reduce(((t,[e,i])=>Object.assign(Object.assign({},t),{[`form.${e}`]:i})),t)}catch(t){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var t,e;const i=this.getAttribute("theme");if("os"===i){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"}return i||"light"}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,St,"f").call(this);return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,St,"f").call(this);return t}))}getFlowConfig(){var e,i;return t(this,void 0,void 0,(function*(){const t=yield this.getProjectConfig(),o=(null===(e=null==t?void 0:t.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(i=o.version)&&void 0!==i||(o.version=0),o}))}getTargetLocales(){return t(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}connectedCallback(){return t(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(e(this,ct,"f").subscribe(e(this,at,"m",Tt).bind(this)),e(this,ct,"f").update({isDebug:this.debug}),e(this,at,"m",vt).call(this))return void e(this,at,"m",mt).call(this);if(e(this,at,"m",bt).call(this),yield e(this,at,"m",Ct).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield e(this,St,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield e(this,at,"m",$t).call(this),yield e(this,at,"m",Et).call(this),e(this,at,"m",xt).call(this),e(this,at,"m",Rt).call(this);const{executionId:t,stepId:o,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}=K();window.addEventListener("popstate",e(this,pt,"f").popstate),window.addEventListener("components-context",e(this,pt,"f").componentsContext),window.addEventListener("visibilitychange",e(this,pt,"f").visibilitychange),e(this,dt,"f").subscribe(e(this,at,"m",kt).bind(this)),e(this,dt,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}),i(this,lt,!0,"f")}}))}disconnectedCallback(){e(this,dt,"f").unsubscribeAll(),e(this,ct,"f").unsubscribeAll(),e(this,at,"m",Lt).call(this),window.removeEventListener("popstate",e(this,pt,"f").popstate),window.removeEventListener("visibilitychange",e(this,pt,"f").visibilitychange),window.removeEventListener("components-context",e(this,pt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,lt,"f")&&i!==o&&ee.observedAttributes.includes(t)){e(this,at,"m",bt).call(this);const n=null===i;e(this,dt,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return n||(s=null,r=null,q()),{[F(t)]:o,stepId:r,executionId:s}})),e(this,ct,"f").update({isDebug:this.debug})}}}lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,pt=new WeakMap,ft=new WeakMap,St=new WeakMap,at=new WeakSet,gt=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(st.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},vt=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},mt=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},bt=function(){const t=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if(ee.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[F(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')},yt=function(){const{stepId:t,executionId:i}=N();e(this,dt,"f").update({stepId:t,executionId:i})},wt=function(){document.hidden||setTimeout((()=>{e(this,dt,"f").update({deferredRedirect:!1})}),300)},It=function(e,i){this.sdk=o(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},ee.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},kt=function(i,o,n){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=i;if(n("projectId")||n("baseUrl")){if(!t)return;e(this,at,"m",It).call(this,t,o)}e(this,ft,"f").call(this,i)}))},Ct=function(){return t(this,void 0,void 0,(function*(){return(yield e(this,St,"f").call(this)).isMissingConfig&&(yield e(this,at,"m",At).call(this))}))},At=function(){return t(this,void 0,void 0,(function*(){const t=P(this.projectId,l,"v2-alpha");try{return yield $(t,"json"),!0}catch(t){return!1}}))},xt=function(){var i,o;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,St,"f").call(this),n=null===(o=null===(i=null==t?void 0:t.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.fonts;n&&Object.values(n).forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Et=function(){return t(this,void 0,void 0,(function*(){yield e(this,at,"m",jt).call(this),yield e(this,at,"m",Ot).call(this)}))},jt=function(){var e,i,o,n;return t(this,void 0,void 0,(function*(){const t=document.createElement("style"),r=P(this.projectId,"theme.json");try{const{body:s}=yield $(r,"json");t.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"");const a=yield ee.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(o=null==s?void 0:s.light)||void 0===o?void 0:o.components,dark:null===(n=null==s?void 0:s.dark)||void 0===n?void 0:n.components})}catch(t){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Ut=function(t){i(this,ut,Object.assign(Object.assign({},t.detail),e(this,ut,"f")),"f")},Ot=function(){return t(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const t=yield ee.descopeUI;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)}))},Lt=function(){var t;null===(t=e(this,ht,"f"))||void 0===t||t.remove(),i(this,ht,null,"f")},Tt=function({isDebug:o}){return t(this,void 0,void 0,(function*(){o?(i(this,ht,document.createElement("descope-debugger"),"f"),Object.assign(e(this,ht,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-893f1cd0.js"),document.body.appendChild(e(this,ht,"f"))):e(this,at,"m",Lt).call(this)}))},Wt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,ht,"f"))||void 0===o||o.updateData({title:t,description:i}))},Rt=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("descope-button");if(1===e.length)return void e[0].click();const i=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));if(1===i.length)i[0].click();else if(0===i.length){const t=Array.from(e).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&t[0].click()}}},Mt=function(){var i,o;return t(this,void 0,void 0,(function*(){const t=null===(o=null===(i=yield e(this,St,"f").call(this))||void 0===i?void 0:i.projectConfig)||void 0===o?void 0:o.componentsVersion;return t||(this.logger.error("Did not get components version, using latest version"),"latest")}))},$t=function(){return t(this,void 0,void 0,(function*(){ee.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):ee.descopeUI=new Promise((i=>{if(globalThis.DescopeUI)return void i(globalThis.DescopeUI);const o=t=>{const e=document.createElement("script");return e.id="load-descope-ui",e.src=t,e},n=(t,e)=>t.replace("<version>",e),r=(t,e)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),e()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),i(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{t(this,void 0,void 0,(function*(){const t=yield e(this,at,"m",Mt).call(this),s=o(n(c,t));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const e=o(n(u,t));r(e,(()=>{i(void 0)})),document.body.append(e)})),document.body.append(s)}))})()}))}))},ee.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.0"}};class ie extends ee{static set sdkConfigOverrides(t){ee.sdkConfigOverrides=t}constructor(){const o=new Y;super(o.update.bind(o)),Pt.add(this),this.stepState=new Y({},{updateOnlyOnChange:!1}),Dt.set(this,void 0),Nt.set(this,null),qt.set(this,((o,n,r,s,a)=>{r===E&&i(this,Dt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t;const i=yield this.sdk.flow.next(o,n,T,s,a,{});e(this,Kt,"f").call(this,i);const{action:r}=null!==(t=null==i?void 0:i.data)&&void 0!==t?t:{};e(this,qt,"f").call(this,o,n,r,s,a)}))),2e3),"f")})),Ft.set(this,(()=>{clearTimeout(e(this,Dt,"f")),i(this,Dt,null,"f")})),Kt.set(this,(t=>{var i,o,n,r,a,l,d,c,u;if(!(null==t?void 0:t.ok)){e(this,Pt,"m",te).call(this,"error",null==t?void 0:t.error);const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,l=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.statusText}`;return void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(c=null===(d=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===d?void 0:d.state)||void 0===c?void 0:c.errorText;(null===(u=t.data)||void 0===u?void 0:u.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${h?`${h} - `:""}${t.data.error.message}`):h&&this.loggerWrapper.error(h);const{status:p,authInfo:f,lastAuth:g}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&s&&localStorage.setItem(y,JSON.stringify(t))}(g),void e(this,Pt,"m",te).call(this,"success",f);const{executionId:v,stepId:m,stepName:b,action:w,screen:I,redirect:k,webauthn:C,error:A,samlIdpResponse:S}=t.data;w!==E?(this.loggerWrapper.info(`Step "${b||`#${m}`}" is ${p}`,"",{screen:I,status:p,stepId:m,stepName:b,action:w,error:A}),this.flowState.update({stepId:m,executionId:v,action:w,redirectTo:null==k?void 0:k.url,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==S?void 0:S.url,samlIdpResponseSamlResponse:null==S?void 0:S.samlResponse,samlIdpResponseRelayState:null==S?void 0:S.relayState})):this.flowState.update({action:w})})),_t.set(this,_((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.error("Webauthn start failed",t.message)}}))))),this.flowState=o}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var i,o;return t(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=e(this,Nt,"f"))||void 0===t||t.abort(),i(this,Nt,null,"f")}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const n=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(n)&&(t=`${i}-${n}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield $(i,"text");return t}catch(t){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${e}`,t)}try{const{body:t}=yield $(e,"text");return t}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(o,s,a){var l,d;return t(this,void 0,void 0,(function*(){const{projectId:t,flowId:c,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectUrl:b,token:y,code:w,exchangeError:I,webauthnTransactionId:k,webauthnOptions:C,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:S,redirectAuthBackupCallbackUri:E,redirectAuthInitiator:T,oidcIdpStateId:W,locale:R,samlIdpStateId:M,samlIdpUsername:$,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:F,ssoAppId:K,oidcLoginHint:_}=o;let B,J;const z=(()=>{const t=localStorage.getItem(rt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(rt,t.toString()),t}return Number(t)})(),G=this.sdk.getLastUserLoginId(),Q=yield this.getFlowConfig(),X=yield this.getProjectConfig(),Y=S&&A?{callbackUrl:S,codeChallenge:A,backupCallbackUri:E}:void 0;if(!p&&(Q.fingerprintEnabled&&Q.fingerprintKey?n(Q.fingerprintKey):r(),Q.conditions?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i,predicate:o})=>{var n;if("ELSE"===e)return!0;const r=null===(n=ot[e])||void 0===n?void 0:n[i];return!!(null==r?void 0:r(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:G,code:w,token:y,abTestingKey:z},Q.conditions)):Q.condition?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{var i;const o=null===(i=ot[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const n=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==n?void 0:n.screenId,conditionInteractionId:null==n?void 0:n.interactionId}})(Q.condition,{loginId:G,code:w,token:y,abTestingKey:z})):B=Q.startScreenId,!H(B,W,M,$,K,_))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign({tenant:u,redirectAuth:Y,oidcIdpStateId:W,samlIdpStateId:M,samlIdpUsername:$,ssoAppId:K,oidcLoginHint:_,client:this.client},b&&{redirectUrl:b}),{lastAuth:nt(G),abTestingKey:z}),J,"",Q.version,X.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),w?{exchangeCode:w,idpInitiated:!0}:{}),y?{token:y}:{}),_?{externalId:_}:{}));return e(this,Kt,"f").call(this,t),void("completed"!==(null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(a("token")&&y||a("code")&&w||a("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,L,Q.version,X.componentsVersion,{token:y,exchangeCode:w,exchangeError:I});return e(this,Kt,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===O&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>a(t)))){if(!N||!q)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,i,o)=>{const n=document.createElement("form");n.method="POST",n.action=t,n.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(n),o(n)})(N,q,F||"",V)}if(f===x&&(a("redirectTo")||a("deferredRedirect")))return m?"android"===T&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===j||f===U){if(!k||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(d=e(this,Nt,"f"))||void 0===d||d.abort(),i(this,Nt,null,"f");try{t=f===j?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),o=t.name}const n=yield this.sdk.flow.next(p,h,L,Q.version,X.componentsVersion,{transactionId:k,response:t,failure:o});e(this,Kt,"f").call(this,n)}if(e(this,qt,"f").call(this,p,h,f,Q.version,X.componentsVersion),!g&&!B)return void this.loggerWrapper.warn("No screen was found to show");const Z=B||g,tt=yield this.getHtmlFilenameWithLocale(R,Z),et={direction:D(+h,+s.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.form),null==v?void 0:v.form),lastAuth:{loginId:G,name:this.sdk.getLastUserDisplayName()||G}}),htmlUrl:P(t,`${Z}.html`),htmlLocaleUrl:tt&&P(t,tt),samlIdpUsername:$,oidcLoginHint:_},it=nt(G);H(B,W,M,$,K,_)?et.next=(t,e,i,o)=>this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:Y,oidcIdpStateId:W,samlIdpStateId:M,samlIdpUsername:$,ssoAppId:K,oidcLoginHint:_,lastAuth:it,preview:this.preview,abTestingKey:z,client:this.client},b&&{redirectUrl:b}),J,t,e,i,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),w&&{exchangeCode:w,idpInitiated:!0}),y&&{token:y})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(et.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(et)}))}loadDescopeUiComponents(e){return t(this,void 0,void 0,(function*(){const i=yield ee.descopeUI;if(!i)return;const o=(t=>[...Array.from(t.querySelectorAll("*")).reduce(((t,e)=>e.tagName.startsWith("DESCOPE-")?t.add(e.tagName.toLocaleLowerCase()):t),new Set)])(e);yield Promise.all(o.map((e=>t(this,void 0,void 0,(function*(){if(!!!customElements.get(e))if(i[e])try{return yield i[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(i).join(", ")}"`)})))))}))}onStepChange(i,o){var n,r;return t(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c}=i,u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u.content);this.sdk.webauthn.helpers.isSupported()?yield e(this,Pt,"m",Vt).call(this,h,d):h.querySelectorAll(`descope-button[${S}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(n=c.form)||void 0===n?void 0:n.loginId)||(null===(r=c.form)||void 0===r?void 0:r.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),et(h,c,c.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(h,f);const g=()=>t(this,void 0,void 0,(function*(){var t;yield p,((t,e)=>{var i,o;const n=null===(i=customElements.get("descope-totp-image"))||void 0===i?void 0:i.cssVarList.url;e&&n&&(null===(o=null==t?void 0:t.style)||void 0===o||o.setProperty(n,`url(data:image/jpg;base64,${e})`))})(this.shadowRoot.querySelector("div"),null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),this.rootElement.replaceChildren(h),setTimeout((()=>((t,e)=>{Z(t,null==e?void 0:e.inputs),Z(t,null==e?void 0:e.form)})(this.rootElement,c)));const i=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,i),e(this,Pt,"m",Yt).call(this,d),i&&e(this,Pt,"m",te).call(this,"ready",{}),e(this,Pt,"m",te).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${S}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(T,t.version,i.componentsVersion,{});e(this,Kt,"f").call(this,o)}}));l?e(this,Pt,"m",Zt).call(this,g,l):g()}))}}Dt=new WeakMap,Nt=new WeakMap,qt=new WeakMap,Ft=new WeakMap,Kt=new WeakMap,_t=new WeakMap,Pt=new WeakSet,Ht=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const i=`user-${e}`;t.setAttribute("name",i),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:i)}))}},Vt=function(o,n){var r;return t(this,void 0,void 0,(function*(){null===(r=e(this,Nt,"f"))||void 0===r||r.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield it())){const{options:o,transactionId:r}=(yield e(this,_t,"f").call(this))||{};if(o&&r){e(this,Pt,"m",Ht).call(this,s),i(this,Nt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Nt,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield n(s.id,a.version,l.componentsVersion,{transactionId:r,response:i});e(this,Kt,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},Bt=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((t=>{var e,i;return null===(e=t.reportValidity)||void 0===e||e.call(t),null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)}))},Jt=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${b}])`));return(yield Promise.all(e.map((e=>t(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},zt=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Gt=function(t={}){var e,i;const o=B(t,["externalId","email","phone"]),n=B(t,["newPassword","password"]);if(o&&n)try{const t=new globalThis.PasswordCredential({id:o,password:n});null===(i=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===i||i.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},Qt=function(i,o){return t(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||e(this,Pt,"m",Bt).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,Pt,"m",zt).call(this,i);const r=yield e(this,Pt,"m",Jt).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(n,d.version,c.componentsVersion,l);e(this,Kt,"f").call(this,u),e(this,Pt,"m",Gt).call(this,r)}var t}))},Xt=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,Pt,"m",Qt).call(this,i,t)}))}))},Yt=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,Pt,"m",Qt).call(this,i,t)}})),e(this,Pt,"m",Xt).call(this,t)},Zt=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===W.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(i)})),this.rootElement.classList.add("fade-out")},te=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",ie);export{ie as D,Y as S};
|
|
1
|
+
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import o,{ensureFingerprintIds as n,clearFingerprintData as r}from"@descope/web-js-sdk";const s="undefined"!=typeof localStorage,a=s&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",l="config.json",d="base.ui.components.url",c=s&&localStorage.getItem(d)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",u=s&&localStorage.getItem(d)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",h="descope-login-flow",p="code",f="ra-challenge",g="ra-callback",v="ra-backup-callback",m="ra-initiator",b="data-exclude-field",y="dls_last_auth",w="state_id",I="saml_idp_state_id",k="saml_idp_username",C="sso_app_id",A="oidc_login_hint",S="data-type",x="redirect",E="poll",j="webauthnCreate",U="webauthnGet",O="loadForm",L="submit",T="polling";var W;function R(t){return new URLSearchParams(window.location.search).get(t)}function M(t){if(window.history.replaceState&&R(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function $(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(W||(W={}));function P(t,e,i="v2-beta"){const o=new URL(a);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,i,e),o.toString()}function D(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?W.forward:t<e?W.backward:void 0}const N=()=>{const[t="",e=""]=(R(h)||"").split("_");return{executionId:t,stepId:e}};function q(){M(h)}const F=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),K=()=>{const{executionId:t,stepId:e}=N();(t||e)&&q();const i=R("t")||void 0;i&&M("t");const o=R(p)||void 0;o&&M(p);const n=R("err")||void 0;n&&M("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:R(f),redirectAuthCallbackUrl:R(g),redirectAuthBackupCallbackUri:R(v),redirectAuthInitiator:R(m)};(r||s||a||l)&&(M(f),M(g),M(v),M(m));const d=R(w);d&&M(w);const c=R(I);c&&M(I);const u=R(k);c&&M(k);const h=R(C);h&&M(C);const b=R(A);return b&&M(A),{executionId:t,stepId:e,token:i,code:o,exchangeError:n,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:b}},_=t=>{let e,i;return(...o)=>{return e&&(r=o,(n=e).length===r.length&&n.every(((t,e)=>t===r[e])))||(e=o,i=t(...o)),i;var n,r}};const H=(t,e,i,o,n,r)=>t&&!e&&(t&&!i&&!o)&&(t&&!n)&&(t&&!r),V=t=>null==t?void 0:t.submit(),B=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null};var J,z,G,Q;function X(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const n=i[o],r=t[n],s=e[n];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!X(r,s))return!1}else if(r!==s)return!1}return!0}class Y{constructor(t={},{updateOnlyOnChange:o=!0}={}){J.set(this,void 0),z.set(this,{}),G.set(this,0),Q.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,J,"f")):t,n=Object.assign(Object.assign({},e(this,J,"f")),o);if(!e(this,Q,"f")||!X(e(this,J,"f"),n)){const t=e(this,J,"f");i(this,J,n,"f"),Object.freeze(e(this,J,"f")),setTimeout((()=>{Object.values(e(this,z,"f")).forEach((e=>e(n,t,((t,e)=>i=>t[i]!==e[i])(n,t))))}),0)}},i(this,J,t,"f"),i(this,Q,o,"f")}get current(){return Object.assign({},e(this,J,"f"))}subscribe(t){return i(this,G,e(this,G,"f")+1,"f"),e(this,z,"f")[e(this,G,"f")]=t,e(this,G,"f").toString()}unsubscribe(t){const i=!!e(this,z,"f")[t];return i&&delete e(this,z,"f")[t],i}unsubscribeAll(){return i(this,z,{},"f"),!0}}J=new WeakMap,z=new WeakMap,G=new WeakMap,Q=new WeakMap;const Z=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${b}])`)).forEach((t=>{t.value=i}))}))},tt=(t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),et=(t,e,i,o,n)=>{var r;let s=null==e?void 0:e.errorText;try{s=(null==o?void 0:o({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){n.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${S}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",s),((t,e)=>{t.querySelectorAll(`[${S}="totp-link"]`).forEach((t=>{t.setAttribute("href",e)}))})(t,null===(r=null==e?void 0:e.totp)||void 0===r?void 0:r.provisionUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link").forEach((t=>{t.textContent=tt(t.textContent,e)}))})(t,e),((t,e,i)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const n=e[o];Object.keys(n).forEach((e=>{let o=n[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){i.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,i,n),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=tt(t.value,e)}))}))})(t,e)},it=_((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o,n;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,i=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return i?i.version:0})()>=108;return yield(i=100,o=r,n=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?t(n):e(new Error(`Promise timed out after ${i} ms`))}),i);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ot={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function nt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(y)))}catch(t){}return e}const rt="dls_ab_testing_id",st=document.createElement("template");var at,lt,dt,ct,ut,ht,pt,ft,gt,vt,mt,bt,yt,wt,It,kt,Ct,At,St,xt,Et,jt,Ut,Ot,Lt,Tt,Wt,Rt,Mt,$t,Pt,Dt,Nt,qt,Ft,Kt,_t,Ht,Vt,Bt,Jt,zt,Gt,Qt,Xt,Yt,Zt,te;st.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[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<div id="wc-root"></div>\n\t';class ee extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(o){super(),at.add(this),this.logger=console,lt.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,at,"m",Wt).call(this,t,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)}},dt.set(this,new Y({deferredRedirect:!1})),ct.set(this,new Y),ut.set(this,{}),this.getComponentsContext=()=>e(this,ut,"f"),this.nextRequestStatus=new Y({isLoading:!1}),ht.set(this,void 0),pt.set(this,{popstate:e(this,at,"m",yt).bind(this),visibilitychange:e(this,at,"m",wt).bind(this),componentsContext:e(this,at,"m",Ut).bind(this)}),ft.set(this,void 0),St.set(this,_((()=>t(this,void 0,void 0,(function*(){const t=P(this.projectId,l);try{const{body:e,headers:i}=yield $(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,ft,o,"f"),e(this,at,"m",gt).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const t=JSON.parse(this.getAttribute("form"))||{};return Object.entries(t).reduce(((t,[e,i])=>Object.assign(Object.assign({},t),{[`form.${e}`]:i})),t)}catch(t){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var t,e;const i=this.getAttribute("theme");if("os"===i){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"}return i||"light"}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,St,"f").call(this);return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,St,"f").call(this);return t}))}getFlowConfig(){var e,i;return t(this,void 0,void 0,(function*(){const t=yield this.getProjectConfig(),o=(null===(e=null==t?void 0:t.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(i=o.version)&&void 0!==i||(o.version=0),o}))}getTargetLocales(){return t(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}connectedCallback(){return t(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(e(this,ct,"f").subscribe(e(this,at,"m",Tt).bind(this)),e(this,ct,"f").update({isDebug:this.debug}),e(this,at,"m",vt).call(this))return void e(this,at,"m",mt).call(this);if(e(this,at,"m",bt).call(this),yield e(this,at,"m",Ct).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield e(this,St,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield e(this,at,"m",$t).call(this),yield e(this,at,"m",Et).call(this),e(this,at,"m",xt).call(this),e(this,at,"m",Rt).call(this);const{executionId:t,stepId:o,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}=K();window.addEventListener("popstate",e(this,pt,"f").popstate),window.addEventListener("components-context",e(this,pt,"f").componentsContext),window.addEventListener("visibilitychange",e(this,pt,"f").visibilitychange),e(this,dt,"f").subscribe(e(this,at,"m",kt).bind(this)),e(this,dt,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}),i(this,lt,!0,"f")}}))}disconnectedCallback(){e(this,dt,"f").unsubscribeAll(),e(this,ct,"f").unsubscribeAll(),e(this,at,"m",Lt).call(this),window.removeEventListener("popstate",e(this,pt,"f").popstate),window.removeEventListener("visibilitychange",e(this,pt,"f").visibilitychange),window.removeEventListener("components-context",e(this,pt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,lt,"f")&&i!==o&&ee.observedAttributes.includes(t)){e(this,at,"m",bt).call(this);const n=null===i;e(this,dt,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return n||(s=null,r=null,q()),{[F(t)]:o,stepId:r,executionId:s}})),e(this,ct,"f").update({isDebug:this.debug})}}}lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,pt=new WeakMap,ft=new WeakMap,St=new WeakMap,at=new WeakSet,gt=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(st.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},vt=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},mt=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},bt=function(){const t=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if(ee.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[F(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')},yt=function(){const{stepId:t,executionId:i}=N();e(this,dt,"f").update({stepId:t,executionId:i})},wt=function(){document.hidden||setTimeout((()=>{e(this,dt,"f").update({deferredRedirect:!1})}),300)},It=function(e,i){this.sdk=o(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},ee.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},kt=function(i,o,n){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=i;if(n("projectId")||n("baseUrl")){if(!t)return;e(this,at,"m",It).call(this,t,o)}e(this,ft,"f").call(this,i)}))},Ct=function(){return t(this,void 0,void 0,(function*(){return(yield e(this,St,"f").call(this)).isMissingConfig&&(yield e(this,at,"m",At).call(this))}))},At=function(){return t(this,void 0,void 0,(function*(){const t=P(this.projectId,l,"v2-alpha");try{return yield $(t,"json"),!0}catch(t){return!1}}))},xt=function(){var i,o;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,St,"f").call(this),n=null===(o=null===(i=null==t?void 0:t.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.fonts;n&&Object.values(n).forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Et=function(){return t(this,void 0,void 0,(function*(){yield e(this,at,"m",jt).call(this),yield e(this,at,"m",Ot).call(this)}))},jt=function(){var e,i,o,n;return t(this,void 0,void 0,(function*(){const t=document.createElement("style"),r=P(this.projectId,"theme.json");try{const{body:s}=yield $(r,"json");t.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"");const a=yield ee.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(o=null==s?void 0:s.light)||void 0===o?void 0:o.components,dark:null===(n=null==s?void 0:s.dark)||void 0===n?void 0:n.components})}catch(t){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Ut=function(t){i(this,ut,Object.assign(Object.assign({},t.detail),e(this,ut,"f")),"f")},Ot=function(){return t(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const t=yield ee.descopeUI;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)}))},Lt=function(){var t;null===(t=e(this,ht,"f"))||void 0===t||t.remove(),i(this,ht,null,"f")},Tt=function({isDebug:o}){return t(this,void 0,void 0,(function*(){o?(i(this,ht,document.createElement("descope-debugger"),"f"),Object.assign(e(this,ht,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-155193fe.js"),document.body.appendChild(e(this,ht,"f"))):e(this,at,"m",Lt).call(this)}))},Wt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,ht,"f"))||void 0===o||o.updateData({title:t,description:i}))},Rt=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("descope-button");if(1===e.length)return void e[0].click();const i=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));if(1===i.length)i[0].click();else if(0===i.length){const t=Array.from(e).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&t[0].click()}}},Mt=function(){var i,o;return t(this,void 0,void 0,(function*(){const t=null===(o=null===(i=yield e(this,St,"f").call(this))||void 0===i?void 0:i.projectConfig)||void 0===o?void 0:o.componentsVersion;return t||(this.logger.error("Did not get components version, using latest version"),"latest")}))},$t=function(){return t(this,void 0,void 0,(function*(){ee.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):ee.descopeUI=new Promise((i=>{if(globalThis.DescopeUI)return void i(globalThis.DescopeUI);const o=t=>{const e=document.createElement("script");return e.id="load-descope-ui",e.src=t,e},n=(t,e)=>t.replace("<version>",e),r=(t,e)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),e()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),i(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{t(this,void 0,void 0,(function*(){const t=yield e(this,at,"m",Mt).call(this),s=o(n(c,t));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const e=o(n(u,t));r(e,(()=>{i(void 0)})),document.body.append(e)})),document.body.append(s)}))})()}))}))},ee.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.1"}};class ie extends ee{static set sdkConfigOverrides(t){ee.sdkConfigOverrides=t}constructor(){const o=new Y;super(o.update.bind(o)),Pt.add(this),this.stepState=new Y({},{updateOnlyOnChange:!1}),Dt.set(this,void 0),Nt.set(this,null),qt.set(this,((o,n,r,s,a)=>{r===E&&i(this,Dt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t;const i=yield this.sdk.flow.next(o,n,T,s,a,{});e(this,Kt,"f").call(this,i);const{action:r}=null!==(t=null==i?void 0:i.data)&&void 0!==t?t:{};e(this,qt,"f").call(this,o,n,r,s,a)}))),2e3),"f")})),Ft.set(this,(()=>{clearTimeout(e(this,Dt,"f")),i(this,Dt,null,"f")})),Kt.set(this,(t=>{var i,o,n,r,a,l,d,c,u;if(!(null==t?void 0:t.ok)){e(this,Pt,"m",te).call(this,"error",null==t?void 0:t.error);const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,l=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.statusText}`;return void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(c=null===(d=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===d?void 0:d.state)||void 0===c?void 0:c.errorText;(null===(u=t.data)||void 0===u?void 0:u.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${h?`${h} - `:""}${t.data.error.message}`):h&&this.loggerWrapper.error(h);const{status:p,authInfo:f,lastAuth:g}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&s&&localStorage.setItem(y,JSON.stringify(t))}(g),void e(this,Pt,"m",te).call(this,"success",f);const{executionId:v,stepId:m,stepName:b,action:w,screen:I,redirect:k,webauthn:C,error:A,samlIdpResponse:S}=t.data;w!==E?(this.loggerWrapper.info(`Step "${b||`#${m}`}" is ${p}`,"",{screen:I,status:p,stepId:m,stepName:b,action:w,error:A}),this.flowState.update({stepId:m,executionId:v,action:w,redirectTo:null==k?void 0:k.url,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==S?void 0:S.url,samlIdpResponseSamlResponse:null==S?void 0:S.samlResponse,samlIdpResponseRelayState:null==S?void 0:S.relayState})):this.flowState.update({action:w})})),_t.set(this,_((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.error("Webauthn start failed",t.message)}}))))),this.flowState=o}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var i,o;return t(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=e(this,Nt,"f"))||void 0===t||t.abort(),i(this,Nt,null,"f")}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const n=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(n)&&(t=`${i}-${n}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield $(i,"text");return t}catch(t){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${e}`,t)}try{const{body:t}=yield $(e,"text");return t}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(o,s,a){var l,d;return t(this,void 0,void 0,(function*(){const{projectId:t,flowId:c,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectUrl:b,token:y,code:w,exchangeError:I,webauthnTransactionId:k,webauthnOptions:C,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:S,redirectAuthBackupCallbackUri:E,redirectAuthInitiator:T,oidcIdpStateId:W,locale:R,samlIdpStateId:M,samlIdpUsername:$,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:F,ssoAppId:K,oidcLoginHint:_}=o;let B,J;const z=(()=>{const t=localStorage.getItem(rt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(rt,t.toString()),t}return Number(t)})(),G=this.sdk.getLastUserLoginId(),Q=yield this.getFlowConfig(),X=yield this.getProjectConfig(),Y=S&&A?{callbackUrl:S,codeChallenge:A,backupCallbackUri:E}:void 0;if(!p&&(Q.fingerprintEnabled&&Q.fingerprintKey?n(Q.fingerprintKey):r(),Q.conditions?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i,predicate:o})=>{var n;if("ELSE"===e)return!0;const r=null===(n=ot[e])||void 0===n?void 0:n[i];return!!(null==r?void 0:r(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:G,code:w,token:y,abTestingKey:z},Q.conditions)):Q.condition?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{var i;const o=null===(i=ot[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const n=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==n?void 0:n.screenId,conditionInteractionId:null==n?void 0:n.interactionId}})(Q.condition,{loginId:G,code:w,token:y,abTestingKey:z})):B=Q.startScreenId,!H(B,W,M,$,K,_))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign({tenant:u,redirectAuth:Y,oidcIdpStateId:W,samlIdpStateId:M,samlIdpUsername:$,ssoAppId:K,oidcLoginHint:_,client:this.client},b&&{redirectUrl:b}),{lastAuth:nt(G),abTestingKey:z}),J,"",Q.version,X.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),w?{exchangeCode:w,idpInitiated:!0}:{}),y?{token:y}:{}),_?{externalId:_}:{}));return e(this,Kt,"f").call(this,t),void("completed"!==(null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(a("token")&&y||a("code")&&w||a("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,L,Q.version,X.componentsVersion,{token:y,exchangeCode:w,exchangeError:I});return e(this,Kt,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===O&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>a(t)))){if(!N||!q)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,i,o)=>{const n=document.createElement("form");n.method="POST",n.action=t,n.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(n),o(n)})(N,q,F||"",V)}if(f===x&&(a("redirectTo")||a("deferredRedirect")))return m?"android"===T&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===j||f===U){if(!k||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(d=e(this,Nt,"f"))||void 0===d||d.abort(),i(this,Nt,null,"f");try{t=f===j?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),o=t.name}const n=yield this.sdk.flow.next(p,h,L,Q.version,X.componentsVersion,{transactionId:k,response:t,failure:o});e(this,Kt,"f").call(this,n)}if(e(this,qt,"f").call(this,p,h,f,Q.version,X.componentsVersion),!g&&!B)return void this.loggerWrapper.warn("No screen was found to show");const Z=B||g,tt=yield this.getHtmlFilenameWithLocale(R,Z),et={direction:D(+h,+s.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.form),null==v?void 0:v.form),lastAuth:{loginId:G,name:this.sdk.getLastUserDisplayName()||G}}),htmlUrl:P(t,`${Z}.html`),htmlLocaleUrl:tt&&P(t,tt),samlIdpUsername:$,oidcLoginHint:_},it=nt(G);H(B,W,M,$,K,_)?et.next=(t,e,i,o)=>this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:Y,oidcIdpStateId:W,samlIdpStateId:M,samlIdpUsername:$,ssoAppId:K,oidcLoginHint:_,lastAuth:it,preview:this.preview,abTestingKey:z,client:this.client},b&&{redirectUrl:b}),J,t,e,i,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),w&&{exchangeCode:w,idpInitiated:!0}),y&&{token:y})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(et.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(et)}))}loadDescopeUiComponents(e){return t(this,void 0,void 0,(function*(){const i=yield ee.descopeUI;if(!i)return;const o=(t=>[...Array.from(t.querySelectorAll("*")).reduce(((t,e)=>e.tagName.startsWith("DESCOPE-")?t.add(e.tagName.toLocaleLowerCase()):t),new Set)])(e);yield Promise.all(o.map((e=>t(this,void 0,void 0,(function*(){if(!!!customElements.get(e))if(i[e])try{return yield i[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(i).join(", ")}"`)})))))}))}onStepChange(i,o){var n,r;return t(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c}=i,u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u.content);this.sdk.webauthn.helpers.isSupported()?yield e(this,Pt,"m",Vt).call(this,h,d):h.querySelectorAll(`descope-button[${S}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(n=c.form)||void 0===n?void 0:n.loginId)||(null===(r=c.form)||void 0===r?void 0:r.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),et(h,c,c.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(h,f);const g=()=>t(this,void 0,void 0,(function*(){var t;yield p,((t,e)=>{var i,o;const n=null===(i=customElements.get("descope-totp-image"))||void 0===i?void 0:i.cssVarList.url;e&&n&&(null===(o=null==t?void 0:t.style)||void 0===o||o.setProperty(n,`url(data:image/jpg;base64,${e})`))})(this.shadowRoot.querySelector("div"),null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),this.rootElement.replaceChildren(h),setTimeout((()=>((t,e)=>{Z(t,null==e?void 0:e.inputs),Z(t,null==e?void 0:e.form)})(this.rootElement,c)));const i=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,i),e(this,Pt,"m",Yt).call(this,d),i&&e(this,Pt,"m",te).call(this,"ready",{}),e(this,Pt,"m",te).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${S}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(T,t.version,i.componentsVersion,{});e(this,Kt,"f").call(this,o)}}));l?e(this,Pt,"m",Zt).call(this,g,l):g()}))}}Dt=new WeakMap,Nt=new WeakMap,qt=new WeakMap,Ft=new WeakMap,Kt=new WeakMap,_t=new WeakMap,Pt=new WeakSet,Ht=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const i=`user-${e}`;t.setAttribute("name",i),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:i)}))}},Vt=function(o,n){var r;return t(this,void 0,void 0,(function*(){null===(r=e(this,Nt,"f"))||void 0===r||r.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield it())){const{options:o,transactionId:r}=(yield e(this,_t,"f").call(this))||{};if(o&&r){e(this,Pt,"m",Ht).call(this,s),i(this,Nt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Nt,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield n(s.id,a.version,l.componentsVersion,{transactionId:r,response:i});e(this,Kt,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},Bt=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((t=>{var e,i;return null===(e=t.reportValidity)||void 0===e||e.call(t),null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)}))},Jt=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${b}])`));return(yield Promise.all(e.map((e=>t(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},zt=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Gt=function(t={}){var e,i;const o=B(t,["externalId","email","phone"]),n=B(t,["newPassword","password"]);if(o&&n)try{const t=new globalThis.PasswordCredential({id:o,password:n});null===(i=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===i||i.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},Qt=function(i,o){return t(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||e(this,Pt,"m",Bt).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,Pt,"m",zt).call(this,i);const r=yield e(this,Pt,"m",Jt).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(n,d.version,c.componentsVersion,l);e(this,Kt,"f").call(this,u),e(this,Pt,"m",Gt).call(this,r)}var t}))},Xt=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,Pt,"m",Qt).call(this,i,t)}))}))},Yt=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,Pt,"m",Qt).call(this,i,t)}})),e(this,Pt,"m",Xt).call(this,t)},Zt=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===W.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(i)})),this.rootElement.classList.add("fade-out")},te=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",ie);export{ie as D,Y as S};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{D as default}from"./index-
|
|
1
|
+
export{D as default}from"./index-7bbe2eec.js";import"tslib";import"@descope/web-js-sdk";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,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 t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(e){this.message=e}"function"==typeof SuppressedError&&SuppressedError,r.prototype=new Error,r.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=t.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(e){this.message=e}function l(e,t){if("string"!=typeof e)throw new a("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(s(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return s(t)}}(e.split(".")[n]))}catch(e){throw new a("Invalid token specified: "+e.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u="__lodash_hash_undefined__",h=1/0,p="[object Function]",f="[object GeneratorFunction]",g="[object Symbol]",v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,m=/^\w*$/,b=/^\./,w=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,I=/^\[object .+?Constructor\]$/,k="object"==typeof c&&c&&c.Object===Object&&c,O="object"==typeof self&&self&&self.Object===Object&&self,j=k||O||Function("return this")();var C,x=Array.prototype,S=Function.prototype,A=Object.prototype,E=j["__core-js_shared__"],U=(C=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+C:"",_=S.toString,R=A.hasOwnProperty,T=A.toString,P=RegExp("^"+_.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),L=j.Symbol,$=x.splice,M=B(j,"Map"),W=B(Object,"create"),q=L?L.prototype:void 0,D=q?q.toString:void 0;function N(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function F(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function H(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function K(e,t){for(var n,o,i=e.length;i--;)if((n=e[i][0])===(o=t)||n!=n&&o!=o)return i;return-1}function J(e,t){var n;t=function(e,t){if(Y(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ee(e))return!0;return m.test(e)||!v.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Y(n=t)?n:Z(n);for(var o=0,i=t.length;null!=e&&o<i;)e=e[G(t[o++])];return o&&o==i?e:void 0}function V(e){if(!Q(e)||(t=e,U&&U in t))return!1;var t,n=function(e){var t=Q(e)?T.call(e):"";return t==p||t==f}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?P:I;return n.test(function(e){if(null!=e){try{return _.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function z(e,t){var n,o,i=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function B(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return V(n)?n:void 0}N.prototype.clear=function(){this.__data__=W?W(null):{}},N.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},N.prototype.get=function(e){var t=this.__data__;if(W){var n=t[e];return n===u?void 0:n}return R.call(t,e)?t[e]:void 0},N.prototype.has=function(e){var t=this.__data__;return W?void 0!==t[e]:R.call(t,e)},N.prototype.set=function(e,t){return this.__data__[e]=W&&void 0===t?u:t,this},F.prototype.clear=function(){this.__data__=[]},F.prototype.delete=function(e){var t=this.__data__,n=K(t,e);return!(n<0)&&(n==t.length-1?t.pop():$.call(t,n,1),!0)},F.prototype.get=function(e){var t=this.__data__,n=K(t,e);return n<0?void 0:t[n][1]},F.prototype.has=function(e){return K(this.__data__,e)>-1},F.prototype.set=function(e,t){var n=this.__data__,o=K(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},H.prototype.clear=function(){this.__data__={hash:new N,map:new(M||F),string:new N}},H.prototype.delete=function(e){return z(this,e).delete(e)},H.prototype.get=function(e){return z(this,e).get(e)},H.prototype.has=function(e){return z(this,e).has(e)},H.prototype.set=function(e,t){return z(this,e).set(e,t),this};var Z=X((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ee(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-h?"-0":t}(t);var n=[];return b.test(e)&&n.push(""),e.replace(w,(function(e,t,o,i){n.push(o?i.replace(y,"$1"):t||e)})),n}));function G(e){if("string"==typeof e||ee(e))return e;var t=e+"";return"0"==t&&1/e==-h?"-0":t}function X(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var o=arguments,i=t?t.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=e.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new(X.Cache||H),n}X.Cache=H;var Y=Array.isArray;function Q(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ee(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&T.call(e)==g}var te=d((function(e,t,n){var o=null==e?void 0:J(e,t);return void 0===o?n:o})),ne="/v1/auth/accesskey/exchange",oe="/v1/auth/otp/verify",ie="/v1/auth/otp/signin",re="/v1/auth/otp/signup",se={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},ae="/v1/auth/otp/signup-in",le="/v1/auth/magiclink/verify",ce="/v1/auth/magiclink/signin",de="/v1/auth/magiclink/signup",ue={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},he="/v1/auth/magiclink/signup-in",pe="/v1/auth/enchantedlink/verify",fe="/v1/auth/enchantedlink/signin",ge="/v1/auth/enchantedlink/signup",ve="/v1/auth/enchantedlink/pending-session",me={email:"/v1/auth/enchantedlink/update/email"},be="/v1/auth/enchantedlink/signup-in",we="/v1/auth/oauth/authorize",ye="/v1/auth/oauth/exchange",Ie="/v1/auth/saml/authorize",ke="/v1/auth/saml/exchange",Oe="/v1/auth/totp/verify",je="/v1/auth/totp/signup",Ce="/v1/auth/totp/update",xe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Se={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Ae={start:"/v1/auth/webauthn/signup-in/start"},Ee={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Ue="/v1/auth/password/signup",_e="/v1/auth/password/signin",Re="/v1/auth/password/reset",Te="/v1/auth/password/update",Pe="/v1/auth/password/replace",Le="/v1/auth/password/policy",$e="/v1/auth/refresh",Me="/v1/auth/tenant/select",We="/v1/auth/logout",qe="/v1/auth/logoutall",De="/v1/auth/me",Ne="/v1/auth/me/history",Fe="/v1/flow/start",He="/v1/flow/next";const Ke="<region>",Je=`https://api.${Ke}descope.com`,Ve=6e5,ze=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var Be;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(Be||(Be={}));const Ze=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),Ge=e=>void 0===e?void 0:JSON.stringify(e),Xe=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ye=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>ze().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return ze().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),l=async o=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f={headers:Ze(Xe(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.9.1"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Ge(c)};null!==r&&(f.credentials=r||"include");const g=await a((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Ke,i?i+".":"");const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:l,baseUrl:e,queryParams:u,projectId:t}),f);return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:Be.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:Be.post,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:Be.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:Be.delete,token:o}),hooks:i}};var Qe=429;function et(e,t,n){var o;let i=tt(e);t&&(i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]);const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function tt(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return l(e)}function nt(e){const{exp:t}=tt(e);return(new Date).getTime()/1e3>t}function ot(e){let t=tt(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function it(e,t){return et(e,t,"permissions")}function rt(e,t){return et(e,t,"roles")}const st=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function at(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=t?t(r):r:(i.error=r,o.status===Qe&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const lt=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ct=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),dt=e=>t=>e.test(t),ut=dt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ht=dt(/^\+[1-9]{1}[0-9]{3,14}$/),pt=lt(ut,'"{val}" is not a valid email'),ft=lt(ht,'"{val}" is not a valid phone number'),gt=lt((1,e=>e.length>=1),"Minimum length is 1");const vt=lt((e=>"string"==typeof e),"Input is not a string"),mt=lt((e=>void 0===e),"Input is defined"),bt=(wt=[vt(),mt()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=wt.filter((e=>e(t)));return!(n.length<wt.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var wt;const yt=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ct(...e).validate(n[t]))),t(...n)),It=e=>[vt(`"${e}" must be a string`),gt(`"${e}" must not be empty`)],kt=e=>[vt(`"${e}" must be a string`),pt()],Ot=e=>[vt(`"${e}" must be a string`),ft()],jt=yt(It("accessKey")),Ct=e=>({exchange:jt((t=>at(e.post(ne,{},{token:t}))))});var xt,St;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(xt||(xt={})),function(e){e.email="email"}(St||(St={}));const At=Object.assign(Object.assign({},xt),St);var Et;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Et||(Et={}));const Ut=It("loginId"),_t=yt(It("token")),Rt=yt(Ut),Tt=yt(It("pendingRef")),Pt=yt(Ut,kt("email")),Lt=e=>({verify:_t((t=>at(e.post(pe,{token:t})))),signIn:Rt(((t,n,o,i)=>at(e.post(st(fe,At.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:Rt(((t,n,o)=>at(e.post(st(be,At.email),{loginId:t,URI:n,loginOptions:o})))),signUp:Rt(((t,n,o,i)=>at(e.post(st(ge,At.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:Tt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Ve,Ve)}))(n);let s;const a=setInterval((async()=>{const n=await e.post(ve,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(at(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Pt(((t,n,o,i,r)=>at(e.post(me.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),$t=yt(It("flowId")),Mt=yt(It("executionId"),It("stepId"),It("interactionId")),Wt=e=>({start:$t(((t,n,o,i,r,s,a)=>at(e.post(Fe,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:Mt(((t,n,o,i,r,s)=>at(e.post(He,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),qt=It("loginId"),Dt=yt(It("token")),Nt=yt(qt),Ft=yt(qt,Ot("phone")),Ht=yt(qt,kt("email")),Kt=e=>({verify:Dt((t=>at(e.post(le,{token:t})))),signIn:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Nt(((t,o,i,r)=>at(e.post(st(ce,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Nt(((t,o,i,r)=>at(e.post(st(de,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Nt(((t,o,i)=>at(e.post(st(he,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:Ht(((t,n,o,i,r)=>at(e.post(ue.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(xt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ft(((t,o,i,r,s)=>at(e.post(st(ue.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Jt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Jt||(Jt={}));const Vt=yt(It("code")),zt=e=>({start:Object.assign(((t,n,o,i)=>at(e.post(we,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(Jt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>at(e.post(we,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:Vt((t=>at(e.post(ye,{code:t}))))}),Bt=It("loginId"),Zt=yt(Bt,It("code")),Gt=yt(Bt),Xt=yt(Bt,Ot("phone")),Yt=yt(Bt,kt("email")),Qt=e=>({verify:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Zt(((t,o)=>at(e.post(st(oe,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,i)=>at(e.post(st(ie,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,i)=>at(e.post(st(re,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(At).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o)=>at(e.post(st(ae,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Yt(((t,n,o,i)=>at(e.post(se.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(xt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xt(((t,o,i,r)=>at(e.post(st(se.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),en=yt(It("tenant")),tn=yt(It("code")),nn=e=>({start:en(((t,n,o,i)=>at(e.post(Ie,o||{},{queryParams:{tenant:t,redirectURL:n},token:i})))),exchange:tn((t=>at(e.post(ke,{code:t}))))}),on=It("loginId"),rn=yt(on,It("code")),sn=yt(on),an=yt(on),ln=e=>({signUp:sn(((t,n)=>at(e.post(je,{loginId:t,user:n})))),verify:rn(((t,n,o,i)=>at(e.post(Oe,{loginId:t,code:n,loginOptions:o},{token:i})))),update:an(((t,n)=>at(e.post(Ce,{loginId:t},{token:n}))))}),cn=It("loginId"),dn=It("newPassword"),un=yt(cn,It("password")),hn=yt(cn),pn=yt(cn,dn),fn=yt(cn,It("oldPassword"),dn),gn=e=>({signUp:un(((t,n,o)=>at(e.post(Ue,{loginId:t,password:n,user:o})))),signIn:un(((t,n)=>at(e.post(_e,{loginId:t,password:n})))),sendReset:hn(((t,n,o)=>at(e.post(Re,{loginId:t,redirectUrl:n,templateOptions:o})))),update:pn(((t,n,o)=>at(e.post(Te,{loginId:t,newPassword:n},{token:o})))),replace:fn(((t,n,o)=>at(e.post(Pe,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>at(e.get(Le))}),vn=[vt('"loginId" must be a string')],mn=It("loginId"),bn=It("origin"),wn=yt(mn,bn,It("name")),yn=yt(mn,bn),In=yt(vn,bn),kn=yt(mn,bn,It("token")),On=yt(It("transactionId"),It("response")),jn=e=>({signUp:{start:wn(((t,n,o)=>at(e.post(xe.start,{user:{loginId:t,name:o},origin:n})))),finish:On(((t,n)=>at(e.post(xe.finish,{transactionId:t,response:n}))))},signIn:{start:In(((t,n,o,i)=>at(e.post(Se.start,{loginId:t,origin:n,loginOptions:o},{token:i})))),finish:On(((t,n)=>at(e.post(Se.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:yn(((t,n)=>at(e.post(Ae.start,{loginId:t,origin:n}))))},update:{start:kn(((t,n,o)=>at(e.post(Ee.start,{loginId:t,origin:n},{token:o})))),finish:On(((t,n)=>at(e.post(Ee.finish,{transactionId:t,response:n}))))}}),Cn=yt(It("token")),xn=yt([bt('"token" must be string or undefined')]);var Sn,An=yt([("projectId",Sn=It("projectId"),lt(((e,t)=>n=>ct(...t).validate(te(n,e)))("projectId",Sn))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=Ye({baseUrl:n||Je,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ct(a),otp:Qt(a),magicLink:Kt(a),enchantedLink:Lt(a),oauth:zt(a),saml:nn(a),totp:ln(a),webauthn:jn(a),password:gn(a),flow:Wt(a),refresh:xn((e=>at(a.post($e,{},{token:e})))),selectTenant:yt([vt("tenantId")],[bt('"token" must be string or undefined')])(((e,t)=>at(a.post(Me,{tenant:e},{token:t})))),logout:xn((e=>at(a.post(We,{},{token:e})))),logoutAll:xn((e=>at(a.post(qe,{},{token:e})))),me:xn((e=>at(a.get(De,{token:e})))),history:xn((e=>at(a.get(Ne,{token:e})))),isJwtExpired:Cn(nt),getTenants:Cn(ot),getJwtPermissions:Cn(it),getJwtRoles:Cn(rt),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const En=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e);var Un=Object.assign(An,{DeliveryMethods:At});var _n="Blocked by CSP",Rn="9319";function Tn(e,t){var n=[];return function(e,t){var n,o,i=(o=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return o[0]},postpone:function(){var e=o.shift();void 0!==e&&o.push(e)},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(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===_n||t===Rn}(e)?i.postpone():i.exclude();var t,o=i.current();if(void 0===o)throw e;return(t=r(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(e,(function(e){var o=new Date,i=function(t){return n.push({url:e,startedAt:o,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return i()}),i),r})).then((function(e){return[e,{attempts:n}]}))}var Pn="Failed to load the JS script of the agent";function Ln(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]: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");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.8.5"):e}))}(String(e),t)}))}(l,s);return Tn(e,$n).catch(Wn)})).then((function(t){var n=t[0],o=t[1];return n.load(e(e({},a),{ldi:o}))}))}function $n(e){return function(e,t,n,o){var i,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return l(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(l(),i)return function(){throw new Error(_n)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(Pn))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)})).then(Mn)}function Mn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Rn);return n}function Wn(e){throw e instanceof Error&&e.message===Rn?new Error(Pn):e}
|
|
2
|
-
/*! js-cookie v3.0.5 | MIT */function qn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var Dn=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=qn({},n,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 r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",qn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,qn({},this.attributes,t))},withConverter:function(t){return e(qn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const Nn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Fn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Hn=async e=>{const t=await Fn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Kn="undefined"!=typeof localStorage,Jn=(e,t)=>Kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Vn=e=>Kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),zn=e=>Kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Bn=(...e)=>{console.debug(...e)},Zn="undefined"!=typeof window,Gn=Math.pow(2,31)-1,Xn=Zn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Yn="fp",Qn=(e=!1)=>{const t=localStorage.getItem(Yn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},eo=async e=>{try{if(Qn())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Ln({apiKey:e,endpoint:Xn}),o=await n,{requestId:i}=await o.get({linkedId:t}),r=((e,t)=>({vsid:e,vrid:t}))(t,i);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Yn,JSON.stringify(t))})(r)}catch(e){global.FB_DEBUG&&console.error(e)}},to=e=>{const t=Qn(!0);return t&&e.body&&(e.body.fpData=t),e},no="dls_last_user_login_id",oo="dls_last_user_display_name",io=()=>Vn(no),ro=()=>Vn(oo),so=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=io(),r=ro();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},ao=e=>async(...t)=>{const n=await e(...t);return zn(no),zn(oo),n};function lo(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const co="DS",uo="DSR";function ho(e=""){return Vn(`${e}${uo}`)||""}function po(e=""){zn(`${e}${uo}`),zn(`${e}${co}`),Dn.remove(co)}async function fo(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=yo(n.publicKey.challenge),n.publicKey.user.id=yo(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=yo(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Io(n.rawId),type:n.type,response:{attestationObject:Io(n.response.attestationObject),clientDataJSON:Io(n.response.clientDataJSON)}});var n}async function go(e){const t=bo(e);return wo(await navigator.credentials.get(t))}async function vo(e,t){const n=bo(e);return n.signal=t.signal,n.mediation="conditional",wo(await navigator.credentials.get(n))}async function mo(e=!1){if(!Zn)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function bo(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=yo(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=yo(e.id)})),n}function wo(e){return JSON.stringify({id:e.id,rawId:Io(e.rawId),type:e.type,response:{authenticatorData:Io(e.response.authenticatorData),clientDataJSON:Io(e.response.clientDataJSON),signature:Io(e.response.signature),userHandle:e.response.userHandle?Io(e.response.userHandle):void 0}})}function yo(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Io(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ko,Oo=(ko=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const i=await fo(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await go(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await fo(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await go(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const i=await fo(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:fo,get:go,isSupported:mo,conditional:vo}}),(...e)=>{const t=ko(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t}),jo=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await mo(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const Co=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Zn?(o&&i&&eo(o).catch((()=>null)),e(Nn(r,{beforeRequest:to}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(r))}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,l;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Bn("Expiration time passed, refreshing session"),c.refresh(l))}));const c=e(Nn(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await Fn(t);if(401===(null==t?void 0:t.status))Bn("Received 401, canceling all timers"),r();else if(o){a=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(o),l=n;let e=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;e>Gn&&(Bn(`Timeout is too large (${e}ms), setting it to ${Gn}ms`),e=Gn),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Bn(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Bn("Refreshing session due to timer"),c.refresh(n)}),e)}var i}}));return En(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Bn("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.9.5"},t.baseHeaders)}))),(e=>t=>{const n=lo(),o=lo(),i=e(Nn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await Hn(t);e&&o.pub(e);const{sessionJwt:i}=await Fn(t);i&&n.pub(i)}}})),r=En(i,["logout","logoutAll"],(e=>async(...t)=>{const i=await e(...t);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>t=>{const n=e(Nn(t,{afterRequest:async(e,t)=>{var n;const o=await Hn(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{Jn(no,e)})(i),(e=>{Jn(oo,e)})(r))}}));let o=En(n,["flow.start"],so);return o=En(o,["logout","logoutAll"],ao),Object.assign(o,{getLastUserLoginId:io,getLastUserDisplayName:ro})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Zn)return o&&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"),e(s);const a=e(Nn(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||ho(l)})),afterRequest:async(e,n)=>{401===(null==n?void 0:n.status)?po(r):((e={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&Jn(`${o}${uo}`,i),r&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const r=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);Dn.set(e,t,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(co,r,s):Jn(`${o}${co}`,r))})(await Fn(n),i,r)}}));var l;const c=En(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return po(e),o})(r));return Object.assign(c,{getRefreshToken:()=>ho(r),getSessionToken:()=>function(e=""){return Dn.get(co)||Vn(`${e}${co}`)||""}(r)})}))(((...e)=>{const t=Un(...e);return Object.assign(Object.assign({},t),{flow:jo(t),webauthn:Oo(t)})})),xo="undefined"!=typeof localStorage,So=xo&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Ao="config.json",Eo="base.ui.components.url",Uo=xo&&localStorage.getItem(Eo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",_o=xo&&localStorage.getItem(Eo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ro="descope-login-flow",To="code",Po="ra-challenge",Lo="ra-callback",$o="ra-backup-callback",Mo="ra-initiator",Wo="data-exclude-field",qo="dls_last_auth",Do="state_id",No="saml_idp_state_id",Fo="saml_idp_username",Ho="sso_app_id",Ko="oidc_login_hint",Jo="data-type",Vo="redirect",zo="poll",Bo="webauthnCreate",Zo="webauthnGet",Go="loadForm",Xo="submit",Yo="polling";var Qo;function ei(e){return new URLSearchParams(window.location.search).get(e)}function ti(e){if(window.history.replaceState&&ei(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function ni(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(e){e.backward="backward",e.forward="forward"}(Qo||(Qo={}));function oi(e,t,n="v2-beta"){const o=new URL(So);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}function ii(e,t){if(!Number.isNaN(e)&&!Number.isNaN(t))return e>t?Qo.forward:e<t?Qo.backward:void 0}const ri=()=>{const[e="",t=""]=(ei(Ro)||"").split("_");return{executionId:e,stepId:t}};function si(){ti(Ro)}const ai=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),li=()=>{const{executionId:e,stepId:t}=ri();(e||t)&&si();const n=ei("t")||void 0;n&&ti("t");const o=ei(To)||void 0;o&&ti(To);const i=ei("err")||void 0;i&&ti("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:ei(Po),redirectAuthCallbackUrl:ei(Lo),redirectAuthBackupCallbackUri:ei($o),redirectAuthInitiator:ei(Mo)};(r||s||a||l)&&(ti(Po),ti(Lo),ti($o),ti(Mo));const c=ei(Do);c&&ti(Do);const d=ei(No);d&&ti(No);const u=ei(Fo);d&&ti(Fo);const h=ei(Ho);h&&ti(Ho);const p=ei(Ko);return p&&ti(Ko),{executionId:e,stepId:t,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:p}},ci=e=>{let t,n;return(...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}};const di=(e,t,n,o,i,r)=>e&&!t&&(e&&!n&&!o)&&(e&&!i)&&(e&&!r),ui=e=>null==e?void 0:e.submit(),hi=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null};var pi,fi,gi,vi;function mi(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!mi(r,s))return!1}else if(r!==s)return!1}return!0}class bi{constructor(e={},{updateOnlyOnChange:t=!0}={}){pi.set(this,void 0),fi.set(this,{}),gi.set(this,0),vi.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,pi,"f")):e,n=Object.assign(Object.assign({},o(this,pi,"f")),t);if(!o(this,vi,"f")||!mi(o(this,pi,"f"),n)){const e=o(this,pi,"f");i(this,pi,n,"f"),Object.freeze(o(this,pi,"f")),setTimeout((()=>{Object.values(o(this,fi,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,pi,e,"f"),i(this,vi,t,"f")}get current(){return Object.assign({},o(this,pi,"f"))}subscribe(e){return i(this,gi,o(this,gi,"f")+1,"f"),o(this,fi,"f")[o(this,gi,"f")]=e,o(this,gi,"f").toString()}unsubscribe(e){const t=!!o(this,fi,"f")[e];return t&&delete o(this,fi,"f")[e],t}unsubscribeAll(){return i(this,fi,{},"f"),!0}}pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,vi=new WeakMap;const wi=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Wo}])`)).forEach((e=>{e.value=n}))}))},yi=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),Ii=(e,t,n,o,i)=>{var r;let s=null==t?void 0:t.errorText;try{s=(null==o?void 0:o({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){i.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${Jo}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",s),((e,t)=>{e.querySelectorAll(`[${Jo}="totp-link"]`).forEach((e=>{e.setAttribute("href",t)}))})(e,null===(r=null==t?void 0:t.totp)||void 0===r?void 0:r.provisionUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link").forEach((e=>{e.textContent=yi(e.textContent,t)}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const i=t[o];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=yi(e.value,t)}))}))})(e,t)},ki=ci((()=>n(void 0,void 0,void 0,(function*(){var e,t,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),s=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((e,t)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?e(i):t(new Error(`Promise timed out after ${n} ms`))}),n);o.then((t=>{r||(clearTimeout(s),e(t))})).catch((e=>{r||(clearTimeout(s),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),Oi=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},ji={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function Ci(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(qo)))}catch(e){}return t}const xi="dls_ab_testing_id",Si=document.createElement("template");var Ai,Ei,Ui,_i,Ri,Ti,Pi,Li,$i,Mi,Wi,qi,Di,Ni,Fi,Hi,Ki,Ji,Vi,zi,Bi,Zi,Gi,Xi,Yi,Qi,er,tr,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br,wr,yr,Ir,kr,Or,jr,Cr,xr,Sr,Ar,Er,Ur,_r;Si.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[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<div id="wc-root"></div>\n\t';class Rr extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(e){super(),Ai.add(this),this.logger=console,Ei.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,Ai,"m",er).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)}},Ui.set(this,new bi({deferredRedirect:!1})),_i.set(this,new bi),Ri.set(this,{}),this.getComponentsContext=()=>o(this,Ri,"f"),this.nextRequestStatus=new bi({isLoading:!1}),Ti.set(this,void 0),Pi.set(this,{popstate:o(this,Ai,"m",Di).bind(this),visibilitychange:o(this,Ai,"m",Ni).bind(this),componentsContext:o(this,Ai,"m",Gi).bind(this)}),Li.set(this,void 0),Vi.set(this,ci((()=>n(this,void 0,void 0,(function*(){const e=oi(this.projectId,Ao);try{const{body:t,headers:n}=yield ni(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),i(this,Li,e,"f"),o(this,Ai,"m",$i).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const e=JSON.parse(this.getAttribute("form"))||{};return Object.entries(e).reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[`form.${t}`]:n})),e)}catch(e){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield o(this,Vi,"f").call(this);return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Vi,"f").call(this);return e}))}getFlowConfig(){var e,t;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,_i,"f").subscribe(o(this,Ai,"m",Qi).bind(this)),o(this,_i,"f").update({isDebug:this.debug}),o(this,Ai,"m",Mi).call(this))return void o(this,Ai,"m",Wi).call(this);if(o(this,Ai,"m",qi).call(this),yield o(this,Ai,"m",Ki).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield o(this,Vi,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield o(this,Ai,"m",or).call(this),yield o(this,Ai,"m",Bi).call(this),o(this,Ai,"m",zi).call(this),o(this,Ai,"m",tr).call(this);const{executionId:e,stepId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}=li();window.addEventListener("popstate",o(this,Pi,"f").popstate),window.addEventListener("components-context",o(this,Pi,"f").componentsContext),window.addEventListener("visibilitychange",o(this,Pi,"f").visibilitychange),o(this,Ui,"f").subscribe(o(this,Ai,"m",Hi).bind(this)),o(this,Ui,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}),i(this,Ei,!0,"f")}}))}disconnectedCallback(){o(this,Ui,"f").unsubscribeAll(),o(this,_i,"f").unsubscribeAll(),o(this,Ai,"m",Yi).call(this),window.removeEventListener("popstate",o(this,Pi,"f").popstate),window.removeEventListener("visibilitychange",o(this,Pi,"f").visibilitychange),window.removeEventListener("components-context",o(this,Pi,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,Ei,"f")&&t!==n&&Rr.observedAttributes.includes(e)){o(this,Ai,"m",qi).call(this);const i=null===t;o(this,Ui,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,si()),{[ai(e)]:n,stepId:r,executionId:s}})),o(this,_i,"f").update({isDebug:this.debug})}}}Ei=new WeakMap,Ui=new WeakMap,_i=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Li=new WeakMap,Vi=new WeakMap,Ai=new WeakSet,$i=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Si.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},Mi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Wi=function(){const e=this.shadowRoot.host,t=document.createElement("form");e.parentElement.appendChild(t),t.appendChild(e)},qi=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if(Rr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[ai(t)])throw Error(`${t} 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')},Di=function(){const{stepId:e,executionId:t}=ri();o(this,Ui,"f").update({stepId:e,executionId:t})},Ni=function(){document.hidden||setTimeout((()=>{o(this,Ui,"f").update({deferredRedirect:!1})}),300)},Fi=function(e,t){this.sdk=Co(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},Rr.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Hi=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,Ai,"m",Fi).call(this,t,n)}o(this,Li,"f").call(this,e)}))},Ki=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Vi,"f").call(this)).isMissingConfig&&(yield o(this,Ai,"m",Ji).call(this))}))},Ji=function(){return n(this,void 0,void 0,(function*(){const e=oi(this.projectId,Ao,"v2-alpha");try{return yield ni(e,"json"),!0}catch(e){return!1}}))},zi=function(){var e,t;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Vi,"f").call(this),i=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;i&&Object.values(i).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},Bi=function(){return n(this,void 0,void 0,(function*(){yield o(this,Ai,"m",Zi).call(this),yield o(this,Ai,"m",Xi).call(this)}))},Zi=function(){var e,t,o,i;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),r=oi(this.projectId,"theme.json");try{const{body:s}=yield ni(r,"json");n.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield Rr.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(o=null==s?void 0:s.light)||void 0===o?void 0:o.components,dark:null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components})}catch(e){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(n)}))},Gi=function(e){i(this,Ri,Object.assign(Object.assign({},e.detail),o(this,Ri,"f")),"f")},Xi=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield Rr.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},Yi=function(){var e;null===(e=o(this,Ti,"f"))||void 0===e||e.remove(),i(this,Ti,null,"f")},Qi=function({isDebug:e}){return n(this,void 0,void 0,(function*(){e?(i(this,Ti,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Ti,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return $r})),document.body.appendChild(o(this,Ti,"f"))):o(this,Ai,"m",Yi).call(this)}))},er=function(e,t){var n;e&&this.debug&&(null===(n=o(this,Ti,"f"))||void 0===n||n.updateData({title:e,description:t}))},tr=function(){this.rootElement.onkeydown=e=>{if("Enter"!==e.key)return;e.preventDefault();const t=this.rootElement.querySelectorAll("descope-button");if(1===t.length)return void t[0].click();const n=Array.from(t).filter((e=>"button"===e.getAttribute("data-type")));if(1===n.length)n[0].click();else if(0===n.length){const e=Array.from(t).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&e[0].click()}}},nr=function(){var e,t;return n(this,void 0,void 0,(function*(){const n=null===(t=null===(e=yield o(this,Vi,"f").call(this))||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))},or=function(){return n(this,void 0,void 0,(function*(){Rr.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):Rr.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},i=(e,t)=>e.replace("<version>",t),r=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,Ai,"m",nr).call(this),s=t(i(Uo,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=t(i(_o,n));r(o,(()=>{e(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},Rr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.0"}};class Tr extends Rr{static set sdkConfigOverrides(e){Rr.sdkConfigOverrides=e}constructor(){const e=new bi;super(e.update.bind(e)),ir.add(this),this.stepState=new bi({},{updateOnlyOnChange:!1}),rr.set(this,void 0),sr.set(this,null),ar.set(this,((e,t,r,s,a)=>{r===zo&&i(this,rr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(e,t,Yo,s,a,{});o(this,cr,"f").call(this,i);const{action:r}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,ar,"f").call(this,e,t,r,s,a)}))),2e3),"f")})),lr.set(this,(()=>{clearTimeout(o(this,rr,"f")),i(this,rr,null,"f")})),cr.set(this,(e=>{var t,n,i,r,s,a,l,c,d;if(!(null==e?void 0:e.ok)){o(this,ir,"m",Ir).call(this,"error",null==e?void 0:e.error);const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,l=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;return void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||l)}const u=null===(c=null===(l=null===(a=e.data)||void 0===a?void 0:a.screen)||void 0===l?void 0:l.state)||void 0===c?void 0:c.errorText;(null===(d=e.data)||void 0===d?void 0:d.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${u?`${u} - `:""}${e.data.error.message}`):u&&this.loggerWrapper.error(u);const{status:h,authInfo:p,lastAuth:f}=e.data;if("completed"===h)return function(e){(null==e?void 0:e.authMethod)&&xo&&localStorage.setItem(qo,JSON.stringify(e))}(f),void o(this,ir,"m",Ir).call(this,"success",p);const{executionId:g,stepId:v,stepName:m,action:b,screen:w,redirect:y,webauthn:I,error:k,samlIdpResponse:O}=e.data;b!==zo?(this.loggerWrapper.info(`Step "${m||`#${v}`}" is ${h}`,"",{screen:w,status:h,stepId:v,stepName:m,action:b,error:k}),this.flowState.update({stepId:v,executionId:g,action:b,redirectTo:null==y?void 0:y.url,screenId:null==w?void 0:w.id,screenState:null==w?void 0:w.state,webauthnTransactionId:null==I?void 0:I.transactionId,webauthnOptions:null==I?void 0:I.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState})):this.flowState.update({action:b})})),dr.set(this,ci((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.error("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.error("Webauthn start failed",e.message)}}))))),this.flowState=e}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var t,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=o(this,sr,"f"))||void 0===e||e.abort(),i(this,sr,null,"f")}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const i=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(i)&&(n=`${t}-${i}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield ni(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield ni(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:l,tenant:c,stepId:d,executionId:u,action:h,screenId:p,screenState:f,redirectTo:g,redirectUrl:v,token:m,code:b,exchangeError:w,webauthnTransactionId:y,webauthnOptions:I,redirectAuthCodeChallenge:k,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:C,oidcIdpStateId:x,locale:S,samlIdpStateId:A,samlIdpUsername:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:_,samlIdpResponseRelayState:R,ssoAppId:T,oidcLoginHint:P}=e;let L,$;const M=(()=>{const e=localStorage.getItem(xi);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(xi,e.toString()),e}return Number(e)})(),W=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),D=yield this.getProjectConfig(),N=O&&k?{callbackUrl:O,codeChallenge:k,backupCallbackUri:j}:void 0;if(!u&&(q.fingerprintEnabled&&q.fingerprintKey?eo(q.fingerprintKey):localStorage.removeItem(Yn),q.conditions?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=ji[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:b,token:m,abTestingKey:M},q.conditions)):q.condition?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{var n;const o=null===(n=ji[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(q.condition,{loginId:W,code:b,token:m,abTestingKey:M})):L=q.startScreenId,!di(L,x,A,E,T,P))){const e=yield this.sdk.flow.start(l,Object.assign(Object.assign({tenant:c,redirectAuth:N,oidcIdpStateId:x,samlIdpStateId:A,samlIdpUsername:E,ssoAppId:T,oidcLoginHint:P,client:this.client},v&&{redirectUrl:v}),{lastAuth:Ci(W),abTestingKey:M}),$,"",q.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),b?{exchangeCode:b,idpInitiated:!0}:{}),m?{token:m}:{}),P?{externalId:P}:{}));return o(this,cr,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0,token:void 0}))}if(u&&(r("token")&&m||r("code")&&b||r("exchangeError")&&w)){const e=yield this.sdk.flow.next(u,d,Xo,q.version,D.componentsVersion,{token:m,exchangeCode:b,exchangeError:w});return o(this,cr,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(h===Go&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>r(e)))){if(!U||!_)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(U,_,R||"",ui)}if(h===Vo&&(r("redirectTo")||r("deferredRedirect")))return g?"android"===C&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(h===Bo||h===Zo){if(!y||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=o(this,sr,"f"))||void 0===a||a.abort(),i(this,sr,null,"f");try{e=h===Bo?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(u,d,Xo,q.version,D.componentsVersion,{transactionId:y,response:e,failure:t});o(this,cr,"f").call(this,n)}if(o(this,ar,"f").call(this,u,d,h,q.version,D.componentsVersion),!p&&!L)return void this.loggerWrapper.warn("No screen was found to show");const F=L||p,H=yield this.getHtmlFilenameWithLocale(S,F),K={direction:ii(+d,+t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.form),null==f?void 0:f.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:oi(n,`${F}.html`),htmlLocaleUrl:H&&oi(n,H),samlIdpUsername:E,oidcLoginHint:P},J=Ci(W);di(L,x,A,E,T,P)?K.next=(e,t,n,o)=>this.sdk.flow.start(l,Object.assign({tenant:c,redirectAuth:N,oidcIdpStateId:x,samlIdpStateId:A,samlIdpUsername:E,ssoAppId:T,oidcLoginHint:P,lastAuth:J,preview:this.preview,abTestingKey:M,client:this.client},v&&{redirectUrl:v}),$,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),b&&{exchangeCode:b,idpInitiated:!0}),m&&{token:m})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(K.next=(...e)=>this.sdk.flow.next(u,d,...e)),this.stepState.update(K)}))}loadDescopeUiComponents(e){return n(this,void 0,void 0,(function*(){const t=yield Rr.descopeUI;if(!t)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(o.map((e=>n(this,void 0,void 0,(function*(){if(!!!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){var i,r;return n(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d}=e,u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,ir,"m",hr).call(this,h,c):h.querySelectorAll(`descope-button[${Jo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Ii(h,d,d.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,f);const g=()=>n(this,void 0,void 0,(function*(){var e;yield p,((e,t)=>{var n,o;const i=null===(n=customElements.get("descope-totp-image"))||void 0===n?void 0:n.cssVarList.url;t&&i&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(i,`url(data:image/jpg;base64,${t})`))})(this.shadowRoot.querySelector("div"),null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image),this.rootElement.replaceChildren(h),setTimeout((()=>((e,t)=>{wi(e,null==t?void 0:t.inputs),wi(e,null==t?void 0:t.form)})(this.rootElement,d)));const n=!t.htmlUrl;((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,n),o(this,ir,"m",wr).call(this,c),n&&o(this,ir,"m",Ir).call(this,"ready",{}),o(this,ir,"m",Ir).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Jo}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield c(Yo,e.version,t.componentsVersion,{});o(this,cr,"f").call(this,n)}}));l?o(this,ir,"m",yr).call(this,g,l):g()}))}}rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ir=new WeakSet,ur=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},hr=function(e,t){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,sr,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ki())){const{options:e,transactionId:r}=(yield o(this,dr,"f").call(this))||{};if(e&&r){o(this,ir,"m",ur).call(this,s),i(this,sr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,o(this,sr,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,l.componentsVersion,{transactionId:r,response:e});o(this,cr,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},pr=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))},fr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Wo}])`));return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},gr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},vr=function(e={}){var t,n;const o=hi(e,["externalId","email","phone"]),i=hi(e,["newPassword","password"]);if(o&&i)try{const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},mr=function(e,t){return n(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||o(this,ir,"m",pr).call(this)){const i=null==e?void 0:e.getAttribute("id");o(this,ir,"m",gr).call(this,e);const r=yield o(this,ir,"m",fr).call(this),s=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(i,c.version,d.componentsVersion,l);o(this,cr,"f").call(this,u),o(this,ir,"m",vr).call(this,r)}var n}))},br=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&o(this,ir,"m",mr).call(this,t,e)}))}))},wr=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{o(this,ir,"m",mr).call(this,t,e)}})),o(this,ir,"m",br).call(this,e)},yr=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Qo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},Ir=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.define("descope-wc",Tr);const Pr=document.createElement("template");Pr.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 word-wrap: break-word;\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 Lr extends HTMLElement{constructor(){super(),kr.add(this),Or.set(this,new bi({messages:[]})),jr.set(this,void 0),Cr.set(this,void 0),xr.set(this,void 0),Sr.set(this,{resize:o(this,kr,"m",_r).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Pr.content.cloneNode(!0)),i(this,jr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Cr,o(this,jr,"f").querySelector(".content"),"f"),i(this,xr,o(this,jr,"f").querySelector(".header"),"f")}updateData(e){o(this,Or,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Oi(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,jr,"f"),o(this,xr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Sr,"f").resize),(e=o(this,jr,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},o(this,jr,"f").onresize=o(this,kr,"m",Ur).bind(this),o(this,Or,"f").subscribe(o(this,kr,"m",Ar).bind(this))}disconnectedCallback(){o(this,Or,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Sr,"f").resize)}}Or=new WeakMap,jr=new WeakMap,Cr=new WeakMap,xr=new WeakMap,Sr=new WeakMap,kr=new WeakSet,Ar=function(e){o(this,kr,"m",Er).call(this,e),o(this,kr,"m",Ur).call(this)},Er=function(e){o(this,Cr,"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("")},Ur=function(){o(this,Cr,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},_r=function(){const[e,t]=Oi(o(this,jr,"f"),Number.parseInt(o(this,jr,"f").style.left,10),Number.parseInt(o(this,jr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,jr,"f").style.top=`${t}px`,o(this,jr,"f").style.left=`${e}px`},customElements.define("descope-debugger",Lr);var $r=Object.freeze({__proto__:null,default:Lr})}();
|
|
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{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((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}"function"==typeof SuppressedError&&SuppressedError,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 l(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 c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u="__lodash_hash_undefined__",h=1/0,p="[object Function]",f="[object GeneratorFunction]",g="[object Symbol]",v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,m=/^\w*$/,b=/^\./,w=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,I=/^\[object .+?Constructor\]$/,k="object"==typeof c&&c&&c.Object===Object&&c,O="object"==typeof self&&self&&self.Object===Object&&self,j=k||O||Function("return this")();var C,x=Array.prototype,S=Function.prototype,A=Object.prototype,E=j["__core-js_shared__"],U=(C=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+C:"",_=S.toString,T=A.hasOwnProperty,R=A.toString,P=RegExp("^"+_.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),L=j.Symbol,$=x.splice,M=B(j,"Map"),W=B(Object,"create"),q=L?L.prototype:void 0,D=q?q.toString:void 0;function N(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 F(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 H(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 K(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 J(t,e){var n;e=function(t,e){if(Y(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||tt(t))return!0;return m.test(t)||!v.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Y(n=e)?n:G(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 V(t){if(!Q(t)||(e=t,U&&U in e))return!1;var e,n=function(t){var e=Q(t)?R.call(t):"";return e==p||e==f}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?P:I;return n.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function z(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 B(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return V(n)?n:void 0}N.prototype.clear=function(){this.__data__=W?W(null):{}},N.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},N.prototype.get=function(t){var e=this.__data__;if(W){var n=e[t];return n===u?void 0:n}return T.call(e,t)?e[t]:void 0},N.prototype.has=function(t){var e=this.__data__;return W?void 0!==e[t]:T.call(e,t)},N.prototype.set=function(t,e){return this.__data__[t]=W&&void 0===e?u:e,this},F.prototype.clear=function(){this.__data__=[]},F.prototype.delete=function(t){var e=this.__data__,n=K(e,t);return!(n<0)&&(n==e.length-1?e.pop():$.call(e,n,1),!0)},F.prototype.get=function(t){var e=this.__data__,n=K(e,t);return n<0?void 0:e[n][1]},F.prototype.has=function(t){return K(this.__data__,t)>-1},F.prototype.set=function(t,e){var n=this.__data__,o=K(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},H.prototype.clear=function(){this.__data__={hash:new N,map:new(M||F),string:new N}},H.prototype.delete=function(t){return z(this,t).delete(t)},H.prototype.get=function(t){return z(this,t).get(t)},H.prototype.has=function(t){return z(this,t).has(t)},H.prototype.set=function(t,e){return z(this,t).set(t,e),this};var G=X((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(tt(t))return D?D.call(t):"";var e=t+"";return"0"==e&&1/t==-h?"-0":e}(e);var n=[];return b.test(t)&&n.push(""),t.replace(w,(function(t,e,o,i){n.push(o?i.replace(y,"$1"):e||t)})),n}));function Z(t){if("string"==typeof t||tt(t))return t;var e=t+"";return"0"==e&&1/t==-h?"-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||H),n}X.Cache=H;var Y=Array.isArray;function Q(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function tt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&R.call(t)==g}var et=d((function(t,e,n){var o=null==t?void 0:J(t,e);return void 0===o?n:o})),nt="/v1/auth/accesskey/exchange",ot="/v1/auth/otp/verify",it="/v1/auth/otp/signin",rt="/v1/auth/otp/signup",st={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},at="/v1/auth/otp/signup-in",lt="/v1/auth/magiclink/verify",ct="/v1/auth/magiclink/signin",dt="/v1/auth/magiclink/signup",ut={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ht="/v1/auth/magiclink/signup-in",pt="/v1/auth/enchantedlink/verify",ft="/v1/auth/enchantedlink/signin",gt="/v1/auth/enchantedlink/signup",vt="/v1/auth/enchantedlink/pending-session",mt={email:"/v1/auth/enchantedlink/update/email"},bt="/v1/auth/enchantedlink/signup-in",wt="/v1/auth/oauth/authorize",yt="/v1/auth/oauth/exchange",It="v1/auth/oauth/native/start",kt="v1/auth/oauth/native/finish",Ot="/v1/auth/saml/authorize",jt="/v1/auth/saml/exchange",Ct="/v1/auth/totp/verify",xt="/v1/auth/totp/signup",St="/v1/auth/totp/update",At={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Et={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Ut={start:"/v1/auth/webauthn/signup-in/start"},_t={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Tt="/v1/auth/password/signup",Rt="/v1/auth/password/signin",Pt="/v1/auth/password/reset",Lt="/v1/auth/password/update",$t="/v1/auth/password/replace",Mt="/v1/auth/password/policy",Wt="/v1/auth/refresh",qt="/v1/auth/tenant/select",Dt="/v1/auth/logout",Nt="/v1/auth/logoutall",Ft="/v1/auth/me",Ht="/v1/auth/me/history",Kt="/v1/flow/start",Jt="/v1/flow/next";const Vt="<region>",zt=`https://api.${Vt}descope.com`,Bt=6e5,Gt=()=>{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 Zt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Zt||(Zt={}));const Xt=(...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}),{})),Yt=t=>void 0===t?void 0:JSON.stringify(t),Qt=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},te=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),t?async(...e)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");t.log((t=>Gt().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.text();return Gt().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o,s),l=async o=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f={headers:Xt(Qt(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.10.0"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Yt(c)};null!==r&&(f.credentials=r||"include");const g=await a((({path:t,baseUrl:e,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);e=e.replace(Vt,i?i+".":"");const r=new URL(t,e);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:l,baseUrl:t,queryParams:u,projectId:e}),f);return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==g?void 0:g.clone()),g};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Zt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Zt.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Zt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Zt.delete,token:o}),hooks:i}};var ee=429;function ne(t,e,n){var o;let i=oe(t);e&&(i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]);const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function oe(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return l(t)}function ie(t){const{exp:e}=oe(t);return(new Date).getTime()/1e3>e}function re(t){let e=oe(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function se(t,e){return ne(t,e,"permissions")}function ae(t,e){return ne(t,e,"roles")}const le=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function ce(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===ee&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const de=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),ue=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),he=t=>e=>t.test(e),pe=he(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),fe=he(/^\+[1-9]{1}[0-9]{3,14}$/),ge=de(pe,'"{val}" is not a valid email'),ve=de(fe,'"{val}" is not a valid phone number'),me=de((1,t=>t.length>=1),"Minimum length is 1");const be=de((t=>"string"==typeof t),"Input is not a string"),we=de((t=>void 0===t),"Input is defined"),ye=(Ie=[be(),we()],"Input is not a string or undefined",(t="Input is not a string or undefined")=>e=>{const n=Ie.filter((t=>t(e)));return!(n.length<Ie.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var Ie;const ke=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>ue(...t).validate(n[e]))),e(...n)),Oe=t=>[be(`"${t}" must be a string`),me(`"${t}" must not be empty`)],je=t=>[be(`"${t}" must be a string`),ge()],Ce=t=>[be(`"${t}" must be a string`),ve()],xe=ke(Oe("accessKey")),Se=t=>({exchange:xe((e=>ce(t.post(nt,{},{token:e}))))});var Ae,Ee;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Ae||(Ae={})),function(t){t.email="email"}(Ee||(Ee={}));const Ue=Object.assign(Object.assign({},Ae),Ee);var _e;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(_e||(_e={}));const Te=Oe("loginId"),Re=ke(Oe("token")),Pe=ke(Te),Le=ke(Oe("pendingRef")),$e=ke(Te,je("email")),Me=t=>({verify:Re((e=>ce(t.post(pt,{token:e})))),signIn:Pe(((e,n,o,i)=>ce(t.post(le(ft,Ue.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:Pe(((e,n,o)=>ce(t.post(le(bt,Ue.email),{loginId:e,URI:n,loginOptions:o})))),signUp:Pe(((e,n,o,i)=>ce(t.post(le(gt,Ue.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:Le(((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||Bt,Bt)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(vt,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(ce(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:$e(((e,n,o,i,r)=>ce(t.post(mt.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),We=ke(Oe("flowId")),qe=ke(Oe("executionId"),Oe("stepId"),Oe("interactionId")),De=t=>({start:We(((e,n,o,i,r,s,a)=>ce(t.post(Kt,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:qe(((e,n,o,i,r,s)=>ce(t.post(Jt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),Ne=Oe("loginId"),Fe=ke(Oe("token")),He=ke(Ne),Ke=ke(Ne,Ce("phone")),Je=ke(Ne,je("email")),Ve=t=>({verify:Fe((e=>ce(t.post(lt,{token:e})))),signIn:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:He(((e,o,i,r)=>ce(t.post(le(ct,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:He(((e,o,i,r)=>ce(t.post(le(dt,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:He(((e,o,i)=>ce(t.post(le(ht,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:Je(((e,n,o,i,r)=>ce(t.post(ut.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ae).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ke(((e,o,i,r,s)=>ce(t.post(le(ut.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ze;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ze||(ze={}));const Be=ke(Oe("code")),Ge=t=>({start:Object.assign(((e,n,o,i)=>ce(t.post(wt,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ze).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>ce(t.post(wt,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:Be((e=>ce(t.post(yt,{code:e})))),startNative:(e,n)=>ce(t.post(It,{provider:e,loginOptions:n})),finishNative:(e,n,o,i,r)=>ce(t.post(kt,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),Ze=Oe("loginId"),Xe=ke(Ze,Oe("code")),Ye=ke(Ze),Qe=ke(Ze,Ce("phone")),tn=ke(Ze,je("email")),en=t=>({verify:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Xe(((e,o)=>ce(t.post(le(ot,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ye(((e,o,i)=>ce(t.post(le(it,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ye(((e,o,i)=>ce(t.post(le(rt,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ye(((e,o)=>ce(t.post(le(at,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:tn(((e,n,o,i)=>ce(t.post(st.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Ae).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Qe(((e,o,i,r)=>ce(t.post(le(st.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),nn=ke(Oe("tenant")),on=ke(Oe("code")),rn=t=>({start:nn(((e,n,o,i)=>ce(t.post(Ot,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:on((e=>ce(t.post(jt,{code:e}))))}),sn=Oe("loginId"),an=ke(sn,Oe("code")),ln=ke(sn),cn=ke(sn),dn=t=>({signUp:ln(((e,n)=>ce(t.post(xt,{loginId:e,user:n})))),verify:an(((e,n,o,i)=>ce(t.post(Ct,{loginId:e,code:n,loginOptions:o},{token:i})))),update:cn(((e,n)=>ce(t.post(St,{loginId:e},{token:n}))))}),un=Oe("loginId"),hn=Oe("newPassword"),pn=ke(un,Oe("password")),fn=ke(un),gn=ke(un,hn),vn=ke(un,Oe("oldPassword"),hn),mn=t=>({signUp:pn(((e,n,o)=>ce(t.post(Tt,{loginId:e,password:n,user:o})))),signIn:pn(((e,n)=>ce(t.post(Rt,{loginId:e,password:n})))),sendReset:fn(((e,n,o)=>ce(t.post(Pt,{loginId:e,redirectUrl:n,templateOptions:o})))),update:gn(((e,n,o)=>ce(t.post(Lt,{loginId:e,newPassword:n},{token:o})))),replace:vn(((e,n,o)=>ce(t.post($t,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>ce(t.get(Mt))}),bn=[be('"loginId" must be a string')],wn=Oe("loginId"),yn=Oe("origin"),In=ke(wn,yn,Oe("name")),kn=ke(wn,yn),On=ke(bn,yn),jn=ke(wn,yn,Oe("token")),Cn=ke(Oe("transactionId"),Oe("response")),xn=t=>({signUp:{start:In(((e,n,o)=>ce(t.post(At.start,{user:{loginId:e,name:o},origin:n})))),finish:Cn(((e,n)=>ce(t.post(At.finish,{transactionId:e,response:n}))))},signIn:{start:On(((e,n,o,i)=>ce(t.post(Et.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:Cn(((e,n)=>ce(t.post(Et.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:kn(((e,n)=>ce(t.post(Ut.start,{loginId:e,origin:n}))))},update:{start:jn(((e,n,o)=>ce(t.post(_t.start,{loginId:e,origin:n},{token:o})))),finish:Cn(((e,n)=>ce(t.post(_t.finish,{transactionId:e,response:n}))))}}),Sn=ke(Oe("token")),An=ke([ye('"token" must be string or undefined')]);var En,Un=ke([("projectId",En=Oe("projectId"),de(((t,e)=>n=>ue(...e).validate(et(n,t)))("projectId",En))())])((t=>(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=te({baseUrl:n||zt,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Se(a),otp:en(a),magicLink:Ve(a),enchantedLink:Me(a),oauth:Ge(a),saml:rn(a),totp:dn(a),webauthn:xn(a),password:mn(a),flow:De(a),refresh:An((t=>ce(a.post(Wt,{},{token:t})))),selectTenant:ke([be("tenantId")],[ye('"token" must be string or undefined')])(((t,e)=>ce(a.post(qt,{tenant:t},{token:e})))),logout:An((t=>ce(a.post(Dt,{},{token:t})))),logoutAll:An((t=>ce(a.post(Nt,{},{token:t})))),me:An((t=>ce(a.get(Ft,{token:t})))),history:An((t=>ce(a.get(Ht,{token:t})))),isJwtExpired:Sn(ie),getTenants:Sn(re),getJwtPermissions:Sn(se),getJwtRoles:Sn(ae),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))));const _n=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t);var Tn=Object.assign(Un,{DeliveryMethods:Ue});var Rn="Blocked by CSP",Pn="9319";function Ln(t,e){var n=[];return function(t,e){var n,o,i=(o=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0),{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 e===Rn||e===Pn}(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(e){return n.push({url:t,startedAt:o,finishedAt:new Date,error:e})},r=e(t);return r.then((function(){return i()}),i),r})).then((function(t){return[t,{attempts:n}]}))}var $n="Failed to load the JS script of the agent";function Mn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=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");var t=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.5"):t}))}(String(t),e)}))}(l,s);return Ln(t,Wn).catch(Dn)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function Wn(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,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),i)return function(){throw new Error(Rn)}();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($n))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(qn)}function qn(){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(Pn);return n}function Dn(t){throw t instanceof Error&&t.message===Pn?new Error($n):t}
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */function Nn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var Fn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Nn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Nn({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Nn({},this.attributes,e))},withConverter:function(e){return t(Nn({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(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:"/"});const Hn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},Kn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},Jn=async t=>{const e=await Kn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Vn="undefined"!=typeof localStorage,zn=(t,e)=>Vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Bn=t=>Vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Gn=t=>Vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Zn=(...t)=>{console.debug(...t)},Xn="undefined"!=typeof window,Yn=Math.pow(2,31)-1,Qn=Xn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",to="fp",eo=(t=!1)=>{const e=localStorage.getItem(to);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},no=async t=>{try{if(eo())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Mn({apiKey:t,endpoint:Qn}),o=await n,{requestId:i}=await o.get({linkedId:e}),r=((t,e)=>({vsid:t,vrid:e}))(e,i);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(to,JSON.stringify(e))})(r)}catch(t){global.FB_DEBUG&&console.error(t)}},oo=t=>{const e=eo(!0);return e&&t.body&&(t.body.fpData=e),t},io="dls_last_user_login_id",ro="dls_last_user_display_name",so=()=>Bn(io),ao=()=>Bn(ro),lo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=so(),r=ao();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},co=t=>async(...e)=>{const n=await t(...e);return Gn(io),Gn(ro),n};function uo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const ho="DS",po="DSR";function fo(t=""){return Bn(`${t}${po}`)||""}function go(t=""){Gn(`${t}${po}`),Gn(`${t}${ho}`),Fn.remove(ho)}async function vo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ko(n.publicKey.challenge),n.publicKey.user.id=ko(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ko(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Oo(n.rawId),type:n.type,response:{attestationObject:Oo(n.response.attestationObject),clientDataJSON:Oo(n.response.clientDataJSON)}});var n}async function mo(t){const e=yo(t);return Io(await navigator.credentials.get(e))}async function bo(t,e){const n=yo(t);return n.signal=e.signal,n.mediation="conditional",Io(await navigator.credentials.get(n))}async function wo(t=!1){if(!Xn)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function yo(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ko(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ko(t.id)})),n}function Io(t){return JSON.stringify({id:t.id,rawId:Oo(t.rawId),type:t.type,response:{authenticatorData:Oo(t.response.authenticatorData),clientDataJSON:Oo(t.response.clientDataJSON),signature:Oo(t.response.signature),userHandle:t.response.userHandle?Oo(t.response.userHandle):void 0}})}function ko(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Oo(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var jo,Co=(jo=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await vo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await mo(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await vo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await mo(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await vo(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:vo,get:mo,isSupported:wo,conditional:bo}}),(...t)=>{const e=jo(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const xo=t=>({async oneTap(e,n,o,i){const r=null!=e?e:"google",s=await t.oauth.startNative(r,o);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{e(t.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==i||i())}))}))}});var So=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await wo(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Ao=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return Xn?(o&&i&&no(o).catch((()=>null)),t(Hn(r,{beforeRequest:oo}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(r))}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let a,l;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Zn("Expiration time passed, refreshing session"),c.refresh(l))}));const c=t(Hn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Kn(e);if(401===(null==e?void 0:e.status))Zn("Received 401, canceling all timers"),r();else if(o){a=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o),l=n;let t=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;t>Yn&&(Zn(`Timeout is too large (${t}ms), setting it to ${Yn}ms`),t=Yn),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});Zn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{Zn("Refreshing session due to timer"),c.refresh(n)}),t)}var i}}));return _n(c,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Zn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.0"},e.baseHeaders)}))),(t=>e=>{const n=uo(),o=uo(),i=t(Hn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await Jn(e);t&&o.pub(t);const{sessionJwt:i}=await Kn(e);i&&n.pub(i)}}})),r=_n(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(Hn(e,{afterRequest:async(t,e)=>{var n;const o=await Jn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{zn(io,t)})(i),(t=>{zn(ro,t)})(r))}}));let o=_n(n,["flow.start"],lo);return o=_n(o,["logout","logoutAll"],co),Object.assign(o,{getLastUserLoginId:so,getLastUserDisplayName:ao})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Xn)return o&&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"),t(s);const a=t(Hn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||fo(l)})),afterRequest:async(t,n)=>{401===(null==n?void 0:n.status)?go(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&zn(`${o}${po}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);Fn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(ho,r,s):zn(`${o}${ho}`,r))})(await Kn(n),i,r)}}));var l;const c=_n(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return go(t),o})(r));return Object.assign(c,{getRefreshToken:()=>fo(r),getSessionToken:()=>function(t=""){return Fn.get(ho)||Bn(`${t}${ho}`)||""}(r)})}))(((...t)=>{const e=Tn(...t);return Object.assign(Object.assign({},e),{flow:So(e),webauthn:Co(e),fedcm:xo(e)})})),Eo="undefined"!=typeof localStorage,Uo=Eo&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",_o="config.json",To="base.ui.components.url",Ro=Eo&&localStorage.getItem(To)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Po=Eo&&localStorage.getItem(To)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Lo="descope-login-flow",$o="code",Mo="ra-challenge",Wo="ra-callback",qo="ra-backup-callback",Do="ra-initiator",No="data-exclude-field",Fo="dls_last_auth",Ho="state_id",Ko="saml_idp_state_id",Jo="saml_idp_username",Vo="sso_app_id",zo="oidc_login_hint",Bo="data-type",Go="redirect",Zo="poll",Xo="webauthnCreate",Yo="webauthnGet",Qo="loadForm",ti="submit",ei="polling";var ni;function oi(t){return new URLSearchParams(window.location.search).get(t)}function ii(t){if(window.history.replaceState&&oi(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())}}function ri(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} [${n.status}]`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(ni||(ni={}));function si(t,e,n="v2-beta"){const o=new URL(Uo);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.toString()}function ai(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?ni.forward:t<e?ni.backward:void 0}const li=()=>{const[t="",e=""]=(oi(Lo)||"").split("_");return{executionId:t,stepId:e}};function ci(){ii(Lo)}const di=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),ui=()=>{const{executionId:t,stepId:e}=li();(t||e)&&ci();const n=oi("t")||void 0;n&&ii("t");const o=oi($o)||void 0;o&&ii($o);const i=oi("err")||void 0;i&&ii("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:oi(Mo),redirectAuthCallbackUrl:oi(Wo),redirectAuthBackupCallbackUri:oi(qo),redirectAuthInitiator:oi(Do)};(r||s||a||l)&&(ii(Mo),ii(Wo),ii(qo),ii(Do));const c=oi(Ho);c&&ii(Ho);const d=oi(Ko);d&&ii(Ko);const u=oi(Jo);d&&ii(Jo);const h=oi(Vo);h&&ii(Vo);const p=oi(zo);return p&&ii(zo),{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:p}},hi=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}};const pi=(t,e,n,o,i,r)=>t&&!e&&(t&&!n&&!o)&&(t&&!i)&&(t&&!r),fi=t=>null==t?void 0:t.submit(),gi=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null};var vi,mi,bi,wi;function yi(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(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!yi(r,s))return!1}else if(r!==s)return!1}return!0}class Ii{constructor(t={},{updateOnlyOnChange:e=!0}={}){vi.set(this,void 0),mi.set(this,{}),bi.set(this,0),wi.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,vi,"f")):t,n=Object.assign(Object.assign({},o(this,vi,"f")),e);if(!o(this,wi,"f")||!yi(o(this,vi,"f"),n)){const t=o(this,vi,"f");i(this,vi,n,"f"),Object.freeze(o(this,vi,"f")),setTimeout((()=>{Object.values(o(this,mi,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,vi,t,"f"),i(this,wi,e,"f")}get current(){return Object.assign({},o(this,vi,"f"))}subscribe(t){return i(this,bi,o(this,bi,"f")+1,"f"),o(this,mi,"f")[o(this,bi,"f")]=t,o(this,bi,"f").toString()}unsubscribe(t){const e=!!o(this,mi,"f")[t];return e&&delete o(this,mi,"f")[t],e}unsubscribeAll(){return i(this,mi,{},"f"),!0}}vi=new WeakMap,mi=new WeakMap,bi=new WeakMap,wi=new WeakMap;const ki=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${No}])`)).forEach((t=>{t.value=n}))}))},Oi=(t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ji=(t,e,n,o,i)=>{var r;let s=null==e?void 0:e.errorText;try{s=(null==o?void 0:o({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){i.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${Bo}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",s),((t,e)=>{t.querySelectorAll(`[${Bo}="totp-link"]`).forEach((t=>{t.setAttribute("href",e)}))})(t,null===(r=null==e?void 0:e.totp)||void 0===r?void 0:r.provisionUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link").forEach((t=>{t.textContent=Oi(t.textContent,e)}))})(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,i),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=Oi(t.value,e)}))}))})(t,e)},Ci=hi((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?t(i):e(new Error(`Promise timed out after ${n} ms`))}),n);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),xi=(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))]},Si={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function Ai(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(Fo)))}catch(t){}return e}const Ei="dls_ab_testing_id",Ui=document.createElement("template");var _i,Ti,Ri,Pi,Li,$i,Mi,Wi,qi,Di,Ni,Fi,Hi,Ki,Ji,Vi,zi,Bi,Gi,Zi,Xi,Yi,Qi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br,wr,yr,Ir,kr,Or,jr,Cr,xr,Sr,Ar,Er,Ur,_r,Tr,Rr,Pr;Ui.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[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<div id="wc-root"></div>\n\t';class Lr extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(t){super(),_i.add(this),this.logger=console,Ti.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,_i,"m",or).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)}},Ri.set(this,new Ii({deferredRedirect:!1})),Pi.set(this,new Ii),Li.set(this,{}),this.getComponentsContext=()=>o(this,Li,"f"),this.nextRequestStatus=new Ii({isLoading:!1}),$i.set(this,void 0),Mi.set(this,{popstate:o(this,_i,"m",Hi).bind(this),visibilitychange:o(this,_i,"m",Ki).bind(this),componentsContext:o(this,_i,"m",Qi).bind(this)}),Wi.set(this,void 0),Gi.set(this,hi((()=>n(this,void 0,void 0,(function*(){const t=si(this.projectId,_o);try{const{body:e,headers:n}=yield ri(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,Wi,t,"f"),o(this,_i,"m",qi).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const t=JSON.parse(this.getAttribute("form"))||{};return Object.entries(t).reduce(((t,[e,n])=>Object.assign(Object.assign({},t),{[`form.${e}`]:n})),t)}catch(t){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var t,e;const n=this.getAttribute("theme");if("os"===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"}return n||"light"}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Gi,"f").call(this);return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield o(this,Gi,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,Pi,"f").subscribe(o(this,_i,"m",nr).bind(this)),o(this,Pi,"f").update({isDebug:this.debug}),o(this,_i,"m",Di).call(this))return void o(this,_i,"m",Ni).call(this);if(o(this,_i,"m",Fi).call(this),yield o(this,_i,"m",zi).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield o(this,Gi,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield o(this,_i,"m",sr).call(this),yield o(this,_i,"m",Xi).call(this),o(this,_i,"m",Zi).call(this),o(this,_i,"m",ir).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}=ui();window.addEventListener("popstate",o(this,Mi,"f").popstate),window.addEventListener("components-context",o(this,Mi,"f").componentsContext),window.addEventListener("visibilitychange",o(this,Mi,"f").visibilitychange),o(this,Ri,"f").subscribe(o(this,_i,"m",Vi).bind(this)),o(this,Ri,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:e,executionId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,ssoAppId:f,oidcLoginHint:g}),i(this,Ti,!0,"f")}}))}disconnectedCallback(){o(this,Ri,"f").unsubscribeAll(),o(this,Pi,"f").unsubscribeAll(),o(this,_i,"m",er).call(this),window.removeEventListener("popstate",o(this,Mi,"f").popstate),window.removeEventListener("visibilitychange",o(this,Mi,"f").visibilitychange),window.removeEventListener("components-context",o(this,Mi,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,Ti,"f")&&e!==n&&Lr.observedAttributes.includes(t)){o(this,_i,"m",Fi).call(this);const i=null===e;o(this,Ri,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,ci()),{[di(t)]:n,stepId:r,executionId:s}})),o(this,Pi,"f").update({isDebug:this.debug})}}}Ti=new WeakMap,Ri=new WeakMap,Pi=new WeakMap,Li=new WeakMap,$i=new WeakMap,Mi=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,_i=new WeakSet,qi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ui.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},Di=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ni=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},Fi=function(){const t=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if(Lr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[di(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')},Hi=function(){const{stepId:t,executionId:e}=li();o(this,Ri,"f").update({stepId:t,executionId:e})},Ki=function(){document.hidden||setTimeout((()=>{o(this,Ri,"f").update({deferredRedirect:!1})}),300)},Ji=function(t,e){this.sdk=Ao(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},Lr.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Vi=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,_i,"m",Ji).call(this,e,n)}o(this,Wi,"f").call(this,t)}))},zi=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Gi,"f").call(this)).isMissingConfig&&(yield o(this,_i,"m",Bi).call(this))}))},Bi=function(){return n(this,void 0,void 0,(function*(){const t=si(this.projectId,_o,"v2-alpha");try{return yield ri(t,"json"),!0}catch(t){return!1}}))},Zi=function(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Gi,"f").call(this),i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.fonts;i&&Object.values(i).forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Xi=function(){return n(this,void 0,void 0,(function*(){yield o(this,_i,"m",Yi).call(this),yield o(this,_i,"m",tr).call(this)}))},Yi=function(){var t,e,o,i;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),r=si(this.projectId,"theme.json");try{const{body:s}=yield ri(r,"json");n.innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(e=null==s?void 0:s.dark)||void 0===e?void 0:e.globals)||"");const a=yield Lr.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(o=null==s?void 0:s.light)||void 0===o?void 0:o.components,dark:null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components})}catch(t){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(n)}))},Qi=function(t){i(this,Li,Object.assign(Object.assign({},t.detail),o(this,Li,"f")),"f")},tr=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const t=yield Lr.descopeUI;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)}))},er=function(){var t;null===(t=o(this,$i,"f"))||void 0===t||t.remove(),i(this,$i,null,"f")},nr=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(i(this,$i,document.createElement("descope-debugger"),"f"),Object.assign(o(this,$i,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return qr})),document.body.appendChild(o(this,$i,"f"))):o(this,_i,"m",er).call(this)}))},or=function(t,e){var n;t&&this.debug&&(null===(n=o(this,$i,"f"))||void 0===n||n.updateData({title:t,description:e}))},ir=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("descope-button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));if(1===n.length)n[0].click();else if(0===n.length){const t=Array.from(e).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&t[0].click()}}},rr=function(){var t,e;return n(this,void 0,void 0,(function*(){const n=null===(e=null===(t=yield o(this,Gi,"f").call(this))||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))},sr=function(){return n(this,void 0,void 0,(function*(){Lr.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):Lr.descopeUI=new Promise((t=>{if(globalThis.DescopeUI)return void t(globalThis.DescopeUI);const e=t=>{const e=document.createElement("script");return e.id="load-descope-ui",e.src=t,e},i=(t,e)=>t.replace("<version>",e),r=(e,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${e.src}"`),n()};e.addEventListener("load",(()=>{globalThis.DescopeUI||o(),t(globalThis.DescopeUI)})),e.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,_i,"m",rr).call(this),s=e(i(Ro,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=e(i(Po,n));r(o,(()=>{t(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},Lr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.1"}};class $r extends Lr{static set sdkConfigOverrides(t){Lr.sdkConfigOverrides=t}constructor(){const t=new Ii;super(t.update.bind(t)),ar.add(this),this.stepState=new Ii({},{updateOnlyOnChange:!1}),lr.set(this,void 0),cr.set(this,null),dr.set(this,((t,e,r,s,a)=>{r===Zo&&i(this,lr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(t,e,ei,s,a,{});o(this,hr,"f").call(this,i);const{action:r}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,dr,"f").call(this,t,e,r,s,a)}))),2e3),"f")})),ur.set(this,(()=>{clearTimeout(o(this,lr,"f")),i(this,lr,null,"f")})),hr.set(this,(t=>{var e,n,i,r,s,a,l,c,d;if(!(null==t?void 0:t.ok)){o(this,ar,"m",jr).call(this,"error",null==t?void 0:t.error);const a=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}const u=null===(c=null===(l=null===(a=t.data)||void 0===a?void 0:a.screen)||void 0===l?void 0:l.state)||void 0===c?void 0:c.errorText;(null===(d=t.data)||void 0===d?void 0:d.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${u?`${u} - `:""}${t.data.error.message}`):u&&this.loggerWrapper.error(u);const{status:h,authInfo:p,lastAuth:f}=t.data;if("completed"===h)return function(t){(null==t?void 0:t.authMethod)&&Eo&&localStorage.setItem(Fo,JSON.stringify(t))}(f),void o(this,ar,"m",jr).call(this,"success",p);const{executionId:g,stepId:v,stepName:m,action:b,screen:w,redirect:y,webauthn:I,error:k,samlIdpResponse:O}=t.data;b!==Zo?(this.loggerWrapper.info(`Step "${m||`#${v}`}" is ${h}`,"",{screen:w,status:h,stepId:v,stepName:m,action:b,error:k}),this.flowState.update({stepId:v,executionId:g,action:b,redirectTo:null==y?void 0:y.url,screenId:null==w?void 0:w.id,screenState:null==w?void 0:w.state,webauthnTransactionId:null==I?void 0:I.transactionId,webauthnOptions:null==I?void 0:I.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState})):this.flowState.update({action:b})})),pr.set(this,hi((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.error("Webauthn start failed",t.message)}}))))),this.flowState=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,cr,"f"))||void 0===t||t.abort(),i(this,cr,null,"f")}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const i=(t||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(i)&&(n=`${e}-${i}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield ri(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield ri(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,e,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:l,tenant:c,stepId:d,executionId:u,action:h,screenId:p,screenState:f,redirectTo:g,redirectUrl:v,token:m,code:b,exchangeError:w,webauthnTransactionId:y,webauthnOptions:I,redirectAuthCodeChallenge:k,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:C,oidcIdpStateId:x,locale:S,samlIdpStateId:A,samlIdpUsername:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:_,samlIdpResponseRelayState:T,ssoAppId:R,oidcLoginHint:P}=t;let L,$;const M=(()=>{const t=localStorage.getItem(Ei);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(Ei,t.toString()),t}return Number(t)})(),W=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),D=yield this.getProjectConfig(),N=O&&k?{callbackUrl:O,codeChallenge:k,backupCallbackUri:j}:void 0;if(!u&&(q.fingerprintEnabled&&q.fingerprintKey?no(q.fingerprintKey):localStorage.removeItem(to),q.conditions?({startScreenId:L,conditionInteractionId:$}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=Si[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:b,token:m,abTestingKey:M},q.conditions)):q.condition?({startScreenId:L,conditionInteractionId:$}=((t,e)=>{var n;const o=null===(n=Si[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(q.condition,{loginId:W,code:b,token:m,abTestingKey:M})):L=q.startScreenId,!pi(L,x,A,E,R,P))){const t=yield this.sdk.flow.start(l,Object.assign(Object.assign({tenant:c,redirectAuth:N,oidcIdpStateId:x,samlIdpStateId:A,samlIdpUsername:E,ssoAppId:R,oidcLoginHint:P,client:this.client},v&&{redirectUrl:v}),{lastAuth:Ai(W),abTestingKey:M}),$,"",q.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),b?{exchangeCode:b,idpInitiated:!0}:{}),m?{token:m}:{}),P?{externalId:P}:{}));return o(this,hr,"f").call(this,t),void("completed"!==(null===(s=null==t?void 0:t.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0,token:void 0}))}if(u&&(r("token")&&m||r("code")&&b||r("exchangeError")&&w)){const t=yield this.sdk.flow.next(u,d,ti,q.version,D.componentsVersion,{token:m,exchangeCode:b,exchangeError:w});return o(this,hr,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(h===Qo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>r(t)))){if(!U||!_)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(U,_,T||"",fi)}if(h===Go&&(r("redirectTo")||r("deferredRedirect")))return g?"android"===C&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(h===Xo||h===Yo){if(!y||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,cr,"f"))||void 0===a||a.abort(),i(this,cr,null,"f");try{t=h===Xo?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(u,d,ti,q.version,D.componentsVersion,{transactionId:y,response:t,failure:e});o(this,hr,"f").call(this,n)}if(o(this,dr,"f").call(this,u,d,h,q.version,D.componentsVersion),!p&&!L)return void this.loggerWrapper.warn("No screen was found to show");const F=L||p,H=yield this.getHtmlFilenameWithLocale(S,F),K={direction:ai(+d,+e.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.form),null==f?void 0:f.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:si(n,`${F}.html`),htmlLocaleUrl:H&&si(n,H),samlIdpUsername:E,oidcLoginHint:P},J=Ai(W);pi(L,x,A,E,R,P)?K.next=(t,e,n,o)=>this.sdk.flow.start(l,Object.assign({tenant:c,redirectAuth:N,oidcIdpStateId:x,samlIdpStateId:A,samlIdpUsername:E,ssoAppId:R,oidcLoginHint:P,lastAuth:J,preview:this.preview,abTestingKey:M,client:this.client},v&&{redirectUrl:v}),$,t,e,n,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),b&&{exchangeCode:b,idpInitiated:!0}),m&&{token:m})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(K.next=(...t)=>this.sdk.flow.next(u,d,...t)),this.stepState.update(K)}))}loadDescopeUiComponents(t){return n(this,void 0,void 0,(function*(){const e=yield Lr.descopeUI;if(!e)return;const o=(t=>[...Array.from(t.querySelectorAll("*")).reduce(((t,e)=>e.tagName.startsWith("DESCOPE-")?t.add(e.tagName.toLocaleLowerCase()):t),new Set)])(t);yield Promise.all(o.map((t=>n(this,void 0,void 0,(function*(){if(!!!customElements.get(t))if(e[t])try{return yield e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`${t} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)})))))}))}onStepChange(t,e){var i,r;return n(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d}=t,u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,ar,"m",gr).call(this,h,c):h.querySelectorAll(`descope-button[${Bo}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),ji(h,d,d.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(h,f);const g=()=>n(this,void 0,void 0,(function*(){var t;yield p,((t,e)=>{var n,o;const i=null===(n=customElements.get("descope-totp-image"))||void 0===n?void 0:n.cssVarList.url;e&&i&&(null===(o=null==t?void 0:t.style)||void 0===o||o.setProperty(i,`url(data:image/jpg;base64,${e})`))})(this.shadowRoot.querySelector("div"),null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image),this.rootElement.replaceChildren(h),setTimeout((()=>((t,e)=>{ki(t,null==e?void 0:e.inputs),ki(t,null==e?void 0:e.form)})(this.rootElement,d)));const n=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,n),o(this,ar,"m",kr).call(this,c),n&&o(this,ar,"m",jr).call(this,"ready",{}),o(this,ar,"m",jr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Bo}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(ei,t.version,e.componentsVersion,{});o(this,hr,"f").call(this,n)}}));l?o(this,ar,"m",Or).call(this,g,l):g()}))}}lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,ar=new WeakSet,fr=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},gr=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,cr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ci())){const{options:t,transactionId:r}=(yield o(this,pr,"f").call(this))||{};if(t&&r){o(this,ar,"m",fr).call(this,s),i(this,cr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,cr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,hr,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},vr=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((t=>{var e,n;return null===(e=t.reportValidity)||void 0===e||e.call(t),null===(n=t.checkValidity)||void 0===n?void 0:n.call(t)}))},mr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${No}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},br=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},wr=function(t={}){var e,n;const o=gi(t,["externalId","email","phone"]),i=gi(t,["newPassword","password"]);if(o&&i)try{const t=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},yr=function(t,e){return n(this,void 0,void 0,(function*(){if("true"===t.getAttribute("formnovalidate")||o(this,ar,"m",vr).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,ar,"m",br).call(this,t);const r=yield o(this,ar,"m",mr).call(this),s=(n=t,Array.from((null==n?void 0:n.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}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield e(i,c.version,d.componentsVersion,l);o(this,hr,"f").call(this,u),o(this,ar,"m",wr).call(this,r)}var n}))},Ir=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&o(this,ar,"m",yr).call(this,e,t)}))}))},kr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,ar,"m",yr).call(this,e,t)}})),o(this,ar,"m",Ir).call(this,t)},Or=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===ni.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},jr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",$r);const Mr=document.createElement("template");Mr.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 word-wrap: break-word;\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 Wr extends HTMLElement{constructor(){super(),Cr.add(this),xr.set(this,new Ii({messages:[]})),Sr.set(this,void 0),Ar.set(this,void 0),Er.set(this,void 0),Ur.set(this,{resize:o(this,Cr,"m",Pr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Mr.content.cloneNode(!0)),i(this,Sr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Ar,o(this,Sr,"f").querySelector(".content"),"f"),i(this,Er,o(this,Sr,"f").querySelector(".header"),"f")}updateData(t){o(this,xr,"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,l]=xi(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,Sr,"f"),o(this,Er,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Ur,"f").resize),(t=o(this,Sr,"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,Sr,"f").onresize=o(this,Cr,"m",Rr).bind(this),o(this,xr,"f").subscribe(o(this,Cr,"m",_r).bind(this))}disconnectedCallback(){o(this,xr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Ur,"f").resize)}}xr=new WeakMap,Sr=new WeakMap,Ar=new WeakMap,Er=new WeakMap,Ur=new WeakMap,Cr=new WeakSet,_r=function(t){o(this,Cr,"m",Tr).call(this,t),o(this,Cr,"m",Rr).call(this)},Tr=function(t){o(this,Ar,"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("")},Rr=function(){o(this,Ar,"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)}))},Pr=function(){const[t,e]=xi(o(this,Sr,"f"),Number.parseInt(o(this,Sr,"f").style.left,10),Number.parseInt(o(this,Sr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Sr,"f").style.top=`${e}px`,o(this,Sr,"f").style.left=`${t}px`},customElements.define("descope-debugger",Wr);var qr=Object.freeze({__proto__:null,default:Wr})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"author": "Descope Team <info@descope.com>",
|
|
5
5
|
"homepage": "https://github.com/descope/web-component",
|
|
6
6
|
"bugs": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"tslib": "2.6.2",
|
|
69
|
-
"@descope/web-js-sdk": "1.
|
|
69
|
+
"@descope/web-js-sdk": "1.10.0"
|
|
70
70
|
},
|
|
71
71
|
"overrides": {
|
|
72
72
|
"terser": "5.21.0"
|