/* * Copyright (C) 2026 Fluxer Contributors * * This file is part of Fluxer. * * Fluxer is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fluxer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Fluxer. If not, see . */ import type {PhoneVerificationToken, UserID} from '@fluxer/api/src/BrandedTypes'; import type { AuthSessionRow, EmailRevertTokenRow, EmailVerificationTokenRow, PasswordResetTokenRow, PhoneTokenRow, } from '@fluxer/api/src/database/types/AuthTypes'; import type {AuthSession} from '@fluxer/api/src/models/AuthSession'; import type {EmailRevertToken} from '@fluxer/api/src/models/EmailRevertToken'; import type {EmailVerificationToken} from '@fluxer/api/src/models/EmailVerificationToken'; import type {MfaBackupCode} from '@fluxer/api/src/models/MfaBackupCode'; import type {PasswordResetToken} from '@fluxer/api/src/models/PasswordResetToken'; import type {WebAuthnCredential} from '@fluxer/api/src/models/WebAuthnCredential'; export interface IUserAuthRepository { listAuthSessions(userId: UserID): Promise>; getAuthSessionByToken(sessionIdHash: Buffer): Promise; createAuthSession(sessionData: AuthSessionRow): Promise; updateAuthSessionLastUsed(sessionIdHash: Buffer): Promise; deleteAuthSessions(userId: UserID, sessionIdHashes: Array): Promise; revokeAuthSession(sessionIdHash: Buffer): Promise; deleteAllAuthSessions(userId: UserID): Promise; listMfaBackupCodes(userId: UserID): Promise>; createMfaBackupCodes(userId: UserID, codes: Array): Promise>; clearMfaBackupCodes(userId: UserID): Promise; consumeMfaBackupCode(userId: UserID, code: string): Promise; deleteAllMfaBackupCodes(userId: UserID): Promise; getEmailVerificationToken(token: string): Promise; createEmailVerificationToken(tokenData: EmailVerificationTokenRow): Promise; deleteEmailVerificationToken(token: string): Promise; getPasswordResetToken(token: string): Promise; createPasswordResetToken(tokenData: PasswordResetTokenRow): Promise; deletePasswordResetToken(token: string): Promise; getEmailRevertToken(token: string): Promise; createEmailRevertToken(tokenData: EmailRevertTokenRow): Promise; deleteEmailRevertToken(token: string): Promise; createPhoneToken(token: PhoneVerificationToken, phone: string, userId: UserID | null): Promise; getPhoneToken(token: PhoneVerificationToken): Promise; deletePhoneToken(token: PhoneVerificationToken): Promise; updateUserActivity(userId: UserID, clientIp: string): Promise; checkIpAuthorized(userId: UserID, ip: string): Promise; createAuthorizedIp(userId: UserID, ip: string): Promise; createIpAuthorizationToken(userId: UserID, token: string, email: string): Promise; authorizeIpByToken(token: string): Promise<{userId: UserID; email: string} | null>; deleteAllAuthorizedIps(userId: UserID): Promise; listWebAuthnCredentials(userId: UserID): Promise>; getWebAuthnCredential(userId: UserID, credentialId: string): Promise; createWebAuthnCredential( userId: UserID, credentialId: string, publicKey: Buffer, counter: bigint, transports: Set | null, name: string, ): Promise; updateWebAuthnCredentialCounter(userId: UserID, credentialId: string, counter: bigint): Promise; updateWebAuthnCredentialLastUsed(userId: UserID, credentialId: string): Promise; updateWebAuthnCredentialName(userId: UserID, credentialId: string, name: string): Promise; deleteWebAuthnCredential(userId: UserID, credentialId: string): Promise; getUserIdByCredentialId(credentialId: string): Promise; deleteAllWebAuthnCredentials(userId: UserID): Promise; }