Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x | import Crypto from "../Crypto";
class WsUser {
id: string;
name: string;
connectedAt: Date;
userId: string | false;
token: string | false;
constructor(name: string, userId: string | false = false) {
this.id = Crypto.generateUUid(32);
this.name = name;
this.connectedAt = new Date();
this.userId = userId;
this.token = false;
}
getId(): string {
return this.id;
}
generateToken(): Promise<string> {
return new Promise(async (resolve, reject) => {
const token = Crypto.generateUUid(32, false);
try {
this.token = await Crypto.generateTokenHash(token);
resolve(token);
} catch (e) {
reject(e);
}
});
}
verifyToken(token: string): Promise<boolean> {
return Crypto.verifyTokenHash(token, this.token);
}
}
export default WsUser; |