@descope/web-component 4.7.4 → 4.8.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/constants/index.js +1 -1
- package/dist/cjs/constants/index.js.map +1 -1
- package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/cjs/descope-wc/DescopeWc.js +1 -1
- package/dist/cjs/descope-wc/DescopeWc.js.map +1 -1
- package/dist/cjs/helpers/templates.js +1 -1
- package/dist/cjs/helpers/templates.js.map +1 -1
- package/dist/esm/constants/index.js +1 -1
- package/dist/esm/constants/index.js.map +1 -1
- package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/esm/descope-wc/DescopeWc.js +1 -1
- package/dist/esm/descope-wc/DescopeWc.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 +1 -1
- package/dist/index.js +2 -2
- package/package.json +4 -4
|
@@ -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),u=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,c)=>r?t(a(o,c)):a(o,c))),d=(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})`))},m=(t,o,c,l)=>{var i,a;d(t,"totp-link",null===(i=null==o?void 0:o.totp)||void 0===i?void 0:i.provisionUrl),d(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=u(e.textContent,t,o);const r=e.getAttribute("href");r&&e.setAttribute("href",u(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=u(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)},h=(e,t)=>{i(e,null==t?void 0:t.inputs),i(e,null==t?void 0:t.form)},y=(e,t)=>{p(e,"descope-totp-image",t)},b=(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,b as setNOTPVariable,y as setTOTPVariable,h as updateScreenFromScreenState,m as updateTemplateFromScreenState};
|
|
1
|
+
import{__rest as e}from"tslib";import{escapeMarkdown as t}from"@descope/escape-markdown";import{ELEMENT_TYPE_ATTRIBUTE as o,HAS_DYNAMIC_VALUES_ATTR_NAME as r,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as c}from"../constants/index.js";import{shouldHandleMarkdown as n}from"./helpers.js";const s=["disabled"],l=(e,t,r="")=>{e.querySelectorAll(`[${o}="${t}"]`).forEach((e=>{e.textContent=r,e.classList[r?"remove":"add"]("hide")}))},i=(e,t)=>{Object.entries(t||{}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${c}])`)).forEach((e=>{e.value=o}))}))},a=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),u=(e,o,r)=>e.replace(/{{(.+?)}}/g,((e,c)=>r?t(String(a(o,c))):a(o,c))),d=(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})`))},m=(t,o,c,l)=>{var i,a;d(t,"totp-link",null===(i=null==o?void 0:o.totp)||void 0===i?void 0:i.provisionUrl),d(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=u(e.textContent,t,o);const r=e.getAttribute("href");r&&e.setAttribute("href",u(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=u(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)},h=(e,t)=>{i(e,null==t?void 0:t.inputs),i(e,null==t?void 0:t.form)},y=(e,t)=>{p(e,"descope-totp-image",t)},b=(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,b as setNOTPVariable,y as setTOTPVariable,h as updateScreenFromScreenState,m 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\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 *\n * Note: applying `screenState.componentsState` (the server-applied baseline\n * hide/disable/read-only map) is owned by the `componentConditionsMixin`. The\n * host calls `this.applyComponentsState(...)` after this function returns and\n * before the fragment is mounted.\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};\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","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,CAAA,GAAIL,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,MA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iBAC/B,kBAAkBC,mBAEJC,SAASgH,GAAWA,EAAOhF,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(String(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\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 *\n * Note: applying `screenState.componentsState` (the server-applied baseline\n * hide/disable/read-only map) is owned by the `componentConditionsMixin`. The\n * host calls `this.applyComponentsState(...)` after this function returns and\n * before the fragment is mounted.\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};\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","String","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","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,CAAA,GAAIL,SAAQ,EAAEQ,EAAMC,MAChCC,MAAMC,KACrBhB,EAAQG,iBACN,WAAWU,YAAeI,QAGrBZ,SAASa,IAEhBA,EAASJ,MAAQA,CAAK,GACtB,GACF,EASEK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AIA,EACF,IACE,MAAOE,GAAaC,KAAKC,oBAAoBJ,GACzCE,IACFD,EAAkBC,EAEtB,CAAE,MAAA3D,GAEF,CAGF3C,OAAOC,QAjBQ,CAEbwG,KAAM,eAee/G,SAAQ,EAAEwG,EAAK/F,MACpCC,MAAMC,KAAK2F,EAASxG,iBAAiB,IAAI0G,MAAQ/F,QAAYT,SAC1DC,IACCA,EAAIgC,aAAauE,EAAKG,GAAmBlG,EAAM,GAElD,GACD,EAGSuG,EAA0BV,IACbA,EAASxG,iBAC/B,kBAAkBC,mBAEJC,SAASiH,GAAWA,EAAOhF,aAAa,WAAY,SAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4510,7 +4510,7 @@ declare class DescopeWc extends BaseDescopeWc {
|
|
|
4510
4510
|
* @returns Array of script modules that can be refreshed before form submission
|
|
4511
4511
|
*/
|
|
4512
4512
|
loadSdkScriptsModules(): ScriptModule[];
|
|
4513
|
-
loadSdkScripts(
|
|
4513
|
+
loadSdkScripts(requestedScripts: ClientScript[]): Promise<unknown>;
|
|
4514
4514
|
get isDismissScreenErrorOnInput(): boolean;
|
|
4515
4515
|
init(): Promise<void>;
|
|
4516
4516
|
_init(): Promise<void>;
|