@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,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which authorization warnings become a recorded fault, and how often.
|
|
3
|
+
*
|
|
4
|
+
* The authorization guards note a warning on the request tally every time a
|
|
5
|
+
* lookup passes its mark or a request passes its round-trip budget. One hot
|
|
6
|
+
* caller on a busy list would note it on every request, and a fault row per
|
|
7
|
+
* request is how an alert becomes noise. So a warning is recorded at most once
|
|
8
|
+
* per hour per (warning, route): the fingerprint of the recorded fault names
|
|
9
|
+
* both, so two routes listing the same type are two faults, and the
|
|
10
|
+
* fault-alert sweep groups each by its fingerprint.
|
|
11
|
+
*
|
|
12
|
+
* One instance per HTTP app, in memory: with several API processes each
|
|
13
|
+
* records its own once an hour, which is still a handful of rows an hour.
|
|
14
|
+
*/
|
|
15
|
+
import type { AuthorizationWarning } from "@dads-framework/request-work";
|
|
16
|
+
/** The fault a warning is recorded as: an exception type and fingerprint. */
|
|
17
|
+
export type RecordedWarningFault = {
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly fingerprint: string;
|
|
20
|
+
};
|
|
21
|
+
export declare class AuthorizationWarningFaults {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(intervalMs?: number);
|
|
24
|
+
/**
|
|
25
|
+
* The fault to record for `warning` on `routePattern` now, or `undefined`
|
|
26
|
+
* when the same fault was recorded within the interval.
|
|
27
|
+
*/
|
|
28
|
+
recordable(warning: AuthorizationWarning, routePattern: string | undefined, nowMs: number): RecordedWarningFault | undefined;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=authorization-warning-faults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-warning-faults.d.ts","sourceRoot":"","sources":["../../../src/lib/request-log/authorization-warning-faults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAIzE,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,qBAAa,0BAA0B;;IAIrC,YAAY,UAAU,GAAE,MAAoB,EAE3C;IAED;;;OAGG;IACH,UAAU,CACR,OAAO,EAAE,oBAAoB,EAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,KAAK,EAAE,MAAM,GACZ,oBAAoB,GAAG,SAAS,CAMlC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which authorization warnings become a recorded fault, and how often.
|
|
3
|
+
*
|
|
4
|
+
* The authorization guards note a warning on the request tally every time a
|
|
5
|
+
* lookup passes its mark or a request passes its round-trip budget. One hot
|
|
6
|
+
* caller on a busy list would note it on every request, and a fault row per
|
|
7
|
+
* request is how an alert becomes noise. So a warning is recorded at most once
|
|
8
|
+
* per hour per (warning, route): the fingerprint of the recorded fault names
|
|
9
|
+
* both, so two routes listing the same type are two faults, and the
|
|
10
|
+
* fault-alert sweep groups each by its fingerprint.
|
|
11
|
+
*
|
|
12
|
+
* One instance per HTTP app, in memory: with several API processes each
|
|
13
|
+
* records its own once an hour, which is still a handful of rows an hour.
|
|
14
|
+
*/
|
|
15
|
+
const ONE_HOUR_MS = 60 * 60 * 1000;
|
|
16
|
+
export class AuthorizationWarningFaults {
|
|
17
|
+
#lastRecordedAt = new Map();
|
|
18
|
+
#intervalMs;
|
|
19
|
+
constructor(intervalMs = ONE_HOUR_MS) {
|
|
20
|
+
this.#intervalMs = intervalMs;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The fault to record for `warning` on `routePattern` now, or `undefined`
|
|
24
|
+
* when the same fault was recorded within the interval.
|
|
25
|
+
*/
|
|
26
|
+
recordable(warning, routePattern, nowMs) {
|
|
27
|
+
const fingerprint = `${warning.fingerprint}@${routePattern ?? "unmatched"}`;
|
|
28
|
+
const last = this.#lastRecordedAt.get(fingerprint);
|
|
29
|
+
if (last !== undefined && nowMs - last < this.#intervalMs)
|
|
30
|
+
return undefined;
|
|
31
|
+
this.#lastRecordedAt.set(fingerprint, nowMs);
|
|
32
|
+
return { type: warning.type, fingerprint };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=authorization-warning-faults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-warning-faults.js","sourceRoot":"","sources":["../../../src/lib/request-log/authorization-warning-faults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAQnC,MAAM,OAAO,0BAA0B;IAC5B,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,WAAW,CAAS;IAE7B,YAAY,UAAU,GAAW,WAAW;QAC1C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,UAAU,CACR,OAA6B,EAC7B,YAAgC,EAChC,KAAa;QAEb,MAAM,WAAW,GAAG,GAAG,OAAO,CAAC,WAAW,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACnD,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,WAAW;YAAE,OAAO,SAAS,CAAC;QAC5E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `onResponse` capture.
|
|
3
|
+
*
|
|
4
|
+
* `onResponse` and no other hook: it is the only one that runs for EVERY
|
|
5
|
+
* answer this process gives — a matched route, a 404 from the not-found
|
|
6
|
+
* handler, the 426 client gate, a 429, whatever the error handler wrote, and
|
|
7
|
+
* the protocol mounts (`/api/auth`, `/scim/v2`) that never enter the route
|
|
8
|
+
* pipeline at all. It is also the only one that can read the final status and
|
|
9
|
+
* `reply.elapsedTime`.
|
|
10
|
+
*
|
|
11
|
+
* It runs after the client already has its answer, so nothing here is allowed
|
|
12
|
+
* to matter: a throw is caught and logged, and the row is dropped.
|
|
13
|
+
*/
|
|
14
|
+
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
15
|
+
import type { DiagnosticsReporter } from "@dads-framework/diagnostics";
|
|
16
|
+
import type { AuthorizationWarningFaults } from "./authorization-warning-faults.js";
|
|
17
|
+
import type { RequestLogSink } from "./request-log-sink.js";
|
|
18
|
+
export type RequestCaptureOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Where rows go, looked up per response rather than held.
|
|
21
|
+
*
|
|
22
|
+
* The capture has to be installed with the app — a hook added after a
|
|
23
|
+
* plugin has booted is not inherited by it — but the sink belongs to the
|
|
24
|
+
* composition root, which needs the app's logger before it can build one.
|
|
25
|
+
* A lookup lets the app exist first and answer `undefined` in between.
|
|
26
|
+
*/
|
|
27
|
+
readonly requestLog: (() => RequestLogSink | undefined) | undefined;
|
|
28
|
+
readonly apiRelease: string | undefined;
|
|
29
|
+
/** Which process answered — the container hostname, resolved once at boot. */
|
|
30
|
+
readonly instanceId: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The trace in flight, asked per response.
|
|
33
|
+
*
|
|
34
|
+
* Injected rather than read here: this kit has no business depending on
|
|
35
|
+
* OpenTelemetry, and a deployment that runs no tracing should not carry it.
|
|
36
|
+
* The composition root supplies the one-line reader.
|
|
37
|
+
*/
|
|
38
|
+
readonly currentTraceId?: () => string | undefined;
|
|
39
|
+
/** Probe routes, the same set kept out of the log stream. */
|
|
40
|
+
readonly quietPaths: ReadonlySet<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Which authorization warnings the request tripped become a recorded fault
|
|
43
|
+
* (rate-limited). Absent, warnings are not recorded.
|
|
44
|
+
*/
|
|
45
|
+
readonly warningFaults?: AuthorizationWarningFaults;
|
|
46
|
+
/** Where a recorded authorization warning is also reported, beside its row. */
|
|
47
|
+
readonly diagnostics?: DiagnosticsReporter;
|
|
48
|
+
};
|
|
49
|
+
export declare function captureRequestRecord(request: FastifyRequest, reply: FastifyReply, options: RequestCaptureOptions): void;
|
|
50
|
+
//# sourceMappingURL=capture-request-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-request-record.d.ts","sourceRoot":"","sources":["../../../src/lib/request-log/capture-request-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAIvE,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACnD,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,0BAA0B,CAAC;IACpD,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC;CAC5C,CAAC;AAqBF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAoBN"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `onResponse` capture.
|
|
3
|
+
*
|
|
4
|
+
* `onResponse` and no other hook: it is the only one that runs for EVERY
|
|
5
|
+
* answer this process gives — a matched route, a 404 from the not-found
|
|
6
|
+
* handler, the 426 client gate, a 429, whatever the error handler wrote, and
|
|
7
|
+
* the protocol mounts (`/api/auth`, `/scim/v2`) that never enter the route
|
|
8
|
+
* pipeline at all. It is also the only one that can read the final status and
|
|
9
|
+
* `reply.elapsedTime`.
|
|
10
|
+
*
|
|
11
|
+
* It runs after the client already has its answer, so nothing here is allowed
|
|
12
|
+
* to matter: a throw is caught and logged, and the row is dropped.
|
|
13
|
+
*/
|
|
14
|
+
import { currentAuditActor } from "@dads-framework/audit-actor";
|
|
15
|
+
import { requestWorkOf } from "@dads-framework/request-work";
|
|
16
|
+
import { requestIdOf } from "../request-pipeline/request-id.js";
|
|
17
|
+
import { requestOutcomeOf } from "./request-outcome.js";
|
|
18
|
+
import { buildRequestRecord } from "./request-record.js";
|
|
19
|
+
/**
|
|
20
|
+
* An authorization guard the request tripped while still succeeding, built
|
|
21
|
+
* only to be reported: it is never thrown at a caller.
|
|
22
|
+
*/
|
|
23
|
+
class AuthorizationGuardWarning extends Error {
|
|
24
|
+
constructor(type, detail) {
|
|
25
|
+
super(detail);
|
|
26
|
+
this.name = type;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Methods that change nothing, and there are far more of them than everything
|
|
31
|
+
* else. `OPTIONS` is here for the CORS preflight: the browser sends one before
|
|
32
|
+
* the real request, it carries no credential and touches no resource, and the
|
|
33
|
+
* request it asks about gets its own row a moment later.
|
|
34
|
+
*/
|
|
35
|
+
const NOTHING_CHANGED_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
36
|
+
export function captureRequestRecord(request, reply, options) {
|
|
37
|
+
try {
|
|
38
|
+
const sink = options.requestLog?.();
|
|
39
|
+
if (sink === undefined)
|
|
40
|
+
return;
|
|
41
|
+
const routePattern = request.routeOptions.url;
|
|
42
|
+
if (isQuiet(routePattern, options.quietPaths))
|
|
43
|
+
return;
|
|
44
|
+
const warningFault = recordWarningFault(request, routePattern, options);
|
|
45
|
+
if (warningFault === undefined &&
|
|
46
|
+
!isWorthRecording(request.method, reply.statusCode, sink)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
sink.record(rowFor(request, reply, routePattern, options, warningFault));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
request.log.error({ event: "request-log.capture-failed", err: error }, "request log capture failed");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function isQuiet(routePattern, quietPaths) {
|
|
56
|
+
return routePattern !== undefined && quietPaths.has(routePattern);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The warning the request's authorization guards noted, as the fault its row
|
|
60
|
+
* records, when the rate limit lets it through. A recorded warning is also
|
|
61
|
+
* logged and reported to diagnostics; a successful read that tripped one is
|
|
62
|
+
* recorded although successful reads otherwise are not.
|
|
63
|
+
*/
|
|
64
|
+
function recordWarningFault(request, routePattern, options) {
|
|
65
|
+
const warning = requestWorkOf(request)?.authzWarning;
|
|
66
|
+
if (warning === undefined || options.warningFaults === undefined) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const fault = options.warningFaults.recordable(warning, routePattern, Date.now());
|
|
70
|
+
if (fault === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
const requestId = requestIdOf(request);
|
|
73
|
+
request.log.warn({
|
|
74
|
+
event: "authorization.guard-warning",
|
|
75
|
+
requestId,
|
|
76
|
+
routeId: routePattern,
|
|
77
|
+
type: fault.type,
|
|
78
|
+
fingerprint: fault.fingerprint,
|
|
79
|
+
detail: warning.detail,
|
|
80
|
+
}, "request tripped an authorization guard");
|
|
81
|
+
options.diagnostics?.captureException({
|
|
82
|
+
error: new AuthorizationGuardWarning(fault.type, warning.detail),
|
|
83
|
+
source: "request",
|
|
84
|
+
// Nothing failed — the request answered — so it groups as a warning, by
|
|
85
|
+
// the same per-warning-per-route key its row is grouped by.
|
|
86
|
+
severity: "warning",
|
|
87
|
+
fingerprint: fault.fingerprint,
|
|
88
|
+
requestId,
|
|
89
|
+
...(routePattern === undefined ? {} : { routeId: routePattern }),
|
|
90
|
+
});
|
|
91
|
+
return fault;
|
|
92
|
+
}
|
|
93
|
+
/** Everything that changed something, plus everything that went wrong. */
|
|
94
|
+
function isWorthRecording(method, status, sink) {
|
|
95
|
+
if (sink.includeSuccessfulReads)
|
|
96
|
+
return true;
|
|
97
|
+
return !NOTHING_CHANGED_METHODS.has(method) || status >= 400;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The notes the pipeline left, joined to what Fastify knows.
|
|
101
|
+
*
|
|
102
|
+
* The actor is read off the request rather than out of the ambient context:
|
|
103
|
+
* `carryResolvedAuditActor` scopes the resolved actor to the handler, so by
|
|
104
|
+
* now the context is back to the ingress `anonymous` one. The context is the
|
|
105
|
+
* fallback for responses that never reached a handler.
|
|
106
|
+
*/
|
|
107
|
+
function rowFor(request, reply, routePattern, options, warningFault) {
|
|
108
|
+
const outcome = requestOutcomeOf(request);
|
|
109
|
+
return buildRequestRecord({
|
|
110
|
+
requestId: requestIdOf(request),
|
|
111
|
+
recordedAt: new Date(),
|
|
112
|
+
method: request.method,
|
|
113
|
+
url: request.url,
|
|
114
|
+
routePattern,
|
|
115
|
+
status: reply.statusCode,
|
|
116
|
+
durationMs: Math.round(reply.elapsedTime),
|
|
117
|
+
headers: request.headers,
|
|
118
|
+
ip: request.ip,
|
|
119
|
+
actor: outcome?.actor ?? currentAuditActor(),
|
|
120
|
+
access: outcome?.access,
|
|
121
|
+
errorCode: outcome?.errorCode,
|
|
122
|
+
apiRelease: options.apiRelease,
|
|
123
|
+
// Read off the request, not the ambient context: `onResponse` may run on
|
|
124
|
+
// an async task that no longer belongs to the request that answered.
|
|
125
|
+
work: requestWorkOf(request),
|
|
126
|
+
instanceId: options.instanceId,
|
|
127
|
+
traceId: options.currentTraceId?.(),
|
|
128
|
+
// A thrown fault outranks a warning the same request noted earlier.
|
|
129
|
+
exception: outcome?.exception ?? warningFault,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=capture-request-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-request-record.js","sourceRoot":"","sources":["../../../src/lib/request-log/capture-request-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,aA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nC,oEAAoE;QACpE,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,YAAY;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where captured request rows go.
|
|
3
|
+
*
|
|
4
|
+
* The http kit builds rows and knows nothing about storing them — the
|
|
5
|
+
* Postgres sink lives in `@dads-framework/audit`, which owns the table. A class
|
|
6
|
+
* rather than a bare function type because a sink has a lifecycle: it buffers,
|
|
7
|
+
* it flushes, and shutdown has to drain it.
|
|
8
|
+
*
|
|
9
|
+
* `record` returns void on purpose. Capture runs in an `onResponse` hook,
|
|
10
|
+
* after the client already has its answer; a sink that made the hook wait
|
|
11
|
+
* would put a diagnostic write on the request path, which is the one thing
|
|
12
|
+
* this design refuses to do.
|
|
13
|
+
*/
|
|
14
|
+
import type { RequestRecord } from "./request-record.js";
|
|
15
|
+
export declare abstract class RequestLogSink {
|
|
16
|
+
readonly includeSuccessfulReads: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @param includeSuccessfulReads - whether a successful GET, HEAD or OPTIONS
|
|
19
|
+
* is worth a row. Off by default: reads and CORS preflights are the
|
|
20
|
+
* overwhelming majority of traffic and none of them changed anything, so the
|
|
21
|
+
* table would be mostly noise.
|
|
22
|
+
*/
|
|
23
|
+
constructor(includeSuccessfulReads?: boolean);
|
|
24
|
+
/** Take one row. Never throws, never blocks the response. */
|
|
25
|
+
abstract record(row: RequestRecord): void;
|
|
26
|
+
/** Write everything buffered and wait for it. */
|
|
27
|
+
abstract flush(): Promise<void>;
|
|
28
|
+
/** Stop any timer, flush what is left, accept nothing further. */
|
|
29
|
+
abstract close(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=request-log-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-log-sink.d.ts","sourceRoot":"","sources":["../../../src/lib/request-log/request-log-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,8BAAsB,cAAc;IAOtB,QAAQ,CAAC,sBAAsB;IAN3C;;;;;OAKG;IACH,YAAqB,sBAAsB,UAAQ,EAAI;IAEvD,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAAC;IAE1C,iDAAiD;IACjD,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where captured request rows go.
|
|
3
|
+
*
|
|
4
|
+
* The http kit builds rows and knows nothing about storing them — the
|
|
5
|
+
* Postgres sink lives in `@dads-framework/audit`, which owns the table. A class
|
|
6
|
+
* rather than a bare function type because a sink has a lifecycle: it buffers,
|
|
7
|
+
* it flushes, and shutdown has to drain it.
|
|
8
|
+
*
|
|
9
|
+
* `record` returns void on purpose. Capture runs in an `onResponse` hook,
|
|
10
|
+
* after the client already has its answer; a sink that made the hook wait
|
|
11
|
+
* would put a diagnostic write on the request path, which is the one thing
|
|
12
|
+
* this design refuses to do.
|
|
13
|
+
*/
|
|
14
|
+
export class RequestLogSink {
|
|
15
|
+
includeSuccessfulReads;
|
|
16
|
+
/**
|
|
17
|
+
* @param includeSuccessfulReads - whether a successful GET, HEAD or OPTIONS
|
|
18
|
+
* is worth a row. Off by default: reads and CORS preflights are the
|
|
19
|
+
* overwhelming majority of traffic and none of them changed anything, so the
|
|
20
|
+
* table would be mostly noise.
|
|
21
|
+
*/
|
|
22
|
+
constructor(includeSuccessfulReads = false) {
|
|
23
|
+
this.includeSuccessfulReads = includeSuccessfulReads;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=request-log-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-log-sink.js","sourceRoot":"","sources":["../../../src/lib/request-log/request-log-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,OAAgB,cAAc;IAOb,sBAAsB;IAN3C;;;;;OAKG;IACH,YAAqB,sBAAsB,GAAG,KAAK;sCAA9B,sBAAsB;IAAW,CAAC;CAUxD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the request pipeline learned that the response no longer shows.
|
|
3
|
+
*
|
|
4
|
+
* By the time `onResponse` runs, a denial is an anonymous 404 and a validation
|
|
5
|
+
* failure is a 400 with a body already on the wire — the permission that was
|
|
6
|
+
* checked, the credential that answered, and the envelope's error code are all
|
|
7
|
+
* gone. The stages that DO know them leave a note here, keyed by the request
|
|
8
|
+
* object itself.
|
|
9
|
+
*
|
|
10
|
+
* A `WeakMap` rather than a Fastify decorator: the kit augments no Fastify
|
|
11
|
+
* type today, and a decorator would put a diagnostic field on every request
|
|
12
|
+
* whether or not an app captures anything. The map holds no reference of its
|
|
13
|
+
* own, so a request that ends without a note is collected exactly as before.
|
|
14
|
+
*/
|
|
15
|
+
import type { AuditActor } from "@dads-framework/audit-actor";
|
|
16
|
+
import type { AccessDecision } from "../request-pipeline/enforce-access.js";
|
|
17
|
+
import type { RouteAccess } from "../route/access.js";
|
|
18
|
+
import type { RequestAccessFacts } from "./request-record.js";
|
|
19
|
+
export type RequestOutcome = {
|
|
20
|
+
readonly actor?: AuditActor;
|
|
21
|
+
readonly access?: RequestAccessFacts;
|
|
22
|
+
readonly errorCode?: string;
|
|
23
|
+
readonly exception?: {
|
|
24
|
+
readonly type: string;
|
|
25
|
+
readonly fingerprint: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Keep the actor the request resolved to.
|
|
30
|
+
*
|
|
31
|
+
* `runWithAuditActor` scopes the resolved actor to the handler, so by
|
|
32
|
+
* `onResponse` the ambient context is back to the ingress `anonymous` one.
|
|
33
|
+
* Reading the actor off the request instead of the context is the difference
|
|
34
|
+
* between a row that says `user` and a row that says nobody.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rememberRequestActor(request: object, actor: AuditActor): void;
|
|
37
|
+
/** Freeze what access settled, before the handler turns it into a status. */
|
|
38
|
+
export declare function rememberAccessOutcome(request: object, access: RouteAccess, decision: AccessDecision): void;
|
|
39
|
+
/** Keep the envelope's `code`, the one part of an error body worth a column. */
|
|
40
|
+
export declare function rememberErrorCode(request: object, errorCode: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Keep what actually failed.
|
|
43
|
+
*
|
|
44
|
+
* `errorCode` is `INTERNAL_ERROR` for every unexpected fault — exactly the set
|
|
45
|
+
* worth investigating and exactly the set it cannot tell apart. The type and
|
|
46
|
+
* fingerprint can.
|
|
47
|
+
*/
|
|
48
|
+
export declare function rememberException(request: object, exception: {
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly fingerprint: string;
|
|
51
|
+
}): void;
|
|
52
|
+
export declare function requestOutcomeOf(request: object): RequestOutcome | undefined;
|
|
53
|
+
//# sourceMappingURL=request-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-outcome.d.ts","sourceRoot":"","sources":["../../../src/lib/request-log/request-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9E,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAG7E;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,cAAc,GACvB,IAAI,CAEN;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACjE,IAAI,CAEN;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE5E"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the request pipeline learned that the response no longer shows.
|
|
3
|
+
*
|
|
4
|
+
* By the time `onResponse` runs, a denial is an anonymous 404 and a validation
|
|
5
|
+
* failure is a 400 with a body already on the wire — the permission that was
|
|
6
|
+
* checked, the credential that answered, and the envelope's error code are all
|
|
7
|
+
* gone. The stages that DO know them leave a note here, keyed by the request
|
|
8
|
+
* object itself.
|
|
9
|
+
*
|
|
10
|
+
* A `WeakMap` rather than a Fastify decorator: the kit augments no Fastify
|
|
11
|
+
* type today, and a decorator would put a diagnostic field on every request
|
|
12
|
+
* whether or not an app captures anything. The map holds no reference of its
|
|
13
|
+
* own, so a request that ends without a note is collected exactly as before.
|
|
14
|
+
*/
|
|
15
|
+
import { annotateRequestActor } from "../request-pipeline/request-trace.js";
|
|
16
|
+
const outcomes = new WeakMap();
|
|
17
|
+
/**
|
|
18
|
+
* Keep the actor the request resolved to.
|
|
19
|
+
*
|
|
20
|
+
* `runWithAuditActor` scopes the resolved actor to the handler, so by
|
|
21
|
+
* `onResponse` the ambient context is back to the ingress `anonymous` one.
|
|
22
|
+
* Reading the actor off the request instead of the context is the difference
|
|
23
|
+
* between a row that says `user` and a row that says nobody.
|
|
24
|
+
*/
|
|
25
|
+
export function rememberRequestActor(request, actor) {
|
|
26
|
+
amend(request, { actor });
|
|
27
|
+
annotateRequestActor(request, actor);
|
|
28
|
+
}
|
|
29
|
+
/** Freeze what access settled, before the handler turns it into a status. */
|
|
30
|
+
export function rememberAccessOutcome(request, access, decision) {
|
|
31
|
+
amend(request, { access: describeAccess(access, decision) });
|
|
32
|
+
}
|
|
33
|
+
/** Keep the envelope's `code`, the one part of an error body worth a column. */
|
|
34
|
+
export function rememberErrorCode(request, errorCode) {
|
|
35
|
+
amend(request, { errorCode });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Keep what actually failed.
|
|
39
|
+
*
|
|
40
|
+
* `errorCode` is `INTERNAL_ERROR` for every unexpected fault — exactly the set
|
|
41
|
+
* worth investigating and exactly the set it cannot tell apart. The type and
|
|
42
|
+
* fingerprint can.
|
|
43
|
+
*/
|
|
44
|
+
export function rememberException(request, exception) {
|
|
45
|
+
amend(request, { exception });
|
|
46
|
+
}
|
|
47
|
+
export function requestOutcomeOf(request) {
|
|
48
|
+
return outcomes.get(request);
|
|
49
|
+
}
|
|
50
|
+
function amend(request, note) {
|
|
51
|
+
outcomes.set(request, { ...outcomes.get(request), ...note });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The decision as the row wants it.
|
|
55
|
+
*
|
|
56
|
+
* A refusal carries no resolved facts — that is the point of failing closed —
|
|
57
|
+
* so it reports what the ROUTE declared instead: which kind of access was
|
|
58
|
+
* asked for, and on a permission or visibility route, which permission. Those
|
|
59
|
+
* are facts about the code, not about the caller, and they are what turns "a
|
|
60
|
+
* 404" into "that caller lacked orders.read on organizations/order".
|
|
61
|
+
*/
|
|
62
|
+
function describeAccess(access, decision) {
|
|
63
|
+
if (decision.outcome !== "allow") {
|
|
64
|
+
return {
|
|
65
|
+
outcome: decision.outcome,
|
|
66
|
+
accessKind: access.kind,
|
|
67
|
+
...declared(access),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
outcome: "allow",
|
|
72
|
+
accessKind: decision.accessKind,
|
|
73
|
+
...(decision.permission === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: { permission: decision.permission }),
|
|
76
|
+
...(decision.resource === undefined
|
|
77
|
+
? {}
|
|
78
|
+
: {
|
|
79
|
+
resourceType: decision.resource.type,
|
|
80
|
+
resourceId: decision.resource.id,
|
|
81
|
+
}),
|
|
82
|
+
...(decision.authMethod === undefined
|
|
83
|
+
? {}
|
|
84
|
+
: { authMethod: decision.authMethod }),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** The permission a route declares statically, for the paths that never got one. */
|
|
88
|
+
function declared(access) {
|
|
89
|
+
if (access.kind === "permission" ||
|
|
90
|
+
access.kind === "visibility" ||
|
|
91
|
+
access.kind === "scoped") {
|
|
92
|
+
return { permission: access.permission, resourceType: access.resourceType };
|
|
93
|
+
}
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=request-outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-outcome.js","sourceRoot":"","sources":["../../../src/lib/request-log/request-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAW5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MAAM,CAAC;SACpB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,GAAG,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxC,GAAG,CAAC,QAAQ,CAAC,QAAQ,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI;gBACpC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE;aACjC,CAAC;QACN,GAAG,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,SAAS,QAAQ,CAAC,MAAmB;IAInC,IACE,MAAM,CAAC,IAAI,KAAK,YAAY;QAC5B,MAAM,CAAC,IAAI,KAAK,YAAY;QAC5B,MAAM,CAAC,IAAI,KAAK,QAAQ,EACxB,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One `request_log` row, and the pure function that builds it.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here touches Fastify. The capture hook hands over a plain object —
|
|
5
|
+
* method, status, elapsed time, the headers, the actor in force, what access
|
|
6
|
+
* settled — and gets back the row. That keeps the redaction rules testable
|
|
7
|
+
* without a server: the allowlist below is the ONLY place a request header is
|
|
8
|
+
* read, so "no cookie, no authorization, no query string, no body" is a
|
|
9
|
+
* property of nine lines rather than a promise
|
|
10
|
+
* (docs/architecture/observability.md).
|
|
11
|
+
*/
|
|
12
|
+
import type { AuditActor } from "@dads-framework/audit-actor";
|
|
13
|
+
import type { RequestWorkTally } from "@dads-framework/request-work";
|
|
14
|
+
import { type ClientContext } from "@dads-framework/contract";
|
|
15
|
+
/**
|
|
16
|
+
* How the request ended, in the vocabulary `request_log.decision` stores.
|
|
17
|
+
*
|
|
18
|
+
* `denied` is access saying no (the wire still shows 404, so the table is the
|
|
19
|
+
* only place the difference survives); `not-found` is nothing there to say no
|
|
20
|
+
* about; `error` is every other unhappy status, the server's own 5xx included.
|
|
21
|
+
*/
|
|
22
|
+
export type RequestDecision = "allow" | "denied" | "not-found" | "unauthenticated" | "error";
|
|
23
|
+
/** What access settled, as the capture hook stashed it during the request. */
|
|
24
|
+
export type RequestAccessFacts = {
|
|
25
|
+
readonly outcome: "allow" | "unauthenticated" | "not-found";
|
|
26
|
+
/** Which access declaration answered — `public`, `session`, `permission`, `visibility`. */
|
|
27
|
+
readonly accessKind: string;
|
|
28
|
+
readonly permission?: string;
|
|
29
|
+
readonly resourceType?: string;
|
|
30
|
+
readonly resourceId?: string;
|
|
31
|
+
readonly authMethod?: string;
|
|
32
|
+
};
|
|
33
|
+
/** Fastify's header bag, narrowed to what a pure function can be handed. */
|
|
34
|
+
export type RequestRecordHeaders = Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
35
|
+
export type RequestRecordInput = {
|
|
36
|
+
readonly requestId: string;
|
|
37
|
+
readonly recordedAt: Date;
|
|
38
|
+
readonly method: string;
|
|
39
|
+
/** The raw url — read ONLY to fall back when no route matched. */
|
|
40
|
+
readonly url: string;
|
|
41
|
+
/** The matched route's pattern (`request.routeOptions.url`), when one matched. */
|
|
42
|
+
readonly routePattern: string | undefined;
|
|
43
|
+
readonly status: number;
|
|
44
|
+
readonly durationMs: number;
|
|
45
|
+
readonly headers: RequestRecordHeaders;
|
|
46
|
+
/** `request.ip`, already resolved against the trusted proxy hop count. */
|
|
47
|
+
readonly ip: string | undefined;
|
|
48
|
+
readonly actor: AuditActor | undefined;
|
|
49
|
+
readonly access: RequestAccessFacts | undefined;
|
|
50
|
+
/** The `code` the error envelope reported, when the response was one. */
|
|
51
|
+
readonly errorCode: string | undefined;
|
|
52
|
+
readonly apiRelease: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* What the request cost, as the counters saw it. `undefined` when nothing
|
|
55
|
+
* started a tally — the row then keeps nulls, which reads as "not measured"
|
|
56
|
+
* rather than as "did no work".
|
|
57
|
+
*/
|
|
58
|
+
readonly work: RequestWorkTally | undefined;
|
|
59
|
+
/** Which process answered — the container hostname. */
|
|
60
|
+
readonly instanceId: string | undefined;
|
|
61
|
+
/** The trace this request belonged to, when one was running. */
|
|
62
|
+
readonly traceId: string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* What failed, when something did. Type and fingerprint only — the message
|
|
65
|
+
* and stack stay in the log line keyed by this request id, because a message
|
|
66
|
+
* can quote whatever a user typed and this table is bounded by retention.
|
|
67
|
+
*/
|
|
68
|
+
readonly exception: {
|
|
69
|
+
readonly type: string;
|
|
70
|
+
readonly fingerprint: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The row itself. Field names are the table's column names in camel case, so
|
|
75
|
+
* a sink inserts it without a translation layer between here and the schema.
|
|
76
|
+
*/
|
|
77
|
+
export type RequestRecord = {
|
|
78
|
+
readonly requestId: string;
|
|
79
|
+
readonly recordedAt: Date;
|
|
80
|
+
readonly method: string;
|
|
81
|
+
readonly routeId: string | null;
|
|
82
|
+
readonly path: string;
|
|
83
|
+
readonly status: number;
|
|
84
|
+
readonly durationMs: number;
|
|
85
|
+
readonly actorKind: string;
|
|
86
|
+
readonly actorId: string;
|
|
87
|
+
readonly authMethod: string | null;
|
|
88
|
+
readonly accessKind: string | null;
|
|
89
|
+
readonly permission: string | null;
|
|
90
|
+
readonly resourceType: string | null;
|
|
91
|
+
readonly resourceId: string | null;
|
|
92
|
+
readonly decision: RequestDecision;
|
|
93
|
+
readonly errorCode: string | null;
|
|
94
|
+
readonly ip: string | null;
|
|
95
|
+
readonly forwardedFor: string | null;
|
|
96
|
+
readonly userAgent: string | null;
|
|
97
|
+
readonly clientHints: Record<string, string> | null;
|
|
98
|
+
readonly acceptLanguage: string | null;
|
|
99
|
+
readonly clientContext: ClientContext | null;
|
|
100
|
+
readonly apiRelease: string | null;
|
|
101
|
+
readonly dbQueryCount: number | null;
|
|
102
|
+
readonly dbMs: number | null;
|
|
103
|
+
readonly authzCheckCount: number | null;
|
|
104
|
+
readonly authzMs: number | null;
|
|
105
|
+
readonly authzCachedReadCount: number | null;
|
|
106
|
+
readonly authzFullyConsistentReadCount: number | null;
|
|
107
|
+
readonly authzLargestLookupCount: number | null;
|
|
108
|
+
readonly instanceId: string | null;
|
|
109
|
+
readonly traceId: string | null;
|
|
110
|
+
readonly exceptionType: string | null;
|
|
111
|
+
readonly exceptionFingerprint: string | null;
|
|
112
|
+
};
|
|
113
|
+
export declare function buildRequestRecord(input: RequestRecordInput): RequestRecord;
|
|
114
|
+
//# sourceMappingURL=request-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-record.d.ts","sourceRoot":"","sources":["../../../src/lib/request-log/request-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACzB,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,iBAAiB,GAAG,OAAO,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC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