@descope/web-component 3.49.0 → 3.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=require("@descope/sdk-mixins/inject-style-mixin"),o=require("@descope/web-js-sdk"),n=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,m,b,w,C,k,F,P,A,x,y,E,I,G,j,S=require("../helpers/storage.js"),M=require("../helpers/flowInputs.js"),O=require("../mixins/formMountMixin.js"),U=require("../constants/content.js"),L=require("../constants/general.js");function q(t){return Object.freeze({__proto__:null,default:t})}const R=e.compose(r.themeMixin,i.staticResourcesMixin,O.formMountMixin,s.injectStyleMixin)(HTMLElement);class N extends R{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),u.add(this),c.set(this,!1),h.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",G).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)}},g.set(this,new l),f.set(this,new l),p.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,p,"f"),this.nextRequestStatus=new l({isLoading:!1}),v.set(this,void 0),_.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",k).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",y).bind(this)}),m.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,m,e,"f"),t.__classPrivateFieldGet(this,u,"m",w).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 M.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return M.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,h,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");t.__classPrivateFieldSet(this,h,e,"f"),S.setCustomStorage(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}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;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.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,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",I).bind(this)),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",A).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");const r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,u,"m",j).call(this);const{executionId:s,stepId:o,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b,ssoQueryParams:w}=a.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),t.__classPrivateFieldGet(this,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",P).bind(this)),t.__classPrivateFieldGet(this,g,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,c,"f")&&i!==r&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const s=null===i;t.__classPrivateFieldGet(this,g,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:r,stepId:o,executionId:n}})),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug})}}}d=N,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,u=new WeakSet,b=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\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!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},w=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},k=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,g,"f").update({stepId:e,executionId:i})},F=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,h,"f")&&(r.customStorage=t.__classPrivateFieldGet(this,h,"f")),this.sdk=o.createSdk(r),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:L.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},P=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,u,"m",F).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",x).call(this))}))},x=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:U.CONFIG_FILENAME,assetsFolder:U.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},y=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,v,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,v,null,"f")},I=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,v,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,v,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return q(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},G=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},j=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.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||s||o)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()}}},N.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.49.0"}},module.exports=N;
1
+ "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=require("@descope/sdk-mixins/inject-style-mixin"),o=require("@descope/web-js-sdk"),n=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,m,b,w,C,k,P,F,A,y,x,E,I,G,j=require("../helpers/storage.js"),S=require("../helpers/flowInputs.js"),M=require("../mixins/formMountMixin.js"),O=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const q=e.compose(r.themeMixin,i.staticResourcesMixin,M.formMountMixin,s.injectStyleMixin)(HTMLElement);class R extends q{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),u.add(this),c.set(this,!1),h.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",G).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)}},g.set(this,new l),f.set(this,new l),p.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,p,"f"),this.nextRequestStatus=new l({isLoading:!1}),v.set(this,void 0),_.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",k).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",x).bind(this)}),m.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,m,e,"f"),t.__classPrivateFieldGet(this,u,"m",w).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 S.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return S.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,h,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");t.__classPrivateFieldSet(this,h,e,"f"),j.setCustomStorage(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}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()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),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.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||s||o)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()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.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,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",I).bind(this)),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",A).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");const r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:o,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b,ssoQueryParams:w}=a.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),t.__classPrivateFieldGet(this,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",F).bind(this)),t.__classPrivateFieldGet(this,g,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,c,"f")&&i!==r&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const s=null===i;t.__classPrivateFieldGet(this,g,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:r,stepId:o,executionId:n}})),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug})}}}d=R,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,u=new WeakSet,b=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\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!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},w=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},k=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,g,"f").update({stepId:e,executionId:i})},P=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,h,"f")&&(r.customStorage=t.__classPrivateFieldGet(this,h,"f")),this.sdk=o.createSdk(r),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},F=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,u,"m",P).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",y).call(this))}))},y=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:O.CONFIG_FILENAME,assetsFolder:O.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},x=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,v,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,v,null,"f")},I=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,v,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,v,"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,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},G=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},R.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.49.1"}},module.exports=R;
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport { createSdk } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport { formMountMixin } from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n injectStyleMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'style-id',\n ];\n }\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\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!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get flowId() {\n return this.getAttribute('flow-id');\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get tenantId() {\n return this.getAttribute('tenant') || undefined;\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n try {\n const resp = await origFn(...args);\n return resp;\n } catch (e) {\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n #handleKeyPress() {\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n this.#handleKeyPress();\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","injectStyleMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","_BaseDescopeWc_init","set","this","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","flowId","getAttribute","client","JSON","parse","e","tenantId","undefined","redirectUrl","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","_c","version","getTargetLocales","targetLocales","map","toLowerCase","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","_BaseDescopeWc_handleKeyPress","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","window","_BaseDescopeWc_onFlowChange","Object","assign","projectId","baseUrl","tenant","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","shadowRoot","isConnected","_a","includes","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","rootElement","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","key","origFn","flow","args","__awaiter","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","Promise","resolve","then","_interopNamespaceDefaultOnly","require","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","onkeydown","isLinkEleFocused","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","localName","_d","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","baseHeaders"],"mappings":"0tBA+CA,MAAMA,EAAYC,EAAOA,QACvBC,aACAC,EAAAA,qBACAC,EAAAA,eACAC,EAAgBA,iBAJAJ,CAKhBK,aAGF,MAAMC,UAAsBP,EAC1B,6BAAWQ,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,WAEH,CA+DD,WAAAC,CAAYC,GACVC,oBAtDFC,EAAAC,IAAAC,MAAQ,GAERC,EAA0CF,IAAAC,UAAA,GAE1CA,KAAUE,WAAe,UAEzBF,KAAAG,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCN,KAAKO,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,yBAAAT,cAAAU,KAAAV,KAA6BK,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCN,KAAKO,OAAOI,KAAKN,EAASC,EAAY,EAExCM,KAAM,CAACP,EAAiBC,EAAc,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8I,YAAYoD,UAAazJ,cAE5B,MAAM0J,KAC6B,UAA/BnM,KAAK8H,WAAWsE,qBAAe,IAAApJ,OAAA,EAAAA,EAAAX,aAAa,SAC1CgK,EAA0BC,EAAAA,gCAAgCrE,SAClB,UAAf,QAA7BlD,EAAA/E,KAAK8H,WAAWsE,qBAAa,IAAArH,OAAA,EAAAA,EAAEwH,iBAAa,IAAAC,EAAAA,EAAA,IAG9C,GAAc,UAAV/J,EAAEgH,KAAmB0C,GAAoBE,EAC3C,OAEF5J,EAAEgK,iBACF,MAAMC,EACJ1M,KAAK8I,YAAY6D,iBAAiB,kBAGpC,GACqB,IAAnBD,EAAQE,QACmC,UAA3CF,EAAQ,GAAGrK,aAAa,eAGxB,YADAqK,EAAQ,GAAGG,QAIb,MAAMC,EAAoBC,MAAMC,KAAKN,GAASO,QAC3CC,GAAkD,SAAvCA,EAAO7K,aAAa,iBAElC,GAAiC,IAA7ByK,EAAkBF,OAEpB,YADAE,EAAkB,GAAGD,QAIvB,MAAMM,EAAiBJ,MAAMC,KAAKN,GAASO,QACxCC,GAAgD,WAArCA,EAAO7K,aAAa,eAIlC,GAA8B,IAA1B8K,EAAeP,OACqC,UAAlDO,EAAe,GAAG9K,aAAa,gBACjC8K,EAAe,GAAGN,aAEf,GAA8B,IAA1BM,EAAeP,OAAc,CACtC,MAAMQ,EAAaL,MAAMC,KAAKN,GAASO,QACpCC,GAAgD,QAArCA,EAAO7K,aAAa,eAIR,IAAtB+K,EAAWR,QACqC,UAA9CQ,EAAW,GAAG/K,aAAa,gBAC7B+K,EAAW,GAAGP,OAGnB,EAEL,EA5dOpN,EAAA8J,mBAAyC,CAC9C8D,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
1
+ {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport { createSdk } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport { formMountMixin } from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n injectStyleMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'style-id',\n ];\n }\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\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!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get flowId() {\n return this.getAttribute('flow-id');\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get tenantId() {\n return this.getAttribute('tenant') || undefined;\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n try {\n const resp = await origFn(...args);\n return resp;\n } catch (e) {\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","injectStyleMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","_BaseDescopeWc_init","set","this","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","flowId","getAttribute","client","JSON","parse","e","tenantId","undefined","redirectUrl","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","window","_BaseDescopeWc_onFlowChange","Object","assign","projectId","baseUrl","tenant","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","origFn","flow","args","__awaiter","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","Promise","resolve","then","_interopNamespaceDefaultOnly","require","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"wtBA+CA,MAAMA,EAAYC,EAAOA,QACvBC,aACAC,EAAAA,qBACAC,EAAAA,eACAC,EAAgBA,iBAJAJ,CAKhBK,aAGF,MAAMC,UAAsBP,EAC1B,6BAAWQ,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,WAEH,CA+DD,WAAAC,CAAYC,GACVC,oBAtDFC,EAAAC,IAAAC,MAAQ,GAERC,EAA0CF,IAAAC,UAAA,GAE1CA,KAAUE,WAAe,UAEzBF,KAAAG,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCN,KAAKO,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,yBAAAT,cAAAU,KAAAV,KAA6BK,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCN,KAAKO,OAAOI,KAAKN,EAASC,EAAY,EAExCM,KAAM,CAACP,EAAiBC,EAAc,GAAIO,EAAa,CAAA,KACrDb,KAAKO,OAAOK,KAAKP,EAASC,EAAaO,EAAM,EAE/CC,MAAO,CAACT,EAAiBC,EAAc,MACrCN,KAAKO,OAAOO,MAAMT,EAASC,EAAY,GAI3CS,EAAahB,IAAAC,KAAA,IAAIgB,GAEjBC,EAAclB,IAAAC,KAAA,IAAIgB,GAElBE,EAAAnB,IAAAC,KAAqB,CAAA,GAErBA,KAAAmB,qBAAuB,IAAMV,EAAAA,uBAAAT,YAE7BA,KAAiBoB,kBAAG,IAAIJ,EAA8B,CAAEK,WAAW,IAQnEC,EAEEvB,IAAAC,UAAA,GAEFuB,EAAgBxB,IAAAC,KAAA,C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AAAA,UAAAjL,KAAAoM,eAAA,GAAA,WAAA5E,QAAEA,IACnBA,GACFtF,EAAAA,uBAAAlC,OAAoBgK,SAASC,cAC3B,oBAGD,KAEDxB,OAAOC,OAAOjI,yBAAAT,KAAiBsB,EAAA,KAAC+K,MAAO,CACrCC,SAAU,QACVC,IAAK,IACLC,MAAO,IACPC,OAAQ,QACRC,MAAO,QACPC,cAAe,OACfC,OAAQ,cAIJC,QAAAC,UAAAC,MAAA,WAAA,OAAAC,EAAAC,QAAO,qBAAgB,IAE7BjD,SAASkD,KAAK9C,YAAY3J,EAAAA,uBAAAT,KAAiBsB,EAAA,OAE3Cb,EAAAA,uBAAAT,KAAIyB,EAAA,IAAAuH,GAAJtI,KAAAV,QAIoB,EAAAmN,EAAA,SAAAC,EAAe9M,SACjC8M,GAASpN,KAAKc,QACC,QAAjBkC,EAAAvC,EAAAA,uBAAAT,KAAiBsB,EAAA,YAAA,IAAA0B,GAAAA,EAAEqK,WAAW,CAAED,QAAO9M,gBAC3C,EA7YOb,EAAAmL,mBAAyC,CAC9C0C,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e,t,i,s,r,o,n,a,l,d,c,h,u,p,g,v,m,_,f,b,S,w,E,O,P,C,I,R,y,T,F,A,k,W,N,x,L,U=require("tslib"),G=require("@descope/web-js-sdk"),j=require("../constants/index.js"),D=require("../helpers/helpers.js"),M=require("../helpers/state.js"),$=require("../helpers/templates.js"),q=require("../helpers/webauthn.js"),V=require("../helpers/abTestingKey.js"),B=require("../helpers/conditions.js"),K=require("../helpers/lastAuth.js"),H=require("./BaseDescopeWc.js"),X=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,f=new WeakMap,b=new WeakMap,S=new WeakMap,I=new WeakMap,A=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},n=function(t,i,s){return U.__awaiter(this,void 0,void 0,(function*(){var r;return(null===(r=this.nativeOptions)||void 0===r?void 0:r.bridgeVersion)>=2&&new Promise((r=>{this.nativeCallbacks.screenNext=s,this.nativeCallbacks.screenResolve=r,U.__classPrivateFieldGet(this,e,"m",l).call(this,"beforeScreen",{screen:t,context:i})}))}))},a=function(t){var i;(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&U.__classPrivateFieldGet(this,e,"m",l).call(this,"afterScreen",{screen:t})},l=function(t,i){U.__classPrivateFieldGet(this,e,"m",x).call(this,"bridge",{type:t,payload:i})},d=function({errorText:e,errorType:t}){const i=()=>{var i;let s=e;try{s=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}$.replaceElementMessage(this.contentRootElement,"error-message",s)};this.addEventListener("screen-updated",i,{once:!0}),i()},c=function(){var t,i,s;null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=void 0===t?{}:t,s=U.__rest(i,["errorText","errorType"]),r=U.__rest(e,["screenState"]);return Object.assign(Object.assign({},r),{screenState:s})})),null===(i=this.stepState)||void 0===i||i.subscribe(U.__classPrivateFieldGet(this,e,"m",d).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(s=this.stepState)||void 0===s||s.subscribe(U.__classPrivateFieldGet(this,e,"m",h).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0})},h=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),D.handleAutoFocus(this.contentRootElement,this.autoFocus,!1))},u=function(){return U.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.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")}))},g=function(t){return U.__awaiter(this,void 0,void 0,(function*(){var i;const s=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:o}=s,a=U.__rest(s,["next","stepName"]),l=D.transformStepStateForCustomScreen(a);let d=yield U.__classPrivateFieldGet(this,e,"m",n).call(this,o,l,r);d||(d=Boolean(yield null===(i=this.onScreenUpdate)||void 0===i?void 0:i.call(this,o,l,r,this)));const h=!this.stepState.current.htmlFilename;if(U.__classPrivateFieldGet(this,v,"f").call(this,d),U.__classPrivateFieldGet(this,p,"f")!==d){const[t,i]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${i} screen to ${t} screen`),U.__classPrivateFieldSet(this,p,d,"f"),d?this.stepState.unsubscribeAll():U.__classPrivateFieldGet(this,e,"m",c).call(this)}d&&(this.loggerWrapper.debug("Showing a custom screen"),U.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:h,isCustomScreen:d,stepName:t.stepName})),this.stepState.forceUpdate=d}))},m=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},w=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)}))}},E=function(t,s){return U.__awaiter(this,void 0,void 0,(function*(){var r;null===(r=U.__classPrivateFieldGet(this,i,"f"))||void 0===r||r.abort();const o=t.querySelector('*[autocomplete="webauthn"]');if(o&&(yield q.isConditionalLoginSupported())){const{options:t,transactionId:r}=(yield U.__classPrivateFieldGet(this,S,"f").call(this))||{};t&&r&&(U.__classPrivateFieldGet(this,e,"m",w).call(this,o),U.__classPrivateFieldSet(this,i,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,U.__classPrivateFieldGet(this,i,"f")).then((e=>U.__awaiter(this,void 0,void 0,(function*(){s(o.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},O=function({isFirstScreen:t,isCustomScreen:i,stepName:s}){t&&U.__classPrivateFieldGet(this,e,"m",x).call(this,"ready",{}),i||U.__classPrivateFieldGet(this,e,"m",a).call(this,s),U.__classPrivateFieldGet(this,e,"m",x).call(this,"page-updated",{screenName:s}),U.__classPrivateFieldGet(this,e,"m",x).call(this,"screen-updated",{screenName:s})},P=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},C=function(){return U.__awaiter(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>U.__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})),{})}))},R=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),i=()=>U.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",i),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const s=yield this.getFlowConfig(),r=[...s.clientScripts||[],...s.sdkScripts||[]];this.loadSdkScripts(r)})),s=()=>{var e;window.removeEventListener("pageshow",U.__classPrivateFieldGet(this,I,"f")),U.__classPrivateFieldSet(this,I,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),i())}),"f"),window.addEventListener("pageshow",U.__classPrivateFieldGet(this,I,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,s)=>{e===s&&i(),this.removeEventListener("popupclosed",i),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},r=this.nextRequestStatus.subscribe((({isLoading:o})=>{o?(this.addEventListener("popupclosed",i,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(r),s())}))},y=function(e={}){var t,i;const s=D.getFirstNonEmptyValue(e,["externalId","email","phone"]),r=D.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&r)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:r});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)}},T=function(){D.clearPreviousExternalInputs();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>U.__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}`,r=document.createElement("slot");r.setAttribute("name",s),r.setAttribute("slot",i),e.appendChild(r),t.setAttribute("slot",s),this.appendChild(t)}))},k=function(e){return U.__awaiter(this,void 0,void 0,(function*(){if(U.__classPrivateFieldGet(this,s,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield U.__classPrivateFieldGet(this,s,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}let r=[];for(const e of t)"function"==typeof e.refresh&&r.push(e.refresh());if(r.length>0)try{yield D.timeoutPromise(j.SDK_SCRIPTS_LOAD_TIMEOUT,Promise.all(r),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},W=function(e){this.contentRootElement.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))&&U.__classPrivateFieldGet(this,A,"f").call(this,t,e)}))}))},N=function(t){this.contentRootElement.querySelectorAll(`descope-button:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]), [data-type="button"]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]`).forEach((e=>{e.onclick=()=>{U.__classPrivateFieldGet(this,A,"f").call(this,e,t)}})),U.__classPrivateFieldGet(this,e,"m",W).call(this,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},x=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},L=function(e,t,i){var s;const[r,o]=(null===(s=window.name)||void 0===s?void 0:s.split("|"))||[],n={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===r&&o){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",o);try{window.opener.postMessage(n,o)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(n),t.close()}try{window.close()}catch(e){}},module.exports=class extends H{static set sdkConfigOverrides(e){H.sdkConfigOverrides=e}static get sdkConfigOverrides(){return H.sdkConfigOverrides}constructor(){const n=new M({deferredRedirect:!1});super(n.update.bind(n)),e.add(this),this.stepState=new M({}),t.set(this,void 0),i.set(this,null),s.set(this,null),r.set(this,{visibilitychange:U.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},p.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},v.set(this,(t=>{const i=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?U.__classPrivateFieldGet(this,e,"m",m).call(this,i):i()})),_.set(this,((e,i,s,r,o=!1)=>{const n=[X.FLOW_TIMED_OUT_ERROR_CODE,X.POLLING_STATUS_NOT_FOUND_ERROR_CODE];if(this.flowState.current.action===j.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),l=o?500:2e3;U.__classPrivateFieldSet(this,t,setTimeout((()=>U.__awaiter(this,void 0,void 0,(function*(){var t,d;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,j.CUSTOM_INTERACTIONS.polling,s,r,{}),h=document.hidden&&!o&&Date.now()-a>l+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield D.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,r,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 U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,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)),(null===(d=null==u?void 0:u.error)||void 0===d?void 0:d.errorCode)&&n.includes(u.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,r),U.__classPrivateFieldGet(this,b,"f").call(this,u)}))),l),"f")}})),f.set(this,(()=>{clearTimeout(U.__classPrivateFieldGet(this,t,"f")),U.__classPrivateFieldSet(this,t,null,"f")})),b.set(this,(t=>{var i,r,o,n,a,l,d,c,h,p,g,v,m;if(!(null==t?void 0:t.ok)){const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;U.__classPrivateFieldGet(this,e,"m",x).call(this,"error",(null==t?void 0:t.error)||{errorCode:X.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:d,errorMessage:s}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void(c!==X.FLOW_REQUESTED_IS_IN_OLD_VERSION_ERROR_CODE&&c!==X.FLOW_TIMED_OUT_ERROR_CODE||!this.isRestartOnError||U.__classPrivateFieldGet(this,e,"m",u).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 _=null===(g=null===(p=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===p?void 0:p.state)||void 0===g?void 0:g.errorText;(null===(v=t.data)||void 0===v?void 0:v.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${_?`${_} - `:""}${t.data.error.message}`):_&&this.loggerWrapper.error(_);const{status:b,authInfo:S,lastAuth:w,action:E,openInNewTabUrl:O}=t.data;if(E!==j.RESPONSE_ACTIONS.poll&&U.__classPrivateFieldGet(this,f,"f").call(this),"completed"===b){this.storeLastAuthenticatedUser&&K.setLastAuth(w);const i=Object.assign({},S);return t.data.output&&Object.keys(t.data.output).length>0&&(i.flowOutput=t.data.output),void U.__classPrivateFieldGet(this,e,"m",x).call(this,"success",i)}this.storeLastAuthenticatedUser&&K.setLastAuth(w,!0),O&&window.open(O,"_blank");const{executionId:P,stepId:C,stepName:I,screen:R,redirect:y,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:k}=t.data,W=Date.now();E!==j.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${I||`#${C}`}" is ${b}`,"",{screen:R,status:b,stepId:C,stepName:I,action:E,error:F}),(null===(m=R.state)||void 0===m?void 0:m.clientScripts)&&U.__classPrivateFieldSet(this,s,this.loadSdkScripts(R.state.clientScripts),"f"),this.flowState.update({stepId:C,stepName:I,executionId:P,action:E,redirectTo:null==y?void 0:y.url,redirectIsPopup:null==y?void 0:y.isPopup,screenId:null==R?void 0:R.id,screenState:null==R?void 0:R.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==k?void 0:k.type,nativePayload:null==k?void 0:k.payload,reqTimestamp:W})):this.flowState.update({action:E,reqTimestamp:W})})),S.set(this,D.withMemCache((()=>U.__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)}}))))),I.set(this,null),A.set(this,D.leadingDebounce(((t,i)=>U.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||U.__classPrivateFieldGet(this,e,"m",P).call(this)){const r=null==t?void 0:t.getAttribute("id");U.__classPrivateFieldGet(this,e,"m",R).call(this,t);const o=yield U.__classPrivateFieldGet(this,e,"m",C).call(this),n=D.getElementDescopeAttributes(t);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},n),o),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin});yield i(r,a),this.nextRequestStatus.update({isLoading:!1}),U.__classPrivateFieldGet(this,e,"m",y).call(this,o)}}))))),this.flowState=n}nativeResume(e,t){var i,s,r,o,n;const a=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=a;if(!e){e=null===(i=new URL(a.url).searchParams)||void 0===i?void 0:i.get(j.URL_CODE_PARAM_NAME)}null===(r=(s=this.nativeCallbacks).complete)||void 0===r||r.call(s,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(a.url),t=e.searchParams.get(j.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(j.URL_RUN_IDS_PARAM_NAME).split("_").pop();U.__classPrivateFieldGet(this,f,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=a;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=a,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(n=(o=this.nativeCallbacks).complete)||void 0===n||n.call(o,a)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[D.getScriptResultPath(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>U.__awaiter(this,void 0,void 0,(function*(){var i,s;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.13",`dist/${e.id}.js`);const o=null===(s=globalThis.descope)||void 0===s?void 0:s[e.id];return new Promise(((i,s)=>{try{const s=o(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(s){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=s,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=s.stop)||void 0===t||t.call(s)}))}}catch(e){s(e)}}))}))))),s=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),j.SDK_SCRIPTS_LOAD_TIMEOUT)}));return Promise.race([i,s])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return U.__awaiter(this,void 0,void 0,(function*(){var i,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),U.__classPrivateFieldGet(this,e,"m",c).call(this),window.addEventListener("visibilitychange",U.__classPrivateFieldGet(this,r,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),U.__classPrivateFieldGet(this,f,"f").call(this),null===(e=U.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),U.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",U.__classPrivateFieldGet(this,r,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return U.__awaiter(this,void 0,void 0,(function*(){let i;const s=D.getUserLocale(e),r=yield this.getTargetLocales();return r.includes(s.locale)?i=`${t}-${s.locale}.html`:r.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return U.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(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 this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,r,o){return U.__awaiter(this,void 0,void 0,(function*(){var n,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:v,screenId:m,screenState:f,redirectTo:S,redirectIsPopup:w,redirectUrl:E,token:O,code:P,isPopup:C,exchangeError:I,webauthnTransactionId:R,webauthnOptions:y,redirectAuthCodeChallenge:T,redirectAuthCallbackUrl:F,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:W,locale:N,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:q,nativeResponseType:H,nativePayload:X,reqTimestamp:J}=t,z=U.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let Q,Y,Z;const ee=V.getABTestingKey(),{outboundAppId:te}=this,{outboundAppScopes:ie}=this,se=this.sdk.getLastUserLoginId(),re=yield this.getFlowConfig(),oe=yield this.getProjectConfig(),ne=Object.entries(oe.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),ae=F&&T?{callbackUrl:F,codeChallenge:T,backupCallbackUri:A}:void 0,le=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let de={};if(!p){const e=[...re.clientScripts||[],...re.sdkScripts||[]];if(re.conditions){let t=[];({startScreenId:Q,conditionInteractionId:Z,startScreenName:Y,clientScripts:t,componentsConfig:de}=B.calculateConditions({loginId:se,code:P,token:O,abTestingKey:ee,lastAuth:K.getLastAuth(se)},re.conditions)),e.push(...t||[])}else re.condition?({startScreenId:Q,conditionInteractionId:Z}=B.calculateCondition(re.condition,{loginId:se,code:P,token:O,abTestingKey:ee,lastAuth:K.getLastAuth(se)})):(Y=re.startScreenName,Q=re.startScreenId);if(U.__classPrivateFieldSet(this,s,this.loadSdkScripts(e),"f"),re.fingerprintEnabled&&re.fingerprintKey?yield G.ensureFingerprintIds(re.fingerprintKey,this.baseUrl):G.clearFingerprintData(),!D.showFirstScreenOnExecutionInit(Q,z)){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:ae},z),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:K.getLastAuth(se),abTestingKey:ee,locale:D.getUserLocale(N).locale,nativeOptions:le,outboundAppId:te,outboundAppScopes:ie}),Z,"",oe.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),P?{exchangeCode:P,idpInitiated:!0}:{}),z.descopeIdpInitiated&&{idpInitiated:!0}),O?{token:O}:{}),z.oidcLoginHint?{externalId:z.oidcLoginHint}:{}));return U.__classPrivateFieldGet(this,b,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:C,code:P,exchangeError:I,isCodeChanged:o("code"),isExchangeErrorChanged:o("exchangeError")})),C&&(o("code")&&P||o("exchangeError")&&I))return void U.__classPrivateFieldGet(this,e,"m",L).call(this,p,P,I);if(p&&(o("token")&&O||o("code")&&P||o("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,u,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,{token:O,exchangeCode:P,exchangeError:I});return U.__classPrivateFieldGet(this,b,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(v===j.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!M||!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");D.injectSamlIdpForm(M,$,q||"",D.submitForm)}if(v===j.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect"))){if(!S)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===S)return;if("android"===W&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const t=D.openCenteredPopup(S,"?",598,700),i=this.shouldUsePopupPostMessage();i&&(t.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(i?"postMessage":"BroadcastChannel"));const s=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const t=i?this.popupOrigin:window.location.origin;if(e.origin!==t)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${t}"`);const{action:s,data:r}=e.data||{};"code"===s&&this.flowState.update({code:r.code,exchangeError:r.exchangeError})};let r;this.loggerWrapper.debug("Starting popup closed detection");const o=setInterval((()=>{t.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(o),U.__classPrivateFieldGet(this,e,"m",x).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(i)window.addEventListener("message",s),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",s)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=s,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(S),this.flowState.update({redirectTo:"no-op"}),U.__classPrivateFieldGet(this,e,"m",x).call(this,"popupclosed",{});return}if(v===j.RESPONSE_ACTIONS.webauthnCreate||v===j.RESPONSE_ACTIONS.webauthnGet){if(!R||!y)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=U.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),U.__classPrivateFieldSet(this,i,null,"f");try{e=v===j.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(y):yield this.sdk.webauthn.helpers.get(y)}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,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,{transactionId:R,response:e,failure:t});U.__classPrivateFieldGet(this,b,"f").call(this,s)}if(v===j.RESPONSE_ACTIONS.nativeBridge)return this.nativeCallbacks.complete=e=>U.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,e);U.__classPrivateFieldGet(this,b,"f").call(this,t)})),void U.__classPrivateFieldGet(this,e,"m",l).call(this,H,X);if(o("action")&&U.__classPrivateFieldGet(this,_,"f").call(this,p,u,re.version,oe.componentsVersion),!m&&!Q)return void this.loggerWrapper.warn("No screen was found to show");const ce=Q||m,he=yield this.getHtmlFilenameWithLocale(N,ce),{oidcLoginHint:ue,oidcPrompt:pe,oidcErrorRedirectUri:ge,oidcResource:ve,samlIdpUsername:me}=z,_e={direction:D.getAnimationDirection(u,r.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:se,name:this.sdk.getLastUserDisplayName()||se},componentsConfig:Object.assign(Object.assign(Object.assign({},re.componentsConfig),de),null==f?void 0:f.componentsConfig)}),htmlFilename:`${ce}.html`,htmlLocaleFilename:he,screenId:ce,stepName:t.stepName||Y,samlIdpUsername:me,oidcLoginHint:ue,oidcPrompt:pe,oidcErrorRedirectUri:ge,oidcResource:ve,action:v},fe=K.getLastAuth(se);D.showFirstScreenOnExecutionInit(Q,z)?_e.next=(t,i)=>U.__awaiter(this,void 0,void 0,(function*(){const s=(null==re?void 0:re.clientScripts)||[];yield U.__classPrivateFieldGet(this,e,"m",k).call(this,s);const r=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:ae},z),{lastAuth:fe,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:D.getUserLocale(N).locale,nativeOptions:le,outboundAppId:te,outboundAppScopes:ie}),Z,t,oe.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),D.transformScreenInputs(i)),P&&{exchangeCode:P,idpInitiated:!0}),z.descopeIdpInitiated&&{idpInitiated:!0}),O&&{token:O}));return U.__classPrivateFieldGet(this,b,"f").call(this,r),r})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(_e.next=(t,i)=>U.__awaiter(this,void 0,void 0,(function*(){const s=(null==f?void 0:f.clientScripts)||[];yield U.__classPrivateFieldGet(this,e,"m",k).call(this,s);const r=yield this.sdk.flow.next(p,u,t,re.version,oe.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),D.transformScreenInputs(i)));return U.__classPrivateFieldGet(this,b,"f").call(this,r),r}))),this.loggerWrapper.debug("Got a screen with id",_e.screenId),yield U.__classPrivateFieldGet(this,e,"m",g).call(this,_e),this.stepState.update(_e)}))}onStepChange(t,i){return U.__awaiter(this,void 0,void 0,(function*(){var s,r;const{htmlFilename:o,htmlLocaleFilename:n,direction:a,next:l,screenState:d}=t;this.loggerWrapper.debug("Rendering a flow screen");const c=document.createElement("template");c.innerHTML=yield this.getPageContent(o,n);const h=c.content.cloneNode(!0),u=this.loadDescopeUiComponents(c);this.sdk.webauthn.helpers.isSupported()?yield U.__classPrivateFieldGet(this,e,"m",E).call(this,h,l):$.disableWebauthnButtons(h),!t.samlIdpUsername||(null===(s=d.form)||void 0===s?void 0:s.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),$.updateTemplateFromScreenState(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:p}=yield this.getExecutionContext();$.setPhoneAutoDetectDefaultCode(h,p);const g=()=>U.__awaiter(this,void 0,void 0,(function*(){var s,r;yield u;const o=this.contentRootElement;$.setTOTPVariable(o,null===(s=null==d?void 0:d.totp)||void 0===s?void 0:s.image),$.setNOTPVariable(o,null===(r=null==d?void 0:d.notp)||void 0===r?void 0:r.image),$.setCssVars(o,h,d.cssVars,this.loggerWrapper),o.replaceChildren(h);const n=!i.htmlFilename;setTimeout((()=>{U.__classPrivateFieldGet(this,e,"m",T).call(this),this.validateOnBlur&&D.handleReportValidityOnBlur(o),$.updateScreenFromScreenState(o,d),U.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:n,isCustomScreen:!1,stepName:t.stepName}),D.handleAutoFocus(o,this.autoFocus,n)})),U.__classPrivateFieldGet(this,e,"m",N).call(this,l);o.querySelector(`[${j.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)&&l(j.CUSTOM_INTERACTIONS.polling,{})}));a?U.__classPrivateFieldGet(this,e,"m",m).call(this,g):g()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};
1
+ "use strict";var e,t,i,s,r,o,n,a,l,d,c,h,u,p,g,v,m,_,f,b,S,w,E,O,P,C,I,R,y,T,F,A,k,W,N,x,L,U=require("tslib"),G=require("@descope/web-js-sdk"),j=require("../constants/index.js"),D=require("../helpers/helpers.js"),M=require("../helpers/state.js"),$=require("../helpers/templates.js"),q=require("../helpers/webauthn.js"),V=require("../helpers/abTestingKey.js"),B=require("../helpers/conditions.js"),K=require("../helpers/lastAuth.js"),H=require("./BaseDescopeWc.js"),X=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,f=new WeakMap,b=new WeakMap,S=new WeakMap,I=new WeakMap,A=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},n=function(t,i,s){return U.__awaiter(this,void 0,void 0,(function*(){var r;return(null===(r=this.nativeOptions)||void 0===r?void 0:r.bridgeVersion)>=2&&new Promise((r=>{this.nativeCallbacks.screenNext=s,this.nativeCallbacks.screenResolve=r,U.__classPrivateFieldGet(this,e,"m",l).call(this,"beforeScreen",{screen:t,context:i})}))}))},a=function(t){var i;(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&U.__classPrivateFieldGet(this,e,"m",l).call(this,"afterScreen",{screen:t})},l=function(t,i){U.__classPrivateFieldGet(this,e,"m",x).call(this,"bridge",{type:t,payload:i})},d=function({errorText:e,errorType:t}){const i=()=>{var i;let s=e;try{s=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}$.replaceElementMessage(this.contentRootElement,"error-message",s)};this.addEventListener("screen-updated",i,{once:!0}),i()},c=function(){var t,i,s;null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=void 0===t?{}:t,s=U.__rest(i,["errorText","errorType"]),r=U.__rest(e,["screenState"]);return Object.assign(Object.assign({},r),{screenState:s})})),null===(i=this.stepState)||void 0===i||i.subscribe(U.__classPrivateFieldGet(this,e,"m",d).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(s=this.stepState)||void 0===s||s.subscribe(U.__classPrivateFieldGet(this,e,"m",h).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0})},h=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),D.handleAutoFocus(this.contentRootElement,this.autoFocus,!1))},u=function(){return U.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.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")}))},g=function(t){return U.__awaiter(this,void 0,void 0,(function*(){var i;const s=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:o}=s,a=U.__rest(s,["next","stepName"]),l=D.transformStepStateForCustomScreen(a);let d=yield U.__classPrivateFieldGet(this,e,"m",n).call(this,o,l,r);d||(d=Boolean(yield null===(i=this.onScreenUpdate)||void 0===i?void 0:i.call(this,o,l,r,this)));const h=!this.stepState.current.htmlFilename;if(U.__classPrivateFieldGet(this,v,"f").call(this,d),U.__classPrivateFieldGet(this,p,"f")!==d){const[t,i]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${i} screen to ${t} screen`),U.__classPrivateFieldSet(this,p,d,"f"),d?this.stepState.unsubscribeAll():U.__classPrivateFieldGet(this,e,"m",c).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),U.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:h,isCustomScreen:d,stepName:t.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},m=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},w=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)}))}},E=function(t,s){return U.__awaiter(this,void 0,void 0,(function*(){var r;null===(r=U.__classPrivateFieldGet(this,i,"f"))||void 0===r||r.abort();const o=t.querySelector('*[autocomplete="webauthn"]');if(o&&(yield q.isConditionalLoginSupported())){const{options:t,transactionId:r}=(yield U.__classPrivateFieldGet(this,S,"f").call(this))||{};t&&r&&(U.__classPrivateFieldGet(this,e,"m",w).call(this,o),U.__classPrivateFieldSet(this,i,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,U.__classPrivateFieldGet(this,i,"f")).then((e=>U.__awaiter(this,void 0,void 0,(function*(){s(o.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},O=function({isFirstScreen:t,isCustomScreen:i,stepName:s}){t&&U.__classPrivateFieldGet(this,e,"m",x).call(this,"ready",{}),i||U.__classPrivateFieldGet(this,e,"m",a).call(this,s),U.__classPrivateFieldGet(this,e,"m",x).call(this,"page-updated",{screenName:s}),U.__classPrivateFieldGet(this,e,"m",x).call(this,"screen-updated",{screenName:s})},P=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},C=function(){return U.__awaiter(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>U.__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})),{})}))},R=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),i=()=>U.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",i),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const s=yield this.getFlowConfig(),r=[...s.clientScripts||[],...s.sdkScripts||[]];this.loadSdkScripts(r)})),s=()=>{var e;window.removeEventListener("pageshow",U.__classPrivateFieldGet(this,I,"f")),U.__classPrivateFieldSet(this,I,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),i())}),"f"),window.addEventListener("pageshow",U.__classPrivateFieldGet(this,I,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,s)=>{e===s&&i(),this.removeEventListener("popupclosed",i),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},r=this.nextRequestStatus.subscribe((({isLoading:o})=>{o?(this.addEventListener("popupclosed",i,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(r),s())}))},y=function(e={}){var t,i;const s=D.getFirstNonEmptyValue(e,["externalId","email","phone"]),r=D.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&r)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:r});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)}},T=function(){D.clearPreviousExternalInputs();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>U.__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}`,r=document.createElement("slot");r.setAttribute("name",s),r.setAttribute("slot",i),e.appendChild(r),t.setAttribute("slot",s),this.appendChild(t)}))},k=function(e){return U.__awaiter(this,void 0,void 0,(function*(){if(U.__classPrivateFieldGet(this,s,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield U.__classPrivateFieldGet(this,s,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}let r=[];for(const e of t)"function"==typeof e.refresh&&r.push(e.refresh());if(r.length>0)try{yield D.timeoutPromise(j.SDK_SCRIPTS_LOAD_TIMEOUT,Promise.all(r),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},W=function(e){this.contentRootElement.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))&&U.__classPrivateFieldGet(this,A,"f").call(this,t,e)}))}))},N=function(t){this.contentRootElement.querySelectorAll(`descope-button:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]), [data-type="button"]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]`).forEach((e=>{e.onclick=()=>{U.__classPrivateFieldGet(this,A,"f").call(this,e,t)}})),U.__classPrivateFieldGet(this,e,"m",W).call(this,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},x=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},L=function(e,t,i){var s;const[r,o]=(null===(s=window.name)||void 0===s?void 0:s.split("|"))||[],n={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===r&&o){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",o);try{window.opener.postMessage(n,o)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(n),t.close()}try{window.close()}catch(e){}},module.exports=class extends H{static set sdkConfigOverrides(e){H.sdkConfigOverrides=e}static get sdkConfigOverrides(){return H.sdkConfigOverrides}constructor(){const n=new M({deferredRedirect:!1});super(n.update.bind(n)),e.add(this),this.stepState=new M({}),t.set(this,void 0),i.set(this,null),s.set(this,null),r.set(this,{visibilitychange:U.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},p.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},v.set(this,(t=>{const i=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?U.__classPrivateFieldGet(this,e,"m",m).call(this,i):i()})),_.set(this,((e,i,s,r,o=!1)=>{const n=[X.FLOW_TIMED_OUT_ERROR_CODE,X.POLLING_STATUS_NOT_FOUND_ERROR_CODE];if(this.flowState.current.action===j.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),l=o?500:2e3;U.__classPrivateFieldSet(this,t,setTimeout((()=>U.__awaiter(this,void 0,void 0,(function*(){var t,d;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,j.CUSTOM_INTERACTIONS.polling,s,r,{}),h=document.hidden&&!o&&Date.now()-a>l+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield D.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,r,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 U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,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)),(null===(d=null==u?void 0:u.error)||void 0===d?void 0:d.errorCode)&&n.includes(u.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):U.__classPrivateFieldGet(this,_,"f").call(this,e,i,s,r),U.__classPrivateFieldGet(this,b,"f").call(this,u)}))),l),"f")}})),f.set(this,(()=>{clearTimeout(U.__classPrivateFieldGet(this,t,"f")),U.__classPrivateFieldSet(this,t,null,"f")})),b.set(this,(t=>{var i,r,o,n,a,l,d,c,h,p,g,v,m;if(!(null==t?void 0:t.ok)){const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;U.__classPrivateFieldGet(this,e,"m",x).call(this,"error",(null==t?void 0:t.error)||{errorCode:X.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:d,errorMessage:s}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void(c!==X.FLOW_REQUESTED_IS_IN_OLD_VERSION_ERROR_CODE&&c!==X.FLOW_TIMED_OUT_ERROR_CODE||!this.isRestartOnError||U.__classPrivateFieldGet(this,e,"m",u).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 _=null===(g=null===(p=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===p?void 0:p.state)||void 0===g?void 0:g.errorText;(null===(v=t.data)||void 0===v?void 0:v.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${_?`${_} - `:""}${t.data.error.message}`):_&&this.loggerWrapper.error(_);const{status:b,authInfo:S,lastAuth:w,action:E,openInNewTabUrl:O}=t.data;if(E!==j.RESPONSE_ACTIONS.poll&&U.__classPrivateFieldGet(this,f,"f").call(this),"completed"===b){this.storeLastAuthenticatedUser&&K.setLastAuth(w);const i=Object.assign({},S);return t.data.output&&Object.keys(t.data.output).length>0&&(i.flowOutput=t.data.output),void U.__classPrivateFieldGet(this,e,"m",x).call(this,"success",i)}this.storeLastAuthenticatedUser&&K.setLastAuth(w,!0),O&&window.open(O,"_blank");const{executionId:P,stepId:C,stepName:I,screen:R,redirect:y,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:k}=t.data,W=Date.now();E!==j.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${I||`#${C}`}" is ${b}`,"",{screen:R,status:b,stepId:C,stepName:I,action:E,error:F}),(null===(m=R.state)||void 0===m?void 0:m.clientScripts)&&U.__classPrivateFieldSet(this,s,this.loadSdkScripts(R.state.clientScripts),"f"),this.flowState.update({stepId:C,stepName:I,executionId:P,action:E,redirectTo:null==y?void 0:y.url,redirectIsPopup:null==y?void 0:y.isPopup,screenId:null==R?void 0:R.id,screenState:null==R?void 0:R.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==k?void 0:k.type,nativePayload:null==k?void 0:k.payload,reqTimestamp:W})):this.flowState.update({action:E,reqTimestamp:W})})),S.set(this,D.withMemCache((()=>U.__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)}}))))),I.set(this,null),A.set(this,D.leadingDebounce(((t,i)=>U.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||U.__classPrivateFieldGet(this,e,"m",P).call(this)){const r=null==t?void 0:t.getAttribute("id");U.__classPrivateFieldGet(this,e,"m",R).call(this,t);const o=yield U.__classPrivateFieldGet(this,e,"m",C).call(this),n=D.getElementDescopeAttributes(t);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},n),o),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin});yield i(r,a),this.nextRequestStatus.update({isLoading:!1}),U.__classPrivateFieldGet(this,e,"m",y).call(this,o)}}))))),this.flowState=n}nativeResume(e,t){var i,s,r,o,n;const a=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=a;if(!e){e=null===(i=new URL(a.url).searchParams)||void 0===i?void 0:i.get(j.URL_CODE_PARAM_NAME)}null===(r=(s=this.nativeCallbacks).complete)||void 0===r||r.call(s,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(a.url),t=e.searchParams.get(j.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(j.URL_RUN_IDS_PARAM_NAME).split("_").pop();U.__classPrivateFieldGet(this,f,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=a;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=a,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(n=(o=this.nativeCallbacks).complete)||void 0===n||n.call(o,a)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[D.getScriptResultPath(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>U.__awaiter(this,void 0,void 0,(function*(){var i,s;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.13",`dist/${e.id}.js`);const o=null===(s=globalThis.descope)||void 0===s?void 0:s[e.id];return new Promise(((i,s)=>{try{const s=o(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(s){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=s,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=s.stop)||void 0===t||t.call(s)}))}}catch(e){s(e)}}))}))))),s=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),j.SDK_SCRIPTS_LOAD_TIMEOUT)}));return Promise.race([i,s])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return U.__awaiter(this,void 0,void 0,(function*(){var i,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),U.__classPrivateFieldGet(this,e,"m",c).call(this),window.addEventListener("visibilitychange",U.__classPrivateFieldGet(this,r,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),U.__classPrivateFieldGet(this,f,"f").call(this),null===(e=U.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),U.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",U.__classPrivateFieldGet(this,r,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return U.__awaiter(this,void 0,void 0,(function*(){let i;const s=D.getUserLocale(e),r=yield this.getTargetLocales();return r.includes(s.locale)?i=`${t}-${s.locale}.html`:r.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return U.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(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 this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,r,o){return U.__awaiter(this,void 0,void 0,(function*(){var n,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:v,screenId:m,screenState:f,redirectTo:S,redirectIsPopup:w,redirectUrl:E,token:O,code:P,isPopup:C,exchangeError:I,webauthnTransactionId:R,webauthnOptions:y,redirectAuthCodeChallenge:T,redirectAuthCallbackUrl:F,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:W,locale:N,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:q,nativeResponseType:H,nativePayload:X,reqTimestamp:J}=t,z=U.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let Q,Y,Z;const ee=V.getABTestingKey(),{outboundAppId:te}=this,{outboundAppScopes:ie}=this,se=this.sdk.getLastUserLoginId(),re=yield this.getFlowConfig(),oe=yield this.getProjectConfig(),ne=Object.entries(oe.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),ae=F&&T?{callbackUrl:F,codeChallenge:T,backupCallbackUri:A}:void 0,le=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let de={};if(!p){const e=[...re.clientScripts||[],...re.sdkScripts||[]];if(re.conditions){let t=[];({startScreenId:Q,conditionInteractionId:Z,startScreenName:Y,clientScripts:t,componentsConfig:de}=B.calculateConditions({loginId:se,code:P,token:O,abTestingKey:ee,lastAuth:K.getLastAuth(se)},re.conditions)),e.push(...t||[])}else re.condition?({startScreenId:Q,conditionInteractionId:Z}=B.calculateCondition(re.condition,{loginId:se,code:P,token:O,abTestingKey:ee,lastAuth:K.getLastAuth(se)})):(Y=re.startScreenName,Q=re.startScreenId);if(U.__classPrivateFieldSet(this,s,this.loadSdkScripts(e),"f"),re.fingerprintEnabled&&re.fingerprintKey?yield G.ensureFingerprintIds(re.fingerprintKey,this.baseUrl):G.clearFingerprintData(),!D.showFirstScreenOnExecutionInit(Q,z)){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:ae},z),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:K.getLastAuth(se),abTestingKey:ee,locale:D.getUserLocale(N).locale,nativeOptions:le,outboundAppId:te,outboundAppScopes:ie}),Z,"",oe.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),P?{exchangeCode:P,idpInitiated:!0}:{}),z.descopeIdpInitiated&&{idpInitiated:!0}),O?{token:O}:{}),z.oidcLoginHint?{externalId:z.oidcLoginHint}:{}));return U.__classPrivateFieldGet(this,b,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:C,code:P,exchangeError:I,isCodeChanged:o("code"),isExchangeErrorChanged:o("exchangeError")})),C&&(o("code")&&P||o("exchangeError")&&I))return void U.__classPrivateFieldGet(this,e,"m",L).call(this,p,P,I);if(p&&(o("token")&&O||o("code")&&P||o("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,u,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,{token:O,exchangeCode:P,exchangeError:I});return U.__classPrivateFieldGet(this,b,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(v===j.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!M||!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");D.injectSamlIdpForm(M,$,q||"",D.submitForm)}if(v===j.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect"))){if(!S)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===S)return;if("android"===W&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const t=D.openCenteredPopup(S,"?",598,700),i=this.shouldUsePopupPostMessage();i&&(t.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(i?"postMessage":"BroadcastChannel"));const s=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const t=i?this.popupOrigin:window.location.origin;if(e.origin!==t)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${t}"`);const{action:s,data:r}=e.data||{};"code"===s&&this.flowState.update({code:r.code,exchangeError:r.exchangeError})};let r;this.loggerWrapper.debug("Starting popup closed detection");const o=setInterval((()=>{t.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(o),U.__classPrivateFieldGet(this,e,"m",x).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(i)window.addEventListener("message",s),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",s)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=s,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(S),this.flowState.update({redirectTo:"no-op"}),U.__classPrivateFieldGet(this,e,"m",x).call(this,"popupclosed",{});return}if(v===j.RESPONSE_ACTIONS.webauthnCreate||v===j.RESPONSE_ACTIONS.webauthnGet){if(!R||!y)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=U.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),U.__classPrivateFieldSet(this,i,null,"f");try{e=v===j.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(y):yield this.sdk.webauthn.helpers.get(y)}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,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,{transactionId:R,response:e,failure:t});U.__classPrivateFieldGet(this,b,"f").call(this,s)}if(v===j.RESPONSE_ACTIONS.nativeBridge)return this.nativeCallbacks.complete=e=>U.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,j.CUSTOM_INTERACTIONS.submit,re.version,oe.componentsVersion,e);U.__classPrivateFieldGet(this,b,"f").call(this,t)})),void U.__classPrivateFieldGet(this,e,"m",l).call(this,H,X);if(o("action")&&U.__classPrivateFieldGet(this,_,"f").call(this,p,u,re.version,oe.componentsVersion),!m&&!Q)return void this.loggerWrapper.warn("No screen was found to show");const ce=Q||m,he=yield this.getHtmlFilenameWithLocale(N,ce),{oidcLoginHint:ue,oidcPrompt:pe,oidcErrorRedirectUri:ge,oidcResource:ve,samlIdpUsername:me}=z,_e={direction:D.getAnimationDirection(u,r.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:se,name:this.sdk.getLastUserDisplayName()||se},componentsConfig:Object.assign(Object.assign(Object.assign({},re.componentsConfig),de),null==f?void 0:f.componentsConfig)}),htmlFilename:`${ce}.html`,htmlLocaleFilename:he,screenId:ce,stepName:t.stepName||Y,samlIdpUsername:me,oidcLoginHint:ue,oidcPrompt:pe,oidcErrorRedirectUri:ge,oidcResource:ve,action:v},fe=K.getLastAuth(se);D.showFirstScreenOnExecutionInit(Q,z)?_e.next=(t,i)=>U.__awaiter(this,void 0,void 0,(function*(){const s=(null==re?void 0:re.clientScripts)||[];yield U.__classPrivateFieldGet(this,e,"m",k).call(this,s);const r=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:ae},z),{lastAuth:fe,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:D.getUserLocale(N).locale,nativeOptions:le,outboundAppId:te,outboundAppScopes:ie}),Z,t,oe.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),D.transformScreenInputs(i)),P&&{exchangeCode:P,idpInitiated:!0}),z.descopeIdpInitiated&&{idpInitiated:!0}),O&&{token:O}));return U.__classPrivateFieldGet(this,b,"f").call(this,r),r})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(_e.next=(t,i)=>U.__awaiter(this,void 0,void 0,(function*(){const s=(null==f?void 0:f.clientScripts)||[];yield U.__classPrivateFieldGet(this,e,"m",k).call(this,s);const r=yield this.sdk.flow.next(p,u,t,re.version,oe.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),D.transformScreenInputs(i)));return U.__classPrivateFieldGet(this,b,"f").call(this,r),r}))),this.loggerWrapper.debug("Got a screen with id",_e.screenId),yield U.__classPrivateFieldGet(this,e,"m",g).call(this,_e),this.stepState.update(_e)}))}onStepChange(t,i){return U.__awaiter(this,void 0,void 0,(function*(){var s,r;const{htmlFilename:o,htmlLocaleFilename:n,direction:a,next:l,screenState:d}=t;this.loggerWrapper.debug("Rendering a flow screen");const c=document.createElement("template");c.innerHTML=yield this.getPageContent(o,n);const h=c.content.cloneNode(!0),u=this.loadDescopeUiComponents(c);this.sdk.webauthn.helpers.isSupported()?yield U.__classPrivateFieldGet(this,e,"m",E).call(this,h,l):$.disableWebauthnButtons(h),!t.samlIdpUsername||(null===(s=d.form)||void 0===s?void 0:s.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),$.updateTemplateFromScreenState(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:p}=yield this.getExecutionContext();$.setPhoneAutoDetectDefaultCode(h,p);const g=()=>U.__awaiter(this,void 0,void 0,(function*(){var s,r;yield u;const o=this.contentRootElement;$.setTOTPVariable(o,null===(s=null==d?void 0:d.totp)||void 0===s?void 0:s.image),$.setNOTPVariable(o,null===(r=null==d?void 0:d.notp)||void 0===r?void 0:r.image),$.setCssVars(o,h,d.cssVars,this.loggerWrapper),o.replaceChildren(h);const n=!i.htmlFilename;setTimeout((()=>{U.__classPrivateFieldGet(this,e,"m",T).call(this),this.validateOnBlur&&D.handleReportValidityOnBlur(o),$.updateScreenFromScreenState(o,d),U.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:n,isCustomScreen:!1,stepName:t.stepName}),D.handleAutoFocus(o,this.autoFocus,n)})),U.__classPrivateFieldGet(this,e,"m",N).call(this,l);o.querySelector(`[${j.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)&&l(j.CUSTOM_INTERACTIONS.polling,{})}));a?U.__classPrivateFieldGet(this,e,"m",m).call(this,g):g()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${j.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};
2
2
  //# sourceMappingURL=DescopeWc.js.map