feat(app): add MFA and tsdocker release
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { MfaManager } from './classes.mfamanager.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class WebAuthnChallenge extends plugins.smartdata.SmartDataDbDoc<WebAuthnChallenge, any, MfaManager> {
|
||||
@plugins.smartdata.unI()
|
||||
public id: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public data = {
|
||||
userId: null as string | null,
|
||||
username: null as string | null,
|
||||
mfaChallengeId: null as string | null,
|
||||
type: 'login' as 'registration' | 'login' | 'mfa',
|
||||
challenge: '',
|
||||
status: 'pending' as 'pending' | 'completed' | 'expired',
|
||||
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