From 7b88ee9638fb8e30789d0433c06e411bc3bd16f7 Mon Sep 17 00:00:00 2001 From: tycrek Date: Tue, 29 Nov 2022 21:54:50 -0700 Subject: [PATCH] feat: added type definitions for auth --- src/types/auth.d.ts | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/types/auth.d.ts diff --git a/src/types/auth.d.ts b/src/types/auth.d.ts new file mode 100644 index 0000000..a42e2f6 --- /dev/null +++ b/src/types/auth.d.ts @@ -0,0 +1,64 @@ +/** + * Defines the structure of a user + */ +export interface User { + /** + * Name of the user + */ + username: string + + /** + * Hashed password. Passwords are hashed using bcrypt. + */ + passhash: string + + /** + * Token used for upload authentication + */ + token: string + + /** + * Indicates whether the user is an admin + */ + admin: boolean + + /** + * Extra metadata. Frontends can use this to store extra data. + */ + meta: { + [key: string]: any + } +} + +/** + * Defines the structure of the users.json file + */ +export interface Users { + /** + * List of users. The key is the user's unique ID. + */ + users: { + [key: string]: User + } + + /** + * Indicates whether auth.json has been migrated + */ + migrated?: boolean + + /** + * Extra metadata. Frontends can use this to store extra data. + */ + meta: { + [key: string]: any + } +} + +export interface OldUser { + username: string + count: number +} + +export interface OldUsers { + [key: string]: OldUser +}