UNPKG

1.42 kBTypeScriptView Raw
1import * as Boom from "@hapi/boom";
2import * as http from "http";
3import * as https from "https";
4
5export interface Host {
6 name: string;
7 port: number;
8}
9
10export interface CustomRequest {
11 authorization: string;
12 contentType: string;
13 host: string;
14 method: string;
15 port: number;
16 url: string;
17}
18
19export interface ParseRequestOptions {
20 host?: string | undefined;
21 hostHeaderName?: string | undefined;
22 name?: string | undefined;
23 port?: number | undefined;
24}
25
26export const version: string;
27
28export const limits: {
29 /** Limit the length of uris and headers to avoid a DoS attack on string matching */
30 maxMatchLength: number;
31};
32
33export function setTimeFunction(fn: () => number): void;
34
35export function now(localtimeOffsetMsec: number): number;
36
37export function nowSecs(localtimeOffsetMsec: number): number;
38
39export function parseAuthorizationHeader(header: string, keys?: string[]): Record<string, string>;
40
41export function parseContentType(header?: string): string;
42
43export function parseHost(req: http.RequestOptions | https.RequestOptions, hostHeaderName?: string): Host | null;
44
45export function parseRequest(
46 req: http.RequestOptions | https.RequestOptions,
47 options?: ParseRequestOptions,
48): CustomRequest;
49
50export function unauthorized(
51 message?: string,
52 attributes?: string | Boom.unauthorized.Attributes,
53): Boom.Boom & Boom.unauthorized.MissingAuth;