UNPKG

@heymarco/next-auth

Version:

A complete authentication solution for web applications.

73 lines (72 loc) 3.56 kB
import type { PrismaClient } from '@prisma/client'; import type { Awaitable, Adapter, AdapterUser, AdapterCredentials, AdapterRole } from './types.js'; export type CredentialsSignIn = Record<'username' | 'password', string>; export interface CreatePasswordResetTokenData { passwordResetToken: string; user: AdapterUser; } export interface ValidatePasswordResetTokenData { email: string; username: string | null; } export interface RegisterUserData { userId: string; emailConfirmationToken: string | null; } export interface CredentialsSignInOptions { now?: Date; requireEmailVerified?: boolean; failureMaxAttempts?: number | null; failureLockDuration?: number; } export interface CreatePasswordResetTokenOptions { now?: Date; resetThrottle?: number; resetMaxAge?: number; } export interface ValidatePasswordResetTokenOptions { now?: Date; } export interface UsePasswordResetTokenOptions { now?: Date; } export interface RegisterUserOptions { requireEmailVerified?: boolean; } export interface MarkEmailAsVerifiedOptions { now?: Date; } export interface UseEmailConfirmationTokenOptions { now?: Date; } export interface ModelOptions<TPrisma extends PrismaClient> { modelUser?: Extract<keyof TPrisma, string>; modelRole?: Extract<keyof TPrisma, string> | null; modelAccount?: Extract<keyof TPrisma, string>; modelSession?: Extract<keyof TPrisma, string>; modelCredentials?: Extract<keyof TPrisma, string>; modelPasswordResetToken?: Extract<keyof TPrisma, string> | null; modelEmailConfirmationToken?: Extract<keyof TPrisma, string> | null; modelUserRefRoleId?: string | null; modelAccountRefUserId?: string; modelSessionRefUserId?: string; modelCredentialsRefUserId?: string; modelPasswordResetTokenRefUserId?: string | null; modelEmailConfirmationTokenRefUserId?: string | null; } export interface AdapterWithCredentials extends Adapter { credentialsSignIn: (credentials: CredentialsSignIn, options?: CredentialsSignInOptions) => Awaitable<AdapterUser | false | Date | null>; createPasswordResetToken: (usernameOrEmail: string, options?: CreatePasswordResetTokenOptions) => Awaitable<CreatePasswordResetTokenData | Date | null>; validatePasswordResetToken: (passwordResetToken: string, options?: ValidatePasswordResetTokenOptions) => Awaitable<ValidatePasswordResetTokenData | null>; usePasswordResetToken: (passwordResetToken: string, password: string, options?: UsePasswordResetTokenOptions) => Awaitable<boolean>; checkUsernameAvailability: (username: string) => Awaitable<boolean>; checkEmailAvailability: (email: string) => Awaitable<boolean>; registerUser: (name: string, email: string, username: string, password: string, options?: RegisterUserOptions) => Awaitable<RegisterUserData>; markEmailAsVerified: (userId: string, options?: MarkEmailAsVerifiedOptions) => Awaitable<void>; useEmailConfirmationToken: (emailConfirmationToken: string, options?: UseEmailConfirmationTokenOptions) => Awaitable<boolean>; getCredentialsByUserId: (userId: string) => Awaitable<AdapterCredentials | null>; getCredentialsByUserEmail: (userEmail: string) => Awaitable<AdapterCredentials | null>; getRoleByUserId: (userId: string) => Awaitable<AdapterRole | null>; getRoleByUserEmail: (userEmail: string) => Awaitable<AdapterRole | null>; } export declare const PrismaAdapterWithCredentials: <TPrisma extends PrismaClient>(prisma: TPrisma, options?: ModelOptions<TPrisma>) => AdapterWithCredentials;