34 lines
802 B
TypeScript
34 lines
802 B
TypeScript
import * as plugins from '../plugins.js';
|
|
|
|
import type { AbuseProtectionManager } from './classes.abuseprotectionmanager.js';
|
|
|
|
@plugins.smartdata.Manager()
|
|
export class AbuseWindow extends plugins.smartdata.SmartDataDbDoc<
|
|
AbuseWindow,
|
|
plugins.idpInterfaces.data.IAbuseWindow,
|
|
AbuseProtectionManager
|
|
> {
|
|
@plugins.smartdata.unI()
|
|
public id: string;
|
|
|
|
@plugins.smartdata.svDb()
|
|
public data: plugins.idpInterfaces.data.IAbuseWindow['data'] = {
|
|
action: '',
|
|
identifierHash: '',
|
|
attemptCount: 0,
|
|
windowStartedAt: 0,
|
|
blockedUntil: 0,
|
|
validUntil: 0,
|
|
createdAt: 0,
|
|
updatedAt: 0,
|
|
};
|
|
|
|
public isBlocked(nowArg = Date.now()) {
|
|
return this.data.blockedUntil > nowArg;
|
|
}
|
|
|
|
public isExpired(nowArg = Date.now()) {
|
|
return this.data.validUntil < nowArg;
|
|
}
|
|
}
|