@descope/web-component 3.30.0 → 3.31.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.
Files changed (54) hide show
  1. package/dist/cjs/constants/content.js +1 -0
  2. package/dist/cjs/constants/general.js +1 -0
  3. package/dist/cjs/constants/index.js +1 -0
  4. package/dist/cjs/constants/uiComponents.js +1 -0
  5. package/dist/cjs/debugger-wc.js +1 -0
  6. package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -0
  7. package/dist/cjs/descope-wc/DescopeWc.js +1 -0
  8. package/dist/cjs/descope-wc/index.js +1 -0
  9. package/dist/cjs/descope-wc/initTemplate.js +1 -0
  10. package/dist/cjs/descope-wc/sdkScripts/fingerprint.js +1 -0
  11. package/dist/cjs/descope-wc/sdkScripts/fingerprintDescope.js +1 -0
  12. package/dist/cjs/descope-wc/sdkScripts/forter.js +1 -0
  13. package/dist/cjs/descope-wc/sdkScripts/index.js +1 -0
  14. package/dist/cjs/helpers/abTestingKey.js +1 -0
  15. package/dist/cjs/helpers/conditions.js +1 -0
  16. package/dist/cjs/helpers/flowInputs.js +1 -0
  17. package/dist/cjs/helpers/helpers.js +1 -0
  18. package/dist/cjs/helpers/lastAuth.js +1 -0
  19. package/dist/cjs/helpers/positionHelpers.js +1 -0
  20. package/dist/cjs/helpers/state.js +1 -0
  21. package/dist/cjs/helpers/templates.js +1 -0
  22. package/dist/cjs/helpers/webauthn.js +1 -0
  23. package/dist/cjs/mixins/formMountMixin.js +1 -0
  24. package/dist/cjs/types.js +1 -0
  25. package/dist/esm/constants/content.js +1 -0
  26. package/dist/esm/constants/general.js +1 -0
  27. package/dist/esm/constants/index.js +1 -0
  28. package/dist/esm/constants/uiComponents.js +1 -0
  29. package/dist/esm/debugger-wc.js +1 -0
  30. package/dist/esm/descope-wc/BaseDescopeWc.js +1 -0
  31. package/dist/esm/descope-wc/DescopeWc.js +1 -0
  32. package/dist/esm/descope-wc/index.js +1 -0
  33. package/dist/esm/descope-wc/initTemplate.js +1 -0
  34. package/dist/esm/descope-wc/sdkScripts/index.js +1 -0
  35. package/dist/esm/helpers/abTestingKey.js +1 -0
  36. package/dist/esm/helpers/conditions.js +1 -0
  37. package/dist/esm/helpers/flowInputs.js +1 -0
  38. package/dist/esm/helpers/helpers.js +1 -0
  39. package/dist/esm/helpers/lastAuth.js +1 -0
  40. package/dist/esm/helpers/positionHelpers.js +1 -0
  41. package/dist/esm/helpers/state.js +1 -0
  42. package/dist/esm/helpers/templates.js +1 -0
  43. package/dist/esm/helpers/webauthn.js +1 -0
  44. package/dist/esm/mixins/formMountMixin.js +1 -0
  45. package/dist/esm/types.js +1 -0
  46. package/dist/index.d.ts +41 -183
  47. package/dist/index.js +2 -2
  48. package/package.json +5 -5
  49. package/dist/esm/debugger-wc-6fe609c2.js +0 -1
  50. package/dist/esm/index-3cc4a2cc.js +0 -1
  51. package/dist/esm/index.js +0 -1
  52. /package/dist/esm/{fingerprint-84b451f2.js → descope-wc/sdkScripts/fingerprint.js} +0 -0
  53. /package/dist/esm/{fingerprintDescope-effc737b.js → descope-wc/sdkScripts/fingerprintDescope.js} +0 -0
  54. /package/dist/esm/{forter-74d50b85.js → descope-wc/sdkScripts/forter.js} +0 -0
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.30.0",
3
+ "version": "3.31.1",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
7
7
  "url": "https://github.com/descope/descope-js",
8
8
  "email": "help@descope.com"
9
9
  },
10
- "main": "dist/index.js",
11
- "module": "dist/esm/index.js",
10
+ "main": "dist/cjs/descope-wc/index.js",
11
+ "module": "dist/esm/descope-wc/index.js",
12
12
  "types": "dist/index.d.ts",
13
13
  "description": "Descope WC",
14
14
  "license": "MIT",
@@ -68,9 +68,9 @@
68
68
  "tslib": "2.6.3",
69
69
  "@fingerprintjs/fingerprintjs-pro": "3.9.9",
70
70
  "@descope/sdk-helpers": "0.1.60",
71
- "@descope/sdk-mixins": "0.5.0",
71
+ "@descope/web-js-sdk": "1.22.0",
72
72
  "@descope/escape-markdown": "0.1.1",
73
- "@descope/web-js-sdk": "1.21.0"
73
+ "@descope/sdk-mixins": "0.5.1"
74
74
  },
75
75
  "overrides": {
76
76
  "terser": "5.31.1"
@@ -1 +0,0 @@
1
- import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-3cc4a2cc.js";import"@descope/escape-markdown";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 m=document.createElement("template");m.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 f 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(m.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",f);export{f as default};
@@ -1 +0,0 @@
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{escapeMarkdown as a}from"@descope/escape-markdown";import{themeMixin as l}from"@descope/sdk-mixins";import{createSingletonMixin as d,compose as c}from"@descope/sdk-helpers";const u="undefined"!=typeof localStorage,h="J151000",p=u&&localStorage.getItem("base.content.url")||"",g="config.json",f="base.ui.components.url";u&&localStorage.getItem(f),u&&localStorage.getItem(f);const v="descope-login-flow",m="code",b="data-exclude-field",y="dls_last_auth",w="state_id",I="saml_idp_state_id",C="saml_idp_username",k="descope_idp_initiated",A="sso_app_id",S="third_party_app_id",E="oidc_login_hint",j="oidc_prompt",x="oidc_error_redirect_uri",O="data-type",U="redirect",L="poll",R="webauthnCreate",T="webauthnGet",$="nativeBridge",W="loadForm",P="submit",M="polling",N=["descope-multi-select-combo-box","descope-text-area"];var q;!function(t){t.backward="backward",t.forward="forward"}(q||(q={}));const _=["descope-enriched-text"];function V(t){return new URLSearchParams(window.location.search).get(t)}function D(t){if(window.history.replaceState&&V(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 F(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 K({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(p||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?q.forward:i<o?q.backward:void 0}const B=()=>{const[t="",e=""]=(V(v)||"").split("_");return{executionId:t,stepId:e}};function J(){D(v)}const G=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),z=()=>{const{executionId:t,stepId:e}=B();(t||e)&&J();const i=V("t")||void 0;i&&D("t");const o=V(m)||void 0;o&&D(m);const r=V("err")||void 0;r&&D("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:V("ra-challenge"),redirectAuthCallbackUrl:V("ra-callback"),redirectAuthBackupCallbackUri:V("ra-backup-callback"),redirectAuthInitiator:V("ra-initiator")},d=V(w);d&&D(w);const c=V(I);c&&D(I);const u=V(C);c&&D(C);const h=V(k);h&&D(k);const p=V(A);p&&D(A);const g=V(S);g&&D(S);const f=V(E);f&&D(E);const v=V(j);v&&D(j);const b=V(x);b&&D(x);return{executionId:t,stepId:e,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,thirdPartyAppId:g,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:v,oidcErrorRedirectUri:b}}},Q=t=>{let e,i;return Object.assign(((...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}),{reset:()=>{e=void 0,i=void 0}})};function X(t,e,i){return new Promise(((o,r)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==i?o(i):r(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{n||(clearTimeout(s),o(t))})).catch((t=>{n||(clearTimeout(s),r(t))}))}))}const Y=(t,{oidcIdpStateId:e,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||i||o||r||n||s||a),Z=t=>null==t?void 0:t.submit(),tt=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null},et=(t,e=100)=>{let i;return function(...o){i||t.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),e)}};function it(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}var ot,rt,nt,st;function at(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(!at(n,s))return!1}else if(n!==s)return!1}return!0}class lt{constructor(t={},{updateOnlyOnChange:o=!0}={}){ot.set(this,void 0),rt.set(this,{}),nt.set(this,0),st.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,ot,"f")):t,r=Object.assign(Object.assign({},e(this,ot,"f")),o);if(!e(this,st,"f")||!at(e(this,ot,"f"),r)){const t=e(this,ot,"f");i(this,ot,r,"f"),Object.freeze(e(this,ot,"f")),setTimeout((()=>{Object.values(e(this,rt,"f")).forEach((e=>e(r,t,((t,e)=>i=>t[i]!==e[i])(r,t))))}),0)}},i(this,ot,t,"f"),i(this,st,o,"f")}get current(){return Object.assign({},e(this,ot,"f"))}subscribe(t){return i(this,nt,e(this,nt,"f")+1,"f"),e(this,rt,"f")[e(this,nt,"f")]=t,e(this,nt,"f").toString()}unsubscribe(t){const i=!!e(this,rt,"f")[t];return i&&delete e(this,rt,"f")[t],i}unsubscribeAll(){return i(this,rt,{},"f"),!0}}ot=new WeakMap,rt=new WeakMap,nt=new WeakMap,st=new WeakMap;const dt=["disabled"],ct=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${b}])`)).forEach((t=>{t.value=i}))}))},ut=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ht=(t,e,i)=>t.replace(/{{(.+?)}}/g,((t,o)=>i?a(ut(e,o)):ut(e,o))),pt=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const i=(o=t.localName,_.includes(o));var o;t.textContent=ht(t.textContent,e,i);const r=t.getAttribute("href");r&&t.setAttribute("href",ht(r,e))}))},gt=(t,e,i)=>{t.querySelectorAll(`[${O}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},ft=(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})`))},vt=(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(`[${O}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),gt(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),gt(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),pt(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=ht(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])=>{dt.includes(e)&&t.setAttribute(e,i)}))}))}))})(t,o)},mt=Q((()=>t(void 0,void 0,void 0,(function*(){var t,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),o=(()=>{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 X(100,i,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),bt={"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 yt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(y)))}catch(t){}return e}const wt="dls_ab_testing_id",It=d((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})),Ct=document.createElement("template");Ct.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 kt=(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),kt(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 At,St,Et,jt,xt,Ot,Ut,Lt,Rt,Tt,$t,Wt,Pt,Mt,Nt,qt,_t,Vt,Dt,Ft,Kt;const Ht=c(l,It)(HTMLElement);class Bt extends Ht{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(),At.add(this),Et.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,At,"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)}},jt.set(this,new lt),xt.set(this,new lt),Ot.set(this,{}),this.getComponentsContext=()=>e(this,Ot,"f"),this.nextRequestStatus=new lt({isLoading:!1}),Ut.set(this,void 0),Lt.set(this,{popstate:e(this,At,"m",Wt).bind(this),componentsContext:e(this,At,"m",_t).bind(this)}),Rt.set(this,void 0),this.getConfig=Q((()=>t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:g,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield F(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,Rt,o,"f"),e(this,At,"m",Tt).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 kt(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}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();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()))}))}getComponentsVersion(){return t(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const o=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(t=o.init)||void 0===t?void 0:t.call(this),e(this,xt,"f").subscribe(e(this,At,"m",Dt).bind(this)),e(this,xt,"f").update({isDebug:this.debug}),e(this,At,"m",$t).call(this),yield e(this,At,"m",Nt).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 this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,At,"m",Kt).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,thirdPartyAppId:p,ssoQueryParams:g}=z();window.addEventListener("popstate",e(this,Lt,"f").popstate),window.addEventListener("components-context",e(this,Lt,"f").componentsContext),e(this,jt,"f").subscribe(e(this,At,"m",Mt).bind(this)),e(this,jt,"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,thirdPartyAppId:p},g)),i(this,Et,!0,"f")}))}disconnectedCallback(){e(this,jt,"f").unsubscribeAll(),e(this,xt,"f").unsubscribeAll(),e(this,At,"m",Vt).call(this),window.removeEventListener("popstate",e(this,Lt,"f").popstate),window.removeEventListener("components-context",e(this,Lt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,Et,"f")&&i!==o&&St.observedAttributes.includes(t)){e(this,At,"m",$t).call(this);const r=null===i;e(this,jt,"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,xt,"f").update({isDebug:this.debug})}}}function Jt(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue,he,pe,ge,fe,ve;St=Bt,Et=new WeakMap,jt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,Rt=new WeakMap,At=new WeakSet,Tt=function(){this.shadowRoot.appendChild(Ct.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},$t=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"];St.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[G(e)])throw Error(`${e} cannot be empty`)}))},Wt=function(){const{stepId:t,executionId:i}=B();e(this,jt,"f").update({stepId:t,executionId:i})},Pt=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},St.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:h,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Mt=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,At,"m",Pt).call(this,t,o)}e(this,Rt,"f").call(this,i)}))},Nt=function(){return t(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield e(this,At,"m",qt).call(this))}))},qt=function(){return t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:g,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield F(t,"json"),!0}catch(t){return!1}}))},_t=function(t){i(this,Ot,Object.assign(Object.assign({},e(this,Ot,"f")),t.detail),"f")},Vt=function(){var t;null===(t=e(this,Ut,"f"))||void 0===t||t.remove(),i(this,Ut,null,"f")},Dt=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Ut,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Ut,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-6fe609c2.js"),document.body.appendChild(e(this,Ut,"f"))):e(this,At,"m",Vt).call(this)}))},Ft=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Ut,"f"))||void 0===o||o.updateData({title:t,description:i}))},Kt=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=N.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()}}},Bt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.30.0"}};class me extends Bt{static set sdkConfigOverrides(t){Bt.sdkConfigOverrides=t}constructor(){const o=new lt({deferredRedirect:!1});super(o.update.bind(o)),Gt.add(this),this.stepState=new lt({},{updateOnlyOnChange:!1}),zt.set(this,void 0),Qt.set(this,null),Xt.set(this,{visibilitychange:e(this,Gt,"m",Yt).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const r=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=r;if(!t){t=null===(o=new URL(r.url).searchParams)||void 0===o?void 0:o.get(m)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(r.url),i=t.searchParams.get("t"),o=t.searchParams.get(v).split("_").pop();e(this,ee,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(r)},te.set(this,((o,r,n,s,a=!1)=>{if(this.flowState.current.action===L){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),d=a?500:2e3;i(this,zt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,r,M,n,s,{}),c=document.hidden&&!a&&Date.now()-l>d+500;let u;c&&this.logger.debug("polling - The polling seems to be throttled");try{const t=c?1e3:6e3;u=yield X(t,i)}catch(t){return this.logger.warn(`polling - The ${c?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,te,"f").call(this,o,r,n,s,c)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===h)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,te,"f").call(this,o,r,n,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),e(this,ie,"f").call(this,u),e(this,te,"f").call(this,o,r,n,s)}))),d),"f")}})),ee.set(this,(()=>{clearTimeout(e(this,zt,"f")),i(this,zt,null,"f")})),ie.set(this,(t=>{var i,o,r,n,s,a,l,d,c,h,p,g;if(!(null==t?void 0:t.ok)){const l=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${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}`;e(this,Gt,"m",ve).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:d,errorMessage:l}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||d);const c=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,Gt,"m",Zt).call(this))}null===(d=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.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 f=null===(p=null===(h=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${f?`${f} - `:""}${t.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:v,authInfo:m,lastAuth:b}=t.data;if("completed"===v)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&u&&localStorage.setItem(y,JSON.stringify(t))}(b),void e(this,Gt,"m",ve).call(this,"success",m);const{executionId:w,stepId:I,stepName:C,action:k,screen:A,redirect:S,openInNewTabUrl:E,webauthn:j,error:x,samlIdpResponse:O,nativeResponse:U}=t.data;k!==L?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${v}`,"",{screen:A,status:v,stepId:I,stepName:C,action:k,error:x}),this.flowState.update({stepId:I,executionId:w,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:E,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==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload})):this.flowState.update({action:k})})),oe.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)}}))))),he.set(this,et(((i,o)=>t(this,void 0,void 0,(function*(){var t,r;if("true"===i.getAttribute("formnovalidate")||e(this,Gt,"m",se).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,Gt,"m",le).call(this,i);const s=yield e(this,Gt,"m",ae).call(this),a=(r=i,Array.from((null==r?void 0:r.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}),{})),l=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(t=this.nativeOptions)||void 0===t?void 0:t.origin)||window.location.origin}),c=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield o(n,c.version,u.componentsVersion,d);e(this,ie,"f").call(this,h),e(this,Gt,"m",de).call(this,s)}}))))),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:{[Jt(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,Xt,"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,Qt,"f"))||void 0===t||t.abort(),i(this,Qt,null,"f"),window.removeEventListener("visibilitychange",e(this,Xt,"f").visibilitychange)}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t;const o=it(e),r=yield this.getTargetLocales();return r.includes(o.locale)?t=`${i}-${o.locale}.html`:r.includes(o.fallback)&&(t=`${i}-${o.fallback}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield F(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 F(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 d,c;const{projectId:u,flowId:h,tenant:p,stepId:g,executionId:f,action:v,screenId:m,screenState:b,redirectTo:y,openInNewTabUrl:w,redirectUrl:I,token:C,code:k,exchangeError:A,webauthnTransactionId:S,webauthnOptions:E,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:L,locale:M,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:_,nativeResponseType:V,nativePayload:D,thirdPartyAppId:F}=r,B=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","nativeResponseType","nativePayload","thirdPartyAppId"]);let J,G;const z=(()=>{const t=localStorage.getItem(wt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(wt,t.toString()),t}return Number(t)})(),Q=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),tt=yield this.getProjectConfig(),et=Object.entries(tt.flows||{}).reduce(((t,[e,i])=>(t[e]=i.version,t)),{}),ot=x&&j?{callbackUrl:x,codeChallenge:j,backupCallbackUri:O}:void 0,rt=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!f&&(this.loadSdkScripts(),X.fingerprintEnabled&&X.fingerprintKey?yield n(X.fingerprintKey,this.baseUrl):s(),X.conditions?({startScreenId:J,conditionInteractionId:G}=((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=bt[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:Q,code:k,token:C,abTestingKey:z},X.conditions)):X.condition?({startScreenId:J,conditionInteractionId:G}=((t,e)=>{var i;const o=null===(i=bt[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}})(X.condition,{loginId:Q,code:k,token:C,abTestingKey:z})):J=X.startScreenId,!Y(J,B))){const t=yield this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,redirectAuth:ot,thirdPartyAppId:F},B),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:yt(Q),abTestingKey:z,locale:it(M).locale,nativeOptions:rt}),G,"",tt.componentsVersion,et,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),B.descopeIdpInitiated&&{idpInitiated:!0}),C?{token:C}:{}),B.oidcLoginHint?{externalId:B.oidcLoginHint}:{}));return e(this,ie,"f").call(this,t),void("completed"!==(null===(d=null==t?void 0:t.data)||void 0===d?void 0:d.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&C||l("code")&&k||l("exchangeError")&&A)){const t=yield this.sdk.flow.next(f,g,P,X.version,tt.componentsVersion,{token:C,exchangeCode:k,exchangeError:A});return e(this,ie,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(v===W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!N||!q)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)})(N,q,_||"",Z)}if(v===U&&(l("redirectTo")||l("deferredRedirect")))return y?"android"===L&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(y):void this.loggerWrapper.error("Did not get redirect url");if(v===R||v===T){if(!S||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(c=e(this,Qt,"f"))||void 0===c||c.abort(),i(this,Qt,null,"f");try{t=v===R?yield this.sdk.webauthn.helpers.create(E):yield this.sdk.webauthn.helpers.get(E)}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(f,g,P,X.version,tt.componentsVersion,{transactionId:S,response:t,failure:o});e(this,ie,"f").call(this,r)}if(v===$)return this.nativeComplete=i=>t(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,g,P,X.version,tt.componentsVersion,i);e(this,ie,"f").call(this,t)})),void e(this,Gt,"m",ve).call(this,"bridge",{type:V,payload:D});if(e(this,te,"f").call(this,f,g,X.version,tt.componentsVersion),!m&&!J)return void this.loggerWrapper.warn("No screen was found to show");const nt=J||m,st=yield this.getHtmlFilenameWithLocale(M,nt),{oidcLoginHint:at,oidcPrompt:lt,oidcErrorRedirectUri:dt,samlIdpUsername:ct}=B,ut={direction:H(g,a.stepId),screenState:Object.assign(Object.assign({},b),{form:Object.assign(Object.assign({},this.formConfigValues),null==b?void 0:b.form),lastAuth:{loginId:Q,name:this.sdk.getLastUserDisplayName()||Q}}),htmlUrl:K({projectId:u,filename:`${nt}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:st&&K({projectId:u,filename:st,baseUrl:this.baseStaticUrl}),samlIdpUsername:ct,oidcLoginHint:at,oidcPrompt:lt,oidcErrorRedirectUri:dt,openInNewTabUrl:w},ht=yt(Q);Y(J,B)?ut.next=(t,e,i,o)=>this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,thirdPartyAppId:F,redirectAuth:ot},B),{lastAuth:ht,preview:this.preview,abTestingKey:z,client:this.client}),I&&{redirectUrl:I}),{locale:it(M).locale,nativeOptions:rt}),G,t,i,et,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),B.descopeIdpInitiated&&{idpInitiated:!0}),C&&{token:C})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(ut.next=(...t)=>this.sdk.flow.next(f,g,...t)),this.stepState.update(ut)}))}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,Gt,"m",ne).call(this,p,d):p.querySelectorAll(`descope-button[${O}="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),vt(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,ft(n,"descope-totp-image",s),((t,e)=>{ft(t,"descope-notp-image",e)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),((t,e,i,o)=>{i&&Object.keys(i).forEach((r=>{e.querySelector(r)||o.debug(`Skipping css vars for component "${r}}"`,`Got css vars for component ${r} but Could not find it on next page`);const n=customElements.get(r);n?Object.keys(i[r]).forEach((e=>{var s;const a=i[r],l=null===(s=null==n?void 0:n.cssVarList)||void 0===s?void 0:s[e];if(!l)return void o.info(`Could not find css variable name for ${e} in ${r}`,"Check if the css variable is defined in the component");const d=a[e];t.style.setProperty(l,d)})):o.info(`Could not find component class for ${r}`,"Check if the component is registered")}))})(r,p,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(p);const a=!o.htmlUrl;setTimeout((()=>{e(this,Gt,"m",ce).call(this),((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),((t,e)=>{ct(t,null==e?void 0:e.inputs),ct(t,null==e?void 0:e.form)})(this.rootElement,c)})),e(this,Gt,"m",ge).call(this,d),a&&e(this,Gt,"m",ve).call(this,"ready",{}),e(this,Gt,"m",ve).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${O}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(M,t.version,i.componentsVersion,{});e(this,ie,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Gt,"m",fe).call(this,v,l):v()}))}}zt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,ie=new WeakMap,oe=new WeakMap,he=new WeakMap,Gt=new WeakSet,Yt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Zt=function(){return t(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},re=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)}))}},ne=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,Qt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield mt())){const{options:o,transactionId:n}=(yield e(this,oe,"f").call(this))||{};if(o&&n){e(this,Gt,"m",re).call(this,s),i(this,Qt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Qt,"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,ie,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},se=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},ae=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})),{})}))},le=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},de=function(t={}){var e,i;const o=tt(t,["externalId","email","phone"]),r=tt(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)}},ce=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,Gt,"m",ue).call(this,t)))},ue=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const i=e.getAttribute("slot"),o=`input-${t.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",o),r.setAttribute("slot",i),t.appendChild(r),e.setAttribute("slot",o),this.appendChild(e)}))},pe=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,he,"f").call(this,i,t)}))}))},ge=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,he,"f").call(this,i,t)}})),e(this,Gt,"m",pe).call(this,t)},fe=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===q.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")},ve=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",me);export{me as D,lt as S};
package/dist/esm/index.js DELETED
@@ -1 +0,0 @@
1
- export{D as default}from"./index-3cc4a2cc.js";import"tslib";import"@descope/web-js-sdk";import"@descope/escape-markdown";import"@descope/sdk-mixins";import"@descope/sdk-helpers";