@webpieces/core-context 0.4.641 → 0.4.643
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/package.json +2 -2
- package/src/HttpRequest.d.ts +18 -1
- package/src/HttpRequest.js +11 -1
- package/src/HttpRequest.js.map +1 -1
- package/src/RawRequest.d.ts +78 -0
- package/src/RawRequest.js +64 -0
- package/src/RawRequest.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/core-context",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.643",
|
|
4
4
|
"description": "AsyncLocalStorage-based context management for request-scoped data",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webpieces/core-util": "0.4.
|
|
25
|
+
"@webpieces/core-util": "0.4.643",
|
|
26
26
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
27
27
|
"inversify": "7.10.4",
|
|
28
28
|
"reflect-metadata": "0.2.2"
|
package/src/HttpRequest.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyContextKey } from '@webpieces/core-util';
|
|
2
|
+
import { RawRequest } from './RawRequest';
|
|
2
3
|
/**
|
|
3
4
|
* HttpRequest - webpieces' TRANSPORT-NEUTRAL inbound request.
|
|
4
5
|
*
|
|
@@ -17,9 +18,25 @@ export declare class HttpRequest {
|
|
|
17
18
|
readonly path: string;
|
|
18
19
|
/** Header name (lowercased) -> values (HTTP allows multiple values per name). */
|
|
19
20
|
readonly headers: Map<string, string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* The verbatim bytes + absolute url, present ONLY on an `@Endpoint(..., { rawBody: true })`
|
|
23
|
+
* route (see {@link RawRequest}). Absent everywhere else, and absent is the SAFE state:
|
|
24
|
+
* `@AuthWebhook` has nothing to verify without it and 401s rather than waving the call
|
|
25
|
+
* through. A spec driving a webhook route in-process supplies one here, the same way a spec
|
|
26
|
+
* today supplies an `authorization` header.
|
|
27
|
+
*/
|
|
28
|
+
readonly raw?: RawRequest | undefined;
|
|
20
29
|
constructor(method: string, path: string,
|
|
21
30
|
/** Header name (lowercased) -> values (HTTP allows multiple values per name). */
|
|
22
|
-
headers: Map<string, string[]
|
|
31
|
+
headers: Map<string, string[]>,
|
|
32
|
+
/**
|
|
33
|
+
* The verbatim bytes + absolute url, present ONLY on an `@Endpoint(..., { rawBody: true })`
|
|
34
|
+
* route (see {@link RawRequest}). Absent everywhere else, and absent is the SAFE state:
|
|
35
|
+
* `@AuthWebhook` has nothing to verify without it and 401s rather than waving the call
|
|
36
|
+
* through. A spec driving a webhook route in-process supplies one here, the same way a spec
|
|
37
|
+
* today supplies an `authorization` header.
|
|
38
|
+
*/
|
|
39
|
+
raw?: RawRequest | undefined);
|
|
23
40
|
/** First value of a header, looked up by ContextKey.httpHeader (or a raw lowercased name). */
|
|
24
41
|
getHeader(key: AnyContextKey | string): string | undefined;
|
|
25
42
|
/** All values of a header. */
|
package/src/HttpRequest.js
CHANGED
|
@@ -18,12 +18,22 @@ class HttpRequest {
|
|
|
18
18
|
method;
|
|
19
19
|
path;
|
|
20
20
|
headers;
|
|
21
|
+
raw;
|
|
21
22
|
constructor(method, path,
|
|
22
23
|
/** Header name (lowercased) -> values (HTTP allows multiple values per name). */
|
|
23
|
-
headers
|
|
24
|
+
headers,
|
|
25
|
+
/**
|
|
26
|
+
* The verbatim bytes + absolute url, present ONLY on an `@Endpoint(..., { rawBody: true })`
|
|
27
|
+
* route (see {@link RawRequest}). Absent everywhere else, and absent is the SAFE state:
|
|
28
|
+
* `@AuthWebhook` has nothing to verify without it and 401s rather than waving the call
|
|
29
|
+
* through. A spec driving a webhook route in-process supplies one here, the same way a spec
|
|
30
|
+
* today supplies an `authorization` header.
|
|
31
|
+
*/
|
|
32
|
+
raw) {
|
|
24
33
|
this.method = method;
|
|
25
34
|
this.path = path;
|
|
26
35
|
this.headers = headers;
|
|
36
|
+
this.raw = raw;
|
|
27
37
|
}
|
|
28
38
|
/** First value of a header, looked up by ContextKey.httpHeader (or a raw lowercased name). */
|
|
29
39
|
getHeader(key) {
|
package/src/HttpRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpRequest.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/HttpRequest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"HttpRequest.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/HttpRequest.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;GAYG;AACH,MAAa,WAAW;IAEA;IACA;IAEA;IAQA;IAZpB,YACoB,MAAc,EACd,IAAY;IAC5B,iFAAiF;IACjE,OAA8B;IAC9C;;;;;;OAMG;IACa,GAAgB;QAXhB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,YAAO,GAAP,OAAO,CAAuB;QAQ9B,QAAG,GAAH,GAAG,CAAa;IACjC,CAAC;IAEJ,8FAA8F;IAC9F,SAAS,CAAC,GAA2B;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,CAAC;IAED,8BAA8B;IAC9B,eAAe,CAAC,GAA2B;QACvC,MAAM,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AA3BD,kCA2BC","sourcesContent":["import { ContextKey, AnyContextKey } from '@webpieces/core-util';\nimport { RawRequest } from './RawRequest';\n\n/**\n * HttpRequest - webpieces' TRANSPORT-NEUTRAL inbound request.\n *\n * This is @webpieces/http-routing's own request type (http-routing re-exports it), NOT\n * express's `req`. Each transport adapter (the express adapter in @webpieces/http-server, or\n * any other TypeScript web framework) builds an HttpRequest from its native request and hands\n * it to the router. Filters and the auth layer read it via `RequestContext.getRequest()`\n * instead of touching express — which is what lets the SAME filter chain run over HTTP and\n * in-process (tests build an HttpRequest carrying their credential).\n *\n * It lives in core-context (alongside RequestContext, which stores it in AsyncLocalStorage)\n * to avoid a core-context → http-routing cycle; it is a pure data holder (no express, no DI).\n */\nexport class HttpRequest {\n constructor(\n public readonly method: string,\n public readonly path: string,\n /** Header name (lowercased) -> values (HTTP allows multiple values per name). */\n public readonly headers: Map<string, string[]>,\n /**\n * The verbatim bytes + absolute url, present ONLY on an `@Endpoint(..., { rawBody: true })`\n * route (see {@link RawRequest}). Absent everywhere else, and absent is the SAFE state:\n * `@AuthWebhook` has nothing to verify without it and 401s rather than waving the call\n * through. A spec driving a webhook route in-process supplies one here, the same way a spec\n * today supplies an `authorization` header.\n */\n public readonly raw?: RawRequest,\n ) {}\n\n /** First value of a header, looked up by ContextKey.httpHeader (or a raw lowercased name). */\n getHeader(key: AnyContextKey | string): string | undefined {\n const values = this.getHeaderValues(key);\n return values && values.length > 0 ? values[0] : undefined;\n }\n\n /** All values of a header. */\n getHeaderValues(key: AnyContextKey | string): string[] | undefined {\n const name = (typeof key === 'string' ? key : key.httpHeader ?? key.name).toLowerCase();\n return this.headers.get(name);\n }\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RawRequest - the parts of an inbound request a SIGNATURE is computed over, retained verbatim.
|
|
3
|
+
*
|
|
4
|
+
* It exists because every signed webhook (Sentry, GitHub, Stripe, Slack, Twilio) verifies a
|
|
5
|
+
* derivation over what the SENDER transmitted, and the ordinary request path destroys exactly that:
|
|
6
|
+
* the body is parsed into a DTO and the bytes are dropped. Re-stringifying the DTO is NOT a
|
|
7
|
+
* substitute — `JSON.stringify` of a parsed object differs from the wire bytes in non-ASCII escaping,
|
|
8
|
+
* number formatting (`1e3` vs `1000`) and duplicate-key resolution, so a check built on it passes
|
|
9
|
+
* every test and then 401s the first payload containing an emoji. Worse than no check.
|
|
10
|
+
*
|
|
11
|
+
* It is REQUEST-shaped rather than body-shaped on purpose. Twilio — the vendor this framework already
|
|
12
|
+
* built `formPost` for — signs the absolute URL plus the sorted POST params, not the raw body at all,
|
|
13
|
+
* so a seam that handed out only `rawBody` could not verify it.
|
|
14
|
+
*
|
|
15
|
+
* Retained ONLY for an `@Endpoint(..., { rawBody: true })` route, so the cost lands on webhook routes
|
|
16
|
+
* instead of on every request in the process.
|
|
17
|
+
*
|
|
18
|
+
* Per CLAUDE.md: data-only, therefore a class.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RawRequest {
|
|
21
|
+
/**
|
|
22
|
+
* The ABSOLUTE url as the SENDER addressed it — scheme + host + path + query.
|
|
23
|
+
*
|
|
24
|
+
* Behind a TLS-terminating proxy (Cloud Run, any load balancer) express's own view is wrong
|
|
25
|
+
* in both halves: `req.protocol` reads `http` and the host is the internal one, while Twilio
|
|
26
|
+
* signs the public `https://...` url the customer configured. The express adapter therefore
|
|
27
|
+
* builds this from `x-forwarded-proto` / `x-forwarded-host` when present, falling back to
|
|
28
|
+
* `req.protocol` / the Host header. That is the ONE reconstruction rule; an app that fronts
|
|
29
|
+
* itself with something rewriting neither header gets a signature mismatch, so the rule is
|
|
30
|
+
* stated here rather than left for each app to guess at.
|
|
31
|
+
*/
|
|
32
|
+
readonly absoluteUrl: string;
|
|
33
|
+
/**
|
|
34
|
+
* The exact transmitted bytes. A Buffer, not a string: some schemes sign bytes, and a string
|
|
35
|
+
* would bake in a UTF-8 decode that corrupts a non-UTF-8 body before the app ever sees it.
|
|
36
|
+
*/
|
|
37
|
+
readonly rawBody: Buffer;
|
|
38
|
+
/** The peer address, when the transport knows it. Some vendors also publish IP ranges. */
|
|
39
|
+
readonly remoteAddr?: string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Set when the body could NOT be parsed, instead of failing the request then and there.
|
|
42
|
+
*
|
|
43
|
+
* The failure is HELD so that AUTHENTICATION answers first. A malformed body from an
|
|
44
|
+
* unauthenticated caller must be a 401, not a 400 — a 400 says "your JSON was bad", which
|
|
45
|
+
* says "I got past auth", which is a free oracle on an endpoint whose url is public by
|
|
46
|
+
* construction. `AuthFilter` rethrows it as a 400 once, and only once, the caller is proven.
|
|
47
|
+
*/
|
|
48
|
+
readonly bodyParseError?: Error | undefined;
|
|
49
|
+
constructor(
|
|
50
|
+
/**
|
|
51
|
+
* The ABSOLUTE url as the SENDER addressed it — scheme + host + path + query.
|
|
52
|
+
*
|
|
53
|
+
* Behind a TLS-terminating proxy (Cloud Run, any load balancer) express's own view is wrong
|
|
54
|
+
* in both halves: `req.protocol` reads `http` and the host is the internal one, while Twilio
|
|
55
|
+
* signs the public `https://...` url the customer configured. The express adapter therefore
|
|
56
|
+
* builds this from `x-forwarded-proto` / `x-forwarded-host` when present, falling back to
|
|
57
|
+
* `req.protocol` / the Host header. That is the ONE reconstruction rule; an app that fronts
|
|
58
|
+
* itself with something rewriting neither header gets a signature mismatch, so the rule is
|
|
59
|
+
* stated here rather than left for each app to guess at.
|
|
60
|
+
*/
|
|
61
|
+
absoluteUrl: string,
|
|
62
|
+
/**
|
|
63
|
+
* The exact transmitted bytes. A Buffer, not a string: some schemes sign bytes, and a string
|
|
64
|
+
* would bake in a UTF-8 decode that corrupts a non-UTF-8 body before the app ever sees it.
|
|
65
|
+
*/
|
|
66
|
+
rawBody: Buffer,
|
|
67
|
+
/** The peer address, when the transport knows it. Some vendors also publish IP ranges. */
|
|
68
|
+
remoteAddr?: string | undefined,
|
|
69
|
+
/**
|
|
70
|
+
* Set when the body could NOT be parsed, instead of failing the request then and there.
|
|
71
|
+
*
|
|
72
|
+
* The failure is HELD so that AUTHENTICATION answers first. A malformed body from an
|
|
73
|
+
* unauthenticated caller must be a 401, not a 400 — a 400 says "your JSON was bad", which
|
|
74
|
+
* says "I got past auth", which is a free oracle on an endpoint whose url is public by
|
|
75
|
+
* construction. `AuthFilter` rethrows it as a 400 once, and only once, the caller is proven.
|
|
76
|
+
*/
|
|
77
|
+
bodyParseError?: Error | undefined);
|
|
78
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawRequest = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* RawRequest - the parts of an inbound request a SIGNATURE is computed over, retained verbatim.
|
|
6
|
+
*
|
|
7
|
+
* It exists because every signed webhook (Sentry, GitHub, Stripe, Slack, Twilio) verifies a
|
|
8
|
+
* derivation over what the SENDER transmitted, and the ordinary request path destroys exactly that:
|
|
9
|
+
* the body is parsed into a DTO and the bytes are dropped. Re-stringifying the DTO is NOT a
|
|
10
|
+
* substitute — `JSON.stringify` of a parsed object differs from the wire bytes in non-ASCII escaping,
|
|
11
|
+
* number formatting (`1e3` vs `1000`) and duplicate-key resolution, so a check built on it passes
|
|
12
|
+
* every test and then 401s the first payload containing an emoji. Worse than no check.
|
|
13
|
+
*
|
|
14
|
+
* It is REQUEST-shaped rather than body-shaped on purpose. Twilio — the vendor this framework already
|
|
15
|
+
* built `formPost` for — signs the absolute URL plus the sorted POST params, not the raw body at all,
|
|
16
|
+
* so a seam that handed out only `rawBody` could not verify it.
|
|
17
|
+
*
|
|
18
|
+
* Retained ONLY for an `@Endpoint(..., { rawBody: true })` route, so the cost lands on webhook routes
|
|
19
|
+
* instead of on every request in the process.
|
|
20
|
+
*
|
|
21
|
+
* Per CLAUDE.md: data-only, therefore a class.
|
|
22
|
+
*/
|
|
23
|
+
class RawRequest {
|
|
24
|
+
absoluteUrl;
|
|
25
|
+
rawBody;
|
|
26
|
+
remoteAddr;
|
|
27
|
+
bodyParseError;
|
|
28
|
+
constructor(
|
|
29
|
+
/**
|
|
30
|
+
* The ABSOLUTE url as the SENDER addressed it — scheme + host + path + query.
|
|
31
|
+
*
|
|
32
|
+
* Behind a TLS-terminating proxy (Cloud Run, any load balancer) express's own view is wrong
|
|
33
|
+
* in both halves: `req.protocol` reads `http` and the host is the internal one, while Twilio
|
|
34
|
+
* signs the public `https://...` url the customer configured. The express adapter therefore
|
|
35
|
+
* builds this from `x-forwarded-proto` / `x-forwarded-host` when present, falling back to
|
|
36
|
+
* `req.protocol` / the Host header. That is the ONE reconstruction rule; an app that fronts
|
|
37
|
+
* itself with something rewriting neither header gets a signature mismatch, so the rule is
|
|
38
|
+
* stated here rather than left for each app to guess at.
|
|
39
|
+
*/
|
|
40
|
+
absoluteUrl,
|
|
41
|
+
/**
|
|
42
|
+
* The exact transmitted bytes. A Buffer, not a string: some schemes sign bytes, and a string
|
|
43
|
+
* would bake in a UTF-8 decode that corrupts a non-UTF-8 body before the app ever sees it.
|
|
44
|
+
*/
|
|
45
|
+
rawBody,
|
|
46
|
+
/** The peer address, when the transport knows it. Some vendors also publish IP ranges. */
|
|
47
|
+
remoteAddr,
|
|
48
|
+
/**
|
|
49
|
+
* Set when the body could NOT be parsed, instead of failing the request then and there.
|
|
50
|
+
*
|
|
51
|
+
* The failure is HELD so that AUTHENTICATION answers first. A malformed body from an
|
|
52
|
+
* unauthenticated caller must be a 401, not a 400 — a 400 says "your JSON was bad", which
|
|
53
|
+
* says "I got past auth", which is a free oracle on an endpoint whose url is public by
|
|
54
|
+
* construction. `AuthFilter` rethrows it as a 400 once, and only once, the caller is proven.
|
|
55
|
+
*/
|
|
56
|
+
bodyParseError) {
|
|
57
|
+
this.absoluteUrl = absoluteUrl;
|
|
58
|
+
this.rawBody = rawBody;
|
|
59
|
+
this.remoteAddr = remoteAddr;
|
|
60
|
+
this.bodyParseError = bodyParseError;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RawRequest = RawRequest;
|
|
64
|
+
//# sourceMappingURL=RawRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawRequest.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/RawRequest.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,UAAU;IAaC;IAKA;IAEA;IASA;IA5BpB;IACI;;;;;;;;;;OAUG;IACa,WAAmB;IACnC;;;OAGG;IACa,OAAe;IAC/B,0FAA0F;IAC1E,UAAmB;IACnC;;;;;;;OAOG;IACa,cAAsB;QAhBtB,gBAAW,GAAX,WAAW,CAAQ;QAKnB,YAAO,GAAP,OAAO,CAAQ;QAEf,eAAU,GAAV,UAAU,CAAS;QASnB,mBAAc,GAAd,cAAc,CAAQ;IACvC,CAAC;CACP;AA/BD,gCA+BC","sourcesContent":["/**\n * RawRequest - the parts of an inbound request a SIGNATURE is computed over, retained verbatim.\n *\n * It exists because every signed webhook (Sentry, GitHub, Stripe, Slack, Twilio) verifies a\n * derivation over what the SENDER transmitted, and the ordinary request path destroys exactly that:\n * the body is parsed into a DTO and the bytes are dropped. Re-stringifying the DTO is NOT a\n * substitute — `JSON.stringify` of a parsed object differs from the wire bytes in non-ASCII escaping,\n * number formatting (`1e3` vs `1000`) and duplicate-key resolution, so a check built on it passes\n * every test and then 401s the first payload containing an emoji. Worse than no check.\n *\n * It is REQUEST-shaped rather than body-shaped on purpose. Twilio — the vendor this framework already\n * built `formPost` for — signs the absolute URL plus the sorted POST params, not the raw body at all,\n * so a seam that handed out only `rawBody` could not verify it.\n *\n * Retained ONLY for an `@Endpoint(..., { rawBody: true })` route, so the cost lands on webhook routes\n * instead of on every request in the process.\n *\n * Per CLAUDE.md: data-only, therefore a class.\n */\nexport class RawRequest {\n constructor(\n /**\n * The ABSOLUTE url as the SENDER addressed it — scheme + host + path + query.\n *\n * Behind a TLS-terminating proxy (Cloud Run, any load balancer) express's own view is wrong\n * in both halves: `req.protocol` reads `http` and the host is the internal one, while Twilio\n * signs the public `https://...` url the customer configured. The express adapter therefore\n * builds this from `x-forwarded-proto` / `x-forwarded-host` when present, falling back to\n * `req.protocol` / the Host header. That is the ONE reconstruction rule; an app that fronts\n * itself with something rewriting neither header gets a signature mismatch, so the rule is\n * stated here rather than left for each app to guess at.\n */\n public readonly absoluteUrl: string,\n /**\n * The exact transmitted bytes. A Buffer, not a string: some schemes sign bytes, and a string\n * would bake in a UTF-8 decode that corrupts a non-UTF-8 body before the app ever sees it.\n */\n public readonly rawBody: Buffer,\n /** The peer address, when the transport knows it. Some vendors also publish IP ranges. */\n public readonly remoteAddr?: string,\n /**\n * Set when the body could NOT be parsed, instead of failing the request then and there.\n *\n * The failure is HELD so that AUTHENTICATION answers first. A malformed body from an\n * unauthenticated caller must be a 401, not a 400 — a 400 says \"your JSON was bad\", which\n * says \"I got past auth\", which is a free oracle on an endpoint whose url is public by\n * construction. `AuthFilter` rethrows it as a 400 once, and only once, the caller is proven.\n */\n public readonly bodyParseError?: Error,\n ) {}\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { CapturedContext } from './CapturedContext';
|
|
|
3
3
|
export type { RestorableContext } from './CapturedContext';
|
|
4
4
|
export { RequestContextApiCallContext } from './RequestContextApiCallContext';
|
|
5
5
|
export { HttpRequest } from './HttpRequest';
|
|
6
|
+
export { RawRequest } from './RawRequest';
|
|
6
7
|
export { provideSingletonDefaultForApi } from './provide';
|
|
7
8
|
export { Provider } from './provide';
|
|
8
9
|
export { provideFrameworkSingleton, provideFrameworkSingletonDefaultForApi, provideFrameworkTransient, bindFrameworkProvider, buildFrameworkModule, } from './frameworkProvide';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PendingTrustedValue = exports.PendingWireTrust = exports.RequestContextReader = exports.RequestContextHeaders = exports.buildFrameworkModule = exports.bindFrameworkProvider = exports.provideFrameworkTransient = exports.provideFrameworkSingletonDefaultForApi = exports.provideFrameworkSingleton = exports.Provider = exports.provideSingletonDefaultForApi = exports.HttpRequest = exports.RequestContextApiCallContext = exports.RequestContext = void 0;
|
|
3
|
+
exports.PendingTrustedValue = exports.PendingWireTrust = exports.RequestContextReader = exports.RequestContextHeaders = exports.buildFrameworkModule = exports.bindFrameworkProvider = exports.provideFrameworkTransient = exports.provideFrameworkSingletonDefaultForApi = exports.provideFrameworkSingleton = exports.Provider = exports.provideSingletonDefaultForApi = exports.RawRequest = exports.HttpRequest = exports.RequestContextApiCallContext = exports.RequestContext = void 0;
|
|
4
4
|
// Context management with AsyncLocalStorage
|
|
5
5
|
var RequestContext_1 = require("./RequestContext");
|
|
6
6
|
Object.defineProperty(exports, "RequestContext", { enumerable: true, get: function () { return RequestContext_1.RequestContext; } });
|
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "RequestContextApiCallContext", { enumerable: tru
|
|
|
12
12
|
// Transport-neutral request stored in the context (http-routing's request type; re-exported there)
|
|
13
13
|
var HttpRequest_1 = require("./HttpRequest");
|
|
14
14
|
Object.defineProperty(exports, "HttpRequest", { enumerable: true, get: function () { return HttpRequest_1.HttpRequest; } });
|
|
15
|
+
// The verbatim bytes + absolute url a webhook SIGNATURE is computed over ({ rawBody: true } routes).
|
|
16
|
+
var RawRequest_1 = require("./RawRequest");
|
|
17
|
+
Object.defineProperty(exports, "RawRequest", { enumerable: true, get: function () { return RawRequest_1.RawRequest; } });
|
|
15
18
|
// DI provider decorators (shared DI seam; http-routing re-exports for back-compat)
|
|
16
19
|
var provide_1 = require("./provide");
|
|
17
20
|
Object.defineProperty(exports, "provideSingletonDefaultForApi", { enumerable: true, get: function () { return provide_1.provideSingletonDefaultForApi; } });
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/index.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAiBvB,oGAAoG;AACpG,uGAAuG;AACvG,4FAA4F;AAC5F,+EAA8E;AAArE,4IAAA,4BAA4B,OAAA;AACrC,mGAAmG;AACnG,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/index.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAiBvB,oGAAoG;AACpG,uGAAuG;AACvG,4FAA4F;AAC5F,+EAA8E;AAArE,4IAAA,4BAA4B,OAAA;AACrC,mGAAmG;AACnG,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qGAAqG;AACrG,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,mFAAmF;AACnF,qCAA0D;AAAjD,wHAAA,6BAA6B,OAAA;AACtC,2FAA2F;AAC3F,qCAAqC;AAA5B,mGAAA,QAAQ,OAAA;AACjB,sFAAsF;AACtF,wEAAwE;AACxE,uDAM4B;AALxB,6HAAA,yBAAyB,OAAA;AACzB,0IAAA,sCAAsC,OAAA;AACtC,6HAAA,yBAAyB,OAAA;AACzB,yHAAA,qBAAqB,OAAA;AACrB,wHAAA,oBAAoB,OAAA;AAIxB,mFAAmF;AACnF,yFAAyF;AACzF,yBAAyB;AACzB,EAAE;AACF,8FAA8F;AAC9F,2FAA2F;AAC3F,uDAAuD;AACvD,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,oGAAoG;AACpG,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,uDAA2E;AAAlE,oHAAA,gBAAgB,OAAA;AAAE,uHAAA,mBAAmB,OAAA","sourcesContent":["// Context management with AsyncLocalStorage\nexport { RequestContext } from './RequestContext';\n// The OPAQUE snapshot type that copyContext() produces and restoreContext()/runWithContext() accept.\n//\n// `export type`, NOT `export` — deliberately. Consumers need to NAME it (a field, a queue entry, a\n// parameter) and nothing more. A VALUE export would hand them the class object, and with it the static\n// `capture(...)`, whose capability token a cast can supply even though this barrel never exports the\n// token's type: `CapturedContext.capture(null as never, new Map([['userId','victim']]))` would compile\n// and forge a proven identity — the exact hole this whole change closes. A type-only export removes the\n// class object from the package surface, so there is no factory to reach and copyContext() really is\n// the only producer. (ContextCaptureAuthority is not exported here in any form.)\nexport type { CapturedContext } from './CapturedContext';\n// The narrowed snapshot — what withTrusted() / withoutTrusted() produce and what\n// runWithContext()/restoreContext() accept. A bare CapturedContext is NOT accepted by either, so every\n// call site states whether the proven identity travels with the work (`grep -rn withTrusted`) or is\n// deliberately dropped (`grep -rn withoutTrusted`). Type-only for the same reason as above: with no\n// class object on the surface there is no `of(...)` factory to reach, cast or not.\nexport type { RestorableContext } from './CapturedContext';\n// SERVER impl of the core-util ApiCallContext seam, bound to RequestContext. Importing it here runs\n// its install() side effect, so LogApiCall (core-util, browser-safe) stamps the real RequestContext on\n// a Node server without importing it. A browser never loads core-context → keeps the no-op.\nexport { RequestContextApiCallContext } from './RequestContextApiCallContext';\n// Transport-neutral request stored in the context (http-routing's request type; re-exported there)\nexport { HttpRequest } from './HttpRequest';\n// The verbatim bytes + absolute url a webhook SIGNATURE is computed over ({ rawBody: true } routes).\nexport { RawRequest } from './RawRequest';\n\n// DI provider decorators (shared DI seam; http-routing re-exports for back-compat)\nexport { provideSingletonDefaultForApi } from './provide';\n// Guice-style Provider<T> — lazy singleton OR fresh-per-get, decided by T's binding scope.\nexport { Provider } from './provide';\n// Framework-only DI registry (packages/** use these; keeps framework classes out of a\n// client's buildProviderModule() global scan). See frameworkProvide.ts.\nexport {\n provideFrameworkSingleton,\n provideFrameworkSingletonDefaultForApi,\n provideFrameworkTransient,\n bindFrameworkProvider,\n buildFrameworkModule,\n} from './frameworkProvide';\nexport type { FrameworkScope } from './frameworkProvide';\n\n// Outbound headers for a SERVER: reads RequestContext directly, fails fast outside\n// RequestContext.run(...). Server-side clients (http-client-node, cloudtasks-client) and\n// http-routing use THIS.\n//\n// ContextMgr is deliberately NOT re-exported. It is the browser's answer (an app-held store),\n// and only @webpieces/http-client-browser may name it — importing it here would let a node\n// package reach for a ContextReader it has no use for.\nexport { RequestContextHeaders } from './RequestContextHeaders';\n// The browser store's server counterpart, still used by the logging packages + http-server filters.\nexport { RequestContextReader } from './RequestContextReader';\nexport { PendingWireTrust, PendingTrustedValue } from './PendingWireTrust';\n"]}
|