feat(app): add MFA and tsdocker release
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { MfaManager } from './classes.mfamanager.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class MfaChallenge extends plugins.smartdata.SmartDataDbDoc<MfaChallenge, any, MfaManager> {
|
||||
public static hashToken(tokenArg: string) {
|
||||
return plugins.smarthash.sha256FromStringSync(tokenArg);
|
||||
}
|
||||
|
||||
@plugins.smartdata.unI()
|
||||
public id: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public data = {
|
||||
userId: '',
|
||||
tokenHash: '',
|
||||
status: 'pending' as 'pending' | 'completed' | 'expired',
|
||||
availableMethods: [] as Array<'totp' | 'backupCode' | 'passkey'>,
|
||||
primaryAuthMethod: 'password' as 'password' | 'email',
|
||||
createdAt: 0,
|
||||
expiresAt: 0,
|
||||
completedAt: null as number | null,
|
||||
};
|
||||
|
||||
public isExpired(nowArg = Date.now()) {
|
||||
return this.data.expiresAt < nowArg;
|
||||
}
|
||||
|
||||
public async markCompleted() {
|
||||
this.data.status = 'completed';
|
||||
this.data.completedAt = Date.now();
|
||||
await this.save();
|
||||
}
|
||||
|
||||
public async markExpired() {
|
||||
this.data.status = 'expired';
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user