UNPKG

@nr1e/lucia-adapter-dynamodb

Version:
58 lines 2.09 kB
import { type DynamoDBClient, type QueryCommandInput } from '@aws-sdk/client-dynamodb'; import type { Adapter, DatabaseSession, DatabaseUser } from 'lucia'; /** * Function to retrieve a user. */ export type GetUserFn = (userId: string, client: DynamoDBClient) => Promise<DatabaseUser | null>; /** * Properties for DynamoDBAdapter. */ export interface DynamoDBAdapterProps { /** * The DynamoDB client to use. */ client: DynamoDBClient; /** * The name of the DynamoDB table to use. Default is 'LuciaAuthTable'. */ tableName?: string; /** * Extra attributes to exclude from the user object. Default is an empty array. */ extraUserAttributes?: string[]; /** * Extra attributes to exclude from the session object. Default is an empty array. */ extraSessionAttributes?: string[]; /** * Overrides the default implementation to retrieve user data. * * @param client the DynamoDBClient * @param userId the user ID */ getUser: GetUserFn; /** * Whether to use consistent read when querying the table during getSessionAndUser. Default is false. */ consistentRead?: boolean; } /** * Adapter using two GSIs */ export declare class DynamoDBAdapter implements Adapter { protected client: DynamoDBClient; protected tableName: string; protected getUser: GetUserFn; protected consistentRead: boolean; constructor(options: DynamoDBAdapterProps); deleteSession(sessionId: string): Promise<void>; protected deleteSessions(commandInput: QueryCommandInput): Promise<void>; deleteUserSessions(userId: string): Promise<void>; getSessionAndUser(sessionId: string): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]>; getUserSessions(userId: string): Promise<DatabaseSession[]>; setSession(databaseSession: DatabaseSession): Promise<void>; updateSessionExpiration(sessionId: string, expiresAt: Date): Promise<void>; deleteExpiredSessions(): Promise<void>; private itemToSession; } //# sourceMappingURL=index.d.ts.map