UNPKG

1.36 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 now(localtimeOffsetMsec: number): number;
34
35export function nowSecs(localtimeOffsetMsec: number): number;
36
37export function parseAuthorizationHeader(header: string, keys?: string[]): Record<string, string>;
38
39export function parseContentType(header?: string): string;
40
41export function parseHost(req: http.RequestOptions | https.RequestOptions, hostHeaderName?: string): Host | null;
42
43export function parseRequest(
44 req: http.RequestOptions | https.RequestOptions,
45 options?: ParseRequestOptions,
46): CustomRequest;
47
48export function unauthorized(
49 message?: string,
50 attributes?: string | Boom.unauthorized.Attributes,
51): Boom.Boom & Boom.unauthorized.MissingAuth;