mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
feat(hapi): v19 (#41536)
* chore(@hapi): remove types * feat(@hapi/hapi): v19
This commit is contained in:
committed by
Eli Barzilay
parent
4f00f72a9e
commit
45c702e025
@@ -1704,6 +1704,60 @@
|
||||
"sourceRepoURL": "https://github.com/dwyl/hapi-auth-jwt2/",
|
||||
"asOfVersion": "8.6.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/accept",
|
||||
"typingsPackageName": "hapi__accept",
|
||||
"sourceRepoURL": "https://github.com/hapijs/accept",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/boom",
|
||||
"typingsPackageName": "hapi__boom",
|
||||
"sourceRepoURL": "https://github.com/hapijs/boom",
|
||||
"asOfVersion": "9.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/code",
|
||||
"typingsPackageName": "hapi__code",
|
||||
"sourceRepoURL": "https://github.com/hapijs/code",
|
||||
"asOfVersion": "8.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/cryptiles",
|
||||
"typingsPackageName": "hapi__cryptiles",
|
||||
"sourceRepoURL": "https://github.com/hapijs/cryptiles",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/hoek",
|
||||
"typingsPackageName": "hapi__hoek",
|
||||
"sourceRepoURL": "https://github.com/hapijs/hoek",
|
||||
"asOfVersion": "9.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/iron",
|
||||
"typingsPackageName": "hapi__iron",
|
||||
"sourceRepoURL": "https://github.com/hapijs/iron",
|
||||
"asOfVersion": "6.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/lab",
|
||||
"typingsPackageName": "hapi__lab",
|
||||
"sourceRepoURL": "https://github.com/hapijs/lab",
|
||||
"asOfVersion": "22.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/topo",
|
||||
"typingsPackageName": "hapi__topo",
|
||||
"sourceRepoURL": "https://github.com/hapijs/topo",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@hapi/wreck",
|
||||
"typingsPackageName": "hapi__wreck",
|
||||
"sourceRepoURL": "https://github.com/hapijs/wreck",
|
||||
"asOfVersion": "17.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "hard-rejection",
|
||||
"typingsPackageName": "hard-rejection",
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import * as accept from '@hapi/accept';
|
||||
|
||||
accept.charsets("iso-8859-5, unicode-1-1;q=0.8"); // charset === "iso-8859-5"
|
||||
accept.charset("iso-8859-5, unicode-1-1;q=0.8", ["unicode-1-1"]); // charset === "unicode-1-1"
|
||||
|
||||
accept.encoding("gzip, deflate, sdch"); // encoding === "gzip"
|
||||
accept.encoding("gzip, deflate, sdch", ["deflate", "identity"]);
|
||||
|
||||
const encodings = accept.encodings("compress;q=0.5, gzip;q=1.0"); // encodings === ["gzip", "compress", "identity"]
|
||||
encodings.lastIndexOf('');
|
||||
|
||||
accept.language("en;q=0.7, en-GB;q=0.8");
|
||||
accept.language("en;q=0.7, en-GB;q=0.8", ["en-gb"]); // language === "en-GB"
|
||||
const languages = accept.languages("da, en;q=0.7, en-GB;q=0.8"); // languages === ["da", "en-GB", "en"]
|
||||
languages.lastIndexOf('');
|
||||
|
||||
accept.mediaType("text/plain, application/json;q=0.5, text/html, */*;q=0.1");
|
||||
accept.mediaType("text/plain, application/json;q=0.5, text/html, */*;q=0.1", ["application/json", "text/html"]);
|
||||
const mediaTypes = accept.mediaTypes("text/plain, application/json;q=0.5, text/html, */*;q=0.1");
|
||||
// mediaTypes === ["text/plain", "text/html", "application/json", "*/*"]
|
||||
mediaTypes.lastIndexOf('');
|
||||
const headers = {
|
||||
accept: 'text/plain, application/json;q=0.5, text/html, */*;q=0.1',
|
||||
'accept-language': 'da, en;q=0.7, en-GB;q=0.8'
|
||||
};
|
||||
|
||||
const all = accept.parseAll(headers);
|
||||
all.charsets.length;
|
||||
all.encodings.length;
|
||||
all.languages.length;
|
||||
all.mediaTypes.length;
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
// Type definitions for @hapi/accept 3.2
|
||||
// Project: https://github.com/hapijs/accept#readme
|
||||
// Definitions by: feinoujc <https://github.com/feinoujc>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export function charset(charsetHeader?: string, preferences?: string[]): string;
|
||||
export function charsets(charsetHeader?: string): string[];
|
||||
export function encoding(encodingHeader?: string, preferences?: string[]): string;
|
||||
export function encodings(encodingHeader?: string): string[];
|
||||
export function language(languageHeader?: string, preferences?: string[]): string;
|
||||
export function languages(languageHeader?: string): string[];
|
||||
export function mediaType(mediaTypeHeader?: string, preferences?: string[]): string;
|
||||
export function mediaTypes(mediaTypeHeader?: string): string[];
|
||||
export function parseAll(
|
||||
headers: Record<string, string | string[] | undefined>
|
||||
): {
|
||||
charsets: string[];
|
||||
encodings: string[];
|
||||
languages: string[];
|
||||
mediaTypes: string[];
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/accept": [
|
||||
"hapi__accept"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__accept-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,210 +0,0 @@
|
||||
import * as Boom from '@hapi/boom';
|
||||
|
||||
// 4xx and data type
|
||||
|
||||
const badRequestError = Boom.badRequest('message', {some: 'data'});
|
||||
badRequestError.data.some;
|
||||
const badRequestError2: Boom = Boom.badImplementation('message');
|
||||
|
||||
const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'});
|
||||
unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' };
|
||||
unauthorizedError1.output.headers === { 'WWW-Authenticate': 'scheme some="attribute", error="message"' };
|
||||
|
||||
const unauthorizedError2 = Boom.unauthorized('message', ['scheme']);
|
||||
unauthorizedError2.output.payload.attributes === undefined;
|
||||
unauthorizedError2.output.headers === { 'WWW-Authenticate': 'scheme' };
|
||||
|
||||
const unauthorizedError3 = Boom.unauthorized(null, 'scheme', 'attribute');
|
||||
unauthorizedError3.output.payload.attributes === 'attribute';
|
||||
unauthorizedError3.output.headers === { 'WWW-Authenticate': 'scheme attribute' };
|
||||
|
||||
const unauthorizedError4 = Boom.unauthorized(null, 'scheme', {some: 'attribute'});
|
||||
unauthorizedError4.output.payload.attributes === { some: 'attribute' };
|
||||
unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attribute"' };
|
||||
|
||||
const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'});
|
||||
paymentRequiredError.data.some;
|
||||
const paymentRequiredError2: Boom = Boom.paymentRequired('message');
|
||||
|
||||
const forbiddenError = Boom.forbidden('message', {some: 'data'});
|
||||
forbiddenError.data.some;
|
||||
const forbiddenError2: Boom = Boom.forbidden('message');
|
||||
|
||||
const notFoundError = Boom.notFound('message', {some: 'data'});
|
||||
notFoundError.data.some;
|
||||
const notFoundError2: Boom = Boom.notFound('message');
|
||||
|
||||
const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'});
|
||||
methodNotAllowedError.data.some;
|
||||
const methodNotAllowedError2: Boom = Boom.methodNotAllowed('message');
|
||||
|
||||
const notAcceptableError = Boom.notAcceptable('message', {some: 'data'});
|
||||
notAcceptableError.data.some;
|
||||
const notAcceptableError2: Boom = Boom.notAcceptable('message');
|
||||
|
||||
const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
proxyAuthRequiredError.data.some;
|
||||
const proxyAuthRequiredError2: Boom = Boom.proxyAuthRequired('message');
|
||||
|
||||
const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'});
|
||||
clientTimeoutError.data.some;
|
||||
const clientTimeoutError2: Boom = Boom.clientTimeout('message');
|
||||
|
||||
const conflictError = Boom.conflict('message', {some: 'data'});
|
||||
conflictError.data.some;
|
||||
|
||||
const resourceGoneError = Boom.resourceGone('message', {some: 'data'});
|
||||
resourceGoneError.data.some;
|
||||
const resourceGoneError2: Boom = Boom.resourceGone('message');
|
||||
|
||||
const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'});
|
||||
lengthRequiredError.data.some;
|
||||
const lengthRequiredError2: Boom = Boom.lengthRequired('message');
|
||||
|
||||
const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'});
|
||||
preconditionFailedError.data.some;
|
||||
const preconditionFailedError2: Boom = Boom.preconditionFailed('message');
|
||||
|
||||
const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'});
|
||||
entityTooLargeError.data.some;
|
||||
const entityTooLargeError2: Boom = Boom.lengthRequired('message');
|
||||
|
||||
const uriTooLongError = Boom.uriTooLong('message', {some: 'data'});
|
||||
uriTooLongError.data.some;
|
||||
const uriTooLongError2: Boom = Boom.uriTooLong('message');
|
||||
|
||||
const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
unsupportedMediaTypeError.data.some;
|
||||
const unsupportedMediaTypeError2: Boom = Boom.unsupportedMediaType('message');
|
||||
|
||||
const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
rangeNotSatisfiableError.data.some;
|
||||
const rangeNotSatisfiableError2: Boom = Boom.rangeNotSatisfiable('message');
|
||||
|
||||
const expectationFailedError = Boom.expectationFailed('message', {some: 'data'});
|
||||
expectationFailedError.data.some;
|
||||
const expectationFailedError2: Boom = Boom.expectationFailed('message');
|
||||
|
||||
const teapotError = Boom.teapot('message', {some: 'data'});
|
||||
teapotError.data.some;
|
||||
const teapotError2: Boom = Boom.teapot('message');
|
||||
|
||||
const badDataError = Boom.badData('message', {some: 'data'});
|
||||
badDataError.data.some;
|
||||
const badDataError2: Boom = Boom.badData('message');
|
||||
|
||||
const lockedError = Boom.locked('message', {some: 'data'});
|
||||
lockedError.data.some;
|
||||
const lockedError2: Boom = Boom.locked('message');
|
||||
|
||||
const failedDependencyError = Boom.failedDependency('message', {some: 'data'});
|
||||
failedDependencyError.data.some;
|
||||
const failedDependencyError2: Boom = Boom.failedDependency('message');
|
||||
|
||||
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
|
||||
preconditionRequiredError.data.some;
|
||||
const preconditionRequiredError2: Boom = Boom.preconditionRequired('message');
|
||||
|
||||
const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'});
|
||||
tooManyRequestsError.data.some;
|
||||
const tooManyRequestsError2: Boom = Boom.tooManyRequests('message');
|
||||
|
||||
const illegalError = Boom.illegal('message', {some: 'data'});
|
||||
illegalError.data.some;
|
||||
const illegalError2: Boom = Boom.illegal('message');
|
||||
|
||||
// 5xx and data type
|
||||
|
||||
const badImplementationError = Boom.badImplementation('message', {some: 'data'});
|
||||
badImplementationError.data.some;
|
||||
const badImplementationError2: Boom = Boom.badImplementation('message');
|
||||
|
||||
const internalError = Boom.internal('message', {some: 'data'});
|
||||
internalError.data.some;
|
||||
const internalError2: Boom = Boom.internal('message');
|
||||
|
||||
const notImplementedError = Boom.notImplemented('message', {some: 'data'});
|
||||
notImplementedError.data.some;
|
||||
const notImplementedError2: Boom = Boom.notImplemented('message');
|
||||
|
||||
const badGatewayError = Boom.badGateway('message', {some: 'data'});
|
||||
badGatewayError.data.some;
|
||||
const badGatewayError2: Boom = Boom.badGateway('message');
|
||||
|
||||
const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'});
|
||||
serverUnavailableError.data.some;
|
||||
const serverUnavailableError2: Boom = Boom.serverUnavailable('message');
|
||||
|
||||
const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'});
|
||||
gatewayTimeoutError.data.some;
|
||||
const gatewayTimeoutError2: Boom = Boom.gatewayTimeout('message');
|
||||
|
||||
// boomify
|
||||
const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, message: 'some message' });
|
||||
|
||||
// isBoom
|
||||
|
||||
const isBoomError = new Boom('test');
|
||||
|
||||
Boom.isBoom(isBoomError);
|
||||
|
||||
const maybeBoom = <any> new Boom('test');
|
||||
if (Boom.isBoom(maybeBoom)) {
|
||||
// isBoom is a type guard that allows accessing these properties:
|
||||
maybeBoom.output.headers;
|
||||
}
|
||||
|
||||
// constructor
|
||||
|
||||
const constructorError: Boom = new Boom('test');
|
||||
|
||||
constructorError.message;
|
||||
|
||||
// type widen asserting
|
||||
|
||||
const unauthorizedError = Boom.unauthorized() as Error;
|
||||
|
||||
// status code and reformat
|
||||
|
||||
const error = Boom.badRequest('Cannot feed after midnight');
|
||||
error.output.statusCode = 499; // Assign a custom error code
|
||||
error.reformat();
|
||||
error.reformat(true);
|
||||
|
||||
/**
|
||||
* Add a custom key to the payload
|
||||
*/
|
||||
|
||||
interface CustomPayload extends Boom.Payload {
|
||||
custom: string;
|
||||
}
|
||||
|
||||
(error.output.payload as CustomPayload).custom = 'abc_123';
|
||||
|
||||
/**
|
||||
* Test assignment of custom error data:
|
||||
*/
|
||||
// tslint:disable-next-line:no-object-literal-type-assertion
|
||||
const errorWithData = Boom.badImplementation('', <CustomData1> { custom1: 'test', customType: 'Custom1', isCustom: true });
|
||||
const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type
|
||||
const errorWithExplicitType: Boom<CustomData> = errorWithData; // can assign to union data type
|
||||
const errorWithConcreteCustomData: Boom<CustomData1> = errorWithData; // can assign to concrete data type
|
||||
// assignment to CustomData2 would not be possible
|
||||
// const errorWithConcreteCustomData2: Boom<CustomData2> = errorWithData;
|
||||
|
||||
// Some complex error data types for testing purposes:
|
||||
interface CustomDataBase {
|
||||
isCustom: true;
|
||||
}
|
||||
|
||||
interface CustomData1 extends CustomDataBase {
|
||||
customType: 'Custom1';
|
||||
custom1: string;
|
||||
}
|
||||
|
||||
interface CustomData2 extends CustomDataBase {
|
||||
customType: 'Custom2';
|
||||
custom2: string;
|
||||
}
|
||||
|
||||
type CustomData = CustomData1 | CustomData2;
|
||||
Vendored
-372
@@ -1,372 +0,0 @@
|
||||
// Type definitions for @hapi/boom 7.4
|
||||
// Project: https://github.com/hapijs/boom
|
||||
// Definitions by: Igor Rogatty <https://github.com/rogatty>
|
||||
// AJP <https://github.com/AJamesPhillips>
|
||||
// Jinesh Shah <https://github.com/jineshshah36>
|
||||
// Timon van Spronsen <https://github.com/TimonVS>
|
||||
// Daniel Machado <https://github.com/danielmachado>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export = Boom;
|
||||
/**
|
||||
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
|
||||
* @see {@link https://github.com/hapijs/boom#boom}
|
||||
*/
|
||||
declare class Boom<Data = any> extends Error {
|
||||
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
|
||||
constructor(message?: string | Error, options?: Boom.Options<Data>);
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
isServer: boolean;
|
||||
/** message - the error message. */
|
||||
message: string;
|
||||
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
|
||||
output: Boom.Output;
|
||||
/** reformat() - rebuilds error.output using the other object properties. */
|
||||
reformat(debug?: boolean): string;
|
||||
/**
|
||||
* "If message is unset, the 'error' segment of the header will not be present and
|
||||
* isMissing will be true on the error object." mentioned in
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
isMissing?: boolean;
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
|
||||
data: Data;
|
||||
}
|
||||
declare namespace Boom {
|
||||
interface Options<Data> {
|
||||
/** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */
|
||||
statusCode?: number;
|
||||
/** data - additional error information (assigned to error.data). */
|
||||
data?: Data;
|
||||
/** decorate - an option with extra properties to set on the error object. */
|
||||
decorate?: object;
|
||||
/** ctor - constructor reference used to crop the exception call stack output. */
|
||||
ctor?: any;
|
||||
/** message - error message string. If the error already has a message, the provided message is added as a prefix. Defaults to no message. */
|
||||
message?: string;
|
||||
/**
|
||||
* override - if false, the err provided is a Boom object, and a statusCode or message are
|
||||
* provided, the values are ignored. Defaults to true (apply the provided statusCode and
|
||||
* message options to the error regardless of its type, Error or Boom object).
|
||||
*/
|
||||
override?: boolean;
|
||||
}
|
||||
|
||||
interface Output {
|
||||
/** statusCode - the HTTP status code (typically 4xx or 5xx). */
|
||||
statusCode: number;
|
||||
/**
|
||||
* headers - an object containing any HTTP headers where each key is a header name and
|
||||
* value is the header content. (Limited value type to string
|
||||
* https://github.com/hapijs/boom/issues/151 )
|
||||
*/
|
||||
headers: {[index: string]: string};
|
||||
/**
|
||||
* payload - the formatted object used as the response payload (stringified).
|
||||
* Can be directly manipulated but any changes will be lost if reformat() is called.
|
||||
* Any content allowed and by default includes the following content:
|
||||
*/
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
interface Payload {
|
||||
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
|
||||
statusCode: number;
|
||||
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
|
||||
error: string;
|
||||
/** message - the error message derived from error.message. */
|
||||
message: string;
|
||||
/**
|
||||
* "Every key/value pair will be included ... in the response payload under the attributes key."
|
||||
* [see docs](https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes)
|
||||
*/
|
||||
attributes?: any;
|
||||
// Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload
|
||||
// [anyContent: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates an error with the boom properties
|
||||
* @param error the error object to wrap. If error is already a boom object, it defaults to overriding the object with the new status code and message.
|
||||
* @param options optional additional options
|
||||
* @see {@link https://github.com/hapijs/boom#boomifyerror-options}
|
||||
*/
|
||||
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
|
||||
|
||||
/**
|
||||
* Identifies whether an error is a Boom object. Same as calling instanceof Boom.
|
||||
* @param error the error object to identify.
|
||||
*/
|
||||
function isBoom(error: Error): error is Boom;
|
||||
|
||||
// 4xx
|
||||
/**
|
||||
* Returns a 400 Bad Request error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
|
||||
*/
|
||||
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 401 Unauthorized error
|
||||
* @param message optional message.
|
||||
* @param scheme can be one of the following:
|
||||
* * an authentication scheme name
|
||||
* * an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header.
|
||||
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header.
|
||||
* This value is only used when scheme is a string, otherwise it is ignored.
|
||||
* Every key/value pair will be included in the 'WWW-Authenticate' in the format of
|
||||
* 'key="value"' as well as in the response payload under the attributes key.
|
||||
* Alternatively value can be a string which is use to set the value of the scheme,
|
||||
* for example setting the token value for negotiate header.
|
||||
* If string is used message parameter must be null.
|
||||
* null and undefined will be replaced with an empty string. If attributes is set,
|
||||
* message will be used as the 'error' segment of the 'WWW-Authenticate' header.
|
||||
* If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
|
||||
|
||||
/**
|
||||
* Returns a 402 Payment Required error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
|
||||
*/
|
||||
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 403 Forbidden error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
|
||||
*/
|
||||
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 404 Not Found error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
|
||||
*/
|
||||
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 405 Method Not Allowed error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
|
||||
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
|
||||
*/
|
||||
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 406 Not Acceptable error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
|
||||
*/
|
||||
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 407 Proxy Authentication Required error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
|
||||
*/
|
||||
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 408 Request Time-out error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
|
||||
*/
|
||||
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 409 Conflict error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
|
||||
*/
|
||||
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 410 Gone error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
|
||||
*/
|
||||
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 411 Length Required error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
|
||||
*/
|
||||
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 412 Precondition Failed error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
|
||||
*/
|
||||
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 413 Request Entity Too Large error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
|
||||
*/
|
||||
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 414 Request-URI Too Large error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
|
||||
*/
|
||||
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 415 Unsupported Media Type error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
|
||||
*/
|
||||
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 416 Requested Range Not Satisfiable error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
|
||||
*/
|
||||
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 417 Expectation Failed error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
|
||||
*/
|
||||
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 418 I'm a Teapot error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
|
||||
*/
|
||||
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 422 Unprocessable Entity error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
|
||||
*/
|
||||
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 423 Locked error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
|
||||
*/
|
||||
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 424 Failed Dependency error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data}
|
||||
*/
|
||||
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
|
||||
*/
|
||||
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 429 Too Many Requests error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
|
||||
*/
|
||||
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 451 Unavailable For Legal Reasons error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
|
||||
*/
|
||||
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
// 5xx
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
* Only 500 errors will hide your message from the end user. Your message is recorded in the server log.
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
* Only 500 errors will hide your message from the end user. Your message is recorded in the server log.
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 501 Not Implemented error with your error message to the user
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
|
||||
*/
|
||||
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 502 Bad Gateway error with your error message to the user
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
|
||||
*/
|
||||
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 503 Service Unavailable error with your error message to the user
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
|
||||
*/
|
||||
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 504 Gateway Time-out error with your error message to the user
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
|
||||
*/
|
||||
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/boom": [
|
||||
"hapi__boom"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__boom-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
import { expect, settings, fail, count, incomplete, thrownAt } from "@hapi/code";
|
||||
|
||||
expect(10).to.be.above(5);
|
||||
expect("abc").to.be.a.string();
|
||||
expect([1, 2]).to.be.an.array();
|
||||
expect(20).to.be.at.least(20);
|
||||
expect("abc").to.have.length(3);
|
||||
expect("abc").to.be.a.string().and.contain(["a", "b"]);
|
||||
expect(6).to.be.in.range(5, 6);
|
||||
|
||||
expect(10).to.not.be.above(20);
|
||||
expect([1, 2, 3]).to.shallow.include(3);
|
||||
expect([1, 1, 2]).to.only.include([1, 2]);
|
||||
expect([1, 2]).to.once.include([1, 2]);
|
||||
expect([1, 2, 3]).to.part.include([1, 4]);
|
||||
|
||||
expect(10, "Age").to.be.above(5);
|
||||
|
||||
const func = function() { return arguments; }; // tslint:disable-line only-arrow-functions
|
||||
expect(func()).to.be.arguments();
|
||||
|
||||
expect([1, 2]).to.be.an.array();
|
||||
|
||||
expect(true).to.be.a.boolean();
|
||||
|
||||
expect(new Date()).to.be.a.date();
|
||||
|
||||
const err = new Error("Oops an error occured.");
|
||||
expect(err).to.be.an.error();
|
||||
expect(err).to.be.an.error(Error);
|
||||
expect(err).to.be.an.error("Oops an error occured.");
|
||||
expect(err).to.be.an.error(Error, /occured/);
|
||||
|
||||
expect(func).to.be.a.function();
|
||||
|
||||
expect(123).to.be.a.number();
|
||||
|
||||
expect(/abc/).to.be.a.regexp();
|
||||
|
||||
expect("abc").to.be.a.string();
|
||||
|
||||
expect({ a: "1" }).to.be.an.object();
|
||||
|
||||
expect(true).to.be.true();
|
||||
|
||||
expect(false).to.be.false();
|
||||
|
||||
expect(null).to.be.null();
|
||||
|
||||
expect(undefined).to.be.undefined();
|
||||
|
||||
expect("abc").to.include("ab");
|
||||
expect("abc").to.only.include("abc");
|
||||
expect("aaa").to.only.include("a");
|
||||
expect("abc").to.once.include("b");
|
||||
expect("abc").to.include(["a", "c"]);
|
||||
expect("abc").to.part.include(["a", "d"]);
|
||||
|
||||
expect([1, 2, 3]).to.include(1);
|
||||
expect([{ a: 1 }]).to.include({ a: 1 });
|
||||
expect([1, 2, 3]).to.include([1, 2]);
|
||||
expect([{ a: 1 }]).to.include([{ a: 1 }]);
|
||||
expect([1, 1, 2]).to.only.include([1, 2]);
|
||||
expect([1, 2]).to.once.include([1, 2]);
|
||||
expect([1, 2, 3]).to.part.include([1, 4]);
|
||||
expect([[1], [2]]).to.include([[1]]);
|
||||
|
||||
interface TestType {
|
||||
a: number;
|
||||
b?: number;
|
||||
c?: number;
|
||||
d?: number;
|
||||
}
|
||||
|
||||
interface TestType2 {
|
||||
a: number[];
|
||||
b?: number[];
|
||||
c: number[];
|
||||
}
|
||||
|
||||
expect({ a: 1, b: 2, c: 3 }).to.include("a");
|
||||
expect({ a: 1, b: 2, c: 3 }).to.include(["a", "c"]);
|
||||
expect({ a: 1, b: 2, c: 3 }).to.only.include(["a", "b", "c"]);
|
||||
expect<TestType>({ a: 1, b: 2, c: 3 }).to.include({ a: 1 });
|
||||
expect<any>({ a: 1, b: 2, c: 3 }).to.include({ a: 1 });
|
||||
expect<TestType>({ a: 1, b: 2, c: 3 }).to.include({ a: 1, c: 3 });
|
||||
expect<TestType>({ a: 1, b: 2, c: 3 }).to.part.include({ a: 1, d: 4 });
|
||||
expect<any>({ a: 1, b: 2, c: 3 }).to.part.include({ a: 1, d: 4 });
|
||||
expect({ a: 1, b: 2, c: 3 }).to.only.include({ a: 1, b: 2, c: 3 });
|
||||
expect<TestType2>({ a: [1], b: [2], c: [3] }).to.include({ a: [1], c: [3] });
|
||||
expect<any>({ a: [1], b: [2], c: [3] }).to.include({ a: [1], c: [3] });
|
||||
|
||||
expect("https://example.org/secure").to.startWith("https://");
|
||||
|
||||
expect("http://example.org/relative").to.endWith("/relative");
|
||||
|
||||
expect(4).to.exist();
|
||||
expect(null).to.not.exist();
|
||||
|
||||
expect("abc").to.be.empty();
|
||||
|
||||
expect("abcd").to.have.length(4);
|
||||
|
||||
expect(5).to.equal(5);
|
||||
expect({ a: 1 }).to.equal({ a: 1 });
|
||||
expect([1, 2, 3]).to.equal([1, 2, 3]);
|
||||
|
||||
expect(Object.create(null)).to.equal({}, { prototype: false });
|
||||
|
||||
expect(5).to.shallow.equal(5);
|
||||
expect({ a: 1 }).to.shallow.equal({ a: 1 });
|
||||
|
||||
expect(10).to.be.above(5);
|
||||
|
||||
expect(10).to.be.at.least(10);
|
||||
|
||||
expect(10).to.be.below(20);
|
||||
|
||||
expect(10).to.be.at.most(10);
|
||||
|
||||
expect(10).to.be.within(10, 20);
|
||||
expect(20).to.be.within(10, 20);
|
||||
|
||||
expect(15).to.be.between(10, 20);
|
||||
|
||||
expect(10).to.be.about(9, 1);
|
||||
|
||||
expect(new Date()).to.be.an.instanceof(Date);
|
||||
|
||||
expect("a5").to.match(/\w\d/);
|
||||
expect(["abc", "def"]).to.match(/^[\w\d,]*$/);
|
||||
expect(1).to.match(/^\d$/);
|
||||
|
||||
expect("x").to.satisfy(value => value === "x");
|
||||
|
||||
class CustomError extends Error {
|
||||
call: (message: string) => Error;
|
||||
}
|
||||
|
||||
const throws = () => {
|
||||
throw new CustomError("Oh no!");
|
||||
};
|
||||
|
||||
expect(throws).to.throw(CustomError, "Oh no!");
|
||||
|
||||
fail("This should not occur");
|
||||
|
||||
expect(count()).to.be.a.number();
|
||||
|
||||
expect(incomplete() as null).to.be.null().and.not.be.an.array();
|
||||
|
||||
const error = thrownAt(new Error("oops"));
|
||||
expect(error).to.not.be.undefined();
|
||||
expect(error.column).to.exist();
|
||||
|
||||
const foo = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
settings.truncateMessages = false;
|
||||
expect<number[]>(foo).to.equal([]);
|
||||
|
||||
const bar = Object.create(null);
|
||||
settings.comparePrototypes = false;
|
||||
expect(bar).to.equal({});
|
||||
|
||||
const rejection = Promise.reject(new Error('Oh no!'));
|
||||
/* await */ expect(rejection).to.reject('Oh no!');
|
||||
/* await */ expect(rejection).rejects('Oh no!');
|
||||
|
||||
const typedRejection = Promise.reject(new CustomError('Oh no!'));
|
||||
/* await */ expect(typedRejection).to.reject(CustomError, 'Oh no!');
|
||||
/* await */ expect(typedRejection).rejects(CustomError, 'Oh no!');
|
||||
Vendored
-195
@@ -1,195 +0,0 @@
|
||||
// Type definitions for @hapi/code 5.3
|
||||
// Project: https://github.com/hapijs/code
|
||||
// Definitions by: Prashant Tiwari <https://github.com/prashaantt>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** Generates an assertion object. */
|
||||
export function expect<T>(value: T | T[], prefix?: string): AssertionChain<T>;
|
||||
/** Makes the test fail with the given message. */
|
||||
export function fail(message: string): void;
|
||||
/** Returns the total number of assertions created using the expect() method. */
|
||||
export function count(): number;
|
||||
/** Returns an array of the locations where incomplete assertions were declared or null if no incomplete assertions found. */
|
||||
export function incomplete(): string[] | null;
|
||||
/** Returns the filename, line number, and column number of where the error was created. */
|
||||
export function thrownAt(error?: Error): CodeError;
|
||||
/** Configure code. */
|
||||
export const settings: Settings;
|
||||
|
||||
export type AssertionChain<T> = Assertion<T> & Expectation<T>;
|
||||
|
||||
export type Assertion<T> = Grammar<T> & Flags<T>;
|
||||
|
||||
export type Expectation<T> = Types<T> & Values<T>;
|
||||
|
||||
export interface Grammar<T> {
|
||||
/** Connecting word. */
|
||||
a: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
an: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
and: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
at: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
be: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
have: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
in: AssertionChain<T>;
|
||||
/** Connecting word. */
|
||||
to: AssertionChain<T>;
|
||||
}
|
||||
|
||||
export interface Flags<T> {
|
||||
/** Inverses the expected result of any assertion */
|
||||
not: AssertionChain<T>;
|
||||
/**
|
||||
* Requires that inclusion matches appear only once in the provided value.
|
||||
* Used by include().
|
||||
*/
|
||||
once: AssertionChain<T>;
|
||||
/**
|
||||
* Requires that only the provided elements appear in the provided value.
|
||||
* Used by include().
|
||||
*/
|
||||
only: AssertionChain<T>;
|
||||
/**
|
||||
* Allows a partial match when asserting inclusion
|
||||
* Used by include(). Defaults to false.
|
||||
*/
|
||||
part: AssertionChain<T>;
|
||||
/**
|
||||
* Performs a comparison using strict equality (===).
|
||||
* Code defaults to deep comparison. Used by equal() and include().
|
||||
*/
|
||||
shallow: AssertionChain<T>;
|
||||
}
|
||||
|
||||
export interface Types<T> {
|
||||
/** Asserts that the reference value is an arguments object. */
|
||||
arguments(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is an Array. */
|
||||
array(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a boolean. */
|
||||
boolean(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a Buffer. */
|
||||
buffer(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a Date. */
|
||||
date(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is an error. */
|
||||
error(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a function. */
|
||||
function(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a number. */
|
||||
number(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a RegExp. */
|
||||
regexp(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is a string. */
|
||||
string(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is an object (excluding array, buffer, or other native objects). */
|
||||
object(): AssertionChain<T>;
|
||||
}
|
||||
|
||||
export interface Values<T> {
|
||||
/** Asserts that the reference value is true. */
|
||||
true(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is false. */
|
||||
false(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is null. */
|
||||
null(): AssertionChain<T>;
|
||||
/** Asserts that the reference value is undefined. */
|
||||
undefined(): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string, array, or object) includes the provided values. */
|
||||
include(values: string | string[] | T | T[]): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string, array, or object) includes the provided values. */
|
||||
includes(values: string | string[] | T | T[]): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string, array, or object) includes the provided values. */
|
||||
contain(values: string | string[] | T | T[]): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string, array, or object) includes the provided values. */
|
||||
contains(values: string | string[] | T | T[]): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string) starts with the provided value. */
|
||||
startWith(value: string): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string) starts with the provided value. */
|
||||
startsWith(value: string): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string) ends with the provided value. */
|
||||
endWith(value: string): AssertionChain<T>;
|
||||
/** Asserts that the reference value (a string) ends with the provided value. */
|
||||
endsWith(value: string): AssertionChain<T>;
|
||||
/** Asserts that the reference value exists (not null or undefined). */
|
||||
exist(): AssertionChain<T>;
|
||||
/** Asserts that the reference value exists (not null or undefined). */
|
||||
exists(): AssertionChain<T>;
|
||||
/** Asserts that the reference value has a length property equal to zero or an object with no keys. */
|
||||
empty(): AssertionChain<T>;
|
||||
/** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */
|
||||
length(size: number): AssertionChain<T>;
|
||||
/** Asserts that the reference value equals the provided value. */
|
||||
equal(value: T | T[], options?: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value equals the provided value. */
|
||||
equals(value: T | T[], options?: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value is greater than (>) the provided value. */
|
||||
above(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is greater than (>) the provided value. */
|
||||
greaterThan(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is at least (>=) the provided value. */
|
||||
least(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is at least (>=) the provided value. */
|
||||
min(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is less than (<) the provided value. */
|
||||
below(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is less than (<) the provided value. */
|
||||
lessThan(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is at most (<=) the provided value. */
|
||||
most(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is at most (<=) the provided value. */
|
||||
max(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is within (from <= value <= to) the provided values. */
|
||||
within(from: T, to: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is within (from <= value <= to) the provided values. */
|
||||
range(from: T, to: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is between but not equal (from < value < to) the provided values. */
|
||||
between(from: T, to: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is about the provided value within a delta margin of difference. */
|
||||
about(value: number, delta: number): AssertionChain<T>;
|
||||
/** Asserts that the reference value has the provided instanceof value. */
|
||||
instanceof(type: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value has the provided instanceof value. */
|
||||
instanceOf(type: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value's toString() representation matches the provided regular expression. */
|
||||
match(regex: RegExp): AssertionChain<T>;
|
||||
/** Asserts that the reference value's toString() representation matches the provided regular expression. */
|
||||
matches(regex: RegExp): AssertionChain<T>;
|
||||
/** Asserts that the Promise reference value rejects with an exception when called */
|
||||
reject(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the Promise reference value rejects with an exception when called */
|
||||
rejects(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the reference value satisfies the provided validator function. */
|
||||
satisfy(validator: (value: T) => boolean): AssertionChain<T>;
|
||||
/** Asserts that the reference value satisfies the provided validator function. */
|
||||
satisfies(validator: (value: T) => boolean): AssertionChain<T>;
|
||||
/** Asserts that the function reference value throws an exception when called. */
|
||||
throw(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the function reference value throws an exception when called. */
|
||||
throws(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
/**
|
||||
* Truncate long assertion error messages for readability?
|
||||
* Defaults to true.
|
||||
*/
|
||||
truncateMessages?: boolean;
|
||||
/**
|
||||
* Ignore object prototypes when doing a deep comparison?
|
||||
* Defaults to false.
|
||||
*/
|
||||
comparePrototypes?: boolean;
|
||||
}
|
||||
|
||||
export interface CodeError {
|
||||
filename: string;
|
||||
line: string;
|
||||
column: string;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/code": [
|
||||
"hapi__code"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__code-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,5 +0,0 @@
|
||||
import * as cryptiles from "@hapi/cryptiles";
|
||||
|
||||
cryptiles.randomString(0); // $ExpectType string
|
||||
cryptiles.randomDigits(0); // $ExpectType string
|
||||
cryptiles.fixedTimeComparison("", ""); // $ExpectTpe boolean
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// Type definitions for @hapi/cryptiles 4.2
|
||||
// Project: https://github.com/hapijs/cryptiles
|
||||
// Definitions by: Alex Wendland <https://github.com/awendland>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string.
|
||||
*/
|
||||
export function randomString(size: number): string;
|
||||
|
||||
/**
|
||||
* Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9).
|
||||
* Takes a size argument for the length of the string.
|
||||
*/
|
||||
export function randomDigits(size: number): string;
|
||||
|
||||
/**
|
||||
* Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match).
|
||||
* Returns true if the strings match, false if they differ.
|
||||
*/
|
||||
export function fixedTimeComparison(a: string, b: string): boolean;
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/cryptiles": [
|
||||
"hapi__cryptiles"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__cryptiles-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+4
-4
@@ -9,8 +9,8 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import http = require('http');
|
||||
import Boom = require('@hapi/boom');
|
||||
import { Agent, IncomingMessage } from 'http';
|
||||
import { Boom } from '@hapi/boom';
|
||||
|
||||
import {
|
||||
Plugin,
|
||||
@@ -70,7 +70,7 @@ declare namespace h2o2 {
|
||||
*/
|
||||
onResponse?: (this: RouteOptions,
|
||||
err: null | Boom,
|
||||
res: http.IncomingMessage,
|
||||
res: IncomingMessage,
|
||||
req: Request,
|
||||
h: ResponseToolkit,
|
||||
settings: ProxyHandlerOptions,
|
||||
@@ -78,7 +78,7 @@ declare namespace h2o2 {
|
||||
/** ttl - if set to 'upstream', applies the upstream response caching policy to the response using the response.ttl() method (or passed as an argument to the onResponse method if provided). */
|
||||
ttl?: 'upstream';
|
||||
/** agent - a node http(s) agent to be used for connections to upstream server. @see {@link https://nodejs.org/api/http.html#http_class_http_agent} */
|
||||
agent?: http.Agent;
|
||||
agent?: Agent;
|
||||
/** maxSockets - sets the maximum number of sockets available per outgoing proxy host connection. false means use the wreck module default value (Infinity). Does not affect non-proxy outgoing client connections. Defaults to Infinity. */
|
||||
maxSockets?: false | number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@hapi/boom": "^9.0.0",
|
||||
"@hapi/wreck": "^17.0.0"
|
||||
}
|
||||
}
|
||||
Vendored
+88
-89
@@ -1,4 +1,4 @@
|
||||
// Type definitions for @hapi/hapi 18.2
|
||||
// Type definitions for @hapi/hapi 19.0
|
||||
// Project: https://github.com/hapijs/hapi, https://hapijs.com
|
||||
// Definitions by: Rafael Souza Fijalkowski <https://github.com/rafaelsouzaf>
|
||||
// Justin Simms <https://github.com/jhsimms>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
/// <reference types='node' />
|
||||
|
||||
import * as Boom from '@hapi/boom';
|
||||
import { Boom } from '@hapi/boom';
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import * as Shot from '@hapi/shot';
|
||||
@@ -30,7 +30,7 @@ import * as zlib from 'zlib';
|
||||
|
||||
import { MimosOptions } from '@hapi/mimos';
|
||||
import { SealOptions, SealOptionsSub } from '@hapi/iron';
|
||||
import { ValidationOptions, SchemaMap, Schema } from '@hapi/joi';
|
||||
import { ValidationOptions, SchemaMap, Schema, Root } from '@hapi/joi';
|
||||
import Podium = require('@hapi/podium');
|
||||
import { PolicyOptionVariants, EnginePrototypeOrObject, PolicyOptions, EnginePrototype, Policy, ClientApi, ClientOptions } from '@hapi/catbox';
|
||||
|
||||
@@ -667,7 +667,7 @@ export interface ResponseObjectHeaderOptions {
|
||||
*/
|
||||
export interface ResponseObject extends Podium {
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name].
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseapp)
|
||||
*/
|
||||
@@ -683,7 +683,7 @@ export interface ResponseObject extends Podium {
|
||||
readonly events: ResponseEvents;
|
||||
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* An object containing the response headers where each key is a header field name and the value is the string header value or array of string.
|
||||
* Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders)
|
||||
@@ -691,7 +691,7 @@ export interface ResponseObject extends Podium {
|
||||
readonly headers: Util.Dictionary<string | string[]>;
|
||||
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* Plugin-specific state. Provides a place to store and pass request-level plugin data. plugins is an object where each key is a plugin name and the value is the state.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseplugins)
|
||||
*/
|
||||
@@ -710,7 +710,7 @@ export interface ResponseObject extends Podium {
|
||||
readonly source: Lifecycle.ReturnValue;
|
||||
|
||||
/**
|
||||
* Default value: 200.
|
||||
* @default 200.
|
||||
* The HTTP response status code.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatuscode)
|
||||
*/
|
||||
@@ -942,19 +942,19 @@ export interface ResponseSettings {
|
||||
readonly passThrough: boolean;
|
||||
|
||||
/**
|
||||
* Default value: null (use route defaults).
|
||||
* @default null (use route defaults).
|
||||
* Override the route json options used when source value requires stringification.
|
||||
*/
|
||||
readonly stringify: Json.StringifyArguments;
|
||||
|
||||
/**
|
||||
* Default value: null (use route defaults).
|
||||
* @default null (use route defaults).
|
||||
* If set, overrides the route cache with an expiration value in milliseconds.
|
||||
*/
|
||||
readonly ttl: number;
|
||||
|
||||
/**
|
||||
* Default value: false.
|
||||
* @default false.
|
||||
* If true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present.
|
||||
*/
|
||||
varyEtag: boolean;
|
||||
@@ -1134,7 +1134,7 @@ export type RouteOptionsAccessObject =
|
||||
*/
|
||||
export interface RouteOptionsAccess {
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object
|
||||
* must include at least one of scope or entity.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccess)
|
||||
@@ -1142,7 +1142,7 @@ export interface RouteOptionsAccess {
|
||||
access?: RouteOptionsAccessObject | RouteOptionsAccessObject[];
|
||||
|
||||
/**
|
||||
* Default value: false (no scope requirements).
|
||||
* @default false (no scope requirements).
|
||||
* The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least
|
||||
* one of the scopes defined to access the route. If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For
|
||||
* example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. You may also access
|
||||
@@ -1152,7 +1152,7 @@ export interface RouteOptionsAccess {
|
||||
scope?: RouteOptionsAccessScope;
|
||||
|
||||
/**
|
||||
* Default value: 'any'.
|
||||
* @default 'any'.
|
||||
* The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values:
|
||||
* * 'any' - the authentication can be on behalf of a user or application.
|
||||
* * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy.
|
||||
@@ -1163,7 +1163,7 @@ export interface RouteOptionsAccess {
|
||||
entity?: AccessEntity;
|
||||
|
||||
/**
|
||||
* Default value: 'required'.
|
||||
* @default 'required'.
|
||||
* The authentication mode. Available values:
|
||||
* * 'required' - authentication is required.
|
||||
* * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all.
|
||||
@@ -1173,7 +1173,7 @@ export interface RouteOptionsAccess {
|
||||
mode?: AuthMode;
|
||||
|
||||
/**
|
||||
* Default value: false, unless the scheme requires payload authentication.
|
||||
* @default false, unless the scheme requires payload authentication.
|
||||
* If set, the incoming request payload is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required'
|
||||
* when the scheme sets the authentication options.payload to true. Available values:
|
||||
* * false - no payload authentication.
|
||||
@@ -1184,14 +1184,14 @@ export interface RouteOptionsAccess {
|
||||
payload?: false | 'required' | 'optional';
|
||||
|
||||
/**
|
||||
* Default value: the default strategy set via server.auth.default().
|
||||
* @default the default strategy set via server.auth.default().
|
||||
* An array of string strategy names in the order they should be attempted. Cannot be used together with strategy.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategies)
|
||||
*/
|
||||
strategies?: string[];
|
||||
|
||||
/**
|
||||
* Default value: the default strategy set via server.auth.default().
|
||||
* @default the default strategy set via server.auth.default().
|
||||
* A string strategy names. Cannot be used together with strategies.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategy)
|
||||
*/
|
||||
@@ -1227,7 +1227,7 @@ export type RouteOptionsCache = {
|
||||
);
|
||||
|
||||
/**
|
||||
* Default value: false (no CORS headers).
|
||||
* @default false (no CORS headers).
|
||||
* The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain
|
||||
* than the API server. To enable, set cors to true, or to an object with the following options:
|
||||
* * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a
|
||||
@@ -1302,7 +1302,7 @@ export type PayloadCompressionDecoderSettings = object;
|
||||
*/
|
||||
export interface RouteOptionsPayload {
|
||||
/**
|
||||
* Default value: allows parsing of the following mime types:
|
||||
* @default allows parsing of the following mime types:
|
||||
* * application/json
|
||||
* * application/*+json
|
||||
* * application/octet-stream
|
||||
@@ -1316,35 +1316,35 @@ export interface RouteOptionsPayload {
|
||||
allow?: string | string[];
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression)
|
||||
*/
|
||||
compression?: Util.Dictionary<PayloadCompressionDecoderSettings>;
|
||||
|
||||
/**
|
||||
* Default value: 'application/json'.
|
||||
* @default 'application/json'.
|
||||
* The default content type if the 'Content-Type' request header is missing.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaddefaultcontenttype)
|
||||
*/
|
||||
defaultContentType?: string;
|
||||
|
||||
/**
|
||||
* Default value: 'error' (return a Bad Request (400) error response).
|
||||
* @default 'error' (return a Bad Request (400) error response).
|
||||
* A failAction value which determines how to handle payload parsing errors.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadfailaction)
|
||||
*/
|
||||
failAction?: Lifecycle.FailAction;
|
||||
|
||||
/**
|
||||
* Default value: 1048576 (1MB).
|
||||
* @default 1048576 (1MB).
|
||||
* Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmaxbytes)
|
||||
*/
|
||||
maxBytes?: number;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Overrides payload processing for multipart requests. Value can be one of:
|
||||
* * false - disable multipart processing.
|
||||
* an object with the following required options:
|
||||
@@ -1360,7 +1360,7 @@ export interface RouteOptionsPayload {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: 'data'.
|
||||
* @default 'data'.
|
||||
* The processed payload format. The value must be one of:
|
||||
* * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw
|
||||
* Buffer is returned.
|
||||
@@ -1376,14 +1376,14 @@ export interface RouteOptionsPayload {
|
||||
output?: PayloadOutput;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* A mime type string overriding the 'Content-Type' header value received.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoverride)
|
||||
*/
|
||||
override?: string;
|
||||
|
||||
/**
|
||||
* Default value: true.
|
||||
* @default true.
|
||||
* Determines if the incoming payload is processed or presented raw. Available values:
|
||||
* * true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the
|
||||
* format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded.
|
||||
@@ -1394,7 +1394,7 @@ export interface RouteOptionsPayload {
|
||||
parse?: boolean | 'gunzip';
|
||||
|
||||
/**
|
||||
* Default value: to 10000 (10 seconds).
|
||||
* @default to 10000 (10 seconds).
|
||||
* Payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408)
|
||||
* error response. Set to false to disable.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadtimeout)
|
||||
@@ -1402,7 +1402,7 @@ export interface RouteOptionsPayload {
|
||||
timeout?: false | number;
|
||||
|
||||
/**
|
||||
* Default value: os.tmpdir().
|
||||
* @default os.tmpdir().
|
||||
* The directory used for writing file uploads.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaduploads)
|
||||
*/
|
||||
@@ -1462,7 +1462,7 @@ export type RouteOptionsResponseSchema =
|
||||
*/
|
||||
export interface RouteOptionsResponse {
|
||||
/**
|
||||
* Default value: 200.
|
||||
* @default 204.
|
||||
* The default HTTP status code when the payload is considered empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time of response transmission (the
|
||||
* response status code will remain 200 throughout the request lifecycle unless manually set).
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseemptystatuscode)
|
||||
@@ -1470,21 +1470,21 @@ export interface RouteOptionsResponse {
|
||||
emptyStatusCode?: 200 | 204;
|
||||
|
||||
/**
|
||||
* Default value: 'error' (return an Internal Server Error (500) error response).
|
||||
* @default 'error' (return an Internal Server Error (500) error response).
|
||||
* A failAction value which defines what to do when a response fails payload validation.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsefailaction)
|
||||
*/
|
||||
failAction?: Lifecycle.FailAction;
|
||||
|
||||
/**
|
||||
* Default value: false.
|
||||
* @default false.
|
||||
* If true, applies the validation rule changes to the response payload.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsemodify)
|
||||
*/
|
||||
modify?: boolean;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* [joi](http://github.com/hapijs/joi) options object pass to the validation function. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). If a
|
||||
* custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseoptions)
|
||||
@@ -1492,21 +1492,21 @@ export interface RouteOptionsResponse {
|
||||
options?: ValidationOptions; // TODO needs validation
|
||||
|
||||
/**
|
||||
* Default value: true.
|
||||
* @default true.
|
||||
* If false, payload range support is disabled.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseranges)
|
||||
*/
|
||||
ranges?: boolean;
|
||||
|
||||
/**
|
||||
* Default value: 100 (all responses).
|
||||
* @default 100 (all responses).
|
||||
* The percent of response payloads validated (0 - 100). Set to 0 to disable all validation.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsesample)
|
||||
*/
|
||||
sample?: number;
|
||||
|
||||
/**
|
||||
* Default value: true (no validation).
|
||||
* @default true (no validation).
|
||||
* The default response payload validation rules (for all non-error responses) expressed as one of:
|
||||
* * true - any payload allowed (no validation).
|
||||
* * false - no payload allowed.
|
||||
@@ -1521,7 +1521,7 @@ export interface RouteOptionsResponse {
|
||||
schema?: RouteOptionsResponseSchema;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Validation schemas for specific HTTP status codes. Responses (excluding errors) not matching the listed status codes are validated using the default schema.
|
||||
* status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus)
|
||||
@@ -1546,7 +1546,7 @@ export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' |
|
||||
'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin';
|
||||
|
||||
/**
|
||||
* Default value: false (security headers disabled).
|
||||
* @default false (security headers disabled).
|
||||
* Sets common security headers. To enable, set security to true or to an object with the following options:
|
||||
* * hsts - controls the 'Strict-Transport-Security' header, where:
|
||||
* * * true - the header will be set to max-age=15768000. This is the default value.
|
||||
@@ -1630,20 +1630,20 @@ export interface RouteOptionsSecureObject {
|
||||
export type RouteOptionsSecure = boolean | RouteOptionsSecureObject;
|
||||
|
||||
/**
|
||||
* Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }.
|
||||
* @default { headers: true, params: true, query: true, payload: true, failAction: 'error' }.
|
||||
* Request input validation rules for various request components.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate)
|
||||
*/
|
||||
export interface RouteOptionsValidate {
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* An optional object with error fields copied into every validation error response.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateerrorfields)
|
||||
*/
|
||||
errorFields?: object;
|
||||
|
||||
/**
|
||||
* Default value: 'error' (return a Bad Request (400) error response).
|
||||
* @default 'error' (return a Bad Request (400) error response).
|
||||
* A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatefailaction)
|
||||
*/
|
||||
@@ -1729,14 +1729,14 @@ export interface RouteOptionsApp {
|
||||
|
||||
export interface CommonRouteProperties {
|
||||
/**
|
||||
* Default value: null.
|
||||
* @default null.
|
||||
* An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsbind)
|
||||
*/
|
||||
bind?: object | null;
|
||||
|
||||
/**
|
||||
* Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }.
|
||||
* @default { privacy: 'default', statuses: [200], otherwise: 'no-cache' }.
|
||||
* If the route method is 'GET', the route can be configured to include HTTP caching directives in the response. Caching can be customized using an object with the following options:
|
||||
* privacy - determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are:
|
||||
* * * 'default' - no privacy flag.
|
||||
@@ -1758,7 +1758,7 @@ export interface CommonRouteProperties {
|
||||
compression?: Util.Dictionary<RouteCompressionEncoderSettings>;
|
||||
|
||||
/**
|
||||
* Default value: false (no CORS headers).
|
||||
* @default false (no CORS headers).
|
||||
* The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different
|
||||
* domain than the API server. To enable, set cors to true, or to an object with the following options:
|
||||
* * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a
|
||||
@@ -1776,7 +1776,7 @@ export interface CommonRouteProperties {
|
||||
cors?: boolean | RouteOptionsCors;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Route description used for generating documentation (string).
|
||||
* This setting is not available when setting server route defaults using server.options.routes.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsdescription)
|
||||
@@ -1784,7 +1784,7 @@ export interface CommonRouteProperties {
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the
|
||||
* server.ext(events) event argument.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext)
|
||||
@@ -1795,7 +1795,7 @@ export interface CommonRouteProperties {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: { relativeTo: '.' }.
|
||||
* @default { relativeTo: '.' }.
|
||||
* Defines the behavior for accessing files:
|
||||
* * relativeTo - determines the folder relative paths are resolved against.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsfiles)
|
||||
@@ -1805,7 +1805,7 @@ export interface CommonRouteProperties {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* The route handler function performs the main business logic of the route and sets the response. handler can be assigned:
|
||||
* * a lifecycle method.
|
||||
* * an object with a single property using the name of a handler type registred with the server.handler() method. The matching property value is passed as options to the registered handler
|
||||
@@ -1815,14 +1815,14 @@ export interface CommonRouteProperties {
|
||||
handler?: Lifecycle.Method | object;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* An optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes added with an array of methods.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsid)
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* Default value: false.
|
||||
* @default false.
|
||||
* If true, the route cannot be accessed through the HTTP listener but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should
|
||||
* not be accessible to the outside world.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsisinternal)
|
||||
@@ -1830,7 +1830,7 @@ export interface CommonRouteProperties {
|
||||
isInternal?: boolean;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Optional arguments passed to JSON.stringify() when converting an object or error response to a string payload or escaping it after stringification. Supports the following:
|
||||
* * replacer - the replacer function or array. Defaults to no action.
|
||||
* * space - number of spaces to indent nested object keys. Defaults to no indentation.
|
||||
@@ -1841,7 +1841,7 @@ export interface CommonRouteProperties {
|
||||
json?: Json.StringifyArguments;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload.
|
||||
* For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Cannot be used with stream
|
||||
* responses. The 'Content-Type' response header is set to 'text/javascript' and the 'X-Content-Type-Options' response header is set to 'nosniff', and will override those headers even if
|
||||
@@ -1851,7 +1851,7 @@ export interface CommonRouteProperties {
|
||||
jsonp?: string;
|
||||
|
||||
/**
|
||||
* Default value: { collect: false }.
|
||||
* @default { collect: false }.
|
||||
* Request logging options:
|
||||
* collect - if true, request-level logs (both internal and application) are collected and accessible via request.logs.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionslog)
|
||||
@@ -1861,7 +1861,7 @@ export interface CommonRouteProperties {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Route notes used for generating documentation (string or array of strings).
|
||||
* This setting is not available when setting server route defaults using server.options.routes.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsnotes)
|
||||
@@ -1875,14 +1875,14 @@ export interface CommonRouteProperties {
|
||||
payload?: RouteOptionsPayload;
|
||||
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins)
|
||||
*/
|
||||
plugins?: PluginSpecificConfiguration;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* The pre option allows defining methods for performing actions before the handler is called. These methods allow breaking the handler logic into smaller, reusable components that can be shared
|
||||
* ascross routes, as well as provide a cleaner error handling of prerequisite operations (e.g. load required reference data from a database). pre is assigned an ordered array of methods which
|
||||
* are called serially in order. If the pre array contains another array of methods as one of its elements, those methods are called in parallel. Note that during parallel execution, if any of
|
||||
@@ -1908,13 +1908,13 @@ export interface CommonRouteProperties {
|
||||
response?: RouteOptionsResponse;
|
||||
|
||||
/**
|
||||
* Default value: false (security headers disabled).
|
||||
* @default false (security headers disabled).
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionssecurity)
|
||||
*/
|
||||
security?: RouteOptionsSecure;
|
||||
|
||||
/**
|
||||
* Default value: { parse: true, failAction: 'error' }.
|
||||
* @default { parse: true, failAction: 'error' }.
|
||||
* HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following
|
||||
* options: parse - determines if incoming 'Cookie' headers are parsed and stored in the request.state object. failAction - A failAction value which determines how to handle cookie parsing
|
||||
* errors. Defaults to 'error' (return a Bad Request (400) error response).
|
||||
@@ -1926,7 +1926,7 @@ export interface CommonRouteProperties {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Route tags used for generating documentation (array of strings).
|
||||
* This setting is not available when setting server route defaults using server.options.routes.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstags)
|
||||
@@ -1934,7 +1934,7 @@ export interface CommonRouteProperties {
|
||||
tags?: string[];
|
||||
|
||||
/**
|
||||
* Default value: { server: false }.
|
||||
* @default { server: false }.
|
||||
* Timeouts for processing durations.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstimeout)
|
||||
*/
|
||||
@@ -1946,14 +1946,14 @@ export interface CommonRouteProperties {
|
||||
server?: boolean | number;
|
||||
|
||||
/**
|
||||
* Default value: none (use node default of 2 minutes).
|
||||
* @default none (use node default of 2 minutes).
|
||||
* By default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Set to false to disable socket timeouts.
|
||||
*/
|
||||
socket?: boolean | number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }.
|
||||
* @default { headers: true, params: true, query: true, payload: true, failAction: 'error' }.
|
||||
* Request input validation rules for various request components.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate)
|
||||
*/
|
||||
@@ -2856,6 +2856,8 @@ export interface ServerOptionsCompression {
|
||||
export interface ServerOptionsApp {
|
||||
}
|
||||
|
||||
export type SameSitePolicy = false | 'None' | 'Lax' | 'Strict';
|
||||
|
||||
/**
|
||||
* The server options control the behavior of the server object. Note that the options object is deeply cloned
|
||||
* (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on.
|
||||
@@ -2864,7 +2866,7 @@ export interface ServerOptionsApp {
|
||||
*/
|
||||
export interface ServerOptions {
|
||||
/**
|
||||
* Default value: '0.0.0.0' (all available network interfaces).
|
||||
* @default '0.0.0.0' (all available network interfaces).
|
||||
* Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to
|
||||
* restrict the server to only those coming from the same host.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsaddress)
|
||||
@@ -2872,7 +2874,7 @@ export interface ServerOptions {
|
||||
address?: string;
|
||||
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available
|
||||
* anywhere a server reference is provided. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time
|
||||
* state.
|
||||
@@ -2881,7 +2883,7 @@ export interface ServerOptions {
|
||||
app?: ServerOptionsApp;
|
||||
|
||||
/**
|
||||
* Default value: true.
|
||||
* @default true.
|
||||
* Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework.
|
||||
* Cannot be set to true along with a port value.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsautolisten)
|
||||
@@ -2889,7 +2891,7 @@ export interface ServerOptions {
|
||||
autoListen?: boolean;
|
||||
|
||||
/**
|
||||
* Default value: { engine: require('@hapi/catbox-memory' }.
|
||||
* @default { engine: require('@hapi/catbox-memory' }.
|
||||
* Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and
|
||||
* capabilities. hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized
|
||||
* if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. The configuration can be assigned one or more
|
||||
@@ -2908,13 +2910,13 @@ export interface ServerOptions {
|
||||
cache?: CacheProvider | ServerOptionsCache | ServerOptionsCache[];
|
||||
|
||||
/**
|
||||
* Default value: { minBytes: 1024 }.
|
||||
* @default { minBytes: 1024 }.
|
||||
* Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server.
|
||||
*/
|
||||
compression?: boolean | ServerOptionsCompression;
|
||||
|
||||
/**
|
||||
* Default value: { request: ['implementation'] }.
|
||||
* @default { request: ['implementation'] }.
|
||||
* Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to
|
||||
* disable all console logging, or to an object with:
|
||||
* * log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output.
|
||||
@@ -2930,13 +2932,13 @@ export interface ServerOptions {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: the operating system hostname and if not available, to 'localhost'.
|
||||
* @default the operating system hostname and if not available, to 'localhost'.
|
||||
* The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided.
|
||||
*/
|
||||
host?: string;
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface).
|
||||
* If the listener needs to be manually started, set autoListen to false.
|
||||
* If the listener uses TLS, set tls to true.
|
||||
@@ -2944,7 +2946,7 @@ export interface ServerOptions {
|
||||
listener?: http.Server;
|
||||
|
||||
/**
|
||||
* Default value: { sampleInterval: 0 }.
|
||||
* @default { sampleInterval: 0 }.
|
||||
* Server excessive load handling limits where:
|
||||
* * sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling).
|
||||
* * maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
|
||||
@@ -2955,11 +2957,6 @@ export interface ServerOptions {
|
||||
/** the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). */
|
||||
sampleInterval?: number;
|
||||
|
||||
/**
|
||||
* Max concurrent requests.
|
||||
*/
|
||||
concurrent?: number;
|
||||
|
||||
/** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */
|
||||
maxHeapUsedBytes?: number;
|
||||
/**
|
||||
@@ -2974,7 +2971,7 @@ export interface ServerOptions {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime):
|
||||
* * override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain:
|
||||
* * key - the lower-cased mime-type string (e.g. 'application/javascript').
|
||||
@@ -2986,21 +2983,21 @@ export interface ServerOptions {
|
||||
mime?: MimosOptions;
|
||||
|
||||
/**
|
||||
* Default value: {}.
|
||||
* @default {}.
|
||||
* Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the
|
||||
* difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state.
|
||||
*/
|
||||
plugins?: PluginSpecificConfiguration;
|
||||
|
||||
/**
|
||||
* Default value: 0 (an ephemeral port).
|
||||
* @default 0 (an ephemeral port).
|
||||
* The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port).
|
||||
* If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe.
|
||||
*/
|
||||
port?: number | string;
|
||||
|
||||
/**
|
||||
* Default value: { isCaseSensitive: true, stripTrailingSlash: false }.
|
||||
* @default { isCaseSensitive: true, stripTrailingSlash: false }.
|
||||
* Controls how incoming request URIs are matched against the routing table:
|
||||
* * isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true.
|
||||
* * stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false.
|
||||
@@ -3011,7 +3008,7 @@ export interface ServerOptions {
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* A route options object used as the default configuration for every route.
|
||||
*/
|
||||
routes?: RouteOptions;
|
||||
@@ -3035,18 +3032,18 @@ export interface ServerOptions {
|
||||
ignoreErrors?: boolean,
|
||||
isSecure?: boolean,
|
||||
isHttpOnly?: boolean,
|
||||
isSameSite?: false | 'Strict' | 'Lax',
|
||||
isSameSite?: SameSitePolicy,
|
||||
encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'
|
||||
};
|
||||
|
||||
/**
|
||||
* Default value: none.
|
||||
* @default none.
|
||||
* Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation.
|
||||
*/
|
||||
tls?: boolean | https.ServerOptions;
|
||||
|
||||
/**
|
||||
* Default value: constructed from runtime server information.
|
||||
* @default constructed from runtime server information.
|
||||
* The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings.
|
||||
*/
|
||||
uri?: string;
|
||||
@@ -3249,7 +3246,7 @@ export interface ServerStateCookieOptions {
|
||||
* * 'Strict' - sets the value to 'Strict' (this is the default value).
|
||||
* * 'Lax' - sets the value to 'Lax'.
|
||||
*/
|
||||
isSameSite?: false | 'Strict' | 'Lax';
|
||||
isSameSite?: SameSitePolicy;
|
||||
/** the path scope. Defaults to null (no path). */
|
||||
path?: string | null;
|
||||
/** the domain scope. Defaults to null (no domain). */
|
||||
@@ -3519,10 +3516,6 @@ export class Server {
|
||||
*/
|
||||
eventLoopDelay: number;
|
||||
|
||||
/**
|
||||
* Max concurrent requests.
|
||||
*/
|
||||
concurrent: number
|
||||
/**
|
||||
* V8 heap usage.
|
||||
*/
|
||||
@@ -3963,6 +3956,12 @@ export class Server {
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost)
|
||||
*/
|
||||
table(host?: string): RequestRoute[];
|
||||
|
||||
/**
|
||||
* Registers a server validation module used to compile raw validation rules into validation schemas for all routes.
|
||||
* The validator is only used when validation rules are not pre-compiled schemas. When a validation rules is a function or schema object, the rule is used as-is and the validator is not used.
|
||||
*/
|
||||
validator(joi: Root): void;
|
||||
}
|
||||
|
||||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@hapi/boom": "^9.0.0",
|
||||
"@hapi/iron": "^6.0.0"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ const server = new Server({
|
||||
port: 8000,
|
||||
load: {
|
||||
sampleInterval: 1000,
|
||||
concurrent: 123,
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
import * as Hoek from "@hapi/hoek";
|
||||
|
||||
/**
|
||||
* Import the entire module as above or use named imports:
|
||||
* import { clone, merge, assert } from "@hapi/hoek";
|
||||
* "Tests" taken straight from hoek API reference and adapted to TypeScript.
|
||||
*/
|
||||
|
||||
// clone(obj)
|
||||
|
||||
let nestedObj = {
|
||||
w: /^something$/ig,
|
||||
x: {
|
||||
a: [1, 2, 3],
|
||||
b: 123456,
|
||||
c: new Date()
|
||||
},
|
||||
y: 'y',
|
||||
z: new Date()
|
||||
};
|
||||
|
||||
let copy = Hoek.clone(nestedObj);
|
||||
|
||||
copy.x.b = 100;
|
||||
|
||||
console.log(copy.y); // results in 'y'
|
||||
console.log(nestedObj.x.b); // results in 123456
|
||||
console.log(copy.x.b); // results in 100
|
||||
|
||||
// cloneWithShallow(obj, keys)
|
||||
|
||||
nestedObj = {
|
||||
w: /^something$/ig,
|
||||
x: {
|
||||
a: [1, 2, 3],
|
||||
b: 123456,
|
||||
c: new Date()
|
||||
},
|
||||
y: 'y',
|
||||
z: new Date()
|
||||
};
|
||||
|
||||
copy = Hoek.cloneWithShallow(nestedObj, ['x']);
|
||||
|
||||
copy.x.b = 100;
|
||||
|
||||
console.log(copy.y); // results in 'y'
|
||||
console.log(nestedObj.x.b); // results in 100
|
||||
console.log(copy.x.b); // results in 100
|
||||
|
||||
// merge(target, source, isNullOverride, isMergeArrays)
|
||||
|
||||
const target = { a: 1, b: 2 };
|
||||
const source = { a: 0, c: 5 };
|
||||
const source2 = { a: null, c: 5 };
|
||||
|
||||
Hoek.merge(target, source); // results in {a: 0, b: 2, c: 5}
|
||||
Hoek.merge(target, source2); // results in {a: null, b: 2, c: 5}
|
||||
Hoek.merge(target, source2, false); // results in {a: 1, b: 2, c: 5}
|
||||
|
||||
const targetArray = [1, 2, 3];
|
||||
const sourceArray = [4, 5];
|
||||
|
||||
Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5]
|
||||
Hoek.merge(targetArray, sourceArray, true, false); // results in [4, 5]
|
||||
|
||||
// applyToDefaults(defaults, options, isNullOverride)
|
||||
|
||||
let defaults = { host: "localhost", port: 8000 };
|
||||
const options = { port: 8080 };
|
||||
|
||||
let config = Hoek.applyToDefaults(defaults, options); // results in { host: "localhost", port: 8080 }
|
||||
|
||||
defaults = { host: "localhost", port: 8000 };
|
||||
const options1 = { host: null, port: 8080 };
|
||||
|
||||
config = Hoek.applyToDefaults(defaults, options1, true); // results in { host: null, port: 8080 }
|
||||
|
||||
// applyToDefaultsWithShallow(defaults, options, keys)
|
||||
|
||||
const defaults1 = {
|
||||
server: {
|
||||
host: "localhost",
|
||||
port: 8000
|
||||
},
|
||||
name: 'example'
|
||||
};
|
||||
|
||||
const options2 = { server: { port: 8080 } };
|
||||
|
||||
const config1 = Hoek.applyToDefaultsWithShallow(defaults1, options2, ['server']); // results in { server: { port: 8080 }, name: 'example' }
|
||||
|
||||
// deepEqual(b, a, [options])
|
||||
|
||||
Hoek.deepEqual({ a: [1, 2], b: 'string', c: { d: true } }, { a: [1, 2], b: 'string', c: { d: true } }); // results in true
|
||||
Hoek.deepEqual(Object.create(null), {}, { prototype: false }); // results in true
|
||||
Hoek.deepEqual(Object.create(null), {}); // results in false
|
||||
|
||||
// unique(array, key)
|
||||
|
||||
let array = [1, 2, 2, 3, 3, 4, 5, 6];
|
||||
|
||||
const newArray = Hoek.unique(array); // results in [1,2,3,4,5,6]
|
||||
|
||||
let array1 = [{ id: 1 }, { id: 1 }, { id: 2 }];
|
||||
|
||||
const newArray1 = Hoek.unique(array1, "id"); // results in [{id: 1}, {id: 2}]
|
||||
|
||||
// mapToObject(array, key)
|
||||
|
||||
array = [1, 2, 3];
|
||||
let newObject = Hoek.mapToObject(array); // results in {"1": true, "2": true, "3": true}
|
||||
|
||||
array1 = [{ id: 1 }, { id: 2 }];
|
||||
newObject = Hoek.mapToObject(array1, "id"); // results in {"1": true, "2": true}
|
||||
|
||||
// intersect(array1, array2)
|
||||
|
||||
array = [1, 2, 3];
|
||||
const array2 = [1, 4, 5];
|
||||
|
||||
const newArray2 = Hoek.intersect(array, array2); // results in [1]
|
||||
|
||||
// contain(ref, values, [options])
|
||||
|
||||
Hoek.contain('aaa', 'a', { only: true }); // true
|
||||
Hoek.contain([{ a: 1 }], [{ a: 1 }], { deep: true }); // true
|
||||
Hoek.contain([1, 2, 2], [1, 2], { once: true }); // false
|
||||
Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 4 }, { part: true }); // true
|
||||
|
||||
// flatten(array, [target])
|
||||
|
||||
let array3 = [1, [2, 3]];
|
||||
|
||||
let flattenedArray = Hoek.flatten(array); // results in [1, 2, 3]
|
||||
|
||||
array3 = [1, [2, 3]];
|
||||
const target1 = [4, [5]];
|
||||
|
||||
flattenedArray = Hoek.flatten(array3, target1); // results in [4, [5], 1, 2, 3]
|
||||
|
||||
// reach(obj, chain, [options])
|
||||
|
||||
let chain = 'a.b.c';
|
||||
let obj = { a: { b: { c: 1 } } };
|
||||
|
||||
Hoek.reach(obj, chain); // returns 1
|
||||
|
||||
chain = 'a.b.-1';
|
||||
const obj1 = { a: { b: [2, 3, 6] } };
|
||||
|
||||
Hoek.reach(obj1, chain); // returns 6
|
||||
|
||||
// reachTemplate(obj, template, [options])
|
||||
|
||||
chain = 'a.b.c';
|
||||
obj = { a: { b: { c: 1 } } };
|
||||
|
||||
Hoek.reachTemplate(obj, '1+{a.b.c}=2'); // returns '1+1=2'
|
||||
|
||||
// transform(obj, transform, [options])
|
||||
|
||||
const source1 = {
|
||||
address: {
|
||||
one: '123 main street',
|
||||
two: 'PO Box 1234'
|
||||
},
|
||||
title: 'Warehouse',
|
||||
state: 'CA'
|
||||
};
|
||||
|
||||
let result = Hoek.transform(source1, {
|
||||
'person.address.lineOne': 'address.one',
|
||||
'person.address.lineTwo': 'address.two',
|
||||
title: 'title',
|
||||
'person.address.region': 'state'
|
||||
});
|
||||
// Results in
|
||||
// {
|
||||
// person: {
|
||||
// address: {
|
||||
// lineOne: '123 main street',
|
||||
// lineTwo: 'PO Box 1234',
|
||||
// region: 'CA'
|
||||
// }
|
||||
// },
|
||||
// title: 'Warehouse'
|
||||
// }
|
||||
|
||||
// shallow(obj)
|
||||
|
||||
const shallow = Hoek.shallow({ a: { b: 1 } });
|
||||
|
||||
// stringify(obj)
|
||||
|
||||
let a: any = {};
|
||||
a.b = a;
|
||||
Hoek.stringify(a); // Returns '[Cannot display object: Converting circular structure to JSON]'
|
||||
|
||||
// Timer
|
||||
|
||||
const timerObj = new Hoek.Timer();
|
||||
console.log("Time is now: " + timerObj.ts);
|
||||
console.log(`Elapsed time from initialization: ${timerObj.elapsed()}milliseconds`);
|
||||
|
||||
// Bench
|
||||
|
||||
const benchObj = new Hoek.Bench();
|
||||
console.log(`Elapsed time from initialization: ${benchObj.elapsed()}milliseconds`);
|
||||
|
||||
// base64urlEncode(value)
|
||||
|
||||
Hoek.base64urlEncode("hoek");
|
||||
|
||||
// base64urlDecode(value)
|
||||
|
||||
Hoek.base64urlDecode("aG9law==");
|
||||
|
||||
// escapeHtml(string)
|
||||
|
||||
const string = '<html> hey </html>';
|
||||
const escapedString = Hoek.escapeHtml(string); // returns <html> hey </html>
|
||||
|
||||
// escapeHeaderAttribute(attribute)
|
||||
|
||||
a = Hoek.escapeHeaderAttribute('I said "go w\\o me"'); // returns I said \"go w\\o me\"
|
||||
|
||||
// escapeRegex(string)
|
||||
|
||||
a = Hoek.escapeRegex('4^f$s.4*5+-_?%=#!:@|~\\/`"(>)[<]d{}s,'); // returns 4\^f\$s\.4\*5\+\-_\?%\=#\!\:@\|~\\\/`"\(>\)\[<\]d\{\}s\,
|
||||
|
||||
// assert(condition, message)
|
||||
|
||||
const x = 1;
|
||||
const y = 2 as number;
|
||||
|
||||
Hoek.assert(x === y, 'x should equal y'); // Throws 'x should equal y'
|
||||
|
||||
Hoek.assert(x === y, new Error('x should equal y')); // Throws the given error object
|
||||
|
||||
// abort(message)
|
||||
|
||||
Hoek.abort("Error message");
|
||||
|
||||
// displayStack(slice)
|
||||
|
||||
const stack = Hoek.displayStack();
|
||||
console.log(stack);
|
||||
|
||||
// callStack(slice)
|
||||
|
||||
const stack2 = Hoek.callStack();
|
||||
console.log(stack2);
|
||||
|
||||
// nextTick(fn)
|
||||
|
||||
let myFn = () => {
|
||||
console.log('Do this later');
|
||||
};
|
||||
|
||||
const nextFn = Hoek.nextTick(myFn);
|
||||
|
||||
nextFn();
|
||||
console.log('Do this first');
|
||||
|
||||
// Results in:
|
||||
//
|
||||
// Do this first
|
||||
// Do this later
|
||||
|
||||
// once(fn)
|
||||
|
||||
myFn = () => {
|
||||
console.log('Ran myFn');
|
||||
};
|
||||
|
||||
const onceFn = Hoek.once(myFn);
|
||||
onceFn(); // results in "Ran myFn"
|
||||
onceFn(); // results in undefined
|
||||
|
||||
// ignore
|
||||
|
||||
Hoek.ignore();
|
||||
|
||||
// uniqueFilename(path, extension)
|
||||
|
||||
const result1 = Hoek.uniqueFilename('./test/modules', 'txt'); // results in "full/path/test/modules/{random}.txt"
|
||||
|
||||
// isInteger(value)
|
||||
|
||||
result = Hoek.isInteger('23');
|
||||
Vendored
-213
@@ -1,213 +0,0 @@
|
||||
// Type definitions for @hapi/hoek 6.2
|
||||
// Project: https://github.com/hapijs/hoek
|
||||
// Definitions by: Prashant Tiwari <https://github.com/prashaantt>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface ContainOptions {
|
||||
/** Perform a deep comparison of the values? */
|
||||
deep?: boolean;
|
||||
/** Allow only one occurrence of each value? */
|
||||
once?: boolean;
|
||||
/** Don't allow values not explicitly listed? */
|
||||
only?: boolean;
|
||||
/** Allow partial match of the values? */
|
||||
part?: boolean;
|
||||
}
|
||||
|
||||
export interface ReachOptions {
|
||||
/** String to split chain path on. Defaults to ".". */
|
||||
separator?: string;
|
||||
/** Value to return if the path or value is not present. Default is undefined. */
|
||||
default?: any;
|
||||
/** Throw an error on missing member? Default is false. */
|
||||
strict?: boolean;
|
||||
/** Allow traversing functions for properties? */
|
||||
functions?: boolean;
|
||||
}
|
||||
|
||||
// Object
|
||||
|
||||
/**
|
||||
* Clone an object or an array.
|
||||
*/
|
||||
export function clone<T>(obj: T): T;
|
||||
|
||||
/**
|
||||
* Clone an object or array.
|
||||
*/
|
||||
export function cloneWithShallow(obj: any, keys: string[]): any;
|
||||
|
||||
/**
|
||||
* Merge all the properties of source into target.
|
||||
*/
|
||||
export function merge<T1, T2>(target: T1, source: T2, isNullOverride?: boolean, isMergeArrays?: boolean): T1 & T2;
|
||||
|
||||
/**
|
||||
* Apply options to a copy of the defaults.
|
||||
*/
|
||||
export function applyToDefaults<T1, T2>(defaults: T1, options: T2, isNullOverride?: boolean): T1 & T2;
|
||||
|
||||
/**
|
||||
* Apply options to a copy of the defaults.
|
||||
*/
|
||||
export function applyToDefaultsWithShallow<T1, T2>(defaults: T1, options: T2, keys?: string[]): T1 & T2;
|
||||
|
||||
/**
|
||||
* Perform a deep comparison of the two values.
|
||||
*/
|
||||
export function deepEqual<T>(b: T, a: T, options?: any): T;
|
||||
|
||||
/**
|
||||
* Remove duplicate items from Array.
|
||||
*/
|
||||
export function unique<T>(array: T[], key?: string): T[];
|
||||
|
||||
/**
|
||||
* Convert an Array into an Object.
|
||||
*/
|
||||
export function mapToObject(array: any[], key?: string): any;
|
||||
|
||||
/**
|
||||
* Find the common unique items in two arrays.
|
||||
*/
|
||||
export function intersect(array1: any[], array2: any[]): any;
|
||||
|
||||
/**
|
||||
* Test if the reference value contains the provided values.
|
||||
*/
|
||||
export function contain(ref: any, values: any, options?: ContainOptions): boolean;
|
||||
|
||||
/**
|
||||
* Flatten an array.
|
||||
*/
|
||||
export function flatten(array: any[], target?: any[]): any[];
|
||||
|
||||
/**
|
||||
* Convert an object key chain string to reference.
|
||||
*/
|
||||
export function reach(obj: any, chain: any, options?: ReachOptions): any;
|
||||
|
||||
/**
|
||||
* Replace string parameters ({name}) with their corresponding object key values.
|
||||
*/
|
||||
export function reachTemplate(obj: any, template: string, options?: ReachOptions): any;
|
||||
|
||||
/**
|
||||
* Transform an existing object into a new one based on the supplied obj and transform map.
|
||||
*/
|
||||
export function transform(obj: any, transform: any, options?: ReachOptions): any;
|
||||
|
||||
/**
|
||||
* Perform a shallow copy by copying the references of all the top level children.
|
||||
*/
|
||||
export function shallow(obj: any): any;
|
||||
|
||||
/**
|
||||
* Convert an object to string. Any errors are caught and reported back in the form of the returned string.
|
||||
*/
|
||||
export function stringify(obj: any): string;
|
||||
|
||||
// Timer
|
||||
|
||||
/**
|
||||
* A Timer object.
|
||||
*/
|
||||
export class Timer {
|
||||
/** The number of milliseconds elapsed since the epoch. */
|
||||
ts: number;
|
||||
/** The time (ms) elapsed since the timer was created. */
|
||||
elapsed(): number;
|
||||
}
|
||||
|
||||
// Bench
|
||||
|
||||
/**
|
||||
* Same as Timer, except ts stores the internal node clock.
|
||||
*/
|
||||
export class Bench {
|
||||
/** The number of milliseconds on the node clock elapsed since the epoch. */
|
||||
ts: number;
|
||||
/** The time (ms) elapsed since the timer was created. */
|
||||
elapsed(): number;
|
||||
}
|
||||
|
||||
// Binary Encoding/Decoding
|
||||
|
||||
/**
|
||||
* Encode value of string or buffer type in Base64 or URL encoding.
|
||||
*/
|
||||
export function base64urlEncode(value: string): string;
|
||||
|
||||
/**
|
||||
* Decode string into Base64 or URL encoding.
|
||||
*/
|
||||
export function base64urlDecode(value: string): string;
|
||||
|
||||
// Escaping Characters
|
||||
|
||||
/**
|
||||
* Escape html characters.
|
||||
*/
|
||||
export function escapeHtml(htmlString: string): string;
|
||||
|
||||
/**
|
||||
* Escape attribute value for use in HTTP header.
|
||||
*/
|
||||
export function escapeHeaderAttribute(attribute: string): string;
|
||||
|
||||
/**
|
||||
* Escape string for Regex construction.
|
||||
*/
|
||||
export function escapeRegex(regexString: string): string;
|
||||
|
||||
// Errors
|
||||
|
||||
/**
|
||||
* Print message or throw error if condition fails.
|
||||
*/
|
||||
export function assert(condition: boolean, message: string | Error): void | Error;
|
||||
|
||||
/**
|
||||
* Throw if process.env.NODE_ENV === 'test'. Else display most recent stack and exit process.
|
||||
*/
|
||||
export function abort(message: string | Error): void;
|
||||
|
||||
/**
|
||||
* Display the trace stack.
|
||||
*/
|
||||
export function displayStack(slice?: any): string[];
|
||||
|
||||
/**
|
||||
* Return a trace stack array.
|
||||
*/
|
||||
export function callStack(slice?: any): any[];
|
||||
|
||||
// Function
|
||||
|
||||
/**
|
||||
* Wrap fn in process.nextTick.
|
||||
*/
|
||||
export function nextTick(fn: () => void): () => void;
|
||||
|
||||
/**
|
||||
* Make sure fn is only run once.
|
||||
*/
|
||||
export function once(fn: () => void): () => void;
|
||||
|
||||
/**
|
||||
* A simple no-op function.
|
||||
*/
|
||||
export function ignore(): void;
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
/**
|
||||
* path to prepend to a randomly generated file name.
|
||||
*/
|
||||
export function uniqueFilename(path: string, extension?: string): string;
|
||||
|
||||
/**
|
||||
* Check value to see if it is an integer.
|
||||
*/
|
||||
export function isInteger(value: any): boolean;
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/hoek": [
|
||||
"hapi__hoek"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__hoek-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,78 +0,0 @@
|
||||
import * as Iron from "@hapi/iron";
|
||||
|
||||
const options: Iron.SealOptions = {
|
||||
encryption: {
|
||||
saltBits: 256,
|
||||
algorithm: 'aes-256-cbc',
|
||||
iterations: 1,
|
||||
minPasswordlength: 32
|
||||
},
|
||||
integrity: {
|
||||
saltBits: 256,
|
||||
algorithm: 'sha256',
|
||||
iterations: 1,
|
||||
minPasswordlength: 32
|
||||
},
|
||||
ttl: 0,
|
||||
timestampSkewSec: 60,
|
||||
localtimeOffsetMsec: 0
|
||||
};
|
||||
|
||||
const algorithms: Iron.Algorithms = {
|
||||
'aes-128-ctr': { keyBits: 128, ivBits: 128 },
|
||||
'aes-256-cbc': { keyBits: 256, ivBits: 128 },
|
||||
sha256: { keyBits: 256 }
|
||||
};
|
||||
|
||||
const optionsGenerateKey: Iron.GenerateKeyOptions = {
|
||||
saltBits: 256,
|
||||
salt: '4d8nr9q384nr9q384nr93q8nruq9348run',
|
||||
algorithm: 'aes-128-ctr',
|
||||
iterations: 10000,
|
||||
iv: 'sdfsdfsdfsdfscdrgercgesrcgsercg',
|
||||
minPasswordlength: 32
|
||||
};
|
||||
|
||||
const obj: object = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: [3, 4, 5],
|
||||
d: {
|
||||
e: 'f'
|
||||
}
|
||||
};
|
||||
|
||||
Iron.seal(obj, 'password', options)
|
||||
.then((sealed: string) => {
|
||||
console.log(sealed);
|
||||
});
|
||||
|
||||
Iron.unseal('data', 'password', Iron.defaults)
|
||||
.then((unsealed: object) => {
|
||||
console.log(unsealed);
|
||||
});
|
||||
|
||||
Iron.generateKey('password', options.encryption)
|
||||
.then((value: Iron.Key) => {
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
Iron.generateKey('password', optionsGenerateKey)
|
||||
.then((value: Iron.Key) => {
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
Iron.encrypt('password', Iron.defaults.encryption, 'data')
|
||||
.then((obj: { data: Buffer, key: Iron.Key }) => {
|
||||
console.log(obj);
|
||||
});
|
||||
|
||||
Iron.decrypt('password', Iron.defaults.encryption, 'data')
|
||||
.then((buffer: Buffer) => {
|
||||
console.log(buffer);
|
||||
});
|
||||
|
||||
Iron.hmacWithPassword('password', Iron.defaults.integrity, 'data')
|
||||
.then((value: Iron.HMacResult) => {
|
||||
console.log(value);
|
||||
});
|
||||
Vendored
-100
@@ -1,100 +0,0 @@
|
||||
// Type definitions for @hapi/iron 5.1
|
||||
// Project: https://github.com/hueniverse/iron
|
||||
// Definitions by: Simon Schick <https://github.com/simonschick>
|
||||
// Rafael Souza Fijalkowski <https://github.com/rafaelsouzaf>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface SealOptionsSub {
|
||||
/**
|
||||
* the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result.
|
||||
*/
|
||||
saltBits: number;
|
||||
/**
|
||||
* the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time).
|
||||
*/
|
||||
algorithm: keyof Algorithms;
|
||||
/**
|
||||
* the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations
|
||||
* to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key.
|
||||
*/
|
||||
iterations: number;
|
||||
/**
|
||||
* minimum password size
|
||||
*/
|
||||
minPasswordlength: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* iron provides a few options for customizing the key derivation algorithm used to generate encryption and
|
||||
* integrity verification keys as well as the algorithms and salt sizes used.
|
||||
* For context [See docs](https://github.com/hueniverse/iron#options)
|
||||
*/
|
||||
export interface SealOptions {
|
||||
/**
|
||||
* defines the options used by the encryption process.
|
||||
*/
|
||||
encryption: SealOptionsSub;
|
||||
/**
|
||||
* defines the options used by the HMAC integrity verification process.
|
||||
*/
|
||||
integrity: SealOptionsSub;
|
||||
/**
|
||||
* sealed object lifetime in milliseconds where 0 means forever. Defaults to 0.
|
||||
*/
|
||||
ttl: number;
|
||||
/**
|
||||
* number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds.
|
||||
*/
|
||||
timestampSkewSec: number;
|
||||
/**
|
||||
* local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0.
|
||||
*/
|
||||
localtimeOffsetMsec: number;
|
||||
}
|
||||
|
||||
export interface Algorithms {
|
||||
'aes-128-ctr': {
|
||||
keyBits: number;
|
||||
ivBits: number;
|
||||
};
|
||||
'aes-256-cbc': {
|
||||
keyBits: number;
|
||||
ivBits: number;
|
||||
};
|
||||
'sha256': {
|
||||
keyBits: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface GenerateKeyOptions extends Pick<SealOptionsSub, 'algorithm' | 'iterations' | 'minPasswordlength'> {
|
||||
saltBits?: number;
|
||||
salt?: string;
|
||||
iv?: string;
|
||||
}
|
||||
|
||||
export interface Key {
|
||||
key: Buffer;
|
||||
salt: string;
|
||||
iv: string;
|
||||
}
|
||||
|
||||
export interface HMacResult {
|
||||
digest: string;
|
||||
salt: string;
|
||||
}
|
||||
|
||||
export const defaults: SealOptions;
|
||||
export const algorithms: Algorithms;
|
||||
export const macFormatVersion: string;
|
||||
export const macPrefix: string;
|
||||
|
||||
export function generateKey(password: string, options: GenerateKeyOptions): Promise<Key>;
|
||||
export function encrypt(password: string, options: GenerateKeyOptions, data: string): Promise<{ data: Buffer, key: Key }>;
|
||||
export function decrypt(password: string, options: GenerateKeyOptions, data: string): Promise<Buffer>;
|
||||
export function hmacWithPassword(password: string, options: GenerateKeyOptions, data: string): Promise<HMacResult>;
|
||||
export function seal(obj: object, password: string, options: SealOptions): Promise<string>;
|
||||
export function unseal(data: string, password: string, options: SealOptions): Promise<object>;
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/iron": [
|
||||
"hapi__iron"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__iron-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
import { script, assertions } from "@hapi/lab";
|
||||
|
||||
const { experiment, describe, suite, test, it, before, beforeEach, after, afterEach } = script();
|
||||
const expect = assertions.expect;
|
||||
const fail = assertions.fail;
|
||||
|
||||
experiment('math', () => {
|
||||
|
||||
before((done) => {
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
beforeEach((done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('returns true when 1 + 1 equals 2', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
experiment('math', () => {
|
||||
|
||||
before(() => {
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
test('returns true when 1 + 1 equals 2', () => {
|
||||
|
||||
return Promise.resolve()
|
||||
.then((aValue) => {
|
||||
|
||||
const expectedValue = aValue;
|
||||
expect(aValue).to.equal(expectedValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
experiment.only('with only experiment', () => {
|
||||
|
||||
test('this test will run', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
|
||||
test('another test that will run', (done) => {
|
||||
|
||||
expect(true).to.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
experiment('with only test', () => {
|
||||
|
||||
test.only('only this test will run', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
|
||||
test('another test that will not be executed', (done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('attaches notes', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done.note(`The current time is ${Date.now()}`);
|
||||
done();
|
||||
});
|
||||
|
||||
test('cleanups after test', (done, onCleanup) => {
|
||||
|
||||
if (onCleanup) {
|
||||
|
||||
onCleanup((next) => {
|
||||
|
||||
return next();
|
||||
});
|
||||
}
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
|
||||
experiment('my plan', () => {
|
||||
|
||||
test('only a single assertion executes', { plan: 1 }, (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
experiment('math', { timeout: 1000 }, () => {
|
||||
|
||||
before({ timeout: 500 }, (done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('returns true when 1 + 1 equals 2', { parallel: true }, (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('math', () => {
|
||||
|
||||
before((done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
after((done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
afterEach((done) => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('returns true when 1 + 1 equals 2', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
suite('math', () => {
|
||||
|
||||
test('returns true when 1 + 1 equals 2', (done) => {
|
||||
|
||||
expect(1 + 1).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('expectation', () => {
|
||||
|
||||
it('should be able to expect', (done) => {
|
||||
|
||||
expect(true).to.be.true();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should be able to fail (This test should fail)', (done) => {
|
||||
|
||||
fail('Should fail');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
Vendored
-188
@@ -1,188 +0,0 @@
|
||||
// Type definitions for @hapi/lab 18.1
|
||||
// Project: https://github.com/hapijs/lab
|
||||
// Definitions by: Prashant Tiwari <https://github.com/prashaantt>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** The test script. */
|
||||
export function script(options?: ScriptOptions): Lab & ExperimentAlt & TestAlt;
|
||||
/** Access the configured assertion library. */
|
||||
export const assertions: any;
|
||||
|
||||
interface Lab {
|
||||
/** Organise tests into an experiment */
|
||||
experiment(desc: string, cb: EmptyCallback): void;
|
||||
|
||||
/** Organise tests into an experiment with options */
|
||||
experiment(desc: string, options: ExperimentOptions, cb: EmptyCallback): void;
|
||||
|
||||
/** Create a test suite */
|
||||
describe(desc: string, cb: EmptyCallback): void;
|
||||
|
||||
/** Create a test suite with options */
|
||||
describe(desc: string, options: ExperimentOptions, cb: EmptyCallback): void;
|
||||
|
||||
/** Create a test suite */
|
||||
suite(desc: string, cb: EmptyCallback): void;
|
||||
|
||||
/** Create a test suite with options */
|
||||
suite(desc: string, options: ExperimentOptions, cb: EmptyCallback): void;
|
||||
|
||||
/** The test spec */
|
||||
test(desc: string, cb: TestCallback): void;
|
||||
|
||||
/** The test spec using a promise */
|
||||
test(desc: string, promise: TestPromise): void;
|
||||
|
||||
/** The test spec with options */
|
||||
test(desc: string, options: TestOptions, cb: TestCallback): void;
|
||||
|
||||
/** The test spec using a promise with options */
|
||||
test(desc: string, options: TestOptions, promise: TestPromise): void;
|
||||
|
||||
/** The test spec */
|
||||
it(desc: string, cb: TestCallback): void;
|
||||
|
||||
/** The test spec using a promise */
|
||||
it(desc: string, promise: TestPromise): void;
|
||||
|
||||
/** The test spec with options */
|
||||
it(desc: string, options: TestOptions, cb: TestCallback): void;
|
||||
|
||||
/** The test spec using a promise with options */
|
||||
it(desc: string, options: TestOptions, promise: TestPromise): void;
|
||||
|
||||
/** Perform async actions before the test suite */
|
||||
before(cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions before the test suite using a promise */
|
||||
before(promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions before the test suite with options */
|
||||
before(options: AsyncOptions, cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions before the test suite with otions, using a promise */
|
||||
before(options: AsyncOptions, promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions before each test */
|
||||
beforeEach(cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions before each test using a promise */
|
||||
beforeEach(promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions before each test with options */
|
||||
beforeEach(options: AsyncOptions, cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions before each test with options, using a promise */
|
||||
beforeEach(options: AsyncOptions, promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions after the test suite */
|
||||
after(cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions after the test suite using a promise */
|
||||
after(promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions after the test suite with options */
|
||||
after(options: AsyncOptions, cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions after the test suite with options, using a promise */
|
||||
after(options: AsyncOptions, promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions after each test */
|
||||
afterEach(cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions after each test using a promise */
|
||||
afterEach(promise: AsyncPromise): void;
|
||||
|
||||
/** Perform async actions after each test with options */
|
||||
afterEach(options: AsyncOptions, cb: AsyncCallback): void;
|
||||
|
||||
/** Perform async actions after each test with options, using a promise */
|
||||
afterEach(options: AsyncOptions, promise: AsyncPromise): void;
|
||||
}
|
||||
|
||||
interface ExperimentAlt {
|
||||
experiment: SkipOnlyExperiment;
|
||||
suite: SkipOnlyExperiment;
|
||||
describe: SkipOnlyExperiment;
|
||||
}
|
||||
|
||||
interface TestAlt {
|
||||
test: SkipOnlyTest;
|
||||
it: SkipOnlyTest;
|
||||
}
|
||||
|
||||
interface SkipOnlyExperiment {
|
||||
/** Skip this test suite */
|
||||
skip: ExperimentArgs & ExperimentWithOptionsArgs;
|
||||
|
||||
/** Only execute this test suite */
|
||||
only: ExperimentArgs & ExperimentWithOptionsArgs;
|
||||
}
|
||||
|
||||
interface SkipOnlyTest {
|
||||
/** Skip this test */
|
||||
skip: TestArgs & TestWithOptionsArgs;
|
||||
|
||||
/** Only execute this test */
|
||||
only: TestArgs & TestWithOptionsArgs;
|
||||
}
|
||||
|
||||
interface ScriptOptions {
|
||||
/** Enable auto-execution of the script? (true) */
|
||||
schedule?: boolean;
|
||||
|
||||
/** Pass Lab CLI options */
|
||||
cli?: any;
|
||||
}
|
||||
|
||||
interface ExperimentOptions {
|
||||
/** Set a specific timeout in milliseconds (2000) */
|
||||
timeout?: number;
|
||||
|
||||
/** Execute tests in parallel? (false) */
|
||||
parallel?: boolean;
|
||||
|
||||
/** Skip execution? (false) */
|
||||
skip?: boolean;
|
||||
|
||||
/** Execute only this test/experiment? (false) */
|
||||
only?: boolean;
|
||||
}
|
||||
|
||||
interface TestOptions extends ExperimentOptions {
|
||||
/** The expected number of assertions to execute */
|
||||
plan?: number;
|
||||
}
|
||||
|
||||
interface AsyncOptions {
|
||||
/** Set a specific timeout in milliseconds (disabled) */
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface DoneNote {
|
||||
/** Attach a note to the test case */
|
||||
note: (text: string) => void;
|
||||
}
|
||||
|
||||
type EmptyCallback = () => void;
|
||||
|
||||
type DoneFunction = (err?: Error) => void;
|
||||
|
||||
type CleanupFunction = (func: (next: Function) => void) => void;
|
||||
|
||||
type TestCallback = (done: DoneFunction & DoneNote, onCleanup?: CleanupFunction) => void;
|
||||
|
||||
type TestPromise = () => Promise<any>;
|
||||
|
||||
type AsyncCallback = (done: DoneFunction) => void;
|
||||
|
||||
type AsyncPromise = () => Promise<any>;
|
||||
|
||||
type ExperimentArgs = (desc: string, cb: EmptyCallback) => {};
|
||||
|
||||
type ExperimentWithOptionsArgs = (desc: string, options: ExperimentOptions, cb: EmptyCallback) => {};
|
||||
|
||||
type TestArgs = (desc: string, cb: TestCallback) => {};
|
||||
|
||||
type TestWithOptionsArgs = (desc: string, options: TestOptions, cb: TestCallback) => {}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/lab": [
|
||||
"hapi__lab"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__lab-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"npm-naming": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import Topo = require('@hapi/topo');
|
||||
|
||||
const morning = new Topo<string, 'breakfast' | 'prep' | 'dinner'>();
|
||||
|
||||
morning.add('Nap', { after: ['breakfast', 'prep'] }); // $ExpectType string[]
|
||||
morning.add('Nap', { after: 'foo' }); // $ExpectError
|
||||
morning.add(['Make toast', 'Pour juice'], { before: 'breakfast', group: 'prep' }); // $ExpectType string[]
|
||||
morning.add('Eat breakfast', { group: 'breakfast' }); // $ExpectType string[]
|
||||
|
||||
morning.nodes; // $ExpectType string[]
|
||||
|
||||
const dinner = new Topo<string, 'breakfast' | 'prep' | 'dinner'>();
|
||||
dinner.add('Eat dinner', { group: 'dinner', after: 'breakfast' }); // $ExpectType string[]
|
||||
|
||||
morning.merge(dinner);
|
||||
Vendored
-49
@@ -1,49 +0,0 @@
|
||||
// Type definitions for @hapi/topo 3.1
|
||||
// Project: https://github.com/hapijs/topo#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export = Topo;
|
||||
|
||||
/**
|
||||
* The Topo object is the container for topologically sorting a list of nodes with non-circular interdependencies.
|
||||
*/
|
||||
declare class Topo<TNode = any, TGroup = string> {
|
||||
/**
|
||||
* An array of the topologically sorted nodes. This list is renewed upon each call to `topo.add()`.
|
||||
*/
|
||||
nodes: TNode[];
|
||||
|
||||
/**
|
||||
* Specifies an additional node or list of nodes to be topologically sorted.
|
||||
*
|
||||
* @param nodes a mixed value or array of mixed values to be added as nodes to the topologically sorted list.
|
||||
* @param options optional sorting information about the `nodes`:
|
||||
* - `group` - a string naming the group to which `nodes` should be assigned. The group name `'?'` is reserved.
|
||||
* - `before` - a string or array of strings specifying the groups that `nodes` must precede in the topological sort.
|
||||
* - `after` - a string or array of strings specifying the groups that `nodes` must succeed in the topological sort.
|
||||
* - `sort` - a numerical value used to sort items when performing a `topo.merge()`.
|
||||
* @returns an array of the topologically sorted nodes.
|
||||
*/
|
||||
add(
|
||||
nodes: TNode | TNode[],
|
||||
options?: {
|
||||
group?: TGroup;
|
||||
before?: TGroup | TGroup[];
|
||||
after?: TGroup | TGroup[];
|
||||
sort?: number;
|
||||
}
|
||||
): TNode[];
|
||||
|
||||
/**
|
||||
* Merges another `Topo` object into the current object.
|
||||
* If the order in which items have been added to each list matters, use the `sort` option in `topo.add()`
|
||||
* with an incrementing value providing an absolute sort order among all items added to either object.
|
||||
*
|
||||
* @param others the other object or array of objects to be merged into the current one. `null` values are ignored.
|
||||
* @returns an array of the topologically sorted nodes. Will throw if a dependency error is found as a result of the combined items.
|
||||
*/
|
||||
merge(others: Topo<TNode, TGroup> | Array<Topo<TNode, TGroup>>): TNode[];
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/topo": [
|
||||
"hapi__topo"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__topo-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
import Http = require('http');
|
||||
import Wreck = require('@hapi/wreck');
|
||||
|
||||
Wreck.get('https://google.com/', {}).then((response) => {
|
||||
/* do stuff */
|
||||
});
|
||||
|
||||
|
||||
var method = 'GET'; // GET, POST, PUT, DELETE
|
||||
var uri = 'https://google.com/';
|
||||
var readableStream = Wreck.toReadableStream('foo=bar');
|
||||
|
||||
var wreck = Wreck.defaults({
|
||||
headers: { 'x-foo-bar': 123 }
|
||||
});
|
||||
|
||||
// cascading example -- does not alter `wreck`
|
||||
var wreckWithTimeout = wreck.defaults({
|
||||
timeout: 5
|
||||
});
|
||||
|
||||
// regression test for wreck with custom agent
|
||||
var wreckWithAgent = Wreck.defaults({
|
||||
agent: new Http.Agent(),
|
||||
})
|
||||
|
||||
// all attributes are optional
|
||||
var options = {
|
||||
maxBytes: 1048576, // 1 MB, default: unlimited
|
||||
rejectUnauthorized: true
|
||||
};
|
||||
|
||||
var optionalCallback = function (err: any, res: any) {
|
||||
|
||||
/* handle err if it exists, in which case res will be undefined */
|
||||
|
||||
// buffer the response stream
|
||||
Wreck.read(res, null).then((payload) => {
|
||||
/* do stuff */
|
||||
});
|
||||
};
|
||||
|
||||
var req = wreck.request(method, uri, options).then((response) => {
|
||||
/* do stuff */
|
||||
});
|
||||
Vendored
-86
@@ -1,86 +0,0 @@
|
||||
// Type definitions for @hapi/wreck 15.0
|
||||
// Project: https://github.com/hapijs/wreck
|
||||
// Definitions by: Marcin Porębski <https://github.com/marcinporebski>
|
||||
// Rodrigo Saboya <https://github.com/saboya>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Geoff Goodman <https://github.com/ggoodman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
import * as Boom from "@hapi/boom";
|
||||
import * as events from "events";
|
||||
import * as http from "http";
|
||||
import * as stream from "stream";
|
||||
import * as Url from "url";
|
||||
|
||||
interface RequestOptions {
|
||||
baseUrl?: string;
|
||||
socketPath? : string;
|
||||
payload?: any;
|
||||
headers?: { [key: string]: any };
|
||||
redirects?: number;
|
||||
redirect303?: boolean;
|
||||
beforeRedirect?: (redirectMethod: string, statusCode: number, location: string, resHeaders: { [key: string]: any }, redirectOptions: any, next: () => {}) => void;
|
||||
redirected?: (statusCode: number, location: string, req: http.ClientRequest) => void;
|
||||
timeout?: number;
|
||||
maxBytes?: number;
|
||||
rejectUnauthorized?: boolean;
|
||||
downstreamRes?: any;
|
||||
agent?: http.Agent | false;
|
||||
secureProtocol?: string;
|
||||
ciphers?: string;
|
||||
events?: boolean;
|
||||
}
|
||||
|
||||
interface ReadOptions {
|
||||
timeout?: number;
|
||||
json?: true | "strict" | "force";
|
||||
gunzip?: boolean | "force";
|
||||
maxBytes?: number;
|
||||
}
|
||||
|
||||
interface RequestResponse {
|
||||
res: http.IncomingMessage,
|
||||
payload: any,
|
||||
}
|
||||
|
||||
declare type RequestCallback = (uri: string, options: RequestOptions & { payload?: any }) => void;
|
||||
declare type ResponseCallback = (err: Boom | undefined, details: { req: http.ClientRequest, res: http.IncomingMessage | undefined, start: number, url: Url.URL }) => void;
|
||||
|
||||
declare class WreckEventEmitter extends events.EventEmitter {
|
||||
on(event: "request", listener: RequestCallback): this;
|
||||
on(event: "response", listener: ResponseCallback): this;
|
||||
}
|
||||
|
||||
interface WreckObject {
|
||||
defaults: (options: RequestOptions) => WreckObject;
|
||||
|
||||
request: (method: string, uri: string, options: RequestOptions) => Promise<http.IncomingMessage> & { req: http.ClientRequest };
|
||||
|
||||
read: (response: http.IncomingMessage, options: ReadOptions) => Promise<any>;
|
||||
|
||||
get: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
post: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
patch: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
put: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
delete: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
|
||||
toReadableStream: (payload: any, encoding?: string) => stream.Readable;
|
||||
|
||||
parseCacheControl: (field: string) => any;
|
||||
|
||||
agents: {
|
||||
http: http.Agent,
|
||||
https: http.Agent,
|
||||
httpsAllowUnauthorized: http.Agent
|
||||
};
|
||||
|
||||
events?: WreckEventEmitter;
|
||||
}
|
||||
|
||||
declare var wreck: WreckObject;
|
||||
|
||||
export = wreck;
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@hapi/wreck": [
|
||||
"hapi__wreck"
|
||||
],
|
||||
"@hapi/boom": [
|
||||
"hapi__boom"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi__wreck-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"npm-naming": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user