@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
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./general.js").IS_LOCAL_STORAGE&&localStorage.getItem("base.content.url")||"";exports.ASSETS_FOLDER="v2-beta",exports.BASE_CONTENT_URL="https://static.descope.com/pages",exports.CONFIG_FILENAME="config.json",exports.OVERRIDE_CONTENT_URL=e,exports.PREV_VER_ASSETS_FOLDER="v2-alpha";
@@ -0,0 +1 @@
1
+ "use strict";const E="undefined"!=typeof localStorage;exports.FETCH_ERROR_RESPONSE_ERROR_CODE="J151001",exports.FETCH_EXCEPTION_ERROR_CODE="J151000",exports.IS_LOCAL_STORAGE=E;
@@ -0,0 +1 @@
1
+ "use strict";var _=require("./content.js"),E=require("./uiComponents.js");exports.ASSETS_FOLDER=_.ASSETS_FOLDER,exports.BASE_CONTENT_URL=_.BASE_CONTENT_URL,exports.CONFIG_FILENAME=_.CONFIG_FILENAME,exports.OVERRIDE_CONTENT_URL=_.OVERRIDE_CONTENT_URL,exports.PREV_VER_ASSETS_FOLDER=_.PREV_VER_ASSETS_FOLDER,exports.UI_COMPONENTS_URL_KEY=E.UI_COMPONENTS_URL_KEY,exports.APPLICATION_SCOPES_PARAM_NAME="application_scopes",exports.CUSTOM_INTERACTIONS={submit:"submit",polling:"polling"},exports.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD="data-exclude-field",exports.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON="data-exclude-next",exports.DESCOPE_ATTRIBUTE_PREFIX="data-descope-",exports.DESCOPE_IDP_INITIATED_PARAM_NAME="descope_idp_initiated",exports.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY="dls_last_auth",exports.ELEMENTS_TO_IGNORE_ENTER_KEY_ON=["descope-multi-select-combo-box","descope-text-area"],exports.ELEMENT_TYPE_ATTRIBUTE="data-type",exports.HAS_DYNAMIC_VALUES_ATTR_NAME="data-has-dynamic-attr-values",exports.OIDC_ERROR_REDIRECT_URI_PARAM_NAME="oidc_error_redirect_uri",exports.OIDC_IDP_STATE_ID_PARAM_NAME="state_id",exports.OIDC_LOGIN_HINT_PARAM_NAME="oidc_login_hint",exports.OIDC_PROMPT_PARAM_NAME="oidc_prompt",exports.RESPONSE_ACTIONS={redirect:"redirect",poll:"poll",webauthnCreate:"webauthnCreate",webauthnGet:"webauthnGet",nativeBridge:"nativeBridge",loadForm:"loadForm"},exports.SAML_IDP_STATE_ID_PARAM_NAME="saml_idp_state_id",exports.SAML_IDP_USERNAME_PARAM_NAME="saml_idp_username",exports.SDK_SCRIPT_RESULTS_KEY="sdkScriptsResults",exports.SSO_APP_ID_PARAM_NAME="sso_app_id",exports.THIRD_PARTY_APP_ID_PARAM_NAME="third_party_app_id",exports.THIRD_PARTY_APP_STATE_ID_PARAM_NAME="third_party_app_state_id",exports.URL_CODE_PARAM_NAME="code",exports.URL_ERR_PARAM_NAME="err",exports.URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME="ra-backup-callback",exports.URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME="ra-callback",exports.URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME="ra-challenge",exports.URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME="ra-initiator",exports.URL_RUN_IDS_PARAM_NAME="descope-login-flow",exports.URL_TOKEN_PARAM_NAME="t";
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./general.js");const t="base.ui.components.url";e.IS_LOCAL_STORAGE&&localStorage.getItem(t),e.IS_LOCAL_STORAGE&&localStorage.getItem(t),exports.UI_COMPONENTS_URL_KEY=t;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("tslib");require("./constants/content.js"),require("./constants/uiComponents.js"),require("./types.js");var s=require("./helpers/state.js");require("@descope/escape-markdown"),require("./helpers/webauthn.js");var t,n,i,l,a,r,o,d,c,p,h=require("./helpers/positionHelpers.js");const g=document.createElement("template");g.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 v extends HTMLElement{constructor(){super(),t.add(this),n.set(this,new s({messages:[]})),i.set(this,void 0),l.set(this,void 0),a.set(this,void 0),r.set(this,{resize:e.__classPrivateFieldGet(this,t,"m",p).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(g.content.cloneNode(!0)),e.__classPrivateFieldSet(this,i,this.shadowRoot.querySelector(".debugger"),"f"),e.__classPrivateFieldSet(this,l,e.__classPrivateFieldGet(this,i,"f").querySelector(".content"),"f"),e.__classPrivateFieldSet(this,a,e.__classPrivateFieldGet(this,i,"f").querySelector(".header"),"f")}updateData(s){e.__classPrivateFieldGet(this,n,"f").update((e=>({messages:e.messages.concat(s)})))}connectedCallback(){h.dragElement(e.__classPrivateFieldGet(this,i,"f"),e.__classPrivateFieldGet(this,a,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e.__classPrivateFieldGet(this,r,"f").resize),h.addOnResize(e.__classPrivateFieldGet(this,i,"f")),e.__classPrivateFieldGet(this,i,"f").onresize=e.__classPrivateFieldGet(this,t,"m",c).bind(this),e.__classPrivateFieldGet(this,n,"f").subscribe(e.__classPrivateFieldGet(this,t,"m",o).bind(this))}disconnectedCallback(){e.__classPrivateFieldGet(this,n,"f").unsubscribeAll(),window.removeEventListener("resize",e.__classPrivateFieldGet(this,r,"f").resize)}}n=new WeakMap,i=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(s){e.__classPrivateFieldGet(this,t,"m",d).call(this,s),e.__classPrivateFieldGet(this,t,"m",c).call(this)},d=function(s){e.__classPrivateFieldGet(this,l,"f").innerHTML=s.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("")},c=function(){e.__classPrivateFieldGet(this,l,"f").querySelectorAll(".msg").forEach((e=>{const s=e.querySelector(".msg_desc"),t=s.scrollWidth>s.clientWidth,n=s.clientHeight>20;t||n?(e.classList.add("collapsible"),e.onclick=s=>{s.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},p=function(){const[s,t]=h.limitCoordinateToScreenBoundaries(e.__classPrivateFieldGet(this,i,"f"),Number.parseInt(e.__classPrivateFieldGet(this,i,"f").style.left,10),Number.parseInt(e.__classPrivateFieldGet(this,i,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e.__classPrivateFieldGet(this,i,"f").style.top=`${t}px`,e.__classPrivateFieldGet(this,i,"f").style.left=`${s}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",v),module.exports=v;
@@ -0,0 +1 @@
1
+ "use strict";var t=require("tslib"),e=require("@descope/web-js-sdk"),i=require("@descope/sdk-mixins/themeMixin"),r=require("@descope/sdk-helpers"),s=require("../constants/index.js"),o=require("../helpers/helpers.js"),n=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var a,l,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,k,x,E,I=require("../mixins/formMountMixin.js"),y=require("./initTemplate.js"),G=require("../helpers/flowInputs.js"),j=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const S=r.compose(i.themeMixin,I.formMountMixin)(HTMLElement);class M extends S{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(e){super(),a.add(this),u.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,a,"m",x).call(this,e,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)}},d.set(this,new n),c.set(this,new n),h.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,h,"f"),this.nextRequestStatus=new n({isLoading:!1}),g.set(this,void 0),f.set(this,{popstate:t.__classPrivateFieldGet(this,a,"m",b).bind(this),componentsContext:t.__classPrivateFieldGet(this,a,"m",A).bind(this)}),v.set(this,void 0),this.getConfig=o.withMemCache((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=o.getContentUrl({projectId:this.projectId,filename:j.CONFIG_FILENAME,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield o.fetchContent(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),t.__classPrivateFieldSet(this,v,e,"f"),t.__classPrivateFieldGet(this,a,"m",p).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 G.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return G.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return t.__awaiter(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.__awaiter(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 e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,a,"m",k).bind(this)),t.__classPrivateFieldGet(this,c,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,a,"m",_).call(this),yield t.__classPrivateFieldGet(this,a,"m",C).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");t.__classPrivateFieldGet(this,a,"m",E).call(this);const{executionId:r,stepId:s,token:n,code:l,exchangeError:h,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:p,redirectAuthInitiator:b,ssoQueryParams:m}=o.handleUrlParams();window.addEventListener("popstate",t.__classPrivateFieldGet(this,f,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,f,"f").componentsContext),t.__classPrivateFieldGet(this,d,"f").subscribe(t.__classPrivateFieldGet(this,a,"m",w).bind(this)),t.__classPrivateFieldGet(this,d,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:n,code:l,exchangeError:h,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:p,redirectAuthInitiator:b},m)),t.__classPrivateFieldSet(this,u,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,d,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,a,"m",P).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,f,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,f,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,u,"f")&&i!==r&&l.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,a,"m",_).call(this);const s=null===i;t.__classPrivateFieldGet(this,d,"f").update((({stepId:t,executionId:i})=>{let n=t,a=i;return s||(a=null,n=null,o.clearRunIdsFromUrl()),{[o.camelCase(e)]:r,stepId:n,executionId:a}})),t.__classPrivateFieldGet(this,c,"f").update({isDebug:this.debug})}}}l=M,u=new WeakMap,d=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,a=new WeakSet,p=function(){this.shadowRoot.appendChild(y.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},_=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"];l.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[o.camelCase(e)])throw Error(`${e} cannot be empty`)}))},b=function(){const{stepId:e,executionId:i}=o.getRunIdsFromUrl();t.__classPrivateFieldGet(this,d,"f").update({stepId:e,executionId:i})},m=function(i,r){this.sdk=e(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},l.sdkConfigOverrides),{projectId:i,baseUrl:r})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},w=function(e,i,r){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:s}=e;if(r("projectId")||r("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,a,"m",m).call(this,i,s)}t.__classPrivateFieldGet(this,v,"f").call(this,e)}))},C=function(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t.__classPrivateFieldGet(this,a,"m",F).call(this))}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=o.getContentUrl({projectId:this.projectId,filename:j.CONFIG_FILENAME,assetsFolder:j.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield o.fetchContent(t,"json"),!0}catch(t){return!1}}))},A=function(e){t.__classPrivateFieldSet(this,h,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,h,"f")),e.detail),"f")},P=function(){var e;null===(e=t.__classPrivateFieldGet(this,g,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,g,null,"f")},k=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,g,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,g,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return L(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,g,"f"))):t.__classPrivateFieldGet(this,a,"m",P).call(this)}))},x=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,g,"f"))||void 0===r||r.updateData({title:e,description:i}))},E=function(){this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=s.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},M.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.31.1"}},module.exports=M;
@@ -0,0 +1 @@
1
+ "use strict";var e,t,i,s,o,r,n,a,l,d,c,h,u,p,g,v,m,f,_,b,w,I,S,C=require("tslib"),E=require("@descope/web-js-sdk"),y=require("../constants/index.js"),O=require("../helpers/helpers.js"),P=require("../helpers/state.js"),R=require("../helpers/templates.js"),T=require("../helpers/webauthn.js"),A=require("../helpers/conditions.js"),F=require("../helpers/lastAuth.js"),k=require("../helpers/abTestingKey.js"),U=require("../types.js"),N=require("./BaseDescopeWc.js"),j=require("./sdkScripts/index.js"),x=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,_=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},r=function(){return C.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(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")}))},c=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},h=function(t,s){return C.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=C.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const r=t.querySelector('*[autocomplete="webauthn"]');if(r&&(yield T.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield C.__classPrivateFieldGet(this,d,"f").call(this))||{};if(t&&o){C.__classPrivateFieldGet(this,e,"m",c).call(this,r),C.__classPrivateFieldSet(this,i,new AbortController,"f");const n=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,C.__classPrivateFieldGet(this,i,"f")).then((e=>C.__awaiter(this,void 0,void 0,(function*(){const t=yield s(r.id,n.version,a.componentsVersion,{transactionId:o,response:e});C.__classPrivateFieldGet(this,l,"f").call(this,t)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},u=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},p=function(){return C.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>C.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},g=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},v=function(e={}){var t,i;const s=O.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=O.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},m=function(){O.clearPreviousExternalInputs();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>C.__classPrivateFieldGet(this,e,"m",f).call(this,t)))},f=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},b=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&C.__classPrivateFieldGet(this,_,"f").call(this,t,e)}))}))},w=function(t){this.rootElement.querySelectorAll(`descope-button:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{C.__classPrivateFieldGet(this,_,"f").call(this,e,t)}})),C.__classPrivateFieldGet(this,e,"m",b).call(this,t)},I=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===U.Direction.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},S=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends N{static set sdkConfigOverrides(e){N.sdkConfigOverrides=e}static get sdkConfigOverrides(){return N.sdkConfigOverrides}constructor(){const c=new P({deferredRedirect:!1});super(c.update.bind(c)),e.add(this),this.stepState=new P({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:C.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(y.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(y.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(y.URL_RUN_IDS_PARAM_NAME).split("_").pop();C.__classPrivateFieldGet(this,a,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},n.set(this,((e,i,s,o,r=!1)=>{if(this.flowState.current.action===y.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=r?500:2e3;C.__classPrivateFieldSet(this,t,setTimeout((()=>C.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,y.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!r&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield O.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void C.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===x.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void C.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o);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)),C.__classPrivateFieldGet(this,l,"f").call(this,u),C.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o)}))),d),"f")}})),a.set(this,(()=>{clearTimeout(C.__classPrivateFieldGet(this,t,"f")),C.__classPrivateFieldSet(this,t,null,"f")})),l.set(this,(t=>{var i,s,o,n,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;C.__classPrivateFieldGet(this,e,"m",S).call(this,"error",(null==t?void 0:t.error)||{errorCode:x.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||C.__classPrivateFieldGet(this,e,"m",r).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.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}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&F.setLastAuth(_),void C.__classPrivateFieldGet(this,e,"m",S).call(this,"success",f);const{executionId:b,stepId:w,stepName:I,action:E,screen:O,redirect:P,openInNewTabUrl:R,webauthn:T,error:A,samlIdpResponse:k,nativeResponse:U}=t.data;E!==y.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${I||`#${w}`}" is ${m}`,"",{screen:O,status:m,stepId:w,stepName:I,action:E,error:A}),this.flowState.update({stepId:w,executionId:b,action:E,redirectTo:null==P?void 0:P.url,openInNewTabUrl:R,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==k?void 0:k.url,samlIdpResponseSamlResponse:null==k?void 0:k.samlResponse,samlIdpResponseRelayState:null==k?void 0:k.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload})):this.flowState.update({action:E})})),d.set(this,O.withMemCache((()=>C.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),_.set(this,O.leadingDebounce(((t,i)=>C.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||C.__classPrivateFieldGet(this,e,"m",u).call(this)){const o=null==t?void 0:t.getAttribute("id");C.__classPrivateFieldGet(this,e,"m",g).call(this,t);const r=yield C.__classPrivateFieldGet(this,e,"m",p).call(this),n=O.getElementDescopeAttributes(t),a=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},a),n),r),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin}),c=yield this.getFlowConfig(),h=yield this.getProjectConfig(),u=yield i(o,c.version,h.componentsVersion,d);C.__classPrivateFieldGet(this,l,"f").call(this,u),C.__classPrivateFieldGet(this,e,"m",v).call(this,r)}}))))),this.flowState=c}loadSdkScripts(){return C.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>C.__awaiter(this,void 0,void 0,(function*(){(yield j.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[j.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return C.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",C.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=C.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),C.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",C.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return C.__awaiter(this,void 0,void 0,(function*(){let i;const s=O.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return C.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield O.fetchContent(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield O.fetchContent(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return C.__awaiter(this,void 0,void 0,(function*(){var r,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:g,screenId:v,screenState:m,redirectTo:f,openInNewTabUrl:_,redirectUrl:b,token:w,code:I,exchangeError:P,webauthnTransactionId:R,webauthnOptions:T,redirectAuthCodeChallenge:U,redirectAuthCallbackUrl:N,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:x,locale:G,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:q,nativeResponseType:D,nativePayload:M}=t,$=C.__rest(t,["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"]);let V,B;const K=k.getABTestingKey(),H=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Y=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),z=N&&U?{callbackUrl:N,codeChallenge:U,backupCallbackUri:j}:void 0,Q=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(!p&&(this.loadSdkScripts(),X.fingerprintEnabled&&X.fingerprintKey?yield E.ensureFingerprintIds(X.fingerprintKey,this.baseUrl):E.clearFingerprintData(),X.conditions?({startScreenId:V,conditionInteractionId:B}=A.calculateConditions({loginId:H,code:I,token:w,abTestingKey:K},X.conditions)):X.condition?({startScreenId:V,conditionInteractionId:B}=A.calculateCondition(X.condition,{loginId:H,code:I,token:w,abTestingKey:K})):V=X.startScreenId,!O.showFirstScreenOnExecutionInit(V,$))){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:F.getLastAuth(H),abTestingKey:K,locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,"",J.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return C.__classPrivateFieldGet(this,l,"f").call(this,e),void("completed"!==(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(o("token")&&w||o("code")&&I||o("exchangeError")&&P)){const e=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{token:w,exchangeCode:I,exchangeError:P});return C.__classPrivateFieldGet(this,l,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===y.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!L||!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");O.injectSamlIdpForm(L,W,q||"",O.submitForm)}if(g===y.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return f?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(f):void this.loggerWrapper.error("Did not get redirect url");if(g===y.RESPONSE_ACTIONS.webauthnCreate||g===y.RESPONSE_ACTIONS.webauthnGet){if(!R||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=C.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),C.__classPrivateFieldSet(this,i,null,"f");try{e=g===y.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{transactionId:R,response:e,failure:t});C.__classPrivateFieldGet(this,l,"f").call(this,s)}if(g===y.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>C.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,e);C.__classPrivateFieldGet(this,l,"f").call(this,t)})),void C.__classPrivateFieldGet(this,e,"m",S).call(this,"bridge",{type:D,payload:M});if(C.__classPrivateFieldGet(this,n,"f").call(this,p,u,X.version,J.componentsVersion),!v&&!V)return void this.loggerWrapper.warn("No screen was found to show");const Z=V||v,ee=yield this.getHtmlFilenameWithLocale(G,Z),{oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,samlIdpUsername:oe}=$,re={direction:O.getAnimationDirection(u,s.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlUrl:O.getContentUrl({projectId:d,filename:`${Z}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:ee&&O.getContentUrl({projectId:d,filename:ee,baseUrl:this.baseStaticUrl}),samlIdpUsername:oe,oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,openInNewTabUrl:_},ne=F.getLastAuth(H);O.showFirstScreenOnExecutionInit(V,$)?re.next=(e,t,i,s)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),b&&{redirectUrl:b}),{locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,e,i,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),s),I&&{exchangeCode:I,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(p,u,...e)),this.stepState.update(re)}))}onStepChange(t,i){return C.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlUrl:r,htmlLocaleUrl:n,direction:a,next:d,screenState:c,openInNewTabUrl:u}=t,p=document.createElement("template");p.innerHTML=yield this.getPageContent(r,n);const g=p.content.cloneNode(!0),v=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield C.__classPrivateFieldGet(this,e,"m",h).call(this,g,d):R.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),R.updateTemplateFromScreenState(g,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();R.setPhoneAutoDetectDefaultCode(g,f);const _=()=>C.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.shadowRoot.querySelector("div");R.setTOTPVariable(o,null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),R.setNOTPVariable(o,null===(s=null==c?void 0:c.notp)||void 0===s?void 0:s.image),R.setCssVars(o,g,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(g);const r=!i.htmlUrl;setTimeout((()=>{C.__classPrivateFieldGet(this,e,"m",m).call(this),O.handleAutoFocus(this.rootElement,this.autoFocus,r),this.validateOnBlur&&O.handleReportValidityOnBlur(this.rootElement),R.updateScreenFromScreenState(this.rootElement,c)})),C.__classPrivateFieldGet(this,e,"m",w).call(this,d),r&&C.__classPrivateFieldGet(this,e,"m",S).call(this,"ready",{}),C.__classPrivateFieldGet(this,e,"m",S).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${y.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),i=yield d(y.CUSTOM_INTERACTIONS.polling,e.version,t.componentsVersion,{});C.__classPrivateFieldGet(this,l,"f").call(this,i)}u&&!i.openInNewTabUrl&&window.open(u,"_blank")}));a?C.__classPrivateFieldGet(this,e,"m",I).call(this,_,a):_()}))}};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./DescopeWc.js");customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",e),module.exports=e;
@@ -0,0 +1 @@
1
+ "use strict";const t=document.createElement("template");t.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",module.exports=t;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@fingerprintjs/fingerprintjs-pro");const r=(r,i,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:i,cloudflareScriptUrl:o,cloudflareEndpointUrl:l}=r;let a=[];a=i&&l?[l,t.defaultEndpoint]:[t.defaultEndpoint];let d=[];if(i&&o){const e=new URL(o);d=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,t.defaultScriptUrlPattern]}else d=[t.defaultScriptUrlPattern];const p=t.load({apiKey:e,endpoint:a,scriptUrlPattern:d}),s=yield p,{requestId:u}=yield s.get();n(u)}catch(e){console.warn("Could not load fingerprint",e)}}));exports.default=r,exports.loadFingerprint=r;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@fingerprintjs/fingerprintjs-pro");const r=(r,o,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{customDomain:e,publicApiKey:n,cloudflareEndpointPath:a,cloudflareScriptPath:p}=r,{baseUrl:s}=o;let d;d=e?`https://${e}`:s||"https://api.descope.com";const l=new URL(d);l.pathname=a;const c=new URL(d);c.pathname=p;const u=`${c.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,f=t.load({apiKey:n,endpoint:[l.toString(),t.defaultEndpoint],scriptUrlPattern:[u,t.defaultScriptUrlPattern]}),y=yield f,{requestId:g}=yield y.get();i(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));exports.default=r,exports.loadFingerprint=r;
@@ -0,0 +1 @@
1
+ "use strict";var t=require("tslib");const n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';module.exports=(e,r,o)=>t.__awaiter(void 0,void 0,void 0,(function*(){const{siteId:t}=e,r=n.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=r,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}));
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("../../constants/index.js");function t(e){return Object.freeze({__proto__:null,default:e})}exports.default=function(r){return e.__awaiter(this,void 0,void 0,(function*(){let e;switch(r){case"forter":return e=yield Promise.resolve().then((function(){return t(require("./forter.js"))})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return require("./fingerprint.js")})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return require("./fingerprintDescope.js")})),e.default;default:throw new Error(`Unknown script id: ${r}`)}}))},exports.getScriptResultPath=function(e,t){const n=t?`${e}_${t}`:e;return`${r.SDK_SCRIPT_RESULTS_KEY}.${n}`};
@@ -0,0 +1 @@
1
+ "use strict";const t="dls_ab_testing_id";exports.getABTestingKey=()=>{const e=localStorage.getItem(t);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(t,e.toString()),e}return Number(e)};
@@ -0,0 +1 @@
1
+ "use strict";const t={"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}};exports.calculateCondition=(e,n)=>{var i;const o=null===(i=t[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!o)return{};const r=o(n,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}},exports.calculateConditions=(e,n)=>{const i=null==n?void 0:n.find((({key:n,operator:i,predicate:o})=>{var r;if("ELSE"===n)return!0;const d=null===(r=t[n])||void 0===r?void 0:r[i];return!!(null==d?void 0:d(e,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}};
@@ -0,0 +1 @@
1
+ "use strict";const e=(t,r="")=>Object.keys(t).reduce(((s,a)=>{var c;if("object"==typeof t[a]&&null!==t[a]&&!(null===(c=t[a])||void 0===c?void 0:c.value))return Object.assign(Object.assign({},s),e(t[a],`${r+a}.`));const n="object"==typeof t[a]?t[a]:{value:t[a]},o=Object.assign(Object.assign({},s),{[r+a]:n,[`form.${r}${a}`]:n});return"displayName"===a?Object.assign(Object.assign({},o),{[`${r}fullName`]:n,[`form.${r}fullName`]:n}):o}),[]);exports.extractNestedAttribute=(e,t)=>Object.fromEntries(Object.entries(e).map((([e,r])=>[e,r[t]]))),exports.transformFlowInputFormData=t=>{try{return e(JSON.parse(t))}catch(e){return{}}};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("tslib"),r=require("../constants/index.js"),t=require("../types.js"),o=require("../constants/content.js");const n=["descope-enriched-text"];function a(e){return new URLSearchParams(window.location.search).get(e)}function i(e){if(window.history.replaceState&&a(e)){const r=new URL(window.location.href),t=new URLSearchParams(r.search);t.delete(e),r.search=t.toString(),window.history.replaceState({},"",r.toString())}}const c=()=>{const[e="",t=""]=(a(r.URL_RUN_IDS_PARAM_NAME)||"").split("_");return{executionId:e,stepId:t}};function s(){i(r.URL_RUN_IDS_PARAM_NAME)}function A(){return a(r.URL_TOKEN_PARAM_NAME)||void 0}function l(){i(r.URL_TOKEN_PARAM_NAME)}function u(){return a(r.URL_CODE_PARAM_NAME)||void 0}function _(){return a(r.URL_ERR_PARAM_NAME)||void 0}function d(){i(r.URL_CODE_PARAM_NAME)}function p(){i(r.URL_ERR_PARAM_NAME)}function P(){return{redirectAuthCodeChallenge:a(r.URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME),redirectAuthCallbackUrl:a(r.URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME),redirectAuthBackupCallbackUri:a(r.URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME),redirectAuthInitiator:a(r.URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME)}}function m(){return a(r.OIDC_IDP_STATE_ID_PARAM_NAME)}function I(){i(r.OIDC_IDP_STATE_ID_PARAM_NAME)}function R(){return a(r.SAML_IDP_STATE_ID_PARAM_NAME)}function E(){i(r.SAML_IDP_STATE_ID_PARAM_NAME)}function M(){return a(r.SAML_IDP_USERNAME_PARAM_NAME)}function U(){i(r.SAML_IDP_USERNAME_PARAM_NAME)}function C(){return a(r.DESCOPE_IDP_INITIATED_PARAM_NAME)}function D(){i(r.DESCOPE_IDP_INITIATED_PARAM_NAME)}function h(){return a(r.SSO_APP_ID_PARAM_NAME)}function f(){return a(r.THIRD_PARTY_APP_ID_PARAM_NAME)}function S(){i(r.SSO_APP_ID_PARAM_NAME)}function T(){i(r.THIRD_PARTY_APP_ID_PARAM_NAME)}function x(){return a(r.THIRD_PARTY_APP_STATE_ID_PARAM_NAME)}function N(){i(r.THIRD_PARTY_APP_STATE_ID_PARAM_NAME)}function g(){return a(r.APPLICATION_SCOPES_PARAM_NAME)}function L(){i(r.APPLICATION_SCOPES_PARAM_NAME)}function O(){return a(r.OIDC_LOGIN_HINT_PARAM_NAME)}function v(){i(r.OIDC_LOGIN_HINT_PARAM_NAME)}function F(){return a(r.OIDC_PROMPT_PARAM_NAME)}function y(){i(r.OIDC_PROMPT_PARAM_NAME)}function b(){return a(r.OIDC_ERROR_REDIRECT_URI_PARAM_NAME)}function w(){i(r.OIDC_ERROR_REDIRECT_URI_PARAM_NAME)}exports.camelCase=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),exports.clearApplicationScopesParamFromUrl=L,exports.clearCodeFromUrl=d,exports.clearDescopeIDPInitiatedParamFromUrl=D,exports.clearExchangeErrorFromUrl=p,exports.clearOIDCErrorRedirectUriParamFromUrl=w,exports.clearOIDCIDPParamFromUrl=I,exports.clearOIDCLoginHintParamFromUrl=v,exports.clearOIDCPromptParamFromUrl=y,exports.clearPreviousExternalInputs=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()))},exports.clearRunIdsFromUrl=s,exports.clearSAMLIDPParamFromUrl=E,exports.clearSAMLIDPUsernameParamFromUrl=U,exports.clearSSOAppIdParamFromUrl=S,exports.clearThirdPartyAppIdParamFromUrl=T,exports.clearThirdPartyAppStateIdParamFromUrl=N,exports.clearTokenFromUrl=l,exports.createIsChanged=(e,r)=>t=>e[t]!==r[t],exports.fetchContent=function(r,t){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield fetch(r,{cache:"default"});if(!e.ok)throw Error(`Error fetching URL ${r} [${e.status}]`);return{body:yield e[t||"text"](),headers:Object.fromEntries(e.headers.entries())}}))},exports.getAnimationDirection=function(e,r){if(!r)return;const o=+e,n=+r;return Number.isNaN(o)||Number.isNaN(n)?void 0:o>n?t.Direction.forward:o<n?t.Direction.backward:void 0},exports.getApplicationScopesParamFromUrl=g,exports.getChromiumVersion=()=>{var e;const r=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,t=null==r?void 0:r.find((({brand:e,version:r})=>"Chromium"===e&&parseFloat(r)));return t?t.version:0},exports.getCodeFromUrl=u,exports.getContentUrl=function({projectId:e,filename:r,assetsFolder:t=o.ASSETS_FOLDER,baseUrl:n}){const a=new URL(o.OVERRIDE_CONTENT_URL||n||o.BASE_CONTENT_URL);return a.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(a.pathname,e,t,r),a.toString()},exports.getDescopeIDPInitiatedParamFromUrl=C,exports.getElementDescopeAttributes=e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var o;const n=null===(o=new RegExp(`^${r.DESCOPE_ATTRIBUTE_PREFIX}(\\S+)$`).exec(t.name))||void 0===o?void 0:o[1];return n?Object.assign(e,{[n]:t.value}):e}),{}),exports.getExchangeErrorFromUrl=_,exports.getFirstNonEmptyValue=(e,r)=>{const t=r.find((r=>e[r]));return t?e[t]:null},exports.getOIDCErrorRedirectUriParamFromUrl=b,exports.getOIDCIDPParamFromUrl=m,exports.getOIDCLoginHintParamFromUrl=O,exports.getOIDCPromptParamFromUrl=F,exports.getRedirectAuthFromUrl=P,exports.getRunIdsFromUrl=c,exports.getSAMLIDPParamFromUrl=R,exports.getSAMLIDPUsernameParamFromUrl=M,exports.getSSOAppIdParamFromUrl=h,exports.getThirdPartyAppIdParamFromUrl=f,exports.getThirdPartyAppStateIdParamFromUrl=x,exports.getTokenFromUrl=A,exports.getUserLocale=function(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const r=navigator.language;return r?r.includes("-")?{locale:r.toLowerCase(),fallback:r.split("-")[0].toLowerCase()}:{locale:r.toLowerCase(),fallback:r.toLowerCase()}:{locale:"",fallback:""}},exports.handleAutoFocus=(e,r,t)=>{if(!0===r||"skipFirstScreen"===r&&!t){const r=e.querySelector("*[name]");setTimeout((()=>{null==r||r.focus()}))}},exports.handleReportValidityOnBlur=e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var r;const t=e.focus;e.focus=()=>{},null===(r=e.reportValidity)||void 0===r||r.call(e),setTimeout((()=>{e.focus=t}))}))}))},exports.handleUrlParams=()=>{const{executionId:e,stepId:r}=c();(e||r)&&s();const t=A();t&&l();const o=u();o&&d();const n=_();n&&p();const{redirectAuthCodeChallenge:a,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:k,redirectAuthInitiator:H}=P(),B=m();B&&I();const j=R();j&&E();const q=M();j&&U();const $=C();$&&D();const K=h();K&&S();const V=f();V&&T();const G=x();G&&N();const Y=g();Y&&L();const Q=O();Q&&v();const X=F();X&&y();const z=b();z&&w();return{executionId:e,stepId:r,token:t,code:o,exchangeError:n,redirectAuthCodeChallenge:a,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:k,redirectAuthInitiator:H,ssoQueryParams:{oidcIdpStateId:B,samlIdpStateId:j,samlIdpUsername:q,descopeIdpInitiated:"true"===$,ssoAppId:K,oidcLoginHint:Q,oidcPrompt:X,oidcErrorRedirectUri:z,thirdPartyAppId:V,thirdPartyAppStateId:G,applicationScopes:Y}}},exports.injectSamlIdpForm=(e,r,t,o)=>{const n=document.createElement("form");n.method="POST",n.action=e,n.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${r}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${t}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(n),o(n)},exports.isChromium=function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},exports.leadingDebounce=(e,r=100)=>{let t;return function(...o){t||e.apply(this,o),clearTimeout(t),t=setTimeout((()=>{t=null}),r)}},exports.shouldHandleMarkdown=e=>n.includes(e),exports.showFirstScreenOnExecutionInit=(e,{oidcIdpStateId:r,samlIdpStateId:t,samlIdpUsername:o,ssoAppId:n,oidcLoginHint:a,oidcPrompt:i,oidcErrorRedirectUri:c,thirdPartyAppId:s,thirdPartyAppStateId:A,applicationScopes:l})=>!(!e||r||t||o||n||a||i||c||s||A||l),exports.submitForm=e=>null==e?void 0:e.submit(),exports.timeoutPromise=function(e,r,t){return new Promise(((o,n)=>{let a=!1;const i=setTimeout((()=>{a=!0,void 0!==t?o(t):n(new Error(`Promise timed out after ${e} ms`))}),e);r.then((e=>{a||(clearTimeout(i),o(e))})).catch((e=>{a||(clearTimeout(i),n(e))}))}))},exports.withMemCache=e=>{let r,t;return Object.assign(((...o)=>{return r&&(a=o,(n=r).length===a.length&&n.every(((e,r)=>e===a[r])))||(r=o,t=e(...o)),t;var n,a}),{reset:()=>{r=void 0,t=void 0}})};
@@ -0,0 +1 @@
1
+ "use strict";var t=require("../constants/index.js"),e=require("../constants/general.js");exports.getLastAuth=function(e){const s={};if(e)try{Object.assign(s,JSON.parse(localStorage.getItem(t.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY)))}catch(t){}return s},exports.setLastAuth=function(s){(null==s?void 0:s.authMethod)&&e.IS_LOCAL_STORAGE&&localStorage.setItem(t.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY,JSON.stringify(s))};
@@ -0,0 +1 @@
1
+ "use strict";const t=(t,e,o,n={})=>{var i,l,f,s;return[Math.min(Math.max(e,("all"===n.left?t.offsetWidth:null!==(i=n.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===n.right?t.offsetWidth:null!==(l=n.right)&&void 0!==l?l:0)),Math.min(Math.max(o,("all"===n.top?t.offsetHeight:null!==(f=n.top)&&void 0!==f?f:0)-t.offsetHeight),window.innerHeight-("all"===n.bottom?t.offsetHeight:null!==(s=n.bottom)&&void 0!==s?s:0))]};exports.addOnResize=t=>{t.onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight}},exports.dragElement=(e,o,n)=>{let i=0,l=0,f=0,s=0;function r(o){o.preventDefault(),i=f-o.clientX,l=s-o.clientY,f=o.clientX,s=o.clientY;const[r,a]=t(e,e.offsetLeft-i,e.offsetTop-l,n);e.style.top=`${a}px`,e.style.left=`${r}px`}function a(){document.onmouseup=null,document.onmousemove=null}function u(t){t.preventDefault(),f=t.clientX,s=t.clientY,document.onmouseup=a,document.onmousemove=r}o?o.onmousedown=u:e.onmousedown=u},exports.limitCoordinateToScreenBoundaries=t;
@@ -0,0 +1 @@
1
+ "use strict";var e,t,s,i,r=require("tslib"),a=require("./helpers.js");function l(e,t){const s=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(s.length!==i.length)return!1;for(let i=0;i<s.length;i+=1){const r=s[i],a=e[r],c=t[r];if(null===a||null===c){if(a!==c)return!1}else if("object"==typeof a&&"object"==typeof c){if(!l(a,c))return!1}else if(a!==c)return!1}return!0}e=new WeakMap,t=new WeakMap,s=new WeakMap,i=new WeakMap,module.exports=class{constructor(c={},{updateOnlyOnChange:n=!0}={}){e.set(this,void 0),t.set(this,{}),s.set(this,0),i.set(this,!1),this.update=s=>{const c="function"==typeof s?s(r.__classPrivateFieldGet(this,e,"f")):s,n=Object.assign(Object.assign({},r.__classPrivateFieldGet(this,e,"f")),c);if(!r.__classPrivateFieldGet(this,i,"f")||!l(r.__classPrivateFieldGet(this,e,"f"),n)){const s=r.__classPrivateFieldGet(this,e,"f");r.__classPrivateFieldSet(this,e,n,"f"),Object.freeze(r.__classPrivateFieldGet(this,e,"f")),setTimeout((()=>{Object.values(r.__classPrivateFieldGet(this,t,"f")).forEach((e=>e(n,s,a.createIsChanged(n,s))))}),0)}},r.__classPrivateFieldSet(this,e,c,"f"),r.__classPrivateFieldSet(this,i,n,"f")}get current(){return Object.assign({},r.__classPrivateFieldGet(this,e,"f"))}subscribe(e){return r.__classPrivateFieldSet(this,s,r.__classPrivateFieldGet(this,s,"f")+1,"f"),r.__classPrivateFieldGet(this,t,"f")[r.__classPrivateFieldGet(this,s,"f")]=e,r.__classPrivateFieldGet(this,s,"f").toString()}unsubscribe(e){const s=!!r.__classPrivateFieldGet(this,t,"f")[e];return s&&delete r.__classPrivateFieldGet(this,t,"f")[e],s}unsubscribeAll(){return r.__classPrivateFieldSet(this,t,{},"f"),!0}};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@descope/escape-markdown"),t=require("../constants/index.js"),r=require("./helpers.js");const o=["disabled"],s=(e,r)=>{Object.entries(r||{}).forEach((([r,o])=>{Array.from(e.querySelectorAll(`*[name="${r}"]:not([${t.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`)).forEach((e=>{e.value=o}))}))},l=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),n=(t,r,o)=>t.replace(/{{(.+?)}}/g,((t,s)=>o?e.escapeMarkdown(l(r,s)):l(r,s))),c=(e,r,o)=>{e.querySelectorAll(`[${t.ELEMENT_TYPE_ATTRIBUTE}="${r}"]`).forEach((e=>{e.setAttribute("href",o)}))},i=(e,t,r)=>{var o,s;const l=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;r&&l&&(null===(s=null==e?void 0:e.style)||void 0===s||s.setProperty(l,`url(data:image/jpg;base64,${r})`))};exports.disableWebauthnButtons=e=>{e.querySelectorAll(`descope-button[${t.ELEMENT_TYPE_ATTRIBUTE}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))},exports.setCssVars=(e,t,r,o)=>{r&&Object.keys(r).forEach((s=>{t.querySelector(s)||o.debug(`Skipping css vars for component "${s}}"`,`Got css vars for component ${s} but Could not find it on next page`);const l=customElements.get(s);l?Object.keys(r[s]).forEach((t=>{var n;const c=r[s],i=null===(n=null==l?void 0:l.cssVarList)||void 0===n?void 0:n[t];if(!i)return void o.info(`Could not find css variable name for ${t} in ${s}`,"Check if the css variable is defined in the component");const a=c[t];e.style.setProperty(i,a)})):o.info(`Could not find component class for ${s}`,"Check if the component is registered")}))},exports.setNOTPVariable=(e,t)=>{i(e,"descope-notp-image",t)},exports.setPhoneAutoDetectDefaultCode=(e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))},exports.setTOTPVariable=(e,t)=>{i(e,"descope-totp-image",t)},exports.updateScreenFromScreenState=(e,t)=>{s(e,null==t?void 0:t.inputs),s(e,null==t?void 0:t.form)},exports.updateTemplateFromScreenState=(e,s,l,i,a,u)=>{var d,p;let f=null==s?void 0:s.errorText;try{f=(null==a?void 0:a({text:null==s?void 0:s.errorText,type:null==s?void 0:s.errorType}))||(null==s?void 0:s.errorText)}catch(e){u.error("Error transforming error message",e.message)}((e,r,o="")=>{e.querySelectorAll(`[${t.ELEMENT_TYPE_ATTRIBUTE}="${r}"]`).forEach((e=>{e.textContent=o,e.classList[o?"remove":"add"]("hide")}))})(e,"error-message",f),c(e,"totp-link",null===(d=null==s?void 0:s.totp)||void 0===d?void 0:d.provisionUrl),c(e,"notp-link",null===(p=null==s?void 0:s.notp)||void 0===p?void 0:p.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=r.shouldHandleMarkdown(e.localName);e.textContent=n(e.textContent,t,o);const s=e.getAttribute("href");s&&e.setAttribute("href",n(s,t))}))})(e,s),((e,t,r)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const s=t[o];Object.keys(s).forEach((t=>{let o=s[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){r.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,l,u),((e,r)=>{e.querySelectorAll(`[${t.HAS_DYNAMIC_VALUES_ATTR_NAME}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=n(e.value,r)}))}))})(e,s),((e,t)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(r).forEach((([t,r])=>{o.includes(t)&&e.setAttribute(t,r)}))}))}))})(e,i)};
@@ -0,0 +1 @@
1
+ "use strict";var i=require("tslib"),e=require("./helpers.js");const o=e.withMemCache((()=>i.__awaiter(void 0,void 0,void 0,(function*(){var i,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(i=window.PublicKeyCredential)||void 0===i?void 0:i.isConditionalMediationAvailable(),null===(o=window.PublicKeyCredential)||void 0===o?void 0:o.isUserVerifyingPlatformAuthenticatorAvailable()]).then((i=>i.every((i=>!!i)))),t=e.getChromiumVersion()>=108;return yield e.timeoutPromise(100,r,t)}catch(i){return console.error("Conditional login check failed",i),!1}}))));exports.isConditionalLoginSupported=o;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),s=require("../helpers/helpers.js");require("../helpers/state.js"),require("@descope/escape-markdown"),require("../constants/content.js"),require("../constants/uiComponents.js"),require("../helpers/webauthn.js");const r=t.createSingletonMixin((t=>{var r,i,n,o;return o=class extends t{constructor(){super(...arguments),r.add(this)}connectedCallback(){var t;e.__classPrivateFieldGet(this,r,"m",i).call(this)&&e.__classPrivateFieldGet(this,r,"m",n).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},r=new WeakSet,i=function(){return!this.shadowRoot.host.closest("form")&&s.isChromium()},n=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o}));exports.formMountMixin=r;
@@ -0,0 +1 @@
1
+ "use strict";var r;exports.Direction=void 0,(r=exports.Direction||(exports.Direction={})).backward="backward",r.forward="forward";
@@ -0,0 +1 @@
1
+ import{IS_LOCAL_STORAGE as t}from"./general.js";const e=t&&localStorage.getItem("base.content.url")||"",o="https://static.descope.com/pages",a="v2-beta",s="v2-alpha",c="config.json";export{a as ASSETS_FOLDER,o as BASE_CONTENT_URL,c as CONFIG_FILENAME,e as OVERRIDE_CONTENT_URL,s as PREV_VER_ASSETS_FOLDER};
@@ -0,0 +1 @@
1
+ const e="undefined"!=typeof localStorage,o="J151000",t="J151001";export{t as FETCH_ERROR_RESPONSE_ERROR_CODE,o as FETCH_EXCEPTION_ERROR_CODE,e as IS_LOCAL_STORAGE};
@@ -0,0 +1 @@
1
+ export{ASSETS_FOLDER,BASE_CONTENT_URL,CONFIG_FILENAME,OVERRIDE_CONTENT_URL,PREV_VER_ASSETS_FOLDER}from"./content.js";export{UI_COMPONENTS_URL_KEY}from"./uiComponents.js";const e="descope-login-flow",t="t",a="code",i="err",d="ra-challenge",o="ra-callback",_="ra-backup-callback",r="ra-initiator",p="data-descope-",l="data-exclude-field",s="data-exclude-next",c="dls_last_auth",n="state_id",u="saml_idp_state_id",E="saml_idp_username",m="descope_idp_initiated",b="sso_app_id",h="third_party_app_id",R="third_party_app_state_id",S="oidc_login_hint",x="oidc_prompt",N="oidc_error_redirect_uri",O="application_scopes",g="data-type",C="sdkScriptsResults",T={redirect:"redirect",poll:"poll",webauthnCreate:"webauthnCreate",webauthnGet:"webauthnGet",nativeBridge:"nativeBridge",loadForm:"loadForm"},F={submit:"submit",polling:"polling"},L="data-has-dynamic-attr-values",w=["descope-multi-select-combo-box","descope-text-area"];export{O as APPLICATION_SCOPES_PARAM_NAME,F as CUSTOM_INTERACTIONS,l as DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,s as DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON,p as DESCOPE_ATTRIBUTE_PREFIX,m as DESCOPE_IDP_INITIATED_PARAM_NAME,c as DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY,w as ELEMENTS_TO_IGNORE_ENTER_KEY_ON,g as ELEMENT_TYPE_ATTRIBUTE,L as HAS_DYNAMIC_VALUES_ATTR_NAME,N as OIDC_ERROR_REDIRECT_URI_PARAM_NAME,n as OIDC_IDP_STATE_ID_PARAM_NAME,S as OIDC_LOGIN_HINT_PARAM_NAME,x as OIDC_PROMPT_PARAM_NAME,T as RESPONSE_ACTIONS,u as SAML_IDP_STATE_ID_PARAM_NAME,E as SAML_IDP_USERNAME_PARAM_NAME,C as SDK_SCRIPT_RESULTS_KEY,b as SSO_APP_ID_PARAM_NAME,h as THIRD_PARTY_APP_ID_PARAM_NAME,R as THIRD_PARTY_APP_STATE_ID_PARAM_NAME,a as URL_CODE_PARAM_NAME,i as URL_ERR_PARAM_NAME,_ as URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,o as URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,d as URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,r as URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,e as URL_RUN_IDS_PARAM_NAME,t as URL_TOKEN_PARAM_NAME};
@@ -0,0 +1 @@
1
+ import{IS_LOCAL_STORAGE as e}from"./general.js";const o="base.ui.components.url";e&&localStorage.getItem(o),e&&localStorage.getItem(o);export{o as UI_COMPONENTS_URL_KEY};
@@ -0,0 +1 @@
1
+ import{__classPrivateFieldGet as n,__classPrivateFieldSet as e}from"tslib";import"./constants/content.js";import"./constants/uiComponents.js";import"./types.js";import t from"./helpers/state.js";import"@descope/escape-markdown";import"./helpers/webauthn.js";import{dragElement as s,addOnResize as i,limitCoordinateToScreenBoundaries as o}from"./helpers/positionHelpers.js";var l,r,a,d,p,c,h,g,m,f;const x=document.createElement("template");x.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 b extends HTMLElement{constructor(){super(),l.add(this),r.set(this,new t({messages:[]})),a.set(this,void 0),d.set(this,void 0),p.set(this,void 0),c.set(this,{resize:n(this,l,"m",f).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(x.content.cloneNode(!0)),e(this,a,this.shadowRoot.querySelector(".debugger"),"f"),e(this,d,n(this,a,"f").querySelector(".content"),"f"),e(this,p,n(this,a,"f").querySelector(".header"),"f")}updateData(e){n(this,r,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){s(n(this,a,"f"),n(this,p,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,c,"f").resize),i(n(this,a,"f")),n(this,a,"f").onresize=n(this,l,"m",m).bind(this),n(this,r,"f").subscribe(n(this,l,"m",h).bind(this))}disconnectedCallback(){n(this,r,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,c,"f").resize)}}r=new WeakMap,a=new WeakMap,d=new WeakMap,p=new WeakMap,c=new WeakMap,l=new WeakSet,h=function(e){n(this,l,"m",g).call(this,e),n(this,l,"m",m).call(this)},g=function(e){n(this,d,"f").innerHTML=e.messages.map((n=>`\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 ${n.title}\n </div>\n <div class="msg_desc">\n ${n.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},m=function(){n(this,d,"f").querySelectorAll(".msg").forEach((n=>{const e=n.querySelector(".msg_desc"),t=e.scrollWidth>e.clientWidth,s=e.clientHeight>20;t||s?(n.classList.add("collapsible"),n.onclick=e=>{e.target.classList.contains("msg_desc")||n.classList.toggle("collapsed")}):(n.classList.remove("collapsible"),n.onclick=null)}))},f=function(){const[e,t]=o(n(this,a,"f"),Number.parseInt(n(this,a,"f").style.left,10),Number.parseInt(n(this,a,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,a,"f").style.top=`${t}px`,n(this,a,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",b);export{b as default};
@@ -0,0 +1 @@
1
+ import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import r from"@descope/web-js-sdk";import{themeMixin as s}from"@descope/sdk-mixins/themeMixin";import{compose as o}from"@descope/sdk-helpers";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as n}from"../constants/index.js";import{withMemCache as u,getContentUrl as a,fetchContent as l,handleUrlParams as d,clearRunIdsFromUrl as c,camelCase as h,getRunIdsFromUrl as f}from"../helpers/helpers.js";import g from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{formMountMixin as p}from"../mixins/formMountMixin.js";import v from"./initTemplate.js";import{transformFlowInputFormData as b,extractNestedAttribute as m}from"../helpers/flowInputs.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as A}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as C}from"../constants/general.js";var k,x,y,j,I,E,U,L,M,S,O,W,D,R,P,q,F,T,B,N,V;const H=o(s,p)(HTMLElement);class K extends H{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(r){super(),k.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,k,"m",N).call(this,e,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)}},j.set(this,new g),I.set(this,new g),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new g({isLoading:!1}),U.set(this,void 0),L.set(this,{popstate:t(this,k,"m",W).bind(this),componentsContext:t(this,k,"m",F).bind(this)}),M.set(this,void 0),this.getConfig=u((()=>e(this,void 0,void 0,(function*(){const t=a({projectId:this.projectId,filename:w,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield l(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,M,r,"f"),t(this,k,"m",S).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 b(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return m(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(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 r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,I,"f").subscribe(t(this,k,"m",B).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,k,"m",O).call(this),yield t(this,k,"m",P).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");t(this,k,"m",V).call(this);const{executionId:s,stepId:o,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f,ssoQueryParams:g}=d();window.addEventListener("popstate",t(this,L,"f").popstate),window.addEventListener("components-context",t(this,L,"f").componentsContext),t(this,j,"f").subscribe(t(this,k,"m",R).bind(this)),t(this,j,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f},g)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,k,"m",T).call(this),window.removeEventListener("popstate",t(this,L,"f").popstate),window.removeEventListener("components-context",t(this,L,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,y,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,k,"m",O).call(this);const s=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,c()),{[h(e)]:r,stepId:o,executionId:n}})),t(this,I,"f").update({isDebug:this.debug})}}}x=K,y=new WeakMap,j=new WeakMap,I=new WeakMap,E=new WeakMap,U=new WeakMap,L=new WeakMap,M=new WeakMap,k=new WeakSet,S=function(){this.shadowRoot.appendChild(v.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},O=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"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[h(e)])throw Error(`${e} cannot be empty`)}))},W=function(){const{stepId:e,executionId:i}=f();t(this,j,"f").update({stepId:e,executionId:i})},D=function(t,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},x.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:C,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},R=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,k,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},P=function(){return e(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t(this,k,"m",q).call(this))}))},q=function(){return e(this,void 0,void 0,(function*(){const t=a({projectId:this.projectId,filename:w,assetsFolder:A,baseUrl:this.baseStaticUrl});try{return yield l(t,"json"),!0}catch(t){return!1}}))},F=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},T=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},B=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,U,"f"))):t(this,k,"m",T).call(this)}))},N=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},V=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=n.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const u=this.rootElement.querySelectorAll("descope-button");if(1===u.length&&"false"!==u[0].getAttribute("auto-submit"))return void u[0].click();const a=Array.from(u).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(u).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(u).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},K.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.31.1"}};export{K as default};
@@ -0,0 +1 @@
1
+ import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,fetchContent as b,showFirstScreenOnExecutionInit as w,injectSamlIdpForm as y,getAnimationDirection as I,getContentUrl as C,getElementDescopeAttributes as k,submitForm as S,handleAutoFocus as j,handleReportValidityOnBlur as O,getFirstNonEmptyValue as R,clearPreviousExternalInputs as E}from"../helpers/helpers.js";import U from"../helpers/state.js";import{disableWebauthnButtons as A,updateTemplateFromScreenState as x,setPhoneAutoDetectDefaultCode as W,setTOTPVariable as T,setNOTPVariable as L,setCssVars as $,updateScreenFromScreenState as P}from"../helpers/templates.js";import{isConditionalLoginSupported as V}from"../helpers/webauthn.js";import{calculateConditions as N,calculateCondition as F}from"../helpers/conditions.js";import{setLastAuth as q,getLastAuth as M}from"../helpers/lastAuth.js";import{getABTestingKey as D}from"../helpers/abTestingKey.js";import{Direction as K}from"../types.js";import H from"./BaseDescopeWc.js";import B,{getScriptResultPath as G}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as J,FETCH_ERROR_RESPONSE_ERROR_CODE as _}from"../constants/general.js";var z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve,me,fe;class be extends H{static set sdkConfigOverrides(e){H.sdkConfigOverrides=e}static get sdkConfigOverrides(){return H.sdkConfigOverrides}constructor(){const o=new U({deferredRedirect:!1});super(o.update.bind(o)),z.add(this),this.stepState=new U({},{updateOnlyOnChange:!1}),Q.set(this,void 0),X.set(this,null),Y.set(this,{visibilitychange:e(this,z,"m",Z).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ie,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},te.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,Q,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,te,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===J)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,te,"f").call(this,o,s,n,r);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,oe,"f").call(this,u),e(this,te,"f").call(this,o,s,n,r)}))),d),"f")}})),ie.set(this,(()=>{clearTimeout(e(this,Q,"f")),t(this,Q,null,"f")})),oe.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=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===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,z,"m",fe).call(this,"error",(null==t?void 0:t.error)||{errorCode:_,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,z,"m",ee).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.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}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&q(b),void e(this,z,"m",fe).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:j,webauthn:O,error:R,samlIdpResponse:E,nativeResponse:U}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:R}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:j,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload})):this.flowState.update({action:C})})),se.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),pe.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,z,"m",le).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,z,"m",de).call(this,t);const n=yield e(this,z,"m",ae).call(this),r=k(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),h=yield o(s,d.version,c.componentsVersion,a);e(this,oe,"f").call(this,h),e(this,z,"m",ce).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield B(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[G(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,Y,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,X,"f"))||void 0===i||i.abort(),t(this,X,null,"f"),window.removeEventListener("visibilitychange",e(this,Y,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield b(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield b(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u;const{projectId:p,flowId:g,tenant:v,stepId:m,executionId:b,action:k,screenId:j,screenState:O,redirectTo:R,openInNewTabUrl:E,redirectUrl:U,token:A,code:x,exchangeError:W,webauthnTransactionId:T,webauthnOptions:L,redirectAuthCodeChallenge:$,redirectAuthCallbackUrl:P,redirectAuthBackupCallbackUri:V,redirectAuthInitiator:q,locale:K,samlIdpResponseUrl:H,samlIdpResponseSamlResponse:B,samlIdpResponseRelayState:G,nativeResponseType:J,nativePayload:_}=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","nativeResponseType","nativePayload"]);let Y,Z;const ee=D(),ie=this.sdk.getLastUserLoginId(),se=yield this.getFlowConfig(),ne=yield this.getProjectConfig(),re=Object.entries(ne.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),le=P&&$?{callbackUrl:P,codeChallenge:$,backupCallbackUri:V}:void 0,ae=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(!b&&(this.loadSdkScripts(),se.fingerprintEnabled&&se.fingerprintKey?yield s(se.fingerprintKey,this.baseUrl):n(),se.conditions?({startScreenId:Y,conditionInteractionId:Z}=N({loginId:ie,code:x,token:A,abTestingKey:ee},se.conditions)):se.condition?({startScreenId:Y,conditionInteractionId:Z}=F(se.condition,{loginId:ie,code:x,token:A,abTestingKey:ee})):Y=se.startScreenId,!w(Y,Q))){const t=yield this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:le},Q),{client:this.client}),U&&{redirectUrl:U}),{lastAuth:M(ie),abTestingKey:ee,locale:f(K).locale,nativeOptions:ae}),Z,"",ne.componentsVersion,re,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),x?{exchangeCode:x,idpInitiated:!0}:{}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A?{token:A}:{}),Q.oidcLoginHint?{externalId:Q.oidcLoginHint}:{}));return e(this,oe,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(b&&(a("token")&&A||a("code")&&x||a("exchangeError")&&W)){const t=yield this.sdk.flow.next(b,m,c.submit,se.version,ne.componentsVersion,{token:A,exchangeCode:x,exchangeError:W});return e(this,oe,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(k===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!H||!B)return void this.loggerWrapper.error("Did not get saml idp params data to load");y(H,B,G||"",S)}if(k===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return R?"android"===q&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(R):void this.loggerWrapper.error("Did not get redirect url");if(k===d.webauthnCreate||k===d.webauthnGet){if(!T||!L)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,X,"f"))||void 0===u||u.abort(),t(this,X,null,"f");try{i=k===d.webauthnCreate?yield this.sdk.webauthn.helpers.create(L):yield this.sdk.webauthn.helpers.get(L)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(b,m,c.submit,se.version,ne.componentsVersion,{transactionId:T,response:i,failure:o});e(this,oe,"f").call(this,s)}if(k===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(b,m,c.submit,se.version,ne.componentsVersion,t);e(this,oe,"f").call(this,i)})),void e(this,z,"m",fe).call(this,"bridge",{type:J,payload:_});if(e(this,te,"f").call(this,b,m,se.version,ne.componentsVersion),!j&&!Y)return void this.loggerWrapper.warn("No screen was found to show");const de=Y||j,ce=yield this.getHtmlFilenameWithLocale(K,de),{oidcLoginHint:he,oidcPrompt:ue,oidcErrorRedirectUri:pe,samlIdpUsername:ge}=Q,ve={direction:I(m,l.stepId),screenState:Object.assign(Object.assign({},O),{form:Object.assign(Object.assign({},this.formConfigValues),null==O?void 0:O.form),lastAuth:{loginId:ie,name:this.sdk.getLastUserDisplayName()||ie}}),htmlUrl:C({projectId:p,filename:`${de}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:ce&&C({projectId:p,filename:ce,baseUrl:this.baseStaticUrl}),samlIdpUsername:ge,oidcLoginHint:he,oidcPrompt:ue,oidcErrorRedirectUri:pe,openInNewTabUrl:E},me=M(ie);w(Y,Q)?ve.next=(e,t,i,o)=>this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:le},Q),{lastAuth:me,preview:this.preview,abTestingKey:ee,client:this.client}),U&&{redirectUrl:U}),{locale:f(K).locale,nativeOptions:ae}),Z,e,i,re,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),x&&{exchangeCode:x,idpInitiated:!0}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A&&{token:A})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(ve.next=(...e)=>this.sdk.flow.next(b,m,...e)),this.stepState.update(ve)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlUrl:r,htmlLocaleUrl:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,z,"m",re).call(this,v,d):A(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),x(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();W(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.shadowRoot.querySelector("div");T(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),L(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),$(s,v,u.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(v);const n=!o.htmlUrl;setTimeout((()=>{e(this,z,"m",he).call(this),j(this.rootElement,this.autoFocus,n),this.validateOnBlur&&O(this.rootElement),P(this.rootElement,u)})),e(this,z,"m",ve).call(this,d),n&&e(this,z,"m",fe).call(this,"ready",{}),e(this,z,"m",fe).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${h}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(c.polling,t.version,i.componentsVersion,{});e(this,oe,"f").call(this,o)}p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,z,"m",me).call(this,b,a):b()}))}}Q=new WeakMap,X=new WeakMap,Y=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,se=new WeakMap,pe=new WeakMap,z=new WeakSet,Z=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ee=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(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")}))},ne=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},re=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,X,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield V())){const{options:o,transactionId:n}=(yield e(this,se,"f").call(this))||{};if(o&&n){e(this,z,"m",ne).call(this,r),t(this,X,new AbortController,"f");const l=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,X,"f")).then((t=>i(this,void 0,void 0,(function*(){const i=yield s(r.id,l.version,a.componentsVersion,{transactionId:n,response:t});e(this,oe,"f").call(this,i)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},le=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},ae=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},de=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ce=function(e={}){var t,i;const o=R(e,["externalId","email","phone"]),s=R(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},he=function(){E();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,z,"m",ue).call(this,t)))},ue=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ge=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,pe,"f").call(this,i,t)}))}))},ve=function(t){this.rootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,pe,"f").call(this,i,t)}})),e(this,z,"m",ge).call(this,t)},me=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===K.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},fe=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{be as default};
@@ -0,0 +1 @@
1
+ import e from"./DescopeWc.js";customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",e);export{e as default};
@@ -0,0 +1 @@
1
+ const t=document.createElement("template");t.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";export{t as default};
@@ -0,0 +1 @@
1
+ import{__awaiter as r}from"tslib";import{SDK_SCRIPT_RESULTS_KEY as t}from"../../constants/index.js";function e(r,e){return`${t}.${e?`${r}_${e}`:r}`}function i(t){return r(this,void 0,void 0,(function*(){let r;switch(t){case"forter":return r=yield import("./forter.js"),r.default;case"fingerprint":return r=yield import("./fingerprint.js"),r.default;case"fingerprintDescope":return r=yield import("./fingerprintDescope.js"),r.default;default:throw new Error(`Unknown script id: ${t}`)}}))}export{i as default,e as getScriptResultPath};
@@ -0,0 +1 @@
1
+ const t="dls_ab_testing_id",o=()=>{const o=localStorage.getItem(t);if(!o){const o=Math.floor(100*Math.random()+1);return localStorage.setItem(t,o.toString()),o}return Number(o)};export{o as getABTestingKey};
@@ -0,0 +1 @@
1
+ const e={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}},t=(t,n)=>{var i;const o=null===(i=e[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const r=o(n,t.predicate)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}},n=(t,n)=>{const i=null==n?void 0:n.find((({key:n,operator:i,predicate:o})=>{var r;if("ELSE"===n)return!0;const d=null===(r=e[n])||void 0===r?void 0:r[i];return!!(null==d?void 0:d(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}};export{t as calculateCondition,n as calculateConditions};
@@ -0,0 +1 @@
1
+ const e=(t,s="")=>Object.keys(t).reduce(((r,a)=>{var c;if("object"==typeof t[a]&&null!==t[a]&&!(null===(c=t[a])||void 0===c?void 0:c.value))return Object.assign(Object.assign({},r),e(t[a],`${s+a}.`));const n="object"==typeof t[a]?t[a]:{value:t[a]},i=Object.assign(Object.assign({},r),{[s+a]:n,[`form.${s}${a}`]:n});return"displayName"===a?Object.assign(Object.assign({},i),{[`${s}fullName`]:n,[`form.${s}fullName`]:n}):i}),[]),t=t=>{try{return e(JSON.parse(t))}catch(e){return{}}},s=(e,t)=>Object.fromEntries(Object.entries(e).map((([e,s])=>[e,s[t]])));export{s as extractNestedAttribute,t as transformFlowInputFormData};
@@ -0,0 +1 @@
1
+ import{__awaiter as t}from"tslib";import{URL_RUN_IDS_PARAM_NAME as e,URL_TOKEN_PARAM_NAME as n,URL_CODE_PARAM_NAME as r,URL_ERR_PARAM_NAME as o,OIDC_IDP_STATE_ID_PARAM_NAME as i,SAML_IDP_STATE_ID_PARAM_NAME as c,SAML_IDP_USERNAME_PARAM_NAME as a,DESCOPE_IDP_INITIATED_PARAM_NAME as u,SSO_APP_ID_PARAM_NAME as s,THIRD_PARTY_APP_ID_PARAM_NAME as d,THIRD_PARTY_APP_STATE_ID_PARAM_NAME as l,APPLICATION_SCOPES_PARAM_NAME as f,OIDC_LOGIN_HINT_PARAM_NAME as p,OIDC_PROMPT_PARAM_NAME as m,OIDC_ERROR_REDIRECT_URI_PARAM_NAME as h,DESCOPE_ATTRIBUTE_PREFIX as v,URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME as g,URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME as I,URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME as b,URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME as y}from"../constants/index.js";import{Direction as A}from"../types.js";import{OVERRIDE_CONTENT_URL as S,BASE_CONTENT_URL as w,ASSETS_FOLDER as C}from"../constants/content.js";const k=["descope-enriched-text"];function L(t){return new URLSearchParams(window.location.search).get(t)}function U(t){if(window.history.replaceState&&L(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function E(e,n){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[n||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}function P({projectId:t,filename:e,assetsFolder:n=C,baseUrl:r}){const o=new URL(S||r||w);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.toString()}function x(t,e){if(!e)return;const n=+t,r=+e;return Number.isNaN(n)||Number.isNaN(r)?void 0:n>r?A.forward:n<r?A.backward:void 0}const R=()=>{const[t="",n=""]=(L(e)||"").split("_");return{executionId:t,stepId:n}};function T(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function j(){U(e)}function $(){return L(n)||void 0}function N(){U(n)}function B(){return L(r)||void 0}function O(){return L(o)||void 0}function q(){U(r)}function F(){U(o)}function H(){return{redirectAuthCodeChallenge:L(g),redirectAuthCallbackUrl:L(I),redirectAuthBackupCallbackUri:L(b),redirectAuthInitiator:L(y)}}function M(){return L(i)}function D(){U(i)}function G(){return L(c)}function Q(){U(c)}function V(){return L(a)}function _(){U(a)}function z(){return L(u)}function J(){U(u)}function K(){return L(s)}function W(){return L(d)}function X(){U(s)}function Y(){U(d)}function Z(){return L(l)}function tt(){U(l)}function et(){return L(f)}function nt(){U(f)}function rt(){return L(p)}function ot(){U(p)}function it(){return L(m)}function ct(){U(m)}function at(){return L(h)}function ut(){U(h)}const st=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),dt=(t,e)=>n=>t[n]!==e[n],lt=t=>Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var n;const r=null===(n=new RegExp(`^${v}(\\S+)$`).exec(e.name))||void 0===n?void 0:n[1];return r?Object.assign(t,{[r]:e.value}):t}),{}),ft=()=>{const{executionId:t,stepId:e}=R();(t||e)&&j();const n=$();n&&N();const r=B();r&&q();const o=O();o&&F();const{redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:u}=H(),s=M();s&&D();const d=G();d&&Q();const l=V();d&&_();const f=z();f&&J();const p=K();p&&X();const m=W();m&&Y();const h=Z();h&&tt();const v=et();v&&nt();const g=rt();g&&ot();const I=it();I&&ct();const b=at();b&&ut();return{executionId:t,stepId:e,token:n,code:r,exchangeError:o,redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:s,samlIdpStateId:d,samlIdpUsername:l,descopeIdpInitiated:"true"===f,ssoAppId:p,oidcLoginHint:g,oidcPrompt:I,oidcErrorRedirectUri:b,thirdPartyAppId:m,thirdPartyAppStateId:h,applicationScopes:v}}},pt=t=>{let e,n;return Object.assign(((...r)=>{return e&&(i=r,(o=e).length===i.length&&o.every(((t,e)=>t===i[e])))||(e=r,n=t(...r)),n;var o,i}),{reset:()=>{e=void 0,n=void 0}})},mt=(t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}},ht=t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))};function vt(t,e,n){return new Promise(((r,o)=>{let i=!1;const c=setTimeout((()=>{i=!0,void 0!==n?r(n):o(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{i||(clearTimeout(c),r(t))})).catch((t=>{i||(clearTimeout(c),o(t))}))}))}const gt=()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0},It=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:r,ssoAppId:o,oidcLoginHint:i,oidcPrompt:c,oidcErrorRedirectUri:a,thirdPartyAppId:u,thirdPartyAppStateId:s,applicationScopes:d})=>!(!t||e||n||r||o||i||c||a||u||s||d),bt=(t,e,n,r)=>{const o=document.createElement("form");o.method="POST",o.action=t,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),r(o)},yt=t=>null==t?void 0:t.submit(),At=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},St=(t,e=100)=>{let n;return function(...r){n||t.apply(this,r),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function wt(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:""}}const Ct=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()))},kt=t=>k.includes(t);export{st as camelCase,nt as clearApplicationScopesParamFromUrl,q as clearCodeFromUrl,J as clearDescopeIDPInitiatedParamFromUrl,F as clearExchangeErrorFromUrl,ut as clearOIDCErrorRedirectUriParamFromUrl,D as clearOIDCIDPParamFromUrl,ot as clearOIDCLoginHintParamFromUrl,ct as clearOIDCPromptParamFromUrl,Ct as clearPreviousExternalInputs,j as clearRunIdsFromUrl,Q as clearSAMLIDPParamFromUrl,_ as clearSAMLIDPUsernameParamFromUrl,X as clearSSOAppIdParamFromUrl,Y as clearThirdPartyAppIdParamFromUrl,tt as clearThirdPartyAppStateIdParamFromUrl,N as clearTokenFromUrl,dt as createIsChanged,E as fetchContent,x as getAnimationDirection,et as getApplicationScopesParamFromUrl,gt as getChromiumVersion,B as getCodeFromUrl,P as getContentUrl,z as getDescopeIDPInitiatedParamFromUrl,lt as getElementDescopeAttributes,O as getExchangeErrorFromUrl,At as getFirstNonEmptyValue,at as getOIDCErrorRedirectUriParamFromUrl,M as getOIDCIDPParamFromUrl,rt as getOIDCLoginHintParamFromUrl,it as getOIDCPromptParamFromUrl,H as getRedirectAuthFromUrl,R as getRunIdsFromUrl,G as getSAMLIDPParamFromUrl,V as getSAMLIDPUsernameParamFromUrl,K as getSSOAppIdParamFromUrl,W as getThirdPartyAppIdParamFromUrl,Z as getThirdPartyAppStateIdParamFromUrl,$ as getTokenFromUrl,wt as getUserLocale,mt as handleAutoFocus,ht as handleReportValidityOnBlur,ft as handleUrlParams,bt as injectSamlIdpForm,T as isChromium,St as leadingDebounce,kt as shouldHandleMarkdown,It as showFirstScreenOnExecutionInit,yt as submitForm,vt as timeoutPromise,pt as withMemCache};
@@ -0,0 +1 @@
1
+ import{DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY as t}from"../constants/index.js";import{IS_LOCAL_STORAGE as o}from"../constants/general.js";function n(o){const n={};if(o)try{Object.assign(n,JSON.parse(localStorage.getItem(t)))}catch(t){}return n}function e(n){(null==n?void 0:n.authMethod)&&o&&localStorage.setItem(t,JSON.stringify(n))}export{n as getLastAuth,e as setLastAuth};
@@ -0,0 +1 @@
1
+ const t=(t,e,o,n={})=>{var i,l,f,u;return[Math.min(Math.max(e,("all"===n.left?t.offsetWidth:null!==(i=n.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===n.right?t.offsetWidth:null!==(l=n.right)&&void 0!==l?l:0)),Math.min(Math.max(o,("all"===n.top?t.offsetHeight:null!==(f=n.top)&&void 0!==f?f:0)-t.offsetHeight),window.innerHeight-("all"===n.bottom?t.offsetHeight:null!==(u=n.bottom)&&void 0!==u?u:0))]},e=(e,o,n)=>{let i=0,l=0,f=0,u=0;function s(o){o.preventDefault(),i=f-o.clientX,l=u-o.clientY,f=o.clientX,u=o.clientY;const[s,a]=t(e,e.offsetLeft-i,e.offsetTop-l,n);e.style.top=`${a}px`,e.style.left=`${s}px`}function a(){document.onmouseup=null,document.onmousemove=null}function h(t){t.preventDefault(),f=t.clientX,u=t.clientY,document.onmouseup=a,document.onmousemove=s}o?o.onmousedown=h:e.onmousedown=h},o=t=>{t.onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight}};export{o as addOnResize,e as dragElement,t as limitCoordinateToScreenBoundaries};
@@ -0,0 +1 @@
1
+ import{__classPrivateFieldGet as t,__classPrivateFieldSet as e}from"tslib";import{createIsChanged as s}from"./helpers.js";var i,n,r,f;function h(t,e){const s=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(s.length!==i.length)return!1;for(let i=0;i<s.length;i+=1){const n=s[i],r=t[n],f=e[n];if(null===r||null===f){if(r!==f)return!1}else if("object"==typeof r&&"object"==typeof f){if(!h(r,f))return!1}else if(r!==f)return!1}return!0}class o{constructor(o={},{updateOnlyOnChange:u=!0}={}){i.set(this,void 0),n.set(this,{}),r.set(this,0),f.set(this,!1),this.update=r=>{const o="function"==typeof r?r(t(this,i,"f")):r,u=Object.assign(Object.assign({},t(this,i,"f")),o);if(!t(this,f,"f")||!h(t(this,i,"f"),u)){const r=t(this,i,"f");e(this,i,u,"f"),Object.freeze(t(this,i,"f")),setTimeout((()=>{Object.values(t(this,n,"f")).forEach((t=>t(u,r,s(u,r))))}),0)}},e(this,i,o,"f"),e(this,f,u,"f")}get current(){return Object.assign({},t(this,i,"f"))}subscribe(s){return e(this,r,t(this,r,"f")+1,"f"),t(this,n,"f")[t(this,r,"f")]=s,t(this,r,"f").toString()}unsubscribe(e){const s=!!t(this,n,"f")[e];return s&&delete t(this,n,"f")[e],s}unsubscribeAll(){return e(this,n,{},"f"),!0}}i=new WeakMap,n=new WeakMap,r=new WeakMap,f=new WeakMap;export{o as default};
@@ -0,0 +1 @@
1
+ import{escapeMarkdown as e}from"@descope/escape-markdown";import{ELEMENT_TYPE_ATTRIBUTE as t,HAS_DYNAMIC_VALUES_ATTR_NAME as o,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as r}from"../constants/index.js";import{shouldHandleMarkdown as l}from"./helpers.js";const s=["disabled"],n=(e,t)=>{Object.entries(t||{}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${r}])`)).forEach((e=>{e.value=o}))}))},i=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),c=(t,o,r)=>t.replace(/{{(.+?)}}/g,((t,l)=>r?e(i(o,l)):i(o,l))),a=(e,o,r)=>{e.querySelectorAll(`[${t}="${o}"]`).forEach((e=>{e.setAttribute("href",r)}))},d=(e,t,o,r)=>{o&&Object.keys(o).forEach((l=>{t.querySelector(l)||r.debug(`Skipping css vars for component "${l}}"`,`Got css vars for component ${l} but Could not find it on next page`);const s=customElements.get(l);s?Object.keys(o[l]).forEach((t=>{var n;const i=o[l],c=null===(n=null==s?void 0:s.cssVarList)||void 0===n?void 0:n[t];if(!c)return void r.info(`Could not find css variable name for ${t} in ${l}`,"Check if the css variable is defined in the component");const a=i[t];e.style.setProperty(c,a)})):r.info(`Could not find component class for ${l}`,"Check if the component is registered")}))},u=(e,t,o)=>{var r,l;const s=null===(r=customElements.get(t))||void 0===r?void 0:r.cssVarList.url;o&&s&&(null===(l=null==e?void 0:e.style)||void 0===l||l.setProperty(s,`url(data:image/jpg;base64,${o})`))},f=(e,r,n,i,d,u)=>{var f,p;let m=null==r?void 0:r.errorText;try{m=(null==d?void 0:d({text:null==r?void 0:r.errorText,type:null==r?void 0:r.errorType}))||(null==r?void 0:r.errorText)}catch(e){u.error("Error transforming error message",e.message)}((e,o,r="")=>{e.querySelectorAll(`[${t}="${o}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))})(e,"error-message",m),a(e,"totp-link",null===(f=null==r?void 0:r.totp)||void 0===f?void 0:f.provisionUrl),a(e,"notp-link",null===(p=null==r?void 0:r.notp)||void 0===p?void 0:p.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=l(e.localName);e.textContent=c(e.textContent,t,o);const r=e.getAttribute("href");r&&e.setAttribute("href",c(r,t))}))})(e,r),((e,t,o)=>{t&&Object.keys(t).forEach((r=>{e.querySelectorAll(`[name=${r}]`).forEach((e=>{const l=t[r];Object.keys(l).forEach((t=>{let r=l[t];if("string"!=typeof r)try{r=JSON.stringify(r)}catch(e){o.error(`Could not stringify value "${r}" for "${t}"`,e.message),r=""}e.setAttribute(t,r)}))}))}))})(e,n,u),((e,t)=>{e.querySelectorAll(`[${o}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=c(e.value,t)}))}))})(e,r),((e,t)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(o).forEach((([t,o])=>{s.includes(t)&&e.setAttribute(t,o)}))}))}))})(e,i)},p=(e,t)=>{n(e,null==t?void 0:t.inputs),n(e,null==t?void 0:t.form)},m=(e,t)=>{u(e,"descope-totp-image",t)},v=(e,t)=>{u(e,"descope-notp-image",t)},h=(e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))},y=e=>{e.querySelectorAll(`descope-button[${t}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))};export{y as disableWebauthnButtons,d as setCssVars,v as setNOTPVariable,h as setPhoneAutoDetectDefaultCode,m as setTOTPVariable,p as updateScreenFromScreenState,f as updateTemplateFromScreenState};
@@ -0,0 +1 @@
1
+ import{__awaiter as i}from"tslib";import{withMemCache as e,getChromiumVersion as l,timeoutPromise as o}from"./helpers.js";const n=e((()=>i(void 0,void 0,void 0,(function*(){var i,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(i=window.PublicKeyCredential)||void 0===i?void 0:i.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((i=>i.every((i=>!!i)))),r=l()>=108;return yield o(100,n,r)}catch(i){return console.error("Conditional login check failed",i),!1}}))));export{n as isConditionalLoginSupported};
@@ -0,0 +1 @@
1
+ import{__classPrivateFieldGet as t}from"tslib";import{createSingletonMixin as e}from"@descope/sdk-helpers";import{isChromium as s}from"../helpers/helpers.js";import"../helpers/state.js";import"@descope/escape-markdown";import"../constants/content.js";import"../constants/uiComponents.js";import"../helpers/webauthn.js";const o=e((e=>{var o,n,r,l;return l=class extends e{constructor(){super(...arguments),o.add(this)}connectedCallback(){var e;t(this,o,"m",n).call(this)&&t(this,o,"m",r).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},o=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&s()},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)},l}));export{o as formMountMixin};
@@ -0,0 +1 @@
1
+ var r;!function(r){r.backward="backward",r.forward="forward"}(r||(r={}));export{r as Direction};