@depup/h3 2.0.1-depup.0
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/LICENSE +21 -0
- package/README.md +25 -0
- package/bin/h3.mjs +36 -0
- package/changes.json +5 -0
- package/dist/THIRD-PARTY-LICENSES.md +70 -0
- package/dist/_entries/bun.d.mts +6 -0
- package/dist/_entries/bun.mjs +16 -0
- package/dist/_entries/cloudflare.d.mts +6 -0
- package/dist/_entries/cloudflare.mjs +16 -0
- package/dist/_entries/deno.d.mts +6 -0
- package/dist/_entries/deno.mjs +16 -0
- package/dist/_entries/generic.d.mts +6 -0
- package/dist/_entries/generic.mjs +16 -0
- package/dist/_entries/node.d.mts +10 -0
- package/dist/_entries/node.mjs +19 -0
- package/dist/_entries/service-worker.d.mts +6 -0
- package/dist/_entries/service-worker.mjs +16 -0
- package/dist/_utils.mjs +240 -0
- package/dist/cache.mjs +599 -0
- package/dist/cache2.mjs +50 -0
- package/dist/cors.mjs +292 -0
- package/dist/docs/0.guide/0.index/index.md +117 -0
- package/dist/docs/0.guide/1.basics/0.lifecycle.md +68 -0
- package/dist/docs/0.guide/1.basics/1.routing.md +167 -0
- package/dist/docs/0.guide/1.basics/2.middleware.md +97 -0
- package/dist/docs/0.guide/1.basics/3.handler.md +165 -0
- package/dist/docs/0.guide/1.basics/4.response.md +171 -0
- package/dist/docs/0.guide/1.basics/5.error.md +117 -0
- package/dist/docs/0.guide/1.basics/6.nested-apps.md +57 -0
- package/dist/docs/0.guide/2.rules.md +698 -0
- package/dist/docs/0.guide/3.api/0.h3.md +144 -0
- package/dist/docs/0.guide/3.api/1.h3event.md +160 -0
- package/dist/docs/0.guide/4.advanced/0.plugins.md +50 -0
- package/dist/docs/0.guide/4.advanced/1.websocket.md +176 -0
- package/dist/docs/0.guide/4.advanced/2.nightly.md +13 -0
- package/dist/docs/1.utils/0.index/index.md +46 -0
- package/dist/docs/1.utils/1.request.md +447 -0
- package/dist/docs/1.utils/2.response.md +172 -0
- package/dist/docs/1.utils/3.cookie.md +33 -0
- package/dist/docs/1.utils/4.security.md +175 -0
- package/dist/docs/1.utils/5.proxy.md +57 -0
- package/dist/docs/1.utils/6.mcp.md +75 -0
- package/dist/docs/1.utils/7.more.md +117 -0
- package/dist/docs/1.utils/8.community.md +48 -0
- package/dist/docs/2.examples/0.index/index.md +17 -0
- package/dist/docs/2.examples/1.handle-cookie.md +67 -0
- package/dist/docs/2.examples/2.handle-query.md +76 -0
- package/dist/docs/2.examples/3.handle-session.md +210 -0
- package/dist/docs/2.examples/4.serve-static-assets.md +66 -0
- package/dist/docs/2.examples/5.stream-response.md +76 -0
- package/dist/docs/2.examples/6.validate-data.md +193 -0
- package/dist/docs/3.migration/0.index/index.md +204 -0
- package/dist/docs/README.md +37 -0
- package/dist/h3.d.mts +1669 -0
- package/dist/h3.mjs +1809 -0
- package/dist/index.d.mts +1634 -0
- package/dist/match.d.mts +123 -0
- package/dist/middleware.mjs +123 -0
- package/dist/normalize.mjs +645 -0
- package/dist/path.mjs +42 -0
- package/dist/proxy.mjs +254 -0
- package/dist/response.mjs +465 -0
- package/dist/rules/cache.d.mts +29 -0
- package/dist/rules/cache.mjs +163 -0
- package/dist/rules/compiler.d.mts +94 -0
- package/dist/rules/compiler.mjs +173 -0
- package/dist/rules/index.d.mts +77 -0
- package/dist/rules/index.mjs +34 -0
- package/dist/rules/proxy.d.mts +3 -0
- package/dist/rules/proxy.mjs +14 -0
- package/dist/tracing.d.mts +33 -0
- package/dist/tracing.mjs +89 -0
- package/package.json +148 -0
package/dist/h3.d.mts
ADDED
|
@@ -0,0 +1,1669 @@
|
|
|
1
|
+
import { FetchHandler, ServerRequest, ServerRequestContext, ServerRuntimeContext } from "srvx";
|
|
2
|
+
declare const kGetSession: unique symbol;
|
|
3
|
+
declare const kSessionNew: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Stringify options.
|
|
6
|
+
*/
|
|
7
|
+
interface CookieStringifyOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
|
10
|
+
* Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
|
|
11
|
+
* a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
|
|
12
|
+
*
|
|
13
|
+
* @default encodeURIComponent
|
|
14
|
+
*/
|
|
15
|
+
encode?: (str: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies a function that will be used to coerce non-string values to a string.
|
|
18
|
+
*
|
|
19
|
+
* @default JSON.stringify
|
|
20
|
+
*/
|
|
21
|
+
stringify?: (value: unknown) => string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Set-Cookie object.
|
|
25
|
+
*/
|
|
26
|
+
interface SetCookie {
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the name of the cookie.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies the string to be the value for the cookie.
|
|
33
|
+
*/
|
|
34
|
+
value: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
|
37
|
+
*
|
|
38
|
+
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
|
39
|
+
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
|
40
|
+
* so if both are set, they should point to the same date and time.
|
|
41
|
+
*/
|
|
42
|
+
maxAge?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
|
45
|
+
* When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over.
|
|
46
|
+
*
|
|
47
|
+
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
|
48
|
+
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
|
49
|
+
* so if both are set, they should point to the same date and time.
|
|
50
|
+
*/
|
|
51
|
+
expires?: Date;
|
|
52
|
+
/**
|
|
53
|
+
* Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
|
54
|
+
* When no domain is set, clients consider the cookie to apply to the current domain only.
|
|
55
|
+
*/
|
|
56
|
+
domain?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
|
59
|
+
* When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
|
60
|
+
*/
|
|
61
|
+
path?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
|
64
|
+
* When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
|
65
|
+
*/
|
|
66
|
+
httpOnly?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
|
69
|
+
* When enabled, clients will only send the cookie back if the browser has an HTTPS connection.
|
|
70
|
+
*/
|
|
71
|
+
secure?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
|
74
|
+
* When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
|
75
|
+
*
|
|
76
|
+
* This is an attribute that has not yet been fully standardized, and may change in the future.
|
|
77
|
+
* This also means clients may ignore this attribute until they understand it. More information
|
|
78
|
+
* about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
|
79
|
+
*/
|
|
80
|
+
partitioned?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
|
83
|
+
*
|
|
84
|
+
* - `'low'` will set the `Priority` attribute to `Low`.
|
|
85
|
+
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
|
86
|
+
* - `'high'` will set the `Priority` attribute to `High`.
|
|
87
|
+
*
|
|
88
|
+
* More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
|
89
|
+
*/
|
|
90
|
+
priority?: "low" | "medium" | "high";
|
|
91
|
+
/**
|
|
92
|
+
* Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
|
93
|
+
*
|
|
94
|
+
* - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
|
95
|
+
* - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
|
96
|
+
* - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
|
97
|
+
* - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
|
98
|
+
*
|
|
99
|
+
* More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
|
100
|
+
*/
|
|
101
|
+
sameSite?: boolean | "lax" | "strict" | "none";
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Backward compatibility serialize options.
|
|
105
|
+
*/
|
|
106
|
+
type CookieSerializeOptions = CookieStringifyOptions & Omit<SetCookie, "name" | "value">;
|
|
107
|
+
/** Algorithm used for encryption and decryption. */
|
|
108
|
+
type EncryptionAlgorithm = "aes-128-ctr" | "aes-256-cbc";
|
|
109
|
+
/** Algorithm used for integrity verification. */
|
|
110
|
+
type IntegrityAlgorithm = "sha256";
|
|
111
|
+
/** @internal */
|
|
112
|
+
type _Algorithm = EncryptionAlgorithm | IntegrityAlgorithm;
|
|
113
|
+
/**
|
|
114
|
+
* Options for customizing the key derivation algorithm used to generate encryption and integrity verification keys as well as the algorithms and salt sizes used.
|
|
115
|
+
*/
|
|
116
|
+
type SealOptions = Readonly<{
|
|
117
|
+
/** Encryption step options. */
|
|
118
|
+
encryption: SealOptionsSub<EncryptionAlgorithm>;
|
|
119
|
+
/** Integrity step options. */
|
|
120
|
+
integrity: SealOptionsSub<IntegrityAlgorithm>;
|
|
121
|
+
ttl: number;
|
|
122
|
+
/** Number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. */
|
|
123
|
+
timestampSkewSec: number;
|
|
124
|
+
/**
|
|
125
|
+
* Local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0.
|
|
126
|
+
*/
|
|
127
|
+
localtimeOffsetMsec: number;
|
|
128
|
+
}>;
|
|
129
|
+
/** `seal()` method options. */
|
|
130
|
+
type SealOptionsSub<Algorithm extends _Algorithm = _Algorithm> = Readonly<{
|
|
131
|
+
/** The length of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result). Defaults to 256. */
|
|
132
|
+
saltBits: number;
|
|
133
|
+
/** The algorithm used. Defaults to 'aes-256-cbc' for encryption and 'sha256' for integrity. */
|
|
134
|
+
algorithm: Algorithm;
|
|
135
|
+
/** The number of iterations used to derive a key from the password. Defaults to 1. */
|
|
136
|
+
iterations: number;
|
|
137
|
+
/** Minimum password size. Defaults to 32. */
|
|
138
|
+
minPasswordlength: number;
|
|
139
|
+
}>;
|
|
140
|
+
type SessionDataT = Record<string, any>;
|
|
141
|
+
export type SessionData<T extends SessionDataT = SessionDataT> = Partial<T>;
|
|
142
|
+
export interface Session<T extends SessionDataT = SessionDataT> {
|
|
143
|
+
id: string;
|
|
144
|
+
/** Time the session was created. The point `maxAge` is measured from. */
|
|
145
|
+
createdAt: number;
|
|
146
|
+
/**
|
|
147
|
+
* Time the session was last resealed. Only stamped when `idleTimeout` is set,
|
|
148
|
+
* and the point the idle window is measured from.
|
|
149
|
+
*/
|
|
150
|
+
lastSeenAt?: number;
|
|
151
|
+
data: SessionData<T>;
|
|
152
|
+
[kGetSession]?: Promise<Session<T>>;
|
|
153
|
+
/** Set on a session created in-memory for this request and not yet persisted */
|
|
154
|
+
[kSessionNew]?: true;
|
|
155
|
+
}
|
|
156
|
+
export interface SessionManager<T extends SessionDataT = SessionDataT> {
|
|
157
|
+
readonly id: string | undefined;
|
|
158
|
+
readonly data: SessionData<T>;
|
|
159
|
+
update: (update: SessionUpdate<T>) => Promise<SessionManager<T>>;
|
|
160
|
+
clear: () => Promise<SessionManager<T>>;
|
|
161
|
+
}
|
|
162
|
+
export interface SessionConfig {
|
|
163
|
+
/**
|
|
164
|
+
* Private key used to seal session tokens. Must be at least 32 characters.
|
|
165
|
+
*
|
|
166
|
+
* Its entropy is the security boundary: a stolen cookie can be brute-forced
|
|
167
|
+
* offline, so generate this from a cryptographically random source (e.g.
|
|
168
|
+
* `crypto.randomBytes(32).toString("base64")`) — a guessable passphrase is
|
|
169
|
+
* unsafe even at 32+ characters.
|
|
170
|
+
*/
|
|
171
|
+
password: string;
|
|
172
|
+
/**
|
|
173
|
+
* Absolute session lifetime in seconds, counted from when the session was
|
|
174
|
+
* created. Reached regardless of how active the user is.
|
|
175
|
+
*/
|
|
176
|
+
maxAge?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Sliding session lifetime in seconds, counted from the last request. An
|
|
179
|
+
* active user stays signed in; an idle one is signed out after this long.
|
|
180
|
+
*
|
|
181
|
+
* Equivalent to `rolling` in express-session and koa-session, but with its own
|
|
182
|
+
* duration instead of reinterpreting `maxAge` — so `maxAge` remains available
|
|
183
|
+
* as an absolute cap on top of the idle window rather than being replaced.
|
|
184
|
+
*
|
|
185
|
+
* H3 moves the window forward by resealing the session cookie with the reseal
|
|
186
|
+
* time stamped into it as `lastSeenAt`; `createdAt` is untouched. Only
|
|
187
|
+
* cookie-based sessions slide: a session read from the session header cannot
|
|
188
|
+
* be resealed, so it expires `idleTimeout` after its seal was issued.
|
|
189
|
+
*
|
|
190
|
+
* The reseal is throttled to once per half window (writing the session
|
|
191
|
+
* reseals it too, and counts), so `lastSeenAt` can trail the last request by
|
|
192
|
+
* up to half of `idleTimeout`. An idle session is therefore signed out
|
|
193
|
+
* between `idleTimeout / 2` and `idleTimeout` after the last request — never
|
|
194
|
+
* later, and never while the user keeps making requests.
|
|
195
|
+
*/
|
|
196
|
+
idleTimeout?: number;
|
|
197
|
+
/** default is h3 */
|
|
198
|
+
name?: string;
|
|
199
|
+
/** Default is secure, httpOnly, sameSite lax, / */
|
|
200
|
+
cookie?: false | (CookieSerializeOptions & {
|
|
201
|
+
chunkMaxLength?: number;
|
|
202
|
+
});
|
|
203
|
+
/** Default is x-h3-session / x-{name}-session */
|
|
204
|
+
sessionHeader?: false | string;
|
|
205
|
+
/**
|
|
206
|
+
* Overrides for the iron seal (algorithms, PBKDF2 iterations, TTL, clock skew).
|
|
207
|
+
*
|
|
208
|
+
* `SealOptions` has no optional fields, so an override must specify all of
|
|
209
|
+
* them. Session expiration is enforced by `maxAge`/`idleTimeout` independently
|
|
210
|
+
* of the seal `ttl` set here, so a shorter or zeroed `ttl` cannot extend a
|
|
211
|
+
* session beyond those limits.
|
|
212
|
+
*/
|
|
213
|
+
seal?: SealOptions;
|
|
214
|
+
/**
|
|
215
|
+
* Set to `false` to reject sessions sealed with the legacy default of 1
|
|
216
|
+
* PBKDF2 iteration instead of unsealing and resealing them.
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
legacySealFallback?: boolean;
|
|
220
|
+
crypto?: Crypto;
|
|
221
|
+
/** Default is Crypto.randomUUID */
|
|
222
|
+
generateId?: () => string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Create a session manager for the current request.
|
|
226
|
+
*
|
|
227
|
+
* Starts a session if the request does not carry one, persisting it so its id
|
|
228
|
+
* is stable across requests. Use {@link getSession} to read a session without
|
|
229
|
+
* starting one.
|
|
230
|
+
*/
|
|
231
|
+
export declare function useSession<T extends SessionData = SessionData>(event: HTTPEvent, config: SessionConfig): Promise<SessionManager<T>>;
|
|
232
|
+
/**
|
|
233
|
+
* Get the session for the current request.
|
|
234
|
+
*
|
|
235
|
+
* A request without a session gets a new one initialized in memory only — no
|
|
236
|
+
* `Set-Cookie` is issued until something is stored with {@link updateSession},
|
|
237
|
+
* so reading the session (an auth check, for example) does not start one for
|
|
238
|
+
* anonymous visitors. Its `id` is therefore only stable across requests once
|
|
239
|
+
* the session has been written; use {@link useSession} to start one eagerly.
|
|
240
|
+
*/
|
|
241
|
+
export declare function getSession<T extends SessionData = SessionData>(event: HTTPEvent, config: SessionConfig): Promise<Session<T>>;
|
|
242
|
+
type SessionUpdate<T extends SessionData = SessionData> = Partial<SessionData<T>> | ((oldData: SessionData<T>) => Partial<SessionData<T>> | undefined);
|
|
243
|
+
/**
|
|
244
|
+
* Update the session data for the current request.
|
|
245
|
+
*/
|
|
246
|
+
export declare function updateSession<T extends SessionData = SessionData>(event: HTTPEvent, config: SessionConfig, update?: SessionUpdate<T>): Promise<Session<T>>;
|
|
247
|
+
/**
|
|
248
|
+
* Encrypt and sign the session data for the current request.
|
|
249
|
+
*/
|
|
250
|
+
export declare function sealSession<T extends SessionData = SessionData>(event: HTTPEvent, config: SessionConfig): Promise<string>;
|
|
251
|
+
/**
|
|
252
|
+
* Decrypt and verify the session data for the current request.
|
|
253
|
+
*/
|
|
254
|
+
export declare function unsealSession(_event: HTTPEvent, config: SessionConfig, sealed: string): Promise<Partial<Session>>;
|
|
255
|
+
/**
|
|
256
|
+
* Clear the session data for the current request.
|
|
257
|
+
*/
|
|
258
|
+
export declare function clearSession(event: HTTPEvent, config: Partial<SessionConfig>): Promise<void>;
|
|
259
|
+
//#region src/fetch.d.ts
|
|
260
|
+
type TypedHeaderName<TypedHeaderValues> = Extract<keyof TypedHeaderValues, string> | string & {};
|
|
261
|
+
type TypedHeaderValue<TypedHeaderValues, Name extends string> = Lowercase<Name> extends keyof TypedHeaderValues ? Extract<TypedHeaderValues[Lowercase<Name>], string> : string;
|
|
262
|
+
interface TypedHeaders<TypedHeaderValues extends Record<string, string> | unknown> extends Omit<Headers, "append" | "delete" | "get" | "getSetCookie" | "has" | "set" | "forEach"> {
|
|
263
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */
|
|
264
|
+
append: <Name extends TypedHeaderName<TypedHeaderValues>>(name: Name, value: TypedHeaderValue<TypedHeaderValues, Name>) => void;
|
|
265
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */
|
|
266
|
+
delete: <Name extends TypedHeaderName<TypedHeaderValues>>(name: Name) => void;
|
|
267
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */
|
|
268
|
+
get: <Name extends TypedHeaderName<TypedHeaderValues>>(name: Name) => TypedHeaderValue<TypedHeaderValues, Name> | null;
|
|
269
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) */
|
|
270
|
+
getSetCookie: () => string[];
|
|
271
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */
|
|
272
|
+
has: <Name extends TypedHeaderName<TypedHeaderValues>>(name: Name) => boolean;
|
|
273
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */
|
|
274
|
+
set: <Name extends TypedHeaderName<TypedHeaderValues>>(name: Name, value: TypedHeaderValue<TypedHeaderValues, Name>) => void;
|
|
275
|
+
forEach: (callbackfn: (value: Extract<TypedHeaderValues[keyof TypedHeaderValues], string> | string & {}, key: TypedHeaderName<TypedHeaderValues>, parent: TypedHeaders<TypedHeaderValues>) => void, thisArg?: any) => void;
|
|
276
|
+
}
|
|
277
|
+
interface TypedResponse<Body = unknown, Headers extends Record<string, string> | unknown = ResponseHeaderMap> extends Omit<Response, "clone" | "headers" | "json"> {
|
|
278
|
+
clone: () => TypedResponse<Body, Headers>;
|
|
279
|
+
json: () => Promise<Body>;
|
|
280
|
+
headers: TypedHeaders<Headers>;
|
|
281
|
+
}
|
|
282
|
+
interface TypedRequest<Body = unknown, Headers extends Record<string, string> | unknown = RequestHeaderMap> extends Omit<Request, "clone" | "headers" | "json"> {
|
|
283
|
+
clone: () => TypedRequest<Body, Headers>;
|
|
284
|
+
json: () => Promise<Body>;
|
|
285
|
+
headers: TypedHeaders<Headers>;
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/http/mimes.d.ts
|
|
289
|
+
type ApplicationType = `application/${"1d-interleaved-parityfec" | "3gpdash-qoe-report+xml" | "3gppHal+json" | "3gppHalForms+json" | "3gpp-ims+xml" | "A2L" | "ace+cbor" | "ace+json" | "activemessage" | "activity+json" | "aif+cbor" | "aif+json" | "alto-cdni+json" | "alto-cdnifilter+json" | "alto-costmap+json" | "alto-costmapfilter+json" | "alto-directory+json" | "alto-endpointprop+json" | "alto-endpointpropparams+json" | "alto-endpointcost+json" | "alto-endpointcostparams+json" | "alto-error+json" | "alto-networkmapfilter+json" | "alto-networkmap+json" | "alto-propmap+json" | "alto-propmapparams+json" | "alto-tips+json" | "alto-tipsparams+json" | "alto-updatestreamcontrol+json" | "alto-updatestreamparams+json" | "AML" | "andrew-inset" | "applefile" | "at+jwt" | "ATF" | "ATFX" | "atom+xml" | "atomcat+xml" | "atomdeleted+xml" | "atomicmail" | "atomsvc+xml" | "atsc-dwd+xml" | "atsc-dynamic-event-message" | "atsc-held+xml" | "atsc-rdt+json" | "atsc-rsat+xml" | "ATXML" | "auth-policy+xml" | "automationml-aml+xml" | "automationml-amlx+zip" | "bacnet-xdd+zip" | "batch-SMTP" | "beep+xml" | "c2pa" | "calendar+json" | "calendar+xml" | "call-completion" | "CALS-1840" | "captive+json" | "cbor" | "cbor-seq" | "cccex" | "ccmp+xml" | "ccxml+xml" | "cda+xml" | "CDFX+XML" | "cdmi-capability" | "cdmi-container" | "cdmi-domain" | "cdmi-object" | "cdmi-queue" | "cdni" | "CEA" | "cea-2018+xml" | "cellml+xml" | "cfw" | "cid-edhoc+cbor-seq" | "city+json" | "clr" | "clue_info+xml" | "clue+xml" | "cms" | "cnrp+xml" | "coap-group+json" | "coap-payload" | "commonground" | "concise-problem-details+cbor" | "conference-info+xml" | "cpl+xml" | "cose" | "cose-key" | "cose-key-set" | "cose-x509" | "csrattrs" | "csta+xml" | "CSTAdata+xml" | "csvm+json" | "cwl" | "cwl+json" | "cwt" | "cybercash" | "dash+xml" | "dash-patch+xml" | "dashdelta" | "davmount+xml" | "dca-rft" | "DCD" | "dec-dx" | "dialog-info+xml" | "dicom" | "dicom+json" | "dicom+xml" | "DII" | "DIT" | "dns" | "dns+json" | "dns-message" | "dots+cbor" | "dpop+jwt" | "dskpp+xml" | "dssc+der" | "dssc+xml" | "dvcs" | "ecmascript" | "edhoc+cbor-seq" | "EDI-consent" | "EDIFACT" | "EDI-X12" | "efi" | "elm+json" | "elm+xml" | "EmergencyCallData.cap+xml" | "EmergencyCallData.Comment+xml" | "EmergencyCallData.Control+xml" | "EmergencyCallData.DeviceInfo+xml" | "EmergencyCallData.eCall.MSD" | "EmergencyCallData.LegacyESN+json" | "EmergencyCallData.ProviderInfo+xml" | "EmergencyCallData.ServiceInfo+xml" | "EmergencyCallData.SubscriberInfo+xml" | "EmergencyCallData.VEDS+xml" | "emma+xml" | "emotionml+xml" | "encaprtp" | "epp+xml" | "epub+zip" | "eshop" | "example" | "exi" | "expect-ct-report+json" | "express" | "fastinfoset" | "fastsoap" | "fdf" | "fdt+xml" | "fhir+json" | "fhir+xml" | "fits" | "flexfec" | "font-sfnt" | "font-tdpfr" | "font-woff" | "framework-attributes+xml" | "geo+json" | "geo+json-seq" | "geopackage+sqlite3" | "geoxacml+json" | "geoxacml+xml" | "gltf-buffer" | "gml+xml" | "gzip" | "H224" | "held+xml" | "hl7v2+xml" | "http" | "hyperstudio" | "ibe-key-request+xml" | "ibe-pkg-reply+xml" | "ibe-pp-data" | "iges" | "im-iscomposing+xml" | "index" | "index.cmd" | "index.obj" | "index.response" | "index.vnd" | "inkml+xml" | "IOTP" | "ipfix" | "ipp" | "ISUP" | "its+xml" | "java-archive" | "javascript" | "jf2feed+json" | "jose" | "jose+json" | "jrd+json" | "jscalendar+json" | "jscontact+json" | "json" | "json-patch+json" | "json-seq" | "jsonpath" | "jwk+json" | "jwk-set+json" | "jwt" | "kpml-request+xml" | "kpml-response+xml" | "ld+json" | "lgr+xml" | "link-format" | "linkset" | "linkset+json" | "load-control+xml" | "logout+jwt" | "lost+xml" | "lostsync+xml" | "lpf+zip" | "LXF" | "mac-binhex40" | "macwriteii" | "mads+xml" | "manifest+json" | "marc" | "marcxml+xml" | "mathematica" | "mathml+xml" | "mathml-content+xml" | "mathml-presentation+xml" | "mbms-associated-procedure-description+xml" | "mbms-deregister+xml" | "mbms-envelope+xml" | "mbms-msk-response+xml" | "mbms-msk+xml" | "mbms-protection-description+xml" | "mbms-reception-report+xml" | "mbms-register-response+xml" | "mbms-register+xml" | "mbms-schedule+xml" | "mbms-user-service-description+xml" | "mbox" | "media_control+xml" | "media-policy-dataset+xml" | "mediaservercontrol+xml" | "merge-patch+json" | "metalink4+xml" | "mets+xml" | "MF4" | "mikey" | "mipc" | "missing-blocks+cbor-seq" | "mmt-aei+xml" | "mmt-usd+xml" | "mods+xml" | "moss-keys" | "moss-signature" | "mosskey-data" | "mosskey-request" | "mp21" | "mp4" | "mpeg4-generic" | "mpeg4-iod" | "mpeg4-iod-xmt" | "mrb-consumer+xml" | "mrb-publish+xml" | "msc-ivr+xml" | "msc-mixer+xml" | "msword" | "mud+json" | "multipart-core" | "mxf" | "n-quads" | "n-triples" | "nasdata" | "news-checkgroups" | "news-groupinfo" | "news-transmission" | "nlsml+xml" | "node" | "nss" | "oauth-authz-req+jwt" | "oblivious-dns-message" | "ocsp-request" | "ocsp-response" | "octet-stream" | "ODA" | "odm+xml" | "ODX" | "oebps-package+xml" | "ogg" | "ohttp-keys" | "opc-nodeset+xml" | "oscore" | "oxps" | "p21" | "p21+zip" | "p2p-overlay+xml" | "parityfec" | "passport" | "patch-ops-error+xml" | "pdf" | "PDX" | "pem-certificate-chain" | "pgp-encrypted" | "pgp-keys" | "pgp-signature" | "pidf-diff+xml" | "pidf+xml" | "pkcs10" | "pkcs7-mime" | "pkcs7-signature" | "pkcs8" | "pkcs8-encrypted" | "pkcs12" | "pkix-attr-cert" | "pkix-cert" | "pkix-crl" | "pkix-pkipath" | "pkixcmp" | "pls+xml" | "poc-settings+xml" | "postscript" | "ppsp-tracker+json" | "private-token-issuer-directory" | "private-token-request" | "private-token-response" | "problem+json" | "problem+xml" | "provenance+xml" | "prs.alvestrand.titrax-sheet" | "prs.cww" | "prs.cyn" | "prs.hpub+zip" | "prs.implied-document+xml" | "prs.implied-executable" | "prs.implied-object+json" | "prs.implied-object+json-seq" | "prs.implied-object+yaml" | "prs.implied-structure" | "prs.nprend" | "prs.plucker" | "prs.rdf-xml-crypt" | "prs.vcfbzip2" | "prs.xsf+xml" | "pskc+xml" | "pvd+json" | "rdf+xml" | "route-apd+xml" | "route-s-tsid+xml" | "route-usd+xml" | "QSIG" | "raptorfec" | "rdap+json" | "reginfo+xml" | "relax-ng-compact-syntax" | "remote-printing" | "reputon+json" | "resource-lists-diff+xml" | "resource-lists+xml" | "rfc+xml" | "riscos" | "rlmi+xml" | "rls-services+xml" | "rpki-checklist" | "rpki-ghostbusters" | "rpki-manifest" | "rpki-publication" | "rpki-roa" | "rpki-updown" | "rtf" | "rtploopback" | "rtx" | "samlassertion+xml" | "samlmetadata+xml" | "sarif-external-properties+json" | "sarif+json" | "sbe" | "sbml+xml" | "scaip+xml" | "scim+json" | "scvp-cv-request" | "scvp-cv-response" | "scvp-vp-request" | "scvp-vp-response" | "sdp" | "secevent+jwt" | "senml-etch+cbor" | "senml-etch+json" | "senml-exi" | "senml+cbor" | "senml+json" | "senml+xml" | "sensml-exi" | "sensml+cbor" | "sensml+json" | "sensml+xml" | "sep-exi" | "sep+xml" | "session-info" | "set-payment" | "set-payment-initiation" | "set-registration" | "set-registration-initiation" | "SGML" | "sgml-open-catalog" | "shf+xml" | "sieve" | "simple-filter+xml" | "simple-message-summary" | "simpleSymbolContainer" | "sipc" | "slate" | "smil" | "smil+xml" | "smpte336m" | "soap+fastinfoset" | "soap+xml" | "sparql-query" | "spdx+json" | "sparql-results+xml" | "spirits-event+xml" | "sql" | "srgs" | "srgs+xml" | "sru+xml" | "ssml+xml" | "stix+json" | "swid+cbor" | "swid+xml" | "tamp-apex-update" | "tamp-apex-update-confirm" | "tamp-community-update" | "tamp-community-update-confirm" | "tamp-error" | "tamp-sequence-adjust" | "tamp-sequence-adjust-confirm" | "tamp-status-query" | "tamp-status-response" | "tamp-update" | "tamp-update-confirm" | "taxii+json" | "td+json" | "tei+xml" | "TETRA_ISI" | "thraud+xml" | "timestamp-query" | "timestamp-reply" | "timestamped-data" | "tlsrpt+gzip" | "tlsrpt+json" | "tm+json" | "tnauthlist" | "token-introspection+jwt" | "trickle-ice-sdpfrag" | "trig" | "ttml+xml" | "tve-trigger" | "tzif" | "tzif-leap" | "ulpfec" | "urc-grpsheet+xml" | "urc-ressheet+xml" | "urc-targetdesc+xml" | "urc-uisocketdesc+xml" | "vcard+json" | "vcard+xml" | "vemmi" | "vnd.1000minds.decision-model+xml" | "vnd.1ob" | "vnd.3gpp.5gnas" | "vnd.3gpp.access-transfer-events+xml" | "vnd.3gpp.bsf+xml" | "vnd.3gpp.crs+xml" | "vnd.3gpp.current-location-discovery+xml" | "vnd.3gpp.GMOP+xml" | "vnd.3gpp.gtpc" | "vnd.3gpp.interworking-data" | "vnd.3gpp.lpp" | "vnd.3gpp.mc-signalling-ear" | "vnd.3gpp.mcdata-affiliation-command+xml" | "vnd.3gpp.mcdata-info+xml" | "vnd.3gpp.mcdata-msgstore-ctrl-request+xml" | "vnd.3gpp.mcdata-payload" | "vnd.3gpp.mcdata-regroup+xml" | "vnd.3gpp.mcdata-service-config+xml" | "vnd.3gpp.mcdata-signalling" | "vnd.3gpp.mcdata-ue-config+xml" | "vnd.3gpp.mcdata-user-profile+xml" | "vnd.3gpp.mcptt-affiliation-command+xml" | "vnd.3gpp.mcptt-floor-request+xml" | "vnd.3gpp.mcptt-info+xml" | "vnd.3gpp.mcptt-location-info+xml" | "vnd.3gpp.mcptt-mbms-usage-info+xml" | "vnd.3gpp.mcptt-regroup+xml" | "vnd.3gpp.mcptt-service-config+xml" | "vnd.3gpp.mcptt-signed+xml" | "vnd.3gpp.mcptt-ue-config+xml" | "vnd.3gpp.mcptt-ue-init-config+xml" | "vnd.3gpp.mcptt-user-profile+xml" | "vnd.3gpp.mcvideo-affiliation-command+xml" | "vnd.3gpp.mcvideo-affiliation-info+xml" | "vnd.3gpp.mcvideo-info+xml" | "vnd.3gpp.mcvideo-location-info+xml" | "vnd.3gpp.mcvideo-mbms-usage-info+xml" | "vnd.3gpp.mcvideo-regroup+xml" | "vnd.3gpp.mcvideo-service-config+xml" | "vnd.3gpp.mcvideo-transmission-request+xml" | "vnd.3gpp.mcvideo-ue-config+xml" | "vnd.3gpp.mcvideo-user-profile+xml" | "vnd.3gpp.mid-call+xml" | "vnd.3gpp.ngap" | "vnd.3gpp.pfcp" | "vnd.3gpp.pic-bw-large" | "vnd.3gpp.pic-bw-small" | "vnd.3gpp.pic-bw-var" | "vnd.3gpp-prose-pc3a+xml" | "vnd.3gpp-prose-pc3ach+xml" | "vnd.3gpp-prose-pc3ch+xml" | "vnd.3gpp-prose-pc8+xml" | "vnd.3gpp-prose+xml" | "vnd.3gpp.s1ap" | "vnd.3gpp.seal-group-doc+xml" | "vnd.3gpp.seal-info+xml" | "vnd.3gpp.seal-location-info+xml" | "vnd.3gpp.seal-mbms-usage-info+xml" | "vnd.3gpp.seal-network-QoS-management-info+xml" | "vnd.3gpp.seal-ue-config-info+xml" | "vnd.3gpp.seal-unicast-info+xml" | "vnd.3gpp.seal-user-profile-info+xml" | "vnd.3gpp.sms" | "vnd.3gpp.sms+xml" | "vnd.3gpp.srvcc-ext+xml" | "vnd.3gpp.SRVCC-info+xml" | "vnd.3gpp.state-and-event-info+xml" | "vnd.3gpp.ussd+xml" | "vnd.3gpp.vae-info+xml" | "vnd.3gpp-v2x-local-service-information" | "vnd.3gpp2.bcmcsinfo+xml" | "vnd.3gpp2.sms" | "vnd.3gpp2.tcap" | "vnd.3gpp.v2x" | "vnd.3lightssoftware.imagescal" | "vnd.3M.Post-it-Notes" | "vnd.accpac.simply.aso" | "vnd.accpac.simply.imp" | "vnd.acm.addressxfer+json" | "vnd.acm.chatbot+json" | "vnd.acucobol" | "vnd.acucorp" | "vnd.adobe.flash.movie" | "vnd.adobe.formscentral.fcdt" | "vnd.adobe.fxp" | "vnd.adobe.partial-upload" | "vnd.adobe.xdp+xml" | "vnd.aether.imp" | "vnd.afpc.afplinedata" | "vnd.afpc.afplinedata-pagedef" | "vnd.afpc.cmoca-cmresource" | "vnd.afpc.foca-charset" | "vnd.afpc.foca-codedfont" | "vnd.afpc.foca-codepage" | "vnd.afpc.modca" | "vnd.afpc.modca-cmtable" | "vnd.afpc.modca-formdef" | "vnd.afpc.modca-mediummap" | "vnd.afpc.modca-objectcontainer" | "vnd.afpc.modca-overlay" | "vnd.afpc.modca-pagesegment" | "vnd.age" | "vnd.ah-barcode" | "vnd.ahead.space" | "vnd.airzip.filesecure.azf" | "vnd.airzip.filesecure.azs" | "vnd.amadeus+json" | "vnd.amazon.mobi8-ebook" | "vnd.americandynamics.acc" | "vnd.amiga.ami" | "vnd.amundsen.maze+xml" | "vnd.android.ota" | "vnd.anki" | "vnd.anser-web-certificate-issue-initiation" | "vnd.antix.game-component" | "vnd.apache.arrow.file" | "vnd.apache.arrow.stream" | "vnd.apache.thrift.binary" | "vnd.apache.thrift.compact" | "vnd.apache.thrift.json" | "vnd.apexlang" | "vnd.api+json" | "vnd.aplextor.warrp+json" | "vnd.apothekende.reservation+json" | "vnd.apple.installer+xml" | "vnd.apple.keynote" | "vnd.apple.mpegurl" | "vnd.apple.numbers" | "vnd.apple.pages" | "vnd.arastra.swi" | "vnd.aristanetworks.swi" | "vnd.artisan+json" | "vnd.artsquare" | "vnd.astraea-software.iota" | "vnd.audiograph" | "vnd.autopackage" | "vnd.avalon+json" | "vnd.avistar+xml" | "vnd.balsamiq.bmml+xml" | "vnd.banana-accounting" | "vnd.bbf.usp.error" | "vnd.bbf.usp.msg" | "vnd.bbf.usp.msg+json" | "vnd.balsamiq.bmpr" | "vnd.bekitzur-stech+json" | "vnd.belightsoft.lhzd+zip" | "vnd.belightsoft.lhzl+zip" | "vnd.bint.med-content" | "vnd.biopax.rdf+xml" | "vnd.blink-idb-value-wrapper" | "vnd.blueice.multipass" | "vnd.bluetooth.ep.oob" | "vnd.bluetooth.le.oob" | "vnd.bmi" | "vnd.bpf" | "vnd.bpf3" | "vnd.businessobjects" | "vnd.byu.uapi+json" | "vnd.bzip3" | "vnd.cab-jscript" | "vnd.canon-cpdl" | "vnd.canon-lips" | "vnd.capasystems-pg+json" | "vnd.cendio.thinlinc.clientconf" | "vnd.century-systems.tcp_stream" | "vnd.chemdraw+xml" | "vnd.chess-pgn" | "vnd.chipnuts.karaoke-mmd" | "vnd.ciedi" | "vnd.cinderella" | "vnd.cirpack.isdn-ext" | "vnd.citationstyles.style+xml" | "vnd.claymore" | "vnd.cloanto.rp9" | "vnd.clonk.c4group" | "vnd.cluetrust.cartomobile-config" | "vnd.cluetrust.cartomobile-config-pkg" | "vnd.cncf.helm.chart.content.v1.tar+gzip" | "vnd.cncf.helm.chart.provenance.v1.prov" | "vnd.cncf.helm.config.v1+json" | "vnd.coffeescript" | "vnd.collabio.xodocuments.document" | "vnd.collabio.xodocuments.document-template" | "vnd.collabio.xodocuments.presentation" | "vnd.collabio.xodocuments.presentation-template" | "vnd.collabio.xodocuments.spreadsheet" | "vnd.collabio.xodocuments.spreadsheet-template" | "vnd.collection.doc+json" | "vnd.collection+json" | "vnd.collection.next+json" | "vnd.comicbook-rar" | "vnd.comicbook+zip" | "vnd.commerce-battelle" | "vnd.commonspace" | "vnd.coreos.ignition+json" | "vnd.cosmocaller" | "vnd.contact.cmsg" | "vnd.crick.clicker" | "vnd.crick.clicker.keyboard" | "vnd.crick.clicker.palette" | "vnd.crick.clicker.template" | "vnd.crick.clicker.wordbank" | "vnd.criticaltools.wbs+xml" | "vnd.cryptii.pipe+json" | "vnd.crypto-shade-file" | "vnd.cryptomator.encrypted" | "vnd.cryptomator.vault" | "vnd.ctc-posml" | "vnd.ctct.ws+xml" | "vnd.cups-pdf" | "vnd.cups-postscript" | "vnd.cups-ppd" | "vnd.cups-raster" | "vnd.cups-raw" | "vnd.curl" | "vnd.cyan.dean.root+xml" | "vnd.cybank" | "vnd.cyclonedx+json" | "vnd.cyclonedx+xml" | "vnd.d2l.coursepackage1p0+zip" | "vnd.d3m-dataset" | "vnd.d3m-problem" | "vnd.dart" | "vnd.data-vision.rdz" | "vnd.datalog" | "vnd.datapackage+json" | "vnd.dataresource+json" | "vnd.dbf" | "vnd.debian.binary-package" | "vnd.dece.data" | "vnd.dece.ttml+xml" | "vnd.dece.unspecified" | "vnd.dece.zip" | "vnd.denovo.fcselayout-link" | "vnd.desmume.movie" | "vnd.dir-bi.plate-dl-nosuffix" | "vnd.dm.delegation+xml" | "vnd.dna" | "vnd.document+json" | "vnd.dolby.mobile.1" | "vnd.dolby.mobile.2" | "vnd.doremir.scorecloud-binary-document" | "vnd.dpgraph" | "vnd.dreamfactory" | "vnd.drive+json" | "vnd.dtg.local" | "vnd.dtg.local.flash" | "vnd.dtg.local.html" | "vnd.dvb.ait" | "vnd.dvb.dvbisl+xml" | "vnd.dvb.dvbj" | "vnd.dvb.esgcontainer" | "vnd.dvb.ipdcdftnotifaccess" | "vnd.dvb.ipdcesgaccess" | "vnd.dvb.ipdcesgaccess2" | "vnd.dvb.ipdcesgpdd" | "vnd.dvb.ipdcroaming" | "vnd.dvb.iptv.alfec-base" | "vnd.dvb.iptv.alfec-enhancement" | "vnd.dvb.notif-aggregate-root+xml" | "vnd.dvb.notif-container+xml" | "vnd.dvb.notif-generic+xml" | "vnd.dvb.notif-ia-msglist+xml" | "vnd.dvb.notif-ia-registration-request+xml" | "vnd.dvb.notif-ia-registration-response+xml" | "vnd.dvb.notif-init+xml" | "vnd.dvb.pfr" | "vnd.dvb.service" | "vnd.dxr" | "vnd.dynageo" | "vnd.dzr" | "vnd.easykaraoke.cdgdownload" | "vnd.ecip.rlp" | "vnd.ecdis-update" | "vnd.eclipse.ditto+json" | "vnd.ecowin.chart" | "vnd.ecowin.filerequest" | "vnd.ecowin.fileupdate" | "vnd.ecowin.series" | "vnd.ecowin.seriesrequest" | "vnd.ecowin.seriesupdate" | "vnd.efi.img" | "vnd.efi.iso" | "vnd.eln+zip" | "vnd.emclient.accessrequest+xml" | "vnd.enliven" | "vnd.enphase.envoy" | "vnd.eprints.data+xml" | "vnd.epson.esf" | "vnd.epson.msf" | "vnd.epson.quickanime" | "vnd.epson.salt" | "vnd.epson.ssf" | "vnd.ericsson.quickcall" | "vnd.erofs" | "vnd.espass-espass+zip" | "vnd.eszigno3+xml" | "vnd.etsi.aoc+xml" | "vnd.etsi.asic-s+zip" | "vnd.etsi.asic-e+zip" | "vnd.etsi.cug+xml" | "vnd.etsi.iptvcommand+xml" | "vnd.etsi.iptvdiscovery+xml" | "vnd.etsi.iptvprofile+xml" | "vnd.etsi.iptvsad-bc+xml" | "vnd.etsi.iptvsad-cod+xml" | "vnd.etsi.iptvsad-npvr+xml" | "vnd.etsi.iptvservice+xml" | "vnd.etsi.iptvsync+xml" | "vnd.etsi.iptvueprofile+xml" | "vnd.etsi.mcid+xml" | "vnd.etsi.mheg5" | "vnd.etsi.overload-control-policy-dataset+xml" | "vnd.etsi.pstn+xml" | "vnd.etsi.sci+xml" | "vnd.etsi.simservs+xml" | "vnd.etsi.timestamp-token" | "vnd.etsi.tsl+xml" | "vnd.etsi.tsl.der" | "vnd.eu.kasparian.car+json" | "vnd.eudora.data" | "vnd.evolv.ecig.profile" | "vnd.evolv.ecig.settings" | "vnd.evolv.ecig.theme" | "vnd.exstream-empower+zip" | "vnd.exstream-package" | "vnd.ezpix-album" | "vnd.ezpix-package" | "vnd.f-secure.mobile" | "vnd.fastcopy-disk-image" | "vnd.familysearch.gedcom+zip" | "vnd.fdsn.mseed" | "vnd.fdsn.seed" | "vnd.ffsns" | "vnd.ficlab.flb+zip" | "vnd.filmit.zfc" | "vnd.fints" | "vnd.firemonkeys.cloudcell" | "vnd.FloGraphIt" | "vnd.fluxtime.clip" | "vnd.font-fontforge-sfd" | "vnd.framemaker" | "vnd.freelog.comic" | "vnd.frogans.fnc" | "vnd.frogans.ltf" | "vnd.fsc.weblaunch" | "vnd.fujifilm.fb.docuworks" | "vnd.fujifilm.fb.docuworks.binder" | "vnd.fujifilm.fb.docuworks.container" | "vnd.fujifilm.fb.jfi+xml" | "vnd.fujitsu.oasys" | "vnd.fujitsu.oasys2" | "vnd.fujitsu.oasys3" | "vnd.fujitsu.oasysgp" | "vnd.fujitsu.oasysprs" | "vnd.fujixerox.ART4" | "vnd.fujixerox.ART-EX" | "vnd.fujixerox.ddd" | "vnd.fujixerox.docuworks" | "vnd.fujixerox.docuworks.binder" | "vnd.fujixerox.docuworks.container" | "vnd.fujixerox.HBPL" | "vnd.fut-misnet" | "vnd.futoin+cbor" | "vnd.futoin+json" | "vnd.fuzzysheet" | "vnd.genomatix.tuxedo" | "vnd.genozip" | "vnd.gentics.grd+json" | "vnd.gentoo.catmetadata+xml" | "vnd.gentoo.ebuild" | "vnd.gentoo.eclass" | "vnd.gentoo.gpkg" | "vnd.gentoo.manifest" | "vnd.gentoo.xpak" | "vnd.gentoo.pkgmetadata+xml" | "vnd.geo+json" | "vnd.geocube+xml" | "vnd.geogebra.file" | "vnd.geogebra.slides" | "vnd.geogebra.tool" | "vnd.geometry-explorer" | "vnd.geonext" | "vnd.geoplan" | "vnd.geospace" | "vnd.gerber" | "vnd.globalplatform.card-content-mgt" | "vnd.globalplatform.card-content-mgt-response" | "vnd.gmx" | "vnd.gnu.taler.exchange+json" | "vnd.gnu.taler.merchant+json" | "vnd.google-earth.kml+xml" | "vnd.google-earth.kmz" | "vnd.gov.sk.e-form+xml" | "vnd.gov.sk.e-form+zip" | "vnd.gov.sk.xmldatacontainer+xml" | "vnd.gpxsee.map+xml" | "vnd.grafeq" | "vnd.gridmp" | "vnd.groove-account" | "vnd.groove-help" | "vnd.groove-identity-message" | "vnd.groove-injector" | "vnd.groove-tool-message" | "vnd.groove-tool-template" | "vnd.groove-vcard" | "vnd.hal+json" | "vnd.hal+xml" | "vnd.HandHeld-Entertainment+xml" | "vnd.hbci" | "vnd.hc+json" | "vnd.hcl-bireports" | "vnd.hdt" | "vnd.heroku+json" | "vnd.hhe.lesson-player" | "vnd.hp-HPGL" | "vnd.hp-hpid" | "vnd.hp-hps" | "vnd.hp-jlyt" | "vnd.hp-PCL" | "vnd.hp-PCLXL" | "vnd.hsl" | "vnd.httphone" | "vnd.hydrostatix.sof-data" | "vnd.hyper-item+json" | "vnd.hyper+json" | "vnd.hyperdrive+json" | "vnd.hzn-3d-crossword" | "vnd.ibm.afplinedata" | "vnd.ibm.electronic-media" | "vnd.ibm.MiniPay" | "vnd.ibm.modcap" | "vnd.ibm.rights-management" | "vnd.ibm.secure-container" | "vnd.iccprofile" | "vnd.ieee.1905" | "vnd.igloader" | "vnd.imagemeter.folder+zip" | "vnd.imagemeter.image+zip" | "vnd.immervision-ivp" | "vnd.immervision-ivu" | "vnd.ims.imsccv1p1" | "vnd.ims.imsccv1p2" | "vnd.ims.imsccv1p3" | "vnd.ims.lis.v2.result+json" | "vnd.ims.lti.v2.toolconsumerprofile+json" | "vnd.ims.lti.v2.toolproxy.id+json" | "vnd.ims.lti.v2.toolproxy+json" | "vnd.ims.lti.v2.toolsettings+json" | "vnd.ims.lti.v2.toolsettings.simple+json" | "vnd.informedcontrol.rms+xml" | "vnd.infotech.project" | "vnd.infotech.project+xml" | "vnd.informix-visionary" | "vnd.innopath.wamp.notification" | "vnd.insors.igm" | "vnd.intercon.formnet" | "vnd.intergeo" | "vnd.intertrust.digibox" | "vnd.intertrust.nncp" | "vnd.intu.qbo" | "vnd.intu.qfx" | "vnd.ipfs.ipns-record" | "vnd.ipld.car" | "vnd.ipld.dag-cbor" | "vnd.ipld.dag-json" | "vnd.ipld.raw" | "vnd.iptc.g2.catalogitem+xml" | "vnd.iptc.g2.conceptitem+xml" | "vnd.iptc.g2.knowledgeitem+xml" | "vnd.iptc.g2.newsitem+xml" | "vnd.iptc.g2.newsmessage+xml" | "vnd.iptc.g2.packageitem+xml" | "vnd.iptc.g2.planningitem+xml" | "vnd.ipunplugged.rcprofile" | "vnd.irepository.package+xml" | "vnd.is-xpr" | "vnd.isac.fcs" | "vnd.jam" | "vnd.iso11783-10+zip" | "vnd.japannet-directory-service" | "vnd.japannet-jpnstore-wakeup" | "vnd.japannet-payment-wakeup" | "vnd.japannet-registration" | "vnd.japannet-registration-wakeup" | "vnd.japannet-setstore-wakeup" | "vnd.japannet-verification" | "vnd.japannet-verification-wakeup" | "vnd.jcp.javame.midlet-rms" | "vnd.jisp" | "vnd.joost.joda-archive" | "vnd.jsk.isdn-ngn" | "vnd.kahootz" | "vnd.kde.karbon" | "vnd.kde.kchart" | "vnd.kde.kformula" | "vnd.kde.kivio" | "vnd.kde.kontour" | "vnd.kde.kpresenter" | "vnd.kde.kspread" | "vnd.kde.kword" | "vnd.kenameaapp" | "vnd.kidspiration" | "vnd.Kinar" | "vnd.koan" | "vnd.kodak-descriptor" | "vnd.las" | "vnd.las.las+json" | "vnd.las.las+xml" | "vnd.laszip" | "vnd.ldev.productlicensing" | "vnd.leap+json" | "vnd.liberty-request+xml" | "vnd.llamagraphics.life-balance.desktop" | "vnd.llamagraphics.life-balance.exchange+xml" | "vnd.logipipe.circuit+zip" | "vnd.loom" | "vnd.lotus-1-2-3" | "vnd.lotus-approach" | "vnd.lotus-freelance" | "vnd.lotus-notes" | "vnd.lotus-organizer" | "vnd.lotus-screencam" | "vnd.lotus-wordpro" | "vnd.macports.portpkg" | "vnd.mapbox-vector-tile" | "vnd.marlin.drm.actiontoken+xml" | "vnd.marlin.drm.conftoken+xml" | "vnd.marlin.drm.license+xml" | "vnd.marlin.drm.mdcf" | "vnd.mason+json" | "vnd.maxar.archive.3tz+zip" | "vnd.maxmind.maxmind-db" | "vnd.mcd" | "vnd.mdl" | "vnd.mdl-mbsdf" | "vnd.medcalcdata" | "vnd.mediastation.cdkey" | "vnd.medicalholodeck.recordxr" | "vnd.meridian-slingshot" | "vnd.mermaid" | "vnd.MFER" | "vnd.mfmp" | "vnd.micro+json" | "vnd.micrografx.flo" | "vnd.micrografx.igx" | "vnd.microsoft.portable-executable" | "vnd.microsoft.windows.thumbnail-cache" | "vnd.miele+json" | "vnd.mif" | "vnd.minisoft-hp3000-save" | "vnd.mitsubishi.misty-guard.trustweb" | "vnd.Mobius.DAF" | "vnd.Mobius.DIS" | "vnd.Mobius.MBK" | "vnd.Mobius.MQY" | "vnd.Mobius.MSL" | "vnd.Mobius.PLC" | "vnd.Mobius.TXF" | "vnd.modl" | "vnd.mophun.application" | "vnd.mophun.certificate" | "vnd.motorola.flexsuite" | "vnd.motorola.flexsuite.adsi" | "vnd.motorola.flexsuite.fis" | "vnd.motorola.flexsuite.gotap" | "vnd.motorola.flexsuite.kmr" | "vnd.motorola.flexsuite.ttc" | "vnd.motorola.flexsuite.wem" | "vnd.motorola.iprm" | "vnd.mozilla.xul+xml" | "vnd.ms-artgalry" | "vnd.ms-asf" | "vnd.ms-cab-compressed" | "vnd.ms-3mfdocument" | "vnd.ms-excel" | "vnd.ms-excel.addin.macroEnabled.12" | "vnd.ms-excel.sheet.binary.macroEnabled.12" | "vnd.ms-excel.sheet.macroEnabled.12" | "vnd.ms-excel.template.macroEnabled.12" | "vnd.ms-fontobject" | "vnd.ms-htmlhelp" | "vnd.ms-ims" | "vnd.ms-lrm" | "vnd.ms-office.activeX+xml" | "vnd.ms-officetheme" | "vnd.ms-playready.initiator+xml" | "vnd.ms-powerpoint" | "vnd.ms-powerpoint.addin.macroEnabled.12" | "vnd.ms-powerpoint.presentation.macroEnabled.12" | "vnd.ms-powerpoint.slide.macroEnabled.12" | "vnd.ms-powerpoint.slideshow.macroEnabled.12" | "vnd.ms-powerpoint.template.macroEnabled.12" | "vnd.ms-PrintDeviceCapabilities+xml" | "vnd.ms-PrintSchemaTicket+xml" | "vnd.ms-project" | "vnd.ms-tnef" | "vnd.ms-windows.devicepairing" | "vnd.ms-windows.nwprinting.oob" | "vnd.ms-windows.printerpairing" | "vnd.ms-windows.wsd.oob" | "vnd.ms-wmdrm.lic-chlg-req" | "vnd.ms-wmdrm.lic-resp" | "vnd.ms-wmdrm.meter-chlg-req" | "vnd.ms-wmdrm.meter-resp" | "vnd.ms-word.document.macroEnabled.12" | "vnd.ms-word.template.macroEnabled.12" | "vnd.ms-works" | "vnd.ms-wpl" | "vnd.ms-xpsdocument" | "vnd.msa-disk-image" | "vnd.mseq" | "vnd.msign" | "vnd.multiad.creator" | "vnd.multiad.creator.cif" | "vnd.musician" | "vnd.music-niff" | "vnd.muvee.style" | "vnd.mynfc" | "vnd.nacamar.ybrid+json" | "vnd.nato.bindingdataobject+cbor" | "vnd.nato.bindingdataobject+json" | "vnd.nato.bindingdataobject+xml" | "vnd.nato.openxmlformats-package.iepd+zip" | "vnd.ncd.control" | "vnd.ncd.reference" | "vnd.nearst.inv+json" | "vnd.nebumind.line" | "vnd.nervana" | "vnd.netfpx" | "vnd.neurolanguage.nlu" | "vnd.nimn" | "vnd.nintendo.snes.rom" | "vnd.nintendo.nitro.rom" | "vnd.nitf" | "vnd.noblenet-directory" | "vnd.noblenet-sealer" | "vnd.noblenet-web" | "vnd.nokia.catalogs" | "vnd.nokia.conml+wbxml" | "vnd.nokia.conml+xml" | "vnd.nokia.iptv.config+xml" | "vnd.nokia.iSDS-radio-presets" | "vnd.nokia.landmark+wbxml" | "vnd.nokia.landmark+xml" | "vnd.nokia.landmarkcollection+xml" | "vnd.nokia.ncd" | "vnd.nokia.n-gage.ac+xml" | "vnd.nokia.n-gage.data" | "vnd.nokia.n-gage.symbian.install" | "vnd.nokia.pcd+wbxml" | "vnd.nokia.pcd+xml" | "vnd.nokia.radio-preset" | "vnd.nokia.radio-presets" | "vnd.novadigm.EDM" | "vnd.novadigm.EDX" | "vnd.novadigm.EXT" | "vnd.ntt-local.content-share" | "vnd.ntt-local.file-transfer" | "vnd.ntt-local.ogw_remote-access" | "vnd.ntt-local.sip-ta_remote" | "vnd.ntt-local.sip-ta_tcp_stream" | "vnd.oai.workflows" | "vnd.oai.workflows+json" | "vnd.oai.workflows+yaml" | "vnd.oasis.opendocument.base" | "vnd.oasis.opendocument.chart" | "vnd.oasis.opendocument.chart-template" | "vnd.oasis.opendocument.database" | "vnd.oasis.opendocument.formula" | "vnd.oasis.opendocument.formula-template" | "vnd.oasis.opendocument.graphics" | "vnd.oasis.opendocument.graphics-template" | "vnd.oasis.opendocument.image" | "vnd.oasis.opendocument.image-template" | "vnd.oasis.opendocument.presentation" | "vnd.oasis.opendocument.presentation-template" | "vnd.oasis.opendocument.spreadsheet" | "vnd.oasis.opendocument.spreadsheet-template" | "vnd.oasis.opendocument.text" | "vnd.oasis.opendocument.text-master" | "vnd.oasis.opendocument.text-master-template" | "vnd.oasis.opendocument.text-template" | "vnd.oasis.opendocument.text-web" | "vnd.obn" | "vnd.ocf+cbor" | "vnd.oci.image.manifest.v1+json" | "vnd.oftn.l10n+json" | "vnd.oipf.contentaccessdownload+xml" | "vnd.oipf.contentaccessstreaming+xml" | "vnd.oipf.cspg-hexbinary" | "vnd.oipf.dae.svg+xml" | "vnd.oipf.dae.xhtml+xml" | "vnd.oipf.mippvcontrolmessage+xml" | "vnd.oipf.pae.gem" | "vnd.oipf.spdiscovery+xml" | "vnd.oipf.spdlist+xml" | "vnd.oipf.ueprofile+xml" | "vnd.oipf.userprofile+xml" | "vnd.olpc-sugar" | "vnd.oma.bcast.associated-procedure-parameter+xml" | "vnd.oma.bcast.drm-trigger+xml" | "vnd.oma.bcast.imd+xml" | "vnd.oma.bcast.ltkm" | "vnd.oma.bcast.notification+xml" | "vnd.oma.bcast.provisioningtrigger" | "vnd.oma.bcast.sgboot" | "vnd.oma.bcast.sgdd+xml" | "vnd.oma.bcast.sgdu" | "vnd.oma.bcast.simple-symbol-container" | "vnd.oma.bcast.smartcard-trigger+xml" | "vnd.oma.bcast.sprov+xml" | "vnd.oma.bcast.stkm" | "vnd.oma.cab-address-book+xml" | "vnd.oma.cab-feature-handler+xml" | "vnd.oma.cab-pcc+xml" | "vnd.oma.cab-subs-invite+xml" | "vnd.oma.cab-user-prefs+xml" | "vnd.oma.dcd" | "vnd.oma.dcdc" | "vnd.oma.dd2+xml" | "vnd.oma.drm.risd+xml" | "vnd.oma.group-usage-list+xml" | "vnd.oma.lwm2m+cbor" | "vnd.oma.lwm2m+json" | "vnd.oma.lwm2m+tlv" | "vnd.oma.pal+xml" | "vnd.oma.poc.detailed-progress-report+xml" | "vnd.oma.poc.final-report+xml" | "vnd.oma.poc.groups+xml" | "vnd.oma.poc.invocation-descriptor+xml" | "vnd.oma.poc.optimized-progress-report+xml" | "vnd.oma.push" | "vnd.oma.scidm.messages+xml" | "vnd.oma.xcap-directory+xml" | "vnd.omads-email+xml" | "vnd.omads-file+xml" | "vnd.omads-folder+xml" | "vnd.omaloc-supl-init" | "vnd.oma-scws-config" | "vnd.oma-scws-http-request" | "vnd.oma-scws-http-response" | "vnd.onepager" | "vnd.onepagertamp" | "vnd.onepagertamx" | "vnd.onepagertat" | "vnd.onepagertatp" | "vnd.onepagertatx" | "vnd.onvif.metadata" | "vnd.openblox.game-binary" | "vnd.openblox.game+xml" | "vnd.openeye.oeb" | "vnd.openstreetmap.data+xml" | "vnd.opentimestamps.ots" | "vnd.openxmlformats-officedocument.custom-properties+xml" | "vnd.openxmlformats-officedocument.customXmlProperties+xml" | "vnd.openxmlformats-officedocument.drawing+xml" | "vnd.openxmlformats-officedocument.drawingml.chart+xml" | "vnd.openxmlformats-officedocument.drawingml.chartshapes+xml" | "vnd.openxmlformats-officedocument.drawingml.diagramColors+xml" | "vnd.openxmlformats-officedocument.drawingml.diagramData+xml" | "vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml" | "vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml" | "vnd.openxmlformats-officedocument.extended-properties+xml" | "vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml" | "vnd.openxmlformats-officedocument.presentationml.comments+xml" | "vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml" | "vnd.openxmlformats-officedocument.presentationml.notesMaster+xml" | "vnd.openxmlformats-officedocument.presentationml.notesSlide+xml" | "vnd.openxmlformats-officedocument.presentationml.presentation" | "vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" | "vnd.openxmlformats-officedocument.presentationml.presProps+xml" | "vnd.openxmlformats-officedocument.presentationml.slide" | "vnd.openxmlformats-officedocument.presentationml.slide+xml" | "vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" | "vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" | "vnd.openxmlformats-officedocument.presentationml.slideshow" | "vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" | "vnd.openxmlformats-officedocument.presentationml.slideUpdateInfo+xml" | "vnd.openxmlformats-officedocument.presentationml.tableStyles+xml" | "vnd.openxmlformats-officedocument.presentationml.tags+xml" | "vnd.openxmlformats-officedocument.presentationml.template" | "vnd.openxmlformats-officedocument.presentationml.template.main+xml" | "vnd.openxmlformats-officedocument.presentationml.viewProps+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.comments+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.connections+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.table+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.template" | "vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml" | "vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" | "vnd.openxmlformats-officedocument.theme+xml" | "vnd.openxmlformats-officedocument.themeOverride+xml" | "vnd.openxmlformats-officedocument.vmlDrawing" | "vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.document" | "vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.template" | "vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" | "vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" | "vnd.openxmlformats-package.core-properties+xml" | "vnd.openxmlformats-package.digital-signature-xmlsignature+xml" | "vnd.openxmlformats-package.relationships+xml" | "vnd.oracle.resource+json" | "vnd.orange.indata" | "vnd.osa.netdeploy" | "vnd.osgeo.mapguide.package" | "vnd.osgi.bundle" | "vnd.osgi.dp" | "vnd.osgi.subsystem" | "vnd.otps.ct-kip+xml" | "vnd.oxli.countgraph" | "vnd.pagerduty+json" | "vnd.palm" | "vnd.panoply" | "vnd.paos.xml" | "vnd.patentdive" | "vnd.patientecommsdoc" | "vnd.pawaafile" | "vnd.pcos" | "vnd.pg.format" | "vnd.pg.osasli" | "vnd.piaccess.application-licence" | "vnd.picsel" | "vnd.pmi.widget" | "vnd.poc.group-advertisement+xml" | "vnd.pocketlearn" | "vnd.powerbuilder6" | "vnd.powerbuilder6-s" | "vnd.powerbuilder7" | "vnd.powerbuilder75" | "vnd.powerbuilder75-s" | "vnd.powerbuilder7-s" | "vnd.preminet" | "vnd.previewsystems.box" | "vnd.proteus.magazine" | "vnd.psfs" | "vnd.pt.mundusmundi" | "vnd.publishare-delta-tree" | "vnd.pvi.ptid1" | "vnd.pwg-multiplexed" | "vnd.pwg-xhtml-print+xml" | "vnd.qualcomm.brew-app-res" | "vnd.quarantainenet" | "vnd.Quark.QuarkXPress" | "vnd.quobject-quoxdocument" | "vnd.radisys.moml+xml" | "vnd.radisys.msml-audit-conf+xml" | "vnd.radisys.msml-audit-conn+xml" | "vnd.radisys.msml-audit-dialog+xml" | "vnd.radisys.msml-audit-stream+xml" | "vnd.radisys.msml-audit+xml" | "vnd.radisys.msml-conf+xml" | "vnd.radisys.msml-dialog-base+xml" | "vnd.radisys.msml-dialog-fax-detect+xml" | "vnd.radisys.msml-dialog-fax-sendrecv+xml" | "vnd.radisys.msml-dialog-group+xml" | "vnd.radisys.msml-dialog-speech+xml" | "vnd.radisys.msml-dialog-transform+xml" | "vnd.radisys.msml-dialog+xml" | "vnd.radisys.msml+xml" | "vnd.rainstor.data" | "vnd.rapid" | "vnd.rar" | "vnd.realvnc.bed" | "vnd.recordare.musicxml" | "vnd.recordare.musicxml+xml" | "vnd.relpipe" | "vnd.RenLearn.rlprint" | "vnd.resilient.logic" | "vnd.restful+json" | "vnd.rig.cryptonote" | "vnd.route66.link66+xml" | "vnd.rs-274x" | "vnd.ruckus.download" | "vnd.s3sms" | "vnd.sailingtracker.track" | "vnd.sar" | "vnd.sbm.cid" | "vnd.sbm.mid2" | "vnd.scribus" | "vnd.sealed.3df" | "vnd.sealed.csf" | "vnd.sealed.doc" | "vnd.sealed.eml" | "vnd.sealed.mht" | "vnd.sealed.net" | "vnd.sealed.ppt" | "vnd.sealed.tiff" | "vnd.sealed.xls" | "vnd.sealedmedia.softseal.html" | "vnd.sealedmedia.softseal.pdf" | "vnd.seemail" | "vnd.seis+json" | "vnd.sema" | "vnd.semd" | "vnd.semf" | "vnd.shade-save-file" | "vnd.shana.informed.formdata" | "vnd.shana.informed.formtemplate" | "vnd.shana.informed.interchange" | "vnd.shana.informed.package" | "vnd.shootproof+json" | "vnd.shopkick+json" | "vnd.shp" | "vnd.shx" | "vnd.sigrok.session" | "vnd.SimTech-MindMapper" | "vnd.siren+json" | "vnd.smaf" | "vnd.smart.notebook" | "vnd.smart.teacher" | "vnd.smintio.portals.archive" | "vnd.snesdev-page-table" | "vnd.software602.filler.form+xml" | "vnd.software602.filler.form-xml-zip" | "vnd.solent.sdkm+xml" | "vnd.spotfire.dxp" | "vnd.spotfire.sfs" | "vnd.sqlite3" | "vnd.sss-cod" | "vnd.sss-dtf" | "vnd.sss-ntf" | "vnd.stepmania.package" | "vnd.stepmania.stepchart" | "vnd.street-stream" | "vnd.sun.wadl+xml" | "vnd.sus-calendar" | "vnd.svd" | "vnd.swiftview-ics" | "vnd.sybyl.mol2" | "vnd.sycle+xml" | "vnd.syft+json" | "vnd.syncml.dm.notification" | "vnd.syncml.dmddf+xml" | "vnd.syncml.dmtnds+wbxml" | "vnd.syncml.dmtnds+xml" | "vnd.syncml.dmddf+wbxml" | "vnd.syncml.dm+wbxml" | "vnd.syncml.dm+xml" | "vnd.syncml.ds.notification" | "vnd.syncml+xml" | "vnd.tableschema+json" | "vnd.tao.intent-module-archive" | "vnd.tcpdump.pcap" | "vnd.think-cell.ppttc+json" | "vnd.tml" | "vnd.tmd.mediaflex.api+xml" | "vnd.tmobile-livetv" | "vnd.tri.onesource" | "vnd.trid.tpt" | "vnd.triscape.mxs" | "vnd.trueapp" | "vnd.truedoc" | "vnd.ubisoft.webplayer" | "vnd.ufdl" | "vnd.uiq.theme" | "vnd.umajin" | "vnd.unity" | "vnd.uoml+xml" | "vnd.uplanet.alert" | "vnd.uplanet.alert-wbxml" | "vnd.uplanet.bearer-choice" | "vnd.uplanet.bearer-choice-wbxml" | "vnd.uplanet.cacheop" | "vnd.uplanet.cacheop-wbxml" | "vnd.uplanet.channel" | "vnd.uplanet.channel-wbxml" | "vnd.uplanet.list" | "vnd.uplanet.listcmd" | "vnd.uplanet.listcmd-wbxml" | "vnd.uplanet.list-wbxml" | "vnd.uri-map" | "vnd.uplanet.signal" | "vnd.valve.source.material" | "vnd.vcx" | "vnd.vd-study" | "vnd.vectorworks" | "vnd.vel+json" | "vnd.verimatrix.vcas" | "vnd.veritone.aion+json" | "vnd.veryant.thin" | "vnd.ves.encrypted" | "vnd.vidsoft.vidconference" | "vnd.visio" | "vnd.visionary" | "vnd.vividence.scriptfile" | "vnd.vsf" | "vnd.wap.sic" | "vnd.wap.slc" | "vnd.wap.wbxml" | "vnd.wap.wmlc" | "vnd.wap.wmlscriptc" | "vnd.wasmflow.wafl" | "vnd.webturbo" | "vnd.wfa.dpp" | "vnd.wfa.p2p" | "vnd.wfa.wsc" | "vnd.windows.devicepairing" | "vnd.wmc" | "vnd.wmf.bootstrap" | "vnd.wolfram.mathematica" | "vnd.wolfram.mathematica.package" | "vnd.wolfram.player" | "vnd.wordlift" | "vnd.wordperfect" | "vnd.wqd" | "vnd.wrq-hp3000-labelled" | "vnd.wt.stf" | "vnd.wv.csp+xml" | "vnd.wv.csp+wbxml" | "vnd.wv.ssp+xml" | "vnd.xacml+json" | "vnd.xara" | "vnd.xecrets-encrypted" | "vnd.xfdl" | "vnd.xfdl.webform" | "vnd.xmi+xml" | "vnd.xmpie.cpkg" | "vnd.xmpie.dpkg" | "vnd.xmpie.plan" | "vnd.xmpie.ppkg" | "vnd.xmpie.xlim" | "vnd.yamaha.hv-dic" | "vnd.yamaha.hv-script" | "vnd.yamaha.hv-voice" | "vnd.yamaha.openscoreformat.osfpvg+xml" | "vnd.yamaha.openscoreformat" | "vnd.yamaha.remote-setup" | "vnd.yamaha.smaf-audio" | "vnd.yamaha.smaf-phrase" | "vnd.yamaha.through-ngn" | "vnd.yamaha.tunnel-udpencap" | "vnd.yaoweme" | "vnd.yellowriver-custom-menu" | "vnd.youtube.yt" | "vnd.zul" | "vnd.zzazz.deck+xml" | "voicexml+xml" | "voucher-cms+json" | "vq-rtcpxr" | "wasm" | "watcherinfo+xml" | "webpush-options+json" | "whoispp-query" | "whoispp-response" | "widget" | "wita" | "wordperfect5.1" | "wsdl+xml" | "wspolicy+xml" | "x-pki-message" | "x-www-form-urlencoded" | "x-x509-ca-cert" | "x-x509-ca-ra-cert" | "x-x509-next-ca-cert" | "x400-bp" | "xacml+xml" | "xcap-att+xml" | "xcap-caps+xml" | "xcap-diff+xml" | "xcap-el+xml" | "xcap-error+xml" | "xcap-ns+xml" | "xcon-conference-info-diff+xml" | "xcon-conference-info+xml" | "xenc+xml" | "xfdf" | "xhtml+xml" | "xliff+xml" | "xml" | "xml-dtd" | "xml-external-parsed-entity" | "xml-patch+xml" | "xmpp+xml" | "xop+xml" | "xslt+xml" | "xv+xml" | "yaml" | "yang" | "yang-data+cbor" | "yang-data+json" | "yang-data+xml" | "yang-patch+json" | "yang-patch+xml" | "yin+xml" | "zip" | "zlib" | "zstd"}`;
|
|
290
|
+
type AudioMimeType = `audio/${"1d-interleaved-parityfec" | "32kadpcm" | "3gpp" | "3gpp2" | "aac" | "ac3" | "AMR" | "AMR-WB" | "amr-wb+" | "aptx" | "asc" | "ATRAC-ADVANCED-LOSSLESS" | "ATRAC-X" | "ATRAC3" | "basic" | "BV16" | "BV32" | "clearmode" | "CN" | "DAT12" | "dls" | "dsr-es201108" | "dsr-es202050" | "dsr-es202211" | "dsr-es202212" | "DV" | "DVI4" | "eac3" | "encaprtp" | "EVRC" | "EVRC-QCP" | "EVRC0" | "EVRC1" | "EVRCB" | "EVRCB0" | "EVRCB1" | "EVRCNW" | "EVRCNW0" | "EVRCNW1" | "EVRCWB" | "EVRCWB0" | "EVRCWB1" | "EVS" | "example" | "flexfec" | "fwdred" | "G711-0" | "G719" | "G7221" | "G722" | "G723" | "G726-16" | "G726-24" | "G726-32" | "G726-40" | "G728" | "G729" | "G7291" | "G729D" | "G729E" | "GSM" | "GSM-EFR" | "GSM-HR-08" | "iLBC" | "ip-mr_v2.5" | "L8" | "L16" | "L20" | "L24" | "LPC" | "matroska" | "MELP" | "MELP600" | "MELP1200" | "MELP2400" | "mhas" | "mobile-xmf" | "MPA" | "mp4" | "MP4A-LATM" | "mpa-robust" | "mpeg" | "mpeg4-generic" | "ogg" | "opus" | "parityfec" | "PCMA" | "PCMA-WB" | "PCMU" | "PCMU-WB" | "prs.sid" | "QCELP" | "raptorfec" | "RED" | "rtp-enc-aescm128" | "rtploopback" | "rtp-midi" | "rtx" | "scip" | "SMV" | "SMV0" | "SMV-QCP" | "sofa" | "sp-midi" | "speex" | "t140c" | "t38" | "telephone-event" | "TETRA_ACELP" | "TETRA_ACELP_BB" | "tone" | "TSVCIS" | "UEMCLIP" | "ulpfec" | "usac" | "VDVI" | "VMR-WB" | "vnd.3gpp.iufp" | "vnd.4SB" | "vnd.audiokoz" | "vnd.CELP" | "vnd.cisco.nse" | "vnd.cmles.radio-events" | "vnd.cns.anp1" | "vnd.cns.inf1" | "vnd.dece.audio" | "vnd.digital-winds" | "vnd.dlna.adts" | "vnd.dolby.heaac.1" | "vnd.dolby.heaac.2" | "vnd.dolby.mlp" | "vnd.dolby.mps" | "vnd.dolby.pl2" | "vnd.dolby.pl2x" | "vnd.dolby.pl2z" | "vnd.dolby.pulse.1" | "vnd.dra" | "vnd.dts" | "vnd.dts.hd" | "vnd.dts.uhd" | "vnd.dvb.file" | "vnd.everad.plj" | "vnd.hns.audio" | "vnd.lucent.voice" | "vnd.ms-playready.media.pya" | "vnd.nokia.mobile-xmf" | "vnd.nortel.vbk" | "vnd.nuera.ecelp4800" | "vnd.nuera.ecelp7470" | "vnd.nuera.ecelp9600" | "vnd.octel.sbc" | "vnd.presonus.multitrack" | "vnd.qcelp" | "vnd.rhetorex.32kadpcm" | "vnd.rip" | "vnd.sealedmedia.softseal.mpeg" | "vnd.vmx.cvsd" | "vorbis" | "vorbis-config"}`;
|
|
291
|
+
type FontMimeType = `font/${"collection" | "otf" | "sfnt" | "ttf" | "woff" | "woff2"}`;
|
|
292
|
+
type ImageMimeType = `image/${"aces" | "apng" | "avci" | "avcs" | "avif" | "bmp" | "cgm" | "dicom-rle" | "dpx" | "emf" | "example" | "fits" | "g3fax" | "heic" | "heic-sequence" | "heif" | "heif-sequence" | "hej2k" | "hsj2" | "j2c" | "jls" | "jp2" | "jph" | "jphc" | "jpm" | "jpx" | "jxr" | "jxrA" | "jxrS" | "jxs" | "jxsc" | "jxsi" | "jxss" | "ktx" | "ktx2" | "naplps" | "png" | "prs.btif" | "prs.pti" | "pwg-raster" | "svg+xml" | "t38" | "tiff" | "tiff-fx" | "vnd.adobe.photoshop" | "vnd.airzip.accelerator.azv" | "vnd.cns.inf2" | "vnd.dece.graphic" | "vnd.djvu" | "vnd.dwg" | "vnd.dxf" | "vnd.dvb.subtitle" | "vnd.fastbidsheet" | "vnd.fpx" | "vnd.fst" | "vnd.fujixerox.edmics-mmr" | "vnd.fujixerox.edmics-rlc" | "vnd.globalgraphics.pgb" | "vnd.microsoft.icon" | "vnd.mix" | "vnd.ms-modi" | "vnd.mozilla.apng" | "vnd.net-fpx" | "vnd.pco.b16" | "vnd.radiance" | "vnd.sealed.png" | "vnd.sealedmedia.softseal.gif" | "vnd.sealedmedia.softseal.jpg" | "vnd.svf" | "vnd.tencent.tap" | "vnd.valve.source.texture" | "vnd.wap.wbmp" | "vnd.xiff" | "vnd.zbrush.pcx" | "webp" | "wmf" | "emf" | "wmf"}`;
|
|
293
|
+
type MessageMimeType = `message/${"bhttp" | "CPIM" | "delivery-status" | "disposition-notification" | "example" | "feedback-report" | "global" | "global-delivery-status" | "global-disposition-notification" | "global-headers" | "http" | "imdn+xml" | "mls" | "news" | "ohttp-req" | "ohttp-res" | "s-http" | "sip" | "sipfrag" | "tracking-status" | "vnd.si.simp" | "vnd.wfa.wsc"}`;
|
|
294
|
+
type ModelMimeType = `model/${"3mf" | "e57" | "example" | "gltf-binary" | "gltf+json" | "JT" | "iges" | "mtl" | "obj" | "prc" | "step" | "step+xml" | "step+zip" | "step-xml+zip" | "stl" | "u3d" | "vnd.bary" | "vnd.cld" | "vnd.collada+xml" | "vnd.dwf" | "vnd.flatland.3dml" | "vnd.gdl" | "vnd.gs-gdl" | "vnd.gtw" | "vnd.moml+xml" | "vnd.mts" | "vnd.opengex" | "vnd.parasolid.transmit.binary" | "vnd.parasolid.transmit.text" | "vnd.pytha.pyox" | "vnd.rosette.annotated-data-model" | "vnd.sap.vds" | "vnd.usda" | "vnd.usdz+zip" | "vnd.valve.source.compiled-map" | "vnd.vtu" | "x3d-vrml" | "x3d+fastinfoset" | "x3d+xml"}`;
|
|
295
|
+
type MultipartMimeType = `multipart/${"appledouble" | "byteranges" | "encrypted" | "example" | "form-data" | "header-set" | "multilingual" | "related" | "report" | "signed" | "vnd.bint.med-plus" | "voice-message" | "x-mixed-replace"}`;
|
|
296
|
+
type TextMimeType = `text/${"1d-interleaved-parityfec" | "cache-manifest" | "calendar" | "cql" | "cql-expression" | "cql-identifier" | "css" | "csv" | "csv-schema" | "directory" | "dns" | "ecmascript" | "encaprtp" | "example" | "fhirpath" | "flexfec" | "fwdred" | "gff3" | "grammar-ref-list" | "hl7v2" | "html" | "javascript" | "jcr-cnd" | "markdown" | "mizar" | "n3" | "parameters" | "parityfec" | "provenance-notation" | "prs.fallenstein.rst" | "prs.lines.tag" | "prs.prop.logic" | "prs.texi" | "raptorfec" | "RED" | "rfc822-headers" | "rtf" | "rtp-enc-aescm128" | "rtploopback" | "rtx" | "SGML" | "shaclc" | "shex" | "spdx" | "strings" | "t140" | "tab-separated-values" | "troff" | "turtle" | "ulpfec" | "uri-list" | "vcard" | "vnd.a" | "vnd.abc" | "vnd.ascii-art" | "vnd.curl" | "vnd.debian.copyright" | "vnd.DMClientScript" | "vnd.dvb.subtitle" | "vnd.esmertec.theme-descriptor" | "vnd.exchangeable" | "vnd.familysearch.gedcom" | "vnd.ficlab.flt" | "vnd.fly" | "vnd.fmi.flexstor" | "vnd.gml" | "vnd.graphviz" | "vnd.hans" | "vnd.hgl" | "vnd.in3d.3dml" | "vnd.in3d.spot" | "vnd.IPTC.NewsML" | "vnd.IPTC.NITF" | "vnd.latex-z" | "vnd.motorola.reflex" | "vnd.ms-mediapackage" | "vnd.net2phone.commcenter.command" | "vnd.radisys.msml-basic-layout" | "vnd.senx.warpscript" | "vnd.si.uricatalogue" | "vnd.sun.j2me.app-descriptor" | "vnd.sosi" | "vnd.trolltech.linguist" | "vnd.wap.si" | "vnd.wap.sl" | "vnd.wap.wml" | "vnd.wap.wmlscript" | "vtt" | "wgsl" | "xml" | "xml-external-parsed-entity"}`;
|
|
297
|
+
type VideoMimeType = `video/${"1d-interleaved-parityfec" | "3gpp" | "3gpp2" | "3gpp-tt" | "AV1" | "BMPEG" | "BT656" | "CelB" | "DV" | "encaprtp" | "example" | "FFV1" | "flexfec" | "H261" | "H263" | "H263-1998" | "H263-2000" | "H264" | "H264-RCDO" | "H264-SVC" | "H265" | "H266" | "iso.segment" | "JPEG" | "jpeg2000" | "jxsv" | "matroska" | "matroska-3d" | "mj2" | "MP1S" | "MP2P" | "MP2T" | "mp4" | "MP4V-ES" | "MPV" | "mpeg4-generic" | "nv" | "ogg" | "parityfec" | "pointer" | "quicktime" | "raptorfec" | "raw" | "rtp-enc-aescm128" | "rtploopback" | "rtx" | "scip" | "smpte291" | "SMPTE292M" | "ulpfec" | "vc1" | "vc2" | "vnd.CCTV" | "vnd.dece.hd" | "vnd.dece.mobile" | "vnd.dece.mp4" | "vnd.dece.pd" | "vnd.dece.sd" | "vnd.dece.video" | "vnd.directv.mpeg" | "vnd.directv.mpeg-tts" | "vnd.dlna.mpeg-tts" | "vnd.dvb.file" | "vnd.fvt" | "vnd.hns.video" | "vnd.iptvforum.1dparityfec-1010" | "vnd.iptvforum.1dparityfec-2005" | "vnd.iptvforum.2dparityfec-1010" | "vnd.iptvforum.2dparityfec-2005" | "vnd.iptvforum.ttsavc" | "vnd.iptvforum.ttsmpeg2" | "vnd.motorola.video" | "vnd.motorola.videop" | "vnd.mpegurl" | "vnd.ms-playready.media.pyv" | "vnd.nokia.interleaved-multimedia" | "vnd.nokia.mp4vr" | "vnd.nokia.videovoip" | "vnd.objectvideo" | "vnd.radgamettools.bink" | "vnd.radgamettools.smacker" | "vnd.sealed.mpeg1" | "vnd.sealed.mpeg4" | "vnd.sealed.swf" | "vnd.sealedmedia.softseal.mov" | "vnd.uvvu.mp4" | "vnd.youtube.yt" | "vnd.vivo" | "VP8" | "VP9"}`;
|
|
298
|
+
type MimeType$1 = ApplicationType | AudioMimeType | FontMimeType | ImageMimeType | MessageMimeType | ModelMimeType | MultipartMimeType | TextMimeType | VideoMimeType | (string & {});
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/http/headers/request.d.ts
|
|
301
|
+
type AnyString$1 = string & {};
|
|
302
|
+
type RequestHeaderName = keyof RequestHeaderMap | AnyString$1;
|
|
303
|
+
interface RequestHeaderMap {
|
|
304
|
+
"Accept": MimeType$1 | AnyString$1;
|
|
305
|
+
"Accept-Charset": AnyString$1;
|
|
306
|
+
"Accept-Encoding": "gzip" | "compress" | "deflate" | "br" | "identity" | AnyString$1;
|
|
307
|
+
"Accept-Language": AnyString$1;
|
|
308
|
+
"Accept-Ch": "Sec-CH-UA" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform" | "Sec-CH-UA-Platform-Version" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-Prefers-Color-Scheme" | "Device-Memory" | "Width" | "Viewport-Width" | "Save-Data" | "Downlink" | "ECT" | "RTT" | AnyString$1;
|
|
309
|
+
"Access-Control-Allow-Credentials": "true" | "false" | AnyString$1;
|
|
310
|
+
"Access-Control-Allow-Headers": RequestHeaderName | AnyString$1;
|
|
311
|
+
"Access-Control-Allow-Methods": HTTPMethod$1 | AnyString$1;
|
|
312
|
+
"Access-Control-Allow-Origin": "*" | AnyString$1;
|
|
313
|
+
"Access-Control-Expose-Headers": RequestHeaderName | AnyString$1;
|
|
314
|
+
"Access-Control-Max-Age": AnyString$1;
|
|
315
|
+
"Access-Control-Request-Headers": RequestHeaderName | AnyString$1;
|
|
316
|
+
"Access-Control-Request-Method": HTTPMethod$1 | AnyString$1;
|
|
317
|
+
"Age": AnyString$1;
|
|
318
|
+
"Allow": HTTPMethod$1 | AnyString$1;
|
|
319
|
+
"Authorization": AnyString$1;
|
|
320
|
+
"Cache-Control": "no-cache" | "no-store" | "max-age" | "must-revalidate" | "public" | "private" | "proxy-revalidate" | "s-maxage" | "stale-while-revalidate" | "stale-if-error" | AnyString$1;
|
|
321
|
+
"Connection": "keep-alive" | "close" | "upgrade" | AnyString$1;
|
|
322
|
+
"Content-Disposition": AnyString$1;
|
|
323
|
+
"Content-Encoding": "gzip" | "compress" | "deflate" | "br" | "identity" | AnyString$1;
|
|
324
|
+
"Content-Language": AnyString$1;
|
|
325
|
+
"Content-Length": AnyString$1;
|
|
326
|
+
"Content-Location": AnyString$1;
|
|
327
|
+
"Content-Range": AnyString$1;
|
|
328
|
+
"Content-Security-Policy": AnyString$1;
|
|
329
|
+
"Content-Type": MimeType$1 | AnyString$1;
|
|
330
|
+
"Cookie": AnyString$1;
|
|
331
|
+
"Critical-CH": AnyString$1;
|
|
332
|
+
"Date": AnyString$1;
|
|
333
|
+
"Device-Memory": "0.25" | "0.5" | "1" | "2" | "4" | "8" | AnyString$1;
|
|
334
|
+
"Digest": AnyString$1;
|
|
335
|
+
"ETag": AnyString$1;
|
|
336
|
+
"Expect": "100-continue" | AnyString$1;
|
|
337
|
+
"Expires": AnyString$1;
|
|
338
|
+
"Forwarded": AnyString$1;
|
|
339
|
+
"From": AnyString$1;
|
|
340
|
+
"Host": AnyString$1;
|
|
341
|
+
"If-Match": AnyString$1;
|
|
342
|
+
"If-Modified-Since": AnyString$1;
|
|
343
|
+
"If-None-Match": AnyString$1;
|
|
344
|
+
"If-Range": AnyString$1;
|
|
345
|
+
"If-Unmodified-Since": AnyString$1;
|
|
346
|
+
"Keep-Alive": `timeout=${string}, max=${string}` | AnyString$1;
|
|
347
|
+
"Last-Modified": AnyString$1;
|
|
348
|
+
"Link": AnyString$1;
|
|
349
|
+
"Location": AnyString$1;
|
|
350
|
+
"Max-Forwards": AnyString$1;
|
|
351
|
+
"Origin": AnyString$1;
|
|
352
|
+
"Origin-Agent-Cluster": `?1` | `?0` | AnyString$1;
|
|
353
|
+
"Ping-From": AnyString$1;
|
|
354
|
+
"Ping-To": AnyString$1;
|
|
355
|
+
"Pragma": AnyString$1;
|
|
356
|
+
"Proxy-Authenticate": AnyString$1;
|
|
357
|
+
"Proxy-Authorization": AnyString$1;
|
|
358
|
+
"Range": AnyString$1;
|
|
359
|
+
"Referer": AnyString$1;
|
|
360
|
+
"Referrer-Policy": "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | AnyString$1;
|
|
361
|
+
"Retry-After": AnyString$1;
|
|
362
|
+
"Save-Data": `on` | `off` | AnyString$1;
|
|
363
|
+
"Sec-CH-UA": AnyString$1;
|
|
364
|
+
"Sec-CH-UA-Arch": "x86" | "ARM" | "[arm64-v8a, armeabi-v7a, armeabi]" | AnyString$1;
|
|
365
|
+
"Sec-CH-UA-Bitness": "64" | "32" | AnyString$1;
|
|
366
|
+
"Sec-CH-UA-Full-Version-List": AnyString$1;
|
|
367
|
+
"Sec-CH-UA-Mobile": `?1` | `?0` | AnyString$1;
|
|
368
|
+
"Sec-CH-UA-Model": AnyString$1;
|
|
369
|
+
"Sec-CH-UA-Platform": "Android" | "Chrome OS" | "Chromium OS" | "iOS" | "Linux" | "macOS" | "Windows" | "Unknown" | AnyString$1;
|
|
370
|
+
"Sec-CH-UA-Platform-Version": AnyString$1;
|
|
371
|
+
"Sec-CH-UA-Prefers-Color-Scheme": "dark" | "light" | AnyString$1;
|
|
372
|
+
"Sec-CH-UA-Prefers-Reduced-Motion": "no-preference" | "reduce" | AnyString$1;
|
|
373
|
+
"Sec-Fetch-Dest": "audio" | "audioworklet" | "document" | "embed" | "empty" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt" | AnyString$1;
|
|
374
|
+
"Sec-Fetch-Mode": "cors" | "navigate" | "no-cors" | "same-origin" | "websocket" | AnyString$1;
|
|
375
|
+
"Sec-Fetch-Site": "cross-site" | "same-origin" | "same-site" | "none" | AnyString$1;
|
|
376
|
+
"Sec-Fetch-User": "?1" | AnyString$1;
|
|
377
|
+
"Sec-Purpose": "prefetch" | AnyString$1;
|
|
378
|
+
"Sec-WebSocket-Accept": AnyString$1;
|
|
379
|
+
"Sec-WebSocket-Extensions": AnyString$1;
|
|
380
|
+
"Sec-WebSocket-Key": AnyString$1;
|
|
381
|
+
"Sec-WebSocket-Protocol": AnyString$1;
|
|
382
|
+
"Sec-WebSocket-Version": AnyString$1;
|
|
383
|
+
"Server": AnyString$1;
|
|
384
|
+
"Service-Worker-Allowed": AnyString$1;
|
|
385
|
+
"Set-Cookie": AnyString$1;
|
|
386
|
+
"Strict-Transport-Security": AnyString$1;
|
|
387
|
+
"TE": "trailers" | AnyString$1;
|
|
388
|
+
"Trailer": AnyString$1;
|
|
389
|
+
"Transfer-Encoding": "chunked" | "compress" | "deflate" | "gzip" | "identity" | AnyString$1;
|
|
390
|
+
"Upgrade": AnyString$1;
|
|
391
|
+
"Upgrade-Insecure-Requests": "1" | AnyString$1;
|
|
392
|
+
"User-Agent": AnyString$1;
|
|
393
|
+
"Vary": AnyString$1;
|
|
394
|
+
"Via": AnyString$1;
|
|
395
|
+
"Warning": AnyString$1;
|
|
396
|
+
"WWW-Authenticate": AnyString$1;
|
|
397
|
+
"X-Content-Type-Options": "nosniff" | AnyString$1;
|
|
398
|
+
"X-DNS-Prefetch-Control": "on" | "off" | AnyString$1;
|
|
399
|
+
"X-Forwarded-For": AnyString$1;
|
|
400
|
+
"X-Forwarded-Host": AnyString$1;
|
|
401
|
+
"X-Forwarded-Proto": AnyString$1;
|
|
402
|
+
"X-Frame-Options": "deny" | "sameorigin" | AnyString$1;
|
|
403
|
+
"X-Permitted-Cross-Domain-Policies": "none" | "master-only" | "by-content-type" | "all" | AnyString$1;
|
|
404
|
+
"X-Pingback": AnyString$1;
|
|
405
|
+
"X-Requested-With": AnyString$1;
|
|
406
|
+
"X-XSS-Protection": "0" | "1" | "1; mode=block" | AnyString$1;
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/http/headers/response.d.ts
|
|
410
|
+
type AnyString = string & {};
|
|
411
|
+
type ResponseHeaderName = keyof ResponseHeaderMap | AnyString;
|
|
412
|
+
interface ResponseHeaderMap {
|
|
413
|
+
"Accept-Patch": AnyString;
|
|
414
|
+
"Accept-Ranges": "bytes" | "none" | AnyString;
|
|
415
|
+
"Access-Control-Allow-Credentials": "true" | AnyString;
|
|
416
|
+
"Access-Control-Allow-Headers": "*" | ResponseHeaderName | AnyString;
|
|
417
|
+
"Access-Control-Allow-Methods": "*" | HTTPMethod$1 | AnyString;
|
|
418
|
+
"Access-Control-Allow-Origin": "*" | "null" | AnyString;
|
|
419
|
+
"Access-Control-Expose-Headers": "*" | ResponseHeaderName | AnyString;
|
|
420
|
+
"Access-Control-Max-Age": AnyString;
|
|
421
|
+
"Age": AnyString;
|
|
422
|
+
"Allow": HTTPMethod$1 | AnyString;
|
|
423
|
+
"Alt-Svc": AnyString;
|
|
424
|
+
"Alt-Used": AnyString;
|
|
425
|
+
"Cache-Control": "no-cache" | "no-store" | "max-age" | "must-revalidate" | "public" | "private" | "proxy-revalidate" | "s-maxage" | "stale-while-revalidate" | "stale-if-error" | AnyString;
|
|
426
|
+
"Clear-Site-Data": AnyString;
|
|
427
|
+
"Connection": "keep-alive" | "close" | AnyString;
|
|
428
|
+
"Content-Disposition": AnyString;
|
|
429
|
+
"Content-DPR": AnyString;
|
|
430
|
+
"Content-Encoding": "gzip" | "compress" | "deflate" | "br" | "identity" | AnyString;
|
|
431
|
+
"Content-Language": AnyString;
|
|
432
|
+
"Content-Length": AnyString;
|
|
433
|
+
"Content-Location": AnyString;
|
|
434
|
+
"Content-Range": AnyString;
|
|
435
|
+
"Content-Security-Policy": AnyString;
|
|
436
|
+
"Content-Security-Policy-Report-Only": AnyString;
|
|
437
|
+
"Content-Type": MimeType | AnyString;
|
|
438
|
+
"Cross-Origin-Embedder-Policy": "unsafe-none" | "require-corp" | "credentialless" | AnyString;
|
|
439
|
+
"Cross-Origin-Opener-Policy": "unsafe-none" | "same-origin-allow-popups" | "same-origin" | AnyString;
|
|
440
|
+
"Cross-Origin-Resource-Policy": "same-site" | "same-origin" | "cross-origin" | AnyString;
|
|
441
|
+
"Date": AnyString;
|
|
442
|
+
"Device-Memory": AnyString;
|
|
443
|
+
"Digest": AnyString;
|
|
444
|
+
"Downlink": AnyString;
|
|
445
|
+
"ECT": "slow-2g" | "2g" | "3g" | "4g" | AnyString;
|
|
446
|
+
"ETag": AnyString;
|
|
447
|
+
"Early-Data": "1" | AnyString;
|
|
448
|
+
"Expect-CT": AnyString;
|
|
449
|
+
"Expires": AnyString;
|
|
450
|
+
"Feature-Policy": AnyString;
|
|
451
|
+
"Last-Event-ID": AnyString;
|
|
452
|
+
"Last-Modified": AnyString;
|
|
453
|
+
"Link": AnyString;
|
|
454
|
+
"Location": AnyString;
|
|
455
|
+
"NEL": AnyString;
|
|
456
|
+
"Origin-Agent-Cluster": AnyString;
|
|
457
|
+
"Origin-Isolation": AnyString;
|
|
458
|
+
"Proxy-Authenticate": AnyString;
|
|
459
|
+
"Public-Key-Pins": AnyString;
|
|
460
|
+
"Public-Key-Pins-Report-Only": AnyString;
|
|
461
|
+
"Refresh": AnyString;
|
|
462
|
+
"Report-To": AnyString;
|
|
463
|
+
"Retry-After": AnyString;
|
|
464
|
+
"Save-Data": AnyString;
|
|
465
|
+
"Sec-WebSocket-Accept": AnyString;
|
|
466
|
+
"Sec-WebSocket-Extensions": AnyString;
|
|
467
|
+
"Sec-WebSocket-Protocol": AnyString;
|
|
468
|
+
"Sec-WebSocket-Version": AnyString;
|
|
469
|
+
"Server": AnyString;
|
|
470
|
+
"Server-Timing": AnyString;
|
|
471
|
+
"Service-Worker-Allowed": AnyString;
|
|
472
|
+
"Service-Worker-Navigation-Preload": AnyString;
|
|
473
|
+
"Set-Cookie": AnyString;
|
|
474
|
+
"Signature": AnyString;
|
|
475
|
+
"Signed-Headers": AnyString;
|
|
476
|
+
"Sourcemap": AnyString;
|
|
477
|
+
"Strict-Transport-Security": AnyString;
|
|
478
|
+
"Timing-Allow-Origin": AnyString;
|
|
479
|
+
"Tk": AnyString;
|
|
480
|
+
"Vary": AnyString;
|
|
481
|
+
"Via": AnyString;
|
|
482
|
+
"WWW-Authenticate": AnyString;
|
|
483
|
+
"X-Content-Type-Options": "nosniff" | AnyString;
|
|
484
|
+
"X-DNS-Prefetch-Control": "on" | "off" | AnyString;
|
|
485
|
+
"X-Frame-Options": "DENY" | "SAMEORIGIN" | AnyString;
|
|
486
|
+
"X-Permitted-Cross-Domain-Policies": "none" | "master-only" | "by-content-type" | "all" | AnyString;
|
|
487
|
+
"X-Powered-By": AnyString;
|
|
488
|
+
"X-Robots-Tag": AnyString;
|
|
489
|
+
"X-UA-Compatible": "IE=edge" | AnyString;
|
|
490
|
+
"X-XSS-Protection": "0" | "1" | "1; mode=block" | AnyString;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/http/index.d.ts
|
|
494
|
+
type HTTPMethod$1 = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD" | "CONNECT" | "TRACE";
|
|
495
|
+
export type MaybePromise<T = unknown> = T | Promise<T>;
|
|
496
|
+
export type HTTPHandler<_RequestT extends EventHandlerRequest = any> = EventHandler<_RequestT> | FetchableObject | H3Core;
|
|
497
|
+
/** Collapses the `any` request type of a bare {@link HTTPHandler} to the default request shape. */
|
|
498
|
+
export type ResolvedRequest<_RequestT extends EventHandlerRequest> = 0 extends 1 & _RequestT ? EventHandlerRequest : _RequestT;
|
|
499
|
+
export interface EventHandler<_RequestT extends EventHandlerRequest = EventHandlerRequest, _ResponseT extends EventHandlerResponse = EventHandlerResponse> {
|
|
500
|
+
(event: H3Event<_RequestT>): _ResponseT;
|
|
501
|
+
meta?: H3RouteMeta;
|
|
502
|
+
}
|
|
503
|
+
export interface EventHandlerObject<_RequestT extends EventHandlerRequest = EventHandlerRequest, _ResponseT extends EventHandlerResponse = EventHandlerResponse> {
|
|
504
|
+
handler?: EventHandler<_RequestT, _ResponseT>;
|
|
505
|
+
fetch?: FetchHandler$1;
|
|
506
|
+
middleware?: Middleware[];
|
|
507
|
+
meta?: H3RouteMeta;
|
|
508
|
+
}
|
|
509
|
+
export interface EventHandlerRequest {
|
|
510
|
+
body?: unknown;
|
|
511
|
+
headers?: unknown;
|
|
512
|
+
query?: Partial<Record<string, string | string[]>>;
|
|
513
|
+
routerParams?: Record<string, string>;
|
|
514
|
+
}
|
|
515
|
+
export type EventHandlerResponse<T = unknown> = T | Promise<T>;
|
|
516
|
+
export type TypedServerRequest<_RequestT extends EventHandlerRequest = EventHandlerRequest> = Omit<ServerRequest, "json" | "headers" | "clone"> & Pick<TypedRequest<NonNullable<_RequestT["body"]>, Record<keyof RequestHeaderMap, string>>, "json" | "headers" | "clone">;
|
|
517
|
+
type FetchHandler$1 = (req: ServerRequest) => Response | Promise<Response>;
|
|
518
|
+
export type FetchableObject = {
|
|
519
|
+
fetch: FetchHandler$1;
|
|
520
|
+
};
|
|
521
|
+
export type EventHandlerWithFetch<_RequestT extends EventHandlerRequest = EventHandlerRequest, _ResponseT extends EventHandlerResponse = EventHandlerResponse> = EventHandler<_RequestT, _ResponseT> & {
|
|
522
|
+
fetch: EventHandlerFetch<TypedResponse<_ResponseT, ResponseHeaderMap>>;
|
|
523
|
+
};
|
|
524
|
+
export type EventHandlerFetch<T extends Response | TypedResponse = Response> = (req: ServerRequest | URL | string) => Promise<T>;
|
|
525
|
+
export type Middleware = (event: H3Event, next: () => MaybePromise<unknown | undefined>) => MaybePromise<unknown | undefined>;
|
|
526
|
+
export type LazyEventHandler = () => EventHandler | FetchableObject | Promise<EventHandler | FetchableObject>;
|
|
527
|
+
export interface DynamicEventHandler extends EventHandlerWithFetch {
|
|
528
|
+
set: (handler: EventHandler | FetchableObject) => void;
|
|
529
|
+
}
|
|
530
|
+
export type InferEventInput<Key extends keyof EventHandlerRequest, Event extends HTTPEvent, T> = void extends T ? (Event extends HTTPEvent<infer E> ? E[Key] : never) : T;
|
|
531
|
+
/**
|
|
532
|
+
* Raw object describing HTTP error (passed to `HTTPError` constructor).
|
|
533
|
+
*/
|
|
534
|
+
export interface ErrorInput<DataT = unknown> extends Partial<ErrorBody<DataT>> {
|
|
535
|
+
/**
|
|
536
|
+
* Original error object that caused this error.
|
|
537
|
+
*/
|
|
538
|
+
cause?: unknown;
|
|
539
|
+
/**
|
|
540
|
+
* Additional HTTP headers to be sent in error response.
|
|
541
|
+
*/
|
|
542
|
+
headers?: HeadersInit;
|
|
543
|
+
/**
|
|
544
|
+
* @deprecated use `status`
|
|
545
|
+
*/
|
|
546
|
+
statusCode?: number;
|
|
547
|
+
/**
|
|
548
|
+
* @deprecated use `statusText`
|
|
549
|
+
*/
|
|
550
|
+
statusMessage?: string;
|
|
551
|
+
}
|
|
552
|
+
export type ErrorDetails = (Error & {
|
|
553
|
+
cause?: unknown;
|
|
554
|
+
}) | HTTPError | ErrorInput;
|
|
555
|
+
export interface ErrorBody<DataT = unknown> {
|
|
556
|
+
/**
|
|
557
|
+
* HTTP status code in range [200...599]
|
|
558
|
+
*/
|
|
559
|
+
status: number;
|
|
560
|
+
/**
|
|
561
|
+
* HTTP status text
|
|
562
|
+
*
|
|
563
|
+
* **NOTE:** This should be short (max 512 to 1024 characters).
|
|
564
|
+
* Allowed characters are tabs, spaces, visible ASCII characters, and extended characters (byte value 128–255).
|
|
565
|
+
*
|
|
566
|
+
* **TIP:** Use `message` for longer error descriptions in JSON body.
|
|
567
|
+
*/
|
|
568
|
+
statusText?: string;
|
|
569
|
+
/**
|
|
570
|
+
* HTTP Error message.
|
|
571
|
+
*
|
|
572
|
+
* **NOTE:** This message will be in JSON body under `message` key.
|
|
573
|
+
*/
|
|
574
|
+
message: string;
|
|
575
|
+
/**
|
|
576
|
+
* Flag to indicate that the error was not handled by the application.
|
|
577
|
+
*
|
|
578
|
+
* Unhandled error stack trace, `data`, `body` and `message` are hidden for security reasons.
|
|
579
|
+
*/
|
|
580
|
+
unhandled?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Additional data to attach in the error JSON body under `data` key.
|
|
583
|
+
*/
|
|
584
|
+
data?: DataT;
|
|
585
|
+
/**
|
|
586
|
+
* Additional top level JSON body properties to attach in the error JSON body.
|
|
587
|
+
*/
|
|
588
|
+
body?: Record<string, unknown>;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* HTTPError
|
|
592
|
+
*/
|
|
593
|
+
export declare class HTTPError<DataT = unknown> extends Error implements ErrorBody<DataT> {
|
|
594
|
+
override get name(): string;
|
|
595
|
+
/**
|
|
596
|
+
* HTTP status code in range [200...599]
|
|
597
|
+
*/
|
|
598
|
+
readonly status: number;
|
|
599
|
+
/**
|
|
600
|
+
* HTTP status text
|
|
601
|
+
*
|
|
602
|
+
* **NOTE:** This should be short (max 512 to 1024 characters).
|
|
603
|
+
* Allowed characters are tabs, spaces, visible ASCII characters, and extended characters (byte value 128–255).
|
|
604
|
+
*
|
|
605
|
+
* **TIP:** Use `message` for longer error descriptions in JSON body.
|
|
606
|
+
*/
|
|
607
|
+
readonly statusText: string | undefined;
|
|
608
|
+
/**
|
|
609
|
+
* Additional HTTP headers to be sent in error response.
|
|
610
|
+
*/
|
|
611
|
+
readonly headers: Headers | undefined;
|
|
612
|
+
/**
|
|
613
|
+
* Original error object that caused this error.
|
|
614
|
+
*/
|
|
615
|
+
override readonly cause: unknown | undefined;
|
|
616
|
+
/**
|
|
617
|
+
* Additional data attached in the error JSON body under `data` key.
|
|
618
|
+
*/
|
|
619
|
+
readonly data: DataT | undefined;
|
|
620
|
+
/**
|
|
621
|
+
* Additional top level JSON body properties to attach in the error JSON body.
|
|
622
|
+
*/
|
|
623
|
+
readonly body: Record<string, unknown> | undefined;
|
|
624
|
+
/**
|
|
625
|
+
* Flag to indicate that the error was not handled by the application.
|
|
626
|
+
*
|
|
627
|
+
* Unhandled error stack trace, data and message are hidden in non debug mode for security reasons.
|
|
628
|
+
*/
|
|
629
|
+
readonly unhandled: boolean | undefined;
|
|
630
|
+
/**
|
|
631
|
+
* Check if the input is an instance of HTTPError using its constructor name and status.
|
|
632
|
+
*
|
|
633
|
+
* It is safer than using `instanceof` because it works across different contexts (e.g., if the error was thrown in a different module).
|
|
634
|
+
*
|
|
635
|
+
* Requiring a `status` rejects unrelated errors named `HTTPError` (e.g. from fetch clients like `ky` or `got`), while
|
|
636
|
+
* still accepting HTTPError-shaped errors from other packages (e.g. srvx `BodyTooLargeError`).
|
|
637
|
+
*/
|
|
638
|
+
static override isError(input: any): input is HTTPError;
|
|
639
|
+
/**
|
|
640
|
+
* Create a new HTTPError with the given status code and optional status text and details.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
*
|
|
644
|
+
* HTTPError.status(404)
|
|
645
|
+
* HTTPError.status(418, "I'm a teapot")
|
|
646
|
+
* HTTPError.status(403, "Forbidden", { message: "Not authenticated" })
|
|
647
|
+
*/
|
|
648
|
+
static status(status: number, statusText?: string, details?: Exclude<ErrorDetails, "status" | "statusText" | "statusCode" | "statusMessage">): HTTPError;
|
|
649
|
+
/**
|
|
650
|
+
* Create a new HTTPError with the given message and optional details.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
*
|
|
654
|
+
* new HTTPError("This is an error", { status: 400, cause: error })
|
|
655
|
+
* new HTTPError({ message: "This is an error", status: 500, statusText: "Not Found", data: {} })
|
|
656
|
+
*/
|
|
657
|
+
constructor(message: string, details?: ErrorDetails);
|
|
658
|
+
constructor(details: ErrorDetails);
|
|
659
|
+
/**
|
|
660
|
+
* @deprecated Use `status`
|
|
661
|
+
*/
|
|
662
|
+
get statusCode(): number;
|
|
663
|
+
/**
|
|
664
|
+
* @deprecated Use `statusText`
|
|
665
|
+
*/
|
|
666
|
+
get statusMessage(): string | undefined;
|
|
667
|
+
toJSON(): Omit<ErrorBody, "body"> & ErrorBody["body"];
|
|
668
|
+
}
|
|
669
|
+
export type H3Plugin = (h3: H3) => void;
|
|
670
|
+
export declare function definePlugin<T = unknown>(def: (h3: H3, options: T) => void): undefined extends T ? (options?: T) => H3Plugin : (options: T) => H3Plugin;
|
|
671
|
+
export declare function defineMiddleware(input: Middleware): Middleware;
|
|
672
|
+
/**
|
|
673
|
+
* Composed middleware chain: calls each middleware in order, then the final `handler`.
|
|
674
|
+
*
|
|
675
|
+
* The chain is built once per middleware list (see {@link composeMiddleware}) and the
|
|
676
|
+
* terminal handler is passed per-call so one composed chain can serve every route.
|
|
677
|
+
*/
|
|
678
|
+
export type ComposedMiddleware = (event: H3Event, handler: EventHandler) => unknown | Promise<unknown>;
|
|
679
|
+
/**
|
|
680
|
+
* Precompose a middleware list into a single callable chain.
|
|
681
|
+
*
|
|
682
|
+
* Unlike {@link callMiddleware}, per-layer dispatch cost is paid once at build time
|
|
683
|
+
* instead of on every request. Later mutations of the input array are not reflected —
|
|
684
|
+
* rebuild when the list changes.
|
|
685
|
+
*/
|
|
686
|
+
export declare function composeMiddleware(middleware: Middleware[]): ComposedMiddleware;
|
|
687
|
+
export declare function callMiddleware(event: H3Event, middleware: Middleware[], handler: EventHandler, index?: number): unknown | Promise<unknown>;
|
|
688
|
+
/**
|
|
689
|
+
* Converts any HTTPHandler or Middleware into Middleware.
|
|
690
|
+
*
|
|
691
|
+
* If FetchableObject or Handler returns a Response with 404 status, the next middleware will be called.
|
|
692
|
+
*/
|
|
693
|
+
export declare function toMiddleware(input: HTTPHandler | Middleware | undefined): Middleware;
|
|
694
|
+
export interface RouterContext {
|
|
695
|
+
root: any;
|
|
696
|
+
static: Record<string, any>;
|
|
697
|
+
}
|
|
698
|
+
export type MatchedRoute<T = any> = {
|
|
699
|
+
data: T;
|
|
700
|
+
params?: Record<string, string>;
|
|
701
|
+
};
|
|
702
|
+
export type HTTPMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "QUERY";
|
|
703
|
+
export interface H3Config {
|
|
704
|
+
/**
|
|
705
|
+
* When enabled, H3 displays debugging stack traces in HTTP responses (potentially dangerous for production!).
|
|
706
|
+
*/
|
|
707
|
+
debug?: boolean;
|
|
708
|
+
/**
|
|
709
|
+
* When enabled, H3 console errors for unhandled exceptions will not be displayed.
|
|
710
|
+
*/
|
|
711
|
+
silent?: boolean;
|
|
712
|
+
/**
|
|
713
|
+
* By default H3 rejects requests with a malformed percent-encoded URL path
|
|
714
|
+
* (e.g. `/foo%`, `/%ZZ`) with a `400 Bad Request` before routing.
|
|
715
|
+
*
|
|
716
|
+
* When enabled, such requests are allowed through with the raw, undecoded
|
|
717
|
+
* pathname instead. Your handlers are then responsible for handling it safely.
|
|
718
|
+
*/
|
|
719
|
+
allowMalformedURL?: boolean;
|
|
720
|
+
plugins?: H3Plugin[];
|
|
721
|
+
onRequest?: (event: H3Event) => MaybePromise<void>;
|
|
722
|
+
onResponse?: (response: Response, event: H3Event) => MaybePromise<void>;
|
|
723
|
+
onError?: (error: HTTPError, event: H3Event) => MaybePromise<void | unknown>;
|
|
724
|
+
}
|
|
725
|
+
export type H3CoreConfig = Omit<H3Config, "plugins">;
|
|
726
|
+
export type PreparedResponse = ResponseInit & {
|
|
727
|
+
body?: BodyInit | null;
|
|
728
|
+
};
|
|
729
|
+
export interface H3RouteMeta {
|
|
730
|
+
readonly [key: string]: unknown;
|
|
731
|
+
}
|
|
732
|
+
export interface H3Route {
|
|
733
|
+
route?: string;
|
|
734
|
+
method?: HTTPMethod;
|
|
735
|
+
middleware?: Middleware[];
|
|
736
|
+
meta?: H3RouteMeta;
|
|
737
|
+
handler: EventHandler;
|
|
738
|
+
/**
|
|
739
|
+
* Cached composition of `middleware` + `handler` (built on first match).
|
|
740
|
+
* @internal
|
|
741
|
+
*/
|
|
742
|
+
"~composed"?: EventHandler;
|
|
743
|
+
}
|
|
744
|
+
export type RouteOptions = {
|
|
745
|
+
middleware?: Middleware[];
|
|
746
|
+
meta?: H3RouteMeta;
|
|
747
|
+
};
|
|
748
|
+
export type MiddlewareOptions = {
|
|
749
|
+
method?: string;
|
|
750
|
+
match?: (event: H3Event) => boolean;
|
|
751
|
+
};
|
|
752
|
+
declare class H3Core$1 {
|
|
753
|
+
/**
|
|
754
|
+
* Brand used to detect H3 instances (see `toEventHandler`).
|
|
755
|
+
* @internal
|
|
756
|
+
*/
|
|
757
|
+
static "~h3": boolean;
|
|
758
|
+
/**
|
|
759
|
+
* H3 instance config.
|
|
760
|
+
*/
|
|
761
|
+
readonly config: H3Config;
|
|
762
|
+
/** @internal */
|
|
763
|
+
"~middleware": Middleware[];
|
|
764
|
+
/**
|
|
765
|
+
* Cached dispatch function (invalidated by `use()` and `mount()`).
|
|
766
|
+
* @internal
|
|
767
|
+
*/
|
|
768
|
+
"~dispatch"?: (event: H3Event, route: MatchedRoute<H3Route> | void) => unknown | Promise<unknown>;
|
|
769
|
+
/**
|
|
770
|
+
* Cached composition of `~middleware` (invalidated by `use()` and `mount()`).
|
|
771
|
+
* @internal
|
|
772
|
+
*/
|
|
773
|
+
"~composed"?: ComposedMiddleware;
|
|
774
|
+
/** @internal */
|
|
775
|
+
"~routes": H3Route[];
|
|
776
|
+
/**
|
|
777
|
+
* Create a new H3 app instance.
|
|
778
|
+
*/
|
|
779
|
+
constructor(config?: H3Config);
|
|
780
|
+
/**
|
|
781
|
+
* A [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)-compatible API allowing to fetch app routes.
|
|
782
|
+
*
|
|
783
|
+
* Input should be standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object.
|
|
784
|
+
*
|
|
785
|
+
* Returned value is a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) Promise.
|
|
786
|
+
*/
|
|
787
|
+
fetch(_request: ServerRequest): Response | Promise<Response>;
|
|
788
|
+
/**
|
|
789
|
+
* An h3 compatible event handler useful to compose multiple h3 app instances.
|
|
790
|
+
*/
|
|
791
|
+
handler(event: H3Event): unknown | Promise<unknown>;
|
|
792
|
+
/** @internal */
|
|
793
|
+
"~request"(request: ServerRequest, context?: H3EventContext): Response | Promise<Response>;
|
|
794
|
+
/** @internal */
|
|
795
|
+
"~findRoute"(_event: H3Event): MatchedRoute<H3Route> | void;
|
|
796
|
+
/**
|
|
797
|
+
* Returns the middleware chain for an event. Can be overridden (subclass method or
|
|
798
|
+
* instance assignment) to provide dynamic per-event middleware, which disables
|
|
799
|
+
* middleware precomposition. Override before handling the first request — the
|
|
800
|
+
* dispatch strategy is cached and only re-evaluated after `use()` or `mount()`.
|
|
801
|
+
* @internal
|
|
802
|
+
*/
|
|
803
|
+
"~getMiddleware"(event: H3Event, route: MatchedRoute<H3Route> | undefined): Middleware[];
|
|
804
|
+
/** @internal */
|
|
805
|
+
"~addRoute"(_route: H3Route): void;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Registers a route handler, inferring the handler request type when it has one.
|
|
809
|
+
*/
|
|
810
|
+
export interface RouteRegistrar<T> {
|
|
811
|
+
<_RequestT extends EventHandlerRequest = EventHandlerRequest>(route: string, handler: HTTPHandler<_RequestT>, opts?: RouteOptions): T;
|
|
812
|
+
}
|
|
813
|
+
declare class H3$1 extends H3Core$1 {
|
|
814
|
+
/** @internal */
|
|
815
|
+
"~rou3": RouterContext;
|
|
816
|
+
/**
|
|
817
|
+
* A [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)-compatible API allowing to fetch app routes.
|
|
818
|
+
*
|
|
819
|
+
* Input can be a URL, relative path or standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object.
|
|
820
|
+
*
|
|
821
|
+
* Returned value is a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) Promise.
|
|
822
|
+
*/
|
|
823
|
+
request(request: ServerRequest | URL | string, options?: RequestInit, context?: H3EventContext): Response | Promise<Response>;
|
|
824
|
+
/**
|
|
825
|
+
* Register a global middleware.
|
|
826
|
+
*/
|
|
827
|
+
use(route: string, handler: Middleware | H3$1, opts?: MiddlewareOptions): this;
|
|
828
|
+
use(handler: Middleware | H3$1, opts?: MiddlewareOptions): this;
|
|
829
|
+
/**
|
|
830
|
+
* Register a route handler for the specified HTTP method and route.
|
|
831
|
+
*/
|
|
832
|
+
on<_RequestT extends EventHandlerRequest = EventHandlerRequest>(method: HTTPMethod | Lowercase<HTTPMethod> | "", route: string, handler: HTTPHandler<_RequestT>, opts?: RouteOptions): this;
|
|
833
|
+
/**
|
|
834
|
+
* Immediately register an H3 plugin.
|
|
835
|
+
*/
|
|
836
|
+
register(plugin: H3Plugin): this;
|
|
837
|
+
/**
|
|
838
|
+
* Mount an H3 app or a `.fetch` compatible server (like Hono or Elysia) with a base prefix.
|
|
839
|
+
*
|
|
840
|
+
* When mounting a sub-app, all routes will be added with base prefix and global middleware will be added as one prefixed middleware.
|
|
841
|
+
*
|
|
842
|
+
* **Note:** Sub-app options and global hooks are not inherited by the mounted app please consider setting them in the main app directly.
|
|
843
|
+
*/
|
|
844
|
+
mount(base: string, input: FetchHandler | {
|
|
845
|
+
fetch: FetchHandler;
|
|
846
|
+
} | H3$1): this;
|
|
847
|
+
/**
|
|
848
|
+
* Register a route handler for all HTTP methods.
|
|
849
|
+
*/
|
|
850
|
+
all: RouteRegistrar<this>;
|
|
851
|
+
get: RouteRegistrar<this>;
|
|
852
|
+
post: RouteRegistrar<this>;
|
|
853
|
+
put: RouteRegistrar<this>;
|
|
854
|
+
delete: RouteRegistrar<this>;
|
|
855
|
+
patch: RouteRegistrar<this>;
|
|
856
|
+
head: RouteRegistrar<this>;
|
|
857
|
+
options: RouteRegistrar<this>;
|
|
858
|
+
connect: RouteRegistrar<this>;
|
|
859
|
+
trace: RouteRegistrar<this>;
|
|
860
|
+
query: RouteRegistrar<this>;
|
|
861
|
+
}
|
|
862
|
+
export declare function toResponse(val: unknown, event: H3Event, config?: H3Config): Response | Promise<Response>;
|
|
863
|
+
export declare class HTTPResponse {
|
|
864
|
+
#private;
|
|
865
|
+
body?: BodyInit | null;
|
|
866
|
+
constructor(body: BodyInit | null, init?: Pick<ResponseInit, "status" | "statusText" | "headers">);
|
|
867
|
+
/**
|
|
868
|
+
* Status of the response, or `undefined` when unset.
|
|
869
|
+
*
|
|
870
|
+
* Unset means "inherit": the status staged on `event.res.status` is used, falling back to `200`.
|
|
871
|
+
* Defaulting to `200` here instead would make an untouched `HTTPResponse` indistinguishable from
|
|
872
|
+
* one explicitly built with `{ status: 200 }`, and always win over `event.res`.
|
|
873
|
+
*/
|
|
874
|
+
get status(): number | undefined;
|
|
875
|
+
/** Status text of the response, or `undefined` when unset. See {@link HTTPResponse.status}. */
|
|
876
|
+
get statusText(): string | undefined;
|
|
877
|
+
get headers(): Headers;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Check if the origin is allowed.
|
|
881
|
+
*/
|
|
882
|
+
export declare function isCorsOriginAllowed(origin: string | null | undefined, options: CorsOptions): boolean;
|
|
883
|
+
export interface CorsOptions {
|
|
884
|
+
/**
|
|
885
|
+
* This determines the value of the "access-control-allow-origin" response header.
|
|
886
|
+
* If "*", it can be used to allow all origins.
|
|
887
|
+
* If an array of strings or regular expressions, it can be used with origin matching.
|
|
888
|
+
* If a custom function, it's used to validate the origin. It takes the origin as an argument and returns `true` if allowed.
|
|
889
|
+
*
|
|
890
|
+
* **Security:** Regular-expression entries are tested against the full origin
|
|
891
|
+
* string **unanchored** (via `RegExp.prototype.test`). A pattern like
|
|
892
|
+
* `/example\.com/` therefore also matches `https://example.com.evil.test` and
|
|
893
|
+
* `https://notexample.com`. Always **anchor** (`^`…`$`) and **escape** literal
|
|
894
|
+
* dots in regex origins — e.g. `/^https:\/\/([a-z0-9-]+\.)?example\.com$/` to
|
|
895
|
+
* allow `example.com` and one optional subdomain label (use `(…\.)*` for
|
|
896
|
+
* arbitrary depth), or `/^https?:\/\/example\.com$/` for an exact host. Prefer
|
|
897
|
+
* plain string entries (matched by exact equality) when
|
|
898
|
+
* you don't need pattern matching.
|
|
899
|
+
*
|
|
900
|
+
* Avoid `"null"` together with `credentials: true`. Sandboxed iframes, `data:`/`file:` documents,
|
|
901
|
+
* and other opaque origins all send `Origin: null`, so allowing it with credentials would share
|
|
902
|
+
* them across untrusted contexts.
|
|
903
|
+
*
|
|
904
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
|
905
|
+
* @default "*"
|
|
906
|
+
*/
|
|
907
|
+
origin?: "*" | "null" | (string | RegExp)[] | ((origin: string) => boolean);
|
|
908
|
+
/**
|
|
909
|
+
* This determines the value of the "access-control-allow-methods" response header of a preflight request.
|
|
910
|
+
*
|
|
911
|
+
* The default `"*"` permits any method (including non-safelisted ones like `QUERY`).
|
|
912
|
+
* When using an explicit allowlist, remember that `QUERY` is **not** a CORS-safelisted
|
|
913
|
+
* method, so browsers preflight it — include `"QUERY"` in the array to allow it.
|
|
914
|
+
*
|
|
915
|
+
* When `credentials` is enabled, browsers treat `"*"` as a literal method name — in that
|
|
916
|
+
* case the requested method is reflected back instead of sending a literal `*`.
|
|
917
|
+
*
|
|
918
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
|
|
919
|
+
* @default "*"
|
|
920
|
+
* @example ["GET", "HEAD", "PUT", "POST", "QUERY"]
|
|
921
|
+
*/
|
|
922
|
+
methods?: "*" | string[];
|
|
923
|
+
/**
|
|
924
|
+
* This determines the value of the "access-control-allow-headers" response header of a preflight request.
|
|
925
|
+
*
|
|
926
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
|
|
927
|
+
* @default "*"
|
|
928
|
+
*/
|
|
929
|
+
allowHeaders?: "*" | string[];
|
|
930
|
+
/**
|
|
931
|
+
* This determines the value of the "access-control-expose-headers" response header.
|
|
932
|
+
*
|
|
933
|
+
* When `credentials` is enabled, browsers treat `"*"` as a literal header name — in that
|
|
934
|
+
* case the header is omitted; list the headers explicitly to expose them.
|
|
935
|
+
*
|
|
936
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
|
|
937
|
+
* @default "*"
|
|
938
|
+
*/
|
|
939
|
+
exposeHeaders?: "*" | string[];
|
|
940
|
+
/**
|
|
941
|
+
* This determines the value of the "access-control-allow-credentials" response header.
|
|
942
|
+
* When request with credentials, the options that `origin`, `methods`, `exposeHeaders` and `allowHeaders` should not be set "*".
|
|
943
|
+
*
|
|
944
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
|
|
945
|
+
* @see https://fetch.spec.whatwg.org/#cors-protocol-and-credentials
|
|
946
|
+
* @default false
|
|
947
|
+
*/
|
|
948
|
+
credentials?: boolean;
|
|
949
|
+
/**
|
|
950
|
+
* This determines the value of the "access-control-max-age" response header of a preflight request.
|
|
951
|
+
*
|
|
952
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
|
953
|
+
* @default false
|
|
954
|
+
*/
|
|
955
|
+
maxAge?: string | false;
|
|
956
|
+
/**
|
|
957
|
+
*
|
|
958
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
|
|
959
|
+
*/
|
|
960
|
+
preflight?: {
|
|
961
|
+
statusCode?: number;
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Check if the incoming request is a CORS preflight request.
|
|
966
|
+
*/
|
|
967
|
+
export declare function isPreflightRequest(event: HTTPEvent): boolean;
|
|
968
|
+
/**
|
|
969
|
+
* Append CORS preflight headers to the response.
|
|
970
|
+
*/
|
|
971
|
+
export declare function appendCorsPreflightHeaders(event: H3Event, options: CorsOptions): void;
|
|
972
|
+
/**
|
|
973
|
+
* Append CORS headers to the response.
|
|
974
|
+
*/
|
|
975
|
+
export declare function appendCorsHeaders(event: H3Event, options: CorsOptions): void;
|
|
976
|
+
/**
|
|
977
|
+
* Handle CORS for the incoming request.
|
|
978
|
+
*
|
|
979
|
+
* If the incoming request is a CORS preflight request, it will append the CORS preflight headers and send a 204 response.
|
|
980
|
+
*
|
|
981
|
+
* If return value is not `false`, the request is handled and no further action is needed.
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* const app = new H3();
|
|
985
|
+
* app.all("/", async (event) => {
|
|
986
|
+
* const corsRes = handleCors(event, {
|
|
987
|
+
* origin: "*",
|
|
988
|
+
* preflight: {
|
|
989
|
+
* statusCode: 204,
|
|
990
|
+
* },
|
|
991
|
+
* methods: "*",
|
|
992
|
+
* });
|
|
993
|
+
* if (corsRes !== false) {
|
|
994
|
+
* return corsRes;
|
|
995
|
+
* }
|
|
996
|
+
* // Your code here
|
|
997
|
+
* });
|
|
998
|
+
*/
|
|
999
|
+
export declare function handleCors(event: H3Event, options: CorsOptions): false | HTTPResponse;
|
|
1000
|
+
export interface ProxyOptions {
|
|
1001
|
+
headers?: HeadersInit;
|
|
1002
|
+
/**
|
|
1003
|
+
* Header names allowed to bypass the built-in denylist. Matched
|
|
1004
|
+
* case-insensitively.
|
|
1005
|
+
*
|
|
1006
|
+
* This is **not** an exclusive allowlist: all ordinary request headers are
|
|
1007
|
+
* still forwarded regardless. It only lists exceptions that force-forward a
|
|
1008
|
+
* header the proxy would otherwise drop — e.g. `forwardHeaders: ["host"]`
|
|
1009
|
+
* forwards the client's `host` verbatim. `filterHeaders` still wins over it.
|
|
1010
|
+
*
|
|
1011
|
+
* Only the "soft" drops (`host`, `accept-encoding`, `expect`) can be
|
|
1012
|
+
* overridden this way. It can **never** force-forward a true hop-by-hop framing header
|
|
1013
|
+
* (`connection`, `keep-alive`, `transfer-encoding`, `te`, `trailer`,
|
|
1014
|
+
* `upgrade`, `proxy-authorization`, `proxy-connection`) or a field the
|
|
1015
|
+
* incoming `Connection` header nominates — forwarding those could desync
|
|
1016
|
+
* request framing or leak the inbound proxy's credentials upstream, so they
|
|
1017
|
+
* are always dropped.
|
|
1018
|
+
*/
|
|
1019
|
+
forwardHeaders?: string[];
|
|
1020
|
+
/**
|
|
1021
|
+
* Denylist of incoming request header names to drop before proxying.
|
|
1022
|
+
* Header names are matched case-insensitively.
|
|
1023
|
+
*/
|
|
1024
|
+
filterHeaders?: string[];
|
|
1025
|
+
/**
|
|
1026
|
+
* Options forwarded to the underlying `fetch()` call.
|
|
1027
|
+
*
|
|
1028
|
+
* Upstream 3xx responses are passed through to the client by default
|
|
1029
|
+
* (`redirect: "manual"`) rather than followed. Set
|
|
1030
|
+
* `fetchOptions: { redirect: "follow" }` to restore following redirects — but
|
|
1031
|
+
* note that following a redirect for a request with a streamed body can fail,
|
|
1032
|
+
* since the body cannot be replayed once it has been consumed.
|
|
1033
|
+
*/
|
|
1034
|
+
fetchOptions?: RequestInit & {
|
|
1035
|
+
duplex?: "half" | "full";
|
|
1036
|
+
};
|
|
1037
|
+
cookieDomainRewrite?: string | Record<string, string>;
|
|
1038
|
+
cookiePathRewrite?: string | Record<string, string>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Rewrite `location` and `refresh` response headers, like nginx
|
|
1041
|
+
* `proxy_redirect`:
|
|
1042
|
+
*
|
|
1043
|
+
* - `true` (default): a URL whose origin matches the proxy `target` is
|
|
1044
|
+
* rewritten to the proxy's own origin (path and query preserved), so
|
|
1045
|
+
* client-side redirects keep flowing through the proxy instead of
|
|
1046
|
+
* exposing the upstream host. Relative and third-party URLs are left
|
|
1047
|
+
* untouched, as are internal (`/`-prefixed) targets, which already share
|
|
1048
|
+
* the proxy origin.
|
|
1049
|
+
* - A record maps URL prefixes to replacements (nginx
|
|
1050
|
+
* `proxy_redirect <from> <to>`); the first matching prefix is replaced,
|
|
1051
|
+
* e.g. `{ "https://upstream.example/two/": "/one/" }`. Only the explicit
|
|
1052
|
+
* mappings apply in this mode (including for internal targets).
|
|
1053
|
+
* - `false`: forward these headers verbatim.
|
|
1054
|
+
*
|
|
1055
|
+
* @default true
|
|
1056
|
+
*/
|
|
1057
|
+
locationRewrite?: boolean | Record<string, string>;
|
|
1058
|
+
onResponse?: (event: H3Event, response: Response) => void | Promise<void>;
|
|
1059
|
+
/**
|
|
1060
|
+
* Control how a client disconnect is handled.
|
|
1061
|
+
*
|
|
1062
|
+
* The incoming request's abort signal (`event.req.signal`) is always forwarded
|
|
1063
|
+
* to the proxied request, so a client disconnect aborts the upstream request
|
|
1064
|
+
* and releases its connection. By default the resulting abort is handled
|
|
1065
|
+
* quietly with a `499 Client Closed Request` response (never delivered, since
|
|
1066
|
+
* the client is already gone) rather than logged as a `502` gateway error.
|
|
1067
|
+
*
|
|
1068
|
+
* Set this to `true` to instead let the `AbortError` propagate to your handler
|
|
1069
|
+
* (e.g. to run cleanup). This also applies to a custom `fetchOptions.signal`,
|
|
1070
|
+
* except when it aborts with a `TimeoutError` — timeouts always map to `504`
|
|
1071
|
+
* (see `timeout`).
|
|
1072
|
+
*/
|
|
1073
|
+
propagateAbortError?: boolean;
|
|
1074
|
+
/**
|
|
1075
|
+
* Milliseconds to wait for the upstream response (headers) before giving up.
|
|
1076
|
+
* On timeout the proxy responds with `504 Gateway Timeout`. The deadline is
|
|
1077
|
+
* cleared once the upstream responds — it never cuts off a long-running
|
|
1078
|
+
* response body stream.
|
|
1079
|
+
*
|
|
1080
|
+
* Because a fired timeout aborts with a `TimeoutError`, a caller-supplied
|
|
1081
|
+
* `fetchOptions.signal` that is itself an `AbortSignal.timeout` is also
|
|
1082
|
+
* mapped to `504` (rather than the `499` used for client disconnects) — note
|
|
1083
|
+
* that such a signal stays armed during body streaming and can truncate it;
|
|
1084
|
+
* prefer this option.
|
|
1085
|
+
*/
|
|
1086
|
+
timeout?: number;
|
|
1087
|
+
/**
|
|
1088
|
+
* When `true`, add `x-forwarded-*` request headers derived from the incoming
|
|
1089
|
+
* request so the upstream learns the client and original request info:
|
|
1090
|
+
*
|
|
1091
|
+
* - `x-forwarded-for`: the client IP (`event.req.ip`, when available),
|
|
1092
|
+
* **appended** to any inbound chain (like nginx
|
|
1093
|
+
* `$proxy_add_x_forwarded_for`) so each hop is preserved.
|
|
1094
|
+
* - `x-forwarded-proto`: the incoming request protocol.
|
|
1095
|
+
* - `x-forwarded-host`: the original host (incl. port).
|
|
1096
|
+
* - `x-forwarded-port`: the original port (or the protocol default — `443` for
|
|
1097
|
+
* https, `80` for http).
|
|
1098
|
+
*
|
|
1099
|
+
* An inbound value from the client never wins: the last three are replaced
|
|
1100
|
+
* with the server-resolved values from `event.url`, and the client's
|
|
1101
|
+
* `x-forwarded-for` becomes only the left of the chain. Otherwise a client
|
|
1102
|
+
* could hand the upstream — which trusts these headers precisely because a
|
|
1103
|
+
* proxy sits in front of it — an arbitrary origin address, protocol, and host,
|
|
1104
|
+
* defeating IP allowlists, rate limiting, and audit logs.
|
|
1105
|
+
*
|
|
1106
|
+
* These values reflect the server's own view of the request, which by default
|
|
1107
|
+
* comes from the real transport and the on-the-wire `Host`. They follow an
|
|
1108
|
+
* inbound `x-forwarded-*` header only when the server is explicitly configured
|
|
1109
|
+
* to trust an upstream proxy (e.g. srvx's `trustProxy`) — the correct setup
|
|
1110
|
+
* when a proxy you control sits in front, and the case where replacing them
|
|
1111
|
+
* here is a no-op.
|
|
1112
|
+
*
|
|
1113
|
+
* Headers passed explicitly via `headers` or `fetchOptions.headers` still win
|
|
1114
|
+
* over all of the above, since they are merged in afterwards.
|
|
1115
|
+
*
|
|
1116
|
+
* Only applied by `proxyRequest` (which forwards the incoming request);
|
|
1117
|
+
* the lower-level `proxy` ignores this option.
|
|
1118
|
+
*
|
|
1119
|
+
* @default false
|
|
1120
|
+
*/
|
|
1121
|
+
xfwd?: boolean;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Proxy the incoming request to a target URL.
|
|
1125
|
+
*
|
|
1126
|
+
* If the `target` starts with `/`, the request is handled internally by the app router
|
|
1127
|
+
* via `event.app.fetch()` instead of making an external HTTP request. Such a target
|
|
1128
|
+
* always resolves against the app's own origin: a leading separator run
|
|
1129
|
+
* (`//host/x`, `/\host/x`, and C0-interleaved forms like `/\thost/x` that the
|
|
1130
|
+
* URL parser strips down to one) is collapsed to a single `/` rather than read
|
|
1131
|
+
* as an authority.
|
|
1132
|
+
*
|
|
1133
|
+
* The request body is streamed to the target without buffering. Per the Fetch
|
|
1134
|
+
* standard, a request body can only be consumed once, so reading it beforehand
|
|
1135
|
+
* (e.g. via `readBody()`, `readFormData()`, or body-reading middleware) locks
|
|
1136
|
+
* the stream and proxying fails. If you need to inspect the body and still
|
|
1137
|
+
* proxy it, read from a clone and leave the original event untouched.
|
|
1138
|
+
*
|
|
1139
|
+
* Upstream 3xx responses are passed through to the client by default rather than
|
|
1140
|
+
* followed. Set `fetchOptions: { redirect: "follow" }` to follow them instead —
|
|
1141
|
+
* but following a redirect with a streamed request body can fail, since the body
|
|
1142
|
+
* cannot be replayed once consumed.
|
|
1143
|
+
*
|
|
1144
|
+
* **Security:** Never pass unsanitized user input as the `target`. Callers are
|
|
1145
|
+
* responsible for validating and restricting the target URL (e.g. allowlisting
|
|
1146
|
+
* hosts, blocking internal paths, enforcing protocol). Consider using
|
|
1147
|
+
* `bodyLimit()` middleware to prevent large request bodies from consuming
|
|
1148
|
+
* excessive resources when proxying untrusted input.
|
|
1149
|
+
*
|
|
1150
|
+
* **Credential forwarding:** the incoming request's `Cookie` and `Authorization`
|
|
1151
|
+
* headers are forwarded to the `target` verbatim. This is the correct behavior
|
|
1152
|
+
* for a same-trust reverse proxy, but leaks the client's credentials to any
|
|
1153
|
+
* upstream you do not fully trust. When proxying to a not-fully-trusted upstream,
|
|
1154
|
+
* strip them with `filterHeaders: ["cookie", "authorization"]`. (This differs
|
|
1155
|
+
* from `fetchWithEvent`, which never forwards the event's headers to an external
|
|
1156
|
+
* URL.)
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* app.all("/proxy", async (event) => {
|
|
1160
|
+
* const body = await event.req.clone().json(); // read from the clone
|
|
1161
|
+
* // ...inspect body...
|
|
1162
|
+
* return proxyRequest(event, "/target"); // original stream still intact
|
|
1163
|
+
* });
|
|
1164
|
+
*/
|
|
1165
|
+
export declare function proxyRequest(event: H3Event, target: string, opts?: ProxyOptions): Promise<HTTPResponse>;
|
|
1166
|
+
/**
|
|
1167
|
+
* Make a proxy request to a target URL and send the response back to the client.
|
|
1168
|
+
*
|
|
1169
|
+
* If the `target` starts with `/`, the request is dispatched internally via
|
|
1170
|
+
* `event.app.fetch()` (sub-request) and never leaves the process. This bypasses
|
|
1171
|
+
* any external security layer (reverse proxy auth, IP allowlisting, mTLS).
|
|
1172
|
+
*
|
|
1173
|
+
* Upstream 3xx responses are passed through to the client by default rather than
|
|
1174
|
+
* followed. Set `fetchOptions: { redirect: "follow" }` to follow them instead —
|
|
1175
|
+
* but following a redirect with a streamed request body can fail, since the body
|
|
1176
|
+
* cannot be replayed once consumed. (Internal sub-requests via `event.app.fetch()`
|
|
1177
|
+
* never follow redirects.)
|
|
1178
|
+
*
|
|
1179
|
+
* **Limitations** (inherited from `fetch`): upstream response bodies are always
|
|
1180
|
+
* decompressed (compression is not preserved end-to-end), the `host` header is
|
|
1181
|
+
* rewritten to the target (preserving it via `forwardHeaders: ["host"]` works on
|
|
1182
|
+
* Node.js but may be ignored on other runtimes), and unix sockets, TLS options,
|
|
1183
|
+
* or connection agents require a runtime-specific escape hatch (e.g. undici's
|
|
1184
|
+
* `dispatcher` in `fetchOptions` on Node.js). On browser and service-worker
|
|
1185
|
+
* runtimes, `redirect: "manual"` produces an unrelayable opaque-redirect for
|
|
1186
|
+
* external targets (a `502` is returned) — set
|
|
1187
|
+
* `fetchOptions: { redirect: "follow" }` there.
|
|
1188
|
+
*
|
|
1189
|
+
* **Security:** Never pass unsanitized user input as the `target`. Callers are
|
|
1190
|
+
* responsible for validating and restricting the target URL (e.g. allowlisting
|
|
1191
|
+
* hosts, blocking internal paths, enforcing protocol).
|
|
1192
|
+
*
|
|
1193
|
+
* **Credential forwarding:** `proxy` does not forward the incoming request's
|
|
1194
|
+
* headers automatically — only headers the caller explicitly passes via
|
|
1195
|
+
* `opts.headers` (or `fetchOptions.headers`) are sent, verbatim. Do not pass the
|
|
1196
|
+
* client's `Cookie` or `Authorization` headers through to an upstream you do not
|
|
1197
|
+
* fully trust. Note that `opts.filterHeaders` has no effect here — it is only
|
|
1198
|
+
* applied by `proxyRequest` (which does forward the incoming headers and offers
|
|
1199
|
+
* `filterHeaders: ["cookie", "authorization"]` as the mitigation).
|
|
1200
|
+
*/
|
|
1201
|
+
export declare function proxy(event: H3Event, target: string, opts?: ProxyOptions): Promise<HTTPResponse>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Get the request headers object without headers known to cause issues when proxying.
|
|
1204
|
+
*/
|
|
1205
|
+
export declare function getProxyRequestHeaders(event: H3Event, opts?: {
|
|
1206
|
+
host?: boolean;
|
|
1207
|
+
forwardHeaders?: string[];
|
|
1208
|
+
filterHeaders?: string[];
|
|
1209
|
+
}): Record<string, string>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Make a fetch request carrying the event's context.
|
|
1212
|
+
*
|
|
1213
|
+
* Behavior depends on the target:
|
|
1214
|
+
*
|
|
1215
|
+
* An **internal** `url` (starting with `/`) is dispatched via
|
|
1216
|
+
* `event.app.fetch()` (sub-request) and never leaves the process. It inherits
|
|
1217
|
+
* the incoming request's filtered headers (via `getProxyRequestHeaders`) and
|
|
1218
|
+
* runtime metadata (`ip`, `waitUntil`, ...). It always resolves against the
|
|
1219
|
+
* app's own origin: a leading separator run (`//host/x`, `/\host/x`, and
|
|
1220
|
+
* C0-interleaved forms like `/\thost/x` that the URL parser strips down to
|
|
1221
|
+
* one) is collapsed to a single `/` rather than read as an authority.
|
|
1222
|
+
*
|
|
1223
|
+
* An **external** `url` is sent with native `fetch(url, init)` **unchanged** —
|
|
1224
|
+
* the event's headers and context are *not* inherited (forwarding cookies or
|
|
1225
|
+
* authorization to arbitrary hosts would be unsafe). A streamed `init.body`
|
|
1226
|
+
* is given `duplex: "half"` when unset, which Node's `fetch` requires.
|
|
1227
|
+
*
|
|
1228
|
+
* **Security:** Never pass unsanitized user input as the `url`. Callers are
|
|
1229
|
+
* responsible for validating and restricting the URL.
|
|
1230
|
+
*/
|
|
1231
|
+
export declare function fetchWithEvent(event: H3Event, url: string, init?: RequestInit & {
|
|
1232
|
+
duplex?: "half" | "full";
|
|
1233
|
+
}): Promise<Response>;
|
|
1234
|
+
/** Valid HTTP status code (100–599). Kept loose (`number`) for portability. */
|
|
1235
|
+
export type HTTPStatus = number;
|
|
1236
|
+
/** Declarative options for a `cache` route rule. */
|
|
1237
|
+
export interface CacheRuleOptions {
|
|
1238
|
+
/**
|
|
1239
|
+
* Full cache name. Replaces the default app, method, rule, and route scoping;
|
|
1240
|
+
* prefer the cache handler's `id` option for stable cross-process keys.
|
|
1241
|
+
*/
|
|
1242
|
+
name?: string;
|
|
1243
|
+
/** Cache key group prefix. Defaults to `"h3/route-rules"`. */
|
|
1244
|
+
group?: string;
|
|
1245
|
+
/** Custom integrity value participating in cache invalidation. */
|
|
1246
|
+
integrity?: unknown;
|
|
1247
|
+
/** Number of seconds to cache the response. */
|
|
1248
|
+
maxAge?: number;
|
|
1249
|
+
/** Enable stale-while-revalidate: serve stale cache while refreshing in the background. */
|
|
1250
|
+
swr?: boolean;
|
|
1251
|
+
/** Maximum number of seconds a stale entry may be served while revalidating. */
|
|
1252
|
+
staleMaxAge?: number;
|
|
1253
|
+
/** Storage key base prefix(es). */
|
|
1254
|
+
base?: string | string[];
|
|
1255
|
+
/**
|
|
1256
|
+
* Seconds one shared resolution may take before every waiter is rejected and
|
|
1257
|
+
* the entry evicted. Defaults to `30`; `0` or `Infinity` disables the deadline.
|
|
1258
|
+
*/
|
|
1259
|
+
maxResolveTime?: number;
|
|
1260
|
+
/**
|
|
1261
|
+
* Stream the response that fills the entry instead of buffering it first.
|
|
1262
|
+
* Trades a synthesized `etag` and mid-body error recovery for time to first
|
|
1263
|
+
* byte; later requests are still served from the stored entry.
|
|
1264
|
+
*/
|
|
1265
|
+
stream?: boolean;
|
|
1266
|
+
/**
|
|
1267
|
+
* Largest response body, in bytes, that may be buffered for storage. Defaults
|
|
1268
|
+
* to what the storage backend can hold; a larger response streams through
|
|
1269
|
+
* uncached.
|
|
1270
|
+
*/
|
|
1271
|
+
maxBodySize?: number;
|
|
1272
|
+
/** Only handle conditional headers (304 responses) without caching full responses. */
|
|
1273
|
+
headersOnly?: boolean;
|
|
1274
|
+
/**
|
|
1275
|
+
* Headers that vary the cache key and response `Vary`. Authorization headers
|
|
1276
|
+
* are forwarded only when {@link allowAuthorization} is enabled.
|
|
1277
|
+
*/
|
|
1278
|
+
varies?: string[] | readonly string[];
|
|
1279
|
+
/**
|
|
1280
|
+
* Query parameter names that reach the handler and vary the cache key. No
|
|
1281
|
+
* query parameter does by default; `true` opts the full query string back in.
|
|
1282
|
+
*/
|
|
1283
|
+
allowQuery?: boolean | string[] | readonly string[];
|
|
1284
|
+
/**
|
|
1285
|
+
* Cookies allowed to vary the cache key and reach the handler. Other request
|
|
1286
|
+
* cookies are filtered, and `Set-Cookie` is never stored.
|
|
1287
|
+
*/
|
|
1288
|
+
allowCookies?: string[] | readonly string[];
|
|
1289
|
+
/**
|
|
1290
|
+
* Forward authorization headers and vary the cache per credential. Disabled
|
|
1291
|
+
* by default; enabling it can greatly increase cache cardinality.
|
|
1292
|
+
*
|
|
1293
|
+
* Custom cache implementations must enforce this behavior themselves.
|
|
1294
|
+
*/
|
|
1295
|
+
allowAuthorization?: boolean;
|
|
1296
|
+
/** Whether to synthesize a `Cache-Control` response header (default `true`). */
|
|
1297
|
+
sendCacheControl?: boolean;
|
|
1298
|
+
/** Cache-status response header: `true` (`X-Cache`), a custom name, or `false`. */
|
|
1299
|
+
cacheStatusHeader?: boolean | string;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* User-authored rules for one route pattern. Custom rule names require module
|
|
1303
|
+
* augmentation.
|
|
1304
|
+
*/
|
|
1305
|
+
export interface RouteRuleConfig {
|
|
1306
|
+
/**
|
|
1307
|
+
* Enable runtime caching; `false` disables caching inherited from a less-specific
|
|
1308
|
+
* pattern. Requires a registered `cache` handler (`h3/rules/cache`'s ocache-backed
|
|
1309
|
+
* one, or your own via `createCacheRuleHandler`).
|
|
1310
|
+
*/
|
|
1311
|
+
cache?: CacheRuleOptions | false;
|
|
1312
|
+
/**
|
|
1313
|
+
* Response headers to set. `false` disables headers inherited from a
|
|
1314
|
+
* less-specific pattern.
|
|
1315
|
+
*/
|
|
1316
|
+
headers?: Record<string, string> | false;
|
|
1317
|
+
/**
|
|
1318
|
+
* Server-side redirect; a plain string defaults to status `307`. When the rule
|
|
1319
|
+
* key ends in `/**`, a `**` in `to` is replaced with the matched tail — appended
|
|
1320
|
+
* for a trailing `to: "/new/**"`, or interpolated in place anywhere else in the
|
|
1321
|
+
* target's path, query, or fragment (`/new?from=**`).
|
|
1322
|
+
* A request whose path already has the target's shape (`/docs/v2/…` for
|
|
1323
|
+
* `to: "/docs/v2/**"`) is not redirected again.
|
|
1324
|
+
* `false` disables a redirect inherited from a less-specific pattern.
|
|
1325
|
+
*/
|
|
1326
|
+
redirect?: string | {
|
|
1327
|
+
to: string;
|
|
1328
|
+
status?: HTTPStatus;
|
|
1329
|
+
} | false;
|
|
1330
|
+
/**
|
|
1331
|
+
* Proxy to another origin or internal path; a plain string is the destination,
|
|
1332
|
+
* or use an object for {@link ProxyOptions}. Wildcard `**` tail behavior matches
|
|
1333
|
+
* {@link redirect}. `false` disables a proxy inherited from a less-specific pattern.
|
|
1334
|
+
*/
|
|
1335
|
+
proxy?: string | ({
|
|
1336
|
+
to: string;
|
|
1337
|
+
} & ProxyOptions) | false;
|
|
1338
|
+
/**
|
|
1339
|
+
* CORS via h3's `handleCors`; `true` applies permissive defaults (`*`), or pass
|
|
1340
|
+
* {@link CorsOptions}. A preflight is answered (204) before any other rule.
|
|
1341
|
+
* `false` disables CORS inherited from a less-specific pattern.
|
|
1342
|
+
*/
|
|
1343
|
+
cors?: CorsOptions | boolean;
|
|
1344
|
+
/** Enable stale-while-revalidate, optionally with a `maxAge` in seconds. */
|
|
1345
|
+
swr?: boolean | number;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Rules for one normalized pattern. Includes custom names and `false` markers
|
|
1349
|
+
* that reset inherited rules.
|
|
1350
|
+
*/
|
|
1351
|
+
export type NormalizedRouteRules = { [K in RouteRuleName]?: ResolvedRouteRules[K] | RuleReset<K>; } & {
|
|
1352
|
+
[key: string]: unknown;
|
|
1353
|
+
};
|
|
1354
|
+
/** The `false` reset marker for rule `K`, when its authored config admits one. */
|
|
1355
|
+
type RuleReset<K extends RouteRuleName> = K extends keyof RouteRuleConfig ? Extract<RouteRuleConfig[K], false> : false;
|
|
1356
|
+
/** Normalized `redirect` rule options. */
|
|
1357
|
+
export interface RedirectRuleOptions {
|
|
1358
|
+
to: string;
|
|
1359
|
+
status: HTTPStatus;
|
|
1360
|
+
/** Scope base used to validate and strip the tail a `/**` rule key matched. */
|
|
1361
|
+
base?: string;
|
|
1362
|
+
}
|
|
1363
|
+
/** Normalized `proxy` rule options. */
|
|
1364
|
+
export type ProxyRuleOptions = {
|
|
1365
|
+
to: string;
|
|
1366
|
+
/** Scope base used to validate and strip the tail a `/**` rule key matched. */
|
|
1367
|
+
base?: string;
|
|
1368
|
+
} & ProxyOptions;
|
|
1369
|
+
/** A declared built-in or augmented route-rule name. */
|
|
1370
|
+
type RouteRuleName = Extract<keyof ResolvedRouteRules, string>;
|
|
1371
|
+
/** A matched rule with merged options and route provenance. */
|
|
1372
|
+
export interface MatchedRouteRule<K extends RouteRuleName = RouteRuleName> {
|
|
1373
|
+
/** The merged rule options (never `false` — a reset deletes the rule instead). */
|
|
1374
|
+
options: NonNullable<ResolvedRouteRules[K]>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Most specific pattern that contributed to the rule, as normalized: spelled
|
|
1377
|
+
* the way h3 stores the equivalent route, so `"/café/**"` reads
|
|
1378
|
+
* `/caf%C3%A9/**` and `"/a b/**"` reads `/a%20b/**`.
|
|
1379
|
+
*/
|
|
1380
|
+
route: string;
|
|
1381
|
+
/** rou3 params from every matched pattern that contributed to this rule. */
|
|
1382
|
+
params?: Record<string, string>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Rule handler: the middleware constructor plus its optional `order`.
|
|
1385
|
+
* Data-only rules have no handler.
|
|
1386
|
+
*/
|
|
1387
|
+
handler?: RuleHandler<K>;
|
|
1388
|
+
}
|
|
1389
|
+
/** Matched rules with provenance, keyed by rule name. */
|
|
1390
|
+
export type MatchedRouteRules = { [K in RouteRuleName]?: MatchedRouteRule<K>; };
|
|
1391
|
+
/** Builds middleware for a matched rule. */
|
|
1392
|
+
export interface RuleHandler<K extends RouteRuleName = RouteRuleName> {
|
|
1393
|
+
/**
|
|
1394
|
+
* Execution order, lower runs first (outermost). Defaults to `0`, which is
|
|
1395
|
+
* outside every built-in that can short-circuit (`redirect` 1, `proxy` 2,
|
|
1396
|
+
* `cache` 3) and inside `cors` (-3) and `headers` (-1); `-2` is left free for
|
|
1397
|
+
* a gate that must also precede `headers`.
|
|
1398
|
+
*
|
|
1399
|
+
* Two handlers must not share an order when one of them can answer without
|
|
1400
|
+
* calling `next()` — the tie is broken by rule name, which is deterministic
|
|
1401
|
+
* but arbitrary, and the loser never runs.
|
|
1402
|
+
*/
|
|
1403
|
+
order?: number;
|
|
1404
|
+
/**
|
|
1405
|
+
* Mark fail-closed rules such as auth gates. Restricting rules may be re-added
|
|
1406
|
+
* from alternate path readings after a narrower reset; defaults to `false`.
|
|
1407
|
+
*/
|
|
1408
|
+
restricting?: boolean;
|
|
1409
|
+
handler: (matched: MatchedRouteRule<K>) => Middleware;
|
|
1410
|
+
}
|
|
1411
|
+
/** Map of rule name → handler constructor. */
|
|
1412
|
+
export type RuleHandlers = Record<string, RuleHandler<any> | undefined>;
|
|
1413
|
+
/** Result of matching a request against the rule set. */
|
|
1414
|
+
export interface MatchResult {
|
|
1415
|
+
/**
|
|
1416
|
+
* Merged rule options keyed by rule name — the map exposed as
|
|
1417
|
+
* `event.context.routeRules`, so `routeRules.redirect?.to` reads directly.
|
|
1418
|
+
*/
|
|
1419
|
+
routeRules: ResolvedRouteRules;
|
|
1420
|
+
/** The same rules with their contributing pattern, params, and handler. */
|
|
1421
|
+
matchedRules: MatchedRouteRules;
|
|
1422
|
+
/** Ordered middleware to run before the route handler. */
|
|
1423
|
+
routeRuleMiddleware: Middleware[];
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* The rule keys `h3/rules` ships a built-in handler for, typed as the **merged
|
|
1427
|
+
* rule options** the runtime resolves for them — the same shape the rule was
|
|
1428
|
+
* authored in (`RouteRuleConfig`), minus the input sugar normalization already
|
|
1429
|
+
* expanded (`redirect: "/new"` → `{ to, status }`) and minus the `false` reset
|
|
1430
|
+
* marker, which is applied as a deletion and can therefore never survive into a
|
|
1431
|
+
* merged rule set.
|
|
1432
|
+
*
|
|
1433
|
+
* Declared on their own interface rather than on {@link RouteRules}, the shared
|
|
1434
|
+
* augmentable one. Declaration merging compares a redeclared property by *type
|
|
1435
|
+
* identity* (`TS2717`), so naming these keys on `RouteRules` itself would make
|
|
1436
|
+
* every third-party declaration of the same key an error — including the ones
|
|
1437
|
+
* Nitro and the standalone `h3-rules` package have always shipped:
|
|
1438
|
+
*
|
|
1439
|
+
* ```ts
|
|
1440
|
+
* declare module "h3" {
|
|
1441
|
+
* interface RouteRules {
|
|
1442
|
+
* redirect?: { to: string; status?: number };
|
|
1443
|
+
* }
|
|
1444
|
+
* }
|
|
1445
|
+
* ```
|
|
1446
|
+
*
|
|
1447
|
+
* *Inheriting* them (`interface RouteRules extends BuiltinRouteRules`) does not
|
|
1448
|
+
* work either. It only downgrades the check to assignability (`TS2430` — a
|
|
1449
|
+
* derived interface may narrow an inherited property), and the shapes actually
|
|
1450
|
+
* shipped are not narrowings of anything useful: `nitropack`'s
|
|
1451
|
+
* `redirect?: string | { to; status? }` carries a **primitive** arm (h3's own
|
|
1452
|
+
* `@example` shipped that shape too), and its `cache?: … | false` /
|
|
1453
|
+
* `cors?: boolean` carry a **`false`** arm — `false` being h3's own reset
|
|
1454
|
+
* marker. Widening the built-in's declared type until those assign makes it an
|
|
1455
|
+
* escape hatch that erases member access for everyone who does *not* augment.
|
|
1456
|
+
*
|
|
1457
|
+
* The built-ins are therefore *composed in at the point of use* — see
|
|
1458
|
+
* {@link ResolvedRouteRules} — where nothing is inherited and no assignability
|
|
1459
|
+
* check applies at all.
|
|
1460
|
+
*
|
|
1461
|
+
* Adding a `[key: string]: unknown` index signature here (so that a data-only
|
|
1462
|
+
* rule reads off the context without being declared) is equally out: on a shared
|
|
1463
|
+
* ecosystem interface an index signature makes every other module's augmentation
|
|
1464
|
+
* an error (`TS2411`), whatever key or type it adds. A custom rule is declared
|
|
1465
|
+
* once, on {@link RouteRules}.
|
|
1466
|
+
*/
|
|
1467
|
+
export interface BuiltinRouteRules {
|
|
1468
|
+
headers?: Record<string, string>;
|
|
1469
|
+
redirect?: RedirectRuleOptions;
|
|
1470
|
+
proxy?: ProxyRuleOptions;
|
|
1471
|
+
cache?: CacheRuleOptions;
|
|
1472
|
+
cors?: CorsOptions;
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* The rules matched for the current route, **keyed by rule name and holding the
|
|
1476
|
+
* merged rule options directly** (`rules.redirect.to`, `rules.headers["x-a"]`) —
|
|
1477
|
+
* the canonical extension point for route rules in the h3 ecosystem.
|
|
1478
|
+
*
|
|
1479
|
+
* Intentionally **empty and unconstrained**: modules that implement or consume
|
|
1480
|
+
* route rules (such as Nitro) augment it via declaration merging, so that a
|
|
1481
|
+
* single type describes the rules of any h3 app regardless of which module
|
|
1482
|
+
* declared them. Every shape is accepted, including on a key h3 ships a built-in
|
|
1483
|
+
* for — see {@link BuiltinRouteRules} for why nothing is declared here.
|
|
1484
|
+
*
|
|
1485
|
+
* Handlers read the *resolved* set, {@link ResolvedRouteRules}, off
|
|
1486
|
+
* `event.context.routeRules`, where it is typed `Readonly` — matchers are
|
|
1487
|
+
* commonly memoized, so a matched object can be shared between requests and must
|
|
1488
|
+
* not be mutated in place.
|
|
1489
|
+
*
|
|
1490
|
+
* This is the **one** `RouteRules` interface: `h3/rules` re-exports it, so a
|
|
1491
|
+
* custom rule is declared once, in one shape, and is then typed on both the
|
|
1492
|
+
* matched result and the context. (Its authored counterpart, `RouteRuleConfig`,
|
|
1493
|
+
* stays a separate closed interface — that is what makes a typo a compile
|
|
1494
|
+
* error.) Per-rule provenance — which pattern contributed the options, its
|
|
1495
|
+
* params, the handler — is deliberately *not* here; it is passed to rule
|
|
1496
|
+
* handlers as a `MatchedRouteRule` and available as `MatchResult.matchedRules`.
|
|
1497
|
+
*
|
|
1498
|
+
* @example
|
|
1499
|
+
* ```ts
|
|
1500
|
+
* declare module "h3/rules" {
|
|
1501
|
+
* interface RouteRuleConfig {
|
|
1502
|
+
* audience?: "public" | "internal";
|
|
1503
|
+
* }
|
|
1504
|
+
* interface RouteRules {
|
|
1505
|
+
* audience?: "public" | "internal";
|
|
1506
|
+
* }
|
|
1507
|
+
* }
|
|
1508
|
+
*
|
|
1509
|
+
* // event.context.routeRules.audience -> "public" | "internal" | undefined
|
|
1510
|
+
* ```
|
|
1511
|
+
*/
|
|
1512
|
+
export interface RouteRules {}
|
|
1513
|
+
/**
|
|
1514
|
+
* The rules as seen on `event.context.routeRules`: everything declared on
|
|
1515
|
+
* {@link RouteRules}, plus a built-in for every key nobody claimed.
|
|
1516
|
+
*
|
|
1517
|
+
* `Omit` — not `&` — so that an augmenter's redeclaration *replaces* h3's
|
|
1518
|
+
* built-in rather than intersecting with it; intersecting `RedirectRuleOptions`
|
|
1519
|
+
* with `string | { to: string }` would yield a type no value inhabits. Keys left
|
|
1520
|
+
* to h3 keep their exact option type, so `rules.redirect?.to` reads without
|
|
1521
|
+
* narrowing.
|
|
1522
|
+
*/
|
|
1523
|
+
export type ResolvedRouteRules = RouteRules & Omit<BuiltinRouteRules, keyof RouteRules>;
|
|
1524
|
+
export interface H3EventContext extends ServerRequestContext {
|
|
1525
|
+
params?: Record<string, string>;
|
|
1526
|
+
middlewareParams?: Record<string, string>;
|
|
1527
|
+
/**
|
|
1528
|
+
* Matched router Node
|
|
1529
|
+
*
|
|
1530
|
+
* @experimental The object structure may change in non-major version.
|
|
1531
|
+
*/
|
|
1532
|
+
matchedRoute?: H3Route;
|
|
1533
|
+
sessions?: Record<string, Session>;
|
|
1534
|
+
routeRules?: Readonly<ResolvedRouteRules>;
|
|
1535
|
+
clientAddress?: string;
|
|
1536
|
+
basicAuth?: {
|
|
1537
|
+
username: string;
|
|
1538
|
+
password?: string;
|
|
1539
|
+
realm: string;
|
|
1540
|
+
};
|
|
1541
|
+
timing?: Array<{
|
|
1542
|
+
name: string;
|
|
1543
|
+
} & Record<string, unknown>>;
|
|
1544
|
+
}
|
|
1545
|
+
export interface HTTPEvent<_RequestT extends EventHandlerRequest = EventHandlerRequest> {
|
|
1546
|
+
/**
|
|
1547
|
+
* Incoming HTTP request info.
|
|
1548
|
+
*
|
|
1549
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
1550
|
+
*/
|
|
1551
|
+
req: TypedServerRequest<_RequestT>;
|
|
1552
|
+
}
|
|
1553
|
+
export declare class H3Event<_RequestT extends EventHandlerRequest = EventHandlerRequest> implements HTTPEvent<_RequestT> {
|
|
1554
|
+
/**
|
|
1555
|
+
* Access to the H3 application instance.
|
|
1556
|
+
*/
|
|
1557
|
+
app?: H3Core;
|
|
1558
|
+
/**
|
|
1559
|
+
* Incoming HTTP request info.
|
|
1560
|
+
*
|
|
1561
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
1562
|
+
*/
|
|
1563
|
+
readonly req: TypedServerRequest<_RequestT>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Access to the parsed request URL.
|
|
1566
|
+
*
|
|
1567
|
+
* `event.url.pathname` is the path in its wire encoding, with one exception:
|
|
1568
|
+
* an escape that is *needlessly* there is dropped — one whose character
|
|
1569
|
+
* survives WHATWG path serialization unchanged, minus `%2F` and `%25` which
|
|
1570
|
+
* must stay opaque (e.g. `/%61dmin` -> `/admin`, `/%40handle` -> `/@handle`).
|
|
1571
|
+
* This is decoded once, before routing, so that route matching, `use()`
|
|
1572
|
+
* matchers and a handler reading `event.url.pathname` all compare one and the
|
|
1573
|
+
* same string and `/%61dmin` cannot slip past an `/admin` guard. Nothing else
|
|
1574
|
+
* is touched, and `event.req.url` always keeps the original wire encoding.
|
|
1575
|
+
* See the "Pathname encoding" section of the guide for the full rule:
|
|
1576
|
+
* https://h3.dev/guide/api/h3event#pathname-encoding
|
|
1577
|
+
*
|
|
1578
|
+
* Malformed encoding (`/foo%`, `/%ZZ`) has no canonical form and is rejected
|
|
1579
|
+
* with a `400` before any handler runs, unless the `allowMalformedURL` app
|
|
1580
|
+
* option is enabled.
|
|
1581
|
+
*
|
|
1582
|
+
* Every escape that survives is therefore opaque, and must be treated as such:
|
|
1583
|
+
* `%2F`/`%5C` keep a separator out of a `:param` the router matched as one
|
|
1584
|
+
* segment, and decoding `pathname` yourself can reintroduce a `/` or `..` that
|
|
1585
|
+
* routing and middleware never saw (path traversal). To read a route param in
|
|
1586
|
+
* decoded form use `getRouterParams(event, { decode: true })`, which keeps
|
|
1587
|
+
* encoded separators encoded.
|
|
1588
|
+
*
|
|
1589
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
1590
|
+
*/
|
|
1591
|
+
url: URL;
|
|
1592
|
+
/**
|
|
1593
|
+
* Event context.
|
|
1594
|
+
*/
|
|
1595
|
+
readonly context: H3EventContext;
|
|
1596
|
+
/**
|
|
1597
|
+
* @internal
|
|
1598
|
+
*/
|
|
1599
|
+
static __is_event__: boolean;
|
|
1600
|
+
constructor(req: ServerRequest, context?: H3EventContext, app?: H3Core);
|
|
1601
|
+
/**
|
|
1602
|
+
* Prepared HTTP response.
|
|
1603
|
+
*/
|
|
1604
|
+
get res(): H3EventResponse;
|
|
1605
|
+
/**
|
|
1606
|
+
* Access to runtime specific additional context.
|
|
1607
|
+
*
|
|
1608
|
+
*/
|
|
1609
|
+
get runtime(): ServerRuntimeContext | undefined;
|
|
1610
|
+
/**
|
|
1611
|
+
* Tell the runtime about an ongoing operation that shouldn't close until the promise resolves.
|
|
1612
|
+
*/
|
|
1613
|
+
waitUntil(promise: Promise<any>): void;
|
|
1614
|
+
toString(): string;
|
|
1615
|
+
toJSON(): string;
|
|
1616
|
+
/**
|
|
1617
|
+
* Access to the raw Node.js req/res objects.
|
|
1618
|
+
*
|
|
1619
|
+
* @deprecated Use `event.runtime.{node|deno|bun|...}.` instead.
|
|
1620
|
+
*/
|
|
1621
|
+
get node(): ServerRuntimeContext["node"] | undefined;
|
|
1622
|
+
/**
|
|
1623
|
+
* Access to the incoming request headers.
|
|
1624
|
+
*
|
|
1625
|
+
* @deprecated Use `event.req.headers` instead.
|
|
1626
|
+
*
|
|
1627
|
+
*/
|
|
1628
|
+
get headers(): Headers;
|
|
1629
|
+
/**
|
|
1630
|
+
* Access to the incoming request url (pathname+search).
|
|
1631
|
+
*
|
|
1632
|
+
* @deprecated Use `event.url.pathname + event.url.search` instead.
|
|
1633
|
+
*
|
|
1634
|
+
* Example: `/api/hello?name=world`
|
|
1635
|
+
* */
|
|
1636
|
+
get path(): string;
|
|
1637
|
+
/**
|
|
1638
|
+
* Access to the incoming request method.
|
|
1639
|
+
*
|
|
1640
|
+
* @deprecated Use `event.req.method` instead.
|
|
1641
|
+
*/
|
|
1642
|
+
get method(): string;
|
|
1643
|
+
}
|
|
1644
|
+
declare class H3EventResponse {
|
|
1645
|
+
status?: number;
|
|
1646
|
+
statusText?: string;
|
|
1647
|
+
get headers(): Headers;
|
|
1648
|
+
get errHeaders(): Headers;
|
|
1649
|
+
}
|
|
1650
|
+
export declare class H3Core implements H3Core$1 {
|
|
1651
|
+
static "~h3": boolean;
|
|
1652
|
+
readonly config: H3CoreConfig;
|
|
1653
|
+
"~middleware": Middleware[];
|
|
1654
|
+
"~routes": H3Route[];
|
|
1655
|
+
"~dispatch"?: (event: H3Event, route: MatchedRoute<H3Route> | void) => unknown | Promise<unknown>;
|
|
1656
|
+
"~composed"?: ComposedMiddleware;
|
|
1657
|
+
constructor(config?: H3CoreConfig);
|
|
1658
|
+
fetch(request: ServerRequest): Response | Promise<Response>;
|
|
1659
|
+
handler(event: H3Event): unknown | Promise<unknown>;
|
|
1660
|
+
"~request"(request: ServerRequest, context?: H3EventContext): Response | Promise<Response>;
|
|
1661
|
+
"~findRoute"(_event: H3Event): MatchedRoute<H3Route> | void;
|
|
1662
|
+
"~addRoute"(_route: H3Route): void;
|
|
1663
|
+
"~getMiddleware"(_event: H3Event, _route?: MatchedRoute<H3Route>): Middleware[];
|
|
1664
|
+
}
|
|
1665
|
+
export declare const H3: {
|
|
1666
|
+
new (config?: H3Config): H3$1;
|
|
1667
|
+
};
|
|
1668
|
+
export type H3 = H3$1;
|
|
1669
|
+
export { type CookieSerializeOptions, FetchHandler$1 as FetchHandler, H3$1, type TypedHeaders };
|