feat(auth): add IUsersRepository + IAuthenticationService interfaces
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import type { User } from "../../entities/user";
|
||||
|
||||
export interface IUsersRepository {
|
||||
getUser(id: string): Promise<User | undefined>;
|
||||
getUserByUsername(username: string): Promise<User | undefined>;
|
||||
createUser(input: User): Promise<User>;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { Session } from "../../entities/session";
|
||||
import type { User } from "../../entities/user";
|
||||
|
||||
export interface IAuthenticationService {
|
||||
generateUserId(): string;
|
||||
hashPassword(password: string): Promise<string>;
|
||||
verifyPassword(hash: string, password: string): Promise<boolean>;
|
||||
validateSession(
|
||||
sessionId: string,
|
||||
): Promise<{ user: User; session: Session }>;
|
||||
createSession(user: User): Promise<{ session: Session; cookie: Cookie }>;
|
||||
invalidateSession(sessionId: string): Promise<{ blankCookie: Cookie }>;
|
||||
}
|
||||
Reference in New Issue
Block a user