30 lines
721 B
TypeScript
30 lines
721 B
TypeScript
|
|
import * as plugins from '../plugins.js';
|
||
|
|
|
||
|
|
import type { PassportManager } from './classes.passportmanager.js';
|
||
|
|
|
||
|
|
@plugins.smartdata.Manager()
|
||
|
|
export class PassportNonce extends plugins.smartdata.SmartDataDbDoc<
|
||
|
|
PassportNonce,
|
||
|
|
plugins.idpInterfaces.data.IPassportNonce,
|
||
|
|
PassportManager
|
||
|
|
> {
|
||
|
|
public static hashNonce(nonceArg: string) {
|
||
|
|
return plugins.smarthash.sha256FromStringSync(nonceArg);
|
||
|
|
}
|
||
|
|
|
||
|
|
@plugins.smartdata.unI()
|
||
|
|
public id: string;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public data: plugins.idpInterfaces.data.IPassportNonce['data'] = {
|
||
|
|
deviceId: '',
|
||
|
|
nonceHash: '',
|
||
|
|
createdAt: 0,
|
||
|
|
expiresAt: 0,
|
||
|
|
};
|
||
|
|
|
||
|
|
public isExpired(nowArg = Date.now()) {
|
||
|
|
return this.data.expiresAt < nowArg;
|
||
|
|
}
|
||
|
|
}
|