because I got bored of customising my CV for every job
1import { BaseEntity } from "@cv/system";
2
3export class RefreshToken extends BaseEntity {
4 constructor(
5 id: string,
6 public token: string,
7 public userId: string,
8 public expiresAt: Date,
9 createdAt: Date,
10 updatedAt: Date,
11 public userAgent: string | null = null,
12 public ipAddress: string | null = null,
13 public deviceName: string | null = null,
14 public deviceType: string | null = null,
15 public country: string | null = null,
16 public city: string | null = null,
17 public usedAt: Date | null = null,
18 ) {
19 super(id, createdAt, updatedAt);
20 }
21
22 get isExpired(): boolean {
23 return this.expiresAt < new Date();
24 }
25
26 get isUsed(): boolean {
27 return this.usedAt !== null;
28 }
29
30 get isValid(): boolean {
31 return this.isExpired ? false : !this.isUsed;
32 }
33}