🔒

<secure-password-confirm>

Two linked password fields - a "New Password" and a "Confirm Password" - in a single component. Match validation fires only after the confirm field is first blurred. The raw password is never exposed in custom events. Security tier is locked to CRITICAL.

Overview

<secure-password-confirm> renders two linked password fields in a single custom element. It handles match validation, strength enforcement, and show/hide toggling internally. The raw password value is never included in custom events — retrieve it with getPasswordValue() at submission time only.

The security tier is locked to CRITICAL and cannot be overridden.

Installation HTML
<script type="module"
  src="/components/secure-password-confirm/secure-password-confirm.js">
</script>
Minimal usage HTML
<secure-password-confirm
  name="password"
  required>
</secure-password-confirm>

Security Model

Security tier is immutably fixed to CRITICAL. The following guarantees are always enforced:

  • Raw password value never dispatched in events — call getPasswordValue() only at submission
  • Hidden input populated only when both fields match; cleared immediately on mismatch
  • Hidden input omitted entirely when nested inside <secure-form>
  • Match and mismatch events audited at CRITICAL tier via the base class logger
ControlDetail
Raw value isolationThe password value is never dispatched in events. Call getPasswordValue() to retrieve it programmatically.
Tier lockSecurity tier is hard-coded to CRITICAL. The security-tier attribute has no effect.
Audit loggingMatch and mismatch events are recorded via the base class audit logger at CRITICAL tier.
Hidden inputA hidden <input type="hidden"> is created outside the Shadow DOM. Populated only when both fields match. Omitted when inside <secure-form>.

Match Validation Behaviour

Match validation is intentionally deferred to avoid showing errors on every keystroke. The validation lifecycle is:

EventBehaviour
Confirm field first blurValidation runs. secure-password-match or secure-password-mismatch is dispatched. Error message is shown.
Subsequent input (either field)Validation re-runs on each keystroke after the confirm field has been blurred at least once.
Match achievedError message clears. Hidden input is populated. secure-password-match fires.
MismatchError message reads "Passwords do not match". Hidden input is cleared. secure-password-mismatch fires.

Strength Rules

Strength is evaluated on the new-password field. The valid getter returns false when strength requirements are not met. All five requirements must be satisfied:

RuleRequirement
Minimum lengthAt least 8 characters
UppercaseAt least one uppercase letter (A–Z)
LowercaseAt least one lowercase letter (a–z)
DigitAt least one numeric digit (0–9)
Special characterAt least one of: ! @ # $ % ^ & * ( ) _ + - = [ ] { } ; ' : " , . < > ?

Strength indicators are rendered below the new-password field as five inline markers. Each marker turns green when its rule is satisfied.

API Reference

Attributes

AttributeTypeDefaultDescription
namestring—Name of the hidden form input. Omitted when inside <secure-form>.
labelstring—Optional section label rendered above both fields.
password-labelstringNew PasswordLabel text above the new-password field.
confirm-labelstringConfirm PasswordLabel text above the confirm-password field.
requiredbooleanfalseMarks both fields as required.
disabledbooleanfalseDisables both fields and the show/hide toggles.

Properties

valid boolean True only when both fields match and all strength rules pass.
name string Reflects the name attribute.

Methods

getPasswordValue(): string | null
Returns the password when both fields match; null otherwise. This is the only way to retrieve the raw value — it is intentionally absent from all events.

Events

EventDetailWhen
secure-password-match{ name, matched: true }After confirm field blur when both fields match.
secure-password-mismatch{ name, matched: false }After confirm field blur when fields do not match.
secure-password-confirm-change{ name, tier }Fired on each keystroke in either field. Raw value intentionally absent.