import { ArkosSocket } from "../../../components/arkos-gateway/types"; import { ArkosRequest, User } from "../../../types"; import { AuthAction } from "./services/auth-action.service"; type ArkosBaseContext = ArkosRequest | ArkosSocket; interface ArkosMiddlewareAdapter { context: TContext; done: (error?: unknown | any) => void; } declare class AuthHookManager { /** * Runs the full authenticate pipeline — before hooks, core user resolution, * after hooks — and calls `done` when finished. * * Shared by the HTTP authenticate middleware and the WebSocket auth ns.use(). * * @param adapter.context - The request or socket being authenticated. * @param adapter.done - Called with no args on success, or with an error to propagate. * @param getUser - Async function that resolves the user from the context. */ runAuthenticate(adapter: ArkosMiddlewareAdapter, getUser: (context: TContext) => Promise, keyName?: "user" | "currentUser"): Promise; /** * Runs the full authorize pipeline — before hooks, core permission check, * after hooks — and calls `done` when finished. * * Shared by the HTTP `authorize()` middleware and WebSocket per-event authorization. * * @param adapter.context - The request or socket being authorized. * @param authAction {AuthAction} * @param keyName {"user" | "currentUser"} */ runAuthorize(adapter: ArkosMiddlewareAdapter, authAction: Required, keyName?: "user" | "currentUser"): Promise; /** * Runs a chain of `after` hooks in sequence. * * - If a hook throws — chain aborts, error is forwarded to the global error handler. * - If a hook returns — next hook in chain runs. * * @returns Promise resolving to `{ error? }` */ private runAfterHooks; /** * Runs a chain of `before` hooks in sequence. * * - If a hook throws — chain aborts, error is forwarded to `onError` hooks. * - If a hook calls `skip()` — chain stops, core logic is bypassed, jumps to `after` hooks. * - If a hook returns — next hook in chain runs. * * @returns Promise resolving to `{ skipped, error? }` */ private runHooks; /** * Runs a chain of `onError` hooks in sequence. * * - If a hook throws — chain aborts, error is forwarded to the global error handler. * - If a hook calls `skip()` — suppresses the error and jumps to `after` hooks. * - If a hook returns — next hook in chain runs. * * @returns Promise resolving to `{ skipped, error? }` */ private runErrorHooks; } declare const authHookManager: AuthHookManager; export default authHookManager;