@webpieces/core-context 0.4.710 → 0.4.711
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/core-context",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.711",
|
|
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.711",
|
|
26
26
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
27
27
|
"inversify": "7.10.4",
|
|
28
28
|
"reflect-metadata": "0.2.2"
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ApiCallContext, AnyUntrustedContextKey } from '@webpieces/core-util';
|
|
2
2
|
/**
|
|
3
3
|
* RequestContextApiCallContext - the SERVER (Node) implementation of the {@link ApiCallContext} seam,
|
|
4
|
-
* backing it with the ambient {@link RequestContext} (AsyncLocalStorage). {@link
|
|
4
|
+
* backing it with the ambient {@link RequestContext} (AsyncLocalStorage). {@link LogApiCallImpl} — which
|
|
5
5
|
* lives in browser-safe core-util and cannot import RequestContext — stamps its `api` tag through this.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* and `
|
|
9
|
-
* and
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* CONSTRUCTED, never installed: `LogApiFilter` (http-routing, inbound), `NodeProxyClient`
|
|
8
|
+
* (http-client-node, outbound http) and `TaskProxyClient` (cloudtasks-client, outbound enqueue) each
|
|
9
|
+
* build one and pass it to their own {@link LogApiCallImpl}. Every one of those packages is node-only
|
|
10
|
+
* and already depends on core-context, so none of them needs a startup hook — which is what lets a
|
|
11
|
+
* plain NestJS/Express host use a webpieces client with no webpieces STARTUP INSTALL. What it DOES
|
|
12
|
+
* still need is an open `RequestContext.run(...)` scope, because {@link isActive} is false outside one
|
|
13
|
+
* and LogApiCall throws on an inactive context. A browser never loads core-context; it builds a
|
|
14
|
+
* `BrowserApiCallContext` instead.
|
|
12
15
|
*
|
|
13
16
|
* WRITE-ONLY: the logging backends read the stamped key back off RequestContext
|
|
14
17
|
* (`buildStructuredLogFields`) on every record, so this seam only needs to set it.
|
|
@@ -4,14 +4,17 @@ exports.RequestContextApiCallContext = void 0;
|
|
|
4
4
|
const RequestContext_1 = require("./RequestContext");
|
|
5
5
|
/**
|
|
6
6
|
* RequestContextApiCallContext - the SERVER (Node) implementation of the {@link ApiCallContext} seam,
|
|
7
|
-
* backing it with the ambient {@link RequestContext} (AsyncLocalStorage). {@link
|
|
7
|
+
* backing it with the ambient {@link RequestContext} (AsyncLocalStorage). {@link LogApiCallImpl} — which
|
|
8
8
|
* lives in browser-safe core-util and cannot import RequestContext — stamps its `api` tag through this.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* and `
|
|
12
|
-
* and
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* CONSTRUCTED, never installed: `LogApiFilter` (http-routing, inbound), `NodeProxyClient`
|
|
11
|
+
* (http-client-node, outbound http) and `TaskProxyClient` (cloudtasks-client, outbound enqueue) each
|
|
12
|
+
* build one and pass it to their own {@link LogApiCallImpl}. Every one of those packages is node-only
|
|
13
|
+
* and already depends on core-context, so none of them needs a startup hook — which is what lets a
|
|
14
|
+
* plain NestJS/Express host use a webpieces client with no webpieces STARTUP INSTALL. What it DOES
|
|
15
|
+
* still need is an open `RequestContext.run(...)` scope, because {@link isActive} is false outside one
|
|
16
|
+
* and LogApiCall throws on an inactive context. A browser never loads core-context; it builds a
|
|
17
|
+
* `BrowserApiCallContext` instead.
|
|
15
18
|
*
|
|
16
19
|
* WRITE-ONLY: the logging backends read the stamped key back off RequestContext
|
|
17
20
|
* (`buildStructuredLogFields`) on every record, so this seam only needs to set it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContextApiCallContext.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/RequestContextApiCallContext.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAElD
|
|
1
|
+
{"version":3,"file":"RequestContextApiCallContext.js","sourceRoot":"","sources":["../../../../../packages/core/core-context/src/RequestContextApiCallContext.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAElD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,4BAA4B;IACrC,+FAA+F;IAC/F,QAAQ;QACJ,OAAO,+BAAc,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;IAED,gHAAgH;IAChH,GAAG,CAAC,UAAkC,EAAE,KAAc;QAClD,+BAAc,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,UAAkC;QACrC,+BAAc,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACJ;AAdD,oEAcC","sourcesContent":["import { ApiCallContext, AnyUntrustedContextKey } from '@webpieces/core-util';\nimport { RequestContext } from './RequestContext';\n\n/**\n * RequestContextApiCallContext - the SERVER (Node) implementation of the {@link ApiCallContext} seam,\n * backing it with the ambient {@link RequestContext} (AsyncLocalStorage). {@link LogApiCallImpl} — which\n * lives in browser-safe core-util and cannot import RequestContext — stamps its `api` tag through this.\n *\n * CONSTRUCTED, never installed: `LogApiFilter` (http-routing, inbound), `NodeProxyClient`\n * (http-client-node, outbound http) and `TaskProxyClient` (cloudtasks-client, outbound enqueue) each\n * build one and pass it to their own {@link LogApiCallImpl}. Every one of those packages is node-only\n * and already depends on core-context, so none of them needs a startup hook — which is what lets a\n * plain NestJS/Express host use a webpieces client with no webpieces STARTUP INSTALL. What it DOES\n * still need is an open `RequestContext.run(...)` scope, because {@link isActive} is false outside one\n * and LogApiCall throws on an inactive context. A browser never loads core-context; it builds a\n * `BrowserApiCallContext` instead.\n *\n * WRITE-ONLY: the logging backends read the stamped key back off RequestContext\n * (`buildStructuredLogFields`) on every record, so this seam only needs to set it.\n */\nexport class RequestContextApiCallContext implements ApiCallContext {\n /** A live request scope is required to stamp; LogApiCall checks this and throws when false. */\n isActive(): boolean {\n return RequestContext.isActive();\n }\n\n // webpieces-disable no-any-unknown -- a context value is heterogeneous (the api struct here; strings elsewhere)\n set(contextKey: AnyUntrustedContextKey, value: unknown): void {\n RequestContext.putUntrusted(contextKey, value);\n }\n\n remove(contextKey: AnyUntrustedContextKey): void {\n RequestContext.removeKey(contextKey);\n }\n}\n"]}
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.PendingTrustedValue = exports.PendingWireTrust = exports.RequestContextR
|
|
|
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; } });
|
|
7
|
-
// SERVER impl of the core-util ApiCallContext seam, bound to RequestContext.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// SERVER impl of the core-util ApiCallContext seam, bound to RequestContext. There is no install and
|
|
8
|
+
// no side effect: each node package that logs api calls (LogApiFilter, NodeProxyClient,
|
|
9
|
+
// TaskProxyClient) CONSTRUCTS one and hands it to its own LogApiCallImpl.
|
|
10
10
|
var RequestContextApiCallContext_1 = require("./RequestContextApiCallContext");
|
|
11
11
|
Object.defineProperty(exports, "RequestContextApiCallContext", { enumerable: true, get: function () { return RequestContextApiCallContext_1.RequestContextApiCallContext; } });
|
|
12
12
|
// Transport-neutral request stored in the context (http-routing's request type; re-exported there)
|
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,
|
|
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,qGAAqG;AACrG,wFAAwF;AACxF,0EAA0E;AAC1E,+EAA8E;AAArE,4IAAA,4BAA4B,OAAA;AACrC,mGAAmG;AACnG,6CAA4D;AAAnD,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. There is no install and\n// no side effect: each node package that logs api calls (LogApiFilter, NodeProxyClient,\n// TaskProxyClient) CONSTRUCTS one and hands it to its own LogApiCallImpl.\nexport { RequestContextApiCallContext } from './RequestContextApiCallContext';\n// Transport-neutral request stored in the context (http-routing's request type; re-exported there)\nexport { HttpRequest, RawHttpRequest } 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"]}
|