@daloyjs/core 0.17.0 → 0.28.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/README.md +3 -3
- package/dist/adapters/bun.d.ts.map +1 -1
- package/dist/adapters/bun.js +38 -7
- package/dist/adapters/bun.js.map +1 -1
- package/dist/adapters/node.d.ts.map +1 -1
- package/dist/adapters/node.js +29 -7
- package/dist/adapters/node.js.map +1 -1
- package/dist/app.d.ts +322 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +715 -29
- package/dist/app.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +218 -1
- package/dist/cli.js.map +1 -1
- package/dist/combine.d.ts +97 -0
- package/dist/combine.d.ts.map +1 -0
- package/dist/combine.js +247 -0
- package/dist/combine.js.map +1 -0
- package/dist/compression.d.ts +127 -0
- package/dist/compression.d.ts.map +1 -0
- package/dist/compression.js +368 -0
- package/dist/compression.js.map +1 -0
- package/dist/config.d.ts +97 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +132 -0
- package/dist/config.js.map +1 -0
- package/dist/conn-info.d.ts +121 -0
- package/dist/conn-info.d.ts.map +1 -0
- package/dist/conn-info.js +145 -0
- package/dist/conn-info.js.map +1 -0
- package/dist/cookie.d.ts +112 -0
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +185 -0
- package/dist/cookie.js.map +1 -0
- package/dist/dependency.d.ts +47 -0
- package/dist/dependency.d.ts.map +1 -0
- package/dist/dependency.js +68 -0
- package/dist/dependency.js.map +1 -0
- package/dist/etag.d.ts +48 -0
- package/dist/etag.d.ts.map +1 -0
- package/dist/etag.js +117 -0
- package/dist/etag.js.map +1 -0
- package/dist/index.d.ts +40 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/ip-restriction.d.ts +75 -0
- package/dist/ip-restriction.d.ts.map +1 -0
- package/dist/ip-restriction.js +203 -0
- package/dist/ip-restriction.js.map +1 -0
- package/dist/jwk.d.ts +82 -0
- package/dist/jwk.d.ts.map +1 -0
- package/dist/jwk.js +269 -0
- package/dist/jwk.js.map +1 -0
- package/dist/jwt.d.ts +103 -0
- package/dist/jwt.d.ts.map +1 -0
- package/dist/jwt.js +437 -0
- package/dist/jwt.js.map +1 -0
- package/dist/load-shedding.d.ts +73 -0
- package/dist/load-shedding.d.ts.map +1 -0
- package/dist/load-shedding.js +171 -0
- package/dist/load-shedding.js.map +1 -0
- package/dist/middleware.d.ts +181 -2
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +367 -77
- package/dist/middleware.js.map +1 -1
- package/dist/multipart.d.ts +17 -0
- package/dist/multipart.d.ts.map +1 -1
- package/dist/multipart.js +117 -1
- package/dist/multipart.js.map +1 -1
- package/dist/openapi.d.ts +8 -0
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +18 -1
- package/dist/openapi.js.map +1 -1
- package/dist/security-schemes.d.ts +21 -5
- package/dist/security-schemes.d.ts.map +1 -1
- package/dist/security-schemes.js +32 -5
- package/dist/security-schemes.js.map +1 -1
- package/dist/session.d.ts +23 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +106 -86
- package/dist/session.js.map +1 -1
- package/dist/subdomains.d.ts +97 -0
- package/dist/subdomains.d.ts.map +1 -0
- package/dist/subdomains.js +157 -0
- package/dist/subdomains.js.map +1 -0
- package/dist/time-claims.d.ts +72 -0
- package/dist/time-claims.d.ts.map +1 -0
- package/dist/time-claims.js +88 -0
- package/dist/time-claims.js.map +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/websocket.d.ts +51 -34
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +162 -2
- package/dist/websocket.js.map +1 -1
- package/package.json +30 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed-DI chain helper (Wave 6 item 12).
|
|
3
|
+
*
|
|
4
|
+
* `defineDependency()` wraps a middleware so the framework deduplicates
|
|
5
|
+
* evaluation per request — a request that triggers two routes both depending
|
|
6
|
+
* on `getCurrentUser` runs the auth check exactly once per request, with the
|
|
7
|
+
* typed result threaded through `ctx.state` declared in {@link AppState}.
|
|
8
|
+
*
|
|
9
|
+
* Refuses-at-construction on cyclic dependency declarations (companion to
|
|
10
|
+
* the cyclic plugin-extension-ordering refusal in {@link App.register}).
|
|
11
|
+
*
|
|
12
|
+
* @since 0.24.0
|
|
13
|
+
*/
|
|
14
|
+
/** Symbol stamped on hooks returned by {@link defineDependency}. */
|
|
15
|
+
export const DEPENDENCY_MARKER = Symbol.for("daloyjs.dependency.marker");
|
|
16
|
+
/** Per-request cache of dependency results, keyed by dependency name. */
|
|
17
|
+
const RESULTS_KEY = Symbol.for("daloyjs.dependency.results");
|
|
18
|
+
/**
|
|
19
|
+
* Wrap a per-request value producer as a {@link Hooks} bundle. The hook
|
|
20
|
+
* runs in `beforeHandle` and writes its resolved value to
|
|
21
|
+
* `ctx.state[stateKey]` (default `name`). Composing the same dependency
|
|
22
|
+
* twice in one chain runs `resolve()` exactly once.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.24.0
|
|
25
|
+
*/
|
|
26
|
+
export function defineDependency(opts) {
|
|
27
|
+
if (typeof opts.name !== "string" || opts.name.length === 0) {
|
|
28
|
+
throw new Error("defineDependency(): name is required and must be a non-empty string.");
|
|
29
|
+
}
|
|
30
|
+
const dependsOn = opts.dependsOn ?? [];
|
|
31
|
+
if (dependsOn.includes(opts.name)) {
|
|
32
|
+
throw new Error(`defineDependency(): dependency "${opts.name}" declares itself as a dependency (cycle).`);
|
|
33
|
+
}
|
|
34
|
+
const stateKey = opts.stateKey ?? opts.name;
|
|
35
|
+
const hooks = {
|
|
36
|
+
async beforeHandle(ctx) {
|
|
37
|
+
const state = ctx.state;
|
|
38
|
+
let cache = state[RESULTS_KEY];
|
|
39
|
+
if (!cache) {
|
|
40
|
+
cache = new Map();
|
|
41
|
+
state[RESULTS_KEY] = cache;
|
|
42
|
+
}
|
|
43
|
+
if (cache.has(opts.name)) {
|
|
44
|
+
// Already resolved this request — re-stamp for the active stateKey
|
|
45
|
+
// in case a sibling chain wrote it under a different key.
|
|
46
|
+
state[stateKey] = cache.get(opts.name);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// Verify declared dependencies ran first; the developer composes them
|
|
50
|
+
// in the correct order via `every(...)` or registration order.
|
|
51
|
+
for (const dep of dependsOn) {
|
|
52
|
+
if (!cache.has(dep)) {
|
|
53
|
+
throw new Error(`defineDependency(): "${opts.name}" requires "${dep}" to be composed first.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const value = await opts.resolve(ctx);
|
|
57
|
+
cache.set(opts.name, value);
|
|
58
|
+
state[stateKey] = value;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(hooks, DEPENDENCY_MARKER, {
|
|
62
|
+
value: { name: opts.name, dependsOn: [...dependsOn] },
|
|
63
|
+
enumerable: false,
|
|
64
|
+
writable: false,
|
|
65
|
+
});
|
|
66
|
+
return hooks;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=dependency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../src/dependency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,oEAAoE;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CACxD,2BAA2B,CAC5B,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,GAAkB,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAyB5E;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAI9B,IAAiD;IACjD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CA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AAG,CAAC,CAAC;YACtC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC5B,KAAK,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC;KACF,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE;QAC9C,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE;QACrD,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,OAAO,KAAwB,CAAC;AAClC,CAAC"}
|
package/dist/etag.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave 5 leftover: first-party `etag()` helper with strong-validation default.
|
|
3
|
+
*
|
|
4
|
+
* Automatically computes a SHA-1 strong ETag for successful `GET` / `HEAD`
|
|
5
|
+
* responses, responds `304 Not Modified` on a matching `If-None-Match`, and
|
|
6
|
+
* — critical for tenant-isolated APIs — skips entirely when the response
|
|
7
|
+
* carries a `Set-Cookie` header OR a `Cache-Control` directive of
|
|
8
|
+
* `private` / `no-store` / `no-cache`. Cross-tenant fingerprinting via
|
|
9
|
+
* cached ETag values is the documented attack class this defense addresses;
|
|
10
|
+
* the skip behavior is on by default and not configurable.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.21.0
|
|
13
|
+
*/
|
|
14
|
+
import type { Hooks } from "./types.js";
|
|
15
|
+
/** Options for {@link etag}. */
|
|
16
|
+
export interface ETagOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Emit a weak ETag (`W/"..."`). Default `false` — strong ETags allow
|
|
19
|
+
* range-request resumption and prevent byte-level cache poisoning by
|
|
20
|
+
* intermediaries.
|
|
21
|
+
*/
|
|
22
|
+
weak?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Override the digest function. Default: SHA-1 via WebCrypto. SHA-1 is
|
|
25
|
+
* appropriate here because the ETag is a cache identifier, not a security
|
|
26
|
+
* boundary; collisions only cause a stale `304`, never a confidentiality
|
|
27
|
+
* break.
|
|
28
|
+
*/
|
|
29
|
+
generator?: (body: Uint8Array) => string | Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* ETag generation + conditional-GET handler.
|
|
33
|
+
*
|
|
34
|
+
* - Skips when the response already carries an `ETag`.
|
|
35
|
+
* - Skips when the response carries `Set-Cookie` OR `Cache-Control: private | no-store | no-cache`.
|
|
36
|
+
* - Skips non-`2xx` responses and methods other than `GET` / `HEAD`.
|
|
37
|
+
* - Emits `304 Not Modified` (preserving `cache-control`, `content-location`, `date`, `etag`, `expires`, `vary` per RFC 7232 §4.1) on a matching `If-None-Match`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { etag } from "@daloyjs/core";
|
|
42
|
+
* app.use(etag());
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @since 0.21.0
|
|
46
|
+
*/
|
|
47
|
+
export declare function etag(opts?: ETagOptions): Hooks;
|
|
48
|
+
//# sourceMappingURL=etag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etag.d.ts","sourceRoot":"","sources":["../src/etag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D;AA4CD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,WAAgB,GAAG,KAAK,CAmClD"}
|
package/dist/etag.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave 5 leftover: first-party `etag()` helper with strong-validation default.
|
|
3
|
+
*
|
|
4
|
+
* Automatically computes a SHA-1 strong ETag for successful `GET` / `HEAD`
|
|
5
|
+
* responses, responds `304 Not Modified` on a matching `If-None-Match`, and
|
|
6
|
+
* — critical for tenant-isolated APIs — skips entirely when the response
|
|
7
|
+
* carries a `Set-Cookie` header OR a `Cache-Control` directive of
|
|
8
|
+
* `private` / `no-store` / `no-cache`. Cross-tenant fingerprinting via
|
|
9
|
+
* cached ETag values is the documented attack class this defense addresses;
|
|
10
|
+
* the skip behavior is on by default and not configurable.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.21.0
|
|
13
|
+
*/
|
|
14
|
+
const CACHE_SKIP_DIRECTIVES = new Set(["private", "no-store", "no-cache"]);
|
|
15
|
+
function shouldSkipForCache(res) {
|
|
16
|
+
if (res.headers.has("set-cookie"))
|
|
17
|
+
return true;
|
|
18
|
+
const cc = res.headers.get("cache-control");
|
|
19
|
+
if (!cc)
|
|
20
|
+
return false;
|
|
21
|
+
for (const part of cc.split(",")) {
|
|
22
|
+
const token = part.trim().toLowerCase().split("=")[0];
|
|
23
|
+
if (CACHE_SKIP_DIRECTIVES.has(token))
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
async function sha1Hex(bytes) {
|
|
29
|
+
const c = globalThis.crypto;
|
|
30
|
+
if (!c?.subtle) {
|
|
31
|
+
throw new Error("etag(): WebCrypto SubtleCrypto API is unavailable on this runtime.");
|
|
32
|
+
}
|
|
33
|
+
const digest = new Uint8Array(await c.subtle.digest("SHA-1", bytes));
|
|
34
|
+
let out = "";
|
|
35
|
+
for (let i = 0; i < digest.length; i++)
|
|
36
|
+
out += digest[i].toString(16).padStart(2, "0");
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function inmMatches(headerValue, candidate) {
|
|
40
|
+
// RFC 7232 §3.2: comma-separated list of entity tags or `*`.
|
|
41
|
+
const list = headerValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
42
|
+
if (list.length === 0)
|
|
43
|
+
return false;
|
|
44
|
+
for (const tag of list) {
|
|
45
|
+
if (tag === "*")
|
|
46
|
+
return true;
|
|
47
|
+
// Strong comparison: tag and candidate must be byte-equal AND neither weak.
|
|
48
|
+
if (tag === candidate) {
|
|
49
|
+
if (!tag.startsWith("W/") && !candidate.startsWith("W/"))
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
// Weak comparison fallback for HEAD/GET on cached representations.
|
|
53
|
+
const tStripped = tag.startsWith("W/") ? tag.slice(2) : tag;
|
|
54
|
+
const cStripped = candidate.startsWith("W/") ? candidate.slice(2) : candidate;
|
|
55
|
+
if (tStripped === cStripped)
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ETag generation + conditional-GET handler.
|
|
62
|
+
*
|
|
63
|
+
* - Skips when the response already carries an `ETag`.
|
|
64
|
+
* - Skips when the response carries `Set-Cookie` OR `Cache-Control: private | no-store | no-cache`.
|
|
65
|
+
* - Skips non-`2xx` responses and methods other than `GET` / `HEAD`.
|
|
66
|
+
* - Emits `304 Not Modified` (preserving `cache-control`, `content-location`, `date`, `etag`, `expires`, `vary` per RFC 7232 §4.1) on a matching `If-None-Match`.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { etag } from "@daloyjs/core";
|
|
71
|
+
* app.use(etag());
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @since 0.21.0
|
|
75
|
+
*/
|
|
76
|
+
export function etag(opts = {}) {
|
|
77
|
+
const weak = opts.weak === true;
|
|
78
|
+
const gen = opts.generator;
|
|
79
|
+
return {
|
|
80
|
+
async onSend(res, ctx) {
|
|
81
|
+
if (res.headers.has("etag"))
|
|
82
|
+
return undefined;
|
|
83
|
+
if (res.status < 200 || res.status >= 300)
|
|
84
|
+
return undefined;
|
|
85
|
+
const method = ctx?.request?.method;
|
|
86
|
+
if (method !== "GET" && method !== "HEAD")
|
|
87
|
+
return undefined;
|
|
88
|
+
if (shouldSkipForCache(res))
|
|
89
|
+
return undefined;
|
|
90
|
+
const body = new Uint8Array(await res.clone().arrayBuffer());
|
|
91
|
+
const tag = gen ? await gen(body) : await sha1Hex(body);
|
|
92
|
+
const value = `${weak ? "W/" : ""}"${tag}"`;
|
|
93
|
+
const headers = new Headers(res.headers);
|
|
94
|
+
headers.set("etag", value);
|
|
95
|
+
const inm = ctx?.request?.headers.get("if-none-match");
|
|
96
|
+
if (inm && inmMatches(inm, value)) {
|
|
97
|
+
const stripped = new Headers();
|
|
98
|
+
for (const allow of ["cache-control", "content-location", "date", "etag", "expires", "vary"]) {
|
|
99
|
+
const v = headers.get(allow);
|
|
100
|
+
if (v !== null)
|
|
101
|
+
stripped.set(allow, v);
|
|
102
|
+
}
|
|
103
|
+
return new Response(null, { status: 304, headers: stripped });
|
|
104
|
+
}
|
|
105
|
+
// Re-emit response with the new header. For HEAD requests the body is
|
|
106
|
+
// already empty so passing `body` is safe; we read the bytes for the
|
|
107
|
+
// digest above, so a fresh Response is required either way.
|
|
108
|
+
const responseBody = method === "HEAD" ? null : body;
|
|
109
|
+
return new Response(responseBody, {
|
|
110
|
+
status: res.status,
|
|
111
|
+
statusText: res.statusText,
|
|
112
|
+
headers,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=etag.js.map
|
package/dist/etag.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etag.js","sourceRoot":"","sources":["../src/etag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqBH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC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AAS,EAAE,MAAM,CAAC,EAAE,CAAC;oBAC7F,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBAC7B,IAAI,CAAC,KAAK,IAAI;wBAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACzC,CAAC;gBACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;YACD,sEAAsE;YACtE,qEAAqE;YACrE,4DAA4D;YAC5D,MAAM,YAAY,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACrD,OAAO,IAAI,QAAQ,CAAC,YAAY,EAAE;gBAChC,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,UAAU,EAAE,GAAG,CAAC,UAAU;gBAC1B,OAAO;aACR,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
export { App } from "./app.js";
|
|
2
2
|
export { createApp } from "./app.js";
|
|
3
3
|
export { _resetPackageJsonCacheForTests } from "./app.js";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export { _resetCrashHandlersForTests } from "./app.js";
|
|
5
|
+
export { _resetInsecureDefaultsLogForTests } from "./app.js";
|
|
6
|
+
export type { AppOptions, AppOpenAPIOptions, DocsRouteOptions, HealthRouteOptions, CspReportRouteOptions, IntrospectedRoute, PluginInstalledEvent, PluginExtension, ShutdownEvent, } from "./app.js";
|
|
7
|
+
export { getConnInfo, setConnInfo, assertBehindProxy, resolveClientIp, readRemoteAddress, readRemotePort, pickForwardedForByHops, } from "./conn-info.js";
|
|
8
|
+
export type { BehindProxyConfig, ConnInfo } from "./conn-info.js";
|
|
9
|
+
export { subdomains, PSL_SNAPSHOT_DATE, PSL_PUBLIC_SUFFIXES, MAX_SNAPSHOT_AGE_DAYS, } from "./subdomains.js";
|
|
10
|
+
export type { SubdomainsOptions, SubdomainsResult } from "./subdomains.js";
|
|
11
|
+
export { defineDependency, DEPENDENCY_MARKER } from "./dependency.js";
|
|
12
|
+
export type { DependencyHooks, DependencyOptions, } from "./dependency.js";
|
|
13
|
+
export type { RouteDefinition, HttpMethod, PathString, RequestSchemas, ResponsesMap, ResponseSpec, AuthSpec, Hooks, BaseContext, AppState, AuthScheme, AuthContext, HandlerReturn, InferRequest, ParamsOf, PathParams, CallbackDefinition, CallbackMap, CallbackOperation, RouteExample, RouteMeta, } from "./types.js";
|
|
6
14
|
export { HttpError, BadRequestError, ValidationError, NotFoundError, UnauthorizedError, ForbiddenError, MethodNotAllowedError, PayloadTooLargeError, UnsupportedMediaTypeError, TooManyRequestsError, RequestTimeoutError, InternalError, } from "./errors.js";
|
|
7
15
|
export type { ProblemDetails, ProblemRenderOptions } from "./errors.js";
|
|
8
16
|
export type { StandardSchemaV1 } from "./schema.js";
|
|
9
17
|
export { validate, isStandardSchema } from "./schema.js";
|
|
10
18
|
export { readBodyLimited, safeJsonParse, sanitizeHeaderName, sanitizeHeaderValue, timingSafeEqual, randomId, assertNoDuplicateSingletonHeaders, SMUGGLING_SINGLETON_HEADERS, verifyWebhookSignature, signWebhookPayload, assertStrongSecret, MIN_PROD_SECRET_BYTES, WEAK_SECRET_STRINGS, } from "./security.js";
|
|
11
19
|
export type { WebhookHmacAlgorithm } from "./security.js";
|
|
12
|
-
export { requestId, secureHeaders, SECURE_HEADERS_MARKER, cors, CORS_HOOK_MARKER, CORS_ORIGIN_ALLOW_MARKER, CORS_WILDCARD_ORIGIN_MARKER, rateLimit, timing, bearerAuth, basicAuth, csrf, CSRF_HOOK_MARKER, } from "./middleware.js";
|
|
13
|
-
export
|
|
20
|
+
export { requestId, secureHeaders, SECURE_HEADERS_MARKER, cors, CORS_HOOK_MARKER, CORS_ORIGIN_ALLOW_MARKER, CORS_WILDCARD_ORIGIN_MARKER, rateLimit, loginThrottle, timing, bearerAuth, basicAuth, csrf, CSRF_HOOK_MARKER, requireScopes, REQUIRE_SCOPES_AGGREGATE_KEY, REQUIRE_SCOPES_HOOK_MARKER, _resetSharedRateLimitStoresForTests, } from "./middleware.js";
|
|
21
|
+
export { etag } from "./etag.js";
|
|
22
|
+
export type { ETagOptions } from "./etag.js";
|
|
23
|
+
export { compression, COMPRESSION_HOOK_MARKER, _resetCompressionRuntimeProbeForTests, } from "./compression.js";
|
|
24
|
+
export type { CompressionEncoding, CompressionOptions, } from "./compression.js";
|
|
25
|
+
export { createJwtSigner, createJwtVerifier, JwtError, DEFAULT_JWT_MAX_LIFETIME_SECONDS, } from "./jwt.js";
|
|
26
|
+
export type { JwtAlgorithm, JwtKeyMaterial, JwtSignerOptions, JwtVerifierOptions, JwtVerified, } from "./jwt.js";
|
|
27
|
+
export { jwk } from "./jwk.js";
|
|
28
|
+
export type { JwkAlgorithm, JwkOptions, JwkSet, JwkSource, JwkVerifyHook, } from "./jwk.js";
|
|
29
|
+
export { serializeCookie, serializeClearCookie, assertCookieAttributes, readRequestCookie, } from "./cookie.js";
|
|
30
|
+
export type { CookieAttributes, CookieSameSite } from "./cookie.js";
|
|
31
|
+
export { assertTemporalClaims, TemporalClaimError, } from "./time-claims.js";
|
|
32
|
+
export type { TemporalClaims, TemporalClaimErrorCode, AssertTemporalClaimsOptions, } from "./time-claims.js";
|
|
33
|
+
export { every, some, except } from "./combine.js";
|
|
34
|
+
export type { ExceptPredicate } from "./combine.js";
|
|
35
|
+
export { ipRestriction } from "./ip-restriction.js";
|
|
36
|
+
export type { IpRestrictionOptions } from "./ip-restriction.js";
|
|
37
|
+
export { loadShedding, LOAD_SHEDDING_MARKER } from "./load-shedding.js";
|
|
38
|
+
export type { LoadSheddingOptions, LoadSheddingSnapshot, } from "./load-shedding.js";
|
|
39
|
+
export { defineConfig, ConfigValidationError } from "./config.js";
|
|
40
|
+
export type { ConfigSource, DefineConfigOptions, } from "./config.js";
|
|
41
|
+
export type { RequestIdOptions, SecureHeadersOptions, CspDirectivesOptions, CorsOptions, CorsOriginAllow, RateLimitOptions, RateLimitStore, LoginThrottleOptions, CsrfOptions, CsrfCookieOptions, BasicAuthOptions, } from "./middleware.js";
|
|
42
|
+
export type { BearerAuthOptions, BearerAuthVerifyHook } from "./middleware.js";
|
|
14
43
|
export { createLogger, noopLogger, DEFAULT_REDACT_KEYS } from "./logger.js";
|
|
15
44
|
export type { Logger, LogLevel, ConsoleLoggerOptions, LoggerRedactionOptions, } from "./logger.js";
|
|
16
45
|
export type { ScalarJsonPrimitive, ScalarJsonValue, ScalarReferenceConfiguration, ScalarTheme, } from "./docs.js";
|
|
@@ -18,16 +47,16 @@ export { formatStartupBanner, printStartupBanner } from "./banner.js";
|
|
|
18
47
|
export type { StartupBannerLink, StartupBannerOptions } from "./banner.js";
|
|
19
48
|
export { sseStream, sseResponse, ndjsonStream, ndjsonResponse, } from "./streaming.js";
|
|
20
49
|
export type { SSEMessage, StreamOptions, SSEStreamOptions, SSEResponseOptions, NDJSONResponseOptions, } from "./streaming.js";
|
|
21
|
-
export { httpBearerScheme, httpBasicScheme, apiKeyScheme, oauth2Scheme, openIdConnectScheme, } from "./security-schemes.js";
|
|
22
|
-
export type { ApiKeyLocation, ApiKeyScheme, ApiKeySchemeOptions, HttpBasicScheme, HttpBasicSchemeOptions, HttpBearerScheme, HttpBearerSchemeOptions, OAuth2AuthorizationCodeFlow, OAuth2ClientCredentialsFlow, OAuth2Flows, OAuth2ImplicitFlow, OAuth2PasswordFlow, OAuth2Scheme, OAuth2SchemeOptions, OpenIdConnectScheme, OpenIdConnectSchemeOptions, SecurityScheme, } from "./security-schemes.js";
|
|
50
|
+
export { httpBearerScheme, httpBasicScheme, apiKeyScheme, oauth2Scheme, openIdConnectScheme, REQUIRE_PAYLOAD_AUTH_EXTENSION, securitySchemeRequiresPayloadAuth, toOpenAPISecurityScheme, } from "./security-schemes.js";
|
|
51
|
+
export type { ApiKeyLocation, ApiKeyScheme, ApiKeySchemeOptions, HttpBasicScheme, HttpBasicSchemeOptions, HttpBearerScheme, HttpBearerSchemeOptions, OAuth2AuthorizationCodeFlow, OAuth2ClientCredentialsFlow, OAuth2Flows, OAuth2ImplicitFlow, OAuth2PasswordFlow, OAuth2Scheme, OAuth2SchemeOptions, OpenIdConnectScheme, OpenIdConnectSchemeOptions, SecurityScheme, RequirePayloadAuthExtension, } from "./security-schemes.js";
|
|
23
52
|
export { discriminator, discriminatedUnion } from "./discriminator.js";
|
|
24
53
|
export type { DiscriminatorObject, DiscriminatedUnion, DiscriminatedUnionOptions, } from "./discriminator.js";
|
|
25
|
-
export { session, signValue, verifySignedValue, MemorySessionStore, SESSION_HOOK_MARKER, SESSION_SECRETS_MARKER, } from "./session.js";
|
|
26
|
-
export type { SessionOptions, SessionCookieOptions, SessionContext, SessionRecord, SessionStore, SessionState, } from "./session.js";
|
|
54
|
+
export { session, rotateSession, signValue, verifySignedValue, MemorySessionStore, SESSION_HOOK_MARKER, SESSION_SECRETS_MARKER, } from "./session.js";
|
|
55
|
+
export type { SessionOptions, SessionCookieOptions, SessionContext, SessionRecord, SessionStore, SessionState, RotateSessionOptions, } from "./session.js";
|
|
27
56
|
export { fileField, multipartObject, isFileFieldSchema, isMultipartObjectSchema, } from "./multipart.js";
|
|
28
|
-
export type { FileFieldSchema, FileFieldOptions, MultipartObjectOptions, MultipartShape, UploadedFile, } from "./multipart.js";
|
|
57
|
+
export type { FileFieldSchema, FileFieldOptions, FileMagicBytesOption, FileMagicBytesSignature, MultipartObjectOptions, MultipartShape, UploadedFile, } from "./multipart.js";
|
|
29
58
|
export { otelTracing, TRACING_SPAN_KIND_SERVER, TRACING_SPAN_STATUS_UNSET, TRACING_SPAN_STATUS_OK, TRACING_SPAN_STATUS_ERROR, } from "./tracing.js";
|
|
30
59
|
export type { OtelTracingOptions, TracingAttributes, TracingAttributeValue, TracingSpan, TracingStartSpanOptions, TracingTracer, } from "./tracing.js";
|
|
31
|
-
export { defineWebSocket, WebSocketRegistry, WebSocketProtocolError, WS_GUID, WS_READY_STATE, WS_OPCODE, WS_CLOSE_CODE, WS_MAX_CONTROL_PAYLOAD, computeAcceptKey, parseSubprotocols, validateSelectedSubprotocol, validateUpgrade, parseFrame, encodeFrame, encodeClosePayload, decodeClosePayload, encodeSendPayload, FrameSink, FRAME_INCOMPLETE, } from "./websocket.js";
|
|
32
|
-
export type { WebSocketConnection, WebSocketContext, WebSocketHandler, WebSocketRouteEntry, HandshakeResult, ParsedFrame, MessageEvent as WebSocketMessageEvent, FrameSinkEvents, } from "./websocket.js";
|
|
60
|
+
export { defineWebSocket, WebSocketRegistry, WebSocketProtocolError, WebSocketPayloadTooLargeError, WS_GUID, WS_READY_STATE, WS_OPCODE, WS_CLOSE_CODE, WS_MAX_CONTROL_PAYLOAD, DEFAULT_WS_BACKPRESSURE_LIMIT, DEFAULT_WS_MAX_PAYLOAD_LENGTH, DEFAULT_WS_IDLE_TIMEOUT_SECONDS, computeAcceptKey, parseSubprotocols, validateSelectedSubprotocol, validateUpgrade, parseFrame, encodeFrame, encodeClosePayload, decodeClosePayload, encodeSendPayload, normalizeWebSocketOptions, wsRateLimit, FrameSink, FRAME_INCOMPLETE, } from "./websocket.js";
|
|
61
|
+
export type { WebSocketConnection, WebSocketContext, WebSocketHandler, WebSocketRouteEntry, NormalizedWebSocketOptions, WebSocketBeforeUpgrade, HandshakeResult, ParsedFrame, MessageEvent as WebSocketMessageEvent, FrameSinkEvents, } from "./websocket.js";
|
|
33
62
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,8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B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,YAAY,IAAI,qBAAqB,EACrC,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
export { App } from "./app.js";
|
|
2
2
|
export { createApp } from "./app.js";
|
|
3
3
|
export { _resetPackageJsonCacheForTests } from "./app.js";
|
|
4
|
+
export { _resetCrashHandlersForTests } from "./app.js";
|
|
5
|
+
export { _resetInsecureDefaultsLogForTests } from "./app.js";
|
|
6
|
+
export { getConnInfo, setConnInfo, assertBehindProxy, resolveClientIp, readRemoteAddress, readRemotePort, pickForwardedForByHops, } from "./conn-info.js";
|
|
7
|
+
export { subdomains, PSL_SNAPSHOT_DATE, PSL_PUBLIC_SUFFIXES, MAX_SNAPSHOT_AGE_DAYS, } from "./subdomains.js";
|
|
8
|
+
export { defineDependency, DEPENDENCY_MARKER } from "./dependency.js";
|
|
4
9
|
export { HttpError, BadRequestError, ValidationError, NotFoundError, UnauthorizedError, ForbiddenError, MethodNotAllowedError, PayloadTooLargeError, UnsupportedMediaTypeError, TooManyRequestsError, RequestTimeoutError, InternalError, } from "./errors.js";
|
|
5
10
|
export { validate, isStandardSchema } from "./schema.js";
|
|
6
11
|
export { readBodyLimited, safeJsonParse, sanitizeHeaderName, sanitizeHeaderValue, timingSafeEqual, randomId, assertNoDuplicateSingletonHeaders, SMUGGLING_SINGLETON_HEADERS, verifyWebhookSignature, signWebhookPayload, assertStrongSecret, MIN_PROD_SECRET_BYTES, WEAK_SECRET_STRINGS, } from "./security.js";
|
|
7
|
-
export { requestId, secureHeaders, SECURE_HEADERS_MARKER, cors, CORS_HOOK_MARKER, CORS_ORIGIN_ALLOW_MARKER, CORS_WILDCARD_ORIGIN_MARKER, rateLimit, timing, bearerAuth, basicAuth, csrf, CSRF_HOOK_MARKER, } from "./middleware.js";
|
|
12
|
+
export { requestId, secureHeaders, SECURE_HEADERS_MARKER, cors, CORS_HOOK_MARKER, CORS_ORIGIN_ALLOW_MARKER, CORS_WILDCARD_ORIGIN_MARKER, rateLimit, loginThrottle, timing, bearerAuth, basicAuth, csrf, CSRF_HOOK_MARKER, requireScopes, REQUIRE_SCOPES_AGGREGATE_KEY, REQUIRE_SCOPES_HOOK_MARKER, _resetSharedRateLimitStoresForTests, } from "./middleware.js";
|
|
13
|
+
export { etag } from "./etag.js";
|
|
14
|
+
export { compression, COMPRESSION_HOOK_MARKER, _resetCompressionRuntimeProbeForTests, } from "./compression.js";
|
|
15
|
+
export { createJwtSigner, createJwtVerifier, JwtError, DEFAULT_JWT_MAX_LIFETIME_SECONDS, } from "./jwt.js";
|
|
16
|
+
export { jwk } from "./jwk.js";
|
|
17
|
+
export { serializeCookie, serializeClearCookie, assertCookieAttributes, readRequestCookie, } from "./cookie.js";
|
|
18
|
+
export { assertTemporalClaims, TemporalClaimError, } from "./time-claims.js";
|
|
19
|
+
export { every, some, except } from "./combine.js";
|
|
20
|
+
export { ipRestriction } from "./ip-restriction.js";
|
|
21
|
+
export { loadShedding, LOAD_SHEDDING_MARKER } from "./load-shedding.js";
|
|
22
|
+
export { defineConfig, ConfigValidationError } from "./config.js";
|
|
8
23
|
export { createLogger, noopLogger, DEFAULT_REDACT_KEYS } from "./logger.js";
|
|
9
24
|
export { formatStartupBanner, printStartupBanner } from "./banner.js";
|
|
10
25
|
export { sseStream, sseResponse, ndjsonStream, ndjsonResponse, } from "./streaming.js";
|
|
11
|
-
export { httpBearerScheme, httpBasicScheme, apiKeyScheme, oauth2Scheme, openIdConnectScheme, } from "./security-schemes.js";
|
|
26
|
+
export { httpBearerScheme, httpBasicScheme, apiKeyScheme, oauth2Scheme, openIdConnectScheme, REQUIRE_PAYLOAD_AUTH_EXTENSION, securitySchemeRequiresPayloadAuth, toOpenAPISecurityScheme, } from "./security-schemes.js";
|
|
12
27
|
export { discriminator, discriminatedUnion } from "./discriminator.js";
|
|
13
|
-
export { session, signValue, verifySignedValue, MemorySessionStore, SESSION_HOOK_MARKER, SESSION_SECRETS_MARKER, } from "./session.js";
|
|
28
|
+
export { session, rotateSession, signValue, verifySignedValue, MemorySessionStore, SESSION_HOOK_MARKER, SESSION_SECRETS_MARKER, } from "./session.js";
|
|
14
29
|
export { fileField, multipartObject, isFileFieldSchema, isMultipartObjectSchema, } from "./multipart.js";
|
|
15
30
|
export { otelTracing, TRACING_SPAN_KIND_SERVER, TRACING_SPAN_STATUS_UNSET, TRACING_SPAN_STATUS_OK, TRACING_SPAN_STATUS_ERROR, } from "./tracing.js";
|
|
16
|
-
export { defineWebSocket, WebSocketRegistry, WebSocketProtocolError, WS_GUID, WS_READY_STATE, WS_OPCODE, WS_CLOSE_CODE, WS_MAX_CONTROL_PAYLOAD, computeAcceptKey, parseSubprotocols, validateSelectedSubprotocol, validateUpgrade, parseFrame, encodeFrame, encodeClosePayload, decodeClosePayload, encodeSendPayload, FrameSink, FRAME_INCOMPLETE, } from "./websocket.js";
|
|
31
|
+
export { defineWebSocket, WebSocketRegistry, WebSocketProtocolError, WebSocketPayloadTooLargeError, WS_GUID, WS_READY_STATE, WS_OPCODE, WS_CLOSE_CODE, WS_MAX_CONTROL_PAYLOAD, DEFAULT_WS_BACKPRESSURE_LIMIT, DEFAULT_WS_MAX_PAYLOAD_LENGTH, DEFAULT_WS_IDLE_TIMEOUT_SECONDS, computeAcceptKey, parseSubprotocols, validateSelectedSubprotocol, validateUpgrade, parseFrame, encodeFrame, encodeClosePayload, decodeClosePayload, encodeSendPayload, normalizeWebSocketOptions, wsRateLimit, FrameSink, FRAME_INCOMPLETE, } from "./websocket.js";
|
|
17
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO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kB,EAAE,MAAM,oBAAoB,CAAC;AAOvE,OAAO,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAWtB,OAAO,EACL,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,6BAA6B,EAC7B,OAAO,EACP,cAAc,EACd,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,WAAW,EACX,SAAS,EACT,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network-layer access control for {@link Hooks}. The {@link ipRestriction}
|
|
3
|
+
* middleware enforces IPv4 / IPv6 / CIDR allow- and deny-lists. Because the
|
|
4
|
+
* Web-standard {@link Request} does not expose a peer address, callers must
|
|
5
|
+
* either provide a trusted resolver or explicitly opt in to trusted proxy
|
|
6
|
+
* headers.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.19.0
|
|
9
|
+
*/
|
|
10
|
+
import type { BaseContext, Hooks } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Options for {@link ipRestriction}. At least one of `allow` or `deny` must
|
|
13
|
+
* be provided; supplying both runs deny-first then allow-otherwise (deny
|
|
14
|
+
* wins on conflict, matching the principle of least privilege).
|
|
15
|
+
*
|
|
16
|
+
* @since 0.19.0
|
|
17
|
+
*/
|
|
18
|
+
export interface IpRestrictionOptions {
|
|
19
|
+
/**
|
|
20
|
+
* IP addresses or CIDR ranges (e.g. `"10.0.0.0/8"`, `"2001:db8::/32"`,
|
|
21
|
+
* `"203.0.113.42"`) that should be allowed. When set, any peer whose
|
|
22
|
+
* address does not match a pattern in this list is rejected with HTTP
|
|
23
|
+
* `403 Forbidden`. Mutually exclusive with running without any list.
|
|
24
|
+
*/
|
|
25
|
+
allow?: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* IP addresses or CIDR ranges that should be rejected outright. Matches
|
|
28
|
+
* here always lose to nothing — even an explicit allow-list entry will
|
|
29
|
+
* not override a deny. Useful for blocking known bad ranges while
|
|
30
|
+
* keeping a broad allow-list.
|
|
31
|
+
*/
|
|
32
|
+
deny?: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Override the source of the client IP. By default Daloy fails closed
|
|
35
|
+
* because Web-standard `Request` objects do not expose the peer address.
|
|
36
|
+
* Provide a function to read adapter connection metadata or a trusted
|
|
37
|
+
* custom header (e.g. a CDN-specific identifier).
|
|
38
|
+
*/
|
|
39
|
+
resolveIp?: (ctx: BaseContext<any, any>) => string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Read `X-Forwarded-For` / `X-Real-IP` in the default resolver. Defaults
|
|
42
|
+
* to `false` because those headers are client-spoofable unless every
|
|
43
|
+
* request reaches Daloy through a proxy chain you control. Pair with
|
|
44
|
+
* `new App({ trustProxy: true })` in production.
|
|
45
|
+
*/
|
|
46
|
+
trustProxyHeaders?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Response message when a request is rejected. Defaults to
|
|
49
|
+
* `"IP address not permitted"`. Avoid echoing the client IP back —
|
|
50
|
+
* doing so can leak proxy topology to attackers.
|
|
51
|
+
*/
|
|
52
|
+
message?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Block or allow requests by source IP / CIDR range. In direct Web-standard
|
|
56
|
+
* runtimes, pass `resolveIp` from the adapter-specific connection metadata.
|
|
57
|
+
* Behind a trusted proxy chain, set `trustProxyHeaders: true` to read
|
|
58
|
+
* `X-Forwarded-For` / `X-Real-IP`.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* app.use(ipRestriction({
|
|
63
|
+
* allow: ["10.0.0.0/8", "::1"],
|
|
64
|
+
* deny: ["10.6.6.0/24"],
|
|
65
|
+
* trustProxyHeaders: true,
|
|
66
|
+
* }));
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* On reject the middleware throws a {@link ForbiddenError}, which Daloy
|
|
70
|
+
* renders as RFC 9457 `application/problem+json`.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.19.0
|
|
73
|
+
*/
|
|
74
|
+
export declare function ipRestriction(opts: IpRestrictionOptions): Hooks;
|
|
75
|
+
//# sourceMappingURL=ip-restriction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-restriction.d.ts","sourceRoot":"","sources":["../src/ip-restriction.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGrD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;IAC/D;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAaD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,KAAK,CAyB/D"}
|