Interface: HashPasswordOptions
Optional overrides when calling hashPassword.
parameters?: Provide partial Argon2Params to override defaults (e.g., increasememorySize). Omitted fields fall back to DEFAULT_ARGON2_PARAMS.salt?: Provide a custom 16-byte salt. Normally auto-generated; only use for deterministic migrations/testing.
⚠️ Security:
- Custom salts must be cryptographically random and unique per password.
- Avoid predictable salts (email, userId, timestamps) to prevent rainbow-table attacks.
- Keep parameter overrides consistent across all app instances.
Edge cases:
- Providing
saltdisables auto-generation. Ensure it is exactly ARGON2_SALT_LENGTH bytes or Argon2 will throw. - Partial
parametersare merged with defaults; unspecified fields retain secure defaults.
Examples
await hashPassword('hunter2', { parameters: { memorySize: 8192 } })
const salt = new Uint8Array(16).fill(0)
await hashPassword('hunter2', { salt })
Properties
parameters?
optional parameters: Partial<Argon2Params>;
salt?
optional salt: Uint8Array;