<secure-password-confirm>

Two linked password fields in a single component. Match validation fires only after the confirm field is first blurred - not on every keystroke. The raw value is never exposed in custom events; use getPasswordValue() at submission. Security tier is locked to CRITICAL. Includes an animated eye icon show/hide toggle on each field.

<script type="module"
  src="/components/secure-password-confirm/secure-password-confirm.js">
</script>
View API Reference →
Live Demo

Configurations

Standalone - required
Simplest usage. Both fields are required. Match and strength errors appear automatically after the confirm field is blurred.
<secure-password-confirm
  name="password"
  required>
</secure-password-confirm>
Custom labels
Override the default "New Password" / "Confirm Password" labels with password-label and confirm-label attributes.
<secure-password-confirm
  name="password"
  label="Set your passphrase"
  password-label="Passphrase"
  confirm-label="Repeat passphrase"
  required>
</secure-password-confirm>
Inside secure-form
The password is never written to the light DOM, in any configuration. A hidden input is ordinary page markup, so one document.querySelector would read it in cleartext. Nest the component inside <secure-form> to submit it, or read it with getPasswordValue(). The secure-password-match event fires when both fields match.
<secure-form
  action="/change-password"
  method="POST"
  security-tier="critical">
  <secure-password-confirm
    name="password"
    label="Change password"
    required>
  </secure-password-confirm>
  <button type="submit">Update</button>
</secure-form>
getPasswordValue() · valid
The raw password is never in events. Call getPasswordValue() on the element to retrieve it - returns null unless both fields match. The valid getter additionally checks strength requirements.
const el = document.querySelector(
  'secure-password-confirm'
);

// Only returns a value when both fields
// match - null otherwise.
const pw = el.getPasswordValue();

// true only when matched + meets
// strength rules (8+, upper, lower,
// digit, special char)
const ok = el.valid;

Events

secure-threat-detected
Fired when an injection pattern is detected in either the password or confirm field. Applies the same 8-pattern scan used by <secure-input>. The raw value is never included — only the patternId, fieldName, tier, and timestamp.
el.addEventListener('secure-threat-detected', e => {
  const { fieldName, threatType,
          patternId, tier, timestamp } = e.detail;
  // threatType: 'injection'
  // patternId: e.g. 'script-tag', 'js-protocol'
  // bubbles: true, composed: true
});
secure-password-match · secure-password-mismatch
Both events fire after the confirm field is first blurred. No raw password value is included in the event detail - only name and matched flag.
el.addEventListener(
  'secure-password-match', e => {
  // e.detail = { name, matched: true }
  // raw password intentionally absent
});

el.addEventListener(
  'secure-password-mismatch', e => {
  // e.detail = { name, matched: false }
});