@descope/web-components-ui 3.9.1 → 3.10.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/index.esm.js CHANGED
@@ -12443,6 +12443,8 @@ const overrideAttrs = [
12443
12443
  'data-password-policy-value-minlength',
12444
12444
  'data-password-policy-value-passwordstrength',
12445
12445
  'data-password-policy-actual-passwordstrength',
12446
+ 'data-password-policy-value-disallowedchars',
12447
+ 'data-password-policy-value-email',
12446
12448
  ];
12447
12449
  const dataAttrs = ['data', 'active-policies', 'overrides', ...overrideAttrs];
12448
12450
  const policyAttrs = ['label', 'value', ...dataAttrs];
@@ -12561,6 +12563,46 @@ class RawPolicyValidation extends createBaseClass({ componentName: componentName
12561
12563
  };
12562
12564
  }
12563
12565
  }
12566
+
12567
+ // disallowedchars: this stores the configured char list in
12568
+ // overrides.disallowedchars.value so the message can interpolate
12569
+ // `{{value}}`. The regex pattern itself is built upstream (orchestrator
12570
+ // or caller) and shipped on the policy entry — it is not derived from
12571
+ // this override. When the attribute is cleared, drop the override so
12572
+ // the panel doesn't keep stale data.
12573
+ if (attrName === 'data-password-policy-value-disallowedchars') {
12574
+ if (newValue) {
12575
+ this.#overrides = {
12576
+ ...this.#overrides,
12577
+ disallowedchars: {
12578
+ ...this.#overrides?.disallowedchars,
12579
+ value: newValue,
12580
+ },
12581
+ };
12582
+ } else if (this.#overrides?.disallowedchars) {
12583
+ const { disallowedchars: _drop, ...rest } = this.#overrides;
12584
+ this.#overrides = rest;
12585
+ }
12586
+ }
12587
+
12588
+ // disallowemail: stash the user's email so the STR_NEQ_CI comparator
12589
+ // has an `expected` to compare against the live password value. Clear
12590
+ // the override when the attribute is removed/empty so we don't keep
12591
+ // blocking against a previous user's email.
12592
+ if (attrName === 'data-password-policy-value-email') {
12593
+ if (newValue) {
12594
+ this.#overrides = {
12595
+ ...this.#overrides,
12596
+ disallowemail: {
12597
+ ...this.#overrides?.disallowemail,
12598
+ expected: newValue,
12599
+ },
12600
+ };
12601
+ } else if (this.#overrides?.disallowemail) {
12602
+ const { disallowemail: _drop, ...rest } = this.#overrides;
12603
+ this.#overrides = rest;
12604
+ }
12605
+ }
12564
12606
  }
12565
12607
 
12566
12608
  this.renderItems(this.#availablePolicies, this.#activePolicies, this.#overrides);
@@ -12625,6 +12667,7 @@ class RawPolicyValidation extends createBaseClass({ componentName: componentName
12625
12667
  }
12626
12668
 
12627
12669
  const { pattern, message, data, compare } = policy;
12670
+ const normalizedCompare = typeof compare === 'string' ? compare.toUpperCase() : compare;
12628
12671
 
12629
12672
  if ((!pattern && !compare) || !message) {
12630
12673
  return results;
@@ -12638,9 +12681,23 @@ class RawPolicyValidation extends createBaseClass({ componentName: componentName
12638
12681
  if (pattern) {
12639
12682
  const exp = new RegExp(interpolateString(pattern, data));
12640
12683
  validationResult.valid = exp.test(this.value);
12684
+ } else if (normalizedCompare === 'STR_NEQ_CI') {
12685
+ // Compare the live password against the configured string AND its
12686
+ // local-part (before '@'), case-insensitively. Used by the
12687
+ // disallowemail policy.
12688
+ const expected = (data?.expected ?? '').toLowerCase();
12689
+ const actual = (this.value ?? '').toLowerCase();
12690
+ if (!expected || !actual) {
12691
+ // nothing to compare → mark valid so we don't block the flow
12692
+ validationResult.valid = true;
12693
+ } else {
12694
+ const at = expected.indexOf('@');
12695
+ const localPart = at > 0 ? expected.slice(0, at) : expected;
12696
+ validationResult.valid = actual !== expected && actual !== localPart;
12697
+ }
12641
12698
  } else if (compare) {
12642
12699
  validationResult.valid = this.compareValues(
12643
- compare,
12700
+ normalizedCompare,
12644
12701
  data?.expected ?? -1,
12645
12702
  data?.actual ?? -1
12646
12703
  );
@@ -12656,13 +12713,18 @@ class RawPolicyValidation extends createBaseClass({ componentName: componentName
12656
12713
  return !this.validate().some(({ valid }) => valid === false);
12657
12714
  }
12658
12715
 
12659
- getValidationItemTemplate({ valid, message }) {
12716
+ buildValidationItem({ valid, message }) {
12660
12717
  const status = !this.value ? 'none' : valid;
12661
- return `
12662
- <li class="item" data-valid="${status}">
12663
- <span class="message">${message}</span>
12664
- </li>
12665
- `;
12718
+ const li = document.createElement('li');
12719
+ li.className = 'item';
12720
+ li.dataset.valid = status;
12721
+ const span = document.createElement('span');
12722
+ span.className = 'message';
12723
+ // `textContent` handles any tenant-configured string in `message` safely
12724
+ // (e.g. the disallowedchars list) without needing to escape HTML.
12725
+ span.textContent = message ?? '';
12726
+ li.appendChild(span);
12727
+ return li;
12666
12728
  }
12667
12729
 
12668
12730
  renderItems(availablePolicies, activePolicies) {
@@ -12670,7 +12732,9 @@ class RawPolicyValidation extends createBaseClass({ componentName: componentName
12670
12732
  return;
12671
12733
  }
12672
12734
 
12673
- this.list.innerHTML = this.validate().map(this.getValidationItemTemplate.bind(this)).join('');
12735
+ this.list.replaceChildren(
12736
+ ...this.validate().map(this.buildValidationItem.bind(this)),
12737
+ );
12674
12738
  }
12675
12739
 
12676
12740
  updateLabel(val) {
@@ -12771,6 +12835,8 @@ const customMixin$9 = (superclass) =>
12771
12835
  'available-policies',
12772
12836
  'data-password-policy-value-minlength',
12773
12837
  'data-password-policy-value-passwordstrength',
12838
+ 'data-password-policy-value-disallowedchars',
12839
+ 'data-password-policy-value-email',
12774
12840
  'label-type',
12775
12841
  'manual-visibility-toggle',
12776
12842
  ],
@@ -12959,6 +13025,8 @@ const policyPanelAttrs = [
12959
13025
  'active-policies',
12960
13026
  'data-password-policy-value-minlength',
12961
13027
  'data-password-policy-value-passwordstrength',
13028
+ 'data-password-policy-value-disallowedchars',
13029
+ 'data-password-policy-value-email',
12962
13030
  'manual-visibility-toggle',
12963
13031
  ];
12964
13032
  const commonAttrs$1 = [