@dads-framework/http 0.0.0-stage → 0.2.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.md +21 -0
- package/README.md +295 -2
- package/dist/http.tsbuildinfo +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/create-http-app.d.ts +108 -0
- package/dist/lib/create-http-app.d.ts.map +1 -0
- package/dist/lib/create-http-app.js +181 -0
- package/dist/lib/create-http-app.js.map +1 -0
- package/dist/lib/http-errors.d.ts +52 -0
- package/dist/lib/http-errors.d.ts.map +1 -0
- package/dist/lib/http-errors.js +66 -0
- package/dist/lib/http-errors.js.map +1 -0
- package/dist/lib/mcp/mcp-tool.d.ts +94 -0
- package/dist/lib/mcp/mcp-tool.d.ts.map +1 -0
- package/dist/lib/mcp/mcp-tool.js +11 -0
- package/dist/lib/mcp/mcp-tool.js.map +1 -0
- package/dist/lib/object-value.d.ts +3 -0
- package/dist/lib/object-value.d.ts.map +1 -0
- package/dist/lib/object-value.js +5 -0
- package/dist/lib/object-value.js.map +1 -0
- package/dist/lib/openapi/build-document.d.ts +27 -0
- package/dist/lib/openapi/build-document.d.ts.map +1 -0
- package/dist/lib/openapi/build-document.js +192 -0
- package/dist/lib/openapi/build-document.js.map +1 -0
- package/dist/lib/openapi/logic/add-discriminators.d.ts +16 -0
- package/dist/lib/openapi/logic/add-discriminators.d.ts.map +1 -0
- package/dist/lib/openapi/logic/add-discriminators.js +235 -0
- package/dist/lib/openapi/logic/add-discriminators.js.map +1 -0
- package/dist/lib/openapi/logic/by-code-point.d.ts +2 -0
- package/dist/lib/openapi/logic/by-code-point.d.ts.map +1 -0
- package/dist/lib/openapi/logic/by-code-point.js +6 -0
- package/dist/lib/openapi/logic/by-code-point.js.map +1 -0
- package/dist/lib/openapi/logic/capitalize-initial.d.ts +2 -0
- package/dist/lib/openapi/logic/capitalize-initial.d.ts.map +1 -0
- package/dist/lib/openapi/logic/capitalize-initial.js +4 -0
- package/dist/lib/openapi/logic/capitalize-initial.js.map +1 -0
- package/dist/lib/openapi/logic/document-record.d.ts +5 -0
- package/dist/lib/openapi/logic/document-record.d.ts.map +1 -0
- package/dist/lib/openapi/logic/document-record.js +14 -0
- package/dist/lib/openapi/logic/document-record.js.map +1 -0
- package/dist/lib/openapi/logic/list-order.d.ts +23 -0
- package/dist/lib/openapi/logic/list-order.d.ts.map +1 -0
- package/dist/lib/openapi/logic/list-order.js +102 -0
- package/dist/lib/openapi/logic/list-order.js.map +1 -0
- package/dist/lib/openapi/logic/open-response-objects.d.ts +14 -0
- package/dist/lib/openapi/logic/open-response-objects.d.ts.map +1 -0
- package/dist/lib/openapi/logic/open-response-objects.js +130 -0
- package/dist/lib/openapi/logic/open-response-objects.js.map +1 -0
- package/dist/lib/openapi/logic/openapi-parts.d.ts +37 -0
- package/dist/lib/openapi/logic/openapi-parts.d.ts.map +1 -0
- package/dist/lib/openapi/logic/openapi-parts.js +243 -0
- package/dist/lib/openapi/logic/openapi-parts.js.map +1 -0
- package/dist/lib/openapi/logic/schema-components.d.ts +5 -0
- package/dist/lib/openapi/logic/schema-components.d.ts.map +1 -0
- package/dist/lib/openapi/logic/schema-components.js +47 -0
- package/dist/lib/openapi/logic/schema-components.js.map +1 -0
- package/dist/lib/request-log/authorization-warning-faults.d.ts +30 -0
- package/dist/lib/request-log/authorization-warning-faults.d.ts.map +1 -0
- package/dist/lib/request-log/authorization-warning-faults.js +35 -0
- package/dist/lib/request-log/authorization-warning-faults.js.map +1 -0
- package/dist/lib/request-log/capture-request-record.d.ts +50 -0
- package/dist/lib/request-log/capture-request-record.d.ts.map +1 -0
- package/dist/lib/request-log/capture-request-record.js +132 -0
- package/dist/lib/request-log/capture-request-record.js.map +1 -0
- package/dist/lib/request-log/request-log-sink.d.ts +31 -0
- package/dist/lib/request-log/request-log-sink.d.ts.map +1 -0
- package/dist/lib/request-log/request-log-sink.js +26 -0
- package/dist/lib/request-log/request-log-sink.js.map +1 -0
- package/dist/lib/request-log/request-outcome.d.ts +53 -0
- package/dist/lib/request-log/request-outcome.d.ts.map +1 -0
- package/dist/lib/request-log/request-outcome.js +96 -0
- package/dist/lib/request-log/request-outcome.js.map +1 -0
- package/dist/lib/request-log/request-record.d.ts +114 -0
- package/dist/lib/request-log/request-record.d.ts.map +1 -0
- package/dist/lib/request-log/request-record.js +231 -0
- package/dist/lib/request-log/request-record.js.map +1 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.d.ts +8 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.d.ts.map +1 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.js +15 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.js.map +1 -0
- package/dist/lib/request-pipeline/carry-audit-actor.d.ts +71 -0
- package/dist/lib/request-pipeline/carry-audit-actor.d.ts.map +1 -0
- package/dist/lib/request-pipeline/carry-audit-actor.js +79 -0
- package/dist/lib/request-pipeline/carry-audit-actor.js.map +1 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.d.ts +4 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.d.ts.map +1 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.js +21 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.js.map +1 -0
- package/dist/lib/request-pipeline/enforce-access.d.ts +146 -0
- package/dist/lib/request-pipeline/enforce-access.d.ts.map +1 -0
- package/dist/lib/request-pipeline/enforce-access.js +238 -0
- package/dist/lib/request-pipeline/enforce-access.js.map +1 -0
- package/dist/lib/request-pipeline/enforce-scope.d.ts +23 -0
- package/dist/lib/request-pipeline/enforce-scope.d.ts.map +1 -0
- package/dist/lib/request-pipeline/enforce-scope.js +58 -0
- package/dist/lib/request-pipeline/enforce-scope.js.map +1 -0
- package/dist/lib/request-pipeline/envelope.d.ts +17 -0
- package/dist/lib/request-pipeline/envelope.d.ts.map +1 -0
- package/dist/lib/request-pipeline/envelope.js +4 -0
- package/dist/lib/request-pipeline/envelope.js.map +1 -0
- package/dist/lib/request-pipeline/error-handler.d.ts +14 -0
- package/dist/lib/request-pipeline/error-handler.d.ts.map +1 -0
- package/dist/lib/request-pipeline/error-handler.js +138 -0
- package/dist/lib/request-pipeline/error-handler.js.map +1 -0
- package/dist/lib/request-pipeline/feature-state-preview.d.ts +79 -0
- package/dist/lib/request-pipeline/feature-state-preview.d.ts.map +1 -0
- package/dist/lib/request-pipeline/feature-state-preview.js +77 -0
- package/dist/lib/request-pipeline/feature-state-preview.js.map +1 -0
- package/dist/lib/request-pipeline/feature-state.d.ts +70 -0
- package/dist/lib/request-pipeline/feature-state.d.ts.map +1 -0
- package/dist/lib/request-pipeline/feature-state.js +46 -0
- package/dist/lib/request-pipeline/feature-state.js.map +1 -0
- package/dist/lib/request-pipeline/logic/is-write-method.d.ts +2 -0
- package/dist/lib/request-pipeline/logic/is-write-method.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/is-write-method.js +7 -0
- package/dist/lib/request-pipeline/logic/is-write-method.js.map +1 -0
- package/dist/lib/request-pipeline/logic/read-request-source.d.ts +19 -0
- package/dist/lib/request-pipeline/logic/read-request-source.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/read-request-source.js +40 -0
- package/dist/lib/request-pipeline/logic/read-request-source.js.map +1 -0
- package/dist/lib/request-pipeline/logic/single-request-header.d.ts +3 -0
- package/dist/lib/request-pipeline/logic/single-request-header.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/single-request-header.js +16 -0
- package/dist/lib/request-pipeline/logic/single-request-header.js.map +1 -0
- package/dist/lib/request-pipeline/machine-credential-access.d.ts +19 -0
- package/dist/lib/request-pipeline/machine-credential-access.d.ts.map +1 -0
- package/dist/lib/request-pipeline/machine-credential-access.js +28 -0
- package/dist/lib/request-pipeline/machine-credential-access.js.map +1 -0
- package/dist/lib/request-pipeline/rate-limit.d.ts +15 -0
- package/dist/lib/request-pipeline/rate-limit.d.ts.map +1 -0
- package/dist/lib/request-pipeline/rate-limit.js +40 -0
- package/dist/lib/request-pipeline/rate-limit.js.map +1 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.d.ts +19 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.d.ts.map +1 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.js +26 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.js.map +1 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.d.ts +16 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.d.ts.map +1 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.js +33 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.js.map +1 -0
- package/dist/lib/request-pipeline/register-routes.d.ts +50 -0
- package/dist/lib/request-pipeline/register-routes.d.ts.map +1 -0
- package/dist/lib/request-pipeline/register-routes.js +217 -0
- package/dist/lib/request-pipeline/register-routes.js.map +1 -0
- package/dist/lib/request-pipeline/request-id.d.ts +22 -0
- package/dist/lib/request-pipeline/request-id.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-id.js +26 -0
- package/dist/lib/request-pipeline/request-id.js.map +1 -0
- package/dist/lib/request-pipeline/request-language-response.d.ts +14 -0
- package/dist/lib/request-pipeline/request-language-response.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-language-response.js +47 -0
- package/dist/lib/request-pipeline/request-language-response.js.map +1 -0
- package/dist/lib/request-pipeline/request-locale.d.ts +38 -0
- package/dist/lib/request-pipeline/request-locale.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-locale.js +102 -0
- package/dist/lib/request-pipeline/request-locale.js.map +1 -0
- package/dist/lib/request-pipeline/request-origin.d.ts +17 -0
- package/dist/lib/request-pipeline/request-origin.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-origin.js +38 -0
- package/dist/lib/request-pipeline/request-origin.js.map +1 -0
- package/dist/lib/request-pipeline/request-trace.d.ts +10 -0
- package/dist/lib/request-pipeline/request-trace.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-trace.js +24 -0
- package/dist/lib/request-pipeline/request-trace.js.map +1 -0
- package/dist/lib/request-pipeline/route-rate-limit.d.ts +19 -0
- package/dist/lib/request-pipeline/route-rate-limit.d.ts.map +1 -0
- package/dist/lib/request-pipeline/route-rate-limit.js +32 -0
- package/dist/lib/request-pipeline/route-rate-limit.js.map +1 -0
- package/dist/lib/request-pipeline/run-route.d.ts +9 -0
- package/dist/lib/request-pipeline/run-route.d.ts.map +1 -0
- package/dist/lib/request-pipeline/run-route.js +42 -0
- package/dist/lib/request-pipeline/run-route.js.map +1 -0
- package/dist/lib/request-pipeline/with-deadline.d.ts +12 -0
- package/dist/lib/request-pipeline/with-deadline.d.ts.map +1 -0
- package/dist/lib/request-pipeline/with-deadline.js +55 -0
- package/dist/lib/request-pipeline/with-deadline.js.map +1 -0
- package/dist/lib/route/access.d.ts +143 -0
- package/dist/lib/route/access.d.ts.map +1 -0
- package/dist/lib/route/access.js +97 -0
- package/dist/lib/route/access.js.map +1 -0
- package/dist/lib/route/capabilities.d.ts +100 -0
- package/dist/lib/route/capabilities.d.ts.map +1 -0
- package/dist/lib/route/capabilities.js +42 -0
- package/dist/lib/route/capabilities.js.map +1 -0
- package/dist/lib/route/define-raw-route.d.ts +81 -0
- package/dist/lib/route/define-raw-route.d.ts.map +1 -0
- package/dist/lib/route/define-raw-route.js +5 -0
- package/dist/lib/route/define-raw-route.js.map +1 -0
- package/dist/lib/route/delete-route.d.ts +26 -0
- package/dist/lib/route/delete-route.d.ts.map +1 -0
- package/dist/lib/route/delete-route.js +6 -0
- package/dist/lib/route/delete-route.js.map +1 -0
- package/dist/lib/route/get-route.d.ts +43 -0
- package/dist/lib/route/get-route.d.ts.map +1 -0
- package/dist/lib/route/get-route.js +18 -0
- package/dist/lib/route/get-route.js.map +1 -0
- package/dist/lib/route/list-result.d.ts +11 -0
- package/dist/lib/route/list-result.d.ts.map +1 -0
- package/dist/lib/route/list-result.js +8 -0
- package/dist/lib/route/list-result.js.map +1 -0
- package/dist/lib/route/list-route.d.ts +60 -0
- package/dist/lib/route/list-route.d.ts.map +1 -0
- package/dist/lib/route/list-route.js +68 -0
- package/dist/lib/route/list-route.js.map +1 -0
- package/dist/lib/route/patch-route.d.ts +27 -0
- package/dist/lib/route/patch-route.d.ts.map +1 -0
- package/dist/lib/route/patch-route.js +8 -0
- package/dist/lib/route/patch-route.js.map +1 -0
- package/dist/lib/route/post-no-content-route.d.ts +18 -0
- package/dist/lib/route/post-no-content-route.d.ts.map +1 -0
- package/dist/lib/route/post-no-content-route.js +8 -0
- package/dist/lib/route/post-no-content-route.js.map +1 -0
- package/dist/lib/route/post-route.d.ts +34 -0
- package/dist/lib/route/post-route.d.ts.map +1 -0
- package/dist/lib/route/post-route.js +23 -0
- package/dist/lib/route/post-route.js.map +1 -0
- package/dist/lib/route/route-definition.d.ts +224 -0
- package/dist/lib/route/route-definition.d.ts.map +1 -0
- package/dist/lib/route/route-definition.js +32 -0
- package/dist/lib/route/route-definition.js.map +1 -0
- package/dist/lib/route/route-execution.d.ts +47 -0
- package/dist/lib/route/route-execution.d.ts.map +1 -0
- package/dist/lib/route/route-execution.js +162 -0
- package/dist/lib/route/route-execution.js.map +1 -0
- package/dist/lib/route/route-group.d.ts +21 -0
- package/dist/lib/route/route-group.d.ts.map +1 -0
- package/dist/lib/route/route-group.js +18 -0
- package/dist/lib/route/route-group.js.map +1 -0
- package/dist/lib/route/route-guards.test-support.d.ts +2 -0
- package/dist/lib/route/route-guards.test-support.d.ts.map +1 -0
- package/dist/lib/route/route-guards.test-support.js +2 -0
- package/dist/lib/route/route-guards.test-support.js.map +1 -0
- package/dist/lib/route/sse-route.d.ts +54 -0
- package/dist/lib/route/sse-route.d.ts.map +1 -0
- package/dist/lib/route/sse-route.js +63 -0
- package/dist/lib/route/sse-route.js.map +1 -0
- package/dist/lib/route/web-socket-route.d.ts +45 -0
- package/dist/lib/route/web-socket-route.d.ts.map +1 -0
- package/dist/lib/route/web-socket-route.js +180 -0
- package/dist/lib/route/web-socket-route.js.map +1 -0
- package/dist/lib/route-catalog/route-catalog-parts.d.ts +27 -0
- package/dist/lib/route-catalog/route-catalog-parts.d.ts.map +1 -0
- package/dist/lib/route-catalog/route-catalog-parts.js +87 -0
- package/dist/lib/route-catalog/route-catalog-parts.js.map +1 -0
- package/dist/protocol-mounts/index.d.ts +19 -0
- package/dist/protocol-mounts/index.d.ts.map +1 -0
- package/dist/protocol-mounts/index.js +19 -0
- package/dist/protocol-mounts/index.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.d.ts +54 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.js +53 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.d.ts +31 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.js +179 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.d.ts +68 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.js +201 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.d.ts +18 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.js +34 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.js.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.d.ts +57 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.js +100 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.js.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.d.ts +14 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.js +60 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.js.map +1 -0
- package/dist/testing/build-test-app.d.ts +47 -0
- package/dist/testing/build-test-app.d.ts.map +1 -0
- package/dist/testing/build-test-app.js +79 -0
- package/dist/testing/build-test-app.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/parse-inject-response.d.ts +32 -0
- package/dist/testing/parse-inject-response.d.ts.map +1 -0
- package/dist/testing/parse-inject-response.js +39 -0
- package/dist/testing/parse-inject-response.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRateLimiter } from "../../../index.js";
|
|
2
|
+
import { toWebRequest } from "./to-web-request.js";
|
|
3
|
+
function pathOf(url) {
|
|
4
|
+
const path = url.split("?")[0] ?? url;
|
|
5
|
+
return path.length > 1 ? path.replace(/\/+$/u, "") : path;
|
|
6
|
+
}
|
|
7
|
+
/** Spends the caller's budget on a limited path: seconds to wait, or null when allowed. */
|
|
8
|
+
function rateLimitedFor(limits, request) {
|
|
9
|
+
const path = pathOf(request.url);
|
|
10
|
+
const matched = limits.find(({ limit }) => limit.method === request.method && limit.path === path);
|
|
11
|
+
if (matched === undefined)
|
|
12
|
+
return null;
|
|
13
|
+
const verdict = matched.limiter.consume(`${matched.limit.method} ${matched.limit.path}`, request.ip);
|
|
14
|
+
return verdict.allowed ? null : verdict.retryAfterSeconds;
|
|
15
|
+
}
|
|
16
|
+
async function sendWebResponse(reply, response, extraSetCookies) {
|
|
17
|
+
void reply.status(response.status);
|
|
18
|
+
response.headers.forEach((value, key) => {
|
|
19
|
+
void reply.header(key, value);
|
|
20
|
+
});
|
|
21
|
+
appendSetCookies(reply, extraSetCookies);
|
|
22
|
+
const payload = Buffer.from(await response.arrayBuffer());
|
|
23
|
+
await reply.send(payload.length > 0 ? payload : undefined);
|
|
24
|
+
}
|
|
25
|
+
function appendSetCookies(reply, extraSetCookies) {
|
|
26
|
+
if (extraSetCookies.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
const existing = reply.getHeader("set-cookie");
|
|
29
|
+
const current = existing === undefined
|
|
30
|
+
? []
|
|
31
|
+
: Array.isArray(existing)
|
|
32
|
+
? existing.map(String)
|
|
33
|
+
: [String(existing)];
|
|
34
|
+
void reply.header("set-cookie", [...current, ...extraSetCookies]);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mounts a fetch-style handler (Better Auth's, for one) on a Fastify scope.
|
|
38
|
+
* Every content type arrives as raw bytes, the request crosses to a WHATWG
|
|
39
|
+
* `Request` whose clones never share a stream (`to-web-request.ts`), and the
|
|
40
|
+
* handler's `Response` is copied back — status, headers, body. Register it
|
|
41
|
+
* with a literal prefix so the protocol-mount wall can read it
|
|
42
|
+
* (docs/architecture/http-edge.md#protocol-mounts).
|
|
43
|
+
*/
|
|
44
|
+
export function mountFetchHandler(fetchHandler, options = {}) {
|
|
45
|
+
return (scope, _opts, done) => {
|
|
46
|
+
scope.removeAllContentTypeParsers();
|
|
47
|
+
scope.addContentTypeParser("*", { parseAs: "buffer" }, (_request, body, parserDone) => {
|
|
48
|
+
parserDone(null, body);
|
|
49
|
+
});
|
|
50
|
+
const rateLimits = (options.rateLimits ?? []).map((limit) => ({
|
|
51
|
+
limit,
|
|
52
|
+
limiter: createRateLimiter({ perMinute: limit.perMinute }, Date.now),
|
|
53
|
+
}));
|
|
54
|
+
const handler = async (request, reply) => {
|
|
55
|
+
const retryAfterSeconds = rateLimitedFor(rateLimits, request);
|
|
56
|
+
if (retryAfterSeconds !== null) {
|
|
57
|
+
await reply
|
|
58
|
+
.status(429)
|
|
59
|
+
.header("retry-after", String(retryAfterSeconds))
|
|
60
|
+
.send({
|
|
61
|
+
error: {
|
|
62
|
+
code: "TOO_MANY_REQUESTS",
|
|
63
|
+
message: "Rate limit exceeded — retry after the indicated delay",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Stamped before the translation, so the request's clones carry it too.
|
|
69
|
+
const webRequest = toWebRequest(options.forwardRequestIdAs === undefined
|
|
70
|
+
? request
|
|
71
|
+
: {
|
|
72
|
+
method: request.method,
|
|
73
|
+
url: request.url,
|
|
74
|
+
body: request.body,
|
|
75
|
+
headers: {
|
|
76
|
+
...request.headers,
|
|
77
|
+
[options.forwardRequestIdAs]: request.id,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const response = await fetchHandler.handler(webRequest);
|
|
81
|
+
const extraSetCookies = options.extraSetCookies?.({
|
|
82
|
+
request: webRequest,
|
|
83
|
+
response,
|
|
84
|
+
incoming: request,
|
|
85
|
+
}) ?? [];
|
|
86
|
+
await sendWebResponse(reply, response, extraSetCookies);
|
|
87
|
+
};
|
|
88
|
+
const bodyLimit = options.bodyLimitBytes === undefined
|
|
89
|
+
? {}
|
|
90
|
+
: { bodyLimit: options.bodyLimitBytes };
|
|
91
|
+
const urls = options.servePrefixRoot === true ? ["/", "/*"] : ["/*"];
|
|
92
|
+
const method = [...(options.methods ?? ["GET", "POST"])];
|
|
93
|
+
const explicitHead = options.methods === undefined ? {} : { exposeHeadRoute: false };
|
|
94
|
+
for (const url of urls) {
|
|
95
|
+
scope.route({ method, url, ...bodyLimit, ...explicitHead, handler });
|
|
96
|
+
}
|
|
97
|
+
done();
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=mount-fetch-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-fetch-handler.js","sourceRoot":"","sources":["../../../../src/protoc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CAAC,CAAC;YACxD,MAAM,eAAe,GACnB,OAAO,CAAC,eAAe,EAAE,CAAC;gBACxB,OAAO,EAAE,UAAU;gBACnB,QAAQ;gBACR,QAAQ,EAAE,OAAO;aAClB,CAAC,IAAI,EAAE,CAAC;YACX,MAAM,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC1D,CAAC,CAAC;QACF,MAAM,SAAS,GACb,OAAO,CAAC,cAAc,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACzD,MAAM,YAAY,GAChB,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAClE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastify request → WHATWG `Request`, for the protocol mounts whose vendor
|
|
3
|
+
* handler speaks fetch (Better Auth, `mount-better-auth.ts`).
|
|
4
|
+
*/
|
|
5
|
+
/** The slice of an incoming fastify request this translation reads. */
|
|
6
|
+
export type IncomingProtocolRequest = {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly url: string;
|
|
9
|
+
readonly headers: Readonly<Record<string, string | string[] | undefined>>;
|
|
10
|
+
/** Raw bytes — the mount parses every content type as a buffer. */
|
|
11
|
+
readonly body: unknown;
|
|
12
|
+
};
|
|
13
|
+
export declare function toWebRequest(request: IncomingProtocolRequest): Request;
|
|
14
|
+
//# sourceMappingURL=to-web-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-web-request.d.ts","sourceRoot":"","sources":["../../../../src/protocol-mounts/lib/protocol-mount/to-web-request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAC1E,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AA8CF,wBAAgB,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAetE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastify request → WHATWG `Request`, for the protocol mounts whose vendor
|
|
3
|
+
* handler speaks fetch (Better Auth, `mount-better-auth.ts`).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A request whose clones re-read the same bytes instead of sharing a stream.
|
|
7
|
+
*
|
|
8
|
+
* Node 22 bundles undici 6.21, whose `cloneBody(instance, body)` tees the
|
|
9
|
+
* body, leaves branch one on the ORIGINAL request, hands branch two to the
|
|
10
|
+
* clone, and registers branch ONE in a `FinalizationRegistry` keyed on the
|
|
11
|
+
* clone. Better Call clones the request to parse its body and drops that
|
|
12
|
+
* clone; Better Auth then clones the original again on the sign-up and
|
|
13
|
+
* sign-in paths, to pass the caller's request to `sendVerificationEmail`. If a
|
|
14
|
+
* collection lands between the two, the registry cancels the LIVE request's
|
|
15
|
+
* own body stream, the second clone throws `TypeError: unusable`, and the
|
|
16
|
+
* route answers 500. Collection timing is the entire trigger — which is how a
|
|
17
|
+
* green suite mass-fails under load and passes on a re-run. undici 7 moved
|
|
18
|
+
* that registration onto `Response` alone; Node 22 does not carry the fix.
|
|
19
|
+
*
|
|
20
|
+
* The mount has already buffered the whole body, so a clone never needs to
|
|
21
|
+
* share a stream with anybody: it re-reads the same immutable bytes. No tee,
|
|
22
|
+
* nothing registered, nothing for a collector to cancel.
|
|
23
|
+
*/
|
|
24
|
+
class BufferedProtocolRequest extends Request {
|
|
25
|
+
#url;
|
|
26
|
+
#init;
|
|
27
|
+
constructor(url, init) {
|
|
28
|
+
super(url, init);
|
|
29
|
+
this.#url = url;
|
|
30
|
+
this.#init = init;
|
|
31
|
+
}
|
|
32
|
+
clone() {
|
|
33
|
+
return new BufferedProtocolRequest(this.#url, this.#init);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function toWebHeaders(request) {
|
|
37
|
+
const headers = new Headers();
|
|
38
|
+
for (const [name, value] of Object.entries(request.headers)) {
|
|
39
|
+
if (typeof value === "string")
|
|
40
|
+
headers.append(name, value);
|
|
41
|
+
else if (Array.isArray(value))
|
|
42
|
+
for (const item of value)
|
|
43
|
+
headers.append(name, item);
|
|
44
|
+
}
|
|
45
|
+
return headers;
|
|
46
|
+
}
|
|
47
|
+
export function toWebRequest(request) {
|
|
48
|
+
const host = request.headers["host"];
|
|
49
|
+
const url = new URL(request.url, `http://${typeof host === "string" ? host : "localhost"}`);
|
|
50
|
+
const hasBody = request.method !== "GET" && request.method !== "HEAD";
|
|
51
|
+
const body = Buffer.isBuffer(request.body)
|
|
52
|
+
? new Uint8Array(request.body)
|
|
53
|
+
: undefined;
|
|
54
|
+
return new BufferedProtocolRequest(url, {
|
|
55
|
+
method: request.method,
|
|
56
|
+
headers: toWebHeaders(request),
|
|
57
|
+
...(hasBody && body ? { body } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=to-web-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-web-request.js","sourceRoot":"","sources":["../../../../src/protocol-mounts/lib/protocol-mount/to-web-request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,uBAAwB,SAAQ,OAAO;IAClC,IAAI,CAAM;IACV,KAAK,CAAc;IAE5B,YAAY,GAAQ,EAAE,IAAiB;QACrC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAEQ,KAAK;QACZ,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,SAAS,YAAY,CAAC,OAAgC;IACpD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACtD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgC;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,OAAO,CAAC,GAAG,EACX,UAAU,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAC1D,CAAC;IACF,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC;IACtE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QACxC,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9B,CAAC,CAAC,SAAS,CAAC;IACd,OAAO,IAAI,uBAAuB,CAAC,GAAG,EAAE;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC;QAC9B,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { InjectOptions, LightMyRequestResponse } from "fastify";
|
|
2
|
+
import type { AccessModel } from "@dads-framework/access";
|
|
3
|
+
import type { AuthorizationContextResolver, PermissionChecker, SubjectResolver, VisibleResourceLookup } from "../lib/request-pipeline/enforce-access.js";
|
|
4
|
+
import type { FeatureStateProtocol } from "../lib/request-pipeline/feature-state.js";
|
|
5
|
+
import type { HttpRoute } from "../lib/route/route-group.js";
|
|
6
|
+
/**
|
|
7
|
+
* Boots an HTTP app for tests with fakes pre-wired and returns `inject` —
|
|
8
|
+
* NEVER a listening socket, so a test run cannot orphan a port or leave a
|
|
9
|
+
* zombie listener (process-discipline bar; the type test pins that `listen`
|
|
10
|
+
* does not exist on the harness).
|
|
11
|
+
*
|
|
12
|
+
* Defaults: the subject comes from the `x-test-subject` header (absent →
|
|
13
|
+
* anonymous), and authorization DENIES everything — tests that exercise
|
|
14
|
+
* permissions pass a seeded `FakeAuthorization`.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The harness's own subject header. Neutral on purpose — it is a fixture
|
|
18
|
+
* channel between a test and `buildTestApp`, never a header any product's
|
|
19
|
+
* client sends.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TEST_SUBJECT_HEADER = "x-test-subject";
|
|
22
|
+
export type TestApp = {
|
|
23
|
+
readonly inject: (options: InjectOptions) => Promise<LightMyRequestResponse>;
|
|
24
|
+
readonly close: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export type BuildTestAppOptions = {
|
|
27
|
+
readonly routes: readonly HttpRoute[];
|
|
28
|
+
readonly accessModel?: AccessModel;
|
|
29
|
+
readonly lookups?: VisibleResourceLookup;
|
|
30
|
+
readonly subjects?: SubjectResolver;
|
|
31
|
+
/**
|
|
32
|
+
* Resolvers for routes declaring `capabilities.machineCredential`; when
|
|
33
|
+
* omitted, every declared name resolves through `subjects`.
|
|
34
|
+
*/
|
|
35
|
+
readonly machineCredentials?: Readonly<Record<string, SubjectResolver>>;
|
|
36
|
+
readonly authorization?: PermissionChecker;
|
|
37
|
+
readonly authorizationContexts?: AuthorizationContextResolver;
|
|
38
|
+
readonly handlerTimeoutMs?: number;
|
|
39
|
+
/** Body media types a raw route under test needs the app to accept. */
|
|
40
|
+
readonly rawBodyContentTypes?: readonly string[];
|
|
41
|
+
/** Body media types a raw route under test needs the app to accept as bytes. */
|
|
42
|
+
readonly byteBodyContentTypes?: readonly string[];
|
|
43
|
+
/** The feature-state protocol, for routes whose answer depends on it. */
|
|
44
|
+
readonly featureState?: FeatureStateProtocol;
|
|
45
|
+
};
|
|
46
|
+
export declare function buildTestApp(options: BuildTestAppOptions): Promise<TestApp>;
|
|
47
|
+
//# sourceMappingURL=build-test-app.d.ts.map
|
|
@@ -0,0 +1 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nC,uEAAuE;IACvE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,gFAAgF;IAChF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClD,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CAC9C,CAAC;AAmCF,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAoClB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { FakeAuthorization } from "@dads-framework/access/testing";
|
|
2
|
+
import { createHttpApp } from "../lib/create-http-app.js";
|
|
3
|
+
import { registerRoutes } from "../lib/request-pipeline/register-routes.js";
|
|
4
|
+
/**
|
|
5
|
+
* Boots an HTTP app for tests with fakes pre-wired and returns `inject` —
|
|
6
|
+
* NEVER a listening socket, so a test run cannot orphan a port or leave a
|
|
7
|
+
* zombie listener (process-discipline bar; the type test pins that `listen`
|
|
8
|
+
* does not exist on the harness).
|
|
9
|
+
*
|
|
10
|
+
* Defaults: the subject comes from the `x-test-subject` header (absent →
|
|
11
|
+
* anonymous), and authorization DENIES everything — tests that exercise
|
|
12
|
+
* permissions pass a seeded `FakeAuthorization`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The harness's own subject header. Neutral on purpose — it is a fixture
|
|
16
|
+
* channel between a test and `buildTestApp`, never a header any product's
|
|
17
|
+
* client sends.
|
|
18
|
+
*/
|
|
19
|
+
export const TEST_SUBJECT_HEADER = "x-test-subject";
|
|
20
|
+
function headerSubjects() {
|
|
21
|
+
return {
|
|
22
|
+
resolve: (request) => {
|
|
23
|
+
const id = request.headers[TEST_SUBJECT_HEADER];
|
|
24
|
+
return Promise.resolve(typeof id === "string" && id.length > 0 ? { type: "user", id } : null);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Routes under test that name a machine credential resolve it like any other caller. */
|
|
29
|
+
function sameSubjectsForEveryCredential(routes, subjects) {
|
|
30
|
+
const names = routes.flatMap((route) => route.capabilities.machineCredential === undefined
|
|
31
|
+
? []
|
|
32
|
+
: [route.capabilities.machineCredential]);
|
|
33
|
+
return Object.fromEntries(names.map((name) => [name, subjects]));
|
|
34
|
+
}
|
|
35
|
+
function listAccessOptions(options) {
|
|
36
|
+
return {
|
|
37
|
+
...(options.accessModel === undefined
|
|
38
|
+
? {}
|
|
39
|
+
: { accessModel: options.accessModel }),
|
|
40
|
+
...(options.lookups === undefined ? {} : { lookups: options.lookups }),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export async function buildTestApp(options) {
|
|
44
|
+
const app = await createHttpApp({
|
|
45
|
+
nodeEnv: "test",
|
|
46
|
+
trustedOrigins: [],
|
|
47
|
+
logger: false,
|
|
48
|
+
...(options.rawBodyContentTypes === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: { rawBodyContentTypes: options.rawBodyContentTypes }),
|
|
51
|
+
...(options.byteBodyContentTypes === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: { byteBodyContentTypes: options.byteBodyContentTypes }),
|
|
54
|
+
});
|
|
55
|
+
const subjects = options.subjects ?? headerSubjects();
|
|
56
|
+
registerRoutes(app, {
|
|
57
|
+
routes: options.routes,
|
|
58
|
+
...listAccessOptions(options),
|
|
59
|
+
subjects,
|
|
60
|
+
machineCredentials: options.machineCredentials ??
|
|
61
|
+
sameSubjectsForEveryCredential(options.routes, subjects),
|
|
62
|
+
authorization: options.authorization ?? new FakeAuthorization(),
|
|
63
|
+
...(options.authorizationContexts === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: { authorizationContexts: options.authorizationContexts }),
|
|
66
|
+
...(options.handlerTimeoutMs === undefined
|
|
67
|
+
? {}
|
|
68
|
+
: { handlerTimeoutMs: options.handlerTimeoutMs }),
|
|
69
|
+
...(options.featureState === undefined
|
|
70
|
+
? {}
|
|
71
|
+
: { featureState: options.featureState }),
|
|
72
|
+
});
|
|
73
|
+
await app.ready();
|
|
74
|
+
return {
|
|
75
|
+
inject: (injectOptions) => app.inject(injectOptions),
|
|
76
|
+
close: () => app.close(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=build-test-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-test-app.js","sourceRoot":"","sources":["../../src/testing/build-test-app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ1D,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AA4BpD,SAAS,cAAc;IACrB,OAAO;QACL,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;YACnB,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAChD,OAAO,OAAO,CAAC,OAAO,CACpB,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CACtE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,SAAS,8BAA8B,CACrC,MAA4B,EAC5B,QAAyB;IAEzB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACrC,KAAK,CAAC,YAAY,CAAC,iBAAiB,KAAK,SAAS;QAChD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAC3C,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAA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Aa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI,iBAAiB,EAAE;QAC/D,GAAG,CAAC,OAAO,CAAC,qBAAqB,KAAK,SAAS;YAC7C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,qBAAqB,EAAE,OAAO,CAAC,qBAAqB,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS;YACxC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS;YACpC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KAC5C,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAClB,OAAO;QACL,MAAM,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;QACpD,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,KAAK,gBAAgB,GACtB,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,GAGpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,GAEX,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Typed access to `app.inject()` responses. light-my-request's `json()`
|
|
4
|
+
* returns `any`; these helpers parse the body once with Zod instead, so
|
|
5
|
+
* tests get real types and the `no-unsafe-*` walls stay green
|
|
6
|
+
* (docs/architecture/type-safety.md — parse at the boundary, tests
|
|
7
|
+
* included).
|
|
8
|
+
*/
|
|
9
|
+
declare const errorEnvelopeSchema: z.ZodObject<{
|
|
10
|
+
error: z.ZodObject<{
|
|
11
|
+
code: z.ZodString;
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
details: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
14
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type InjectedResponse = {
|
|
18
|
+
readonly body: string;
|
|
19
|
+
};
|
|
20
|
+
/** Parses an error response into its typed `error` envelope. */
|
|
21
|
+
export declare function errorBodyOf(response: InjectedResponse): z.output<typeof errorEnvelopeSchema>["error"];
|
|
22
|
+
/** Parses a success envelope's `data` against the route's schema. */
|
|
23
|
+
export declare function dataBodyOf<Schema extends z.ZodType>(response: InjectedResponse, schema: Schema): z.output<Schema>;
|
|
24
|
+
/** Parses a `{ data, meta }` envelope against both route schemas. */
|
|
25
|
+
export declare function listBodyOf<DataSchema extends z.ZodType, MetaSchema extends z.ZodType>(response: InjectedResponse, data: DataSchema, meta: MetaSchema): {
|
|
26
|
+
data: z.output<DataSchema>;
|
|
27
|
+
meta: z.output<MetaSchema>;
|
|
28
|
+
};
|
|
29
|
+
/** The raw parsed body for whole-shape assertions (`toEqual`/`toMatchObject`). */
|
|
30
|
+
export declare function bodyOf(response: InjectedResponse): unknown;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=parse-inject-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-inject-response.d.ts","sourceRoot":"","sources":["../../src/testing/parse-inject-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AAEH,QAAA,MAAM,mBAAmB;;;;;;;iBAOvB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAMzD,gEAAgE;AAChE,wBAAgB,WAAW,CACzB,QAAQ,EAAE,gBAAgB,GACzB,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAE/C;AAKD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,EACjD,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,GACb,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAElB;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CACxB,UAAU,SAAS,CAAC,CAAC,OAAO,EAC5B,UAAU,SAAS,CAAC,CAAC,OAAO,EAE5B,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,GACf;IAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;CAAE,CAG5D;AAED,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Typed access to `app.inject()` responses. light-my-request's `json()`
|
|
4
|
+
* returns `any`; these helpers parse the body once with Zod instead, so
|
|
5
|
+
* tests get real types and the `no-unsafe-*` walls stay green
|
|
6
|
+
* (docs/architecture/type-safety.md — parse at the boundary, tests
|
|
7
|
+
* included).
|
|
8
|
+
*/
|
|
9
|
+
const errorEnvelopeSchema = z.object({
|
|
10
|
+
error: z.object({
|
|
11
|
+
code: z.string(),
|
|
12
|
+
message: z.string(),
|
|
13
|
+
details: z.looseObject({}).optional(),
|
|
14
|
+
requestId: z.string().optional(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
function jsonOf(response) {
|
|
18
|
+
return JSON.parse(response.body);
|
|
19
|
+
}
|
|
20
|
+
/** Parses an error response into its typed `error` envelope. */
|
|
21
|
+
export function errorBodyOf(response) {
|
|
22
|
+
return errorEnvelopeSchema.parse(jsonOf(response)).error;
|
|
23
|
+
}
|
|
24
|
+
const dataEnvelopeSchema = z.object({ data: z.unknown() });
|
|
25
|
+
const listEnvelopeSchema = z.object({ data: z.unknown(), meta: z.unknown() });
|
|
26
|
+
/** Parses a success envelope's `data` against the route's schema. */
|
|
27
|
+
export function dataBodyOf(response, schema) {
|
|
28
|
+
return schema.parse(dataEnvelopeSchema.parse(jsonOf(response)).data);
|
|
29
|
+
}
|
|
30
|
+
/** Parses a `{ data, meta }` envelope against both route schemas. */
|
|
31
|
+
export function listBodyOf(response, data, meta) {
|
|
32
|
+
const envelope = listEnvelopeSchema.parse(jsonOf(response));
|
|
33
|
+
return { data: data.parse(envelope.data), meta: meta.parse(envelope.meta) };
|
|
34
|
+
}
|
|
35
|
+
/** The raw parsed body for whole-shape assertions (`toEqual`/`toMatchObject`). */
|
|
36
|
+
export function bodyOf(response) {
|
|
37
|
+
return jsonOf(response);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=parse-inject-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-inject-response.js","sourceRoot":"","sources":["../../src/testing/parse-inject-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;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IAC5D,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,MAAM,CAAC,QAA0B;IAC/C,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dads-framework/http",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./testing": {
|
|
14
|
+
"types": "./dist/testing/index.d.ts",
|
|
15
|
+
"default": "./dist/testing/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./protocol-mounts": {
|
|
18
|
+
"types": "./dist/protocol-mounts/index.d.ts",
|
|
19
|
+
"default": "./dist/protocol-mounts/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@dads-framework/access": "0.2.0",
|
|
28
|
+
"@dads-framework/audit-actor": "0.2.0",
|
|
29
|
+
"@dads-framework/contract": "0.2.0",
|
|
30
|
+
"@dads-framework/diagnostics": "0.2.0",
|
|
31
|
+
"@dads-framework/errors": "0.2.0",
|
|
32
|
+
"@dads-framework/request-work": "0.2.0",
|
|
33
|
+
"@fastify/cors": "^11.3.0",
|
|
34
|
+
"fastify": "5.10.0",
|
|
35
|
+
"pino": "^10.3.1",
|
|
36
|
+
"ws": "^8.18.3",
|
|
37
|
+
"zod": "^4.4.3"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/ws": "^8.18.1",
|
|
41
|
+
"vitest": "~4.1.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"prepublishOnly": "node ../../../scripts/verify-prepublish.mjs",
|
|
45
|
+
"build": "tsc -b",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:integration": "VITEST_TIER=integration vitest run",
|
|
48
|
+
"typecheck": "tsc -b --pretty false"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"author": "Bryton Cooper",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/brytoncooper/dads-framework.git",
|
|
55
|
+
"directory": "packages/server/http"
|
|
56
|
+
}
|
|
57
|
+
}
|