@descope/web-component 3.22.2 → 3.23.0
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-def6a8b1.js";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";const s=(e,n,t,s={})=>{var o,i,l,r;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(o=s.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(i=s.right)&&void 0!==i?i: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!==(r=s.bottom)&&void 0!==r?r:0))]};var o,i,l,r,a,d,c,p,h,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(),o.add(this),i.set(this,new t({messages:[]})),l.set(this,void 0),r.set(this,void 0),a.set(this,void 0),d.set(this,{resize:e(this,o,"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,r,e(this,l,"f").querySelector(".content"),"f"),n(this,a,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,i,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let o=0,i=0,l=0,r=0;function a(n){n.preventDefault(),o=l-n.clientX,i=r-n.clientY,l=n.clientX,r=n.clientY;const[a,d]=s(e,e.offsetLeft-o,e.offsetTop-i,t);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,r=e.clientY,document.onmouseup=d,document.onmousemove=a}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,a,"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,o,"m",h).bind(this),e(this,i,"f").subscribe(e(this,o,"m",c).bind(this))}disconnectedCallback(){e(this,i,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}i=new WeakMap,l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(n){e(this,o,"m",p).call(this,n),e(this,o,"m",h).call(this)},p=function(n){e(this,r,"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("")},h=function(){e(this,r,"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.get("descope-debugger")||customElements.define("descope-debugger",m);export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i,__rest as o}from"tslib";import r,{ensureFingerprintIds as n,clearFingerprintData as s}from"@descope/web-js-sdk";import{themeMixin as a}from"@descope/sdk-mixins";import{createSingletonMixin as l,compose as d}from"@descope/sdk-helpers";const c="undefined"!=typeof localStorage,u="J151000",h=c&&localStorage.getItem("base.content.url")||"",p="config.json",g="base.ui.components.url";c&&localStorage.getItem(g),c&&localStorage.getItem(g);const f="descope-login-flow",v="code",m="ra-challenge",b="ra-callback",y="ra-backup-callback",w="ra-initiator",I="data-exclude-field",k="dls_last_auth",A="state_id",C="saml_idp_state_id",S="saml_idp_username",j="descope_idp_initiated",E="sso_app_id",x="oidc_login_hint",U="oidc_prompt",O="oidc_error_redirect_uri",L="data-type",R="redirect",T="poll",W="webauthnCreate",$="webauthnGet",M="loadForm",P="submit",N="polling",q=["descope-multi-select-combo-box","descope-text-area"];var _;function F(t){return new URLSearchParams(window.location.search).get(t)}function D(t){if(window.history.replaceState&&F(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 V(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"}(_||(_={}));function K({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(h||o||"https://static.descope.com/pages");return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,i,e),r.toString()}function H(t,e){if(!e)return;const i=+t,o=+e;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?_.forward:i<o?_.backward:void 0}const B=()=>{const[t="",e=""]=(F(f)||"").split("_");return{executionId:t,stepId:e}};function J(){D(f)}const G=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),z=()=>{const{executionId:t,stepId:e}=B();(t||e)&&J();const i=F("t")||void 0;i&&D("t");const o=F(v)||void 0;o&&D(v);const r=F("err")||void 0;r&&D("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:F(m),redirectAuthCallbackUrl:F(b),redirectAuthBackupCallbackUri:F(y),redirectAuthInitiator:F(w)};(n||s||a||l)&&(D(m),D(b),D(y),D(w));const d=F(A);d&&D(A);const c=F(C);c&&D(C);const u=F(S);c&&D(S);const h=F(j);h&&D(j);const p=F(E);p&&D(E);const g=F(x);g&&D(x);const f=F(U);f&&D(U);const I=F(O);I&&D(O);return{executionId:t,stepId:e,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:g,oidcPrompt:f,oidcErrorRedirectUri:I}}},Q=t=>{let e,i;return(...o)=>{return e&&(n=o,(r=e).length===n.length&&r.every(((t,e)=>t===n[e])))||(e=o,i=t(...o)),i;var r,n}};const X=(t,{oidcIdpStateId:e,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||i||o||r||n||s||a),Y=t=>null==t?void 0:t.submit(),Z=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null},tt=(t,e=100)=>{let i;return function(...o){i||t.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),e)}};function et(t){let e=navigator.language;return e&&"zh-TW"!==e&&(e=e.split("-")[0]),(t||e||"").toLowerCase()}var it,ot,rt,nt;function st(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 r=i[o],n=t[r],s=e[r];if(null===n||null===s){if(n!==s)return!1}else if("object"==typeof n&&"object"==typeof s){if(!st(n,s))return!1}else if(n!==s)return!1}return!0}class at{constructor(t={},{updateOnlyOnChange:o=!0}={}){it.set(this,void 0),ot.set(this,{}),rt.set(this,0),nt.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,it,"f")):t,r=Object.assign(Object.assign({},e(this,it,"f")),o);if(!e(this,nt,"f")||!st(e(this,it,"f"),r)){const t=e(this,it,"f");i(this,it,r,"f"),Object.freeze(e(this,it,"f")),setTimeout((()=>{Object.values(e(this,ot,"f")).forEach((e=>e(r,t,((t,e)=>i=>t[i]!==e[i])(r,t))))}),0)}},i(this,it,t,"f"),i(this,nt,o,"f")}get current(){return Object.assign({},e(this,it,"f"))}subscribe(t){return i(this,rt,e(this,rt,"f")+1,"f"),e(this,ot,"f")[e(this,rt,"f")]=t,e(this,rt,"f").toString()}unsubscribe(t){const i=!!e(this,ot,"f")[t];return i&&delete e(this,ot,"f")[t],i}unsubscribeAll(){return i(this,ot,{},"f"),!0}}it=new WeakMap,ot=new WeakMap,rt=new WeakMap,nt=new WeakMap;const lt=["disabled"],dt=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${I}])`)).forEach((t=>{t.value=i}))}))},ct=(t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ut=(t,e,i)=>{t.querySelectorAll(`[${L}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},ht=(t,e,i)=>{var o,r;const n=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;i&&n&&(null===(r=null==t?void 0:t.style)||void 0===r||r.setProperty(n,`url(data:image/jpg;base64,${i})`))},pt=(t,e,i,o,r,n)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==r?void 0:r({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(`[${L}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),ut(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ut(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ct(t.textContent,e);const i=t.getAttribute("href");i&&t.setAttribute("href",ct(i,e))}))})(t,e),((t,e,i)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const r=e[o];Object.keys(r).forEach((e=>{let o=r[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=ct(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,i])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(i).forEach((([e,i])=>{lt.includes(e)&&t.setAttribute(e,i)}))}))}))})(t,o)},gt=Q((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o,r;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=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=n,r=s,new Promise(((t,e)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==r?t(r):e(new Error(`Promise timed out after ${i} ms`))}),i);o.then((e=>{n||(clearTimeout(s),t(e))})).catch((t=>{n||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ft={"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 vt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(k)))}catch(t){}return e}const mt="dls_ab_testing_id",bt=l((t=>{var i,o,r,n;return n=class extends t{constructor(){super(...arguments),i.add(this)}connectedCallback(){var t;e(this,i,"m",o).call(this)&&e(this,i,"m",r).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},i=new WeakSet,o=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},r=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},n})),yt=document.createElement("template");yt.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#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";const wt=(t,e="")=>Object.keys(t).reduce(((i,o)=>{var r;if("object"==typeof t[o]&&null!==t[o]&&!(null===(r=t[o])||void 0===r?void 0:r.value))return Object.assign(Object.assign({},i),wt(t[o],`${e+o}.`));const n="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},i),{[e+o]:n,[`form.${e}${o}`]:n});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:n,[`form.${e}fullName`]:n}):s}),[]);var It,kt,At,Ct,St,jt,Et,xt,Ut,Ot,Lt,Rt,Tt,Wt,$t,Mt,Pt,Nt,qt,_t,Ft,Dt;const Vt=d(a,bt)(HTMLElement);class Kt extends Vt{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(o){super(),It.add(this),At.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,It,"m",Ft).call(this,t,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},Ct.set(this,new at),St.set(this,new at),jt.set(this,{}),this.getComponentsContext=()=>e(this,jt,"f"),this.nextRequestStatus=new at({isLoading:!1}),Et.set(this,void 0),xt.set(this,{popstate:e(this,It,"m",Rt).bind(this),componentsContext:e(this,It,"m",Nt).bind(this)}),Ut.set(this,void 0),Pt.set(this,Q((()=>t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield V(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,Ut,o,"f"),e(this,It,"m",Ot).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}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 autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return wt(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,i])=>[t,i[e]])));var t,e}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,Pt,"f").call(this);return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,Pt,"f").call(this);return t}))}getFlowConfig(){return t(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),o=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(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()))}))}init(){const o=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;if(yield null===(t=o.init)||void 0===t?void 0:t.call(this),e(this,St,"f").subscribe(e(this,It,"m",_t).bind(this)),e(this,St,"f").update({isDebug:this.debug}),e(this,It,"m",Lt).call(this),yield e(this,It,"m",$t).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,Pt,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,It,"m",Dt).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=z();window.addEventListener("popstate",e(this,xt,"f").popstate),window.addEventListener("components-context",e(this,xt,"f").componentsContext),e(this,Ct,"f").subscribe(e(this,It,"m",Wt).bind(this)),e(this,Ct,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,At,!0,"f")}))}disconnectedCallback(){e(this,Ct,"f").unsubscribeAll(),e(this,St,"f").unsubscribeAll(),e(this,It,"m",qt).call(this),window.removeEventListener("popstate",e(this,xt,"f").popstate),window.removeEventListener("components-context",e(this,xt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,At,"f")&&i!==o&&kt.observedAttributes.includes(t)){e(this,It,"m",Lt).call(this);const r=null===i;e(this,Ct,"f").update((({stepId:e,executionId:i})=>{let n=e,s=i;return r||(s=null,n=null,J()),{[G(t)]:o,stepId:n,executionId:s}})),e(this,St,"f").update({isDebug:this.debug})}}}function Ht(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Bt,Jt,Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue;kt=Kt,At=new WeakMap,Ct=new WeakMap,St=new WeakMap,jt=new WeakMap,Et=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Pt=new WeakMap,It=new WeakSet,Ot=function(){this.shadowRoot.appendChild(yt.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Lt=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];kt.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[G(e)])throw Error(`${e} cannot be empty`)}))},Rt=function(){const{stepId:t,executionId:i}=B();e(this,Ct,"f").update({stepId:t,executionId:i})},Tt=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},kt.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)}catch(t){return{error:{errorCode:u,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Wt=function(i,o,r){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=i;if(r("projectId")||r("baseUrl")){if(!t)return;e(this,It,"m",Tt).call(this,t,o)}e(this,Ut,"f").call(this,i)}))},$t=function(){return t(this,void 0,void 0,(function*(){return(yield e(this,Pt,"f").call(this)).isMissingConfig&&(yield e(this,It,"m",Mt).call(this))}))},Mt=function(){return t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield V(t,"json"),!0}catch(t){return!1}}))},Nt=function(t){i(this,jt,Object.assign(Object.assign({},e(this,jt,"f")),t.detail),"f")},qt=function(){var t;null===(t=e(this,Et,"f"))||void 0===t||t.remove(),i(this,Et,null,"f")},_t=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Et,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Et,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-b06f238e.js"),document.body.appendChild(e(this,Et,"f"))):e(this,It,"m",qt).call(this)}))},Ft=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Et,"f"))||void 0===o||o.updateData({title:t,description:i}))},Dt=function(){this.rootElement.onkeydown=t=>{var e,i,o;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=q.includes(null!==(o=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==o?o:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Kt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.23.0"}};class he extends Kt{static set sdkConfigOverrides(t){Kt.sdkConfigOverrides=t}constructor(){const o=new at({deferredRedirect:!1});super(o.update.bind(o)),Bt.add(this),this.stepState=new at({},{updateOnlyOnChange:!1}),Jt.set(this,void 0),Gt.set(this,null),zt.set(this,{visibilitychange:e(this,Bt,"m",Qt).bind(this)}),Xt.set(this,((o,r,n,s,a)=>{n===T&&(this.logger.debug("polling - Scheduling polling request"),i(this,Jt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t,i;this.logger.debug("polling - Calling next");const l=yield this.sdk.flow.next(o,r,N,s,a,{});if((null===(t=null==l?void 0:l.error)||void 0===t?void 0:t.errorCode)===u)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Xt,"f").call(this,o,r,n,s,a);this.logger.debug("polling - Got a response"),(null==l?void 0:l.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(l.error,null,4)),e(this,Zt,"f").call(this,l);const{action:d}=null!==(i=null==l?void 0:l.data)&&void 0!==i?i:{};e(this,Xt,"f").call(this,o,r,d,s,a)}))),2e3),"f"))})),Yt.set(this,(()=>{clearTimeout(e(this,Jt,"f")),i(this,Jt,null,"f")})),Zt.set(this,(t=>{var i,o,r,n,s,a,l,d,u,h,p;if(!(null==t?void 0:t.ok)){const a=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===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return e(this,Bt,"m",ue).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:i,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](i,o):this.loggerWrapper.info(i,o)}));const g=null===(h=null===(u=null===(d=t.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=t.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${g?`${g} - `:""}${t.data.error.message}`):g&&this.loggerWrapper.error(g);const{status:f,authInfo:v,lastAuth:m}=t.data;if("completed"===f)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&c&&localStorage.setItem(k,JSON.stringify(t))}(m),void e(this,Bt,"m",ue).call(this,"success",v);const{executionId:b,stepId:y,stepName:w,action:I,screen:A,redirect:C,openInNewTabUrl:S,webauthn:j,error:E,samlIdpResponse:x}=t.data;I!==T?(this.loggerWrapper.info(`Step "${w||`#${y}`}" is ${f}`,"",{screen:A,status:f,stepId:y,stepName:w,action:I,error:E}),this.flowState.update({stepId:y,executionId:b,action:I,redirectTo:null==C?void 0:C.url,openInNewTabUrl:S,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==x?void 0:x.url,samlIdpResponseSamlResponse:null==x?void 0:x.samlResponse,samlIdpResponseRelayState:null==x?void 0:x.relayState})):this.flowState.update({action:I})})),te.set(this,Q((()=>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.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),ae.set(this,tt(((i,o)=>t(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||e(this,Bt,"m",oe).call(this)){const r=null==i?void 0:i.getAttribute("id");e(this,Bt,"m",ne).call(this,i);const n=yield e(this,Bt,"m",re).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),n),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(r,d.version,c.componentsVersion,l);e(this,Zt,"f").call(this,u),e(this,Bt,"m",se).call(this,n)}var t}))))),this.flowState=o}loadSdkScripts(){return t(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>t(this,void 0,void 0,(function*(){(yield function(e){return t(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield import("./forter-74d50b85.js"),t.default;case"fingerprint":return t=yield import("./fingerprint-84b451f2.js"),t.default;case"fingerprintDescope":return t=yield import("./fingerprintDescope-effc737b.js"),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Ht(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t,o,r;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)),window.addEventListener("visibilitychange",e(this,zt,"f").visibilitychange)),yield null===(r=i.init)||void 0===r?void 0:r.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=e(this,Gt,"f"))||void 0===t||t.abort(),i(this,Gt,null,"f"),window.removeEventListener("visibilitychange",e(this,zt,"f").visibilitychange)}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t;const o=et(e);return(yield this.getTargetLocales()).includes(o)&&(t=`${i}-${o}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield V(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 V(e,"text");return t}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(r,a,l){return t(this,void 0,void 0,(function*(){var t,d;const{projectId:c,flowId:u,tenant:h,stepId:p,executionId:g,action:f,screenId:v,screenState:m,redirectTo:b,openInNewTabUrl:y,redirectUrl:w,token:I,code:k,exchangeError:A,webauthnTransactionId:C,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:U,locale:O,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:N}=r,q=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let _,F;const D=(()=>{const t=localStorage.getItem(mt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(mt,t.toString()),t}return Number(t)})(),V=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),J=yield this.getProjectConfig(),G=E&&j?{callbackUrl:E,codeChallenge:j,backupCallbackUri:x}:void 0;if(!g&&(this.loadSdkScripts(),B.fingerprintEnabled&&B.fingerprintKey?yield n(B.fingerprintKey,this.baseUrl):s(),B.conditions?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i,predicate:o})=>{var r;if("ELSE"===e)return!0;const n=null===(r=ft[e])||void 0===r?void 0:r[i];return!!(null==n?void 0:n(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:V,code:k,token:I,abTestingKey:D},B.conditions)):B.condition?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{var i;const o=null===(i=ft[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const r=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(B.condition,{loginId:V,code:k,token:I,abTestingKey:D})):_=B.startScreenId,!X(_,q))){const i=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:vt(V),abTestingKey:D,locale:et(O)}),F,"",B.version,J.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),I?{token:I}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return e(this,Zt,"f").call(this,i),void("completed"!==(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.status)&&this.flowState.update({code:void 0,token:void 0}))}if(g&&(l("token")&&I||l("code")&&k||l("exchangeError")&&A)){const t=yield this.sdk.flow.next(g,p,P,B.version,J.componentsVersion,{token:I,exchangeCode:k,exchangeError:A});return e(this,Zt,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!L||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,i,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.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(r),o(r)})(L,T,N||"",Y)}if(f===R&&(l("redirectTo")||l("deferredRedirect")))return b?"android"===U&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(b):void this.loggerWrapper.error("Did not get redirect url");if(f===W||f===$){if(!C||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(d=e(this,Gt,"f"))||void 0===d||d.abort(),i(this,Gt,null,"f");try{t=f===W?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}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 r=yield this.sdk.flow.next(g,p,P,B.version,J.componentsVersion,{transactionId:C,response:t,failure:o});e(this,Zt,"f").call(this,r)}if(e(this,Xt,"f").call(this,g,p,f,B.version,J.componentsVersion),!v&&!_)return void this.loggerWrapper.warn("No screen was found to show");const z=_||v,Q=yield this.getHtmlFilenameWithLocale(O,z),{oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,samlIdpUsername:ot}=q,rt={direction:H(p,a.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:V,name:this.sdk.getLastUserDisplayName()||V}}),htmlUrl:K({projectId:c,filename:`${z}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:Q&&K({projectId:c,filename:Q,baseUrl:this.baseStaticUrl}),samlIdpUsername:ot,oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,openInNewTabUrl:y},nt=vt(V);X(_,q)?rt.next=(t,e,i,o)=>this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{lastAuth:nt,preview:this.preview,abTestingKey:D,client:this.client}),w&&{redirectUrl:w}),{locale:et(O)}),F,t,e,i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),I&&{token:I})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(rt.next=(...t)=>this.sdk.flow.next(g,p,...t)),this.stepState.update(rt)}))}onStepChange(i,o){return t(this,void 0,void 0,(function*(){var r,n;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c,openInNewTabUrl:u}=i,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield e(this,Bt,"m",ie).call(this,p,d):p.querySelectorAll(`descope-button[${L}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(r=c.form)||void 0===r?void 0:r.loginId)||(null===(n=c.form)||void 0===n?void 0:n.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),pt(p,c,c.componentsConfig,this.formConfig,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)}))})(p,f);const v=()=>t(this,void 0,void 0,(function*(){var t,i;yield g;const r=this.shadowRoot.querySelector("div");var n,s;n=r,s=null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image,ht(n,"descope-totp-image",s),((t,e)=>{ht(t,"descope-notp-image",e)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{dt(t,null==e?void 0:e.inputs),dt(t,null==e?void 0:e.form)})(this.rootElement,c)}));const a=!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,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const i=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=i}))}))}))})(this.rootElement),e(this,Bt,"m",de).call(this,d),a&&e(this,Bt,"m",ue).call(this,"ready",{}),e(this,Bt,"m",ue).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${L}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(N,t.version,i.componentsVersion,{});e(this,Zt,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Bt,"m",ce).call(this,v,l):v()}))}}Jt=new WeakMap,Gt=new WeakMap,zt=new WeakMap,Xt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ae=new WeakMap,Bt=new WeakSet,Qt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ee=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)}))}},ie=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,Gt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield gt())){const{options:o,transactionId:n}=(yield e(this,te,"f").call(this))||{};if(o&&n){e(this,Bt,"m",ee).call(this,s),i(this,Gt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Gt,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield r(s.id,a.version,l.componentsVersion,{transactionId:n,response:i});e(this,Zt,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},oe=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var i,o;"slot"!==e.localName&&(null===(i=e.reportValidity)||void 0===i||i.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},re=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${I}])`));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})),{})}))},ne=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},se=function(t={}){var e,i;const o=Z(t,["externalId","email","phone"]),r=Z(t,["newPassword","password"]);if(o&&r)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:r});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)}},le=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,ae,"f").call(this,i,t)}))}))},de=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,ae,"f").call(this,i,t)}})),e(this,Bt,"m",le).call(this,t)},ce=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===_.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")},ue=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",he);export{he as D,at as S};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{D as default}from"./index-
|
|
1
|
+
export{D as default}from"./index-def6a8b1.js";import"tslib";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";
|