@descope/web-component 3.54.0 → 3.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/cjs/helpers/helpers.js +1 -1
- package/dist/cjs/helpers/helpers.js.map +1 -1
- package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/esm/helpers/helpers.js +1 -1
- package/dist/esm/helpers/helpers.js.map +1 -1
- package/dist/index.d.ts +46 -46
- package/dist/index.js +2 -2
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/lib/helpers/helpers.ts"],"sourcesContent":["import {\n ASSETS_FOLDER,\n BASE_CONTENT_URL,\n DESCOPE_ATTRIBUTE_PREFIX,\n URL_CODE_PARAM_NAME,\n URL_ERR_PARAM_NAME,\n URL_RUN_IDS_PARAM_NAME,\n URL_TOKEN_PARAM_NAME,\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n OIDC_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_USERNAME_PARAM_NAME,\n SSO_APP_ID_PARAM_NAME,\n OIDC_LOGIN_HINT_PARAM_NAME,\n DESCOPE_IDP_INITIATED_PARAM_NAME,\n OVERRIDE_CONTENT_URL,\n OIDC_PROMPT_PARAM_NAME,\n OIDC_RESOURCE_PARAM_NAME,\n OIDC_ERROR_REDIRECT_URI_PARAM_NAME,\n THIRD_PARTY_APP_ID_PARAM_NAME,\n THIRD_PARTY_APP_STATE_ID_PARAM_NAME,\n APPLICATION_SCOPES_PARAM_NAME,\n SDK_SCRIPT_RESULTS_KEY,\n URL_REDIRECT_MODE_PARAM_NAME,\n} from '../constants';\nimport { EXCLUDED_STATE_KEYS } from '../constants/customScreens';\nimport {\n AutoFocusOptions,\n CustomScreenState,\n Direction,\n Locale,\n SSOQueryParams,\n StepState,\n} from '../types';\n\nconst MD_COMPONENTS = ['descope-enriched-text'];\n\nfunction getUrlParam(paramName: string) {\n const urlParams = new URLSearchParams(window.location.search);\n\n return urlParams.get(paramName);\n}\n\nfunction getFlowUrlParam() {\n return getUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nfunction setFlowUrlParam(id: string) {\n if (window.history.pushState && id !== getFlowUrlParam()) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.set(URL_RUN_IDS_PARAM_NAME, id);\n newUrl.search = search.toString();\n window.history.pushState({}, '', newUrl.toString());\n }\n}\n\nfunction resetUrlParam(paramName: string) {\n if (window.history.replaceState && getUrlParam(paramName)) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.delete(paramName);\n newUrl.search = search.toString();\n window.history.replaceState({}, '', newUrl.toString());\n }\n}\n\nconst getFlowIdFromExecId = (executionId: string) => {\n const regex = /(.*)\\|#\\|.*/;\n return regex.exec(executionId)?.[1] || '';\n};\n\nexport async function fetchContent<T extends 'text' | 'json'>(\n url: string,\n returnType: T,\n): Promise<{\n body: T extends 'json' ? Record<string, any> : string;\n headers: Record<string, string>;\n}> {\n const res = await fetch(url, { cache: 'default' });\n if (!res.ok) {\n throw Error(`Error fetching URL ${url} [${res.status}]`);\n }\n\n return {\n body: await res[returnType || 'text'](),\n headers: Object.fromEntries(res.headers.entries()),\n };\n}\n\nconst pathJoin = (...paths: string[]) => paths.join('/').replace(/\\/+/g, '/'); // preventing duplicate separators\n\nexport function getContentUrl({\n projectId,\n filename,\n assetsFolder = ASSETS_FOLDER,\n baseUrl,\n}: {\n projectId: string;\n filename: string;\n assetsFolder?: string;\n baseUrl?: string;\n}) {\n const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL);\n url.pathname = pathJoin(url.pathname, projectId, assetsFolder, filename);\n\n return url.toString();\n}\n\nexport function getAnimationDirection(\n currentIdxStr: string,\n prevIdxStr: string,\n) {\n if (!prevIdxStr) return undefined;\n\n const currentIdx = +currentIdxStr;\n const prevIdx = +prevIdxStr;\n\n if (Number.isNaN(currentIdx) || Number.isNaN(prevIdx)) return undefined;\n if (currentIdx > prevIdx) return Direction.forward;\n if (currentIdx < prevIdx) return Direction.backward;\n return undefined;\n}\n\nexport const getRunIdsFromUrl = (flowId: string) => {\n let [executionId = '', stepId = ''] = (getFlowUrlParam() || '').split('_');\n const executionFlowId = getFlowIdFromExecId(executionId);\n\n // if the flow id does not match, this execution id is not for this flow\n if (!flowId || (executionFlowId && executionFlowId !== flowId)) {\n executionId = '';\n stepId = '';\n }\n\n return { executionId, stepId, executionFlowId };\n};\n\nexport const setRunIdsOnUrl = (executionId: string, stepId: string) => {\n setFlowUrlParam([executionId, stepId].join('_'));\n};\n\nexport function isChromium() {\n return (\n /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)\n );\n}\n\n// Detect Safari running on iPhone specifically.\nfunction isIphoneSafari() {\n const ua = navigator.userAgent || '';\n const isIphone = /\\b(iPhone)\\b/.test(ua);\n // Safari UA contains 'Safari' and usually 'Version/X', exclude other iOS browsers\n const isSafari =\n /Safari/.test(ua) && !/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(ua);\n\n return isIphone && isSafari;\n}\n\nexport function clearRunIdsFromUrl() {\n resetUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nexport function getTokenFromUrl() {\n return getUrlParam(URL_TOKEN_PARAM_NAME) || undefined;\n}\n\nexport function clearTokenFromUrl() {\n resetUrlParam(URL_TOKEN_PARAM_NAME);\n}\n\nexport function getCodeFromUrl() {\n return getUrlParam(URL_CODE_PARAM_NAME) || undefined;\n}\n\nexport function getIsPopupFromUrl() {\n return getUrlParam(URL_REDIRECT_MODE_PARAM_NAME) === 'popup';\n}\n\nexport function getExchangeErrorFromUrl() {\n return getUrlParam(URL_ERR_PARAM_NAME) || undefined;\n}\n\nexport function clearCodeFromUrl() {\n resetUrlParam(URL_CODE_PARAM_NAME);\n}\n\nexport function clearIsPopupFromUrl() {\n resetUrlParam(URL_REDIRECT_MODE_PARAM_NAME);\n}\n\nexport function clearExchangeErrorFromUrl() {\n resetUrlParam(URL_ERR_PARAM_NAME);\n}\n\nexport function getRedirectAuthFromUrl() {\n const redirectAuthCodeChallenge = getUrlParam(\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n );\n const redirectAuthCallbackUrl = getUrlParam(\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n );\n const redirectAuthBackupCallbackUri = getUrlParam(\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n );\n const redirectAuthInitiator = getUrlParam(\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n );\n return {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n };\n}\n\nexport function getOIDCIDPParamFromUrl() {\n return getUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearOIDCIDPParamFromUrl() {\n resetUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPParamFromUrl() {\n return getUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearSAMLIDPParamFromUrl() {\n resetUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPUsernameParamFromUrl() {\n return getUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function clearSAMLIDPUsernameParamFromUrl() {\n resetUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function getDescopeIDPInitiatedParamFromUrl() {\n return getUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function clearDescopeIDPInitiatedParamFromUrl() {\n resetUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function getSSOAppIdParamFromUrl() {\n return getUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function clearSSOAppIdParamFromUrl() {\n resetUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppStateIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppStateIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function getApplicationScopesParamFromUrl() {\n return getUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function clearApplicationScopesParamFromUrl() {\n resetUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function getOIDCLoginHintParamFromUrl() {\n return getUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function clearOIDCLoginHintParamFromUrl() {\n resetUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function getOIDCPromptParamFromUrl() {\n return getUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function clearOIDCPromptParamFromUrl() {\n resetUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function getOIDCErrorRedirectUriParamFromUrl() {\n return getUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function clearOIDCErrorRedirectUriParamFromUrl() {\n resetUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function getOIDCResourceParamFromUrl() {\n return getUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport function clearOIDCResourceParamFromUrl() {\n resetUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport const camelCase = (s: string) =>\n s.replace(/-./g, (x) => x[1].toUpperCase());\n\nexport const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\nexport const getElementDescopeAttributes = (ele: HTMLElement) =>\n Array.from(ele?.attributes || []).reduce((acc, attr) => {\n const descopeAttrName = new RegExp(\n `^${DESCOPE_ATTRIBUTE_PREFIX}(\\\\S+)$`,\n ).exec(attr.name)?.[1];\n\n return !descopeAttrName\n ? acc\n : Object.assign(acc, { [descopeAttrName]: attr.value });\n }, {});\n\nexport const getFlowConfig = (config: Record<string, any>, flowId: string) =>\n config?.flows?.[flowId] || {};\n\nexport const handleUrlParams = (\n flowId: string,\n logger: { debug: (...data: any[]) => void },\n) => {\n const { executionId, stepId, executionFlowId } = getRunIdsFromUrl(flowId);\n\n // if the flow id does not match, we do not want to read & remove any query params\n // because it's probably belongs to another flow\n if (executionFlowId && flowId !== executionFlowId) {\n logger.debug(\n 'Flow id does not match the execution flow id, skipping url params handling',\n );\n return { ssoQueryParams: {} };\n }\n\n if (executionId || stepId) {\n clearRunIdsFromUrl();\n }\n\n const token = getTokenFromUrl();\n if (token) {\n clearTokenFromUrl();\n }\n\n const code = getCodeFromUrl();\n if (code) {\n clearCodeFromUrl();\n }\n\n // this is used for oauth when we want to open the provider login page in a new tab\n const isPopup = getIsPopupFromUrl();\n if (isPopup) {\n clearIsPopupFromUrl();\n }\n\n const exchangeError = getExchangeErrorFromUrl();\n if (exchangeError) {\n clearExchangeErrorFromUrl();\n }\n\n // these query params are retained to allow the flow to be refreshed\n // without losing the redirect auth state\n const {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n } = getRedirectAuthFromUrl();\n\n const oidcIdpStateId = getOIDCIDPParamFromUrl();\n if (oidcIdpStateId) {\n clearOIDCIDPParamFromUrl();\n }\n\n const samlIdpStateId = getSAMLIDPParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPParamFromUrl();\n }\n\n const samlIdpUsername = getSAMLIDPUsernameParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPUsernameParamFromUrl();\n }\n\n const descopeIdpInitiated = getDescopeIDPInitiatedParamFromUrl();\n if (descopeIdpInitiated) {\n clearDescopeIDPInitiatedParamFromUrl();\n }\n\n const ssoAppId = getSSOAppIdParamFromUrl();\n if (ssoAppId) {\n clearSSOAppIdParamFromUrl();\n }\n\n const thirdPartyAppId = getThirdPartyAppIdParamFromUrl();\n if (thirdPartyAppId) {\n clearThirdPartyAppIdParamFromUrl();\n }\n\n const thirdPartyAppStateId = getThirdPartyAppStateIdParamFromUrl();\n if (thirdPartyAppStateId) {\n clearThirdPartyAppStateIdParamFromUrl();\n }\n\n const applicationScopes = getApplicationScopesParamFromUrl();\n if (applicationScopes) {\n clearApplicationScopesParamFromUrl();\n }\n\n const oidcLoginHint = getOIDCLoginHintParamFromUrl();\n if (oidcLoginHint) {\n clearOIDCLoginHintParamFromUrl();\n }\n\n const oidcPrompt = getOIDCPromptParamFromUrl();\n if (oidcPrompt) {\n clearOIDCPromptParamFromUrl();\n }\n\n const oidcErrorRedirectUri = getOIDCErrorRedirectUriParamFromUrl();\n if (oidcErrorRedirectUri) {\n clearOIDCErrorRedirectUriParamFromUrl();\n }\n\n const oidcResource = getOIDCResourceParamFromUrl();\n if (oidcResource) {\n clearOIDCResourceParamFromUrl();\n }\n\n const idpInitiatedVal = descopeIdpInitiated === 'true';\n\n return {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n ssoQueryParams: {\n oidcIdpStateId,\n samlIdpStateId,\n samlIdpUsername,\n descopeIdpInitiated: idpInitiatedVal,\n ssoAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n },\n };\n};\n\nexport const loadFont = (url: string) => {\n if (!url) return;\n\n const font = document.createElement('link');\n font.href = url;\n font.rel = 'stylesheet';\n document.head.appendChild(font);\n};\n\nconst compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return Object.assign(\n (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n },\n {\n reset: () => {\n prevArgs = undefined;\n cache = undefined;\n },\n },\n );\n};\n\nexport const handleAutoFocus = (\n ele: HTMLElement,\n autoFocus: AutoFocusOptions,\n isFirstScreen: boolean,\n) => {\n if (\n autoFocus === true ||\n (autoFocus === 'skipFirstScreen' && !isFirstScreen)\n ) {\n // focus the first visible input\n const firstVisibleInput: HTMLInputElement = ele.querySelector('*[name]');\n setTimeout(() => {\n firstVisibleInput?.focus();\n });\n }\n};\n\nexport const handleReportValidityOnBlur = (rootEle: HTMLElement) => {\n rootEle.querySelectorAll('*[name]').forEach((ele: HTMLInputElement) => {\n ele.addEventListener('blur', () => {\n const onBlur = () => {\n // reportValidity also focus the element if it's invalid\n // in order to prevent this we need to override the focus method\n const origFocus = ele.focus;\n // eslint-disable-next-line no-param-reassign\n ele.focus = () => {};\n ele.reportValidity?.();\n setTimeout(() => {\n // eslint-disable-next-line no-param-reassign\n ele.focus = origFocus;\n });\n };\n\n const isInputAlreadyInErrorState = ele.getAttribute('invalid') === 'true';\n\n if (isInputAlreadyInErrorState || ele.value?.length) {\n onBlur();\n return;\n }\n\n // If the input is not in an error state, has no value, and a `formnovalidate` button was clicked,\n // we want to prevent triggering validation.\n // This handles a case where a required input was focused, and the user then clicked a social login button —\n // in that case, we don't want the required error message to flash for a split second.\n const ref = { timer: undefined };\n\n const onClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n if (target.getAttribute('formnovalidate') === 'true') {\n clearTimeout(ref.timer);\n ref.timer = undefined;\n }\n };\n\n ref.timer = setTimeout(() => {\n rootEle.removeEventListener('click', onClick);\n onBlur();\n ref.timer = undefined;\n }, 150);\n\n rootEle.addEventListener('click', onClick, { once: true });\n });\n });\n};\n\n/**\n * To return a fallback value in case the timeout expires and the promise\n * isn't fulfilled:\n *\n * const promise = loadUserCount();\n * const count = await timeoutPromise(2000, promise, 0);\n *\n * Or without a fallback value to just throw an error if the timeout expires:\n *\n * try {\n * count = await timeoutPromise(2000, promise);\n * }\n *\n * Fallback is returned only in case of timeout, so if the passed promise rejects\n * the fallback value is not used, and the returned promise will throw as well.\n */\nexport function timeoutPromise<T>(\n timeout: number,\n promise: Promise<T>,\n fallback?: T,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n let expired = false;\n const timer = setTimeout(() => {\n expired = true;\n if (fallback !== undefined) {\n resolve(fallback);\n } else {\n reject(new Error(`Promise timed out after ${timeout} ms`));\n }\n }, timeout);\n\n promise\n .then((value) => {\n if (!expired) {\n clearTimeout(timer);\n resolve(value);\n }\n })\n .catch((error) => {\n if (!expired) {\n clearTimeout(timer);\n reject(error);\n }\n });\n });\n}\n\nexport const getChromiumVersion = (): number => {\n const brands = (navigator as any)?.userAgentData?.brands;\n const found = brands?.find(\n ({ brand, version }) => brand === 'Chromium' && parseFloat(version),\n );\n return found ? found.version : 0;\n};\n\n// As an optimization - We can show first screen if we have startScreenId and we don't have any other of the ssoAppId/oidcIdpStateId/samlIdp params\n// - If there startScreenId it means that the sdk can show the first screen and we don't need to wait for the sdk to return the first screen\n// - If there is any one else of the other params (like oidcIdpStateId, ..) - we can't skip this call because descope may decide not to show the first screen (in cases like a user is already logged in)\nexport const showFirstScreenOnExecutionInit = (\n startScreenId: string,\n {\n oidcIdpStateId,\n samlIdpStateId,\n samlIdpUsername,\n ssoAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n }: SSOQueryParams,\n): boolean =>\n !!startScreenId &&\n !oidcIdpStateId &&\n !samlIdpStateId &&\n !samlIdpUsername &&\n !ssoAppId &&\n !oidcLoginHint &&\n !oidcPrompt &&\n !oidcErrorRedirectUri &&\n !oidcResource &&\n !thirdPartyAppId &&\n !thirdPartyAppStateId &&\n !applicationScopes;\n\nexport const injectSamlIdpForm = (\n url: string,\n samlResponse: string,\n relayState: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n formEle.innerHTML = `\n <input type=\"hidden\" role=\"saml-response\" name=\"SAMLResponse\" value=\"${samlResponse}\" />\n <input type=\"hidden\" role=\"saml-relay-state\" name=\"RelayState\" value=\"${relayState}\" />\n <input style=\"display: none;\" id=\"SAMLSubmitButton\" type=\"submit\" value=\"Continue\" />\n `;\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const submitForm = (formEle: HTMLFormElement) => formEle?.submit();\n\nexport const getFirstNonEmptyValue = (obj: object, keys: string[]) => {\n const firstNonEmptyKey = keys.find((key) => obj[key]);\n return firstNonEmptyKey ? obj[firstNonEmptyKey] : null;\n};\n\nexport const leadingDebounce = <T extends (...args: any[]) => void>(\n func: T,\n wait = 100,\n) => {\n let timeout: NodeJS.Timeout;\n return function executedFunction(...args) {\n if (!timeout) func.apply(this, args);\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n timeout = null;\n }, wait);\n } as T;\n};\n\nexport function getUserLocale(locale: string): Locale {\n if (locale) {\n return { locale: locale.toLowerCase(), fallback: locale.toLowerCase() };\n }\n const nl = navigator.language;\n if (!nl) {\n return { locale: '', fallback: '' };\n }\n\n if (nl.includes('-')) {\n return {\n locale: nl.toLowerCase(),\n fallback: nl.split('-')[0].toLowerCase(),\n };\n }\n\n return { locale: nl.toLowerCase(), fallback: nl.toLowerCase() };\n}\n\nexport const clearPreviousExternalInputs = () => {\n document\n .querySelectorAll('[data-hidden-input=\"true\"]')\n .forEach((ele) => ele.remove());\n};\n\nexport const shouldHandleMarkdown = (compName: string) =>\n MD_COMPONENTS.includes(compName);\n\nconst omitBy = <T extends Record<string, any>>(\n obj: T,\n predicate: (value: any, key: keyof T) => boolean,\n): T =>\n Object.fromEntries(\n Object.entries(obj).filter(\n ([key, value]) => !predicate(value, key as keyof T),\n ),\n ) as T;\n\nexport const transformStepStateForCustomScreen = (\n state: Partial<StepState>,\n) => {\n const sanitizedState: CustomScreenState = omitBy(\n state.screenState,\n (_, key) => EXCLUDED_STATE_KEYS.includes(key) || key.startsWith('_'),\n );\n\n const {\n screenState: { errorText, errorType },\n } = state;\n\n if (errorText || errorType) {\n sanitizedState.error = { text: errorText, type: errorType };\n }\n\n if (state.action) {\n sanitizedState.action = state.action;\n }\n\n if (state.screenState?.componentsConfig?.thirdPartyAppApproveScopes?.data) {\n sanitizedState.inboundAppApproveScopes =\n state.screenState.componentsConfig.thirdPartyAppApproveScopes.data;\n }\n\n return sanitizedState;\n};\n\nexport const transformScreenInputs = (inputs: Record<string, any>) => {\n const res = { ...inputs };\n\n if (inputs.inboundAppApproveScopes) {\n res.thirdPartyAppApproveScopes = inputs.inboundAppApproveScopes;\n }\n\n return res;\n};\n\nexport function getScriptResultPath(scriptId: string, resultKey?: string) {\n const path = resultKey ? `${scriptId}_${resultKey}` : scriptId;\n return `${SDK_SCRIPT_RESULTS_KEY}.${path}`;\n}\n\nexport const openCenteredPopup = (\n url: string,\n title: string,\n w: number,\n h: number,\n) => {\n const dualScreenLeft =\n window.screenLeft !== undefined\n ? window.screenLeft\n : (window.screen as any).left;\n const dualScreenTop =\n window.screenTop !== undefined\n ? window.screenTop\n : (window.screen as any).top;\n\n const width =\n window.innerWidth ||\n document.documentElement.clientWidth ||\n window.screen.width;\n const height =\n window.innerHeight ||\n document.documentElement.clientHeight ||\n window.screen.height;\n\n const left = (width - w) / 2 + dualScreenLeft;\n const top = (height - h) / 2 + dualScreenTop;\n\n // Safari on Mac may detect authentication URLs and replace the popup with a native macOS auth dialog.\n // To avoid that, we open the popup with empty string as URL and then populate it with the needed URL.\n // This avoids the native dialog, and uses the web interface for authentication.\n const initialUrl = isIphoneSafari() ? 'about:blank' : '';\n const popup = window.open(\n initialUrl,\n title,\n `width=${w},height=${h},top=${top},left=${left},scrollbars=yes,resizable=yes`,\n );\n\n popup.location.href = url;\n popup.focus();\n\n return popup;\n};\n"],"names":["MD_COMPONENTS","getUrlParam","paramName","URLSearchParams","window","location","search","get","resetUrlParam","history","replaceState","newUrl","URL","href","delete","toString","fetchContent","url","returnType","res","fetch","cache","ok","Error","status","body","headers","Object","fromEntries","entries","getContentUrl","projectId","filename","assetsFolder","ASSETS_FOLDER","baseUrl","OVERRIDE_CONTENT_URL","BASE_CONTENT_URL","pathname","paths","join","replace","pathJoin","getAnimationDirection","currentIdxStr","prevIdxStr","currentIdx","prevIdx","Number","isNaN","Direction","forward","backward","getRunIdsFromUrl","flowId","executionId","stepId","URL_RUN_IDS_PARAM_NAME","split","executionFlowId","_a","exec","getFlowIdFromExecId","isChromium","test","navigator","userAgent","vendor","clearRunIdsFromUrl","getTokenFromUrl","URL_TOKEN_PARAM_NAME","undefined","clearTokenFromUrl","getCodeFromUrl","URL_CODE_PARAM_NAME","getIsPopupFromUrl","URL_REDIRECT_MODE_PARAM_NAME","getExchangeErrorFromUrl","URL_ERR_PARAM_NAME","clearCodeFromUrl","clearIsPopupFromUrl","clearExchangeErrorFromUrl","getRedirectAuthFromUrl","redirectAuthCodeChallenge","URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME","redirectAuthCallbackUrl","URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME","redirectAuthBackupCallbackUri","URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME","redirectAuthInitiator","URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME","getOIDCIDPParamFromUrl","OIDC_IDP_STATE_ID_PARAM_NAME","clearOIDCIDPParamFromUrl","getSAMLIDPParamFromUrl","SAML_IDP_STATE_ID_PARAM_NAME","clearSAMLIDPParamFromUrl","getSAMLIDPUsernameParamFromUrl","SAML_IDP_USERNAME_PARAM_NAME","clearSAMLIDPUsernameParamFromUrl","getDescopeIDPInitiatedParamFromUrl","DESCOPE_IDP_INITIATED_PARAM_NAME","clearDescopeIDPInitiatedParamFromUrl","getSSOAppIdParamFromUrl","SSO_APP_ID_PARAM_NAME","getThirdPartyAppIdParamFromUrl","THIRD_PARTY_APP_ID_PARAM_NAME","clearSSOAppIdParamFromUrl","clearThirdPartyAppIdParamFromUrl","getThirdPartyAppStateIdParamFromUrl","THIRD_PARTY_APP_STATE_ID_PARAM_NAME","clearThirdPartyAppStateIdParamFromUrl","getApplicationScopesParamFromUrl","APPLICATION_SCOPES_PARAM_NAME","clearApplicationScopesParamFromUrl","getOIDCLoginHintParamFromUrl","OIDC_LOGIN_HINT_PARAM_NAME","clearOIDCLoginHintParamFromUrl","getOIDCPromptParamFromUrl","OIDC_PROMPT_PARAM_NAME","clearOIDCPromptParamFromUrl","getOIDCErrorRedirectUriParamFromUrl","OIDC_ERROR_REDIRECT_URI_PARAM_NAME","clearOIDCErrorRedirectUriParamFromUrl","getOIDCResourceParamFromUrl","OIDC_RESOURCE_PARAM_NAME","clearOIDCResourceParamFromUrl","camelCase","s","x","toUpperCase","createIsChanged","state","prevState","attrName","getElementDescopeAttributes","ele","Array","from","attributes","reduce","acc","attr","descopeAttrName","RegExp","DESCOPE_ATTRIBUTE_PREFIX","name","assign","value","handleUrlParams","logger","debug","ssoQueryParams","token","code","isPopup","exchangeError","oidcIdpStateId","samlIdpStateId","samlIdpUsername","descopeIdpInitiated","ssoAppId","thirdPartyAppId","thirdPartyAppStateId","applicationScopes","oidcLoginHint","oidcPrompt","oidcErrorRedirectUri","oidcResource","withMemCache","fn","prevArgs","args","array2","array1","length","every","index","reset","handleAutoFocus","autoFocus","isFirstScreen","firstVisibleInput","querySelector","setTimeout","focus","handleReportValidityOnBlur","rootEle","querySelectorAll","forEach","addEventListener","onBlur","origFocus","reportValidity","call","getAttribute","ref","timer","onClick","e","target","clearTimeout","removeEventListener","once","timeoutPromise","timeout","promise","fallback","Promise","resolve","reject","expired","then","catch","error","getChromiumVersion","brands","userAgentData","found","find","brand","version","parseFloat","showFirstScreenOnExecutionInit","startScreenId","injectSamlIdpForm","samlResponse","relayState","submitCallback","formEle","document","createElement","method","action","innerHTML","appendChild","submitForm","submit","getFirstNonEmptyValue","obj","keys","firstNonEmptyKey","key","leadingDebounce","func","wait","apply","this","getUserLocale","locale","toLowerCase","nl","language","includes","clearPreviousExternalInputs","remove","shouldHandleMarkdown","compName","transformStepStateForCustomScreen","sanitizedState","screenState","predicate","_","EXCLUDED_STATE_KEYS","startsWith","filter","errorText","errorType","text","type","_c","_b","componentsConfig","thirdPartyAppApproveScopes","data","inboundAppApproveScopes","transformScreenInputs","inputs","getScriptResultPath","scriptId","resultKey","SDK_SCRIPT_RESULTS_KEY","openCenteredPopup","title","w","h","dualScreenLeft","screenLeft","screen","left","dualScreenTop","screenTop","top","innerWidth","documentElement","clientWidth","width","innerHeight","clientHeight","height","initialUrl","ua","isIphone","isSafari","isIphoneSafari","popup","open"],"mappings":"yiCAsCA,MAAMA,EAAgB,CAAC,yBAEvB,SAASC,EAAYC,GAGnB,OAFkB,IAAIC,gBAAgBC,OAAOC,SAASC,QAErCC,IAAIL,EACvB,CAgBA,SAASM,EAAcN,GACrB,GAAIE,OAAOK,QAAQC,cAAgBT,EAAYC,GAAY,CACzD,MAAMS,EAAS,IAAIC,IAAIR,OAAOC,SAASQ,MACjCP,EAAS,IAAIH,gBAAgBQ,EAAOL,QAC1CA,EAAOQ,OAAOZ,GACdS,EAAOL,OAASA,EAAOS,WACvBX,OAAOK,QAAQC,aAAa,CAAA,EAAI,GAAIC,EAAOI,WAC5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E_CONTENT_URL,\n DESCOPE_ATTRIBUTE_PREFIX,\n URL_CODE_PARAM_NAME,\n URL_ERR_PARAM_NAME,\n URL_RUN_IDS_PARAM_NAME,\n URL_TOKEN_PARAM_NAME,\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n OIDC_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_USERNAME_PARAM_NAME,\n SSO_APP_ID_PARAM_NAME,\n OIDC_LOGIN_HINT_PARAM_NAME,\n DESCOPE_IDP_INITIATED_PARAM_NAME,\n OVERRIDE_CONTENT_URL,\n OIDC_PROMPT_PARAM_NAME,\n OIDC_RESOURCE_PARAM_NAME,\n OIDC_ERROR_REDIRECT_URI_PARAM_NAME,\n THIRD_PARTY_APP_ID_PARAM_NAME,\n THIRD_PARTY_APP_STATE_ID_PARAM_NAME,\n APPLICATION_SCOPES_PARAM_NAME,\n SDK_SCRIPT_RESULTS_KEY,\n URL_REDIRECT_MODE_PARAM_NAME,\n} from '../constants';\nimport { EXCLUDED_STATE_KEYS } from '../constants/customScreens';\nimport {\n AutoFocusOptions,\n CustomScreenState,\n Direction,\n Locale,\n SSOQueryParams,\n StepState,\n} from '../types';\n\nconst MD_COMPONENTS = ['descope-enriched-text'];\n\nfunction getUrlParam(paramName: string) {\n const urlParams = new URLSearchParams(window.location.search);\n\n return urlParams.get(paramName);\n}\n\nfunction getFlowUrlParam() {\n return getUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nfunction setFlowUrlParam(id: string) {\n if (window.history.pushState && id !== getFlowUrlParam()) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.set(URL_RUN_IDS_PARAM_NAME, id);\n newUrl.search = search.toString();\n window.history.pushState({}, '', newUrl.toString());\n }\n}\n\nfunction resetUrlParam(paramName: string) {\n if (window.history.replaceState && getUrlParam(paramName)) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.delete(paramName);\n newUrl.search = search.toString();\n window.history.replaceState({}, '', newUrl.toString());\n }\n}\n\nconst getFlowIdFromExecId = (executionId: string) => {\n const regex = /(.*)\\|#\\|.*/;\n return regex.exec(executionId)?.[1] || '';\n};\n\nexport async function fetchContent<T extends 'text' | 'json'>(\n url: string,\n returnType: T,\n): Promise<{\n body: T extends 'json' ? Record<string, any> : string;\n headers: Record<string, string>;\n}> {\n const res = await fetch(url, { cache: 'default' });\n if (!res.ok) {\n throw Error(`Error fetching URL ${url} [${res.status}]`);\n }\n\n return {\n body: await res[returnType || 'text'](),\n headers: Object.fromEntries(res.headers.entries()),\n };\n}\n\nconst pathJoin = (...paths: string[]) => paths.join('/').replace(/\\/+/g, '/'); // preventing duplicate separators\n\nexport function getContentUrl({\n projectId,\n filename,\n assetsFolder = ASSETS_FOLDER,\n baseUrl,\n}: {\n projectId: string;\n filename: string;\n assetsFolder?: string;\n baseUrl?: string;\n}) {\n const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL);\n url.pathname = pathJoin(url.pathname, projectId, assetsFolder, filename);\n\n return url.toString();\n}\n\nexport function getAnimationDirection(\n currentIdxStr: string,\n prevIdxStr: string,\n) {\n if (!prevIdxStr) return undefined;\n\n const currentIdx = +currentIdxStr;\n const prevIdx = +prevIdxStr;\n\n if (Number.isNaN(currentIdx) || Number.isNaN(prevIdx)) return undefined;\n if (currentIdx > prevIdx) return Direction.forward;\n if (currentIdx < prevIdx) return Direction.backward;\n return undefined;\n}\n\nexport const getRunIdsFromUrl = (flowId: string) => {\n let [executionId = '', stepId = ''] = (getFlowUrlParam() || '').split('_');\n const executionFlowId = getFlowIdFromExecId(executionId);\n\n // if the flow id does not match, this execution id is not for this flow\n if (!flowId || (executionFlowId && executionFlowId !== flowId)) {\n executionId = '';\n stepId = '';\n }\n\n return { executionId, stepId, executionFlowId };\n};\n\nexport const setRunIdsOnUrl = (executionId: string, stepId: string) => {\n setFlowUrlParam([executionId, stepId].join('_'));\n};\n\nexport function isChromium() {\n return (\n /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)\n );\n}\n\n// Detect Safari running on iPhone specifically.\nfunction isIphoneSafari() {\n const ua = navigator.userAgent || '';\n const isIphone = /\\b(iPhone)\\b/.test(ua);\n // Safari UA contains 'Safari' and usually 'Version/X', exclude other iOS browsers\n const isSafari =\n /Safari/.test(ua) && !/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(ua);\n\n return isIphone && isSafari;\n}\n\nexport function clearRunIdsFromUrl() {\n resetUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nexport function getTokenFromUrl() {\n return getUrlParam(URL_TOKEN_PARAM_NAME) || undefined;\n}\n\nexport function clearTokenFromUrl() {\n resetUrlParam(URL_TOKEN_PARAM_NAME);\n}\n\nexport function getCodeFromUrl() {\n return getUrlParam(URL_CODE_PARAM_NAME) || undefined;\n}\n\nexport function getIsPopupFromUrl() {\n return getUrlParam(URL_REDIRECT_MODE_PARAM_NAME) === 'popup';\n}\n\nexport function getExchangeErrorFromUrl() {\n return getUrlParam(URL_ERR_PARAM_NAME) || undefined;\n}\n\nexport function clearCodeFromUrl() {\n resetUrlParam(URL_CODE_PARAM_NAME);\n}\n\nexport function clearIsPopupFromUrl() {\n resetUrlParam(URL_REDIRECT_MODE_PARAM_NAME);\n}\n\nexport function clearExchangeErrorFromUrl() {\n resetUrlParam(URL_ERR_PARAM_NAME);\n}\n\nexport function getRedirectAuthFromUrl() {\n const redirectAuthCodeChallenge = getUrlParam(\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n );\n const redirectAuthCallbackUrl = getUrlParam(\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n );\n const redirectAuthBackupCallbackUri = getUrlParam(\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n );\n const redirectAuthInitiator = getUrlParam(\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n );\n return {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n };\n}\n\nexport function getOIDCIDPParamFromUrl() {\n return getUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearOIDCIDPParamFromUrl() {\n resetUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPParamFromUrl() {\n return getUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearSAMLIDPParamFromUrl() {\n resetUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPUsernameParamFromUrl() {\n return getUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function clearSAMLIDPUsernameParamFromUrl() {\n resetUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function getDescopeIDPInitiatedParamFromUrl() {\n return getUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function clearDescopeIDPInitiatedParamFromUrl() {\n resetUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function getSSOAppIdParamFromUrl() {\n return getUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function clearSSOAppIdParamFromUrl() {\n resetUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppStateIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppStateIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function getApplicationScopesParamFromUrl() {\n return getUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function clearApplicationScopesParamFromUrl() {\n resetUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function getOIDCLoginHintParamFromUrl() {\n return getUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function clearOIDCLoginHintParamFromUrl() {\n resetUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function getOIDCPromptParamFromUrl() {\n return getUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function clearOIDCPromptParamFromUrl() {\n resetUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function getOIDCErrorRedirectUriParamFromUrl() {\n return getUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function clearOIDCErrorRedirectUriParamFromUrl() {\n resetUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function getOIDCResourceParamFromUrl() {\n return getUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport function clearOIDCResourceParamFromUrl() {\n resetUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport const camelCase = (s: string) =>\n s.replace(/-./g, (x) => x[1].toUpperCase());\n\nexport const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\nexport const getElementDescopeAttributes = (ele: HTMLElement) =>\n Array.from(ele?.attributes || []).reduce((acc, attr) => {\n const descopeAttrName = new RegExp(\n `^${DESCOPE_ATTRIBUTE_PREFIX}(\\\\S+)$`,\n ).exec(attr.name)?.[1];\n\n return !descopeAttrName\n ? acc\n : Object.assign(acc, { [descopeAttrName]: attr.value });\n }, {});\n\nexport const getFlowConfig = (config: Record<string, any>, flowId: string) =>\n config?.flows?.[flowId] || {};\n\nexport const handleUrlParams = (\n flowId: string,\n logger: { debug: (...data: any[]) => void },\n) => {\n const { executionId, stepId, executionFlowId } = getRunIdsFromUrl(flowId);\n\n // if the flow id does not match, we do not want to read & remove any query params\n // because it's probably belongs to another flow\n if (executionFlowId && flowId !== executionFlowId) {\n logger.debug(\n 'Flow id does not match the execution flow id, skipping url params handling',\n );\n return { ssoQueryParams: {} };\n }\n\n if (executionId || stepId) {\n clearRunIdsFromUrl();\n }\n\n const token = getTokenFromUrl();\n if (token) {\n clearTokenFromUrl();\n }\n\n const code = getCodeFromUrl();\n if (code) {\n clearCodeFromUrl();\n }\n\n // this is used for oauth when we want to open the provider login page in a new tab\n const isPopup = getIsPopupFromUrl();\n if (isPopup) {\n clearIsPopupFromUrl();\n }\n\n const exchangeError = getExchangeErrorFromUrl();\n if (exchangeError) {\n clearExchangeErrorFromUrl();\n }\n\n // these query params are retained to allow the flow to be refreshed\n // without losing the redirect auth state\n const {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n } = getRedirectAuthFromUrl();\n\n const oidcIdpStateId = getOIDCIDPParamFromUrl();\n if (oidcIdpStateId) {\n clearOIDCIDPParamFromUrl();\n }\n\n const samlIdpStateId = getSAMLIDPParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPParamFromUrl();\n }\n\n const samlIdpUsername = getSAMLIDPUsernameParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPUsernameParamFromUrl();\n }\n\n const descopeIdpInitiated = getDescopeIDPInitiatedParamFromUrl();\n if (descopeIdpInitiated) {\n clearDescopeIDPInitiatedParamFromUrl();\n }\n\n const ssoAppId = getSSOAppIdParamFromUrl();\n if (ssoAppId) {\n clearSSOAppIdParamFromUrl();\n }\n\n const thirdPartyAppId = getThirdPartyAppIdParamFromUrl();\n if (thirdPartyAppId) {\n clearThirdPartyAppIdParamFromUrl();\n }\n\n const thirdPartyAppStateId = getThirdPartyAppStateIdParamFromUrl();\n if (thirdPartyAppStateId) {\n clearThirdPartyAppStateIdParamFromUrl();\n }\n\n const applicationScopes = getApplicationScopesParamFromUrl();\n if (applicationScopes) {\n clearApplicationScopesParamFromUrl();\n }\n\n const oidcLoginHint = getOIDCLoginHintParamFromUrl();\n if (oidcLoginHint) {\n clearOIDCLoginHintParamFromUrl();\n }\n\n const oidcPrompt = getOIDCPromptParamFromUrl();\n if (oidcPrompt) {\n clearOIDCPromptParamFromUrl();\n }\n\n const oidcErrorRedirectUri = getOIDCErrorRedirectUriParamFromUrl();\n if (oidcErrorRedirectUri) {\n clearOIDCErrorRedirectUriParamFromUrl();\n }\n\n const oidcResource = getOIDCResourceParamFromUrl();\n if (oidcResource) {\n clearOIDCResourceParamFromUrl();\n }\n\n const idpInitiatedVal = descopeIdpInitiated === 'true';\n\n return {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n ssoQueryParams: {\n oidcIdpStateId,\n samlIdpStateId,\n samlIdpUsername,\n descopeIdpInitiated: idpInitiatedVal,\n ssoAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n },\n };\n};\n\nexport const loadFont = (url: string) => {\n if (!url) return;\n\n const font = document.createElement('link');\n font.href = url;\n font.rel = 'stylesheet';\n document.head.appendChild(font);\n};\n\nconst compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return Object.assign(\n (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n },\n {\n reset: () => {\n prevArgs = undefined;\n cache = undefined;\n },\n },\n );\n};\n\nexport const FOCUSABLE_INPUTS_SELECTOR =\n '*[name]:not([auto-focus=\"false\"]):not([aria-hidden=\"true\"])';\n\nexport const handleAutoFocus = (\n ele: HTMLElement,\n autoFocus: AutoFocusOptions,\n isFirstScreen: boolean,\n) => {\n if (\n autoFocus === true ||\n (autoFocus === 'skipFirstScreen' && !isFirstScreen)\n ) {\n // focus the first visible input\n const firstVisibleInput: HTMLInputElement = ele.querySelector(\n FOCUSABLE_INPUTS_SELECTOR,\n );\n setTimeout(() => {\n firstVisibleInput?.focus();\n });\n }\n};\n\nexport const handleReportValidityOnBlur = (rootEle: HTMLElement) => {\n rootEle.querySelectorAll('*[name]').forEach((ele: HTMLInputElement) => {\n ele.addEventListener('blur', () => {\n const onBlur = () => {\n // reportValidity also focus the element if it's invalid\n // in order to prevent this we need to override the focus method\n const origFocus = ele.focus;\n // eslint-disable-next-line no-param-reassign\n ele.focus = () => {};\n ele.reportValidity?.();\n setTimeout(() => {\n // eslint-disable-next-line no-param-reassign\n ele.focus = origFocus;\n });\n };\n\n const isInputAlreadyInErrorState = ele.getAttribute('invalid') === 'true';\n\n if (isInputAlreadyInErrorState || ele.value?.length) {\n onBlur();\n return;\n }\n\n // If the input is not in an error state, has no value, and a `formnovalidate` button was clicked,\n // we want to prevent triggering validation.\n // This handles a case where a required input was focused, and the user then clicked a social login button —\n // in that case, we don't want the required error message to flash for a split second.\n const ref = { timer: undefined };\n\n const onClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n if (target.getAttribute('formnovalidate') === 'true') {\n clearTimeout(ref.timer);\n ref.timer = undefined;\n }\n };\n\n ref.timer = setTimeout(() => {\n rootEle.removeEventListener('click', onClick);\n onBlur();\n ref.timer = undefined;\n }, 150);\n\n rootEle.addEventListener('click', onClick, { once: true });\n });\n });\n};\n\n/**\n * To return a fallback value in case the timeout expires and the promise\n * isn't fulfilled:\n *\n * const promise = loadUserCount();\n * const count = await timeoutPromise(2000, promise, 0);\n *\n * Or without a fallback value to just throw an error if the timeout expires:\n *\n * try {\n * count = await timeoutPromise(2000, promise);\n * }\n *\n * Fallback is returned only in case of timeout, so if the passed promise rejects\n * the fallback value is not used, and the returned promise will throw as well.\n */\nexport function timeoutPromise<T>(\n timeout: number,\n promise: Promise<T>,\n fallback?: T,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n let expired = false;\n const timer = setTimeout(() => {\n expired = true;\n if (fallback !== undefined) {\n resolve(fallback);\n } else {\n reject(new Error(`Promise timed out after ${timeout} ms`));\n }\n }, timeout);\n\n promise\n .then((value) => {\n if (!expired) {\n clearTimeout(timer);\n resolve(value);\n }\n })\n .catch((error) => {\n if (!expired) {\n clearTimeout(timer);\n reject(error);\n }\n });\n });\n}\n\nexport const getChromiumVersion = (): number => {\n const brands = (navigator as any)?.userAgentData?.brands;\n const found = brands?.find(\n ({ brand, version }) => brand === 'Chromium' && parseFloat(version),\n );\n return found ? found.version : 0;\n};\n\n// As an optimization - We can show first screen if we have startScreenId and we don't have any other of the ssoAppId/oidcIdpStateId/samlIdp params\n// - If there startScreenId it means that the sdk can show the first screen and we don't need to wait for the sdk to return the first screen\n// - If there is any one else of the other params (like oidcIdpStateId, ..) - we can't skip this call because descope may decide not to show the first screen (in cases like a user is already logged in)\nexport const showFirstScreenOnExecutionInit = (\n startScreenId: string,\n {\n oidcIdpStateId,\n samlIdpStateId,\n samlIdpUsername,\n ssoAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n }: SSOQueryParams,\n): boolean =>\n !!startScreenId &&\n !oidcIdpStateId &&\n !samlIdpStateId &&\n !samlIdpUsername &&\n !ssoAppId &&\n !oidcLoginHint &&\n !oidcPrompt &&\n !oidcErrorRedirectUri &&\n !oidcResource &&\n !thirdPartyAppId &&\n !thirdPartyAppStateId &&\n !applicationScopes;\n\nexport const injectSamlIdpForm = (\n url: string,\n samlResponse: string,\n relayState: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n formEle.innerHTML = `\n <input type=\"hidden\" role=\"saml-response\" name=\"SAMLResponse\" value=\"${samlResponse}\" />\n <input type=\"hidden\" role=\"saml-relay-state\" name=\"RelayState\" value=\"${relayState}\" />\n <input style=\"display: none;\" id=\"SAMLSubmitButton\" type=\"submit\" value=\"Continue\" />\n `;\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const submitForm = (formEle: HTMLFormElement) => formEle?.submit();\n\nexport const getFirstNonEmptyValue = (obj: object, keys: string[]) => {\n const firstNonEmptyKey = keys.find((key) => obj[key]);\n return firstNonEmptyKey ? obj[firstNonEmptyKey] : null;\n};\n\nexport const leadingDebounce = <T extends (...args: any[]) => void>(\n func: T,\n wait = 100,\n) => {\n let timeout: NodeJS.Timeout;\n return function executedFunction(...args) {\n if (!timeout) func.apply(this, args);\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n timeout = null;\n }, wait);\n } as T;\n};\n\nexport function getUserLocale(locale: string): Locale {\n if (locale) {\n return { locale: locale.toLowerCase(), fallback: locale.toLowerCase() };\n }\n const nl = navigator.language;\n if (!nl) {\n return { locale: '', fallback: '' };\n }\n\n if (nl.includes('-')) {\n return {\n locale: nl.toLowerCase(),\n fallback: nl.split('-')[0].toLowerCase(),\n };\n }\n\n return { locale: nl.toLowerCase(), fallback: nl.toLowerCase() };\n}\n\nexport const clearPreviousExternalInputs = () => {\n document\n .querySelectorAll('[data-hidden-input=\"true\"]')\n .forEach((ele) => ele.remove());\n};\n\nexport const shouldHandleMarkdown = (compName: string) =>\n MD_COMPONENTS.includes(compName);\n\nconst omitBy = <T extends Record<string, any>>(\n obj: T,\n predicate: (value: any, key: keyof T) => boolean,\n): T =>\n Object.fromEntries(\n Object.entries(obj).filter(\n ([key, value]) => !predicate(value, key as keyof T),\n ),\n ) as T;\n\nexport const transformStepStateForCustomScreen = (\n state: Partial<StepState>,\n) => {\n const sanitizedState: CustomScreenState = omitBy(\n state.screenState,\n (_, key) => EXCLUDED_STATE_KEYS.includes(key) || key.startsWith('_'),\n );\n\n const {\n screenState: { errorText, errorType },\n } = state;\n\n if (errorText || errorType) {\n sanitizedState.error = { text: errorText, type: errorType };\n }\n\n if (state.action) {\n sanitizedState.action = state.action;\n }\n\n if (state.screenState?.componentsConfig?.thirdPartyAppApproveScopes?.data) {\n sanitizedState.inboundAppApproveScopes =\n state.screenState.componentsConfig.thirdPartyAppApproveScopes.data;\n }\n\n return sanitizedState;\n};\n\nexport const transformScreenInputs = (inputs: Record<string, any>) => {\n const res = { ...inputs };\n\n if (inputs.inboundAppApproveScopes) {\n res.thirdPartyAppApproveScopes = inputs.inboundAppApproveScopes;\n }\n\n return res;\n};\n\nexport function getScriptResultPath(scriptId: string, resultKey?: string) {\n const path = resultKey ? `${scriptId}_${resultKey}` : scriptId;\n return `${SDK_SCRIPT_RESULTS_KEY}.${path}`;\n}\n\nexport const openCenteredPopup = (\n url: string,\n title: string,\n w: number,\n h: number,\n) => {\n const dualScreenLeft =\n window.screenLeft !== undefined\n ? window.screenLeft\n : (window.screen as any).left;\n const dualScreenTop =\n window.screenTop !== undefined\n ? window.screenTop\n : (window.screen as any).top;\n\n const width =\n window.innerWidth ||\n document.documentElement.clientWidth ||\n window.screen.width;\n const height =\n window.innerHeight ||\n document.documentElement.clientHeight ||\n window.screen.height;\n\n const left = (width - w) / 2 + dualScreenLeft;\n const top = (height - h) / 2 + dualScreenTop;\n\n // Safari on Mac may detect authentication URLs and replace the popup with a native macOS auth dialog.\n // To avoid that, we open the popup with empty string as URL and then populate it with the needed URL.\n // This avoids the native dialog, and uses the web interface for authentication.\n const initialUrl = isIphoneSafari() ? 'about:blank' : '';\n const popup = window.open(\n initialUrl,\n title,\n `width=${w},height=${h},top=${top},left=${left},scrollbars=yes,resizable=yes`,\n );\n\n popup.location.href = url;\n popup.focus();\n\n return popup;\n};\n"],"names":["MD_COMPONENTS","getUrlParam","paramName","URLSearchParams","window","location","search","get","resetUrlParam","history","replaceState","newUrl","URL","href","delete","toString","fetchContent","url","returnType","res","fetch","cache","ok","Error","status","body","headers","Object","fromEntries","entries","getContentUrl","projectId","filename","assetsFolder","ASSETS_FOLDER","baseUrl","OVERRIDE_CONTENT_URL","BASE_CONTENT_URL","pathname","paths","join","replace","pathJoin","getAnimationDirection","currentIdxStr","prevIdxStr","currentIdx","prevIdx","Number","isNaN","Direction","forward","backward","getRunIdsFromUrl","flowId","executionId","stepId","URL_RUN_IDS_PARAM_NAME","split","executionFlowId","_a","exec","getFlowIdFromExecId","isChromium","test","navigator","userAgent","vendor","clearRunIdsFromUrl","getTokenFromUrl","URL_TOKEN_PARAM_NAME","undefined","clearTokenFromUrl","getCodeFromUrl","URL_CODE_PARAM_NAME","getIsPopupFromUrl","URL_REDIRECT_MODE_PARAM_NAME","getExchangeErrorFromUrl","URL_ERR_PARAM_NAME","clearCodeFromUrl","clearIsPopupFromUrl","clearExchangeErrorFromUrl","getRedirectAuthFromUrl","redirectAuthCodeChallenge","URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME","redirectAuthCallbackUrl","URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME","redirectAuthBackupCallbackUri","URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME","redirectAuthInitiator","URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME","getOIDCIDPParamFromUrl","OIDC_IDP_STATE_ID_PARAM_NAME","clearOIDCIDPParamFromUrl","getSAMLIDPParamFromUrl","SAML_IDP_STATE_ID_PARAM_NAME","clearSAMLIDPParamFromUrl","getSAMLIDPUsernameParamFromUrl","SAML_IDP_USERNAME_PARAM_NAME","clearSAMLIDPUsernameParamFromUrl","getDescopeIDPInitiatedParamFromUrl","DESCOPE_IDP_INITIATED_PARAM_NAME","clearDescopeIDPInitiatedParamFromUrl","getSSOAppIdParamFromUrl","SSO_APP_ID_PARAM_NAME","getThirdPartyAppIdParamFromUrl","THIRD_PARTY_APP_ID_PARAM_NAME","clearSSOAppIdParamFromUrl","clearThirdPartyAppIdParamFromUrl","getThirdPartyAppStateIdParamFromUrl","THIRD_PARTY_APP_STATE_ID_PARAM_NAME","clearThirdPartyAppStateIdParamFromUrl","getApplicationScopesParamFromUrl","APPLICATION_SCOPES_PARAM_NAME","clearApplicationScopesParamFromUrl","getOIDCLoginHintParamFromUrl","OIDC_LOGIN_HINT_PARAM_NAME","clearOIDCLoginHintParamFromUrl","getOIDCPromptParamFromUrl","OIDC_PROMPT_PARAM_NAME","clearOIDCPromptParamFromUrl","getOIDCErrorRedirectUriParamFromUrl","OIDC_ERROR_REDIRECT_URI_PARAM_NAME","clearOIDCErrorRedirectUriParamFromUrl","getOIDCResourceParamFromUrl","OIDC_RESOURCE_PARAM_NAME","clearOIDCResourceParamFromUrl","camelCase","s","x","toUpperCase","createIsChanged","state","prevState","attrName","getElementDescopeAttributes","ele","Array","from","attributes","reduce","acc","attr","descopeAttrName","RegExp","DESCOPE_ATTRIBUTE_PREFIX","name","assign","value","handleUrlParams","logger","debug","ssoQueryParams","token","code","isPopup","exchangeError","oidcIdpStateId","samlIdpStateId","samlIdpUsername","descopeIdpInitiated","ssoAppId","thirdPartyAppId","thirdPartyAppStateId","applicationScopes","oidcLoginHint","oidcPrompt","oidcErrorRedirectUri","oidcResource","withMemCache","fn","prevArgs","args","array2","array1","length","every","index","reset","FOCUSABLE_INPUTS_SELECTOR","handleAutoFocus","autoFocus","isFirstScreen","firstVisibleInput","querySelector","setTimeout","focus","handleReportValidityOnBlur","rootEle","querySelectorAll","forEach","addEventListener","onBlur","origFocus","reportValidity","call","getAttribute","ref","timer","onClick","e","target","clearTimeout","removeEventListener","once","timeoutPromise","timeout","promise","fallback","Promise","resolve","reject","expired","then","catch","error","getChromiumVersion","brands","userAgentData","found","find","brand","version","parseFloat","showFirstScreenOnExecutionInit","startScreenId","injectSamlIdpForm","samlResponse","relayState","submitCallback","formEle","document","createElement","method","action","innerHTML","appendChild","submitForm","submit","getFirstNonEmptyValue","obj","keys","firstNonEmptyKey","key","leadingDebounce","func","wait","apply","this","getUserLocale","locale","toLowerCase","nl","language","includes","clearPreviousExternalInputs","remove","shouldHandleMarkdown","compName","transformStepStateForCustomScreen","sanitizedState","screenState","predicate","_","EXCLUDED_STATE_KEYS","startsWith","filter","errorText","errorType","text","type","_c","_b","componentsConfig","thirdPartyAppApproveScopes","data","inboundAppApproveScopes","transformScreenInputs","inputs","getScriptResultPath","scriptId","resultKey","SDK_SCRIPT_RESULTS_KEY","openCenteredPopup","title","w","h","dualScreenLeft","screenLeft","screen","left","dualScreenTop","screenTop","top","innerWidth","documentElement","clientWidth","width","innerHeight","clientHeight","height","initialUrl","ua","isIphone","isSafari","isIphoneSafari","popup","open"],"mappings":"yiCAsCA,MAAMA,EAAgB,CAAC,yBAEvB,SAASC,EAAYC,GAGnB,OAFkB,IAAIC,gBAAgBC,OAAOC,SAASC,QAErCC,IAAIL,EACvB,CAgBA,SAASM,EAAcN,GACrB,GAAIE,OAAOK,QAAQC,cAAgBT,EAAYC,GAAY,CACzD,MAAMS,EAAS,IAAIC,IAAIR,OAAOC,SAASQ,MACjCP,EAAS,IAAIH,gBAAgBQ,EAAOL,QAC1CA,EAAOQ,OAAOZ,GACdS,EAAOL,OAASA,EAAOS,WACvBX,OAAOK,QAAQC,aAAa,CAAA,EAAI,GAAIC,EAAOI,WAC5C,CACH,CAOsB,SAAAC,EACpBC,EACAC,4CAKA,MAAMC,QAAYC,MAAMH,EAAK,CAAEI,MAAO,YACtC,IAAKF,EAAIG,GACP,MAAMC,MAAM,sBAAsBN,MAAQE,EAAIK,WAGhD,MAAO,CACLC,WAAYN,EAAID,KAChBQ,QAASC,OAAOC,YAAYT,EAAIO,QAAQG,cAE3C,CAIe,SAAAC,GAAcC,UAC5BA,EAASC,SACTA,EAAQC,aACRA,EAAeC,EAAaC,QAC5BA,IAOA,MAAMlB,EAAM,IAAIL,IAAIwB,GAAwBD,GAAWE,G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C,EAAkBC,GAEpD,MAAO,GAAGC,KADGD,EAAY,GAAGD,KAAYC,IAAcD,GAExD,CAEO,MAAMG,GAAoB,CAC/B1Q,EACA2Q,EACAC,EACAC,KAEA,MAAMC,OACkBxN,IAAtBnE,OAAO4R,WACH5R,OAAO4R,WACN5R,OAAO6R,OAAeC,KACvBC,OACiB5N,IAArBnE,OAAOgS,UACHhS,OAAOgS,UACNhS,OAAO6R,OAAeI,IAWvBH,IARJ9R,OAAOkS,YACP/D,SAASgE,gBAAgBC,aACzBpS,OAAO6R,OAAOQ,OAMMZ,GAAK,EAAIE,EACzBM,IALJjS,OAAOsS,aACPnE,SAASgE,gBAAgBI,cACzBvS,OAAO6R,OAAOW,QAGMd,GAAK,EAAIK,EAKzBU,EA7pBR,WACE,MAAMC,EAAK7O,UAAUC,WAAa,GAC5B6O,EAAW,eAAe/O,KAAK8O,GAE/BE,EACJ,SAAShP,KAAK8O,KAAQ,2CAA2C9O,KAAK8O,GAExE,OAAOC,GAAYC,CACrB,CAqpBqBC,GAAmB,cAAgB,GAChDC,EAAQ9S,OAAO+S,KACnBN,EACAjB,EACA,SAASC,YAAYC,SAASO,UAAYH,kCAM5C,OAHAgB,EAAM7S,SAASQ,KAAOI,EACtBiS,EAAMxH,QAECwH,CAAK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -268,12 +268,12 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
268
268
|
readonly cssRules: CSSRuleList;
|
|
269
269
|
} | CSSStyleSheet;
|
|
270
270
|
nonce: string;
|
|
271
|
-
"__#
|
|
271
|
+
"__#32125@#setNonce"(): void;
|
|
272
272
|
init(): Promise<void>;
|
|
273
|
-
"__#
|
|
273
|
+
"__#32120@#observeMappings": {};
|
|
274
274
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
275
275
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
276
|
-
"__#
|
|
276
|
+
"__#32119@#isInit": boolean;
|
|
277
277
|
connectedCallback: (() => void) & (() => void) & (() => void);
|
|
278
278
|
accessKey: string;
|
|
279
279
|
readonly accessKeyLabel: string;
|
|
@@ -599,8 +599,8 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
599
599
|
tabIndex: number;
|
|
600
600
|
blur(): void;
|
|
601
601
|
focus(options?: FocusOptions): void;
|
|
602
|
-
"__#
|
|
603
|
-
"__#
|
|
602
|
+
"__#32118@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
603
|
+
"__#32118@#wrapLogger"(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
604
604
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
605
605
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
606
606
|
onLogEvent(logLevel: "error" | "warn" | "info" | "debug", data: any[]): void;
|
|
@@ -936,15 +936,15 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
936
936
|
focus(options?: FocusOptions): void;
|
|
937
937
|
};
|
|
938
938
|
} & (new (...params: any[]) => {
|
|
939
|
-
"__#
|
|
940
|
-
"__#
|
|
941
|
-
"__#
|
|
942
|
-
"__#
|
|
939
|
+
"__#32122@#lastBaseUrl"?: string;
|
|
940
|
+
"__#32122@#workingBaseUrl"?: string;
|
|
941
|
+
"__#32122@#failedUrls": Set<string>;
|
|
942
|
+
"__#32122@#getResourceUrls"(filename: string): (URL & {
|
|
943
943
|
baseUrl: string;
|
|
944
944
|
}) | (URL & {
|
|
945
945
|
baseUrl: string;
|
|
946
946
|
})[];
|
|
947
|
-
"__#
|
|
947
|
+
"__#32122@#createResourceUrl"(filename: string, baseUrl: string): URL & {
|
|
948
948
|
baseUrl: string;
|
|
949
949
|
};
|
|
950
950
|
fetchStaticResource<F extends "text" | "json">(filename: string, format: F): Promise<{
|
|
@@ -1280,34 +1280,34 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1280
1280
|
blur(): void;
|
|
1281
1281
|
focus(options?: FocusOptions): void;
|
|
1282
1282
|
readonly projectId: string;
|
|
1283
|
-
"__#
|
|
1283
|
+
"__#32121@#handleError"(attrName: string, newValue: string): void;
|
|
1284
1284
|
init(): Promise<void>;
|
|
1285
|
-
"__#
|
|
1285
|
+
"__#32120@#observeMappings": {};
|
|
1286
1286
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
1287
1287
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
1288
|
-
"__#
|
|
1289
|
-
"__#
|
|
1290
|
-
"__#
|
|
1288
|
+
"__#32119@#isInit": boolean;
|
|
1289
|
+
"__#32118@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1290
|
+
"__#32118@#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);
|
|
1291
1291
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1292
1292
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1293
1293
|
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);
|
|
1294
1294
|
}) & (new (...params: any[]) => {
|
|
1295
|
-
"__#
|
|
1295
|
+
"__#32134@#globalStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
|
|
1296
1296
|
readonly theme: _descope_sdk_mixins_static_resources_mixin.ThemeOptions;
|
|
1297
1297
|
readonly styleId: string;
|
|
1298
|
-
"__#
|
|
1299
|
-
"__#
|
|
1300
|
-
readonly "__#
|
|
1301
|
-
"__#
|
|
1302
|
-
"__#
|
|
1303
|
-
"__#
|
|
1298
|
+
"__#32134@#_themeResource": Promise<void | Record<string, any>>;
|
|
1299
|
+
"__#32134@#fetchTheme"(): Promise<Record<string, any>>;
|
|
1300
|
+
readonly "__#32134@#themeResource": Promise<void | Record<string, any>>;
|
|
1301
|
+
"__#32134@#loadGlobalStyle"(): Promise<void>;
|
|
1302
|
+
"__#32134@#loadComponentsStyle"(): Promise<void>;
|
|
1303
|
+
"__#32134@#getFontsConfig"(): Promise<Record<string, {
|
|
1304
1304
|
url?: string;
|
|
1305
1305
|
}>>;
|
|
1306
|
-
"__#
|
|
1307
|
-
"__#
|
|
1308
|
-
"__#
|
|
1309
|
-
"__#
|
|
1310
|
-
"__#
|
|
1306
|
+
"__#32134@#loadFonts"(): Promise<void>;
|
|
1307
|
+
"__#32134@#applyTheme"(): Promise<void>;
|
|
1308
|
+
"__#32134@#onThemeChange": () => void;
|
|
1309
|
+
"__#32134@#loadTheme"(): void;
|
|
1310
|
+
"__#32134@#toggleOsThemeChangeListener": (listen: boolean) => void;
|
|
1311
1311
|
init(): Promise<void>;
|
|
1312
1312
|
injectStyle: ((cssString: string, { prepend }?: {
|
|
1313
1313
|
prepend?: boolean;
|
|
@@ -1325,11 +1325,11 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1325
1325
|
readonly cssRules: CSSRuleList;
|
|
1326
1326
|
});
|
|
1327
1327
|
nonce: string;
|
|
1328
|
-
"__#
|
|
1329
|
-
"__#
|
|
1328
|
+
"__#32125@#setNonce": (() => void) & (() => void);
|
|
1329
|
+
"__#32120@#observeMappings": {};
|
|
1330
1330
|
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);
|
|
1331
1331
|
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);
|
|
1332
|
-
"__#
|
|
1332
|
+
"__#32119@#isInit": boolean;
|
|
1333
1333
|
connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
1334
1334
|
accessKey: string;
|
|
1335
1335
|
readonly accessKeyLabel: string;
|
|
@@ -1655,25 +1655,25 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1655
1655
|
tabIndex: number;
|
|
1656
1656
|
blur(): void;
|
|
1657
1657
|
focus(options?: FocusOptions): void;
|
|
1658
|
-
"__#
|
|
1659
|
-
"__#
|
|
1658
|
+
"__#32118@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1659
|
+
"__#32118@#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);
|
|
1660
1660
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1661
1661
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1662
1662
|
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);
|
|
1663
1663
|
contentRootElement: HTMLElement;
|
|
1664
1664
|
rootElement: HTMLElement;
|
|
1665
1665
|
readonly config: Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1666
|
-
"__#
|
|
1667
|
-
"__#
|
|
1668
|
-
"__#
|
|
1669
|
-
"__#
|
|
1666
|
+
"__#32124@#configCacheClear": (() => void) & (() => void);
|
|
1667
|
+
"__#32124@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1668
|
+
"__#32124@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
|
|
1669
|
+
"__#32123@#callbacks": Map<string, () => void> & Map<string, () => void>;
|
|
1670
1670
|
onReset: ((sectionId: string, callback: () => void | Promise<void>) => () => void) & ((sectionId: string, callback: () => void | Promise<void>) => () => void);
|
|
1671
1671
|
reset: ((...sectionIds: string[]) => Promise<void>) & ((...sectionIds: string[]) => Promise<void>);
|
|
1672
|
-
"__#
|
|
1673
|
-
"__#
|
|
1674
|
-
"__#
|
|
1675
|
-
"__#
|
|
1676
|
-
"__#
|
|
1672
|
+
"__#32121@#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);
|
|
1673
|
+
"__#32122@#lastBaseUrl"?: string;
|
|
1674
|
+
"__#32122@#workingBaseUrl"?: string;
|
|
1675
|
+
"__#32122@#failedUrls": Set<string>;
|
|
1676
|
+
"__#32122@#getResourceUrls": ((filename: string) => (URL & {
|
|
1677
1677
|
baseUrl: string;
|
|
1678
1678
|
}) | (URL & {
|
|
1679
1679
|
baseUrl: string;
|
|
@@ -1686,7 +1686,7 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1686
1686
|
}) | (URL & {
|
|
1687
1687
|
baseUrl: string;
|
|
1688
1688
|
})[]);
|
|
1689
|
-
"__#
|
|
1689
|
+
"__#32122@#createResourceUrl": ((filename: string, baseUrl: string) => URL & {
|
|
1690
1690
|
baseUrl: string;
|
|
1691
1691
|
}) & ((filename: string, baseUrl: string) => URL & {
|
|
1692
1692
|
baseUrl: string;
|
|
@@ -1706,11 +1706,11 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1706
1706
|
readonly baseStaticUrl: string;
|
|
1707
1707
|
readonly baseUrl: string;
|
|
1708
1708
|
readonly projectId: string;
|
|
1709
|
-
"__#
|
|
1710
|
-
"__#
|
|
1709
|
+
"__#32128@#getComponentsVersion"(): Promise<string>;
|
|
1710
|
+
"__#32128@#descopeUi": Promise<any>;
|
|
1711
1711
|
readonly descopeUi: Promise<any>;
|
|
1712
|
-
"__#
|
|
1713
|
-
"__#
|
|
1712
|
+
"__#32128@#loadDescopeUiComponent"(componentName: string): Promise<any>;
|
|
1713
|
+
"__#32128@#getDescopeUi"(): Promise<any>;
|
|
1714
1714
|
loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
|
|
1715
1715
|
readonly baseCdnUrl: string;
|
|
1716
1716
|
injectNpmLib(libName: string, version: string, filePath?: string, overrides?: string[]): Promise<{
|