import { hashIds } from './guard'; export interface LoginRequest { username: string; password: string; } export interface ChangePasswordRequest { oldPassword: string | null; newPassword: string; } export interface CreateUserRequest { username: string; password: string; playerId: string; } export interface UpdateUserRequest { isActive?: boolean; isAdmin?: boolean; } export interface CreatePlayerRequest { name: string; } export interface UpdatePlayerRequest { name?: string; isRatingLocked?:boolean; canBeMultiple?:boolean; } export interface CreateGameRequest { name: string; imagePath?: string; bggId?: string; } export interface UpdateGameRequest { name: string; imagePath?: string; bggId?: string; } export class SecureId { #hashedValue?: string; #secureValue?: string; get value(): string | undefined { return this.#hashedValue; } set value(value: string) { this.#hashedValue = value; this.#secureValue = hashIds.decode(value)?.toString(); } get raw(): string | undefined { return this.#secureValue; } set raw(value: string) { this.#hashedValue = hashIds.encode(value); this.#secureValue = value; } constructor(id: { public?: string; secure?: string }) { if (id.public) { this.value = id.public; } else if (id.secure) { this.raw = id.secure; } } toJSON(): string | undefined { return this.#hashedValue; } public static fromHash(hash: string) { return new SecureId({ public: hash }); } public static fromID(id: string) { return new SecureId({ secure: id }); } }