import type { RequestEvent, SessionConfig } from 'nuxt/server'; import type { OmitWithIndexSignature } from '../../types/utils.js'; import type { LegacyH3Event, SessionEvent, UserSession, UserSessionRequired } from '#auth-utils'; export { USER_SESSION_COOKIE_NAME } from '../lib/session.js'; type UserSessionData = OmitWithIndexSignature; /** * Session options, the session is always sealed with a secret derived from `appSecret`. */ type UserSessionConfig = Omit; /** * An event the session can be written with, WebSocket peers and upgrade requests are read-only. */ type WritableSessionEvent = RequestEvent | LegacyH3Event; export interface SessionHooks { /** * Called when fetching the session from the API * - Add extra properties to the session * - Throw an error if the session could not be verified (with a database for example) */ fetch: (session: UserSession, event: RequestEvent) => void | Promise; /** * Called before clearing the session */ clear: (session: UserSession, event: RequestEvent) => void | Promise; } export declare const sessionHooks: import("hookable").Hookable>; /** * Get the user session from the current request * @param event The request event * @returns The user session */ export declare function getUserSession(event: SessionEvent): Promise; /** * Set a user session * @param event The request event * @param data User session data, please only store public information since it can be decoded with API calls * @see https://github.com/atinux/nuxt-auth-utils */ export declare function setUserSession(event: WritableSessionEvent, data: UserSessionData, config?: UserSessionConfig): Promise; /** * Replace a user session * @param event The request event * @param data User session data, please only store public information since it can be decoded with API calls */ export declare function replaceUserSession(event: WritableSessionEvent, data: UserSessionData, config?: UserSessionConfig): Promise; /** * Clear the user session and removing the session cookie * @param event The request event * @returns true if the session was cleared */ export declare function clearUserSession(event: WritableSessionEvent, config?: UserSessionConfig): Promise; /** * Require a user session, throw a 401 error if the user is not logged in * @param event * @param opts Options to customize the error message and status code * @param opts.status The status code to use for the error (defaults to 401) * @param opts.statusCode Deprecated, use `status` * @param opts.message The message to use for the error (defaults to Unauthorized) * @see https://github.com/atinux/nuxt-auth-utils */ export declare function requireUserSession(event: SessionEvent, opts?: { status?: number; statusCode?: number; message?: string; }): Promise;