@nifrajs/core 2.14.1 → 3.1.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 +4 -0
- package/dist/assurance.d.ts +16 -8
- package/dist/assurance.d.ts.map +1 -1
- package/dist/assurance.js +33 -0
- package/dist/assurance.js.map +1 -1
- package/dist/edge-kit.d.ts +27 -0
- package/dist/edge-kit.d.ts.map +1 -0
- package/dist/edge-kit.js +24 -0
- package/dist/edge-kit.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/route-execution.d.ts +11 -5
- package/dist/internal/route-execution.d.ts.map +1 -1
- package/dist/internal/route-execution.js +2 -1
- package/dist/internal/route-execution.js.map +1 -1
- package/dist/response-observer.d.ts +25 -0
- package/dist/response-observer.d.ts.map +1 -0
- package/dist/response-observer.js +40 -0
- package/dist/response-observer.js.map +1 -0
- package/dist/security/baseline.d.ts +68 -0
- package/dist/security/baseline.d.ts.map +1 -0
- package/dist/security/baseline.js +118 -0
- package/dist/security/baseline.js.map +1 -0
- package/dist/server/bare-error-lane.d.ts +26 -0
- package/dist/server/bare-error-lane.d.ts.map +1 -0
- package/dist/server/bare-error-lane.js +60 -0
- package/dist/server/bare-error-lane.js.map +1 -0
- package/dist/server/body.d.ts +7 -0
- package/dist/server/body.d.ts.map +1 -1
- package/dist/server/body.js +7 -0
- package/dist/server/body.js.map +1 -1
- package/dist/server/bridge-markers.d.ts +25 -0
- package/dist/server/bridge-markers.d.ts.map +1 -0
- package/dist/server/bridge-markers.js +25 -0
- package/dist/server/bridge-markers.js.map +1 -0
- package/dist/server/context.d.ts +6 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/header-case.d.ts.map +1 -1
- package/dist/server/header-case.js +2 -1
- package/dist/server/header-case.js.map +1 -1
- package/dist/server/http.d.ts +36 -3
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +49 -3
- package/dist/server/http.js.map +1 -1
- package/dist/server/install.d.ts +6 -8
- package/dist/server/install.d.ts.map +1 -1
- package/dist/server/install.js +7 -0
- package/dist/server/install.js.map +1 -1
- package/dist/server/node-outcome-hook.d.ts +2 -1
- package/dist/server/node-outcome-hook.d.ts.map +1 -1
- package/dist/server/node-outcome-hook.js.map +1 -1
- package/dist/server/node-outcome.d.ts +17 -2
- package/dist/server/node-outcome.d.ts.map +1 -1
- package/dist/server/node-outcome.js +37 -3
- package/dist/server/node-outcome.js.map +1 -1
- package/dist/server/query.d.ts +7 -1
- package/dist/server/query.d.ts.map +1 -1
- package/dist/server/query.js +8 -3
- package/dist/server/query.js.map +1 -1
- package/dist/server/request-context.d.ts +17 -4
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +63 -29
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/respond.d.ts.map +1 -1
- package/dist/server/respond.js +19 -2
- package/dist/server/respond.js.map +1 -1
- package/dist/server/response-contract-lane.d.ts.map +1 -1
- package/dist/server/response-contract-lane.js +5 -2
- package/dist/server/response-contract-lane.js.map +1 -1
- package/dist/server/response-observer-runtime.d.ts +20 -0
- package/dist/server/response-observer-runtime.d.ts.map +1 -0
- package/dist/server/response-observer-runtime.js +95 -0
- package/dist/server/response-observer-runtime.js.map +1 -0
- package/dist/server/runtime-core.d.ts +60 -0
- package/dist/server/runtime-core.d.ts.map +1 -1
- package/dist/server/runtime-core.js +65 -1
- package/dist/server/runtime-core.js.map +1 -1
- package/dist/server/server-types.d.ts +3 -1
- package/dist/server/server-types.d.ts.map +1 -1
- package/dist/server/server.d.ts +52 -39
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +267 -271
- package/dist/server/server.js.map +1 -1
- package/dist/server/websocket.d.ts +20 -4
- package/dist/server/websocket.d.ts.map +1 -1
- package/dist/server/websocket.js +81 -11
- package/dist/server/websocket.js.map +1 -1
- package/dist/server/ws-bun.d.ts +1 -1
- package/dist/server/ws-bun.d.ts.map +1 -1
- package/dist/server/ws-bun.js +12 -8
- package/dist/server/ws-bun.js.map +1 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/single-copy-register.d.ts +2 -0
- package/dist/single-copy-register.d.ts.map +1 -0
- package/dist/single-copy-register.js +24 -0
- package/dist/single-copy-register.js.map +1 -0
- package/dist/single-copy.d.ts +156 -0
- package/dist/single-copy.d.ts.map +1 -0
- package/dist/single-copy.js +470 -0
- package/dist/single-copy.js.map +1 -0
- package/package.json +24 -2
- package/src/assurance.ts +58 -1
- package/src/edge-kit.ts +27 -0
- package/src/errors.ts +1 -0
- package/src/index.ts +1 -1
- package/src/internal/route-execution.ts +23 -16
- package/src/response-observer.ts +64 -0
- package/src/security/baseline.ts +172 -0
- package/src/server/bare-error-lane.ts +76 -0
- package/src/server/body.ts +8 -0
- package/src/server/bridge-markers.ts +24 -0
- package/src/server/context.ts +6 -1
- package/src/server/header-case.ts +3 -1
- package/src/server/http.ts +53 -3
- package/src/server/install.ts +14 -0
- package/src/server/node-outcome-hook.ts +2 -1
- package/src/server/node-outcome.ts +44 -3
- package/src/server/query.ts +10 -4
- package/src/server/request-context.ts +85 -33
- package/src/server/respond.ts +26 -1
- package/src/server/response-contract-lane.ts +6 -2
- package/src/server/response-observer-runtime.ts +135 -0
- package/src/server/runtime-core.ts +98 -1
- package/src/server/server-types.ts +3 -1
- package/src/server/server.ts +436 -367
- package/src/server/websocket.ts +127 -17
- package/src/server/ws-bun.ts +26 -7
- package/src/server.ts +2 -1
- package/src/single-copy-register.ts +24 -0
- package/src/single-copy.ts +524 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AssurancePolicy } from "../assurance.js";
|
|
2
|
+
/**
|
|
3
|
+
* How much a {@link securityBaseline} demands. Each level is a superset of the one before it, so
|
|
4
|
+
* raising the level only ever adds findings.
|
|
5
|
+
*
|
|
6
|
+
* - `"essential"` - the invariants that hold for ANY app and never false-positive on a reasonable
|
|
7
|
+
* one: a body read must be bounded, an unlimited body may never claim to be bounded, an agent tool
|
|
8
|
+
* ingress must be bounded, and an authenticated state change must prove CSRF. Every required piece
|
|
9
|
+
* of evidence here is either published by the core from the route schema or only demanded when the
|
|
10
|
+
* route already opted into the risk (CSRF is required only where authentication is present). Safe to
|
|
11
|
+
* adopt on day one.
|
|
12
|
+
* - `"standard"` (default) - essential, plus: a route the app itself classified as `pii` or higher
|
|
13
|
+
* must be authenticated, whether it reads or writes. High signal, low noise - it fires only on
|
|
14
|
+
* routes the application already labelled sensitive.
|
|
15
|
+
* - `"strict"` - standard, plus the opinionated, higher-friction requirements: every route must carry
|
|
16
|
+
* a response contract, every read must carry security headers, and every mutation must be rate
|
|
17
|
+
* limited. These need middleware the app has to install, so they are opt-in rather than default.
|
|
18
|
+
*/
|
|
19
|
+
export type SecurityBaselineLevel = "essential" | "standard" | "strict";
|
|
20
|
+
/** Tuning for {@link securityBaseline}. Every knob only ever tightens the policy. */
|
|
21
|
+
export interface SecurityBaselineOptions {
|
|
22
|
+
/** How much the baseline demands. Default `"standard"`. See {@link SecurityBaselineLevel}. */
|
|
23
|
+
readonly level?: SecurityBaselineLevel;
|
|
24
|
+
/**
|
|
25
|
+
* How to treat a route no rule matched. Default `"ignore"` so the baseline is purely additive - it
|
|
26
|
+
* asserts the invariants below and stays silent on everything else, which lets a project adopt it
|
|
27
|
+
* without first classifying its whole route table. Set `"error"` to make an unclassified route a
|
|
28
|
+
* finding, turning the baseline into a closed allow-list (recommended once the table is covered).
|
|
29
|
+
*/
|
|
30
|
+
readonly unmatched?: "error" | "ignore";
|
|
31
|
+
/**
|
|
32
|
+
* Require that a matched route's evidence was installed by runtime enforcement (middleware/plugin
|
|
33
|
+
* or framework policy) rather than asserted inline on `schema.assurance`. Default `true`: an author
|
|
34
|
+
* label is not proof, and a security baseline that accepts labels is theater. Set `false` only to
|
|
35
|
+
* stage adoption before guards emit runtime evidence.
|
|
36
|
+
*/
|
|
37
|
+
readonly requireRuntimeProvenance?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A first-match-wins security policy that turns the recurring audit finding classes into machine
|
|
41
|
+
* checked route invariants. Composed only from the public assurance engine, so it inherits its
|
|
42
|
+
* fail-closed evaluation, provenance checks, and selector validation - no bespoke evaluator.
|
|
43
|
+
*
|
|
44
|
+
* The rules are ordered most-specific-first because assurance evaluation is first-match-wins: each
|
|
45
|
+
* route is owned by exactly one rule, so that rule carries the FULL requirement bundle for its class
|
|
46
|
+
* (a body-carrying mutation proves bounded-body AND CSRF in one rule, not two). Raising the `level`
|
|
47
|
+
* widens those bundles; it never reorders them.
|
|
48
|
+
*
|
|
49
|
+
* Coverage by level (see {@link SecurityBaselineLevel} for the rationale):
|
|
50
|
+
*
|
|
51
|
+
* | invariant | essential | standard | strict |
|
|
52
|
+
* | --- | :-: | :-: | :-: |
|
|
53
|
+
* | unlimited body can never be "bounded" (F-001) | ✓ | ✓ | ✓ |
|
|
54
|
+
* | every body read is bounded | ✓ | ✓ | ✓ |
|
|
55
|
+
* | agent tool ingress is bounded | ✓ | ✓ | ✓ |
|
|
56
|
+
* | authenticated mutation proves CSRF | ✓ | ✓ | ✓ |
|
|
57
|
+
* | pii+ route is authenticated | | ✓ | ✓ |
|
|
58
|
+
* | every route carries a response contract | | | ✓ |
|
|
59
|
+
* | every read carries security headers | | | ✓ |
|
|
60
|
+
* | every mutation is rate limited | | | ✓ |
|
|
61
|
+
*
|
|
62
|
+
* The baseline deliberately does not select on `access`/`zone` capabilities: those selectors require
|
|
63
|
+
* capability definitions and would make the preset refuse an app that declares none. Extend the
|
|
64
|
+
* returned policy's `rules` for capability- or path-specific requirements; put more specific rules
|
|
65
|
+
* before these so they own their routes first.
|
|
66
|
+
*/
|
|
67
|
+
export declare function securityBaseline(options?: SecurityBaselineOptions): AssurancePolicy;
|
|
68
|
+
//# sourceMappingURL=baseline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/security/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,iBAAiB,CAAA;AAGrE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEvE,qFAAqF;AACrF,MAAM,WAAW,uBAAuB;IACtC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAA;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAA;CAC5C;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,eAAe,CAgGvF"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { NIFRA_ASSURANCE_IDS } from "../internal/route-assurance.js";
|
|
2
|
+
const MUTATING = ["POST", "PUT", "PATCH", "DELETE"];
|
|
3
|
+
const READING = ["GET", "HEAD"];
|
|
4
|
+
/** The classification threshold above which the baseline demands authentication. */
|
|
5
|
+
const SENSITIVE = "pii";
|
|
6
|
+
/**
|
|
7
|
+
* A first-match-wins security policy that turns the recurring audit finding classes into machine
|
|
8
|
+
* checked route invariants. Composed only from the public assurance engine, so it inherits its
|
|
9
|
+
* fail-closed evaluation, provenance checks, and selector validation - no bespoke evaluator.
|
|
10
|
+
*
|
|
11
|
+
* The rules are ordered most-specific-first because assurance evaluation is first-match-wins: each
|
|
12
|
+
* route is owned by exactly one rule, so that rule carries the FULL requirement bundle for its class
|
|
13
|
+
* (a body-carrying mutation proves bounded-body AND CSRF in one rule, not two). Raising the `level`
|
|
14
|
+
* widens those bundles; it never reorders them.
|
|
15
|
+
*
|
|
16
|
+
* Coverage by level (see {@link SecurityBaselineLevel} for the rationale):
|
|
17
|
+
*
|
|
18
|
+
* | invariant | essential | standard | strict |
|
|
19
|
+
* | --- | :-: | :-: | :-: |
|
|
20
|
+
* | unlimited body can never be "bounded" (F-001) | ✓ | ✓ | ✓ |
|
|
21
|
+
* | every body read is bounded | ✓ | ✓ | ✓ |
|
|
22
|
+
* | agent tool ingress is bounded | ✓ | ✓ | ✓ |
|
|
23
|
+
* | authenticated mutation proves CSRF | ✓ | ✓ | ✓ |
|
|
24
|
+
* | pii+ route is authenticated | | ✓ | ✓ |
|
|
25
|
+
* | every route carries a response contract | | | ✓ |
|
|
26
|
+
* | every read carries security headers | | | ✓ |
|
|
27
|
+
* | every mutation is rate limited | | | ✓ |
|
|
28
|
+
*
|
|
29
|
+
* The baseline deliberately does not select on `access`/`zone` capabilities: those selectors require
|
|
30
|
+
* capability definitions and would make the preset refuse an app that declares none. Extend the
|
|
31
|
+
* returned policy's `rules` for capability- or path-specific requirements; put more specific rules
|
|
32
|
+
* before these so they own their routes first.
|
|
33
|
+
*/
|
|
34
|
+
export function securityBaseline(options = {}) {
|
|
35
|
+
const level = options.level ?? "standard";
|
|
36
|
+
const strict = level === "strict";
|
|
37
|
+
const authSensitive = level !== "essential";
|
|
38
|
+
const provenance = options.requireRuntimeProvenance === false ? "any" : "runtime";
|
|
39
|
+
const A = NIFRA_ASSURANCE_IDS;
|
|
40
|
+
// Evidence the app must install middleware for, gated to the levels that assume that cost.
|
|
41
|
+
const contract = strict ? [A.RESPONSE_CONTRACT] : [];
|
|
42
|
+
const headers = strict ? [A.SECURITY_HEADERS] : [];
|
|
43
|
+
const rateLimit = strict ? [A.RATE_LIMITED] : [];
|
|
44
|
+
const authed = authSensitive ? [A.AUTHENTICATED] : [];
|
|
45
|
+
const rules = [
|
|
46
|
+
// The static twin of the config-time rejection: a schema route that opted into `bodyLimit:
|
|
47
|
+
// "unlimited"` can never carry `nifra.body-bounded` (the core withholds it), so requiring it is a
|
|
48
|
+
// standing ban. Owns the unlimited case before any body rule below can soften it. (F-001.)
|
|
49
|
+
{
|
|
50
|
+
name: "banned-unlimited-body",
|
|
51
|
+
match: { hasBody: true, bodyLimit: "unlimited" },
|
|
52
|
+
require: [A.BODY_BOUNDED],
|
|
53
|
+
},
|
|
54
|
+
// Agent tool ingress buffers attacker-influenced arguments; it must be bounded. Not CSRF-guarded:
|
|
55
|
+
// tool calls are token-authenticated machine traffic, not ambient-cookie browser posts.
|
|
56
|
+
{
|
|
57
|
+
name: "tool-ingress-bounded",
|
|
58
|
+
match: { tools: true, hasBody: true },
|
|
59
|
+
require: [A.BODY_BOUNDED, ...contract],
|
|
60
|
+
requireProvenance: provenance,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
// Sensitive mutations, split by body shape so bounded-body is required only where a body exists.
|
|
64
|
+
// Emitted only when a level adds a requirement beyond the generic mutation rules, otherwise they
|
|
65
|
+
// would be redundant duplicates that only slow evaluation.
|
|
66
|
+
if (authSensitive || strict) {
|
|
67
|
+
rules.push({
|
|
68
|
+
name: "sensitive-mutation-body",
|
|
69
|
+
match: { methods: [...MUTATING], hasBody: true, classificationAtLeast: SENSITIVE },
|
|
70
|
+
require: [A.BODY_BOUNDED, ...authed, ...contract, ...rateLimit],
|
|
71
|
+
requireCsrfWithAuthenticated: true,
|
|
72
|
+
requireProvenance: provenance,
|
|
73
|
+
}, {
|
|
74
|
+
name: "sensitive-mutation",
|
|
75
|
+
match: { methods: [...MUTATING], classificationAtLeast: SENSITIVE },
|
|
76
|
+
require: [...authed, ...contract, ...rateLimit],
|
|
77
|
+
requireCsrfWithAuthenticated: true,
|
|
78
|
+
requireProvenance: provenance,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
rules.push({
|
|
82
|
+
name: "mutation-body",
|
|
83
|
+
match: { methods: [...MUTATING], hasBody: true },
|
|
84
|
+
require: [A.BODY_BOUNDED, ...contract, ...rateLimit],
|
|
85
|
+
requireCsrfWithAuthenticated: true,
|
|
86
|
+
requireProvenance: provenance,
|
|
87
|
+
}, {
|
|
88
|
+
name: "mutation",
|
|
89
|
+
match: { methods: [...MUTATING] },
|
|
90
|
+
require: [...contract, ...rateLimit],
|
|
91
|
+
requireCsrfWithAuthenticated: true,
|
|
92
|
+
requireProvenance: provenance,
|
|
93
|
+
});
|
|
94
|
+
if (authSensitive || strict) {
|
|
95
|
+
rules.push({
|
|
96
|
+
name: "sensitive-read",
|
|
97
|
+
match: { methods: [...READING], classificationAtLeast: SENSITIVE },
|
|
98
|
+
require: [...authed, ...contract, ...headers],
|
|
99
|
+
requireProvenance: provenance,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// The catch-all read rule. At essential/standard its requirement bundle is empty, so it is a pure
|
|
103
|
+
// classification that simply marks reads as covered - which matters only under `unmatched: "error"`,
|
|
104
|
+
// where an unowned route would otherwise fail. At strict it demands the response + header contract.
|
|
105
|
+
rules.push({
|
|
106
|
+
name: "read",
|
|
107
|
+
match: { methods: [...READING] },
|
|
108
|
+
require: [...contract, ...headers],
|
|
109
|
+
...(strict ? { requireProvenance: provenance } : {}),
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
rules,
|
|
113
|
+
unmatched: options.unmatched ?? "ignore",
|
|
114
|
+
// A wrong import reflecting zero routes must fail, not silently pass a security gate.
|
|
115
|
+
allowEmpty: false,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../src/security/baseline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAyCpE,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,E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9B,EACD;QACE,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE;QACjC,OAAO,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC;QACpC,4BAA4B,EAAE,IAAI;QAClC,iBAAiB,EAAE,UAAU;KAC9B,CACF,CAAA;IAED,IAAI,aAAa,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,qBAAqB,EAAE,SAAS,EAAE;YAClE,OAAO,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC7C,iBAAiB,EAAE,UAAU;SAC9B,CAAC,CAAA;IACJ,CAAC;IAED,kGAAkG;IAClG,qGAAqG;IACrG,oGAAoG;IACpG,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE;QAChC,OAAO,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;QAClC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC,CAAA;IAEF,OAAO;QACL,KAAK;QACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,QAAQ;QACxC,sFAAsF;QACtF,UAAU,EAAE,KAAK;KAClB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Logger } from "./logger.js";
|
|
2
|
+
import { type ResponseResult } from "./runtime-core.js";
|
|
3
|
+
import type { CtxSet, RawContext } from "./server.js";
|
|
4
|
+
/** How much of a thrown error's own text reaches the log sink. Mirrors `Server`'s option. */
|
|
5
|
+
export type ErrorLogDetail = "full" | "message" | "none";
|
|
6
|
+
/**
|
|
7
|
+
* Render a value thrown on the bare lane. Three shapes, in the order the lane means them:
|
|
8
|
+
* - a bare `Response` is the app answering directly - passed through untouched;
|
|
9
|
+
* - a thrown `status(...)` is control flow, still plain data: rendered through the same `finalize`
|
|
10
|
+
* a RETURNED one takes, with the request's `c.set`, so it costs what the return costs;
|
|
11
|
+
* - anything else is a real fault: logged once, then a bodyless 500 (never the caller's error text).
|
|
12
|
+
*
|
|
13
|
+
* `responseSet` and `logError` are injected rather than imported so this file keeps no runtime edge
|
|
14
|
+
* back to `server.ts` (`responseSet` reaches into the context's set symbol; `logError` closes over the
|
|
15
|
+
* server's logger). Both run only on the throw path, so the closures cost nothing on the hot lane.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderBareError<T>(err: unknown, ctx: RawContext, finalize: (result: unknown, set: CtxSet, ctx: RawContext) => T, wrapResponse: (response: Response | ResponseResult) => T, responseSet: (ctx: RawContext) => CtxSet, logError: (err: unknown, ctx: RawContext) => void): T;
|
|
18
|
+
/**
|
|
19
|
+
* Write an unhandled request error to the log. An error's own text can quote the input that produced
|
|
20
|
+
* it, so how much of it reaches the sink is the app's call (`detail`). The default keeps it: a 500
|
|
21
|
+
* with no message and no stack is an incident nobody can diagnose, and the framework already ships
|
|
22
|
+
* the narrower instrument for the leak - a redacting logger with `valuePatterns`. `"none"` is there
|
|
23
|
+
* for an untrusted sink.
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitRequestErrorLog(logger: Logger, detail: ErrorLogDetail, err: unknown, ctx: RawContext): void;
|
|
26
|
+
//# sourceMappingURL=bare-error-lane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bare-error-lane.d.ts","sourceRoot":"","sources":["../../src/server/bare-error-lane.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAErD,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAA;AAExD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,KAAK,CAAC,EAC9D,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,KAAK,CAAC,EACxD,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,EACxC,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,KAAK,IAAI,GAChD,CAAC,CAKH;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,UAAU,GACd,IAAI,CAWN"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bare lane's ERROR rendering, as free functions the kernel delegates to.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this is a lane module and not methods on `Server`
|
|
5
|
+
*
|
|
6
|
+
* These are the cold half of the bare request lane: what happens when a handler (or a `derive`)
|
|
7
|
+
* throws, rather than returns. The success half stays on the class - it reads request-lifecycle
|
|
8
|
+
* state and is the async-frame-skip hot path - but the error half needs none of that class state:
|
|
9
|
+
* `renderBareError` is pure control-flow routing, and `emitRequestErrorLog` needs only the logger
|
|
10
|
+
* and the detail policy, both of which are config fixed at construction. Passing those two in keeps
|
|
11
|
+
* this file free of any runtime dependency back on `server.ts`, so there is no import cycle: the
|
|
12
|
+
* `RawContext`/`CtxSet` imports are type-only and erased (the same shape `edge.ts` already relies on).
|
|
13
|
+
*
|
|
14
|
+
* A single source of truth for the thrown-value contract matters because it is a security surface:
|
|
15
|
+
* an unhandled throw must render as a 500 with no caller-controlled body, and the amount of the
|
|
16
|
+
* error's own text that reaches the log sink is the app's `errorLogDetail` call, not an accident of
|
|
17
|
+
* which lane caught it. Both the generic bare lane and the fused body runner route here, so that
|
|
18
|
+
* decision lives in exactly one place.
|
|
19
|
+
*/
|
|
20
|
+
import { pathnameOf, plainError } from "./http.js";
|
|
21
|
+
import { isResponseResult } from "./runtime-core.js";
|
|
22
|
+
/**
|
|
23
|
+
* Render a value thrown on the bare lane. Three shapes, in the order the lane means them:
|
|
24
|
+
* - a bare `Response` is the app answering directly - passed through untouched;
|
|
25
|
+
* - a thrown `status(...)` is control flow, still plain data: rendered through the same `finalize`
|
|
26
|
+
* a RETURNED one takes, with the request's `c.set`, so it costs what the return costs;
|
|
27
|
+
* - anything else is a real fault: logged once, then a bodyless 500 (never the caller's error text).
|
|
28
|
+
*
|
|
29
|
+
* `responseSet` and `logError` are injected rather than imported so this file keeps no runtime edge
|
|
30
|
+
* back to `server.ts` (`responseSet` reaches into the context's set symbol; `logError` closes over the
|
|
31
|
+
* server's logger). Both run only on the throw path, so the closures cost nothing on the hot lane.
|
|
32
|
+
*/
|
|
33
|
+
export function renderBareError(err, ctx, finalize, wrapResponse, responseSet, logError) {
|
|
34
|
+
if (err instanceof Response)
|
|
35
|
+
return wrapResponse(err);
|
|
36
|
+
if (isResponseResult(err))
|
|
37
|
+
return finalize(err, responseSet(ctx), ctx);
|
|
38
|
+
logError(err, ctx);
|
|
39
|
+
return wrapResponse(plainError(500, "internal_error"));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Write an unhandled request error to the log. An error's own text can quote the input that produced
|
|
43
|
+
* it, so how much of it reaches the sink is the app's call (`detail`). The default keeps it: a 500
|
|
44
|
+
* with no message and no stack is an incident nobody can diagnose, and the framework already ships
|
|
45
|
+
* the narrower instrument for the leak - a redacting logger with `valuePatterns`. `"none"` is there
|
|
46
|
+
* for an untrusted sink.
|
|
47
|
+
*/
|
|
48
|
+
export function emitRequestErrorLog(logger, detail, err, ctx) {
|
|
49
|
+
logger.error("unhandled request error", {
|
|
50
|
+
method: ctx.req.method,
|
|
51
|
+
path: pathnameOf(ctx.req.url),
|
|
52
|
+
name: err instanceof Error ? err.name : "Error",
|
|
53
|
+
// `detail`, not `message`: the logger uses `message` for its own first argument, so a field of
|
|
54
|
+
// that name is silently overwritten and the thrown error's own text never reaches the sink. It
|
|
55
|
+
// survived only incidentally inside `stack`, and was lost outright for a non-Error throw.
|
|
56
|
+
...(detail === "none" ? {} : { detail: err instanceof Error ? err.message : String(err) }),
|
|
57
|
+
...(detail === "full" && err instanceof Error ? { stack: err.stack } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=bare-error-lane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bare-error-lane.js","sourceRoot":"","sources":["../../src/server/bare-error-lane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,mBAAmB,CAAA;AAMzE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAY,EACZ,GAAe,EACf,QAA8D,EAC9D,YAAwD,EACxD,WAAwC,EACxC,QAAiD;IAEjD,IAAI,GAAG,YAAY,QAAQ;QAAE,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;IACrD,IAAI,gBAAgB,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IACtE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAClB,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAA;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,MAAsB,EACtB,GAAY,EACZ,GAAe;IAEf,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;QACtC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM;QACtB,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7B,IAAI,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;QAC/C,+FAA+F;QAC/F,+FAA+F;QAC/F,0FAA0F;QAC1F,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1F,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3E,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/server/body.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface RawBodyReaders {
|
|
|
29
29
|
* overriding the route cap upward, exactly as before the transport cap existed.
|
|
30
30
|
*/
|
|
31
31
|
export declare function rawBodySourceOf<T extends BodySource>(req: T): T;
|
|
32
|
+
/**
|
|
33
|
+
* The byte cap a route that declared `bodyLimit: "unlimited"` reads under. It is a real number, not
|
|
34
|
+
* `Infinity` or a skipped check: every bounded reader keeps its single `> maxBytes` enforcement
|
|
35
|
+
* point (and its `assertByteLimit` guard) rather than growing an uncapped branch that a future
|
|
36
|
+
* caller could reach by accident. No HTTP body reaches 2^53-1 bytes, so this is unlimited in fact.
|
|
37
|
+
*/
|
|
38
|
+
export declare const UNLIMITED_BODY_BYTES: number;
|
|
32
39
|
/** Security/resource limits must be finite byte counts. Invalid values otherwise make `> maxBytes`
|
|
33
40
|
* comparisons fail open (notably for `NaN`) and can re-enable unbounded buffering. */
|
|
34
41
|
export declare function assertByteLimit(value: number, name?: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../src/server/body.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,UAAU,UAAU;IAClB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IAChD,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IACnC,KAAK,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;CAC9B;AAED,oGAAoG;AACpG,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IAChD,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IACnC,qFAAqF;IACrF,KAAK,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;IAC7B,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAE/D;AAED;sFACsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAa,GAAG,IAAI,CAItE;AAED,wBAAgB,kBAAkB,CAAC,KA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AC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE,CAAC,CA4B7E;AAED,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,eAAkC,CAAA;AAsB/D,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED,qDAAqD;AACrD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AA2KD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAmBxE"}
|
package/dist/server/body.js
CHANGED
|
@@ -17,6 +17,13 @@ import { jsonError } from "./http.js";
|
|
|
17
17
|
export function rawBodySourceOf(req) {
|
|
18
18
|
return req[RAW_BODY_READERS] ?? req;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The byte cap a route that declared `bodyLimit: "unlimited"` reads under. It is a real number, not
|
|
22
|
+
* `Infinity` or a skipped check: every bounded reader keeps its single `> maxBytes` enforcement
|
|
23
|
+
* point (and its `assertByteLimit` guard) rather than growing an uncapped branch that a future
|
|
24
|
+
* caller could reach by accident. No HTTP body reaches 2^53-1 bytes, so this is unlimited in fact.
|
|
25
|
+
*/
|
|
26
|
+
export const UNLIMITED_BODY_BYTES = Number.MAX_SAFE_INTEGER;
|
|
20
27
|
/** Security/resource limits must be finite byte counts. Invalid values otherwise make `> maxBytes`
|
|
21
28
|
* comparisons fail open (notably for `NaN`) and can re-enable unbounded buffering. */
|
|
22
29
|
export function assertByteLimit(value, name = "maxBytes") {
|
package/d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AO,UAAU,CAAA;QACnB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,QAAgB;IAC/D,CAAC;IAAC,MAAuC,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAA;AACrE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,OAAgB;IAChE,MAAM,QAAQ,GAAI,MAAuC,CAAC,aAAa,CAAC,CAAA;IACxE,iGAAiG;IACjG,oFAAoF;IACpF,IAAI,QAAQ,KAAK,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAM;IACnE,MAAM,OAAO,GAAI,MAAoD,CAAC,cAAc,CAAA;IACpF,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACvE,+FAA+F;IAC/F,iGAAiG;IACjG,6FAA6F;IAC7F,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,OAAM;IACzD,mBAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC9C,8FAA8F;IAC9F,iGAAiG;IACjG,mFAAmF;IACnF,MAAM,GAAG,GAAI,OAA8D,CAAC,gBAAgB,CAAC,CAAA;IAC7F,IAAK,MAAkB,KAAK,OAAO,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACzD,CAAC;QAAC,MAAkD,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAA;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire marker keys shared between @nifrajs/core and the @nifrajs/node adapter.
|
|
3
|
+
*
|
|
4
|
+
* Each entry names a symbol looked up with `Symbol.for(...)`, so the two packages agree ONLY by the
|
|
5
|
+
* string. A rename on one side and not the other is a silent protocol break - no type error, just a
|
|
6
|
+
* symbol that never matches and a body that stops taking the direct-write lane. This module is the
|
|
7
|
+
* single source: core defines its own symbols from these literals, and `scripts/gen-node-outcome.ts`
|
|
8
|
+
* copies the map verbatim into the adapter's generated contract, so @nifrajs/node reads the identical
|
|
9
|
+
* strings without a runtime dependency on core (the same deployment shape the generated outcome type
|
|
10
|
+
* preserves).
|
|
11
|
+
*
|
|
12
|
+
* Keep this module import-free: every core file that owns one of these symbols imports it, so a cycle
|
|
13
|
+
* here would reach most of the response path.
|
|
14
|
+
*/
|
|
15
|
+
export declare const NODE_BRIDGE_MARKER_KEYS: {
|
|
16
|
+
/** A `Response` carrying its already-serialized bytes, so the Node writer emits them without a drain. */
|
|
17
|
+
readonly responseBody: "nifra.response.body";
|
|
18
|
+
/** A plain-data response-result carrier the node lane renders without building a `Response`. */
|
|
19
|
+
readonly responseResult: "nifra.response.result";
|
|
20
|
+
/** Proof that a header record's names are already the lowercase wire spelling. */
|
|
21
|
+
readonly lowercaseHeaderKeys: "nifra.headers.lowercase";
|
|
22
|
+
/** A mounted handler's node-direct resolver entry point. */
|
|
23
|
+
readonly resolveNodeMount: "@nifrajs/core/resolve-node-mount";
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=bridge-markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-markers.d.ts","sourceRoot":"","sources":["../../src/server/bridge-markers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB;IAClC,yGAAyG;;IAEzG,gGAAgG;;IAEhG,kFAAkF;;IAElF,4DAA4D;;CAEpD,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire marker keys shared between @nifrajs/core and the @nifrajs/node adapter.
|
|
3
|
+
*
|
|
4
|
+
* Each entry names a symbol looked up with `Symbol.for(...)`, so the two packages agree ONLY by the
|
|
5
|
+
* string. A rename on one side and not the other is a silent protocol break - no type error, just a
|
|
6
|
+
* symbol that never matches and a body that stops taking the direct-write lane. This module is the
|
|
7
|
+
* single source: core defines its own symbols from these literals, and `scripts/gen-node-outcome.ts`
|
|
8
|
+
* copies the map verbatim into the adapter's generated contract, so @nifrajs/node reads the identical
|
|
9
|
+
* strings without a runtime dependency on core (the same deployment shape the generated outcome type
|
|
10
|
+
* preserves).
|
|
11
|
+
*
|
|
12
|
+
* Keep this module import-free: every core file that owns one of these symbols imports it, so a cycle
|
|
13
|
+
* here would reach most of the response path.
|
|
14
|
+
*/
|
|
15
|
+
export const NODE_BRIDGE_MARKER_KEYS = {
|
|
16
|
+
/** A `Response` carrying its already-serialized bytes, so the Node writer emits them without a drain. */
|
|
17
|
+
responseBody: "nifra.response.body",
|
|
18
|
+
/** A plain-data response-result carrier the node lane renders without building a `Response`. */
|
|
19
|
+
responseResult: "nifra.response.result",
|
|
20
|
+
/** Proof that a header record's names are already the lowercase wire spelling. */
|
|
21
|
+
lowercaseHeaderKeys: "nifra.headers.lowercase",
|
|
22
|
+
/** A mounted handler's node-direct resolver entry point. */
|
|
23
|
+
resolveNodeMount: "@nifrajs/core/resolve-node-mount",
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=bridge-markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-markers.js","sourceRoot":"","sources":["../../src/server/bridge-markers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,yGAAyG;IACzG,YAAY,EAAE,qBAAqB;IACnC,gGAAgG;IAChG,cAAc,EAAE,uBAAuB;IACvC,kFAAkF;IAClF,mBAAmB,EAAE,yBAAyB;IAC9C,4DAA4D;IAC5D,gBAAgB,EAAE,kCAAkC;CAC5C,CAAA"}
|
package/dist/server/context.d.ts
CHANGED
|
@@ -50,7 +50,12 @@ export type Params<Path extends string> = Prettify<RawParams<Path>>;
|
|
|
50
50
|
export interface RouteSchema {
|
|
51
51
|
/** Transport body cap for this route. Defaults to the server's maxBodyBytes. Use a finite
|
|
52
52
|
* smaller/larger limit for a specific endpoint. The 'unlimited' value is an explicit
|
|
53
|
-
* streaming/upload exemption and requires a non-empty bodyLimitReason for auditability.
|
|
53
|
+
* streaming/upload exemption and requires a non-empty bodyLimitReason for auditability.
|
|
54
|
+
*
|
|
55
|
+
* 'unlimited' is legal only for schema-less streaming/upload routes. It is rejected with `body` or
|
|
56
|
+
* `idempotency`, because those lanes buffer the body before user code can apply a protocol-specific
|
|
57
|
+
* bound. Read an unlimited route from `c.req.body` as a stream and bound it by the protocol it speaks;
|
|
58
|
+
* `nifra.body-bounded` is deliberately NOT published for an unlimited route. */
|
|
54
59
|
readonly bodyLimit?: number | "unlimited";
|
|
55
60
|
/** Required explanation when bodyLimit is 'unlimited' (for example, a streaming upload is
|
|
56
61
|
* bounded by an upstream object-store protocol). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/server/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,oGAAoG;IAC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;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAChE;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACpE;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,KAAK,QAAQ,CAAA;IACxE,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,KAAK,QAAQ,CAAA;CACxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-case.d.ts","sourceRoot":"","sources":["../../src/server/header-case.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"header-case.d.ts","sourceRoot":"","sources":["../../src/server/header-case.ts"],"names":[],"mappings":"AA6BA,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAMzF;AAED,+FAA+F;AAC/F,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,GAAG,IAAI,CAEhG;AAED,0FAA0F;AAC1F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAE7F"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NODE_BRIDGE_MARKER_KEYS } from "./bridge-markers.js";
|
|
1
2
|
/**
|
|
2
3
|
* The all-lowercase header-name proof: one answer, computed once per request, read by everyone who
|
|
3
4
|
* would otherwise re-derive it.
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
* Declared with `Symbol.for` so the `@nifrajs/node` adapter can read it by key rather than importing
|
|
24
25
|
* across the package boundary - the same cross-package convention as the body and result marks.
|
|
25
26
|
*/
|
|
26
|
-
const LOWERCASE_HEADER_KEYS = Symbol.for(
|
|
27
|
+
const LOWERCASE_HEADER_KEYS = Symbol.for(NODE_BRIDGE_MARKER_KEYS.lowercaseHeaderKeys);
|
|
27
28
|
/** True when the name contains an ASCII `A`-`Z`, i.e. is not already the wire spelling. */
|
|
28
29
|
export function hasUpperAscii(name) {
|
|
29
30
|
for (let i = 0; i < name.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-case.js","sourceRoot":"","sources":["../../src/server/header-case.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"header-case.js","sourceRoot":"","sources":["../../src/server/header-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAA;AAErF,2FAA2F;AAC3F,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE;YAAE,OAAO,IAAI,CAAA;IAC3C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,sBAAsB,CAAC,MAAyC;IAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC;YAAE,OAAO,KAAK,CAAA;IACpD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,uBAAuB,CAAC,MAAkD;IACxF,CAAC;IAAC,MAAkC,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAA;AACpE,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,0BAA0B,CAAC,MAAyC;IAClF,OAAQ,MAAkC,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAA;AAC5E,CAAC"}
|
package/dist/server/http.d.ts
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* the server can reuse them without pulling a lane's feature code into the base bundle.
|
|
2
|
+
* HTTP helpers shared by the kernel and the opt-in request lanes (idempotency, effect-ledger). Kept
|
|
3
|
+
* in a leaf module (runtime-core aside, itself a leaf) so a lane can reuse them without importing the
|
|
4
|
+
* server, and so the server can reuse them without pulling a lane's feature code into the base bundle.
|
|
5
5
|
*/
|
|
6
|
+
import { type ResponseResult } from "./runtime-core.js";
|
|
7
|
+
/**
|
|
8
|
+
* Is `value` a destination that stays on this origin?
|
|
9
|
+
*
|
|
10
|
+
* True only for an absolute path: one leading `/`, never `//` (protocol-relative → another origin),
|
|
11
|
+
* and free of any character a URL parser turns into an origin escape. A leading `/` alone is not
|
|
12
|
+
* enough: under a special scheme `\` parses as `/`, and tab/CR/LF are STRIPPED before parsing, so
|
|
13
|
+
* `/\evil.example` and `/<TAB>/evil.example` both resolve to the external host `evil.example` while
|
|
14
|
+
* passing a `//` test. Rejecting CR/LF here also keeps a validated destination out of the
|
|
15
|
+
* response-splitting sink it usually flows into.
|
|
16
|
+
*
|
|
17
|
+
* One implementation, because every caller is the same open-redirect gate: `redirect()` in
|
|
18
|
+
* `@nifrajs/web`, the `redirectTo` of the `@nifrajs/auth` and `@nifrajs/better-auth` guards. Three
|
|
19
|
+
* copies of a security predicate is three chances for one of them to be hardened alone.
|
|
20
|
+
*
|
|
21
|
+
* It answers about a PATH, not a URL: an absolute `https://this.host/x` is false even for the
|
|
22
|
+
* current origin, because the whole point is that the value never got to name a host.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isSameOriginPath(value: string): boolean;
|
|
6
25
|
/** A uniform JSON error envelope: `{ ok: false, error }` at the given status. */
|
|
7
26
|
export declare function jsonError(status: number, error: string, headers?: Record<string, string>): Response;
|
|
27
|
+
/**
|
|
28
|
+
* The same envelope as {@link jsonError}, as plain data rather than a built `Response`.
|
|
29
|
+
*
|
|
30
|
+
* This is what the framework's own renders - 404, 405, 422, the body caps, the timeouts, 500 - answer
|
|
31
|
+
* with wherever the value flows into a lane's response wrapper, so an error costs what a handler's
|
|
32
|
+
* plain return costs. Building the `Response` was measured as the dominant cost of answering early
|
|
33
|
+
* (see `PlainRender`), and on the Node lane an error `Response` is worse still: it is untagged, so
|
|
34
|
+
* the adapter cannot recognize its body and drains it through a Web stream, which is also why an
|
|
35
|
+
* error answered chunked while an ordinary return carries a `content-length`.
|
|
36
|
+
*
|
|
37
|
+
* `jsonError` stays for the callers that genuinely need a `Response` object (mount bridges, the
|
|
38
|
+
* lanes' own typed returns).
|
|
39
|
+
*/
|
|
40
|
+
export declare function plainError(status: number, error: string, headers?: Record<string, string>): ResponseResult;
|
|
8
41
|
export interface UrlParts {
|
|
9
42
|
readonly pathname: string;
|
|
10
43
|
readonly search: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,mBAAmB,CAAA;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CASvD;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,QAAQ,CAKV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,cAAc,CAEhB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAMD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAwBhD;AAKD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAc9C"}
|