@descope/flow-components 3.27.6 → 3.27.8

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.6",
8
+ "buildVersion": "3.27.8",
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.6",
8
+ "buildVersion": "3.27.8",
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.
@@ -84428,9 +84453,12 @@ function requireIndex_cjs () {
84428
84453
  }
84429
84454
 
84430
84455
  #renderItem = ({ displayName, value, label }) => {
84431
- return `<span data-name="${label}" data-id="${value}">${
84432
- displayName || label
84433
- }</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;
84434
84462
  };
84435
84463
 
84436
84464
  #data;
@@ -86009,24 +86037,45 @@ function requireIndex_cjs () {
86009
86037
 
86010
86038
  const componentName$1k = getComponentName('apps-list');
86011
86039
 
86012
- const itemRenderer$6 = ({ name, icon, url }, _, ref) => `
86013
- <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"'}>
86014
86045
  <descope-list-item>
86015
86046
  <div class="avatar-wrapper">
86016
86047
  <descope-avatar
86017
- ${icon ? `img="${icon}"` : ''}
86018
- ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
86019
86048
  size="${ref.logoSize || ref.size}"
86020
86049
  ></descope-avatar>
86021
86050
  </div>
86022
86051
  <descope-text
86023
86052
  variant="${ref.itemTextVariant}"
86024
86053
  mode="primary"
86025
- >${name}</descope-text>
86054
+ ></descope-text>
86026
86055
  </descope-list-item>
86027
86056
  </a>
86028
86057
  `;
86029
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
+
86030
86079
  const customMixin$g = (superclass) =>
86031
86080
  class AppsListMixinClass extends superclass {
86032
86081
  // size controls both item logo size and font size
@@ -90583,13 +90632,12 @@ function requireIndex_cjs () {
90583
90632
  ref,
90584
90633
  ) => {
90585
90634
  const action = isConnected ? 'disconnect' : 'connect';
90586
- 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 = `
90587
90638
  <descope-list-item>
90588
90639
  <descope-avatar
90589
- ${logo ? `img="${logo}"` : ''}
90590
- ${name ? `display-name="${name}" abbr=${limitAbbreviation(name)}` : ''}
90591
90640
  size=${ref.size}
90592
- ${logo ? 'st-avatar-background-color="none"' : ''}
90593
90641
  class="app-logo"
90594
90642
  ></descope-avatar>
90595
90643
 
@@ -90598,7 +90646,7 @@ function requireIndex_cjs () {
90598
90646
  class="app-title"
90599
90647
  variant="subtitle1"
90600
90648
  mode="primary"
90601
- >${name}</descope-text>
90649
+ ></descope-text>
90602
90650
  ${
90603
90651
  description
90604
90652
  ? `
@@ -90606,18 +90654,41 @@ function requireIndex_cjs () {
90606
90654
  class="app-description"
90607
90655
  variant="body2"
90608
90656
  mode="primary"
90609
- >${description}</descope-text>
90657
+ ></descope-text>
90610
90658
  `
90611
90659
  : ''
90612
90660
  }
90613
90661
  </div>
90614
90662
  <div class="controls">
90615
- <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}">
90616
90664
  ${isConnected ? ref.disconnectButtonLabel : ref.connectButtonLabel}
90617
90665
  </descope-button>
90618
90666
  </div>
90619
90667
  </descope-list-item>
90620
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;
90621
90692
  };
90622
90693
 
90623
90694
  const BaseClass$6 = createBaseClass$1({
@@ -106566,7 +106637,7 @@ descope-enriched-text {
106566
106637
  const escapeXML = (s) => {
106567
106638
  const dom = document.createElement('div');
106568
106639
  dom.textContent = s;
106569
- return dom.innerHTML;
106640
+ return dom.innerHTML.replace(/"/g, '&quot;');
106570
106641
  };
106571
106642
 
106572
106643
  const getValueType = (value) => {
@@ -106581,7 +106652,7 @@ descope-enriched-text {
106581
106652
  `<descope-code-snippet copy-button="true" lang="${lang}" class="row-details__value code">${escapeXML(value)}</descope-code-snippet>`;
106582
106653
 
106583
106654
  const renderText = (text) =>
106584
- `<div class="row-details__value text" title="${text}">${escapeXML(text)}</div>`;
106655
+ `<div class="row-details__value text" title="${escapeXML(text)}">${escapeXML(text)}</div>`;
106585
106656
  const renderJson = (value) => renderCodeSnippet(JSON.stringify(value, null, 2), 'json');
106586
106657
  const renderXml = (value) => renderCodeSnippet(value, 'xml');
106587
106658
 
@@ -106619,7 +106690,7 @@ descope-enriched-text {
106619
106690
  <div class="row-details">
106620
106691
  ${Object.entries(item)
106621
106692
  .map(([key, value]) => {
106622
- const label = itemLabelsMapping[key] || toTitle(key);
106693
+ const label = escapeXML(itemLabelsMapping[key] || toTitle(key));
106623
106694
  if (isCodeSnippetValue(value)) {
106624
106695
  return `<details class="row-details__item">
106625
106696
  <summary class="row-details__label">${label}</summary>
@@ -111461,20 +111532,26 @@ descope-enriched-text {
111461
111532
  const componentName$a = getComponentName$1('scopes-list');
111462
111533
  const variants = ['checkbox', 'switch'];
111463
111534
 
111535
+ // we return a template instead of a string, and fill the item data with DOM APIs, so we can avoid XSS
111464
111536
  const itemRenderer = ({ id, desc, required = false }, _, ref) => {
111465
111537
  const ComponentClass = ref.variant === 'checkbox' ? CheckboxClass : SwitchToggleClass;
111466
111538
 
111467
- return `
111539
+ const template = document.createElement('template');
111540
+ template.innerHTML = `
111468
111541
  <${ComponentClass.componentName}
111469
111542
  bordered="true"
111470
111543
  size=${ref.size}
111471
- label="${desc}"
111472
- data-id="${id}"
111473
- readonly="${required || ref.isReadOnly}"
111474
- required="${required}"
111475
111544
  checked="true"
111476
111545
  ></${ComponentClass.componentName}>
111477
111546
  `;
111547
+
111548
+ const item = template.content.firstElementChild;
111549
+ item.setAttribute('label', desc);
111550
+ item.setAttribute('data-id', id);
111551
+ item.setAttribute('readonly', `${required || ref.isReadOnly}`);
111552
+ item.setAttribute('required', `${required}`);
111553
+
111554
+ return template;
111478
111555
  };
111479
111556
 
111480
111557
  class RawScopesList extends createBaseClass({ componentName: componentName$a, baseSelector: 'div' }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.27.6",
3
+ "version": "3.27.8",
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.6"
101
+ "@descope/web-components-ui": "3.27.8"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">= 18"