@bsv/auth-express-middleware
Version:
BSV Blockchain mutual-authentication express middleware
41 lines • 1.81 kB
TypeScript
import { Request } from 'express';
import { Utils } from '@bsv/sdk';
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
/**
* Helper to determine if a given message-level log should be output
* based on the configured log level.
*/
export declare function isLogLevelEnabled(configuredLevel: LogLevel, messageLevel: LogLevel): boolean;
/**
* Retrieves the appropriate logging method from the logger,
* falling back to `log` if not found.
*
* Uses an explicit switch to avoid dynamic property access on a user-influenced
* key, which prevents CodeQL js/unvalidated-dynamic-method-call alerts.
*/
export declare function getLogMethod(logger: typeof console, level: LogLevel): (...args: any[]) => void;
/**
* Write the URL pathname and search components to the binary writer.
*/
export declare function writeUrlToWriter(parsedUrl: URL, writer: Utils.Writer): void;
/**
* Collect and write signed request headers to the binary writer.
*/
export declare function writeRequestHeadersToWriter(req: Request, writer: Utils.Writer): void;
/**
* Write a header pair (key + value) to the binary writer.
*/
export declare function writeHeaderPair(writer: Utils.Writer, key: string, value: string): void;
/**
* Helper: Write body to writer
*/
export declare function writeBodyToWriter(req: Request, writer: Utils.Writer, logger?: typeof console, logLevel?: LogLevel): void;
/**
* Helper: Convert values passed to res.send(...) into byte arrays
*/
export declare function convertValueToArray(val: any, responseHeaders: Record<string, any>): number[];
/**
* Returns a no-op or a bound debug logger depending on config.
*/
export declare function makeDebugLogger(logger?: typeof console, logLevel?: LogLevel): (msg: string, data: any) => void;
//# sourceMappingURL=authMiddlewareHelpers.d.ts.map