import { type MiddlewareFunction, type RouterContextProvider } from "react-router"; import type { MiddlewareGetter } from "./utils.js"; export declare function createBasicAuthMiddleware(options: createBasicAuthMiddleware.Options): createBasicAuthMiddleware.ReturnType; export declare namespace createBasicAuthMiddleware { export type Args = { request: Request; context: Readonly; }; export type MessageFunction = (args: Args) => string | object | Promise; interface BaseOptions { /** * The domain name of the realm, as part of the returned WWW-Authenticate * challenge header. * @default "Secure Area" * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate#directives */ realm?: string; hashFunction?: HashFunction; invalidUserMessage?: string | object | MessageFunction; } export interface User { /** * The username of the user who is authenticating. */ username: string; /** * The password value for the provided username to authenticate against. */ password: string; } export interface HardCodedUserOptions extends BaseOptions { user: User | Array; } export interface DynamicUserOptions extends BaseOptions { verifyUser(username: string, password: string, args: Args): boolean | Promise; } export type Options = HardCodedUserOptions | DynamicUserOptions; export type ReturnType = [ MiddlewareFunction, MiddlewareGetter ]; export type HashFunction = (data: Uint8Array) => Uint8Array; export {}; }