import { DrizzlePostgreSQLAdapter } from "@lucia-auth/adapter-drizzle"; import { Lucia } from "lucia"; import { dev } from "$app/environment"; import { userTable, sessionTable } from "$lib/db/schema"; import { db } from "$lib/db/db.server"; import { Argon2id } from "oslo/password"; const adapter = new DrizzlePostgreSQLAdapter(db, sessionTable, userTable); export const lucia = new Lucia(adapter, { sessionCookie: { attributes: { secure: !dev, }, }, getUserAttributes: (attributes) => { return { // attributes has the type of DatabaseUserAttributes username: attributes.username, }; }, }); declare module "lucia" { interface Register { Lucia: typeof lucia; DatabaseUserAttributes: DatabaseUserAttributes; } } interface DatabaseUserAttributes { username: string; } export interface DatabaseUser { id: string; username: string; hashed_password: string; }