@descope/web-component 3.64.3 → 3.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/cjs/descope-wc/BaseDescopeWc.js.map +1 -1
- package/dist/cjs/helpers/templates.js +1 -1
- package/dist/cjs/helpers/templates.js.map +1 -1
- package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/esm/descope-wc/BaseDescopeWc.js.map +1 -1
- package/dist/esm/helpers/templates.js +1 -1
- package/dist/esm/helpers/templates.js.map +1 -1
- package/dist/index.d.ts +60 -55
- package/dist/index.js +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport { createSdk } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport { formMountMixin } from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n injectStyleMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'style-id',\n ];\n }\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get flowId() {\n return this.getAttribute('flow-id');\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get tenantId() {\n return this.getAttribute('tenant') || undefined;\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n try {\n const resp = await fnWithRetry(...args);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","injectStyleMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","_BaseDescopeWc_init","set","this","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","flowId","getAttribute","client","JSON","parse","e","tenantId","undefined","redirectUrl","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","window","_BaseDescopeWc_onFlowChange","Object","assign","projectId","baseUrl","tenant","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","origFn","flow","fnWithRetry","withRetry","args","__awaiter","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","import","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"yoCAgDA,MAAMA,EAAYC,EAChBC,EACAC,EACAC,EACAC,EAJgBJ,CAKhBK,aAGF,MAAMC,UAAsBP,EAC1B,6BAAWQ,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,WAEH,CA+DD,WAAAC,CAAYC,GACVC,oBAtDFC,EAAAC,IAAAC,MAAQ,GAERC,EAA0CF,IAAAC,UAAA,GAE1CA,KAAUE,WAAe,UAEz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,aADMC,EAAaP,EAAkB,SAC9B,CACR,CAAC,MAAOnJ,GACP,OAAO,CACR,iBAKsBA,GACvBP,EAAAlC,KAA+BkB,EAAAuH,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAjI,EAAAT,KAAIkB,EAAA,MAAwBuB,EAAE2J,QAAM,IACrE,EAACpD,EAAA,iBAYoB,QAAnBhG,EAAAvC,EAAAT,KAAIsB,EAAA,YAAe,IAAA0B,GAAAA,EAAAqJ,SACnBnK,EAAAlC,KAAIsB,EAAgB,KAAI,IAC1B,EAACgG,EAAA,SAAAtE,GAEsB,OAAAmI,EAAAnL,KAAAsM,eAAA,GAAA,WAAA9E,QAAEA,IACnBA,GACFtF,EAAAlC,OAAoBgK,SAASC,cAC3B,oBAGD,KAEDxB,OAAOC,OAAOjI,EAAAT,KAAiBsB,EAAA,KAACiL,MAAO,CACrCC,SAAU,QACVC,IAAK,IACLC,MAAO,IACPC,OAAQ,QACRC,MAAO,QACPC,cAAe,OACfC,OAAQ,cAIJC,OAAO,qBAEb/C,SAASgD,KAAK5C,YAAY3J,EAAAT,KAAiBsB,EAAA,OAE3Cb,EAAAT,KAAIyB,EAAA,IAAAuH,GAAJtI,KAAAV,QAIoB,EAAAiN,EAAA,SAAAC,EAAe5M,SACjC4M,GAASlN,KAAKc,QACC,QAAjBkC,EAAAvC,EAAAT,KAAiBsB,EAAA,YAAA,IAAA0B,GAAAA,EAAEmK,WAAW,CAAED,QAAO5M,gBAC3C,EAhZOb,EAAAmL,mBAAyC,CAC9CwC,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
|
|
1
|
+
{"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport { createSdk } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport { formMountMixin } from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n injectStyleMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'style-id',\n ];\n }\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get flowId() {\n return this.getAttribute('flow-id');\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n try {\n const resp = await fnWithRetry(...args);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","injectStyleMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","_BaseDescopeWc_init","set","this","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","flowId","getAttribute","client","JSON","parse","e","redirectUrl","undefined","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","window","_BaseDescopeWc_onFlowChange","Object","assign","projectId","baseUrl","tenant","tenantId","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","origFn","flow","fnWithRetry","withRetry","args","__awaiter","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","import","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"yoCAgDA,MAAMA,EAAYC,EAChBC,EACAC,EACAC,EACAC,EAJgBJ,CAKhBK,aAGF,MAAMC,UAAsBP,EAC1B,6BAAWQ,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,WAEH,CA+DD,WAAAC,CAAYC,GACVC,oBAtDFC,EAAAC,IAAAC,MAAQ,GAERC,EAA0CF,IAAAC,UAAA,GAE1CA,KAAUE,WAAe,UAEzBF,KAAAG,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCN,KAAKO,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,EAAAT,cAAAU,KAAAV,KAA6BK,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCN,KAAKO,OAAOI,KAAKN,EAASC,EAAY,EAExCM,KAAM,CAACP,EAAiBC,EAAc,GAAIO,EAAa,CAAA,KACrDb,KAAKO,OAAOK,KAAKP,EAASC,EAAaO,EAAM,EAE/CC,MAAO,CAACT,EAAiBC,EAAc,MACrCN,KAAKO,OAAOO,MAAMT,EAASC,EAAY,GAI3CS,EAAahB,IAAAC,KAAA,IAAIgB,GAEjBC,EAAclB,IAAAC,KAAA,IAAIgB,GAElBE,EAAAnB,IAAAC,KAAqB,CAAA,GAErBA,KAAAmB,qBAAuB,IAAMV,EAAAT,YAE7BA,KAAiBoB,kBAAG,IAAIJ,EAA8B,CAAEK,WAAW,IAQnEC,EAEEvB,IAAAC,UAAA,GAEFuB,EAAgBxB,IAAAC,KAAA,CACdwB,SAAUf,EAAAT,KAAIyB,EAAA,IAAAC,GAAqBC,KAAK3B,MACxC4B,kBAAmBnB,EAA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KAAKc,QACC,QAAjBiC,EAAAtC,EAAAT,KAAiBsB,EAAA,YAAA,IAAAyB,GAAAA,EAAEoK,WAAW,CAAED,QAAO5M,gBAC3C,EA5YOb,EAAAmL,mBAAyC,CAC9CwC,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
|
|
@@ -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"],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})`))},
|
|
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})`))},b=(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;case"read-only":e.setAttribute("readonly","true");break;default:null==o||o.error(`Unknown component state "${r}" for component with id "${t}"`,'Valid states are "disable", "hide", and "read-only"')}}))}))})(t,null==o?void 0:o.componentsState,l)},h=(e,t)=>{i(e,null==t?void 0:t.inputs),i(e,null==t?void 0:t.form)},m=(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,m as setTOTPVariable,h as updateScreenFromScreenState,b 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\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,KAyCzBE,EAAwB,CAC5BlC,EACAmC,EACAC,KAEgBpC,EAAQG,iBACtB,IAAIC,MAA2B+B,OAEzB9B,SAASC,IAEfA,EAAI+B,aAAa,OAAQD,EAAa,GACtC,EAoBSE,EAAa,CACxBC,EACAC,EACAC,EACAC,KAMKD,GAIL9B,OAAOgC,KAAKF,GAASpC,SAASuC,IAC5B,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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"}
|
|
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 case 'read-only':\n compEl.setAttribute('readonly', 'true');\n break;\n default:\n logger?.error(\n `Unknown component state \"${state}\" for component with id \"${componentId}\"`,\n 'Valid states are \"disable\", \"hide\", and \"read-only\"',\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,KAyCzBE,EAAwB,CAC5BlC,EACAmC,EACAC,KAEgBpC,EAAQG,iBACtB,IAAIC,MAA2B+B,OAEzB9B,SAASC,IAEfA,EAAI+B,aAAa,OAAQD,EAAa,GACtC,EAoBSE,EAAa,CACxBC,EACAC,EACAC,EACAC,KAMKD,GAIL9B,OAAOgC,KAAKF,GAASpC,SAASuC,IAC5B,IAAKJ,EAAiBK,cAAcD,GAMlC,YALAF,EAAOI,MACL,oCAAoCF,KACpC,8BAA8BA,wCAKlC,MAAMG,EAEUC,eAAeC,IAAIL,GAE9BG,EASLpC,OAAOgC,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C,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
|
@@ -276,12 +276,12 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
276
276
|
readonly cssRules: CSSRuleList;
|
|
277
277
|
} | CSSStyleSheet;
|
|
278
278
|
nonce: string;
|
|
279
|
-
"__#
|
|
279
|
+
"__#34165@#setNonce"(): void;
|
|
280
280
|
init(): Promise<void>;
|
|
281
|
-
"__#
|
|
281
|
+
"__#34160@#observeMappings": {};
|
|
282
282
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
283
283
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
284
|
-
"__#
|
|
284
|
+
"__#34159@#isInit": boolean;
|
|
285
285
|
connectedCallback: (() => void) & (() => void) & (() => void);
|
|
286
286
|
accessKey: string;
|
|
287
287
|
readonly accessKeyLabel: string;
|
|
@@ -607,8 +607,8 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
607
607
|
tabIndex: number;
|
|
608
608
|
blur(): void;
|
|
609
609
|
focus(options?: FocusOptions): void;
|
|
610
|
-
"__#
|
|
611
|
-
"__#
|
|
610
|
+
"__#34158@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
611
|
+
"__#34158@#wrapLogger"(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
612
612
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
613
613
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
614
614
|
onLogEvent(logLevel: "error" | "warn" | "info" | "debug", data: any[]): void;
|
|
@@ -944,15 +944,15 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
944
944
|
focus(options?: FocusOptions): void;
|
|
945
945
|
};
|
|
946
946
|
} & (new (...params: any[]) => {
|
|
947
|
-
"__#
|
|
948
|
-
"__#
|
|
949
|
-
"__#
|
|
950
|
-
"__#
|
|
947
|
+
"__#34162@#lastBaseUrl"?: string;
|
|
948
|
+
"__#34162@#workingBaseUrl"?: string;
|
|
949
|
+
"__#34162@#failedUrls": Set<string>;
|
|
950
|
+
"__#34162@#getResourceUrls"(filename: string): (URL & {
|
|
951
951
|
baseUrl: string;
|
|
952
952
|
}) | (URL & {
|
|
953
953
|
baseUrl: string;
|
|
954
954
|
})[];
|
|
955
|
-
"__#
|
|
955
|
+
"__#34162@#createResourceUrl"(filename: string, baseUrl: string): URL & {
|
|
956
956
|
baseUrl: string;
|
|
957
957
|
};
|
|
958
958
|
fetchStaticResource<F extends "text" | "json">(filename: string, format: F): Promise<{
|
|
@@ -1288,38 +1288,43 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1288
1288
|
blur(): void;
|
|
1289
1289
|
focus(options?: FocusOptions): void;
|
|
1290
1290
|
readonly projectId: string;
|
|
1291
|
-
"__#
|
|
1291
|
+
"__#34161@#handleError"(attrName: string, newValue: string): void;
|
|
1292
1292
|
init(): Promise<void>;
|
|
1293
|
-
"__#
|
|
1293
|
+
"__#34160@#observeMappings": {};
|
|
1294
1294
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
1295
1295
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
1296
|
-
"__#
|
|
1297
|
-
"__#
|
|
1298
|
-
"__#
|
|
1296
|
+
"__#34159@#isInit": boolean;
|
|
1297
|
+
"__#34158@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1298
|
+
"__#34158@#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);
|
|
1299
1299
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1300
1300
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1301
1301
|
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);
|
|
1302
1302
|
}) & (new (...params: any[]) => {
|
|
1303
|
-
"__#
|
|
1304
|
-
"__#
|
|
1303
|
+
"__#34174@#globalStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
|
|
1304
|
+
"__#34174@#tenantStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
|
|
1305
|
+
"__#34174@#customStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
|
|
1305
1306
|
readonly theme: _descope_sdk_mixins_static_resources_mixin.ThemeOptions;
|
|
1306
1307
|
readonly styleId: string;
|
|
1307
1308
|
readonly themeOverride: Record<string, any>;
|
|
1308
|
-
"__#
|
|
1309
|
-
"__#
|
|
1310
|
-
"__#
|
|
1311
|
-
|
|
1312
|
-
"__#
|
|
1313
|
-
"__#
|
|
1314
|
-
"__#
|
|
1315
|
-
"__#
|
|
1309
|
+
"__#34174@#getThemeOverrideString"(): string;
|
|
1310
|
+
"__#34174@#_themeResource": Promise<void | Record<string, any>>;
|
|
1311
|
+
"__#34174@#_tenantThemeResource": Promise<Record<string, any>>;
|
|
1312
|
+
"__#34174@#fetchTheme"(): Promise<Record<string, any>>;
|
|
1313
|
+
readonly "__#34174@#themeResource": Promise<void | Record<string, any>>;
|
|
1314
|
+
"__#34174@#loadGlobalStyle"(): Promise<void>;
|
|
1315
|
+
"__#34174@#fetchTenantTheme"(): Promise<Record<string, any>>;
|
|
1316
|
+
readonly "__#34174@#tenantThemeResource": Promise<Record<string, any>>;
|
|
1317
|
+
"__#34174@#loadTenantStyle"(): Promise<void>;
|
|
1318
|
+
"__#34174@#loadCustomStyle"(): Promise<void>;
|
|
1319
|
+
"__#34174@#loadComponentsStyle"(): Promise<void>;
|
|
1320
|
+
"__#34174@#getFontsConfig"(): Promise<Record<string, {
|
|
1316
1321
|
url?: string;
|
|
1317
1322
|
}>>;
|
|
1318
|
-
"__#
|
|
1319
|
-
"__#
|
|
1320
|
-
"__#
|
|
1321
|
-
"__#
|
|
1322
|
-
"__#
|
|
1323
|
+
"__#34174@#loadFonts"(): Promise<void>;
|
|
1324
|
+
"__#34174@#applyTheme"(): Promise<void>;
|
|
1325
|
+
"__#34174@#onThemeChange": () => void;
|
|
1326
|
+
"__#34174@#loadTheme"(): void;
|
|
1327
|
+
"__#34174@#toggleOsThemeChangeListener": (listen: boolean) => void;
|
|
1323
1328
|
init(): Promise<void>;
|
|
1324
1329
|
injectStyle: ((cssString: string, { prepend }?: {
|
|
1325
1330
|
prepend?: boolean;
|
|
@@ -1337,12 +1342,12 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1337
1342
|
readonly cssRules: CSSRuleList;
|
|
1338
1343
|
});
|
|
1339
1344
|
nonce: string;
|
|
1340
|
-
"__#
|
|
1341
|
-
"__#
|
|
1342
|
-
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);
|
|
1343
|
-
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);
|
|
1344
|
-
"__#
|
|
1345
|
-
connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
1345
|
+
"__#34165@#setNonce": (() => void) & (() => void);
|
|
1346
|
+
"__#34160@#observeMappings": {};
|
|
1347
|
+
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) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
|
|
1348
|
+
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) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
|
|
1349
|
+
"__#34159@#isInit": boolean;
|
|
1350
|
+
connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
1346
1351
|
accessKey: string;
|
|
1347
1352
|
readonly accessKeyLabel: string;
|
|
1348
1353
|
autocapitalize: string;
|
|
@@ -1667,25 +1672,25 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1667
1672
|
tabIndex: number;
|
|
1668
1673
|
blur(): void;
|
|
1669
1674
|
focus(options?: FocusOptions): void;
|
|
1670
|
-
"__#
|
|
1671
|
-
"__#
|
|
1675
|
+
"__#34158@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1676
|
+
"__#34158@#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) & ((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);
|
|
1672
1677
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1673
1678
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1674
|
-
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);
|
|
1679
|
+
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) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
|
|
1675
1680
|
contentRootElement: HTMLElement;
|
|
1676
1681
|
rootElement: HTMLElement;
|
|
1677
1682
|
readonly config: Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1678
|
-
"__#
|
|
1679
|
-
"__#
|
|
1680
|
-
"__#
|
|
1681
|
-
"__#
|
|
1683
|
+
"__#34164@#configCacheClear": (() => void) & (() => void);
|
|
1684
|
+
"__#34164@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1685
|
+
"__#34164@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
|
|
1686
|
+
"__#34163@#callbacks": Map<string, () => void> & Map<string, () => void>;
|
|
1682
1687
|
onReset: ((sectionId: string, callback: () => void | Promise<void>) => () => void) & ((sectionId: string, callback: () => void | Promise<void>) => () => void);
|
|
1683
1688
|
reset: ((...sectionIds: string[]) => Promise<void>) & ((...sectionIds: string[]) => Promise<void>);
|
|
1684
|
-
"__#
|
|
1685
|
-
"__#
|
|
1686
|
-
"__#
|
|
1687
|
-
"__#
|
|
1688
|
-
"__#
|
|
1689
|
+
"__#34161@#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) & ((attrName: string, newValue: string) => void);
|
|
1690
|
+
"__#34162@#lastBaseUrl"?: string;
|
|
1691
|
+
"__#34162@#workingBaseUrl"?: string;
|
|
1692
|
+
"__#34162@#failedUrls": Set<string>;
|
|
1693
|
+
"__#34162@#getResourceUrls": ((filename: string) => (URL & {
|
|
1689
1694
|
baseUrl: string;
|
|
1690
1695
|
}) | (URL & {
|
|
1691
1696
|
baseUrl: string;
|
|
@@ -1698,7 +1703,7 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1698
1703
|
}) | (URL & {
|
|
1699
1704
|
baseUrl: string;
|
|
1700
1705
|
})[]);
|
|
1701
|
-
"__#
|
|
1706
|
+
"__#34162@#createResourceUrl": ((filename: string, baseUrl: string) => URL & {
|
|
1702
1707
|
baseUrl: string;
|
|
1703
1708
|
}) & ((filename: string, baseUrl: string) => URL & {
|
|
1704
1709
|
baseUrl: string;
|
|
@@ -1718,12 +1723,12 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1718
1723
|
readonly baseStaticUrl: string;
|
|
1719
1724
|
readonly baseUrl: string;
|
|
1720
1725
|
readonly projectId: string;
|
|
1721
|
-
"__#
|
|
1722
|
-
"__#
|
|
1723
|
-
"__#
|
|
1726
|
+
"__#34168@#getComponentsVersion"(): Promise<string>;
|
|
1727
|
+
"__#34168@#getComponentsVersionSri"(): Promise<string>;
|
|
1728
|
+
"__#34168@#descopeUi": Promise<any>;
|
|
1724
1729
|
readonly descopeUi: Promise<any>;
|
|
1725
|
-
"__#
|
|
1726
|
-
"__#
|
|
1730
|
+
"__#34168@#loadDescopeUiComponent"(componentName: string): Promise<any>;
|
|
1731
|
+
"__#34168@#getDescopeUi"(): Promise<any>;
|
|
1727
1732
|
loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
|
|
1728
1733
|
readonly baseCdnUrl: string;
|
|
1729
1734
|
injectNpmLib(libName: string, version: string, filePath?: string, overrides?: string[], integrity?: string): Promise<{
|
|
@@ -1731,6 +1736,7 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1731
1736
|
url: URL;
|
|
1732
1737
|
integrity?: string;
|
|
1733
1738
|
}>;
|
|
1739
|
+
readonly tenantId: string;
|
|
1734
1740
|
}) & {
|
|
1735
1741
|
new (): HTMLElement;
|
|
1736
1742
|
prototype: HTMLElement;
|
|
@@ -1758,7 +1764,6 @@ declare class BaseDescopeWc extends BaseClass {
|
|
|
1758
1764
|
constructor(updateExecState: FlowStateUpdateFn);
|
|
1759
1765
|
get flowId(): string;
|
|
1760
1766
|
get client(): Record<string, any>;
|
|
1761
|
-
get tenantId(): string;
|
|
1762
1767
|
get redirectUrl(): string;
|
|
1763
1768
|
get debug(): boolean;
|
|
1764
1769
|
get locale(): string;
|