84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import type {
|
|
AuthIdentity,
|
|
AuthSecurityEvent,
|
|
AuthSession,
|
|
AuthUser,
|
|
LoginAttempt,
|
|
OAuthAccount,
|
|
OneTimeToken,
|
|
OtpChallenge,
|
|
PasskeyCredential,
|
|
PasswordCredential,
|
|
RecoveryCodeRecord,
|
|
TotpCredential,
|
|
TrustedDevice,
|
|
} from "./types.ts";
|
|
|
|
export interface AuthStore {
|
|
createUser(user: AuthUser): Promise<void>;
|
|
updateUser(user: AuthUser): Promise<void>;
|
|
findUserById(id: string): Promise<AuthUser | undefined>;
|
|
listUsers(): Promise<AuthUser[]>;
|
|
|
|
createIdentity(identity: AuthIdentity): Promise<void>;
|
|
updateIdentity(identity: AuthIdentity): Promise<void>;
|
|
findIdentity(
|
|
type: AuthIdentity["type"],
|
|
normalizedValue: string,
|
|
): Promise<AuthIdentity | undefined>;
|
|
listIdentities(userId: string): Promise<AuthIdentity[]>;
|
|
|
|
setPassword(credential: PasswordCredential): Promise<void>;
|
|
getPassword(userId: string): Promise<PasswordCredential | undefined>;
|
|
|
|
createSession(session: AuthSession): Promise<void>;
|
|
updateSession(session: AuthSession): Promise<void>;
|
|
findSession(id: string): Promise<AuthSession | undefined>;
|
|
listSessions(userId: string): Promise<AuthSession[]>;
|
|
deleteSession(id: string): Promise<void>;
|
|
|
|
createTrustedDevice(device: TrustedDevice): Promise<void>;
|
|
updateTrustedDevice(device: TrustedDevice): Promise<void>;
|
|
findTrustedDeviceByFingerprint(
|
|
userId: string,
|
|
fingerprintHash: string,
|
|
): Promise<TrustedDevice | undefined>;
|
|
listTrustedDevices(userId: string): Promise<TrustedDevice[]>;
|
|
|
|
createToken(token: OneTimeToken): Promise<void>;
|
|
updateToken(token: OneTimeToken): Promise<void>;
|
|
findTokenByHash(hash: string): Promise<OneTimeToken | undefined>;
|
|
|
|
createOtp(challenge: OtpChallenge): Promise<void>;
|
|
updateOtp(challenge: OtpChallenge): Promise<void>;
|
|
findOtp(id: string): Promise<OtpChallenge | undefined>;
|
|
|
|
createTotp(credential: TotpCredential): Promise<void>;
|
|
updateTotp(credential: TotpCredential): Promise<void>;
|
|
listTotp(userId: string): Promise<TotpCredential[]>;
|
|
deleteTotp(id: string): Promise<void>;
|
|
|
|
createRecoveryCodes(codes: RecoveryCodeRecord[]): Promise<void>;
|
|
updateRecoveryCode(code: RecoveryCodeRecord): Promise<void>;
|
|
listRecoveryCodes(userId: string): Promise<RecoveryCodeRecord[]>;
|
|
deleteRecoveryCodes(userId: string): Promise<void>;
|
|
|
|
createPasskey(credential: PasskeyCredential): Promise<void>;
|
|
updatePasskey(credential: PasskeyCredential): Promise<void>;
|
|
findPasskeyByCredentialId(credentialId: string): Promise<PasskeyCredential | undefined>;
|
|
listPasskeys(userId: string): Promise<PasskeyCredential[]>;
|
|
deletePasskey(id: string): Promise<void>;
|
|
|
|
createOAuthAccount(account: OAuthAccount): Promise<void>;
|
|
updateOAuthAccount(account: OAuthAccount): Promise<void>;
|
|
findOAuthAccount(provider: string, providerAccountId: string): Promise<OAuthAccount | undefined>;
|
|
listOAuthAccounts(userId: string): Promise<OAuthAccount[]>;
|
|
deleteOAuthAccount(id: string): Promise<void>;
|
|
|
|
createLoginAttempt(attempt: LoginAttempt): Promise<void>;
|
|
listRecentLoginAttempts(identifier: string, since: number): Promise<LoginAttempt[]>;
|
|
|
|
createSecurityEvent(event: AuthSecurityEvent): Promise<void>;
|
|
listSecurityEvents(userId: string, limit?: number): Promise<AuthSecurityEvent[]>;
|
|
}
|