@descope/web-component 3.58.0 → 3.58.2

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,k,C,P,F,y,A,E,x,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",C).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",E).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",k).call(this),yield t.__classPrivateFieldGet(this,u,"m",y).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",x).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",k).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)},k=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`)}))},C=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],r=a.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{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)}))},y=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",A).call(this))}))},A=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}}))},E=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},x=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",x).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.58.0"}},module.exports=R;
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,k,C,P,F,y,A,E,x,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",C).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",E).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",k).call(this),yield t.__classPrivateFieldGet(this,u,"m",y).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",x).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",k).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)},k=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`)}))},C=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],r=a.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{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)}))},y=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",A).call(this))}))},A=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}}))},E=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},x=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",x).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.58.2"}},module.exports=R;
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("tslib"),t=require("@descope/escape-markdown"),o=require("../constants/index.js"),r=require("./helpers.js");const s=["disabled"],n=(e,t)=>{Object.entries(t||{}).forEach((([t,r])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${o.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`)).forEach((e=>{e.value=r}))}))},c=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),l=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,s)=>r?t.escapeMarkdown(c(o,s)):c(o,s))),a=(e,t,r)=>{e.querySelectorAll(`[${o.ELEMENT_TYPE_ATTRIBUTE}="${t}"]`).forEach((e=>{e.setAttribute("href",r)}))},i=(e,t,o)=>{var r,s;const n=null===(r=customElements.get(t))||void 0===r?void 0:r.cssVarList.url;o&&n&&(null===(s=null==e?void 0:e.style)||void 0===s||s.setProperty(n,`url(data:image/jpg;base64,${o})`))};exports.disableWebauthnButtons=e=>{e.querySelectorAll(`descope-button[${o.ELEMENT_TYPE_ATTRIBUTE}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))},exports.replaceElementMessage=(e,t,r="")=>{e.querySelectorAll(`[${o.ELEMENT_TYPE_ATTRIBUTE}="${t}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))},exports.setComponentsAutoDetectByGeo=(e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},exports.setComponentsAutoDetectByLocale=(e,t)=>{Object.entries({lang:"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},exports.setCssVars=(e,t,o,r)=>{o&&Object.keys(o).forEach((s=>{if(!t.querySelector(s))return void r.debug(`Skipping css vars for component "${s}"`,`Got css vars for component ${s} but Could not find it on next page`);const n=customElements.get(s);n?Object.keys(o[s]).forEach((t=>{var c;const l=o[s],a=null===(c=null==n?void 0:n.cssVarList)||void 0===c?void 0:c[t];if(!a)return void r.info(`Could not find css variable name for ${t} in ${s}`,"Check if the css variable is defined in the component");const i=l[t];e.style.setProperty(a,i)})):r.debug(`Could not find component class for ${s}`,"Check if the component is registered")}))},exports.setNOTPVariable=(e,t)=>{i(e,"descope-notp-image",t)},exports.setTOTPVariable=(e,t)=>{i(e,"descope-totp-image",t)},exports.updateScreenFromScreenState=(e,t)=>{n(e,null==t?void 0:t.inputs),n(e,null==t?void 0:t.form)},exports.updateTemplateFromScreenState=(t,n,c,i)=>{var u,d;a(t,"totp-link",null===(u=null==n?void 0:n.totp)||void 0===u?void 0:u.provisionUrl),a(t,"notp-link",null===(d=null==n?void 0:n.notp)||void 0===d?void 0:d.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=r.shouldHandleMarkdown(e.localName);e.textContent=l(e.textContent,t,o);const s=e.getAttribute("href");s&&e.setAttribute("href",l(s,t))}))})(t,n),((t,o,r)=>{if(!o)return;const{componentsDynamicAttrs:s}=o,n=e.__rest(o,["componentsDynamicAttrs"]),c=Object.keys(n).reduce(((e,t)=>(e[`[name=${t}]`]=n[t],e)),{});s&&Object.keys(s).forEach((e=>{const t=s[e];if(t){const{attributes:o}=t;o&&Object.keys(o).length&&(c[e]=o)}})),Object.keys(c).forEach((e=>{t.querySelectorAll(e).forEach((t=>{const o=c[e];Object.keys(o).forEach((e=>{let s=o[e];if("string"!=typeof s)try{s=JSON.stringify(s)}catch(t){r.error(`Could not stringify value "${s}" for "${e}"`,t.message),s=""}t.setAttribute(e,s)}))}))}))})(t,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll(`[${o.HAS_DYNAMIC_VALUES_ATTR_NAME}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=l(e.value,t)}))}))})(t,n),((e,t)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(o).forEach((([t,o])=>{s.includes(t)&&e.setAttribute(t,o)}))}))}))})(t,c),((e,t={},o)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(r){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==o||o.error(`Unknown component state "${r}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(t,null==n?void 0:n.componentsState,i)};
1
+ "use strict";var e=require("tslib"),t=require("@descope/escape-markdown"),o=require("../constants/index.js"),r=require("./helpers.js");const s=["disabled"],n=(e,t)=>{Object.entries(t||{}).forEach((([t,r])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${o.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`)).forEach((e=>{e.value=r}))}))},c=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),l=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,s)=>r?t.escapeMarkdown(c(o,s)):c(o,s))),a=(e,t,r)=>{e.querySelectorAll(`[${o.ELEMENT_TYPE_ATTRIBUTE}="${t}"]`).forEach((e=>{e.setAttribute("href",r)}))},i=(e,t,o)=>{var r,s;const n=null===(r=customElements.get(t))||void 0===r?void 0:r.cssVarList.url;o&&n&&(null===(s=null==e?void 0:e.style)||void 0===s||s.setProperty(n,`url(data:image/jpg;base64,${o})`))};exports.disableWebauthnButtons=e=>{e.querySelectorAll(`descope-button[${o.ELEMENT_TYPE_ATTRIBUTE}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))},exports.replaceElementMessage=(e,t,r="")=>{e.querySelectorAll(`[${o.ELEMENT_TYPE_ATTRIBUTE}="${t}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))},exports.setComponentsAutoDetectByGeo=(e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},exports.setComponentsAutoDetectByLocale=(e,t)=>{let o=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(o=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,r])=>{Array.from(e.querySelectorAll(`[${t}="${r}"]`)).forEach((e=>{e.setAttribute(t,o||r)}))}))},exports.setCssVars=(e,t,o,r)=>{o&&Object.keys(o).forEach((s=>{if(!t.querySelector(s))return void r.debug(`Skipping css vars for component "${s}"`,`Got css vars for component ${s} but Could not find it on next page`);const n=customElements.get(s);n?Object.keys(o[s]).forEach((t=>{var c;const l=o[s],a=null===(c=null==n?void 0:n.cssVarList)||void 0===c?void 0:c[t];if(!a)return void r.info(`Could not find css variable name for ${t} in ${s}`,"Check if the css variable is defined in the component");const i=l[t];e.style.setProperty(a,i)})):r.debug(`Could not find component class for ${s}`,"Check if the component is registered")}))},exports.setNOTPVariable=(e,t)=>{i(e,"descope-notp-image",t)},exports.setTOTPVariable=(e,t)=>{i(e,"descope-totp-image",t)},exports.updateScreenFromScreenState=(e,t)=>{n(e,null==t?void 0:t.inputs),n(e,null==t?void 0:t.form)},exports.updateTemplateFromScreenState=(t,n,c,i)=>{var u,d;a(t,"totp-link",null===(u=null==n?void 0:n.totp)||void 0===u?void 0:u.provisionUrl),a(t,"notp-link",null===(d=null==n?void 0:n.notp)||void 0===d?void 0:d.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=r.shouldHandleMarkdown(e.localName);e.textContent=l(e.textContent,t,o);const s=e.getAttribute("href");s&&e.setAttribute("href",l(s,t))}))})(t,n),((t,o,r)=>{if(!o)return;const{componentsDynamicAttrs:s}=o,n=e.__rest(o,["componentsDynamicAttrs"]),c=Object.keys(n).reduce(((e,t)=>(e[`[name=${t}]`]=n[t],e)),{});s&&Object.keys(s).forEach((e=>{const t=s[e];if(t){const{attributes:o}=t;o&&Object.keys(o).length&&(c[e]=o)}})),Object.keys(c).forEach((e=>{t.querySelectorAll(e).forEach((t=>{const o=c[e];Object.keys(o).forEach((e=>{let s=o[e];if("string"!=typeof s)try{s=JSON.stringify(s)}catch(t){r.error(`Could not stringify value "${s}" for "${e}"`,t.message),s=""}t.setAttribute(e,s)}))}))}))})(t,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll(`[${o.HAS_DYNAMIC_VALUES_ATTR_NAME}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=l(e.value,t)}))}))})(t,n),((e,t)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(o).forEach((([t,o])=>{s.includes(t)&&e.setAttribute(t,o)}))}))}))})(t,c),((e,t={},o)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(r){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==o||o.error(`Unknown component state "${r}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(t,null==n?void 0:n.componentsState,i)};
2
2
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sources":["../../../src/lib/helpers/templates.ts"],"sourcesContent":["import { escapeMarkdown } from '@descope/escape-markdown';\nimport {\n ELEMENT_TYPE_ATTRIBUTE,\n DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,\n HAS_DYNAMIC_VALUES_ATTR_NAME,\n} from '../constants';\nimport { ComponentsConfig, CssVars, ScreenState } from '../types';\nimport { shouldHandleMarkdown } from './helpers';\n\nconst ALLOWED_INPUT_CONFIG_ATTRS = ['disabled'];\n\nexport const replaceElementMessage = (\n baseEle: HTMLElement,\n eleType: string,\n message = '',\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${eleType}\"]`,\n );\n eleList.forEach((ele: HTMLElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.textContent = message;\n ele.classList[message ? 'remove' : 'add']('hide');\n });\n};\n\n/**\n * Replace the 'value' attribute of screen inputs with screen state's inputs.\n * For example: if base element contains '<input name=\"key1\" ...>' and screen input is in form of { key1: 'val1' },\n * it will add 'val1' as the input value\n */\nconst replaceElementInputs = (\n baseEle: HTMLElement,\n screenInputs: Record<string, string>,\n) => {\n Object.entries(screenInputs || {}).forEach(([name, value]) => {\n const inputEls = Array.from(\n baseEle.querySelectorAll(\n `*[name=\"${name}\"]:not([${DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`,\n ),\n ) as HTMLInputElement[];\n inputEls.forEach((inputEle) => {\n // eslint-disable-next-line no-param-reassign\n inputEle.value = value;\n });\n });\n};\n\n/**\n * Get object nested path.\n * Examples:\n * - getByPath({ { a { b: 'rob' } }, 'a.b') => 'hey rob'\n * - getByPath({}, 'a.b') => ''\n */\nconst getByPath = (obj: Record<string, any>, path: string) =>\n path.split('.').reduce((prev, next) => prev?.[next] || '', obj);\n\n/**\n * Apply template language on text, based on screen state.\n * Examples:\n * - 'hey {{a.b}}', { a { b: 'rob' }} => 'hey rob'\n * - 'hey {{not.exists}}', {} => 'hey '\n */\nconst applyTemplates = (\n text: string,\n screenState?: Record<string, any>,\n handleMarkdown?: boolean,\n): string =>\n text.replace(/{{(.+?)}}/g, (_, match) =>\n handleMarkdown\n ? escapeMarkdown(getByPath(screenState, match))\n : getByPath(screenState, match),\n );\n\n/**\n * Replace the templates of content of inner text/link elements with screen state data\n */\nconst replaceElementTemplates = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(\n 'descope-text,descope-link,descope-enriched-text,descope-code-snippet',\n );\n eleList.forEach((inEle: HTMLElement) => {\n const handleMarkdown = shouldHandleMarkdown(inEle.localName);\n // eslint-disable-next-line no-param-reassign\n inEle.textContent = applyTemplates(\n inEle.textContent,\n screenState,\n handleMarkdown,\n );\n const href = inEle.getAttribute('href');\n if (href) {\n inEle.setAttribute('href', applyTemplates(href, screenState));\n }\n });\n};\n\nconst replaceTemplateDynamicAttrValues = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(`[${HAS_DYNAMIC_VALUES_ATTR_NAME}]`);\n eleList.forEach((ele: HTMLElement) => {\n Array.from(ele.attributes).forEach((attr) => {\n // eslint-disable-next-line no-param-reassign\n attr.value = applyTemplates(attr.value, screenState);\n });\n });\n};\n\nconst replaceHrefByDataType = (\n baseEle: DocumentFragment,\n dataType: string,\n provisionUrl?: string,\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${dataType}\"]`,\n );\n eleList.forEach((ele: HTMLLinkElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.setAttribute('href', provisionUrl);\n });\n};\n\nconst setFormConfigValues = (\n baseEle: DocumentFragment,\n formData: Record<string, string>,\n) => {\n Object.entries(formData).forEach(([name, config]) => {\n const eles = baseEle.querySelectorAll(`[name=\"${name}\"]`);\n\n eles.forEach((ele) => {\n Object.entries(config).forEach(([attrName, attrValue]) => {\n if (ALLOWED_INPUT_CONFIG_ATTRS.includes(attrName)) {\n ele.setAttribute(attrName, attrValue);\n }\n });\n });\n });\n};\n\nexport const setCssVars = (\n rootEle: HTMLElement,\n nextPageTemplate: DocumentFragment,\n cssVars: CssVars,\n logger: {\n error: (message: string, description: string) => void;\n info: (message: string, description: string) => void;\n debug: (message: string, description: string) => void;\n },\n) => {\n if (!cssVars) {\n return;\n }\n\n Object.keys(cssVars).forEach((componentName) => {\n if (!nextPageTemplate.querySelector(componentName)) {\n logger.debug(\n `Skipping css vars for component \"${componentName}\"`,\n `Got css vars for component ${componentName} but Could not find it on next page`,\n );\n\n return;\n }\n const componentClass:\n | (CustomElementConstructor & { cssVarList: CssVars })\n | undefined = customElements.get(componentName) as any;\n\n if (!componentClass) {\n logger.debug(\n `Could not find component class for ${componentName}`,\n 'Check if the component is registered',\n );\n\n return;\n }\n\n Object.keys(cssVars[componentName]).forEach((cssVarKey) => {\n const componentCssVars = cssVars[componentName];\n const varName = componentClass?.cssVarList?.[cssVarKey];\n\n if (!varName) {\n logger.info(\n `Could not find css variable name for ${cssVarKey} in ${componentName}`,\n 'Check if the css variable is defined in the component',\n );\n return;\n }\n\n const value = componentCssVars[cssVarKey];\n\n rootEle.style.setProperty(varName, value);\n });\n });\n};\n\nconst setElementConfig = (\n baseEle: DocumentFragment,\n componentsConfig: ComponentsConfig,\n logger?: { error: (message: string, description: string) => void },\n) => {\n if (!componentsConfig) {\n return;\n }\n const { componentsDynamicAttrs, ...rest } = componentsConfig;\n\n const configMap = Object.keys(rest).reduce((acc, componentName) => {\n acc[`[name=${componentName}]`] = rest[componentName];\n return acc;\n }, {});\n\n if (componentsDynamicAttrs) {\n Object.keys(componentsDynamicAttrs).forEach((componentSelector) => {\n const componentDynamicAttrs = componentsDynamicAttrs[componentSelector];\n if (componentDynamicAttrs) {\n const { attributes } = componentDynamicAttrs;\n if (attributes && Object.keys(attributes).length) {\n configMap[componentSelector] = attributes;\n }\n }\n });\n }\n\n // collect components that needs configuration from DOM\n Object.keys(configMap).forEach((componentsSelector) => {\n baseEle.querySelectorAll(componentsSelector).forEach((comp) => {\n const config = configMap[componentsSelector];\n\n Object.keys(config).forEach((attr) => {\n let value = config[attr];\n\n if (typeof value !== 'string') {\n try {\n value = JSON.stringify(value);\n } catch (e) {\n logger.error(\n `Could not stringify value \"${value}\" for \"${attr}\"`,\n e.message,\n );\n value = '';\n }\n }\n\n comp.setAttribute(attr, value);\n });\n });\n });\n};\n\nconst setImageVariable = (\n rootEle: HTMLElement,\n name: string,\n image?: string,\n) => {\n const imageVarName = (\n customElements.get(name) as CustomElementConstructor & {\n cssVarList: Record<string, string>;\n }\n )?.cssVarList.url;\n\n if (image && imageVarName) {\n rootEle?.style?.setProperty(\n imageVarName,\n `url(data:image/jpg;base64,${image})`,\n );\n }\n};\n\nconst applyComponentsState = (\n baseEle: DocumentFragment,\n componentsState: Record<string, string> = {},\n logger?: { error: (message: string, description: string) => void },\n) => {\n Object.entries(componentsState).forEach(([componentId, state]) => {\n const componentEls = baseEle.querySelectorAll(\n `[id=\"${CSS.escape(componentId)}\"]`,\n );\n componentEls.forEach((compEl) => {\n switch (state) {\n case 'disable':\n compEl.setAttribute('disabled', 'true');\n break;\n case 'hide':\n compEl.classList.add('hidden');\n break;\n default:\n logger?.error(\n `Unknown component state \"${state}\" for component with id \"${componentId}\"`,\n 'Valid states are \"disable\" and \"hide\"',\n );\n break;\n }\n });\n });\n};\n\n/**\n * Update a screen template based on the screen state\n * - Show/hide error messages\n * - Replace element templates ({{...}} syntax) with screen state object\n */\nexport const updateTemplateFromScreenState = (\n baseEle: DocumentFragment,\n screenState?: ScreenState,\n flowInputs?: Record<string, string>,\n logger?: { error: (message: string, description: string) => void },\n) => {\n replaceHrefByDataType(baseEle, 'totp-link', screenState?.totp?.provisionUrl);\n replaceHrefByDataType(baseEle, 'notp-link', screenState?.notp?.redirectUrl);\n replaceElementTemplates(baseEle, screenState);\n setElementConfig(baseEle, screenState?.componentsConfig, logger);\n replaceTemplateDynamicAttrValues(baseEle, screenState);\n setFormConfigValues(baseEle, flowInputs);\n applyComponentsState(baseEle, screenState?.componentsState, logger);\n};\n\n/**\n * Update a screen based on a screen state\n * - Replace values of element inputs with screen state's inputs\n */\nexport const updateScreenFromScreenState = (\n baseEle: HTMLElement,\n screenState?: ScreenState,\n) => {\n replaceElementInputs(baseEle, screenState?.inputs);\n replaceElementInputs(baseEle, screenState?.form);\n};\n\nexport const setTOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-totp-image', image);\n};\n\nexport const setNOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-notp-image', image);\n};\n\nexport const setComponentsAutoDetectByGeo = (\n fragment: DocumentFragment,\n countryCodeIso2?: string, // e.g. 'US', 'IL', 'FR'\n) => {\n const config = {\n // phone\n 'default-code': 'autoDetect',\n // country-subdivision-city\n 'default-country': 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, countryCodeIso2 || value);\n },\n );\n });\n};\n\nexport const setComponentsAutoDetectByLocale = (\n fragment: DocumentFragment,\n locale?: string, // e.g. 'en-US', 'fr-FR'\n) => {\n const config = {\n // country-subdivision-city\n lang: 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, locale || value);\n },\n );\n });\n};\n\nexport const disableWebauthnButtons = (fragment: DocumentFragment) => {\n const webauthnButtons = fragment.querySelectorAll(\n `descope-button[${ELEMENT_TYPE_ATTRIBUTE}=\"biometrics\"]`,\n );\n webauthnButtons.forEach((button) => button.setAttribute('disabled', 'true'));\n};\n\nexport const getDescopeUiComponentsList = (clone: DocumentFragment) => [\n ...Array.from(clone.querySelectorAll('*')).reduce<Set<string>>(\n (acc, el: HTMLElement) =>\n el.tagName.startsWith('DESCOPE-')\n ? acc.add(el.tagName.toLocaleLowerCase())\n : acc,\n new Set(),\n ),\n];\n"],"names":["ALLOWED_INPUT_CONFIG_ATTRS","replaceElementInputs","baseEle","screenInputs","Object","entries","forEach","name","value","Array","from","querySelectorAll","DESCOPE_ATTRIBUTE_EXCLUDE_FIELD","inputEle","getByPath","obj","path","split","reduce","prev","next","applyTemplates","text","screenState","handleMarkdown","replace","_","match","escapeMarkdown","replaceHrefByDataType","dataType","provisionUrl","ELEMENT_TYPE_ATTRIBUTE","ele","setAttribute","setImageVariable","rootEle","image","imageVarName","_a","customElements","get","cssVarList","url","_b","style","setProperty","fragment","button","eleType","message","textContent","classList","countryCodeIso2","key","locale","lang","nextPageTemplate","cssVars","logger","keys","componentName","querySelector","debug","componentClass","cssVarKey","componentCssVars","varName","info","inputs","form","flowInputs","totp","notp","redirectUrl","inEle","shouldHandleMarkdown","localName","href","getAttribute","replaceElementTemplates","componentsConfig","componentsDynamicAttrs","rest","__rest","configMap","acc","componentSelector","componentDynamicAttrs","attributes","length","componentsSelector","comp","config","attr","JSON","stringify","e","error","setElementConfig","HAS_DYNAMIC_VALUES_ATTR_NAME","replaceTemplateDynamicAttrValues","formData","attrName","attrValue","includes","setFormConfigValues","componentsState","componentId","state","CSS","escape","compEl","add","applyComponentsState"],"mappings":"uIASA,MAAMA,EAA6B,CAAC,YAsB9BC,EAAuB,CAC3BC,EACAC,KAEAC,OAAOC,QAAQF,GAAgB,CAAE,GAAEG,SAAQ,EAAEC,EAAMC,MAChCC,MAAMC,KACrBR,EAAQS,iBACN,WAAWJ,YAAeK,EAAAA,sCAGrBN,SAASO,IAEhBA,EAASL,MAAQA,CAAK,GACtB,GACF,EASEM,EAAY,CAACC,EAA0BC,IAC3CA,EAAKC,MAAM,KAAKC,QAAO,CAACC,EAAMC,KAASD,aAAI,EAAJA,EAAOC,KAAS,IAAIL,GAQvDM,EAAiB,CACrBC,EACAC,EACAC,IAEAF,EAAKG,QAAQ,cAAc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EAlG,OAAOC,QAAQiG,GAAUhG,SAAQ,EAAEC,EAAMsF,MAC1B3F,EAAQS,iBAAiB,UAAUJ,OAE3CD,SAAS2B,IACZ7B,OAAOC,QAAQwF,GAAQvF,SAAQ,EAAEiG,EAAUC,MACrCxG,EAA2ByG,SAASF,IACtCtE,EAAIC,aAAaqE,EAAUC,EAC5B,GACD,GACF,GACF,EA8KFE,CAAoBxG,EAASqE,GA5CF,EAC3BrE,EACAyG,EAA0C,CAAA,EAC1ChD,KAEAvD,OAAOC,QAAQsG,GAAiBrG,SAAQ,EAAEsG,EAAaC,MAChC3G,EAAQS,iBAC3B,QAAQmG,IAAIC,OAAOH,QAERtG,SAAS0G,IACpB,OAAQH,GACN,IAAK,UACHG,EAAO9E,aAAa,WAAY,QAChC,MACF,IAAK,OACH8E,EAAO5D,UAAU6D,IAAI,UACrB,MACF,QACEtD,SAAAA,EAAQuC,MACN,4BAA4BW,6BAAiCD,KAC7D,yCAGL,GACD,GACF,EAoBFM,CAAqBhH,EAASqB,aAAA,EAAAA,EAAaoF,gBAAiBhD,EAAO"}
1
+ {"version":3,"file":"templates.js","sources":["../../../src/lib/helpers/templates.ts"],"sourcesContent":["import { escapeMarkdown } from '@descope/escape-markdown';\nimport {\n ELEMENT_TYPE_ATTRIBUTE,\n DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,\n HAS_DYNAMIC_VALUES_ATTR_NAME,\n} from '../constants';\nimport { ComponentsConfig, CssVars, ScreenState } from '../types';\nimport { shouldHandleMarkdown } from './helpers';\n\nconst ALLOWED_INPUT_CONFIG_ATTRS = ['disabled'];\n\nexport const replaceElementMessage = (\n baseEle: HTMLElement,\n eleType: string,\n message = '',\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${eleType}\"]`,\n );\n eleList.forEach((ele: HTMLElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.textContent = message;\n ele.classList[message ? 'remove' : 'add']('hide');\n });\n};\n\n/**\n * Replace the 'value' attribute of screen inputs with screen state's inputs.\n * For example: if base element contains '<input name=\"key1\" ...>' and screen input is in form of { key1: 'val1' },\n * it will add 'val1' as the input value\n */\nconst replaceElementInputs = (\n baseEle: HTMLElement,\n screenInputs: Record<string, string>,\n) => {\n Object.entries(screenInputs || {}).forEach(([name, value]) => {\n const inputEls = Array.from(\n baseEle.querySelectorAll(\n `*[name=\"${name}\"]:not([${DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`,\n ),\n ) as HTMLInputElement[];\n inputEls.forEach((inputEle) => {\n // eslint-disable-next-line no-param-reassign\n inputEle.value = value;\n });\n });\n};\n\n/**\n * Get object nested path.\n * Examples:\n * - getByPath({ { a { b: 'rob' } }, 'a.b') => 'hey rob'\n * - getByPath({}, 'a.b') => ''\n */\nconst getByPath = (obj: Record<string, any>, path: string) =>\n path.split('.').reduce((prev, next) => prev?.[next] || '', obj);\n\n/**\n * Apply template language on text, based on screen state.\n * Examples:\n * - 'hey {{a.b}}', { a { b: 'rob' }} => 'hey rob'\n * - 'hey {{not.exists}}', {} => 'hey '\n */\nconst applyTemplates = (\n text: string,\n screenState?: Record<string, any>,\n handleMarkdown?: boolean,\n): string =>\n text.replace(/{{(.+?)}}/g, (_, match) =>\n handleMarkdown\n ? escapeMarkdown(getByPath(screenState, match))\n : getByPath(screenState, match),\n );\n\n/**\n * Replace the templates of content of inner text/link elements with screen state data\n */\nconst replaceElementTemplates = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(\n 'descope-text,descope-link,descope-enriched-text,descope-code-snippet',\n );\n eleList.forEach((inEle: HTMLElement) => {\n const handleMarkdown = shouldHandleMarkdown(inEle.localName);\n // eslint-disable-next-line no-param-reassign\n inEle.textContent = applyTemplates(\n inEle.textContent,\n screenState,\n handleMarkdown,\n );\n const href = inEle.getAttribute('href');\n if (href) {\n inEle.setAttribute('href', applyTemplates(href, screenState));\n }\n });\n};\n\nconst replaceTemplateDynamicAttrValues = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(`[${HAS_DYNAMIC_VALUES_ATTR_NAME}]`);\n eleList.forEach((ele: HTMLElement) => {\n Array.from(ele.attributes).forEach((attr) => {\n // eslint-disable-next-line no-param-reassign\n attr.value = applyTemplates(attr.value, screenState);\n });\n });\n};\n\nconst replaceHrefByDataType = (\n baseEle: DocumentFragment,\n dataType: string,\n provisionUrl?: string,\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${dataType}\"]`,\n );\n eleList.forEach((ele: HTMLLinkElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.setAttribute('href', provisionUrl);\n });\n};\n\nconst setFormConfigValues = (\n baseEle: DocumentFragment,\n formData: Record<string, string>,\n) => {\n Object.entries(formData).forEach(([name, config]) => {\n const eles = baseEle.querySelectorAll(`[name=\"${name}\"]`);\n\n eles.forEach((ele) => {\n Object.entries(config).forEach(([attrName, attrValue]) => {\n if (ALLOWED_INPUT_CONFIG_ATTRS.includes(attrName)) {\n ele.setAttribute(attrName, attrValue);\n }\n });\n });\n });\n};\n\nexport const setCssVars = (\n rootEle: HTMLElement,\n nextPageTemplate: DocumentFragment,\n cssVars: CssVars,\n logger: {\n error: (message: string, description: string) => void;\n info: (message: string, description: string) => void;\n debug: (message: string, description: string) => void;\n },\n) => {\n if (!cssVars) {\n return;\n }\n\n Object.keys(cssVars).forEach((componentName) => {\n if (!nextPageTemplate.querySelector(componentName)) {\n logger.debug(\n `Skipping css vars for component \"${componentName}\"`,\n `Got css vars for component ${componentName} but Could not find it on next page`,\n );\n\n return;\n }\n const componentClass:\n | (CustomElementConstructor & { cssVarList: CssVars })\n | undefined = customElements.get(componentName) as any;\n\n if (!componentClass) {\n logger.debug(\n `Could not find component class for ${componentName}`,\n 'Check if the component is registered',\n );\n\n return;\n }\n\n Object.keys(cssVars[componentName]).forEach((cssVarKey) => {\n const componentCssVars = cssVars[componentName];\n const varName = componentClass?.cssVarList?.[cssVarKey];\n\n if (!varName) {\n logger.info(\n `Could not find css variable name for ${cssVarKey} in ${componentName}`,\n 'Check if the css variable is defined in the component',\n );\n return;\n }\n\n const value = componentCssVars[cssVarKey];\n\n rootEle.style.setProperty(varName, value);\n });\n });\n};\n\nconst setElementConfig = (\n baseEle: DocumentFragment,\n componentsConfig: ComponentsConfig,\n logger?: { error: (message: string, description: string) => void },\n) => {\n if (!componentsConfig) {\n return;\n }\n const { componentsDynamicAttrs, ...rest } = componentsConfig;\n\n const configMap = Object.keys(rest).reduce((acc, componentName) => {\n acc[`[name=${componentName}]`] = rest[componentName];\n return acc;\n }, {});\n\n if (componentsDynamicAttrs) {\n Object.keys(componentsDynamicAttrs).forEach((componentSelector) => {\n const componentDynamicAttrs = componentsDynamicAttrs[componentSelector];\n if (componentDynamicAttrs) {\n const { attributes } = componentDynamicAttrs;\n if (attributes && Object.keys(attributes).length) {\n configMap[componentSelector] = attributes;\n }\n }\n });\n }\n\n // collect components that needs configuration from DOM\n Object.keys(configMap).forEach((componentsSelector) => {\n baseEle.querySelectorAll(componentsSelector).forEach((comp) => {\n const config = configMap[componentsSelector];\n\n Object.keys(config).forEach((attr) => {\n let value = config[attr];\n\n if (typeof value !== 'string') {\n try {\n value = JSON.stringify(value);\n } catch (e) {\n logger.error(\n `Could not stringify value \"${value}\" for \"${attr}\"`,\n e.message,\n );\n value = '';\n }\n }\n\n comp.setAttribute(attr, value);\n });\n });\n });\n};\n\nconst setImageVariable = (\n rootEle: HTMLElement,\n name: string,\n image?: string,\n) => {\n const imageVarName = (\n customElements.get(name) as CustomElementConstructor & {\n cssVarList: Record<string, string>;\n }\n )?.cssVarList.url;\n\n if (image && imageVarName) {\n rootEle?.style?.setProperty(\n imageVarName,\n `url(data:image/jpg;base64,${image})`,\n );\n }\n};\n\nconst applyComponentsState = (\n baseEle: DocumentFragment,\n componentsState: Record<string, string> = {},\n logger?: { error: (message: string, description: string) => void },\n) => {\n Object.entries(componentsState).forEach(([componentId, state]) => {\n const componentEls = baseEle.querySelectorAll(\n `[id=\"${CSS.escape(componentId)}\"]`,\n );\n componentEls.forEach((compEl) => {\n switch (state) {\n case 'disable':\n compEl.setAttribute('disabled', 'true');\n break;\n case 'hide':\n compEl.classList.add('hidden');\n break;\n default:\n logger?.error(\n `Unknown component state \"${state}\" for component with id \"${componentId}\"`,\n 'Valid states are \"disable\" and \"hide\"',\n );\n break;\n }\n });\n });\n};\n\n/**\n * Update a screen template based on the screen state\n * - Show/hide error messages\n * - Replace element templates ({{...}} syntax) with screen state object\n */\nexport const updateTemplateFromScreenState = (\n baseEle: DocumentFragment,\n screenState?: ScreenState,\n flowInputs?: Record<string, string>,\n logger?: { error: (message: string, description: string) => void },\n) => {\n replaceHrefByDataType(baseEle, 'totp-link', screenState?.totp?.provisionUrl);\n replaceHrefByDataType(baseEle, 'notp-link', screenState?.notp?.redirectUrl);\n replaceElementTemplates(baseEle, screenState);\n setElementConfig(baseEle, screenState?.componentsConfig, logger);\n replaceTemplateDynamicAttrValues(baseEle, screenState);\n setFormConfigValues(baseEle, flowInputs);\n applyComponentsState(baseEle, screenState?.componentsState, logger);\n};\n\n/**\n * Update a screen based on a screen state\n * - Replace values of element inputs with screen state's inputs\n */\nexport const updateScreenFromScreenState = (\n baseEle: HTMLElement,\n screenState?: ScreenState,\n) => {\n replaceElementInputs(baseEle, screenState?.inputs);\n replaceElementInputs(baseEle, screenState?.form);\n};\n\nexport const setTOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-totp-image', image);\n};\n\nexport const setNOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-notp-image', image);\n};\n\nexport const setComponentsAutoDetectByGeo = (\n fragment: DocumentFragment,\n countryCodeIso2?: string, // e.g. 'US', 'IL', 'FR'\n) => {\n const config = {\n // phone\n 'default-code': 'autoDetect',\n // country-subdivision-city\n 'default-country': 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, countryCodeIso2 || value);\n },\n );\n });\n};\n\nexport const setComponentsAutoDetectByLocale = (\n fragment: DocumentFragment,\n locale?: string, // e.g. 'en-US', 'fr-FR'\n) => {\n const config = {\n // country-subdivision-city\n lang: 'autoDetect',\n };\n\n let canonicalLocale = locale;\n if (locale) {\n try {\n const [canonical] = Intl.getCanonicalLocales(locale);\n if (canonical) {\n canonicalLocale = canonical;\n }\n } catch {\n // locale is not valid, keep original value\n }\n }\n\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, canonicalLocale || value);\n },\n );\n });\n};\n\nexport const disableWebauthnButtons = (fragment: DocumentFragment) => {\n const webauthnButtons = fragment.querySelectorAll(\n `descope-button[${ELEMENT_TYPE_ATTRIBUTE}=\"biometrics\"]`,\n );\n webauthnButtons.forEach((button) => button.setAttribute('disabled', 'true'));\n};\n\nexport const getDescopeUiComponentsList = (clone: DocumentFragment) => [\n ...Array.from(clone.querySelectorAll('*')).reduce<Set<string>>(\n (acc, el: HTMLElement) =>\n el.tagName.startsWith('DESCOPE-')\n ? acc.add(el.tagName.toLocaleLowerCase())\n : acc,\n new Set(),\n ),\n];\n"],"names":["ALLOWED_INPUT_CONFIG_ATTRS","replaceElementInputs","baseEle","screenInputs","Object","entries","forEach","name","value","Array","from","querySelectorAll","DESCOPE_ATTRIBUTE_EXCLUDE_FIELD","inputEle","getByPath","obj","path","split","reduce","prev","next","applyTemplates","text","screenState","handleMarkdown","replace","_","match","escapeMarkdown","replaceHrefByDataType","dataType","provisionUrl","ELEMENT_TYPE_ATTRIBUTE","ele","setAttribute","setImageVariable","rootEle","image","imageVarName","_a","customElements","get","cssVarList","url","_b","style","setProperty","fragment","button","eleType","message","textContent","classList","countryCodeIso2","key","locale","canonicalLocale","canonical","Intl","getCanonicalLocales","lang","nextPageTemplate","cssVars","logger","keys","componentName","querySelector","debug","componentClass","cssVarKey","componentCssVars","varName","info","inputs","form","flowInputs","totp","notp","redirectUrl","inEle","shouldHandleMarkdown","localName","href","getAttribute","replaceElementTemplates","componentsConfig","componentsDynamicAttrs","rest","__rest","configMap","acc","componentSelector","componentDynamicAttrs","attributes","length","componentsSelector","comp","config","attr","JSON","stringify","e","error","setElementConfig","HAS_DYNAMIC_VALUES_ATTR_NAME","replaceTemplateDynamicAttrValues","formData","attrName","attrValue","includes","setFormConfigValues","componentsState","componentId","state","CSS","escape","compEl","add","applyComponentsState"],"mappings":"uIASA,MAAMA,EAA6B,CAAC,YAsB9BC,EAAuB,CAC3BC,EACAC,KAEAC,OAAOC,QAAQF,GAAgB,CAAE,GAAEG,SAAQ,EAAEC,EAAMC,MAChCC,MAAMC,KACrBR,EAAQS,iBACN,WAAWJ,YAAeK,EAAAA,sCAGrBN,SAASO,IAEhBA,EAASL,MAAQA,CAAK,GACtB,GACF,EASEM,EAAY,CAACC,EAA0BC,IAC3CA,EAAKC,MAAM,KAAKC,QAAO,CAACC,EAAMC,KAASD,aAAI,EAAJA,EAAOC,KAAS,IAAIL,GAQvDM,EAAiB,CACrBC,EACAC,EACAC,IAEAF,EAAKG,QAAQ,cAAc,CAACC,EAAGC,IAC7BH,EACII,EAAAA,eAAed,EAAUS,EAAaI,IACtCb,EAAUS,EAAaI,KAyCzBE,EAAwB,CAC5B3B,EACA4B,EACAC,KAEgB7B,EAAQS,iBACtB,IAAIqB,EAAsBA,2BAAKF,OAEzBxB,SAAS2B,IAEfA,EAAIC,aAAa,OAAQH,EAAa,GACtC,EAgIEI,EAAmB,CACvBC,EACA7B,EACA8B,aAEA,MAAMC,EAIL,QAHCC,EAAAC,eAAeC,IAAIlC,UAGpB,IAAAgC,OAAA,EAAAA,EAAEG,WAAWC,IAEVN,GAASC,IACG,QAAdM,EAAAR,aAAA,EAAAA,EAASS,aAAK,IAAAD,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AA0C,CAAA,EAC1ChD,KAEA3D,OAAOC,QAAQ0G,GAAiBzG,SAAQ,EAAE0G,EAAaC,MAChC/G,EAAQS,iBAC3B,QAAQuG,IAAIC,OAAOH,QAER1G,SAAS8G,IACpB,OAAQH,GACN,IAAK,UACHG,EAAOlF,aAAa,WAAY,QAChC,MACF,IAAK,OACHkF,EAAOhE,UAAUiE,IAAI,UACrB,MACF,QACEtD,SAAAA,EAAQuC,MACN,4BAA4BW,6BAAiCD,KAC7D,yCAGL,GACD,GACF,EAoBFM,CAAqBpH,EAASqB,aAAA,EAAAA,EAAawF,gBAAiBhD,EAAO"}
@@ -1,2 +1,2 @@
1
- import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{createSdk as u}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as g,fetchContent as f,withRetry as p}from"../helpers/helpers.js";import m from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as b}from"../helpers/storage.js";import{transformFlowInputFormData as v,extractNestedAttribute as w}from"../helpers/flowInputs.js";import{formMountMixin as k}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as C,PREV_VER_ASSETS_FOLDER as y}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as A}from"../constants/general.js";var x,I,j,E,L,S,U,M,O,W,D,P,N,F,K,R,T,B,H,J,V,q;const $=r(s,o,k,n)(HTMLElement);class z extends ${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(r){super(),x.add(this),j.set(this,!1),E.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,x,"m",q).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)}},L.set(this,new m),S.set(this,new m),U.set(this,{}),this.getComponentsContext=()=>t(this,U,"f"),this.nextRequestStatus=new m({isLoading:!1}),M.set(this,void 0),O.set(this,{popstate:t(this,x,"m",F).bind(this),componentsContext:t(this,x,"m",H).bind(this)}),W.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,W,r,"f"),t(this,x,"m",P).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 v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return w(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(this,E,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,E,t,"f"),b(t)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=a.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).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 e(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 r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,S,"f").subscribe(t(this,x,"m",V).bind(this)),t(this,S,"f").update({isDebug:this.debug}),t(this,x,"m",N).call(this),yield t(this,x,"m",T).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:n,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,O,"f").popstate),window.addEventListener("components-context",t(this,O,"f").componentsContext),t(this,L,"f").subscribe(t(this,x,"m",R).bind(this)),t(this,L,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:s,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},m)),i(this,j,!0,"f")}))}disconnectedCallback(){t(this,L,"f").unsubscribeAll(),t(this,S,"f").unsubscribeAll(),t(this,x,"m",J).call(this),window.removeEventListener("popstate",t(this,O,"f").popstate),window.removeEventListener("components-context",t(this,O,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,j,"f")&&i!==r&&I.observedAttributes.includes(e)){t(this,x,"m",N).call(this);const o=null===i;t(this,L,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,executionId:n}})),t(this,S,"f").update({isDebug:this.debug})}}}I=z,j=new WeakMap,E=new WeakMap,L=new WeakMap,S=new WeakMap,U=new WeakMap,M=new WeakMap,O=new WeakMap,W=new WeakMap,x=new WeakSet,D=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 ")},P=function(){t(this,x,"m",D).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},N=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"];I.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},F=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,L,"f").update({stepId:e,executionId:i})},K=function(i,r){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},I.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,E,"f")&&(o.customStorage=t(this,E,"f")),this.sdk=u(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t],r=p(i,1e3,3);this.sdk.flow[t]=(...i)=>e(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(e){return this.logger.error(`Error in sdk flow ${t} function`,e),{error:{errorCode:A,errorDescription:e.toString()}}}}))}))},R=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,x,"m",K).call(this,e,r)}t(this,W,"f").call(this,i)}))},T=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,x,"m",B).call(this))}))},B=function(){return e(this,void 0,void 0,(function*(){const t=g({projectId:this.projectId,filename:C,assetsFolder:y,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},H=function(e){i(this,U,Object.assign(Object.assign({},t(this,U,"f")),e.detail),"f")},J=function(){var e;null===(e=t(this,M,"f"))||void 0===e||e.remove(),i(this,M,null,"f")},V=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,M,document.createElement("descope-debugger"),"f"),Object.assign(t(this,M,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,M,"f"))):t(this,x,"m",J).call(this)}))},q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,M,"f"))||void 0===r||r.updateData({title:e,description:i}))},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.58.0"}};export{z as default};
1
+ import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{createSdk as u}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as g,fetchContent as f,withRetry as p}from"../helpers/helpers.js";import m from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as b}from"../helpers/storage.js";import{transformFlowInputFormData as v,extractNestedAttribute as w}from"../helpers/flowInputs.js";import{formMountMixin as k}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as C,PREV_VER_ASSETS_FOLDER as y}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as A}from"../constants/general.js";var x,I,j,E,L,S,U,M,O,W,D,P,N,F,K,R,T,B,H,J,V,q;const $=r(s,o,k,n)(HTMLElement);class z extends ${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(r){super(),x.add(this),j.set(this,!1),E.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,x,"m",q).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)}},L.set(this,new m),S.set(this,new m),U.set(this,{}),this.getComponentsContext=()=>t(this,U,"f"),this.nextRequestStatus=new m({isLoading:!1}),M.set(this,void 0),O.set(this,{popstate:t(this,x,"m",F).bind(this),componentsContext:t(this,x,"m",H).bind(this)}),W.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,W,r,"f"),t(this,x,"m",P).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 v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return w(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(this,E,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,E,t,"f"),b(t)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=a.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).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 e(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 r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,S,"f").subscribe(t(this,x,"m",V).bind(this)),t(this,S,"f").update({isDebug:this.debug}),t(this,x,"m",N).call(this),yield t(this,x,"m",T).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:n,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,O,"f").popstate),window.addEventListener("components-context",t(this,O,"f").componentsContext),t(this,L,"f").subscribe(t(this,x,"m",R).bind(this)),t(this,L,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:s,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},m)),i(this,j,!0,"f")}))}disconnectedCallback(){t(this,L,"f").unsubscribeAll(),t(this,S,"f").unsubscribeAll(),t(this,x,"m",J).call(this),window.removeEventListener("popstate",t(this,O,"f").popstate),window.removeEventListener("components-context",t(this,O,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,j,"f")&&i!==r&&I.observedAttributes.includes(e)){t(this,x,"m",N).call(this);const o=null===i;t(this,L,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,executionId:n}})),t(this,S,"f").update({isDebug:this.debug})}}}I=z,j=new WeakMap,E=new WeakMap,L=new WeakMap,S=new WeakMap,U=new WeakMap,M=new WeakMap,O=new WeakMap,W=new WeakMap,x=new WeakSet,D=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 ")},P=function(){t(this,x,"m",D).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},N=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"];I.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},F=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,L,"f").update({stepId:e,executionId:i})},K=function(i,r){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},I.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,E,"f")&&(o.customStorage=t(this,E,"f")),this.sdk=u(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t],r=p(i,1e3,3);this.sdk.flow[t]=(...i)=>e(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(e){return this.logger.error(`Error in sdk flow ${t} function`,e),{error:{errorCode:A,errorDescription:e.toString()}}}}))}))},R=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,x,"m",K).call(this,e,r)}t(this,W,"f").call(this,i)}))},T=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,x,"m",B).call(this))}))},B=function(){return e(this,void 0,void 0,(function*(){const t=g({projectId:this.projectId,filename:C,assetsFolder:y,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},H=function(e){i(this,U,Object.assign(Object.assign({},t(this,U,"f")),e.detail),"f")},J=function(){var e;null===(e=t(this,M,"f"))||void 0===e||e.remove(),i(this,M,null,"f")},V=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,M,document.createElement("descope-debugger"),"f"),Object.assign(t(this,M,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,M,"f"))):t(this,x,"m",J).call(this)}))},q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,M,"f"))||void 0===r||r.updateData({title:e,description:i}))},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.58.2"}};export{z as default};
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"tslib";import{escapeMarkdown as t}from"@descope/escape-markdown";import{ELEMENT_TYPE_ATTRIBUTE as o,HAS_DYNAMIC_VALUES_ATTR_NAME as r,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as c}from"../constants/index.js";import{shouldHandleMarkdown as n}from"./helpers.js";const s=["disabled"],i=(e,t,r="")=>{e.querySelectorAll(`[${o}="${t}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))},l=(e,t)=>{Object.entries(t||{}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${c}])`)).forEach((e=>{e.value=o}))}))},a=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),d=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,c)=>r?t(a(o,c)):a(o,c))),u=(e,t,r)=>{e.querySelectorAll(`[${o}="${t}"]`).forEach((e=>{e.setAttribute("href",r)}))},f=(e,t,o,r)=>{o&&Object.keys(o).forEach((c=>{if(!t.querySelector(c))return void r.debug(`Skipping css vars for component "${c}"`,`Got css vars for component ${c} but Could not find it on next page`);const n=customElements.get(c);n?Object.keys(o[c]).forEach((t=>{var s;const i=o[c],l=null===(s=null==n?void 0:n.cssVarList)||void 0===s?void 0:s[t];if(!l)return void r.info(`Could not find css variable name for ${t} in ${c}`,"Check if the css variable is defined in the component");const a=i[t];e.style.setProperty(l,a)})):r.debug(`Could not find component class for ${c}`,"Check if the component is registered")}))},p=(e,t,o)=>{var r,c;const n=null===(r=customElements.get(t))||void 0===r?void 0:r.cssVarList.url;o&&n&&(null===(c=null==e?void 0:e.style)||void 0===c||c.setProperty(n,`url(data:image/jpg;base64,${o})`))},m=(t,o,c,i)=>{var l,a;u(t,"totp-link",null===(l=null==o?void 0:o.totp)||void 0===l?void 0:l.provisionUrl),u(t,"notp-link",null===(a=null==o?void 0:o.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=n(e.localName);e.textContent=d(e.textContent,t,o);const r=e.getAttribute("href");r&&e.setAttribute("href",d(r,t))}))})(t,o),((t,o,r)=>{if(!o)return;const{componentsDynamicAttrs:c}=o,n=e(o,["componentsDynamicAttrs"]),s=Object.keys(n).reduce(((e,t)=>(e[`[name=${t}]`]=n[t],e)),{});c&&Object.keys(c).forEach((e=>{const t=c[e];if(t){const{attributes:o}=t;o&&Object.keys(o).length&&(s[e]=o)}})),Object.keys(s).forEach((e=>{t.querySelectorAll(e).forEach((t=>{const o=s[e];Object.keys(o).forEach((e=>{let c=o[e];if("string"!=typeof c)try{c=JSON.stringify(c)}catch(t){r.error(`Could not stringify value "${c}" for "${e}"`,t.message),c=""}t.setAttribute(e,c)}))}))}))})(t,null==o?void 0:o.componentsConfig,i),((e,t)=>{e.querySelectorAll(`[${r}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=d(e.value,t)}))}))})(t,o),((e,t)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(o).forEach((([t,o])=>{s.includes(t)&&e.setAttribute(t,o)}))}))}))})(t,c),((e,t={},o)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(r){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==o||o.error(`Unknown component state "${r}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(t,null==o?void 0:o.componentsState,i)},h=(e,t)=>{l(e,null==t?void 0:t.inputs),l(e,null==t?void 0:t.form)},b=(e,t)=>{p(e,"descope-totp-image",t)},y=(e,t)=>{p(e,"descope-notp-image",t)},v=(e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},A=(e,t)=>{Object.entries({lang:"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},E=e=>{e.querySelectorAll(`descope-button[${o}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))};export{E as disableWebauthnButtons,i as replaceElementMessage,v as setComponentsAutoDetectByGeo,A as setComponentsAutoDetectByLocale,f as setCssVars,y as setNOTPVariable,b as setTOTPVariable,h as updateScreenFromScreenState,m as updateTemplateFromScreenState};
1
+ import{__rest as e}from"tslib";import{escapeMarkdown as t}from"@descope/escape-markdown";import{ELEMENT_TYPE_ATTRIBUTE as o,HAS_DYNAMIC_VALUES_ATTR_NAME as r,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as c}from"../constants/index.js";import{shouldHandleMarkdown as n}from"./helpers.js";const s=["disabled"],l=(e,t,r="")=>{e.querySelectorAll(`[${o}="${t}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))},i=(e,t)=>{Object.entries(t||{}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${c}])`)).forEach((e=>{e.value=o}))}))},a=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),d=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,c)=>r?t(a(o,c)):a(o,c))),u=(e,t,r)=>{e.querySelectorAll(`[${o}="${t}"]`).forEach((e=>{e.setAttribute("href",r)}))},f=(e,t,o,r)=>{o&&Object.keys(o).forEach((c=>{if(!t.querySelector(c))return void r.debug(`Skipping css vars for component "${c}"`,`Got css vars for component ${c} but Could not find it on next page`);const n=customElements.get(c);n?Object.keys(o[c]).forEach((t=>{var s;const l=o[c],i=null===(s=null==n?void 0:n.cssVarList)||void 0===s?void 0:s[t];if(!i)return void r.info(`Could not find css variable name for ${t} in ${c}`,"Check if the css variable is defined in the component");const a=l[t];e.style.setProperty(i,a)})):r.debug(`Could not find component class for ${c}`,"Check if the component is registered")}))},p=(e,t,o)=>{var r,c;const n=null===(r=customElements.get(t))||void 0===r?void 0:r.cssVarList.url;o&&n&&(null===(c=null==e?void 0:e.style)||void 0===c||c.setProperty(n,`url(data:image/jpg;base64,${o})`))},h=(t,o,c,l)=>{var i,a;u(t,"totp-link",null===(i=null==o?void 0:o.totp)||void 0===i?void 0:i.provisionUrl),u(t,"notp-link",null===(a=null==o?void 0:o.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=n(e.localName);e.textContent=d(e.textContent,t,o);const r=e.getAttribute("href");r&&e.setAttribute("href",d(r,t))}))})(t,o),((t,o,r)=>{if(!o)return;const{componentsDynamicAttrs:c}=o,n=e(o,["componentsDynamicAttrs"]),s=Object.keys(n).reduce(((e,t)=>(e[`[name=${t}]`]=n[t],e)),{});c&&Object.keys(c).forEach((e=>{const t=c[e];if(t){const{attributes:o}=t;o&&Object.keys(o).length&&(s[e]=o)}})),Object.keys(s).forEach((e=>{t.querySelectorAll(e).forEach((t=>{const o=s[e];Object.keys(o).forEach((e=>{let c=o[e];if("string"!=typeof c)try{c=JSON.stringify(c)}catch(t){r.error(`Could not stringify value "${c}" for "${e}"`,t.message),c=""}t.setAttribute(e,c)}))}))}))})(t,null==o?void 0:o.componentsConfig,l),((e,t)=>{e.querySelectorAll(`[${r}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=d(e.value,t)}))}))})(t,o),((e,t)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(o).forEach((([t,o])=>{s.includes(t)&&e.setAttribute(t,o)}))}))}))})(t,c),((e,t={},o)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(r){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==o||o.error(`Unknown component state "${r}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(t,null==o?void 0:o.componentsState,l)},m=(e,t)=>{i(e,null==t?void 0:t.inputs),i(e,null==t?void 0:t.form)},b=(e,t)=>{p(e,"descope-totp-image",t)},y=(e,t)=>{p(e,"descope-notp-image",t)},v=(e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([o,r])=>{Array.from(e.querySelectorAll(`[${o}="${r}"]`)).forEach((e=>{e.setAttribute(o,t||r)}))}))},A=(e,t)=>{let o=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(o=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,r])=>{Array.from(e.querySelectorAll(`[${t}="${r}"]`)).forEach((e=>{e.setAttribute(t,o||r)}))}))},E=e=>{e.querySelectorAll(`descope-button[${o}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))};export{E as disableWebauthnButtons,l as replaceElementMessage,v as setComponentsAutoDetectByGeo,A as setComponentsAutoDetectByLocale,f as setCssVars,y as setNOTPVariable,b as setTOTPVariable,m as updateScreenFromScreenState,h as updateTemplateFromScreenState};
2
2
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sources":["../../../src/lib/helpers/templates.ts"],"sourcesContent":["import { escapeMarkdown } from '@descope/escape-markdown';\nimport {\n ELEMENT_TYPE_ATTRIBUTE,\n DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,\n HAS_DYNAMIC_VALUES_ATTR_NAME,\n} from '../constants';\nimport { ComponentsConfig, CssVars, ScreenState } from '../types';\nimport { shouldHandleMarkdown } from './helpers';\n\nconst ALLOWED_INPUT_CONFIG_ATTRS = ['disabled'];\n\nexport const replaceElementMessage = (\n baseEle: HTMLElement,\n eleType: string,\n message = '',\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${eleType}\"]`,\n );\n eleList.forEach((ele: HTMLElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.textContent = message;\n ele.classList[message ? 'remove' : 'add']('hide');\n });\n};\n\n/**\n * Replace the 'value' attribute of screen inputs with screen state's inputs.\n * For example: if base element contains '<input name=\"key1\" ...>' and screen input is in form of { key1: 'val1' },\n * it will add 'val1' as the input value\n */\nconst replaceElementInputs = (\n baseEle: HTMLElement,\n screenInputs: Record<string, string>,\n) => {\n Object.entries(screenInputs || {}).forEach(([name, value]) => {\n const inputEls = Array.from(\n baseEle.querySelectorAll(\n `*[name=\"${name}\"]:not([${DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`,\n ),\n ) as HTMLInputElement[];\n inputEls.forEach((inputEle) => {\n // eslint-disable-next-line no-param-reassign\n inputEle.value = value;\n });\n });\n};\n\n/**\n * Get object nested path.\n * Examples:\n * - getByPath({ { a { b: 'rob' } }, 'a.b') => 'hey rob'\n * - getByPath({}, 'a.b') => ''\n */\nconst getByPath = (obj: Record<string, any>, path: string) =>\n path.split('.').reduce((prev, next) => prev?.[next] || '', obj);\n\n/**\n * Apply template language on text, based on screen state.\n * Examples:\n * - 'hey {{a.b}}', { a { b: 'rob' }} => 'hey rob'\n * - 'hey {{not.exists}}', {} => 'hey '\n */\nconst applyTemplates = (\n text: string,\n screenState?: Record<string, any>,\n handleMarkdown?: boolean,\n): string =>\n text.replace(/{{(.+?)}}/g, (_, match) =>\n handleMarkdown\n ? escapeMarkdown(getByPath(screenState, match))\n : getByPath(screenState, match),\n );\n\n/**\n * Replace the templates of content of inner text/link elements with screen state data\n */\nconst replaceElementTemplates = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(\n 'descope-text,descope-link,descope-enriched-text,descope-code-snippet',\n );\n eleList.forEach((inEle: HTMLElement) => {\n const handleMarkdown = shouldHandleMarkdown(inEle.localName);\n // eslint-disable-next-line no-param-reassign\n inEle.textContent = applyTemplates(\n inEle.textContent,\n screenState,\n handleMarkdown,\n );\n const href = inEle.getAttribute('href');\n if (href) {\n inEle.setAttribute('href', applyTemplates(href, screenState));\n }\n });\n};\n\nconst replaceTemplateDynamicAttrValues = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(`[${HAS_DYNAMIC_VALUES_ATTR_NAME}]`);\n eleList.forEach((ele: HTMLElement) => {\n Array.from(ele.attributes).forEach((attr) => {\n // eslint-disable-next-line no-param-reassign\n attr.value = applyTemplates(attr.value, screenState);\n });\n });\n};\n\nconst replaceHrefByDataType = (\n baseEle: DocumentFragment,\n dataType: string,\n provisionUrl?: string,\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${dataType}\"]`,\n );\n eleList.forEach((ele: HTMLLinkElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.setAttribute('href', provisionUrl);\n });\n};\n\nconst setFormConfigValues = (\n baseEle: DocumentFragment,\n formData: Record<string, string>,\n) => {\n Object.entries(formData).forEach(([name, config]) => {\n const eles = baseEle.querySelectorAll(`[name=\"${name}\"]`);\n\n eles.forEach((ele) => {\n Object.entries(config).forEach(([attrName, attrValue]) => {\n if (ALLOWED_INPUT_CONFIG_ATTRS.includes(attrName)) {\n ele.setAttribute(attrName, attrValue);\n }\n });\n });\n });\n};\n\nexport const setCssVars = (\n rootEle: HTMLElement,\n nextPageTemplate: DocumentFragment,\n cssVars: CssVars,\n logger: {\n error: (message: string, description: string) => void;\n info: (message: string, description: string) => void;\n debug: (message: string, description: string) => void;\n },\n) => {\n if (!cssVars) {\n return;\n }\n\n Object.keys(cssVars).forEach((componentName) => {\n if (!nextPageTemplate.querySelector(componentName)) {\n logger.debug(\n `Skipping css vars for component \"${componentName}\"`,\n `Got css vars for component ${componentName} but Could not find it on next page`,\n );\n\n return;\n }\n const componentClass:\n | (CustomElementConstructor & { cssVarList: CssVars })\n | undefined = customElements.get(componentName) as any;\n\n if (!componentClass) {\n logger.debug(\n `Could not find component class for ${componentName}`,\n 'Check if the component is registered',\n );\n\n return;\n }\n\n Object.keys(cssVars[componentName]).forEach((cssVarKey) => {\n const componentCssVars = cssVars[componentName];\n const varName = componentClass?.cssVarList?.[cssVarKey];\n\n if (!varName) {\n logger.info(\n `Could not find css variable name for ${cssVarKey} in ${componentName}`,\n 'Check if the css variable is defined in the component',\n );\n return;\n }\n\n const value = componentCssVars[cssVarKey];\n\n rootEle.style.setProperty(varName, value);\n });\n });\n};\n\nconst setElementConfig = (\n baseEle: DocumentFragment,\n componentsConfig: ComponentsConfig,\n logger?: { error: (message: string, description: string) => void },\n) => {\n if (!componentsConfig) {\n return;\n }\n const { componentsDynamicAttrs, ...rest } = componentsConfig;\n\n const configMap = Object.keys(rest).reduce((acc, componentName) => {\n acc[`[name=${componentName}]`] = rest[componentName];\n return acc;\n }, {});\n\n if (componentsDynamicAttrs) {\n Object.keys(componentsDynamicAttrs).forEach((componentSelector) => {\n const componentDynamicAttrs = componentsDynamicAttrs[componentSelector];\n if (componentDynamicAttrs) {\n const { attributes } = componentDynamicAttrs;\n if (attributes && Object.keys(attributes).length) {\n configMap[componentSelector] = attributes;\n }\n }\n });\n }\n\n // collect components that needs configuration from DOM\n Object.keys(configMap).forEach((componentsSelector) => {\n baseEle.querySelectorAll(componentsSelector).forEach((comp) => {\n const config = configMap[componentsSelector];\n\n Object.keys(config).forEach((attr) => {\n let value = config[attr];\n\n if (typeof value !== 'string') {\n try {\n value = JSON.stringify(value);\n } catch (e) {\n logger.error(\n `Could not stringify value \"${value}\" for \"${attr}\"`,\n e.message,\n );\n value = '';\n }\n }\n\n comp.setAttribute(attr, value);\n });\n });\n });\n};\n\nconst setImageVariable = (\n rootEle: HTMLElement,\n name: string,\n image?: string,\n) => {\n const imageVarName = (\n customElements.get(name) as CustomElementConstructor & {\n cssVarList: Record<string, string>;\n }\n )?.cssVarList.url;\n\n if (image && imageVarName) {\n rootEle?.style?.setProperty(\n imageVarName,\n `url(data:image/jpg;base64,${image})`,\n );\n }\n};\n\nconst applyComponentsState = (\n baseEle: DocumentFragment,\n componentsState: Record<string, string> = {},\n logger?: { error: (message: string, description: string) => void },\n) => {\n Object.entries(componentsState).forEach(([componentId, state]) => {\n const componentEls = baseEle.querySelectorAll(\n `[id=\"${CSS.escape(componentId)}\"]`,\n );\n componentEls.forEach((compEl) => {\n switch (state) {\n case 'disable':\n compEl.setAttribute('disabled', 'true');\n break;\n case 'hide':\n compEl.classList.add('hidden');\n break;\n default:\n logger?.error(\n `Unknown component state \"${state}\" for component with id \"${componentId}\"`,\n 'Valid states are \"disable\" and \"hide\"',\n );\n break;\n }\n });\n });\n};\n\n/**\n * Update a screen template based on the screen state\n * - Show/hide error messages\n * - Replace element templates ({{...}} syntax) with screen state object\n */\nexport const updateTemplateFromScreenState = (\n baseEle: DocumentFragment,\n screenState?: ScreenState,\n flowInputs?: Record<string, string>,\n logger?: { error: (message: string, description: string) => void },\n) => {\n replaceHrefByDataType(baseEle, 'totp-link', screenState?.totp?.provisionUrl);\n replaceHrefByDataType(baseEle, 'notp-link', screenState?.notp?.redirectUrl);\n replaceElementTemplates(baseEle, screenState);\n setElementConfig(baseEle, screenState?.componentsConfig, logger);\n replaceTemplateDynamicAttrValues(baseEle, screenState);\n setFormConfigValues(baseEle, flowInputs);\n applyComponentsState(baseEle, screenState?.componentsState, logger);\n};\n\n/**\n * Update a screen based on a screen state\n * - Replace values of element inputs with screen state's inputs\n */\nexport const updateScreenFromScreenState = (\n baseEle: HTMLElement,\n screenState?: ScreenState,\n) => {\n replaceElementInputs(baseEle, screenState?.inputs);\n replaceElementInputs(baseEle, screenState?.form);\n};\n\nexport const setTOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-totp-image', image);\n};\n\nexport const setNOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-notp-image', image);\n};\n\nexport const setComponentsAutoDetectByGeo = (\n fragment: DocumentFragment,\n countryCodeIso2?: string, // e.g. 'US', 'IL', 'FR'\n) => {\n const config = {\n // phone\n 'default-code': 'autoDetect',\n // country-subdivision-city\n 'default-country': 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, countryCodeIso2 || value);\n },\n );\n });\n};\n\nexport const setComponentsAutoDetectByLocale = (\n fragment: DocumentFragment,\n locale?: string, // e.g. 'en-US', 'fr-FR'\n) => {\n const config = {\n // country-subdivision-city\n lang: 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, locale || value);\n },\n );\n });\n};\n\nexport const disableWebauthnButtons = (fragment: DocumentFragment) => {\n const webauthnButtons = fragment.querySelectorAll(\n `descope-button[${ELEMENT_TYPE_ATTRIBUTE}=\"biometrics\"]`,\n );\n webauthnButtons.forEach((button) => button.setAttribute('disabled', 'true'));\n};\n\nexport const getDescopeUiComponentsList = (clone: DocumentFragment) => [\n ...Array.from(clone.querySelectorAll('*')).reduce<Set<string>>(\n (acc, el: HTMLElement) =>\n el.tagName.startsWith('DESCOPE-')\n ? acc.add(el.tagName.toLocaleLowerCase())\n : acc,\n new Set(),\n ),\n];\n"],"names":["ALLOWED_INPUT_CONFIG_ATTRS","replaceElementMessage","baseEle","eleType","message","querySelectorAll","ELEMENT_TYPE_ATTRIBUTE","forEach","ele","textContent","classList","replaceElementInputs","screenInputs","Object","entries","name","value","Array","from","DESCOPE_ATTRIBUTE_EXCLUDE_FIELD","inputEle","getByPath","obj","path","split","reduce","prev","next","applyTemplates","text","screenState","handleMarkdown","replace","_","match","escapeMarkdown","replaceHrefByDataType","dataType","provisionUrl","setAttribute","setCssVars","rootEle","nextPageTemplate","cssVars","logger","keys","componentName","querySelector","debug","componentClass","customElements","get","cssVarKey","componentCssVars","varName","_a","cssVarList","info","style","setProperty","setImageVariable","image","imageVarName","url","_b","updateTemplateFromScreenState","flowInputs","totp","notp","redirectUrl","inEle","shouldHandleMarkdown","localName","href","getAttribute","replaceElementTemplates","componentsConfig","componentsDynamicAttrs","rest","__rest","configMap","acc","componentSelector","componentDynamicAttrs","attributes","length","componentsSelector","comp","config","attr","JSON","stringify","e","error","setElementConfig","HAS_DYNAMIC_VALUES_ATTR_NAME","replaceTemplateDynamicAttrValues","formData","attrName","attrValue","includes","setFormConfigValues","componentsState","componentId","state","CSS","escape","compEl","add","applyComponentsState","updateScreenFromScreenState","inputs","form","setTOTPVariable","setNOTPVariable","setComponentsAutoDetectByGeo","fragment","countryCodeIso2","key","setComponentsAutoDetectByLocale","locale","lang","disableWebauthnButtons","button"],"mappings":"mRASA,MAAMA,EAA6B,CAAC,YAEvBC,EAAwB,CACnCC,EACAC,EACAC,EAAU,MAEMF,EAAQG,iBACtB,IAAIC,MAA2BH,OAEzBI,SAASC,IAEfA,EAAIC,YAAcL,EAClBI,EAAIE,UAAUN,EAAU,SAAW,OAAO,OAAO,GACjD,EAQEO,EAAuB,CAC3BT,EACAU,KAEAC,OAAOC,QAAQF,GAAgB,CAAE,GAAEL,SAAQ,EAAEQ,EAAMC,MAChCC,MAAMC,KACrBhB,EAAQG,iBACN,W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,EAAXA,EAAakF,KAAK,EAGrCC,EAAkB,CAACxE,EAAsBoB,KACpDD,EAAiBnB,EAAS,qBAAsBoB,EAAM,EAG3CqD,EAAkB,CAACzE,EAAsBoB,KACpDD,EAAiBnB,EAAS,qBAAsBoB,EAAM,EAG3CsD,EAA+B,CAC1CC,EACAC,KAQAxG,OAAOC,QANQ,CAEb,eAAgB,aAEhB,kBAAmB,eAEEP,SAAQ,EAAE+G,EAAKtG,MACpCC,MAAMC,KAAKkG,EAAS/G,iBAAiB,IAAIiH,MAAQtG,QAAYT,SAC1DC,IACCA,EAAI+B,aAAa+E,EAAKD,GAAmBrG,EAAM,GAElD,GACD,EAGSuG,EAAkC,CAC7CH,EACAI,KAMA3G,OAAOC,QAJQ,CAEb2G,KAAM,eAEelH,SAAQ,EAAE+G,EAAKtG,MACpCC,MAAMC,KAAKkG,EAAS/G,iBAAiB,IAAIiH,MAAQtG,QAAYT,SAC1DC,IACCA,EAAI+B,aAAa+E,EAAKE,GAAUxG,EAAM,GAEzC,GACD,EAGS0G,EAA0BN,IACbA,EAAS/G,iBAC/B,kBAAkBC,mBAEJC,SAASoH,GAAWA,EAAOpF,aAAa,WAAY,SAAQ"}
1
+ {"version":3,"file":"templates.js","sources":["../../../src/lib/helpers/templates.ts"],"sourcesContent":["import { escapeMarkdown } from '@descope/escape-markdown';\nimport {\n ELEMENT_TYPE_ATTRIBUTE,\n DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,\n HAS_DYNAMIC_VALUES_ATTR_NAME,\n} from '../constants';\nimport { ComponentsConfig, CssVars, ScreenState } from '../types';\nimport { shouldHandleMarkdown } from './helpers';\n\nconst ALLOWED_INPUT_CONFIG_ATTRS = ['disabled'];\n\nexport const replaceElementMessage = (\n baseEle: HTMLElement,\n eleType: string,\n message = '',\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${eleType}\"]`,\n );\n eleList.forEach((ele: HTMLElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.textContent = message;\n ele.classList[message ? 'remove' : 'add']('hide');\n });\n};\n\n/**\n * Replace the 'value' attribute of screen inputs with screen state's inputs.\n * For example: if base element contains '<input name=\"key1\" ...>' and screen input is in form of { key1: 'val1' },\n * it will add 'val1' as the input value\n */\nconst replaceElementInputs = (\n baseEle: HTMLElement,\n screenInputs: Record<string, string>,\n) => {\n Object.entries(screenInputs || {}).forEach(([name, value]) => {\n const inputEls = Array.from(\n baseEle.querySelectorAll(\n `*[name=\"${name}\"]:not([${DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`,\n ),\n ) as HTMLInputElement[];\n inputEls.forEach((inputEle) => {\n // eslint-disable-next-line no-param-reassign\n inputEle.value = value;\n });\n });\n};\n\n/**\n * Get object nested path.\n * Examples:\n * - getByPath({ { a { b: 'rob' } }, 'a.b') => 'hey rob'\n * - getByPath({}, 'a.b') => ''\n */\nconst getByPath = (obj: Record<string, any>, path: string) =>\n path.split('.').reduce((prev, next) => prev?.[next] || '', obj);\n\n/**\n * Apply template language on text, based on screen state.\n * Examples:\n * - 'hey {{a.b}}', { a { b: 'rob' }} => 'hey rob'\n * - 'hey {{not.exists}}', {} => 'hey '\n */\nconst applyTemplates = (\n text: string,\n screenState?: Record<string, any>,\n handleMarkdown?: boolean,\n): string =>\n text.replace(/{{(.+?)}}/g, (_, match) =>\n handleMarkdown\n ? escapeMarkdown(getByPath(screenState, match))\n : getByPath(screenState, match),\n );\n\n/**\n * Replace the templates of content of inner text/link elements with screen state data\n */\nconst replaceElementTemplates = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(\n 'descope-text,descope-link,descope-enriched-text,descope-code-snippet',\n );\n eleList.forEach((inEle: HTMLElement) => {\n const handleMarkdown = shouldHandleMarkdown(inEle.localName);\n // eslint-disable-next-line no-param-reassign\n inEle.textContent = applyTemplates(\n inEle.textContent,\n screenState,\n handleMarkdown,\n );\n const href = inEle.getAttribute('href');\n if (href) {\n inEle.setAttribute('href', applyTemplates(href, screenState));\n }\n });\n};\n\nconst replaceTemplateDynamicAttrValues = (\n baseEle: DocumentFragment,\n screenState?: Record<string, any>,\n) => {\n const eleList = baseEle.querySelectorAll(`[${HAS_DYNAMIC_VALUES_ATTR_NAME}]`);\n eleList.forEach((ele: HTMLElement) => {\n Array.from(ele.attributes).forEach((attr) => {\n // eslint-disable-next-line no-param-reassign\n attr.value = applyTemplates(attr.value, screenState);\n });\n });\n};\n\nconst replaceHrefByDataType = (\n baseEle: DocumentFragment,\n dataType: string,\n provisionUrl?: string,\n) => {\n const eleList = baseEle.querySelectorAll(\n `[${ELEMENT_TYPE_ATTRIBUTE}=\"${dataType}\"]`,\n );\n eleList.forEach((ele: HTMLLinkElement) => {\n // eslint-disable-next-line no-param-reassign\n ele.setAttribute('href', provisionUrl);\n });\n};\n\nconst setFormConfigValues = (\n baseEle: DocumentFragment,\n formData: Record<string, string>,\n) => {\n Object.entries(formData).forEach(([name, config]) => {\n const eles = baseEle.querySelectorAll(`[name=\"${name}\"]`);\n\n eles.forEach((ele) => {\n Object.entries(config).forEach(([attrName, attrValue]) => {\n if (ALLOWED_INPUT_CONFIG_ATTRS.includes(attrName)) {\n ele.setAttribute(attrName, attrValue);\n }\n });\n });\n });\n};\n\nexport const setCssVars = (\n rootEle: HTMLElement,\n nextPageTemplate: DocumentFragment,\n cssVars: CssVars,\n logger: {\n error: (message: string, description: string) => void;\n info: (message: string, description: string) => void;\n debug: (message: string, description: string) => void;\n },\n) => {\n if (!cssVars) {\n return;\n }\n\n Object.keys(cssVars).forEach((componentName) => {\n if (!nextPageTemplate.querySelector(componentName)) {\n logger.debug(\n `Skipping css vars for component \"${componentName}\"`,\n `Got css vars for component ${componentName} but Could not find it on next page`,\n );\n\n return;\n }\n const componentClass:\n | (CustomElementConstructor & { cssVarList: CssVars })\n | undefined = customElements.get(componentName) as any;\n\n if (!componentClass) {\n logger.debug(\n `Could not find component class for ${componentName}`,\n 'Check if the component is registered',\n );\n\n return;\n }\n\n Object.keys(cssVars[componentName]).forEach((cssVarKey) => {\n const componentCssVars = cssVars[componentName];\n const varName = componentClass?.cssVarList?.[cssVarKey];\n\n if (!varName) {\n logger.info(\n `Could not find css variable name for ${cssVarKey} in ${componentName}`,\n 'Check if the css variable is defined in the component',\n );\n return;\n }\n\n const value = componentCssVars[cssVarKey];\n\n rootEle.style.setProperty(varName, value);\n });\n });\n};\n\nconst setElementConfig = (\n baseEle: DocumentFragment,\n componentsConfig: ComponentsConfig,\n logger?: { error: (message: string, description: string) => void },\n) => {\n if (!componentsConfig) {\n return;\n }\n const { componentsDynamicAttrs, ...rest } = componentsConfig;\n\n const configMap = Object.keys(rest).reduce((acc, componentName) => {\n acc[`[name=${componentName}]`] = rest[componentName];\n return acc;\n }, {});\n\n if (componentsDynamicAttrs) {\n Object.keys(componentsDynamicAttrs).forEach((componentSelector) => {\n const componentDynamicAttrs = componentsDynamicAttrs[componentSelector];\n if (componentDynamicAttrs) {\n const { attributes } = componentDynamicAttrs;\n if (attributes && Object.keys(attributes).length) {\n configMap[componentSelector] = attributes;\n }\n }\n });\n }\n\n // collect components that needs configuration from DOM\n Object.keys(configMap).forEach((componentsSelector) => {\n baseEle.querySelectorAll(componentsSelector).forEach((comp) => {\n const config = configMap[componentsSelector];\n\n Object.keys(config).forEach((attr) => {\n let value = config[attr];\n\n if (typeof value !== 'string') {\n try {\n value = JSON.stringify(value);\n } catch (e) {\n logger.error(\n `Could not stringify value \"${value}\" for \"${attr}\"`,\n e.message,\n );\n value = '';\n }\n }\n\n comp.setAttribute(attr, value);\n });\n });\n });\n};\n\nconst setImageVariable = (\n rootEle: HTMLElement,\n name: string,\n image?: string,\n) => {\n const imageVarName = (\n customElements.get(name) as CustomElementConstructor & {\n cssVarList: Record<string, string>;\n }\n )?.cssVarList.url;\n\n if (image && imageVarName) {\n rootEle?.style?.setProperty(\n imageVarName,\n `url(data:image/jpg;base64,${image})`,\n );\n }\n};\n\nconst applyComponentsState = (\n baseEle: DocumentFragment,\n componentsState: Record<string, string> = {},\n logger?: { error: (message: string, description: string) => void },\n) => {\n Object.entries(componentsState).forEach(([componentId, state]) => {\n const componentEls = baseEle.querySelectorAll(\n `[id=\"${CSS.escape(componentId)}\"]`,\n );\n componentEls.forEach((compEl) => {\n switch (state) {\n case 'disable':\n compEl.setAttribute('disabled', 'true');\n break;\n case 'hide':\n compEl.classList.add('hidden');\n break;\n default:\n logger?.error(\n `Unknown component state \"${state}\" for component with id \"${componentId}\"`,\n 'Valid states are \"disable\" and \"hide\"',\n );\n break;\n }\n });\n });\n};\n\n/**\n * Update a screen template based on the screen state\n * - Show/hide error messages\n * - Replace element templates ({{...}} syntax) with screen state object\n */\nexport const updateTemplateFromScreenState = (\n baseEle: DocumentFragment,\n screenState?: ScreenState,\n flowInputs?: Record<string, string>,\n logger?: { error: (message: string, description: string) => void },\n) => {\n replaceHrefByDataType(baseEle, 'totp-link', screenState?.totp?.provisionUrl);\n replaceHrefByDataType(baseEle, 'notp-link', screenState?.notp?.redirectUrl);\n replaceElementTemplates(baseEle, screenState);\n setElementConfig(baseEle, screenState?.componentsConfig, logger);\n replaceTemplateDynamicAttrValues(baseEle, screenState);\n setFormConfigValues(baseEle, flowInputs);\n applyComponentsState(baseEle, screenState?.componentsState, logger);\n};\n\n/**\n * Update a screen based on a screen state\n * - Replace values of element inputs with screen state's inputs\n */\nexport const updateScreenFromScreenState = (\n baseEle: HTMLElement,\n screenState?: ScreenState,\n) => {\n replaceElementInputs(baseEle, screenState?.inputs);\n replaceElementInputs(baseEle, screenState?.form);\n};\n\nexport const setTOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-totp-image', image);\n};\n\nexport const setNOTPVariable = (rootEle: HTMLElement, image?: string) => {\n setImageVariable(rootEle, 'descope-notp-image', image);\n};\n\nexport const setComponentsAutoDetectByGeo = (\n fragment: DocumentFragment,\n countryCodeIso2?: string, // e.g. 'US', 'IL', 'FR'\n) => {\n const config = {\n // phone\n 'default-code': 'autoDetect',\n // country-subdivision-city\n 'default-country': 'autoDetect',\n };\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, countryCodeIso2 || value);\n },\n );\n });\n};\n\nexport const setComponentsAutoDetectByLocale = (\n fragment: DocumentFragment,\n locale?: string, // e.g. 'en-US', 'fr-FR'\n) => {\n const config = {\n // country-subdivision-city\n lang: 'autoDetect',\n };\n\n let canonicalLocale = locale;\n if (locale) {\n try {\n const [canonical] = Intl.getCanonicalLocales(locale);\n if (canonical) {\n canonicalLocale = canonical;\n }\n } catch {\n // locale is not valid, keep original value\n }\n }\n\n Object.entries(config).forEach(([key, value]) => {\n Array.from(fragment.querySelectorAll(`[${key}=\"${value}\"]`)).forEach(\n (ele) => {\n ele.setAttribute(key, canonicalLocale || value);\n },\n );\n });\n};\n\nexport const disableWebauthnButtons = (fragment: DocumentFragment) => {\n const webauthnButtons = fragment.querySelectorAll(\n `descope-button[${ELEMENT_TYPE_ATTRIBUTE}=\"biometrics\"]`,\n );\n webauthnButtons.forEach((button) => button.setAttribute('disabled', 'true'));\n};\n\nexport const getDescopeUiComponentsList = (clone: DocumentFragment) => [\n ...Array.from(clone.querySelectorAll('*')).reduce<Set<string>>(\n (acc, el: HTMLElement) =>\n el.tagName.startsWith('DESCOPE-')\n ? acc.add(el.tagName.toLocaleLowerCase())\n : acc,\n new Set(),\n ),\n];\n"],"names":["ALLOWED_INPUT_CONFIG_ATTRS","replaceElementMessage","baseEle","eleType","message","querySelectorAll","ELEMENT_TYPE_ATTRIBUTE","forEach","ele","textContent","classList","replaceElementInputs","screenInputs","Object","entries","name","value","Array","from","DESCOPE_ATTRIBUTE_EXCLUDE_FIELD","inputEle","getByPath","obj","path","split","reduce","prev","next","applyTemplates","text","screenState","handleMarkdown","replace","_","match","escapeMarkdown","replaceHrefByDataType","dataType","provisionUrl","setAttribute","setCssVars","rootEle","nextPageTemplate","cssVars","logger","keys","componentName","querySelector","debug","componentClass","customElements","get","cssVarKey","componentCssVars","varName","_a","cssVarList","info","style","setProperty","setImageVariable","image","imageVarName","url","_b","updateTemplateFromScreenState","flowInputs","totp","notp","redirectUrl","inEle","shouldHandleMarkdown","localName","href","getAttribute","replaceElementTemplates","componentsConfig","componentsDynamicAttrs","rest","__rest","configMap","acc","componentSelector","componentDynamicAttrs","attributes","length","componentsSelector","comp","config","attr","JSON","stringify","e","error","setElementConfig","HAS_DYNAMIC_VALUES_ATTR_NAME","replaceTemplateDynamicAttrValues","formData","attrName","attrValue","includes","setFormConfigValues","componentsState","componentId","state","CSS","escape","compEl","add","applyComponentsState","updateScreenFromScreenState","inputs","form","setTOTPVariable","setNOTPVariable","setComponentsAutoDetectByGeo","fragment","countryCodeIso2","key","setComponentsAutoDetectByLocale","locale","canonicalLocale","canonical","Intl","getCanonicalLocales","lang","disableWebauthnButtons","button"],"mappings":"mRASA,MAAMA,EAA6B,CAAC,YAEvBC,EAAwB,CACnCC,EACAC,EACAC,EAAU,MAEMF,EAAQG,iBACtB,IAAIC,MAA2BH,OAEzBI,SAASC,IAEfA,EAAIC,YAAcL,EAClBI,EAAIE,UAAUN,EAAU,SAAW,OAAO,OAAO,GACjD,EAQEO,EAAuB,CAC3BT,EACAU,KAEAC,OAAOC,QAAQF,GAAgB,CAAE,GAAEL,SAAQ,EAAEQ,EAAMC,MAChCC,MAAMC,KACrBhB,EAAQG,iBACN,WAAWU,YAAeI,QAGrBZ,SAASa,IAEhBA,EAASJ,MAAQA,CAAK,GACtB,GACF,EASEK,EAAY,CAACC,EAA0BC,IAC3CA,EAAKC,MAAM,KAAKC,QAAO,CAACC,EAAMC,KAASD,aAAI,EAAJA,EAAOC,KAAS,IAAIL,GAQvDM,EAAiB,CACrBC,EACAC,EACAC,IAEAF,EAAKG,QAAQ,cAAc,CAACC,EAAGC,IAC7BH,EACII,EAAed,EAAUS,EAAaI,IACtCb,EAAUS,EAAaI,KA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iB,IAAIiH,MAAQtG,QAAYT,SAC1DC,IACCA,EAAI+B,aAAa+E,EAAKD,GAAmBrG,EAAM,GAElD,GACD,EAGSuG,EAAkC,CAC7CH,EACAI,KAOA,IAAIC,EAAkBD,EACtB,GAAIA,EACF,IACE,MAAOE,GAAaC,KAAKC,oBAAoBJ,GACzCE,IACFD,EAAkBC,EAErB,CAAC,MAAAnE,GAED,CAGH1C,OAAOC,QAjBQ,CAEb+G,KAAM,eAeetH,SAAQ,EAAE+G,EAAKtG,MACpCC,MAAMC,KAAKkG,EAAS/G,iBAAiB,IAAIiH,MAAQtG,QAAYT,SAC1DC,IACCA,EAAI+B,aAAa+E,EAAKG,GAAmBzG,EAAM,GAElD,GACD,EAGS8G,EAA0BV,IACbA,EAAS/G,iBAC/B,kBAAkBC,mBAEJC,SAASwH,GAAWA,EAAOxF,aAAa,WAAY,SAAQ"}
package/dist/index.d.ts CHANGED
@@ -269,12 +269,12 @@ declare const BaseClass: (new (...params: any[]) => {
269
269
  readonly cssRules: CSSRuleList;
270
270
  } | CSSStyleSheet;
271
271
  nonce: string;
272
- "__#32157@#setNonce"(): void;
272
+ "__#32163@#setNonce"(): void;
273
273
  init(): Promise<void>;
274
- "__#32152@#observeMappings": {};
274
+ "__#32158@#observeMappings": {};
275
275
  observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
276
276
  observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
277
- "__#32151@#isInit": boolean;
277
+ "__#32157@#isInit": boolean;
278
278
  connectedCallback: (() => void) & (() => void) & (() => void);
279
279
  accessKey: string;
280
280
  readonly accessKeyLabel: string;
@@ -600,8 +600,8 @@ declare const BaseClass: (new (...params: any[]) => {
600
600
  tabIndex: number;
601
601
  blur(): void;
602
602
  focus(options?: FocusOptions): void;
603
- "__#32150@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
604
- "__#32150@#wrapLogger"(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>): _descope_sdk_mixins_static_resources_mixin.Logger;
603
+ "__#32156@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
604
+ "__#32156@#wrapLogger"(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>): _descope_sdk_mixins_static_resources_mixin.Logger;
605
605
  get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
606
606
  set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
607
607
  onLogEvent(logLevel: "error" | "warn" | "info" | "debug", data: any[]): void;
@@ -937,15 +937,15 @@ declare const BaseClass: (new (...params: any[]) => {
937
937
  focus(options?: FocusOptions): void;
938
938
  };
939
939
  } & (new (...params: any[]) => {
940
- "__#32154@#lastBaseUrl"?: string;
941
- "__#32154@#workingBaseUrl"?: string;
942
- "__#32154@#failedUrls": Set<string>;
943
- "__#32154@#getResourceUrls"(filename: string): (URL & {
940
+ "__#32160@#lastBaseUrl"?: string;
941
+ "__#32160@#workingBaseUrl"?: string;
942
+ "__#32160@#failedUrls": Set<string>;
943
+ "__#32160@#getResourceUrls"(filename: string): (URL & {
944
944
  baseUrl: string;
945
945
  }) | (URL & {
946
946
  baseUrl: string;
947
947
  })[];
948
- "__#32154@#createResourceUrl"(filename: string, baseUrl: string): URL & {
948
+ "__#32160@#createResourceUrl"(filename: string, baseUrl: string): URL & {
949
949
  baseUrl: string;
950
950
  };
951
951
  fetchStaticResource<F extends "text" | "json">(filename: string, format: F): Promise<{
@@ -1281,34 +1281,34 @@ declare const BaseClass: (new (...params: any[]) => {
1281
1281
  blur(): void;
1282
1282
  focus(options?: FocusOptions): void;
1283
1283
  readonly projectId: string;
1284
- "__#32153@#handleError"(attrName: string, newValue: string): void;
1284
+ "__#32159@#handleError"(attrName: string, newValue: string): void;
1285
1285
  init(): Promise<void>;
1286
- "__#32152@#observeMappings": {};
1286
+ "__#32158@#observeMappings": {};
1287
1287
  observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
1288
1288
  observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
1289
- "__#32151@#isInit": boolean;
1290
- "__#32150@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1291
- "__#32150@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1289
+ "__#32157@#isInit": boolean;
1290
+ "__#32156@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1291
+ "__#32156@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1292
1292
  get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
1293
1293
  set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
1294
1294
  onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
1295
1295
  }) & (new (...params: any[]) => {
1296
- "__#32166@#globalStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
1296
+ "__#32172@#globalStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
1297
1297
  readonly theme: _descope_sdk_mixins_static_resources_mixin.ThemeOptions;
1298
1298
  readonly styleId: string;
1299
- "__#32166@#_themeResource": Promise<void | Record<string, any>>;
1300
- "__#32166@#fetchTheme"(): Promise<Record<string, any>>;
1301
- readonly "__#32166@#themeResource": Promise<void | Record<string, any>>;
1302
- "__#32166@#loadGlobalStyle"(): Promise<void>;
1303
- "__#32166@#loadComponentsStyle"(): Promise<void>;
1304
- "__#32166@#getFontsConfig"(): Promise<Record<string, {
1299
+ "__#32172@#_themeResource": Promise<void | Record<string, any>>;
1300
+ "__#32172@#fetchTheme"(): Promise<Record<string, any>>;
1301
+ readonly "__#32172@#themeResource": Promise<void | Record<string, any>>;
1302
+ "__#32172@#loadGlobalStyle"(): Promise<void>;
1303
+ "__#32172@#loadComponentsStyle"(): Promise<void>;
1304
+ "__#32172@#getFontsConfig"(): Promise<Record<string, {
1305
1305
  url?: string;
1306
1306
  }>>;
1307
- "__#32166@#loadFonts"(): Promise<void>;
1308
- "__#32166@#applyTheme"(): Promise<void>;
1309
- "__#32166@#onThemeChange": () => void;
1310
- "__#32166@#loadTheme"(): void;
1311
- "__#32166@#toggleOsThemeChangeListener": (listen: boolean) => void;
1307
+ "__#32172@#loadFonts"(): Promise<void>;
1308
+ "__#32172@#applyTheme"(): Promise<void>;
1309
+ "__#32172@#onThemeChange": () => void;
1310
+ "__#32172@#loadTheme"(): void;
1311
+ "__#32172@#toggleOsThemeChangeListener": (listen: boolean) => void;
1312
1312
  init(): Promise<void>;
1313
1313
  injectStyle: ((cssString: string, { prepend }?: {
1314
1314
  prepend?: boolean;
@@ -1326,11 +1326,11 @@ declare const BaseClass: (new (...params: any[]) => {
1326
1326
  readonly cssRules: CSSRuleList;
1327
1327
  });
1328
1328
  nonce: string;
1329
- "__#32157@#setNonce": (() => void) & (() => void);
1330
- "__#32152@#observeMappings": {};
1329
+ "__#32163@#setNonce": (() => void) & (() => void);
1330
+ "__#32158@#observeMappings": {};
1331
1331
  observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
1332
1332
  observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
1333
- "__#32151@#isInit": boolean;
1333
+ "__#32157@#isInit": boolean;
1334
1334
  connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
1335
1335
  accessKey: string;
1336
1336
  readonly accessKeyLabel: string;
@@ -1656,25 +1656,25 @@ declare const BaseClass: (new (...params: any[]) => {
1656
1656
  tabIndex: number;
1657
1657
  blur(): void;
1658
1658
  focus(options?: FocusOptions): void;
1659
- "__#32150@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1660
- "__#32150@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1659
+ "__#32156@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1660
+ "__#32156@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1661
1661
  get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
1662
1662
  set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
1663
1663
  onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
1664
1664
  contentRootElement: HTMLElement;
1665
1665
  rootElement: HTMLElement;
1666
1666
  readonly config: Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
1667
- "__#32156@#configCacheClear": (() => void) & (() => void);
1668
- "__#32156@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
1669
- "__#32156@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
1670
- "__#32155@#callbacks": Map<string, () => void> & Map<string, () => void>;
1667
+ "__#32162@#configCacheClear": (() => void) & (() => void);
1668
+ "__#32162@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
1669
+ "__#32162@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
1670
+ "__#32161@#callbacks": Map<string, () => void> & Map<string, () => void>;
1671
1671
  onReset: ((sectionId: string, callback: () => void | Promise<void>) => () => void) & ((sectionId: string, callback: () => void | Promise<void>) => () => void);
1672
1672
  reset: ((...sectionIds: string[]) => Promise<void>) & ((...sectionIds: string[]) => Promise<void>);
1673
- "__#32153@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1674
- "__#32154@#lastBaseUrl"?: string;
1675
- "__#32154@#workingBaseUrl"?: string;
1676
- "__#32154@#failedUrls": Set<string>;
1677
- "__#32154@#getResourceUrls": ((filename: string) => (URL & {
1673
+ "__#32159@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1674
+ "__#32160@#lastBaseUrl"?: string;
1675
+ "__#32160@#workingBaseUrl"?: string;
1676
+ "__#32160@#failedUrls": Set<string>;
1677
+ "__#32160@#getResourceUrls": ((filename: string) => (URL & {
1678
1678
  baseUrl: string;
1679
1679
  }) | (URL & {
1680
1680
  baseUrl: string;
@@ -1687,7 +1687,7 @@ declare const BaseClass: (new (...params: any[]) => {
1687
1687
  }) | (URL & {
1688
1688
  baseUrl: string;
1689
1689
  })[]);
1690
- "__#32154@#createResourceUrl": ((filename: string, baseUrl: string) => URL & {
1690
+ "__#32160@#createResourceUrl": ((filename: string, baseUrl: string) => URL & {
1691
1691
  baseUrl: string;
1692
1692
  }) & ((filename: string, baseUrl: string) => URL & {
1693
1693
  baseUrl: string;
@@ -1707,12 +1707,12 @@ declare const BaseClass: (new (...params: any[]) => {
1707
1707
  readonly baseStaticUrl: string;
1708
1708
  readonly baseUrl: string;
1709
1709
  readonly projectId: string;
1710
- "__#32160@#getComponentsVersion"(): Promise<string>;
1711
- "__#32160@#getComponentsVersionSri"(): Promise<string>;
1712
- "__#32160@#descopeUi": Promise<any>;
1710
+ "__#32166@#getComponentsVersion"(): Promise<string>;
1711
+ "__#32166@#getComponentsVersionSri"(): Promise<string>;
1712
+ "__#32166@#descopeUi": Promise<any>;
1713
1713
  readonly descopeUi: Promise<any>;
1714
- "__#32160@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1715
- "__#32160@#getDescopeUi"(): Promise<any>;
1714
+ "__#32166@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1715
+ "__#32166@#getDescopeUi"(): Promise<any>;
1716
1716
  loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
1717
1717
  readonly baseCdnUrl: string;
1718
1718
  injectNpmLib(libName: string, version: string, filePath?: string, overrides?: string[], integrity?: string): Promise<{