Page MenuHomeSealhub

password.ts
No OneTemporary

password.ts

import SecureHasher from "../../../utils/secure-hasher.js";
import { Context, Field } from "../../../main.js";
const MIN_LENGTH = 8;
export default class Password extends Field {
typeName = "password";
async isProperValue(context: Context, input: string) {
return input.length >= MIN_LENGTH
? Field.valid()
: Field.invalid(context.app.i18n("invalid_password", [MIN_LENGTH]));
}
async encode(_: Context, input: string) {
if (input === null) {
return null;
}
const hash_params = this.app.ConfigManager.get("password_hash");
const salt = SecureHasher.generateRandomSalt(hash_params.salt_length);
return SecureHasher.hash(input, salt, hash_params);
}
async decode() {
return "secret";
}
}

File Metadata

Mime Type
text/x-Algol68
Expires
Tue, Jul 8, 08:12 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
808664
Default Alt Text
password.ts (719 B)

Event Timeline