@authup/errors 1.0.0-beta.41 → 1.0.0-beta.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in/auth-header.d.ts +7 -0
- package/dist/built-in/auth-header.d.ts.map +1 -0
- package/dist/built-in/bad-request.d.ts +7 -0
- package/dist/built-in/bad-request.d.ts.map +1 -0
- package/dist/built-in/bearer-token.d.ts +2 -1
- package/dist/built-in/bearer-token.d.ts.map +1 -1
- package/dist/built-in/check.d.ts +19 -0
- package/dist/built-in/check.d.ts.map +1 -0
- package/dist/built-in/entity-conflict.d.ts +7 -0
- package/dist/built-in/entity-conflict.d.ts.map +1 -0
- package/dist/built-in/entity-credentials-invalid.d.ts +7 -0
- package/dist/built-in/entity-credentials-invalid.d.ts.map +1 -0
- package/dist/built-in/entity-inactive.d.ts +7 -0
- package/dist/built-in/entity-inactive.d.ts.map +1 -0
- package/dist/built-in/entity-not-found.d.ts +7 -0
- package/dist/built-in/entity-not-found.d.ts.map +1 -0
- package/dist/built-in/index.d.ts +9 -1
- package/dist/built-in/index.d.ts.map +1 -1
- package/dist/built-in/internal.d.ts +7 -0
- package/dist/built-in/internal.d.ts.map +1 -0
- package/dist/built-in/unauthorized.d.ts +7 -0
- package/dist/built-in/unauthorized.d.ts.map +1 -0
- package/dist/check.d.ts +24 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.mts +177 -857
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +312 -24
- package/dist/index.mjs.map +1 -1
- package/dist/module.d.ts +3 -3
- package/dist/module.d.ts.map +1 -1
- package/dist/normalize.d.ts +11 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/serialize.d.ts +15 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/status.d.ts +32 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/built-in/http.d.ts +0 -6
- package/dist/built-in/http.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,20 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
import { BadRequestError, HTTPErrorOptions, UnauthorizedError } from "@ebec/http";
|
|
3
|
-
import { URL as URL$1, URLSearchParams } from "node:url";
|
|
4
|
-
import { Duplex, Readable, Writable } from "node:stream";
|
|
5
|
-
import { EventEmitter } from "node:events";
|
|
6
|
-
import { Blob, File } from "node:buffer";
|
|
7
|
-
import { ConnectionOptions, TLSSocket } from "node:tls";
|
|
8
|
-
import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from "node:net";
|
|
1
|
+
import { BASE_ERROR_INSTANCE, BaseError, ErrorOptions, INSTANCEOF_PROPERTY, hasInstanceof, markInstanceof } from "@ebec/core";
|
|
9
2
|
import { Issue } from "validup";
|
|
10
3
|
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
type AuthupErrorOptions = ErrorOptions & {
|
|
6
|
+
data?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
type AuthupErrorInput = string | AuthupErrorOptions;
|
|
9
|
+
type AuthupEntityErrorOptions = AuthupErrorOptions & {
|
|
10
|
+
entity?: string;
|
|
11
|
+
};
|
|
12
|
+
type AuthupEntityErrorInput = string | AuthupEntityErrorOptions;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/module.d.ts
|
|
15
|
+
declare const AUTHUP_ERROR_INSTANCE: unique symbol;
|
|
16
|
+
declare class AuthupError extends BaseError {
|
|
17
|
+
readonly issues: Issue[];
|
|
18
|
+
readonly data?: Record<string, any>;
|
|
19
|
+
constructor(input?: AuthupErrorInput);
|
|
20
|
+
toJSON(): {
|
|
21
|
+
issues: Issue[];
|
|
22
|
+
name: string;
|
|
23
|
+
message: string;
|
|
24
|
+
code: string;
|
|
25
|
+
cause?: unknown;
|
|
26
|
+
errors?: unknown[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/built-in/unauthorized.d.ts
|
|
31
|
+
declare const UNAUTHORIZED_ERROR_INSTANCE: unique symbol;
|
|
32
|
+
declare class UnauthorizedError extends AuthupError {
|
|
33
|
+
constructor(input?: string | AuthupErrorOptions);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/built-in/auth-header.d.ts
|
|
37
|
+
declare const AUTH_HEADER_ERROR_INSTANCE: unique symbol;
|
|
38
|
+
declare class AuthHeaderError extends UnauthorizedError {
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
static unsupportedType(type: string): AuthHeaderError;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/built-in/bad-request.d.ts
|
|
44
|
+
declare const BAD_REQUEST_ERROR_INSTANCE: unique symbol;
|
|
45
|
+
declare class BadRequestError extends AuthupError {
|
|
46
|
+
constructor(input?: string | AuthupErrorOptions);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/built-in/bearer-token.d.ts
|
|
50
|
+
declare const BEARER_TOKEN_MALFORMED_ERROR_INSTANCE: unique symbol;
|
|
51
|
+
declare class BearerTokenMalformedError extends UnauthorizedError {
|
|
52
|
+
constructor(message?: string);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/built-in/entity-conflict.d.ts
|
|
56
|
+
declare const ENTITY_CONFLICT_ERROR_INSTANCE: unique symbol;
|
|
57
|
+
declare class EntityConflictError extends AuthupError {
|
|
58
|
+
constructor(input?: string | AuthupEntityErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/built-in/entity-credentials-invalid.d.ts
|
|
62
|
+
declare const ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE: unique symbol;
|
|
63
|
+
declare class EntityCredentialsInvalidError extends AuthupError {
|
|
64
|
+
constructor(input?: string | AuthupEntityErrorOptions);
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/built-in/entity-inactive.d.ts
|
|
68
|
+
declare const ENTITY_INACTIVE_ERROR_INSTANCE: unique symbol;
|
|
69
|
+
declare class EntityInactiveError extends AuthupError {
|
|
70
|
+
constructor(input?: string | AuthupEntityErrorOptions);
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/built-in/entity-not-found.d.ts
|
|
74
|
+
declare const ENTITY_NOT_FOUND_ERROR_INSTANCE: unique symbol;
|
|
75
|
+
declare class EntityNotFoundError extends AuthupError {
|
|
76
|
+
constructor(input?: string | AuthupEntityErrorOptions);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/built-in/internal.d.ts
|
|
80
|
+
declare const INTERNAL_ERROR_INSTANCE: unique symbol;
|
|
81
|
+
declare class InternalError extends AuthupError {
|
|
82
|
+
constructor(input?: string | AuthupErrorOptions);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/built-in/check.d.ts
|
|
86
|
+
declare function isAuthHeaderError(input: unknown): input is AuthHeaderError;
|
|
87
|
+
declare function isBearerTokenMalformedError(input: unknown): input is BearerTokenMalformedError;
|
|
88
|
+
declare function isBadRequestError(input: unknown): input is BadRequestError;
|
|
89
|
+
declare function isUnauthorizedError(input: unknown): input is UnauthorizedError;
|
|
90
|
+
declare function isEntityNotFoundError(input: unknown): input is EntityNotFoundError;
|
|
91
|
+
declare function isEntityConflictError(input: unknown): input is EntityConflictError;
|
|
92
|
+
declare function isEntityInactiveError(input: unknown): input is EntityInactiveError;
|
|
93
|
+
declare function isEntityCredentialsInvalidError(input: unknown): input is EntityCredentialsInvalidError;
|
|
94
|
+
declare function isInternalError(input: unknown): input is InternalError;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/check.d.ts
|
|
97
|
+
/**
|
|
98
|
+
* Duck-type guard for `Error`.
|
|
99
|
+
*
|
|
100
|
+
* Re-exports `@ebec/core`'s shape-based check: `input` matches when it
|
|
101
|
+
* carries the standard `name` / `message` / `stack` triplet, regardless
|
|
102
|
+
* of which realm or class hierarchy produced it. Use this instead of
|
|
103
|
+
* `instanceof Error` for cross-realm boundaries (worker threads,
|
|
104
|
+
* duplicate-module copies) where `instanceof` can yield false negatives.
|
|
105
|
+
*/
|
|
106
|
+
declare function isError(input: unknown): input is Error;
|
|
107
|
+
/**
|
|
108
|
+
* Duck-type guard for AuthupError.
|
|
109
|
+
*
|
|
110
|
+
* Fast path: input has the AuthupError marker in its `@instanceof` chain.
|
|
111
|
+
* Subclass instances also accumulate this marker, so this guard matches any
|
|
112
|
+
* AuthupError subclass (`OAuth2Error`, `JWTError`, etc.).
|
|
113
|
+
*
|
|
114
|
+
* Slow path: input is shape-compatible with AuthupError (BaseError + has
|
|
115
|
+
* `issues: Issue[]`). Catches cases where the marker is missing — plain
|
|
116
|
+
* objects rehydrated from JSON, older builds without the marker.
|
|
117
|
+
*/
|
|
118
|
+
declare function isAuthupError(input: unknown): input is AuthupError;
|
|
119
|
+
//#endregion
|
|
11
120
|
//#region src/constants.d.ts
|
|
12
121
|
declare enum ErrorCode {
|
|
122
|
+
BAD_REQUEST = "bad_request",
|
|
123
|
+
INTERNAL_ERROR = "internal_error",
|
|
13
124
|
HTTP_HEADER_AUTH_TYPE_UNSUPPORTED = "unsupported_auth_header_type",
|
|
14
125
|
HTTP_BEARER_TOKEN_MALFORMED = "bearer_token_malformed",
|
|
126
|
+
IDENTITY_UNAUTHORIZED = "identity_unauthorized",
|
|
15
127
|
ENTITY_CREDENTIALS_INVALID = "invalid_credentials",
|
|
16
128
|
ENTITY_INACTIVE = "entity_inactive",
|
|
17
129
|
ENTITY_NOT_FOUND = "entity_not_found",
|
|
130
|
+
ENTITY_CONFLICT = "entity_conflict",
|
|
131
|
+
ENTITY_RELATION_INVALID = "entity_relation_invalid",
|
|
132
|
+
REGISTRATION_DISABLED = "registration_disabled",
|
|
133
|
+
PASSWORD_RECOVERY_DISABLED = "password_recovery_disabled",
|
|
134
|
+
EMAIL_VERIFICATION_REQUIRED = "email_verification_required",
|
|
135
|
+
RESET_TOKEN_EXPIRED = "reset_token_expired",
|
|
136
|
+
STORAGE_INSUFFICIENT = "storage_insufficient",
|
|
18
137
|
JWK_INVALID = "jwk_invalid",
|
|
19
138
|
JWK_NOT_FOUND = "jwk_not_found",
|
|
20
139
|
JWT_INVALID = "invalid_token",
|
|
@@ -36,864 +155,65 @@ declare enum ErrorCode {
|
|
|
36
155
|
POLICY_EVALUATOR_CONTEXT_INVALID = "policy_evaluator_context_invalid"
|
|
37
156
|
}
|
|
38
157
|
//#endregion
|
|
39
|
-
//#region src/
|
|
40
|
-
declare class BearerTokenMalformedError extends UnauthorizedError {
|
|
41
|
-
constructor(message?: string);
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region ../../node_modules/undici/types/utility.d.ts
|
|
45
|
-
type AutocompletePrimitiveBaseType<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : never;
|
|
46
|
-
type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>);
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region ../../node_modules/undici/types/header.d.ts
|
|
158
|
+
//#region src/normalize.d.ts
|
|
49
159
|
/**
|
|
50
|
-
*
|
|
160
|
+
* Normalize an arbitrary thrown value into an `Error` instance.
|
|
161
|
+
*
|
|
162
|
+
* Useful at error-pipeline boundaries (catch blocks, error middleware,
|
|
163
|
+
* fallbacks) where TypeScript hands you `unknown` but downstream code
|
|
164
|
+
* wants a real `Error` to inspect or rethrow. Duck-typed: any value
|
|
165
|
+
* passing `isError` is returned as-is. Strings become `new Error(str)`;
|
|
166
|
+
* any other value is stringified.
|
|
51
167
|
*/
|
|
52
|
-
|
|
53
|
-
type HeaderNames = Autocomplete<'Accept' | 'Accept-CH' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges' | 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Age' | 'Allow' | 'Alt-Svc' | 'Alt-Used' | 'Authorization' | 'Cache-Control' | 'Clear-Site-Data' | 'Connection' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'Device-Memory' | 'ETag' | 'Expect' | 'Expect-CT' | 'Expires' | 'Forwarded' | 'From' | 'Host' | 'If-Match' | 'If-Modified-Since' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Keep-Alive' | 'Last-Modified' | 'Link' | 'Location' | 'Max-Forwards' | 'Origin' | 'Permissions-Policy' | 'Priority' | 'Proxy-Authenticate' | 'Proxy-Authorization' | 'Range' | 'Referer' | 'Referrer-Policy' | 'Retry-After' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-Purpose' | 'Sec-WebSocket-Accept' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'SourceMap' | 'Strict-Transport-Security' | 'TE' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Upgrade-Insecure-Requests' | 'User-Agent' | 'Vary' | 'Via' | 'WWW-Authenticate' | 'X-Content-Type-Options' | 'X-Frame-Options'>;
|
|
54
|
-
type IANARegisteredMimeType = Autocomplete<'audio/aac' | 'video/x-msvideo' | 'image/avif' | 'video/av1' | 'application/octet-stream' | 'image/bmp' | 'text/css' | 'text/csv' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'application/gzip' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'image/jpeg' | 'text/javascript' | 'application/json' | 'application/ld+json' | 'audio/x-midi' | 'audio/mpeg' | 'video/mp4' | 'video/mpeg' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'audio/opus' | 'font/otf' | 'application/pdf' | 'image/png' | 'application/rtf' | 'image/svg+xml' | 'image/tiff' | 'video/mp2t' | 'font/ttf' | 'text/plain' | 'application/wasm' | 'video/webm' | 'audio/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'video/3gpp' | 'video/3gpp2' | 'model/gltf+json' | 'model/gltf-binary'>;
|
|
55
|
-
type KnownHeaderValues = {
|
|
56
|
-
'content-type': IANARegisteredMimeType;
|
|
57
|
-
};
|
|
58
|
-
type HeaderRecord = { [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues ? KnownHeaderValues[Lowercase<K>] : string };
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region ../../node_modules/undici/types/readable.d.ts
|
|
61
|
-
declare class BodyReadable extends Readable {
|
|
62
|
-
constructor(opts: {
|
|
63
|
-
resume: (this: Readable, size: number) => void | null;
|
|
64
|
-
abort: () => void | null;
|
|
65
|
-
contentType?: string;
|
|
66
|
-
contentLength?: number;
|
|
67
|
-
highWaterMark?: number;
|
|
68
|
-
});
|
|
69
|
-
/** Consumes and returns the body as a string
|
|
70
|
-
* https://fetch.spec.whatwg.org/#dom-body-text
|
|
71
|
-
*/
|
|
72
|
-
text(): Promise<string>;
|
|
73
|
-
/** Consumes and returns the body as a JavaScript Object
|
|
74
|
-
* https://fetch.spec.whatwg.org/#dom-body-json
|
|
75
|
-
*/
|
|
76
|
-
json(): Promise<unknown>;
|
|
77
|
-
/** Consumes and returns the body as a Blob
|
|
78
|
-
* https://fetch.spec.whatwg.org/#dom-body-blob
|
|
79
|
-
*/
|
|
80
|
-
blob(): Promise<Blob>;
|
|
81
|
-
/** Consumes and returns the body as an Uint8Array
|
|
82
|
-
* https://fetch.spec.whatwg.org/#dom-body-bytes
|
|
83
|
-
*/
|
|
84
|
-
bytes(): Promise<Uint8Array>;
|
|
85
|
-
/** Consumes and returns the body as an ArrayBuffer
|
|
86
|
-
* https://fetch.spec.whatwg.org/#dom-body-arraybuffer
|
|
87
|
-
*/
|
|
88
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
89
|
-
/** Not implemented
|
|
90
|
-
*
|
|
91
|
-
* https://fetch.spec.whatwg.org/#dom-body-formdata
|
|
92
|
-
*/
|
|
93
|
-
formData(): Promise<never>;
|
|
94
|
-
/** Returns true if the body is not null and the body has been consumed
|
|
95
|
-
*
|
|
96
|
-
* Otherwise, returns false
|
|
97
|
-
*
|
|
98
|
-
* https://fetch.spec.whatwg.org/#dom-body-bodyused
|
|
99
|
-
*/
|
|
100
|
-
readonly bodyUsed: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* If body is null, it should return null as the body
|
|
103
|
-
*
|
|
104
|
-
* If body is not null, should return the body as a ReadableStream
|
|
105
|
-
*
|
|
106
|
-
* https://fetch.spec.whatwg.org/#dom-body-body
|
|
107
|
-
*/
|
|
108
|
-
readonly body: never | undefined;
|
|
109
|
-
/** Dumps the response body by reading `limit` number of bytes.
|
|
110
|
-
* @param opts.limit Number of bytes to read (optional) - Default: 131072
|
|
111
|
-
* @param opts.signal AbortSignal to cancel the operation (optional)
|
|
112
|
-
*/
|
|
113
|
-
dump(opts?: {
|
|
114
|
-
limit: number;
|
|
115
|
-
signal?: AbortSignal;
|
|
116
|
-
}): Promise<void>;
|
|
117
|
-
}
|
|
168
|
+
declare function normalizeError(input: unknown): Error;
|
|
118
169
|
//#endregion
|
|
119
|
-
//#region
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
|
|
135
|
-
toArray(): T[];
|
|
136
|
-
forEach(callbackfn: (value: T, index: number) => void): void;
|
|
137
|
-
some(predicate: (value: T, index: number) => unknown): boolean;
|
|
138
|
-
every(predicate: (value: T, index: number) => unknown): boolean;
|
|
139
|
-
find<S extends T>(predicate: (value: T, index: number) => value is S): S | undefined;
|
|
140
|
-
find(predicate: (value: T, index: number) => unknown): T | undefined;
|
|
141
|
-
readonly [Symbol.toStringTag]: string;
|
|
142
|
-
}
|
|
143
|
-
interface SpecIterableIterator<T> extends SpecIteratorObject<T> {
|
|
144
|
-
[Symbol.iterator](): SpecIterableIterator<T>;
|
|
145
|
-
}
|
|
146
|
-
interface SpecIterable<T> {
|
|
147
|
-
[Symbol.iterator](): SpecIterableIterator<T>;
|
|
148
|
-
}
|
|
149
|
-
type HeadersInit$1 = [string, string][] | HeaderRecord | Headers$1;
|
|
150
|
-
declare class Headers$1 implements SpecIterable<[string, string]> {
|
|
151
|
-
constructor(init?: HeadersInit$1);
|
|
152
|
-
readonly append: (name: string, value: string) => void;
|
|
153
|
-
readonly delete: (name: string) => void;
|
|
154
|
-
readonly get: (name: string) => string | null;
|
|
155
|
-
readonly has: (name: string) => boolean;
|
|
156
|
-
readonly set: (name: string, value: string) => void;
|
|
157
|
-
readonly getSetCookie: () => string[];
|
|
158
|
-
readonly forEach: (callbackfn: (value: string, key: string, iterable: Headers$1) => void, thisArg?: unknown) => void;
|
|
159
|
-
readonly keys: () => SpecIterableIterator<string>;
|
|
160
|
-
readonly values: () => SpecIterableIterator<string>;
|
|
161
|
-
readonly entries: () => SpecIterableIterator<[string, string]>;
|
|
162
|
-
readonly [Symbol.iterator]: () => SpecIterableIterator<[string, string]>;
|
|
163
|
-
}
|
|
170
|
+
//#region src/serialize.d.ts
|
|
171
|
+
/**
|
|
172
|
+
* Convert an `Error` (or any value with a `toJSON()` method) into a
|
|
173
|
+
* plain object suitable for embedding in a JSON response body.
|
|
174
|
+
*
|
|
175
|
+
* Calls `input.toJSON()` if present — preserves every attribute the
|
|
176
|
+
* error chose to surface (`code`, `cause`, `errors`, `issues`, `data`,
|
|
177
|
+
* AuthupError sub-class fields, ...). Falls back to spreading the
|
|
178
|
+
* Error's enumerable own properties alongside the standard
|
|
179
|
+
* `name` / `message` pair, so caller-attached fields survive.
|
|
180
|
+
*
|
|
181
|
+
* Pair with `normalizeError` to handle arbitrary thrown values:
|
|
182
|
+
* `serializeError(normalizeError(e))`.
|
|
183
|
+
*/
|
|
184
|
+
declare function serializeError(input: Error): Record<string, any>;
|
|
164
185
|
//#endregion
|
|
165
|
-
//#region
|
|
166
|
-
declare module 'node:buffer' {
|
|
167
|
-
interface File {
|
|
168
|
-
readonly [Symbol.toStringTag]: string;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
186
|
+
//#region src/status.d.ts
|
|
171
187
|
/**
|
|
172
|
-
*
|
|
188
|
+
* Default mapping from `ErrorCode` to HTTP status. Adapters apply this and
|
|
189
|
+
* may layer their own overrides on top. Codes not listed here fall back
|
|
190
|
+
* to 400 (Bad Request) — which is the right default for "validation /
|
|
191
|
+
* malformed-request" style errors.
|
|
192
|
+
*
|
|
193
|
+
* The mapping mirrors the HTTP statuses produced by the pre-refactor
|
|
194
|
+
* `@ebec/http`-coupled error classes, with one intentional change:
|
|
195
|
+
*
|
|
196
|
+
* - `OAUTH_CLIENT_INVALID`: 400 → **401**, per RFC 6749 §5.2 (`invalid_client`
|
|
197
|
+
* responses should use 401). Surfaces as a behavior change in HTTP-level
|
|
198
|
+
* tests asserting `status: 400, code: OAUTH_CLIENT_INVALID`.
|
|
173
199
|
*/
|
|
174
|
-
declare
|
|
200
|
+
declare const ERROR_CODE_TO_STATUS: Readonly<Partial<Record<`${ErrorCode}`, number>>>;
|
|
175
201
|
/**
|
|
176
|
-
*
|
|
202
|
+
* Resolve an HTTP status for a given error code. Unknown codes fall back
|
|
203
|
+
* to `fallback` (default 400).
|
|
177
204
|
*/
|
|
178
|
-
declare
|
|
179
|
-
/**
|
|
180
|
-
* Appends a new value onto an existing key inside a FormData object,
|
|
181
|
-
* or adds the key if it does not already exist.
|
|
182
|
-
*
|
|
183
|
-
* The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
|
|
184
|
-
*
|
|
185
|
-
* @param name The name of the field whose data is contained in `value`.
|
|
186
|
-
* @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
187
|
-
or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
|
|
188
|
-
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
189
|
-
*/
|
|
190
|
-
append(name: string, value: unknown, fileName?: string): void;
|
|
191
|
-
/**
|
|
192
|
-
* Set a new value for an existing key inside FormData,
|
|
193
|
-
* or add the new field if it does not already exist.
|
|
194
|
-
*
|
|
195
|
-
* @param name The name of the field whose data is contained in `value`.
|
|
196
|
-
* @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
197
|
-
or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
|
|
198
|
-
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
199
|
-
*
|
|
200
|
-
*/
|
|
201
|
-
set(name: string, value: unknown, fileName?: string): void;
|
|
202
|
-
/**
|
|
203
|
-
* Returns the first value associated with a given key from within a `FormData` object.
|
|
204
|
-
* If you expect multiple values and want all of them, use the `getAll()` method instead.
|
|
205
|
-
*
|
|
206
|
-
* @param {string} name A name of the value you want to retrieve.
|
|
207
|
-
*
|
|
208
|
-
* @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
|
|
209
|
-
*/
|
|
210
|
-
get(name: string): FormDataEntryValue | null;
|
|
211
|
-
/**
|
|
212
|
-
* Returns all the values associated with a given key from within a `FormData` object.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} name A name of the value you want to retrieve.
|
|
215
|
-
*
|
|
216
|
-
* @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
|
|
217
|
-
*/
|
|
218
|
-
getAll(name: string): FormDataEntryValue[];
|
|
219
|
-
/**
|
|
220
|
-
* Returns a boolean stating whether a `FormData` object contains a certain key.
|
|
221
|
-
*
|
|
222
|
-
* @param name A string representing the name of the key you want to test for.
|
|
223
|
-
*
|
|
224
|
-
* @return A boolean value.
|
|
225
|
-
*/
|
|
226
|
-
has(name: string): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Deletes a key and its value(s) from a `FormData` object.
|
|
229
|
-
*
|
|
230
|
-
* @param name The name of the key you want to delete.
|
|
231
|
-
*/
|
|
232
|
-
delete(name: string): void;
|
|
233
|
-
/**
|
|
234
|
-
* Executes given callback function for each field of the FormData instance
|
|
235
|
-
*/
|
|
236
|
-
forEach: (callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void, thisArg?: unknown) => void;
|
|
237
|
-
/**
|
|
238
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
|
|
239
|
-
* Each key is a `string`.
|
|
240
|
-
*/
|
|
241
|
-
keys: () => SpecIterableIterator<string>;
|
|
242
|
-
/**
|
|
243
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
|
|
244
|
-
* Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
|
|
245
|
-
*/
|
|
246
|
-
values: () => SpecIterableIterator<FormDataEntryValue>;
|
|
247
|
-
/**
|
|
248
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
|
|
249
|
-
* The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
|
|
250
|
-
*/
|
|
251
|
-
entries: () => SpecIterableIterator<[string, FormDataEntryValue]>;
|
|
252
|
-
/**
|
|
253
|
-
* An alias for FormData#entries()
|
|
254
|
-
*/
|
|
255
|
-
[Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>;
|
|
256
|
-
readonly [Symbol.toStringTag]: string;
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region ../../node_modules/undici/types/connector.d.ts
|
|
260
|
-
declare function buildConnector(options?: buildConnector.BuildOptions): buildConnector.connector;
|
|
261
|
-
declare namespace buildConnector {
|
|
262
|
-
export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
|
|
263
|
-
allowH2?: boolean;
|
|
264
|
-
maxCachedSessions?: number | null;
|
|
265
|
-
socketPath?: string | null;
|
|
266
|
-
timeout?: number | null;
|
|
267
|
-
port?: number;
|
|
268
|
-
keepAlive?: boolean | null;
|
|
269
|
-
keepAliveInitialDelay?: number | null;
|
|
270
|
-
typeOfService?: number | null;
|
|
271
|
-
};
|
|
272
|
-
export interface Options {
|
|
273
|
-
hostname: string;
|
|
274
|
-
host?: string;
|
|
275
|
-
protocol: string;
|
|
276
|
-
port: string;
|
|
277
|
-
servername?: string;
|
|
278
|
-
localAddress?: string | null;
|
|
279
|
-
socketPath?: string | null;
|
|
280
|
-
httpSocket?: Socket;
|
|
281
|
-
}
|
|
282
|
-
export type Callback = (...args: CallbackArgs) => void;
|
|
283
|
-
type CallbackArgs = [null, Socket | TLSSocket] | [Error, null];
|
|
284
|
-
export interface connector {
|
|
285
|
-
(options: buildConnector.Options, callback: buildConnector.Callback): void;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region ../../node_modules/undici/types/client-stats.d.ts
|
|
290
|
-
declare class ClientStats {
|
|
291
|
-
constructor(pool: Client);
|
|
292
|
-
/** If socket has open connection. */
|
|
293
|
-
connected: boolean;
|
|
294
|
-
/** Number of open socket connections in this client that do not have an active request. */
|
|
295
|
-
pending: number;
|
|
296
|
-
/** Number of currently active requests of this client. */
|
|
297
|
-
running: number;
|
|
298
|
-
/** Number of active, pending, or queued requests of this client. */
|
|
299
|
-
size: number;
|
|
300
|
-
}
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region ../../node_modules/undici/types/client.d.ts
|
|
303
|
-
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>;
|
|
205
|
+
declare function httpStatusFromCode(code: string, fallback?: number): number;
|
|
304
206
|
/**
|
|
305
|
-
*
|
|
207
|
+
* Resolve a semantic `ErrorCode` for a foreign HTTP status. Used at the
|
|
208
|
+
* boundary where a non-AuthupError (e.g. `@ebec/http` HTTPError thrown by
|
|
209
|
+
* the framework, or a foreign service response) enters our system and
|
|
210
|
+
* needs to be normalized into an `AuthupError` with an authup-vocabulary
|
|
211
|
+
* code. Status is the only stable handshake across the two vocabularies.
|
|
212
|
+
*
|
|
213
|
+
* Default mapping covers the common HTTP statuses. Anything 5xx
|
|
214
|
+
* collapses to `INTERNAL_ERROR`; unknown 4xx collapses to `BAD_REQUEST`.
|
|
306
215
|
*/
|
|
307
|
-
declare
|
|
308
|
-
constructor(url: string | URL$1, options?: Client.Options);
|
|
309
|
-
/** Property to get and set the pipelining factor. */
|
|
310
|
-
pipelining: number;
|
|
311
|
-
/** `true` after `client.close()` has been called. */
|
|
312
|
-
closed: boolean;
|
|
313
|
-
/** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
|
|
314
|
-
destroyed: boolean;
|
|
315
|
-
/** Aggregate stats for a Client. */
|
|
316
|
-
readonly stats: ClientStats; // Override dispatcher APIs.
|
|
317
|
-
override connect(options: ClientConnectOptions): Promise<Dispatcher.ConnectData>;
|
|
318
|
-
override connect(options: ClientConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
|
|
319
|
-
}
|
|
320
|
-
declare namespace Client {
|
|
321
|
-
export interface OptionsInterceptors {
|
|
322
|
-
Client: readonly Dispatcher.DispatchInterceptor[];
|
|
323
|
-
}
|
|
324
|
-
export interface Options {
|
|
325
|
-
/** TODO */
|
|
326
|
-
interceptors?: OptionsInterceptors;
|
|
327
|
-
/** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
|
|
328
|
-
maxHeaderSize?: number;
|
|
329
|
-
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|
330
|
-
headersTimeout?: number;
|
|
331
|
-
/** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
|
|
332
|
-
socketTimeout?: never;
|
|
333
|
-
/** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
|
|
334
|
-
requestTimeout?: never;
|
|
335
|
-
/** TODO */
|
|
336
|
-
connectTimeout?: number;
|
|
337
|
-
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|
338
|
-
bodyTimeout?: number;
|
|
339
|
-
/** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
|
|
340
|
-
idleTimeout?: never;
|
|
341
|
-
/** @deprecated unsupported keepAlive, use pipelining=0 instead */
|
|
342
|
-
keepAlive?: never;
|
|
343
|
-
/** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
|
|
344
|
-
keepAliveTimeout?: number;
|
|
345
|
-
/** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
|
|
346
|
-
maxKeepAliveTimeout?: never;
|
|
347
|
-
/** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
|
|
348
|
-
keepAliveMaxTimeout?: number;
|
|
349
|
-
/** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
|
|
350
|
-
keepAliveTimeoutThreshold?: number;
|
|
351
|
-
/** TODO */
|
|
352
|
-
socketPath?: string;
|
|
353
|
-
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
|
|
354
|
-
pipelining?: number;
|
|
355
|
-
/** @deprecated use the connect option instead */
|
|
356
|
-
tls?: never;
|
|
357
|
-
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|
358
|
-
strictContentLength?: boolean;
|
|
359
|
-
/** TODO */
|
|
360
|
-
maxCachedSessions?: number;
|
|
361
|
-
/** TODO */
|
|
362
|
-
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
|
|
363
|
-
/** TODO */
|
|
364
|
-
maxRequestsPerClient?: number;
|
|
365
|
-
/** TODO */
|
|
366
|
-
localAddress?: string;
|
|
367
|
-
/** Max response body size in bytes, -1 is disabled */
|
|
368
|
-
maxResponseSize?: number;
|
|
369
|
-
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
|
|
370
|
-
autoSelectFamily?: boolean;
|
|
371
|
-
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
|
|
372
|
-
autoSelectFamilyAttemptTimeout?: number;
|
|
373
|
-
/**
|
|
374
|
-
* @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
|
|
375
|
-
* @default false
|
|
376
|
-
*/
|
|
377
|
-
allowH2?: boolean;
|
|
378
|
-
/**
|
|
379
|
-
* @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
|
|
380
|
-
* @default 100
|
|
381
|
-
*/
|
|
382
|
-
maxConcurrentStreams?: number;
|
|
383
|
-
/**
|
|
384
|
-
* @description Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE).
|
|
385
|
-
* @default 262144
|
|
386
|
-
*/
|
|
387
|
-
initialWindowSize?: number;
|
|
388
|
-
/**
|
|
389
|
-
* @description Sets the HTTP/2 connection-level flow-control window size (ClientHttp2Session.setLocalWindowSize).
|
|
390
|
-
* @default 524288
|
|
391
|
-
*/
|
|
392
|
-
connectionWindowSize?: number;
|
|
393
|
-
/**
|
|
394
|
-
* @description Time interval between PING frames dispatch
|
|
395
|
-
* @default 60000
|
|
396
|
-
*/
|
|
397
|
-
pingInterval?: number;
|
|
398
|
-
}
|
|
399
|
-
export interface SocketInfo {
|
|
400
|
-
localAddress?: string;
|
|
401
|
-
localPort?: number;
|
|
402
|
-
remoteAddress?: string;
|
|
403
|
-
remotePort?: number;
|
|
404
|
-
remoteFamily?: string;
|
|
405
|
-
timeout?: number;
|
|
406
|
-
bytesWritten?: number;
|
|
407
|
-
bytesRead?: number;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region ../../node_modules/undici/types/errors.d.ts
|
|
412
|
-
declare namespace Errors {
|
|
413
|
-
export class UndiciError extends Error {
|
|
414
|
-
name: string;
|
|
415
|
-
code: string;
|
|
416
|
-
}
|
|
417
|
-
/** Connect timeout error. */
|
|
418
|
-
export class ConnectTimeoutError extends UndiciError {
|
|
419
|
-
name: 'ConnectTimeoutError';
|
|
420
|
-
code: 'UND_ERR_CONNECT_TIMEOUT';
|
|
421
|
-
}
|
|
422
|
-
/** A header exceeds the `headersTimeout` option. */
|
|
423
|
-
export class HeadersTimeoutError extends UndiciError {
|
|
424
|
-
name: 'HeadersTimeoutError';
|
|
425
|
-
code: 'UND_ERR_HEADERS_TIMEOUT';
|
|
426
|
-
}
|
|
427
|
-
/** Headers overflow error. */
|
|
428
|
-
export class HeadersOverflowError extends UndiciError {
|
|
429
|
-
name: 'HeadersOverflowError';
|
|
430
|
-
code: 'UND_ERR_HEADERS_OVERFLOW';
|
|
431
|
-
}
|
|
432
|
-
/** A body exceeds the `bodyTimeout` option. */
|
|
433
|
-
export class BodyTimeoutError extends UndiciError {
|
|
434
|
-
name: 'BodyTimeoutError';
|
|
435
|
-
code: 'UND_ERR_BODY_TIMEOUT';
|
|
436
|
-
}
|
|
437
|
-
export class ResponseError extends UndiciError {
|
|
438
|
-
constructor(message: string, code: number, options: {
|
|
439
|
-
headers?: IncomingHttpHeaders | string[] | null;
|
|
440
|
-
body?: null | Record<string, any> | string;
|
|
441
|
-
});
|
|
442
|
-
name: 'ResponseError';
|
|
443
|
-
code: 'UND_ERR_RESPONSE';
|
|
444
|
-
statusCode: number;
|
|
445
|
-
body: null | Record<string, any> | string;
|
|
446
|
-
headers: IncomingHttpHeaders | string[] | null;
|
|
447
|
-
}
|
|
448
|
-
/** Passed an invalid argument. */
|
|
449
|
-
export class InvalidArgumentError extends UndiciError {
|
|
450
|
-
name: 'InvalidArgumentError';
|
|
451
|
-
code: 'UND_ERR_INVALID_ARG';
|
|
452
|
-
}
|
|
453
|
-
/** Returned an invalid value. */
|
|
454
|
-
export class InvalidReturnValueError extends UndiciError {
|
|
455
|
-
name: 'InvalidReturnValueError';
|
|
456
|
-
code: 'UND_ERR_INVALID_RETURN_VALUE';
|
|
457
|
-
}
|
|
458
|
-
/** The request has been aborted by the user. */
|
|
459
|
-
export class RequestAbortedError extends UndiciError {
|
|
460
|
-
name: 'AbortError';
|
|
461
|
-
code: 'UND_ERR_ABORTED';
|
|
462
|
-
}
|
|
463
|
-
/** Expected error with reason. */
|
|
464
|
-
export class InformationalError extends UndiciError {
|
|
465
|
-
name: 'InformationalError';
|
|
466
|
-
code: 'UND_ERR_INFO';
|
|
467
|
-
}
|
|
468
|
-
/** Request body length does not match content-length header. */
|
|
469
|
-
export class RequestContentLengthMismatchError extends UndiciError {
|
|
470
|
-
name: 'RequestContentLengthMismatchError';
|
|
471
|
-
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
|
|
472
|
-
}
|
|
473
|
-
/** Response body length does not match content-length header. */
|
|
474
|
-
export class ResponseContentLengthMismatchError extends UndiciError {
|
|
475
|
-
name: 'ResponseContentLengthMismatchError';
|
|
476
|
-
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
|
|
477
|
-
}
|
|
478
|
-
/** Trying to use a destroyed client. */
|
|
479
|
-
export class ClientDestroyedError extends UndiciError {
|
|
480
|
-
name: 'ClientDestroyedError';
|
|
481
|
-
code: 'UND_ERR_DESTROYED';
|
|
482
|
-
}
|
|
483
|
-
/** Trying to use a closed client. */
|
|
484
|
-
export class ClientClosedError extends UndiciError {
|
|
485
|
-
name: 'ClientClosedError';
|
|
486
|
-
code: 'UND_ERR_CLOSED';
|
|
487
|
-
}
|
|
488
|
-
/** There is an error with the socket. */
|
|
489
|
-
export class SocketError extends UndiciError {
|
|
490
|
-
name: 'SocketError';
|
|
491
|
-
code: 'UND_ERR_SOCKET';
|
|
492
|
-
socket: Client.SocketInfo | null;
|
|
493
|
-
}
|
|
494
|
-
/** Encountered unsupported functionality. */
|
|
495
|
-
export class NotSupportedError extends UndiciError {
|
|
496
|
-
name: 'NotSupportedError';
|
|
497
|
-
code: 'UND_ERR_NOT_SUPPORTED';
|
|
498
|
-
}
|
|
499
|
-
/** No upstream has been added to the BalancedPool. */
|
|
500
|
-
export class BalancedPoolMissingUpstreamError extends UndiciError {
|
|
501
|
-
name: 'MissingUpstreamError';
|
|
502
|
-
code: 'UND_ERR_BPL_MISSING_UPSTREAM';
|
|
503
|
-
}
|
|
504
|
-
export class HTTPParserError extends UndiciError {
|
|
505
|
-
name: 'HTTPParserError';
|
|
506
|
-
code: string;
|
|
507
|
-
}
|
|
508
|
-
/** The response exceed the length allowed. */
|
|
509
|
-
export class ResponseExceededMaxSizeError extends UndiciError {
|
|
510
|
-
name: 'ResponseExceededMaxSizeError';
|
|
511
|
-
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
|
|
512
|
-
}
|
|
513
|
-
export class RequestRetryError extends UndiciError {
|
|
514
|
-
constructor(message: string, statusCode: number, headers?: IncomingHttpHeaders | string[] | null, body?: null | Record<string, any> | string);
|
|
515
|
-
name: 'RequestRetryError';
|
|
516
|
-
code: 'UND_ERR_REQ_RETRY';
|
|
517
|
-
statusCode: number;
|
|
518
|
-
data: {
|
|
519
|
-
count: number;
|
|
520
|
-
};
|
|
521
|
-
headers: Record<string, string | string[]>;
|
|
522
|
-
}
|
|
523
|
-
export class SecureProxyConnectionError extends UndiciError {
|
|
524
|
-
constructor(cause?: Error, message?: string, options?: Record<any, any>);
|
|
525
|
-
name: 'SecureProxyConnectionError';
|
|
526
|
-
code: 'UND_ERR_PRX_TLS';
|
|
527
|
-
}
|
|
528
|
-
export class MaxOriginsReachedError extends UndiciError {
|
|
529
|
-
name: 'MaxOriginsReachedError';
|
|
530
|
-
code: 'UND_ERR_MAX_ORIGINS_REACHED';
|
|
531
|
-
}
|
|
532
|
-
/** SOCKS5 proxy related error. */
|
|
533
|
-
export class Socks5ProxyError extends UndiciError {
|
|
534
|
-
constructor(message?: string, code?: string);
|
|
535
|
-
name: 'Socks5ProxyError';
|
|
536
|
-
code: string;
|
|
537
|
-
}
|
|
538
|
-
/** WebSocket decompressed message exceeded maximum size. */
|
|
539
|
-
export class MessageSizeExceededError extends UndiciError {
|
|
540
|
-
name: 'MessageSizeExceededError';
|
|
541
|
-
code: 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED';
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
//#endregion
|
|
545
|
-
//#region ../../node_modules/undici/types/dispatcher.d.ts
|
|
546
|
-
type AbortSignal$1 = unknown;
|
|
547
|
-
type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
|
|
548
|
-
/** Dispatcher is the core API used to dispatch requests. */
|
|
549
|
-
declare class Dispatcher extends EventEmitter {
|
|
550
|
-
/** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
|
|
551
|
-
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean;
|
|
552
|
-
/** Starts two-way communications with the requested resource. */
|
|
553
|
-
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void;
|
|
554
|
-
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>;
|
|
555
|
-
/** Compose a chain of dispatchers */
|
|
556
|
-
compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
|
|
557
|
-
compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
|
|
558
|
-
/** Performs an HTTP request. */
|
|
559
|
-
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void;
|
|
560
|
-
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>;
|
|
561
|
-
/** For easy use with `stream.pipeline`. */
|
|
562
|
-
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex;
|
|
563
|
-
/** A faster version of `Dispatcher.request`. */
|
|
564
|
-
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void;
|
|
565
|
-
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>;
|
|
566
|
-
/** Upgrade to a different protocol. */
|
|
567
|
-
upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
|
|
568
|
-
upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
|
|
569
|
-
/** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
|
|
570
|
-
close(callback: () => void): void;
|
|
571
|
-
close(): Promise<void>;
|
|
572
|
-
/** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
|
|
573
|
-
destroy(err: Error | null, callback: () => void): void;
|
|
574
|
-
destroy(callback: () => void): void;
|
|
575
|
-
destroy(err: Error | null): Promise<void>;
|
|
576
|
-
destroy(): Promise<void>;
|
|
577
|
-
on(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
578
|
-
on(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
579
|
-
on(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
580
|
-
on(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
581
|
-
once(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
582
|
-
once(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
583
|
-
once(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
584
|
-
once(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
585
|
-
off(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
586
|
-
off(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
587
|
-
off(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
588
|
-
off(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
589
|
-
addListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
590
|
-
addListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
591
|
-
addListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
592
|
-
addListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
593
|
-
removeListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
594
|
-
removeListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
595
|
-
removeListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
596
|
-
removeListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
597
|
-
prependListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
598
|
-
prependListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
599
|
-
prependListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
600
|
-
prependListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
601
|
-
prependOnceListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
|
|
602
|
-
prependOnceListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
603
|
-
prependOnceListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
604
|
-
prependOnceListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
|
|
605
|
-
listeners(eventName: 'connect'): ((origin: URL$1, targets: readonly Dispatcher[]) => void)[];
|
|
606
|
-
listeners(eventName: 'disconnect'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
607
|
-
listeners(eventName: 'connectionError'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
608
|
-
listeners(eventName: 'drain'): ((origin: URL$1) => void)[];
|
|
609
|
-
rawListeners(eventName: 'connect'): ((origin: URL$1, targets: readonly Dispatcher[]) => void)[];
|
|
610
|
-
rawListeners(eventName: 'disconnect'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
611
|
-
rawListeners(eventName: 'connectionError'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
612
|
-
rawListeners(eventName: 'drain'): ((origin: URL$1) => void)[];
|
|
613
|
-
emit(eventName: 'connect', origin: URL$1, targets: readonly Dispatcher[]): boolean;
|
|
614
|
-
emit(eventName: 'disconnect', origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
615
|
-
emit(eventName: 'connectionError', origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
616
|
-
emit(eventName: 'drain', origin: URL$1): boolean;
|
|
617
|
-
}
|
|
618
|
-
declare namespace Dispatcher {
|
|
619
|
-
export interface ComposedDispatcher extends Dispatcher {}
|
|
620
|
-
export type Dispatch = Dispatcher['dispatch'];
|
|
621
|
-
export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch;
|
|
622
|
-
export interface DispatchOptions {
|
|
623
|
-
origin?: string | URL$1;
|
|
624
|
-
path: string;
|
|
625
|
-
method: HttpMethod;
|
|
626
|
-
/** Default: `null` */
|
|
627
|
-
body?: string | Buffer | Uint8Array | Readable | null | FormData;
|
|
628
|
-
/** Default: `null` */
|
|
629
|
-
headers?: UndiciHeaders;
|
|
630
|
-
/** Query string params to be embedded in the request URL. Default: `null` */
|
|
631
|
-
query?: Record<string, any>;
|
|
632
|
-
/** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
|
|
633
|
-
idempotent?: boolean;
|
|
634
|
-
/** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. Defaults to `method !== 'HEAD'`. */
|
|
635
|
-
blocking?: boolean;
|
|
636
|
-
/** The IP Type of Service (ToS) value for the request socket. Must be an integer between 0 and 255. Default: `0` */
|
|
637
|
-
typeOfService?: number | null;
|
|
638
|
-
/** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
|
|
639
|
-
upgrade?: boolean | string | null;
|
|
640
|
-
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
|
|
641
|
-
headersTimeout?: number | null;
|
|
642
|
-
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
|
|
643
|
-
bodyTimeout?: number | null;
|
|
644
|
-
/** Whether the request should stablish a keep-alive or not. Default `false` */
|
|
645
|
-
reset?: boolean;
|
|
646
|
-
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
|
|
647
|
-
throwOnError?: boolean;
|
|
648
|
-
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
|
|
649
|
-
expectContinue?: boolean;
|
|
650
|
-
}
|
|
651
|
-
export interface ConnectOptions<TOpaque = null> {
|
|
652
|
-
origin: string | URL$1;
|
|
653
|
-
path: string;
|
|
654
|
-
/** Default: `null` */
|
|
655
|
-
headers?: UndiciHeaders;
|
|
656
|
-
/** Default: `null` */
|
|
657
|
-
signal?: AbortSignal$1 | EventEmitter | null;
|
|
658
|
-
/** This argument parameter is passed through to `ConnectData` */
|
|
659
|
-
opaque?: TOpaque;
|
|
660
|
-
/** Default: `null` */
|
|
661
|
-
responseHeaders?: 'raw' | null;
|
|
662
|
-
}
|
|
663
|
-
export interface RequestOptions<TOpaque = null> extends DispatchOptions {
|
|
664
|
-
/** Default: `null` */
|
|
665
|
-
opaque?: TOpaque;
|
|
666
|
-
/** Default: `null` */
|
|
667
|
-
signal?: AbortSignal$1 | EventEmitter | null;
|
|
668
|
-
/** Default: `null` */
|
|
669
|
-
onInfo?: (info: {
|
|
670
|
-
statusCode: number;
|
|
671
|
-
headers: Record<string, string | string[]>;
|
|
672
|
-
}) => void;
|
|
673
|
-
/** Default: `null` */
|
|
674
|
-
responseHeaders?: 'raw' | null;
|
|
675
|
-
/** Default: `64 KiB` */
|
|
676
|
-
highWaterMark?: number;
|
|
677
|
-
}
|
|
678
|
-
export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
|
|
679
|
-
/** `true` if the `handler` will return an object stream. Default: `false` */
|
|
680
|
-
objectMode?: boolean;
|
|
681
|
-
}
|
|
682
|
-
export interface UpgradeOptions {
|
|
683
|
-
path: string;
|
|
684
|
-
/** Default: `'GET'` */
|
|
685
|
-
method?: string;
|
|
686
|
-
/** Default: `null` */
|
|
687
|
-
headers?: UndiciHeaders;
|
|
688
|
-
/** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
|
|
689
|
-
protocol?: string;
|
|
690
|
-
/** Default: `null` */
|
|
691
|
-
signal?: AbortSignal$1 | EventEmitter | null;
|
|
692
|
-
/** Default: `null` */
|
|
693
|
-
responseHeaders?: 'raw' | null;
|
|
694
|
-
}
|
|
695
|
-
export interface ConnectData<TOpaque = null> {
|
|
696
|
-
statusCode: number;
|
|
697
|
-
headers: IncomingHttpHeaders;
|
|
698
|
-
socket: Duplex;
|
|
699
|
-
opaque: TOpaque;
|
|
700
|
-
}
|
|
701
|
-
export interface ResponseData<TOpaque = null> {
|
|
702
|
-
statusCode: number;
|
|
703
|
-
statusText: string;
|
|
704
|
-
headers: IncomingHttpHeaders;
|
|
705
|
-
body: BodyReadable & BodyMixin;
|
|
706
|
-
trailers: Record<string, string>;
|
|
707
|
-
opaque: TOpaque;
|
|
708
|
-
context: object;
|
|
709
|
-
}
|
|
710
|
-
export interface PipelineHandlerData<TOpaque = null> {
|
|
711
|
-
statusCode: number;
|
|
712
|
-
headers: IncomingHttpHeaders;
|
|
713
|
-
opaque: TOpaque;
|
|
714
|
-
body: BodyReadable;
|
|
715
|
-
context: object;
|
|
716
|
-
}
|
|
717
|
-
export interface StreamData<TOpaque = null> {
|
|
718
|
-
opaque: TOpaque;
|
|
719
|
-
trailers: Record<string, string>;
|
|
720
|
-
}
|
|
721
|
-
export interface UpgradeData<TOpaque = null> {
|
|
722
|
-
headers: IncomingHttpHeaders;
|
|
723
|
-
socket: Duplex;
|
|
724
|
-
opaque: TOpaque;
|
|
725
|
-
}
|
|
726
|
-
export interface StreamFactoryData<TOpaque = null> {
|
|
727
|
-
statusCode: number;
|
|
728
|
-
headers: IncomingHttpHeaders;
|
|
729
|
-
opaque: TOpaque;
|
|
730
|
-
context: object;
|
|
731
|
-
}
|
|
732
|
-
export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable;
|
|
733
|
-
export interface DispatchController {
|
|
734
|
-
get aborted(): boolean;
|
|
735
|
-
get paused(): boolean;
|
|
736
|
-
get reason(): Error | null;
|
|
737
|
-
abort(reason: Error): void;
|
|
738
|
-
pause(): void;
|
|
739
|
-
resume(): void;
|
|
740
|
-
}
|
|
741
|
-
export interface DispatchHandler {
|
|
742
|
-
onRequestStart?(controller: DispatchController, context: any): void;
|
|
743
|
-
onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
|
|
744
|
-
onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
|
|
745
|
-
onResponseData?(controller: DispatchController, chunk: Buffer): void;
|
|
746
|
-
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
|
|
747
|
-
onResponseError?(controller: DispatchController, error: Error): void;
|
|
748
|
-
/** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
|
|
749
|
-
/** @deprecated */
|
|
750
|
-
onConnect?(abort: (err?: Error) => void): void;
|
|
751
|
-
/** Invoked when an error has occurred. */
|
|
752
|
-
/** @deprecated */
|
|
753
|
-
onError?(err: Error): void;
|
|
754
|
-
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
|
|
755
|
-
/** @deprecated */
|
|
756
|
-
onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
|
|
757
|
-
/** Invoked when response is received, before headers have been read. **/
|
|
758
|
-
/** @deprecated */
|
|
759
|
-
onResponseStarted?(): void;
|
|
760
|
-
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
|
|
761
|
-
/** @deprecated */
|
|
762
|
-
onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
|
|
763
|
-
/** Invoked when response payload data is received. */
|
|
764
|
-
/** @deprecated */
|
|
765
|
-
onData?(chunk: Buffer): boolean;
|
|
766
|
-
/** Invoked when response payload and trailers have been received and the request has completed. */
|
|
767
|
-
/** @deprecated */
|
|
768
|
-
onComplete?(trailers: string[] | null): void;
|
|
769
|
-
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
|
|
770
|
-
/** @deprecated */
|
|
771
|
-
onBodySent?(chunkSize: number, totalBytesSent: number): void;
|
|
772
|
-
}
|
|
773
|
-
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable;
|
|
774
|
-
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>;
|
|
775
|
-
/**
|
|
776
|
-
* @link https://fetch.spec.whatwg.org/#body-mixin
|
|
777
|
-
*/
|
|
778
|
-
interface BodyMixin {
|
|
779
|
-
readonly body?: never;
|
|
780
|
-
readonly bodyUsed: boolean;
|
|
781
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
782
|
-
blob(): Promise<Blob>;
|
|
783
|
-
bytes(): Promise<Uint8Array>;
|
|
784
|
-
formData(): Promise<never>;
|
|
785
|
-
json(): Promise<unknown>;
|
|
786
|
-
text(): Promise<string>;
|
|
787
|
-
}
|
|
788
|
-
export interface DispatchInterceptor {
|
|
789
|
-
(dispatch: Dispatch): Dispatch;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
//#endregion
|
|
793
|
-
//#region ../../node_modules/undici/types/mock-interceptor.d.ts
|
|
794
|
-
/** The scope associated with a mock dispatch. */
|
|
795
|
-
declare class MockScope<TData extends object = object> {
|
|
796
|
-
constructor(mockDispatch: MockInterceptor.MockDispatch<TData>);
|
|
797
|
-
/** Delay a reply by a set amount of time in ms. */
|
|
798
|
-
delay(waitInMs: number): MockScope<TData>;
|
|
799
|
-
/** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
|
|
800
|
-
persist(): MockScope<TData>;
|
|
801
|
-
/** Define a reply for a set amount of matching requests. */
|
|
802
|
-
times(repeatTimes: number): MockScope<TData>;
|
|
803
|
-
}
|
|
804
|
-
/** The interceptor for a Mock. */
|
|
805
|
-
declare class MockInterceptor {
|
|
806
|
-
constructor(options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[]);
|
|
807
|
-
/** Mock an undici request with the defined reply. */
|
|
808
|
-
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>;
|
|
809
|
-
reply<TData extends object = object>(statusCode: number, data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>, responseOptions?: MockInterceptor.MockResponseOptions): MockScope<TData>;
|
|
810
|
-
/** Mock an undici request by throwing the defined reply error. */
|
|
811
|
-
replyWithError<TError extends Error = Error>(error: TError): MockScope;
|
|
812
|
-
/** Set default reply headers on the interceptor for subsequent mocked replies. */
|
|
813
|
-
defaultReplyHeaders(headers: IncomingHttpHeaders): MockInterceptor;
|
|
814
|
-
/** Set default reply trailers on the interceptor for subsequent mocked replies. */
|
|
815
|
-
defaultReplyTrailers(trailers: Record<string, string>): MockInterceptor;
|
|
816
|
-
/** Set automatically calculated content-length header on subsequent mocked replies. */
|
|
817
|
-
replyContentLength(): MockInterceptor;
|
|
818
|
-
}
|
|
819
|
-
declare namespace MockInterceptor {
|
|
820
|
-
/** MockInterceptor options. */
|
|
821
|
-
export interface Options {
|
|
822
|
-
/** Path to intercept on. */
|
|
823
|
-
path: string | RegExp | ((path: string) => boolean);
|
|
824
|
-
/** Method to intercept on. Defaults to GET. */
|
|
825
|
-
method?: string | RegExp | ((method: string) => boolean);
|
|
826
|
-
/** Body to intercept on. */
|
|
827
|
-
body?: string | RegExp | ((body: string) => boolean);
|
|
828
|
-
/** Headers to intercept on. */
|
|
829
|
-
headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
|
|
830
|
-
/** Query params to intercept on */
|
|
831
|
-
query?: Record<string, any>;
|
|
832
|
-
}
|
|
833
|
-
export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
|
|
834
|
-
times: number | null;
|
|
835
|
-
persist: boolean;
|
|
836
|
-
consumed: boolean;
|
|
837
|
-
data: MockDispatchData<TData, TError>;
|
|
838
|
-
}
|
|
839
|
-
export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
|
|
840
|
-
error: TError | null;
|
|
841
|
-
statusCode?: number;
|
|
842
|
-
data?: TData | string;
|
|
843
|
-
}
|
|
844
|
-
export interface MockResponseOptions {
|
|
845
|
-
headers?: IncomingHttpHeaders;
|
|
846
|
-
trailers?: Record<string, string>;
|
|
847
|
-
}
|
|
848
|
-
export interface MockResponseCallbackOptions {
|
|
849
|
-
path: string;
|
|
850
|
-
method: string;
|
|
851
|
-
headers?: Headers$1 | Record<string, string>;
|
|
852
|
-
origin?: string;
|
|
853
|
-
body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
|
|
854
|
-
}
|
|
855
|
-
export type MockResponseDataHandler<TData extends object = object> = (opts: MockResponseCallbackOptions) => TData | Buffer | string;
|
|
856
|
-
export type MockReplyOptionsCallback<TData extends object = object> = (opts: MockResponseCallbackOptions) => {
|
|
857
|
-
statusCode: number;
|
|
858
|
-
data?: TData | Buffer | string;
|
|
859
|
-
responseOptions?: MockResponseOptions;
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
//#endregion
|
|
863
|
-
//#region ../../node_modules/hapic/dist/header/authorization/constants.d.ts
|
|
864
|
-
declare enum AuthorizationHeaderType {
|
|
865
|
-
BEARER = "Bearer",
|
|
866
|
-
BASIC = "Basic",
|
|
867
|
-
X_API_KEY = "X-API-Key",
|
|
868
|
-
API_KEY = "API-Key"
|
|
869
|
-
}
|
|
870
|
-
//#endregion
|
|
871
|
-
//#region src/types.d.ts
|
|
872
|
-
type AuthupErrorOptions = HTTPErrorOptions & {
|
|
873
|
-
data?: Record<string, any>;
|
|
874
|
-
};
|
|
875
|
-
type AuthupErrorInput = string | AuthupErrorOptions;
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region src/module.d.ts
|
|
878
|
-
declare class AuthupError extends BadRequestError {
|
|
879
|
-
readonly issues: Issue[];
|
|
880
|
-
readonly data?: Record<string, any>;
|
|
881
|
-
constructor(input?: AuthupErrorInput);
|
|
882
|
-
toJSON(): {
|
|
883
|
-
issues: Issue[];
|
|
884
|
-
status: number;
|
|
885
|
-
name: string;
|
|
886
|
-
message: string;
|
|
887
|
-
code: string;
|
|
888
|
-
cause?: unknown;
|
|
889
|
-
errors?: unknown[];
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
//#endregion
|
|
893
|
-
//#region src/built-in/http.d.ts
|
|
894
|
-
declare class HTTPError extends AuthupError {
|
|
895
|
-
static unsupportedHeaderType(type: `${AuthorizationHeaderType}`): HTTPError;
|
|
896
|
-
}
|
|
216
|
+
declare function codeFromHttpStatus(status: number): ErrorCode;
|
|
897
217
|
//#endregion
|
|
898
|
-
export { AuthupError, AuthupErrorInput, AuthupErrorOptions, BearerTokenMalformedError, ErrorCode,
|
|
218
|
+
export { AUTHUP_ERROR_INSTANCE, AUTH_HEADER_ERROR_INSTANCE, AuthHeaderError, AuthupEntityErrorInput, AuthupEntityErrorOptions, AuthupError, AuthupErrorInput, AuthupErrorOptions, BAD_REQUEST_ERROR_INSTANCE, BASE_ERROR_INSTANCE, BEARER_TOKEN_MALFORMED_ERROR_INSTANCE, BadRequestError, BearerTokenMalformedError, ENTITY_CONFLICT_ERROR_INSTANCE, ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE, ENTITY_INACTIVE_ERROR_INSTANCE, ENTITY_NOT_FOUND_ERROR_INSTANCE, ERROR_CODE_TO_STATUS, EntityConflictError, EntityCredentialsInvalidError, EntityInactiveError, EntityNotFoundError, ErrorCode, INSTANCEOF_PROPERTY, INTERNAL_ERROR_INSTANCE, InternalError, UNAUTHORIZED_ERROR_INSTANCE, UnauthorizedError, codeFromHttpStatus, hasInstanceof, httpStatusFromCode, isAuthHeaderError, isAuthupError, isBadRequestError, isBearerTokenMalformedError, isEntityConflictError, isEntityCredentialsInvalidError, isEntityInactiveError, isEntityNotFoundError, isError, isInternalError, isUnauthorizedError, markInstanceof, normalizeError, serializeError };
|
|
899
219
|
//# sourceMappingURL=index.d.mts.map
|