@descope/flow-components 3.27.5 → 3.27.7

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.
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.27.5",
8
+ "buildVersion": "3.27.7",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.27.5",
8
+ "buildVersion": "3.27.7",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -79995,6 +79995,31 @@ function requireIndex_cjs () {
79995
79995
 
79996
79996
  const isFunction = (maybeFunc) => typeof maybeFunc === 'function';
79997
79997
 
79998
+ const BLOCKED_URL_PROTOCOLS = ['javascript:', 'vbscript:', 'file:'];
79999
+ // A fixed base, so only an explicit scheme is checked (a relative URL on a file:// page is kept)
80000
+ const URL_CHECK_BASE = 'https://base.invalid';
80001
+
80002
+ // Returns the url when it is safe to use as a link or image source, otherwise ''.
80003
+ // A block-list (not an allow-list), so custom schemes (myapp://, mailto:) keep working.
80004
+ // The result must only be set with setAttribute, never put inside an HTML string.
80005
+ const getSafeUrl = (url, { allowDataImage = false } = {}) => {
80006
+ if (typeof url !== 'string' || !url) return '';
80007
+
80008
+ try {
80009
+ // eslint-disable-next-line no-undef
80010
+ const { protocol } = new URL(url, URL_CHECK_BASE);
80011
+
80012
+ if (BLOCKED_URL_PROTOCOLS.includes(protocol)) return '';
80013
+ if (protocol === 'data:') {
80014
+ return allowDataImage && /^\s*data:image\//i.test(url) ? url : '';
80015
+ }
80016
+
80017
+ return url;
80018
+ } catch {
80019
+ return '';
80020
+ }
80021
+ };
80022
+
79998
80023
  /**
79999
80024
  * Compares two arrays unorderedly.
80000
80025
  * @param {Array} arr1 - The first array to compare.
@@ -83983,6 +84008,16 @@ function requireIndex_cjs () {
83983
84008
 
83984
84009
  const componentName$1s = getComponentName('enriched-text');
83985
84010
 
84011
+ const sanitizeConfig = {
84012
+ ADD_ATTR: ['target'],
84013
+ // Same scheme rule as markdown-it's link check, so custom-scheme links
84014
+ // (myapp://, slack://) keep working; DOMPurify's default list strips them.
84015
+ // `i` because markdown-it lowercases the URL before testing and DOMPurify does not.
84016
+ ALLOWED_URI_REGEXP:
84017
+ /^(?!(?:vbscript|javascript|file|data):)|^data:image\/(?:gif|png|jpeg|webp);/i,
84018
+ FORBID_TAGS: ['form', 'input', 'button', 'textarea', 'select', 'style'],
84019
+ };
84020
+
83986
84021
  class EnrichedText extends createBaseClass$1({
83987
84022
  componentName: componentName$1s,
83988
84023
  baseSelector: ':host > div',
@@ -84178,8 +84213,10 @@ function requireIndex_cjs () {
84178
84213
  console.warn('Not parsing invalid markdown token');
84179
84214
  }
84180
84215
 
84216
+ html = DOMPurify.sanitize(html, sanitizeConfig);
84217
+
84181
84218
  this.contentNode.innerHTML = html;
84182
- this.contentNode.firstChild?.setAttribute('part', 'content');
84219
+ this.contentNode.firstElementChild?.setAttribute('part', 'content');
84183
84220
  }
84184
84221
 
84185
84222
  onReadOnlyChange(isReadOnly) {
@@ -84416,9 +84453,12 @@ function requireIndex_cjs () {
84416
84453
  }
84417
84454
 
84418
84455
  #renderItem = ({ displayName, value, label }) => {
84419
- return `<span data-name="${label}" data-id="${value}">${
84420
- displayName || label
84421
- }</span>`;
84456
+ const ele = document.createElement('span');
84457
+ ele.setAttribute('data-name', label);
84458
+ ele.setAttribute('data-id', value);
84459
+ ele.textContent = displayName || label;
84460
+
84461
+ return ele.outerHTML;
84422
84462
  };
84423
84463
 
84424
84464
  #data;
@@ -85997,24 +86037,45 @@ function requireIndex_cjs () {
85997
86037
 
85998
86038
  const componentName$1k = getComponentName('apps-list');
85999
86039
 
86000
- const itemRenderer$6 = ({ name, icon, url }, _, ref) => `
86001
- <a ${url ? `href="${url}" title="${url}"` : ''} ${ref.openInSameWindow ? '' : 'target="_blank"'}>
86040
+ // we return a template instead of a string, and fill the item data with DOM APIs, so we can avoid XSS
86041
+ const itemRenderer$6 = ({ name, icon, url }, _, ref) => {
86042
+ const template = document.createElement('template');
86043
+ template.innerHTML = `
86044
+ <a ${ref.openInSameWindow ? '' : 'target="_blank"'}>
86002
86045
  <descope-list-item>
86003
86046
  <div class="avatar-wrapper">
86004
86047
  <descope-avatar
86005
- ${icon ? `img="${icon}"` : ''}
86006
- ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
86007
86048
  size="${ref.logoSize || ref.size}"
86008
86049
  ></descope-avatar>
86009
86050
  </div>
86010
86051
  <descope-text
86011
86052
  variant="${ref.itemTextVariant}"
86012
86053
  mode="primary"
86013
- >${name}</descope-text>
86054
+ ></descope-text>
86014
86055
  </descope-list-item>
86015
86056
  </a>
86016
86057
  `;
86017
86058
 
86059
+ const link = template.content.querySelector('a');
86060
+ const safeUrl = getSafeUrl(url);
86061
+ if (safeUrl) {
86062
+ link.setAttribute('href', safeUrl);
86063
+ link.setAttribute('title', safeUrl);
86064
+ }
86065
+
86066
+ const avatar = template.content.querySelector('descope-avatar');
86067
+ const safeIcon = getSafeUrl(icon, { allowDataImage: true });
86068
+ if (safeIcon) avatar.setAttribute('img', safeIcon);
86069
+ if (name) {
86070
+ avatar.setAttribute('display-name', name);
86071
+ avatar.setAttribute('abbr', limitAbbreviation(name));
86072
+ }
86073
+
86074
+ template.content.querySelector('descope-text').textContent = name ?? '';
86075
+
86076
+ return template;
86077
+ };
86078
+
86018
86079
  const customMixin$g = (superclass) =>
86019
86080
  class AppsListMixinClass extends superclass {
86020
86081
  // size controls both item logo size and font size
@@ -90571,13 +90632,12 @@ function requireIndex_cjs () {
90571
90632
  ref,
90572
90633
  ) => {
90573
90634
  const action = isConnected ? 'disconnect' : 'connect';
90574
- return `
90635
+ // we return a template instead of a string, and fill the item data with DOM APIs, so we can avoid XSS
90636
+ const template = document.createElement('template');
90637
+ template.innerHTML = `
90575
90638
  <descope-list-item>
90576
90639
  <descope-avatar
90577
- ${logo ? `img="${logo}"` : ''}
90578
- ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
90579
90640
  size=${ref.size}
90580
- ${logo ? 'st-avatar-background-color="none"' : ''}
90581
90641
  class="app-logo"
90582
90642
  ></descope-avatar>
90583
90643
 
@@ -90586,7 +90646,7 @@ function requireIndex_cjs () {
90586
90646
  class="app-title"
90587
90647
  variant="subtitle1"
90588
90648
  mode="primary"
90589
- >${name}</descope-text>
90649
+ ></descope-text>
90590
90650
  ${
90591
90651
  description
90592
90652
  ? `
@@ -90594,18 +90654,41 @@ function requireIndex_cjs () {
90594
90654
  class="app-description"
90595
90655
  variant="body2"
90596
90656
  mode="primary"
90597
- >${description}</descope-text>
90657
+ ></descope-text>
90598
90658
  `
90599
90659
  : ''
90600
90660
  }
90601
90661
  </div>
90602
90662
  <div class="controls">
90603
- <descope-button variant="link" mode="primary" size=${ref.size} data-action="${action}" data-outbound-app-id="${appId}" data-id="${action}">
90663
+ <descope-button variant="link" mode="primary" size=${ref.size} data-action="${action}" data-id="${action}">
90604
90664
  ${isConnected ? ref.disconnectButtonLabel : ref.connectButtonLabel}
90605
90665
  </descope-button>
90606
90666
  </div>
90607
90667
  </descope-list-item>
90608
90668
  `;
90669
+
90670
+ const avatar = template.content.querySelector('descope-avatar');
90671
+ const safeLogo = getSafeUrl(logo, { allowDataImage: true });
90672
+ if (safeLogo) {
90673
+ avatar.setAttribute('img', safeLogo);
90674
+ avatar.setAttribute('st-avatar-background-color', 'none');
90675
+ }
90676
+ if (name) {
90677
+ avatar.setAttribute('display-name', name);
90678
+ avatar.setAttribute('abbr', limitAbbreviation(name));
90679
+ }
90680
+
90681
+ template.content.querySelector('.app-title').textContent = name ?? '';
90682
+ if (description) {
90683
+ template.content.querySelector('.app-description').textContent =
90684
+ description;
90685
+ }
90686
+
90687
+ template.content
90688
+ .querySelector('descope-button')
90689
+ .setAttribute('data-outbound-app-id', appId);
90690
+
90691
+ return template;
90609
90692
  };
90610
90693
 
90611
90694
  const BaseClass$6 = createBaseClass$1({
@@ -106554,7 +106637,7 @@ descope-enriched-text {
106554
106637
  const escapeXML = (s) => {
106555
106638
  const dom = document.createElement('div');
106556
106639
  dom.textContent = s;
106557
- return dom.innerHTML;
106640
+ return dom.innerHTML.replace(/"/g, '&quot;');
106558
106641
  };
106559
106642
 
106560
106643
  const getValueType = (value) => {
@@ -106569,7 +106652,7 @@ descope-enriched-text {
106569
106652
  `<descope-code-snippet copy-button="true" lang="${lang}" class="row-details__value code">${escapeXML(value)}</descope-code-snippet>`;
106570
106653
 
106571
106654
  const renderText = (text) =>
106572
- `<div class="row-details__value text" title="${text}">${escapeXML(text)}</div>`;
106655
+ `<div class="row-details__value text" title="${escapeXML(text)}">${escapeXML(text)}</div>`;
106573
106656
  const renderJson = (value) => renderCodeSnippet(JSON.stringify(value, null, 2), 'json');
106574
106657
  const renderXml = (value) => renderCodeSnippet(value, 'xml');
106575
106658
 
@@ -106607,7 +106690,7 @@ descope-enriched-text {
106607
106690
  <div class="row-details">
106608
106691
  ${Object.entries(item)
106609
106692
  .map(([key, value]) => {
106610
- const label = itemLabelsMapping[key] || toTitle(key);
106693
+ const label = escapeXML(itemLabelsMapping[key] || toTitle(key));
106611
106694
  if (isCodeSnippetValue(value)) {
106612
106695
  return `<details class="row-details__item">
106613
106696
  <summary class="row-details__label">${label}</summary>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.27.5",
3
+ "version": "3.27.7",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -98,7 +98,7 @@
98
98
  "webpack-subresource-integrity": "5.2.0-rc.1"
99
99
  },
100
100
  "dependencies": {
101
- "@descope/web-components-ui": "3.27.5"
101
+ "@descope/web-components-ui": "3.27.7"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">= 18"