@webiny/api-composition-core 0.0.0-unstable.e1999482d0 → 6.6.0-alpha.13
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/auth/extractAuthToken.d.ts +3 -6
- package/auth/extractAuthToken.js +5 -4
- package/auth/extractAuthToken.js.map +1 -1
- package/auth/extractTenantId.d.ts +2 -1
- package/auth/extractTenantId.js +3 -3
- package/auth/extractTenantId.js.map +1 -1
- package/auth/index.d.ts +0 -2
- package/auth/index.js +0 -1
- package/auth/rejectedTokenResponse.d.ts +3 -6
- package/auth/rejectedTokenResponse.js +2 -6
- package/auth/rejectedTokenResponse.js.map +1 -1
- package/buildParams/registerRootBuildParams.d.ts +15 -0
- package/buildParams/registerRootBuildParams.js +11 -0
- package/buildParams/registerRootBuildParams.js.map +1 -0
- package/http/HttpAssumePermissionsDecorator.d.ts +19 -0
- package/http/HttpAssumePermissionsDecorator.js +22 -0
- package/http/HttpAssumePermissionsDecorator.js.map +1 -0
- package/http/HttpIdentityLoaderDecorator.d.ts +28 -0
- package/{nodeHttp/NodeHttpIdentityLoaderDecorator.js → http/HttpIdentityLoaderDecorator.js} +10 -15
- package/http/HttpIdentityLoaderDecorator.js.map +1 -0
- package/http/HttpInputTenantSource.d.ts +13 -0
- package/http/HttpInputTenantSource.js +11 -0
- package/http/HttpInputTenantSource.js.map +1 -0
- package/http/HttpRequestContextFeature.d.ts +20 -0
- package/http/HttpRequestContextFeature.js +13 -0
- package/http/HttpRequestContextFeature.js.map +1 -0
- package/http/HttpTenantScopeRouter.d.ts +33 -0
- package/http/HttpTenantScopeRouter.js +58 -0
- package/http/HttpTenantScopeRouter.js.map +1 -0
- package/http/index.d.ts +3 -0
- package/http/index.js +2 -0
- package/http/readStreamInScope.d.ts +12 -0
- package/http/readStreamInScope.js +43 -0
- package/http/readStreamInScope.js.map +1 -0
- package/http/registerHttpTransport.d.ts +23 -0
- package/http/registerHttpTransport.js +13 -0
- package/http/registerHttpTransport.js.map +1 -0
- package/http/registerRootAllowedRequestHeaders.d.ts +26 -0
- package/http/registerRootAllowedRequestHeaders.js +39 -0
- package/http/registerRootAllowedRequestHeaders.js.map +1 -0
- package/index.d.ts +4 -4
- package/index.js +4 -3
- package/package.json +26 -26
- package/registerApiRequestStack.d.ts +29 -6
- package/registerApiRequestStack.js +18 -5
- package/registerApiRequestStack.js.map +1 -1
- package/auth/getHeader.d.ts +0 -5
- package/auth/getHeader.js +0 -8
- package/auth/getHeader.js.map +0 -1
- package/buildParams/readBuildParams.d.ts +0 -10
- package/buildParams/readBuildParams.js +0 -13
- package/buildParams/readBuildParams.js.map +0 -1
- package/nodeHttp/NodeHttpAssumePermissionsDecorator.d.ts +0 -19
- package/nodeHttp/NodeHttpAssumePermissionsDecorator.js +0 -23
- package/nodeHttp/NodeHttpAssumePermissionsDecorator.js.map +0 -1
- package/nodeHttp/NodeHttpIdentityLoaderDecorator.d.ts +0 -34
- package/nodeHttp/NodeHttpIdentityLoaderDecorator.js.map +0 -1
- package/nodeHttp/NodeHttpTenantLoaderDecorator.d.ts +0 -24
- package/nodeHttp/NodeHttpTenantLoaderDecorator.js +0 -28
- package/nodeHttp/NodeHttpTenantLoaderDecorator.js.map +0 -1
- package/nodeHttp/headersFromIncomingMessage.d.ts +0 -6
- package/nodeHttp/headersFromIncomingMessage.js +0 -9
- package/nodeHttp/headersFromIncomingMessage.js.map +0 -1
- package/nodeHttp/index.d.ts +0 -3
- package/nodeHttp/index.js +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Abstraction, Container } from "@webiny/di";
|
|
2
|
+
import type { InputHandler } from "@webiny/api-kernel-core";
|
|
3
|
+
export interface IHttpTransportFeature {
|
|
4
|
+
register(container: Container): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Registers an HTTP transport feature (`ApiGatewayFeature`, `FunctionUrlStreamFeature`,
|
|
8
|
+
* `NodeHttpFeature`) together with the tenant, identity and assume-permissions loading every API
|
|
9
|
+
* request needs, in the one order that works. `inputHandler` is the transport's handler abstraction
|
|
10
|
+
* (`ApiGatewayInputHandler`, …).
|
|
11
|
+
*
|
|
12
|
+
* The request is handled at request level first, in no tenant's scope: compression, CORS, error
|
|
13
|
+
* responses, assume-permissions, then the tenant step. A CORS preflight is answered there, and an
|
|
14
|
+
* unknown or disabled tenant fails there, without building a scope. Only then does the request enter
|
|
15
|
+
* its tenant's scope (`HttpTenantScopeRouter`), where the identity loads and the route runs.
|
|
16
|
+
*
|
|
17
|
+
* `HttpRequestContextFeature` has to be registered first. A decorator registered earlier sits further
|
|
18
|
+
* inside, so its decorators then run inside `ErrorResponseDecorator` and `CorsHeadersDecorator`, which
|
|
19
|
+
* the transport feature registers through `HttpFeature`, and their responses and errors get the CORS
|
|
20
|
+
* headers. In the other order, a rejected token's 401 reaches the browser without them and reads as a
|
|
21
|
+
* CORS failure, and nothing else breaks to show it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerHttpTransport(container: Container, transport: IHttpTransportFeature, inputHandler: Abstraction<InputHandler.Interface>): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputTenantSource } from "@webiny/api-core/features/tenancy/TenantScopes/index.js";
|
|
2
|
+
import { HttpRequestContextFeature } from "./HttpRequestContextFeature.js";
|
|
3
|
+
import { HttpTenantScopeRouter } from "./HttpTenantScopeRouter.js";
|
|
4
|
+
import { HttpInputTenantSource } from "./HttpInputTenantSource.js";
|
|
5
|
+
function registerHttpTransport(container, transport, inputHandler) {
|
|
6
|
+
HttpRequestContextFeature.register(container);
|
|
7
|
+
transport.register(container);
|
|
8
|
+
container.register(HttpTenantScopeRouter);
|
|
9
|
+
container.registerInstance(InputTenantSource, new HttpInputTenantSource(inputHandler));
|
|
10
|
+
}
|
|
11
|
+
export { registerHttpTransport };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=registerHttpTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http/registerHttpTransport.js","sources":["../../src/http/registerHttpTransport.ts"],"sourcesContent":["import type { Abstraction, Container } from \"@webiny/di\";\nimport type { InputHandler } from \"@webiny/api-kernel-core\";\nimport { InputTenantSource } from \"@webiny/api-core/features/tenancy/TenantScopes/index.js\";\nimport { HttpRequestContextFeature } from \"./HttpRequestContextFeature.js\";\nimport { HttpTenantScopeRouter } from \"./HttpTenantScopeRouter.js\";\nimport { HttpInputTenantSource } from \"./HttpInputTenantSource.js\";\n\nexport interface IHttpTransportFeature {\n register(container: Container): void;\n}\n\n/**\n * Registers an HTTP transport feature (`ApiGatewayFeature`, `FunctionUrlStreamFeature`,\n * `NodeHttpFeature`) together with the tenant, identity and assume-permissions loading every API\n * request needs, in the one order that works. `inputHandler` is the transport's handler abstraction\n * (`ApiGatewayInputHandler`, …).\n *\n * The request is handled at request level first, in no tenant's scope: compression, CORS, error\n * responses, assume-permissions, then the tenant step. A CORS preflight is answered there, and an\n * unknown or disabled tenant fails there, without building a scope. Only then does the request enter\n * its tenant's scope (`HttpTenantScopeRouter`), where the identity loads and the route runs.\n *\n * `HttpRequestContextFeature` has to be registered first. A decorator registered earlier sits further\n * inside, so its decorators then run inside `ErrorResponseDecorator` and `CorsHeadersDecorator`, which\n * the transport feature registers through `HttpFeature`, and their responses and errors get the CORS\n * headers. In the other order, a rejected token's 401 reaches the browser without them and reads as a\n * CORS failure, and nothing else breaks to show it.\n */\nexport function registerHttpTransport(\n container: Container,\n transport: IHttpTransportFeature,\n inputHandler: Abstraction<InputHandler.Interface>\n): void {\n HttpRequestContextFeature.register(container);\n transport.register(container);\n // Registered after HttpFeature, so it replaces the route matcher as HttpRouter's implementation.\n container.register(HttpTenantScopeRouter);\n // The transport's handler chain stays at request level; the router enters the tenant's scope.\n container.registerInstance(InputTenantSource, new HttpInputTenantSource(inputHandler));\n}\n"],"names":["registerHttpTransport","container","transport","inputHandler","HttpRequestContextFeature","HttpTenantScopeRouter","InputTenantSource","HttpInputTenantSource"],"mappings":";;;;AA4BO,SAASA,sBACZC,SAAoB,EACpBC,SAAgC,EAChCC,YAAiD;IAEjDC,0BAA0B,QAAQ,CAACH;IACnCC,UAAU,QAAQ,CAACD;IAEnBA,UAAU,QAAQ,CAACI;IAEnBJ,UAAU,gBAAgB,CAACK,mBAAmB,IAAIC,sBAAsBJ;AAC5E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
2
|
+
export declare class AllowedRequestHeadersError extends Error {
|
|
3
|
+
constructor(cause: unknown);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Registers, in the root container, the request headers the project's extensions allow in the CORS
|
|
7
|
+
* preflight answer (`HttpAllowedRequestHeaders`), as one list.
|
|
8
|
+
*
|
|
9
|
+
* `CorsHeadersDecorator` answers a preflight at request level, before any tenant scope exists, but
|
|
10
|
+
* extensions register in each tenant scope, where it can't see them. The list comes from the deploy's
|
|
11
|
+
* code and a preflight carries no tenant, so it is the same for every request and tenant: it is read
|
|
12
|
+
* once per process, when the root container is built (a Lambda's cold start, the standalone server's
|
|
13
|
+
* start).
|
|
14
|
+
*
|
|
15
|
+
* An extension registers everything in one callback, and may use what a request has while it
|
|
16
|
+
* registers (feature flags, for one). So a throwaway child of the root gets what a request has, the
|
|
17
|
+
* extensions included (`ApiRequestRegistration`), the allowed headers are read from it, and it is
|
|
18
|
+
* dropped. Registration is lazy: only the allowed-headers implementations are built there, with no
|
|
19
|
+
* tenant and no identity, so they must not depend on either: one that can't be built fails the start.
|
|
20
|
+
*
|
|
21
|
+
* A request's registration that fails there would fail every request the same way, which reports it.
|
|
22
|
+
* Here it is logged as a warning, and only the headers registered before it failed are allowed.
|
|
23
|
+
*
|
|
24
|
+
* Call it last in the root, once `ApiRequestRegistration` and the root's services are registered.
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerRootAllowedRequestHeaders(root: Container): Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HttpAllowedRequestHeaders } from "@webiny/api-kernel-core";
|
|
2
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
3
|
+
import { ApiRequestRegistration } from "../requestRegistration/index.js";
|
|
4
|
+
class AllowedRequestHeadersError extends Error {
|
|
5
|
+
constructor(cause){
|
|
6
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
7
|
+
super([
|
|
8
|
+
"Could not read the request headers the project's extensions allow in CORS (HttpAllowedRequestHeaders).",
|
|
9
|
+
"They are read once per process, at start, in a container that has a request's services but no",
|
|
10
|
+
`tenant and no identity. ${reason}`
|
|
11
|
+
].join(" "), {
|
|
12
|
+
cause
|
|
13
|
+
});
|
|
14
|
+
this.name = "AllowedRequestHeadersError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function registerRootAllowedRequestHeaders(root) {
|
|
18
|
+
const throwaway = root.createChildContainer();
|
|
19
|
+
try {
|
|
20
|
+
await root.resolve(ApiRequestRegistration).register(throwaway);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
const [logger] = root.resolveAll(Logger);
|
|
23
|
+
logger?.warn({
|
|
24
|
+
error: error instanceof Error ? error.message : String(error)
|
|
25
|
+
}, "[cors] Registering a request's services failed while the CORS allowed headers were read, at start. Only headers registered before the failure are allowed.");
|
|
26
|
+
}
|
|
27
|
+
let headers;
|
|
28
|
+
try {
|
|
29
|
+
headers = throwaway.resolveAll(HttpAllowedRequestHeaders).flatMap((item)=>item.headers);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new AllowedRequestHeadersError(error);
|
|
32
|
+
}
|
|
33
|
+
root.registerInstance(HttpAllowedRequestHeaders, {
|
|
34
|
+
headers
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { AllowedRequestHeadersError, registerRootAllowedRequestHeaders };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=registerRootAllowedRequestHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http/registerRootAllowedRequestHeaders.js","sources":["../../src/http/registerRootAllowedRequestHeaders.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { HttpAllowedRequestHeaders } from \"@webiny/api-kernel-core\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { ApiRequestRegistration } from \"~/requestRegistration/index.js\";\n\nexport class AllowedRequestHeadersError extends Error {\n constructor(cause: unknown) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n super(\n [\n `Could not read the request headers the project's extensions allow in CORS (HttpAllowedRequestHeaders).`,\n `They are read once per process, at start, in a container that has a request's services but no`,\n `tenant and no identity. ${reason}`\n ].join(\" \"),\n { cause }\n );\n this.name = \"AllowedRequestHeadersError\";\n }\n}\n\n/**\n * Registers, in the root container, the request headers the project's extensions allow in the CORS\n * preflight answer (`HttpAllowedRequestHeaders`), as one list.\n *\n * `CorsHeadersDecorator` answers a preflight at request level, before any tenant scope exists, but\n * extensions register in each tenant scope, where it can't see them. The list comes from the deploy's\n * code and a preflight carries no tenant, so it is the same for every request and tenant: it is read\n * once per process, when the root container is built (a Lambda's cold start, the standalone server's\n * start).\n *\n * An extension registers everything in one callback, and may use what a request has while it\n * registers (feature flags, for one). So a throwaway child of the root gets what a request has, the\n * extensions included (`ApiRequestRegistration`), the allowed headers are read from it, and it is\n * dropped. Registration is lazy: only the allowed-headers implementations are built there, with no\n * tenant and no identity, so they must not depend on either: one that can't be built fails the start.\n *\n * A request's registration that fails there would fail every request the same way, which reports it.\n * Here it is logged as a warning, and only the headers registered before it failed are allowed.\n *\n * Call it last in the root, once `ApiRequestRegistration` and the root's services are registered.\n */\nexport async function registerRootAllowedRequestHeaders(root: Container): Promise<void> {\n const throwaway = root.createChildContainer();\n try {\n await root.resolve(ApiRequestRegistration).register(throwaway);\n } catch (error) {\n const [logger] = root.resolveAll(Logger);\n logger?.warn(\n { error: error instanceof Error ? error.message : String(error) },\n \"[cors] Registering a request's services failed while the CORS allowed headers were read, at start. Only headers registered before the failure are allowed.\"\n );\n }\n\n let headers: string[];\n try {\n headers = throwaway.resolveAll(HttpAllowedRequestHeaders).flatMap(item => item.headers);\n } catch (error) {\n throw new AllowedRequestHeadersError(error);\n }\n root.registerInstance(HttpAllowedRequestHeaders, { headers });\n}\n"],"names":["AllowedRequestHeadersError","Error","cause","reason","String","registerRootAllowedRequestHeaders","root","throwaway","ApiRequestRegistration","error","logger","Logger","headers","HttpAllowedRequestHeaders","item"],"mappings":";;;AAKO,MAAMA,mCAAmCC;IAC5C,YAAYC,KAAc,CAAE;QACxB,MAAMC,SAASD,iBAAiBD,QAAQC,MAAM,OAAO,GAAGE,OAAOF;QAC/D,KAAK,CACD;YACI;YACA;YACA,CAAC,wBAAwB,EAAEC,QAAQ;SACtC,CAAC,IAAI,CAAC,MACP;YAAED;QAAM;QAEZ,IAAI,CAAC,IAAI,GAAG;IAChB;AACJ;AAuBO,eAAeG,kCAAkCC,IAAe;IACnE,MAAMC,YAAYD,KAAK,oBAAoB;IAC3C,IAAI;QACA,MAAMA,KAAK,OAAO,CAACE,wBAAwB,QAAQ,CAACD;IACxD,EAAE,OAAOE,OAAO;QACZ,MAAM,CAACC,OAAO,GAAGJ,KAAK,UAAU,CAACK;QACjCD,QAAQ,KACJ;YAAE,OAAOD,iBAAiBR,QAAQQ,MAAM,OAAO,GAAGL,OAAOK;QAAO,GAChE;IAER;IAEA,IAAIG;IACJ,IAAI;QACAA,UAAUL,UAAU,UAAU,CAACM,2BAA2B,OAAO,CAACC,CAAAA,OAAQA,KAAK,OAAO;IAC1F,EAAE,OAAOL,OAAO;QACZ,MAAM,IAAIT,2BAA2BS;IACzC;IACAH,KAAK,gBAAgB,CAACO,2BAA2B;QAAED;IAAQ;AAC/D"}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { registerApiRequestStack } from "./registerApiRequestStack.js";
|
|
1
|
+
export { registerApiRequestStack, registerApiRequestStackInOneContainer, registerApiTenantScope } from "./registerApiRequestStack.js";
|
|
2
2
|
export type { RegisterApiRequestStackConfig } from "./registerApiRequestStack.js";
|
|
3
3
|
export { createLogger } from "./logger/createLogger.js";
|
|
4
4
|
export { extractAuthToken, isCookieAuthenticationAllowed } from "./auth/index.js";
|
|
5
|
-
export type { AuthTokenRequest } from "./auth/index.js";
|
|
6
5
|
export { extractTenantId } from "./auth/index.js";
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
6
|
+
export { registerHttpTransport, registerRootAllowedRequestHeaders, AllowedRequestHeadersError } from "./http/index.js";
|
|
7
|
+
export type { IHttpTransportFeature } from "./http/index.js";
|
|
8
|
+
export { registerRootBuildParams } from "./buildParams/registerRootBuildParams.js";
|
|
9
9
|
export { ApiRequestRegistration } from "./requestRegistration/index.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { registerApiRequestStack } from "./registerApiRequestStack.js";
|
|
1
|
+
export { registerApiRequestStack, registerApiRequestStackInOneContainer, registerApiTenantScope } from "./registerApiRequestStack.js";
|
|
2
2
|
export { createLogger } from "./logger/createLogger.js";
|
|
3
|
-
export { extractAuthToken, extractTenantId, isCookieAuthenticationAllowed
|
|
4
|
-
export {
|
|
3
|
+
export { extractAuthToken, extractTenantId, isCookieAuthenticationAllowed } from "./auth/index.js";
|
|
4
|
+
export { AllowedRequestHeadersError, registerHttpTransport, registerRootAllowedRequestHeaders } from "./http/index.js";
|
|
5
|
+
export { registerRootBuildParams } from "./buildParams/registerRootBuildParams.js";
|
|
5
6
|
export { ApiRequestRegistration } from "./requestRegistration/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-composition-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.6.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -18,30 +18,30 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api-aco": "
|
|
22
|
-
"@webiny/api-audit-logs": "
|
|
23
|
-
"@webiny/api-core": "
|
|
24
|
-
"@webiny/api-dashboard": "
|
|
25
|
-
"@webiny/api-file-manager": "
|
|
26
|
-
"@webiny/api-file-manager-aco": "
|
|
27
|
-
"@webiny/api-graphql": "
|
|
28
|
-
"@webiny/api-headless-cms": "
|
|
29
|
-
"@webiny/api-headless-cms-aco": "
|
|
30
|
-
"@webiny/api-headless-cms-scheduler": "
|
|
31
|
-
"@webiny/api-headless-cms-tasks": "
|
|
32
|
-
"@webiny/api-headless-cms-workflows": "
|
|
33
|
-
"@webiny/api-kernel-core": "
|
|
34
|
-
"@webiny/api-mailer": "
|
|
35
|
-
"@webiny/api-record-locking": "
|
|
36
|
-
"@webiny/api-scheduler": "
|
|
37
|
-
"@webiny/api-website-builder": "
|
|
38
|
-
"@webiny/api-website-builder-scheduler": "
|
|
39
|
-
"@webiny/api-website-builder-workflows": "
|
|
40
|
-
"@webiny/api-websockets": "
|
|
41
|
-
"@webiny/api-workflows": "
|
|
42
|
-
"@webiny/background-tasks": "
|
|
43
|
-
"@webiny/feature": "
|
|
44
|
-
"@webiny/handler": "
|
|
21
|
+
"@webiny/api-aco": "6.6.0-alpha.13",
|
|
22
|
+
"@webiny/api-audit-logs": "6.6.0-alpha.13",
|
|
23
|
+
"@webiny/api-core": "6.6.0-alpha.13",
|
|
24
|
+
"@webiny/api-dashboard": "6.6.0-alpha.13",
|
|
25
|
+
"@webiny/api-file-manager": "6.6.0-alpha.13",
|
|
26
|
+
"@webiny/api-file-manager-aco": "6.6.0-alpha.13",
|
|
27
|
+
"@webiny/api-graphql": "6.6.0-alpha.13",
|
|
28
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.13",
|
|
29
|
+
"@webiny/api-headless-cms-aco": "6.6.0-alpha.13",
|
|
30
|
+
"@webiny/api-headless-cms-scheduler": "6.6.0-alpha.13",
|
|
31
|
+
"@webiny/api-headless-cms-tasks": "6.6.0-alpha.13",
|
|
32
|
+
"@webiny/api-headless-cms-workflows": "6.6.0-alpha.13",
|
|
33
|
+
"@webiny/api-kernel-core": "6.6.0-alpha.13",
|
|
34
|
+
"@webiny/api-mailer": "6.6.0-alpha.13",
|
|
35
|
+
"@webiny/api-record-locking": "6.6.0-alpha.13",
|
|
36
|
+
"@webiny/api-scheduler": "6.6.0-alpha.13",
|
|
37
|
+
"@webiny/api-website-builder": "6.6.0-alpha.13",
|
|
38
|
+
"@webiny/api-website-builder-scheduler": "6.6.0-alpha.13",
|
|
39
|
+
"@webiny/api-website-builder-workflows": "6.6.0-alpha.13",
|
|
40
|
+
"@webiny/api-websockets": "6.6.0-alpha.13",
|
|
41
|
+
"@webiny/api-workflows": "6.6.0-alpha.13",
|
|
42
|
+
"@webiny/background-tasks": "6.6.0-alpha.13",
|
|
43
|
+
"@webiny/feature": "6.6.0-alpha.13",
|
|
44
|
+
"@webiny/handler": "6.6.0-alpha.13",
|
|
45
45
|
"pino": "10.4.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/jsonwebtoken": "9.0.10",
|
|
52
|
-
"@webiny/build-tools": "
|
|
52
|
+
"@webiny/build-tools": "6.6.0-alpha.13",
|
|
53
53
|
"@webiny/di": "2.0.0",
|
|
54
54
|
"jsonwebtoken": "9.0.3",
|
|
55
55
|
"rimraf": "6.1.4",
|
|
@@ -41,18 +41,41 @@ export interface RegisterApiRequestStackConfig {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Registers the transport-AGNOSTIC Webiny API request stack
|
|
45
|
-
*
|
|
46
|
-
* packages (`@webiny/api-composition-aws`, and the future `-server`) so the feature set and its
|
|
44
|
+
* Registers the transport-AGNOSTIC Webiny API request stack. This is shared by all transport
|
|
45
|
+
* composition packages (`@webiny/api-composition-aws`, `-standalone`) so the feature set and its
|
|
47
46
|
* ordering live in ONE place and can't drift between transports.
|
|
48
47
|
*
|
|
48
|
+
* The request container gets only the tenant-neutral part: the raw request values, the tenant
|
|
49
|
+
* registry the request's tenant is loaded from, and `TenantScopes`. Build params come from the
|
|
50
|
+
* deploy, the same for every request and tenant, so the transport registers them once in the root
|
|
51
|
+
* (`registerRootBuildParams`), before any request registers a feature that reads them (features
|
|
52
|
+
* gate themselves on `FeatureFlags`, a build param, at register() time). Everything else is
|
|
53
|
+
* tenant-specific and registers in each tenant scope the request enters, through the
|
|
54
|
+
* `TenantScopeRegistration` registered here ({@link registerApiTenantScope}). The request's own work
|
|
55
|
+
* runs in its tenant's scope (`TenantScopesRootFeature`, which the transport registers in the root).
|
|
56
|
+
*
|
|
49
57
|
* Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}
|
|
50
58
|
* at their exact interleave points. The caller is responsible for the ROOT-container transport wiring
|
|
51
|
-
* (HTTP/event transport,
|
|
59
|
+
* (HTTP/event transport, tenant sources, identity loaders, DB + storage) before dispatch reaches
|
|
52
60
|
* this per-request stack. That includes the `Logger`: api-core registers none, so a root without one
|
|
53
61
|
* fails the first time anything that logs is built.
|
|
62
|
+
*/
|
|
63
|
+
export declare function registerApiRequestStack(container: Container, config: RegisterApiRequestStackConfig): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Registers the request stack in ONE container: the tenant-neutral part and a tenant scope's part.
|
|
66
|
+
* For work outside a request that needs everything a request has, without a tenant: the SQL schema
|
|
67
|
+
* setup, which sets up the tables of exactly the storages and modules the API runs.
|
|
68
|
+
*
|
|
69
|
+
* The container is its own `RequestContainer`, as a request's is: services built while it
|
|
70
|
+
* registers (`TenantContext`, through `TenantScopes`) depend on it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function registerApiRequestStackInOneContainer(container: Container, config: RegisterApiRequestStackConfig): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Registers a tenant scope's part of the request stack: every domain feature + the GraphQL engine,
|
|
75
|
+
* in the correct (order-sensitive) sequence, on top of the tenant-neutral part its parent (the
|
|
76
|
+
* request container) has.
|
|
54
77
|
*
|
|
55
78
|
* ORDER IS LOAD-BEARING — do not reorder. Notably: extensions must be applied before anything that
|
|
56
|
-
* lists + caches the
|
|
79
|
+
* lists + caches the scope's model set; the GraphQL engine must be registered last.
|
|
57
80
|
*/
|
|
58
|
-
export declare function
|
|
81
|
+
export declare function registerApiTenantScope(container: Container, config: RegisterApiRequestStackConfig, extensions?: ReturnType<RegisterApiRequestStackConfig["extensions"]>): Promise<void>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { registerExtensions } from "@webiny/handler";
|
|
2
|
+
import { RequestContainer } from "@webiny/api-kernel-core";
|
|
2
3
|
import { GraphQLEngineFeature } from "@webiny/api-graphql";
|
|
3
4
|
import { ApiCoreFeature, RequestStorage } from "@webiny/api-core";
|
|
5
|
+
import { TenantNeutralRequestFeature, TenantScopeRegistration } from "@webiny/api-core/features/tenancy/TenantScopes/index.js";
|
|
4
6
|
import { WcpLicenseLoader } from "@webiny/api-core/features/wcp/WcpLicenseLoader.js";
|
|
5
7
|
import { HeadlessCmsFeature } from "@webiny/api-headless-cms";
|
|
6
8
|
import { AcoHcmsFeature } from "@webiny/api-headless-cms-aco";
|
|
@@ -23,11 +25,22 @@ import { WorkflowsFeature } from "@webiny/api-workflows";
|
|
|
23
25
|
import { SchedulerFeature } from "@webiny/api-scheduler";
|
|
24
26
|
async function registerApiRequestStack(container, config) {
|
|
25
27
|
await WcpLicenseLoader.load();
|
|
26
|
-
for (const storage of container.resolveAll(RequestStorage))await storage.register(container);
|
|
27
28
|
const extensions = config.extensions();
|
|
28
|
-
|
|
29
|
+
TenantNeutralRequestFeature.register(container);
|
|
30
|
+
container.registerInstance(TenantScopeRegistration, {
|
|
31
|
+
register: (scope)=>registerApiTenantScope(scope, config, extensions)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function registerApiRequestStackInOneContainer(container, config) {
|
|
35
|
+
container.registerInstance(RequestContainer, container);
|
|
36
|
+
await registerApiRequestStack(container, config);
|
|
37
|
+
await registerApiTenantScope(container, config);
|
|
38
|
+
}
|
|
39
|
+
async function registerApiTenantScope(container, config, extensions = config.extensions()) {
|
|
40
|
+
for (const storage of container.resolveAll(RequestStorage))await storage.register(container);
|
|
29
41
|
ApiCoreFeature.register(container, {
|
|
30
|
-
wcpLicense: void 0
|
|
42
|
+
wcpLicense: void 0,
|
|
43
|
+
tenantScope: true
|
|
31
44
|
});
|
|
32
45
|
await config.transports?.hostingConfig?.(container);
|
|
33
46
|
HeadlessCmsFeature.register(container, {
|
|
@@ -57,6 +70,6 @@ async function registerApiRequestStack(container, config) {
|
|
|
57
70
|
await registerExtensions(container, extensions);
|
|
58
71
|
GraphQLEngineFeature.register(container);
|
|
59
72
|
}
|
|
60
|
-
export { registerApiRequestStack };
|
|
73
|
+
export { registerApiRequestStack, registerApiRequestStackInOneContainer, registerApiTenantScope };
|
|
61
74
|
|
|
62
75
|
//# sourceMappingURL=registerApiRequestStack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerApiRequestStack.js","sources":["../src/registerApiRequestStack.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { registerBuildParams, registerExtensions } from \"@webiny/handler\";\nimport { GraphQLEngineFeature } from \"@webiny/api-graphql\";\nimport { ApiCoreFeature, RequestStorage } from \"@webiny/api-core\";\nimport { WcpLicenseLoader } from \"@webiny/api-core/features/wcp/WcpLicenseLoader.js\";\nimport { HeadlessCmsFeature } from \"@webiny/api-headless-cms\";\nimport { AcoHcmsFeature } from \"@webiny/api-headless-cms-aco\";\nimport { HcmsTasksFeature } from \"@webiny/api-headless-cms-tasks\";\nimport { CmsWorkflowsFeature } from \"@webiny/api-headless-cms-workflows\";\nimport { CmsSchedulerFeature } from \"@webiny/api-headless-cms-scheduler\";\nimport { MailerFeature } from \"@webiny/api-mailer\";\nimport { RecordLockingAppFeature } from \"@webiny/api-record-locking\";\nimport { AuditLogsFeature } from \"@webiny/api-audit-logs\";\nimport { DashboardAppFeature } from \"@webiny/api-dashboard\";\nimport { AcoFeature } from \"@webiny/api-aco\";\nimport { BackgroundTasksFeature } from \"@webiny/background-tasks/api\";\nimport { FileManagerAppFeature } from \"@webiny/api-file-manager\";\nimport { FileManagerAcoFeature } from \"@webiny/api-file-manager-aco\";\nimport { WebsiteBuilderFeature } from \"@webiny/api-website-builder\";\nimport { WebsiteBuilderWorkflowsFeature } from \"@webiny/api-website-builder-workflows\";\nimport { WebsiteBuilderSchedulerFeature } from \"@webiny/api-website-builder-scheduler\";\nimport { WebsocketsFeature } from \"@webiny/api-websockets\";\nimport { WorkflowsFeature } from \"@webiny/api-workflows\";\nimport { SchedulerFeature } from \"@webiny/api-scheduler\";\n\n/** Installs a hosting-specific transport adapter into the per-request container at its interleave point. */\nexport type TransportRegistrar = (container: Container) => void | Promise<void>;\n\nexport interface RegisterApiRequestStackConfig {\n /**\n * Project-defined extensions, applied at register() time (so extension features — including\n * code-defined CMS models — are registered before anything lists/caches the model set).\n */\n extensions: () => Parameters<typeof registerExtensions>[1];\n /**\n * Hosting-specific transport adapters, each installed at its exact interleave point in the stack.\n * Every entry follows the same shape: it runs immediately AFTER the transport-agnostic domain\n * Feature has registered its NULL default, and overrides that default (nearest-container-last-wins)\n * with the real adapter. Each is optional — omit one for a deployment/transport that lacks that\n * capability. AWS supplies AWS adapters (API Gateway Management API / EventBridge / S3); the\n * standalone server supplies in-process adapters (server WebSockets / in-process scheduler / local disk).\n */\n transports?: {\n /**\n * Hosting-specific replacements for api-core defaults, run right after `ApiCoreFeature`:\n * `PublicUrls` (default: every URL unknown), `CdnCache` (default: nothing to invalidate), and\n * `EncryptionConfig` / `HashingConfig` (default: read from build params).\n */\n hostingConfig?: TransportRegistrar;\n /**\n * Real-time (WebSockets) transport, run right after `WebsocketsFeature`. Overrides the\n * NullWebsocketsTransport, otherwise every server→client send() is a silent no-op.\n */\n realtime?: TransportRegistrar;\n /**\n * Scheduler transport, run AFTER `SchedulerFeature` and BEFORE `CmsSchedulerFeature`.\n */\n scheduler?: TransportRegistrar;\n /**\n * File-manager storage transport, run AFTER `FileManagerAppFeature` (which registers the\n * AssetDeliveryRoute + NULL asset-delivery impls). Overrides those nulls with real impls and\n * adds the file-operation features.\n */\n fileManager?: TransportRegistrar;\n };\n}\n\n/**\n * Registers the transport-AGNOSTIC Webiny API request stack: every domain feature + the GraphQL\n * engine, in the correct (order-sensitive) sequence. This is shared by all transport composition\n * packages (`@webiny/api-composition-aws`, and the future `-server`) so the feature set and its\n * ordering live in ONE place and can't drift between transports.\n *\n * Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}\n * at their exact interleave points. The caller is responsible for the ROOT-container transport wiring\n * (HTTP/event transport, auth/tenant loaders, identity provider, DB + storage) before dispatch reaches\n * this per-request stack. That includes the `Logger`: api-core registers none, so a root without one\n * fails the first time anything that logs is built.\n *\n * ORDER IS LOAD-BEARING — do not reorder. Notably: extensions must be applied before anything that\n * lists + caches the per-request model set; the GraphQL engine must be registered last.\n */\nexport async function registerApiRequestStack(\n container: Container,\n config: RegisterApiRequestStackConfig\n): Promise<void> {\n // Refresh the WCP license BEFORE any feature registers — this is the single per-request refresh.\n // register()-time feature-flag checks (e.g. the private-files gate) and WcpContext.canUse* both\n // read it via the process cache (`WcpLicenseProvider.get()` / `WcpLicenseLoader.getCached()`). Runs here\n // — the shared request stack both hosting types call — so no handler wires it. Process-cached\n // (~5-min TTL) + single-flighted → cheap no-op on warm requests.\n await WcpLicenseLoader.load();\n\n // ── Storage (before ANY feature) ───────────────────────────\n // Every storage that registers per request put a `RequestStorage` in the root; each registers\n // its storages here, in this request's container. First, because `ApiCoreFeature` resolves the\n // core storage while it registers. A storage that keeps its storages in the root (the DynamoDB\n // variants) registers none, and this does nothing.\n for (const storage of container.resolveAll(RequestStorage)) {\n await storage.register(container);\n }\n\n // ── Build params (before ANY feature) ──────────────────────\n // Features gate themselves on FeatureFlags at register() time (AuditLogs, RecordLocking,\n // Workflows, ...), and FeatureFlags is a BuildParam. Registered with the rest of the extensions\n // below, it arrived too late: those gates read `{}`, and a license-granted feature couldn't be\n // disabled from config.\n const extensions = config.extensions();\n await registerBuildParams(container, extensions);\n\n // ── Core API (per-request: EventPublisher + tenant/identity/request contexts must bind to the\n // request child container so per-request event handlers are resolvable) ─────────\n ApiCoreFeature.register(container, { wcpLicense: undefined });\n await config.transports?.hostingConfig?.(container);\n\n // ── CMS ────────────────────────────────────────────────────\n HeadlessCmsFeature.register(container, { type: \"manage\" });\n AcoFeature.register(container);\n AcoHcmsFeature.register(container);\n HcmsTasksFeature.register(container);\n\n // ── File Manager (domain) + storage transport ──────────────\n FileManagerAppFeature.register(container);\n FileManagerAcoFeature.register(container);\n await config.transports?.fileManager?.(container);\n\n // ── Website Builder ────────────────────────────────────────\n WebsiteBuilderFeature.register(container);\n WebsiteBuilderWorkflowsFeature.register(container);\n WebsiteBuilderSchedulerFeature.register(container);\n\n // ── Websockets (domain) + real-time transport ──────────────\n WebsocketsFeature.register(container);\n await config.transports?.realtime?.(container);\n\n // ── Supporting services ────────────────────────────────────\n MailerFeature.register(container);\n RecordLockingAppFeature.register(container, {});\n AuditLogsFeature.register(container, {});\n DashboardAppFeature.register(container);\n BackgroundTasksFeature.register(container);\n\n // ── Workflows ──────────────────────────────────────────────\n WorkflowsFeature.register(container);\n CmsWorkflowsFeature.register(container);\n\n // ── Scheduler + scheduler transport ────────────────────────\n SchedulerFeature.register(container);\n await config.transports?.scheduler?.(container);\n CmsSchedulerFeature.register(container);\n\n // ── Extensions ─────────────────────────────────────────────\n // Apply at register() time so extension features — including code-defined CMS models\n // (ModelFactory), e.g. Languages — are registered before anything populates ModelCache. Anything\n // reaching the model set through GetModel/ListModels (which go via ModelsFetcher ->\n // ModelCache.getOrSet) caches it for the rest of the request, so a set built before extensions\n // register would be missing their models. Every consumer now resolves models at schema-build or\n // resolver time, i.e. after all registration.\n await registerExtensions(container, extensions);\n\n // ── GraphQL engine (always last) ───────────────────────────\n GraphQLEngineFeature.register(container);\n}\n"],"names":["registerApiRequestStack","container","config","WcpLicenseLoader","storage","RequestStorage","extensions","registerBuildParams","ApiCoreFeature","undefined","HeadlessCmsFeature","AcoFeature","AcoHcmsFeature","HcmsTasksFeature","FileManagerAppFeature","FileManagerAcoFeature","WebsiteBuilderFeature","WebsiteBuilderWorkflowsFeature","WebsiteBuilderSchedulerFeature","WebsocketsFeature","MailerFeature","RecordLockingAppFeature","AuditLogsFeature","DashboardAppFeature","BackgroundTasksFeature","WorkflowsFeature","CmsWorkflowsFeature","SchedulerFeature","CmsSchedulerFeature","registerExtensions","GraphQLEngineFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkFO,eAAeA,wBAClBC,SAAoB,EACpBC,MAAqC;IAOrC,MAAMC,iBAAiB,IAAI;IAO3B,KAAK,MAAMC,WAAWH,UAAU,UAAU,CAACI,gBACvC,MAAMD,QAAQ,QAAQ,CAACH;IAQ3B,MAAMK,aAAaJ,OAAO,UAAU;IACpC,MAAMK,oBAAoBN,WAAWK;IAIrCE,eAAe,QAAQ,CAACP,WAAW;QAAE,YAAYQ;IAAU;IAC3D,MAAMP,OAAO,UAAU,EAAE,gBAAgBD;IAGzCS,mBAAmB,QAAQ,CAACT,WAAW;QAAE,MAAM;IAAS;IACxDU,WAAW,QAAQ,CAACV;IACpBW,eAAe,QAAQ,CAACX;IACxBY,iBAAiB,QAAQ,CAACZ;IAG1Ba,sBAAsB,QAAQ,CAACb;IAC/Bc,sBAAsB,QAAQ,CAACd;IAC/B,MAAMC,OAAO,UAAU,EAAE,cAAcD;IAGvCe,sBAAsB,QAAQ,CAACf;IAC/BgB,+BAA+B,QAAQ,CAAChB;IACxCiB,+BAA+B,QAAQ,CAACjB;IAGxCkB,kBAAkB,QAAQ,CAAClB;IAC3B,MAAMC,OAAO,UAAU,EAAE,WAAWD;IAGpCmB,cAAc,QAAQ,CAACnB;IACvBoB,wBAAwB,QAAQ,CAACpB,WAAW,CAAC;IAC7CqB,iBAAiB,QAAQ,CAACrB,WAAW,CAAC;IACtCsB,oBAAoB,QAAQ,CAACtB;IAC7BuB,uBAAuB,QAAQ,CAACvB;IAGhCwB,iBAAiB,QAAQ,CAACxB;IAC1ByB,oBAAoB,QAAQ,CAACzB;IAG7B0B,iBAAiB,QAAQ,CAAC1B;IAC1B,MAAMC,OAAO,UAAU,EAAE,YAAYD;IACrC2B,oBAAoB,QAAQ,CAAC3B;IAS7B,MAAM4B,mBAAmB5B,WAAWK;IAGpCwB,qBAAqB,QAAQ,CAAC7B;AAClC"}
|
|
1
|
+
{"version":3,"file":"registerApiRequestStack.js","sources":["../src/registerApiRequestStack.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { registerExtensions } from \"@webiny/handler\";\nimport { RequestContainer } from \"@webiny/api-kernel-core\";\nimport { GraphQLEngineFeature } from \"@webiny/api-graphql\";\nimport { ApiCoreFeature, RequestStorage } from \"@webiny/api-core\";\nimport {\n TenantNeutralRequestFeature,\n TenantScopeRegistration\n} from \"@webiny/api-core/features/tenancy/TenantScopes/index.js\";\nimport { WcpLicenseLoader } from \"@webiny/api-core/features/wcp/WcpLicenseLoader.js\";\nimport { HeadlessCmsFeature } from \"@webiny/api-headless-cms\";\nimport { AcoHcmsFeature } from \"@webiny/api-headless-cms-aco\";\nimport { HcmsTasksFeature } from \"@webiny/api-headless-cms-tasks\";\nimport { CmsWorkflowsFeature } from \"@webiny/api-headless-cms-workflows\";\nimport { CmsSchedulerFeature } from \"@webiny/api-headless-cms-scheduler\";\nimport { MailerFeature } from \"@webiny/api-mailer\";\nimport { RecordLockingAppFeature } from \"@webiny/api-record-locking\";\nimport { AuditLogsFeature } from \"@webiny/api-audit-logs\";\nimport { DashboardAppFeature } from \"@webiny/api-dashboard\";\nimport { AcoFeature } from \"@webiny/api-aco\";\nimport { BackgroundTasksFeature } from \"@webiny/background-tasks/api\";\nimport { FileManagerAppFeature } from \"@webiny/api-file-manager\";\nimport { FileManagerAcoFeature } from \"@webiny/api-file-manager-aco\";\nimport { WebsiteBuilderFeature } from \"@webiny/api-website-builder\";\nimport { WebsiteBuilderWorkflowsFeature } from \"@webiny/api-website-builder-workflows\";\nimport { WebsiteBuilderSchedulerFeature } from \"@webiny/api-website-builder-scheduler\";\nimport { WebsocketsFeature } from \"@webiny/api-websockets\";\nimport { WorkflowsFeature } from \"@webiny/api-workflows\";\nimport { SchedulerFeature } from \"@webiny/api-scheduler\";\n\n/** Installs a hosting-specific transport adapter into the per-request container at its interleave point. */\nexport type TransportRegistrar = (container: Container) => void | Promise<void>;\n\nexport interface RegisterApiRequestStackConfig {\n /**\n * Project-defined extensions, applied at register() time (so extension features — including\n * code-defined CMS models — are registered before anything lists/caches the model set).\n */\n extensions: () => Parameters<typeof registerExtensions>[1];\n /**\n * Hosting-specific transport adapters, each installed at its exact interleave point in the stack.\n * Every entry follows the same shape: it runs immediately AFTER the transport-agnostic domain\n * Feature has registered its NULL default, and overrides that default (nearest-container-last-wins)\n * with the real adapter. Each is optional — omit one for a deployment/transport that lacks that\n * capability. AWS supplies AWS adapters (API Gateway Management API / EventBridge / S3); the\n * standalone server supplies in-process adapters (server WebSockets / in-process scheduler / local disk).\n */\n transports?: {\n /**\n * Hosting-specific replacements for api-core defaults, run right after `ApiCoreFeature`:\n * `PublicUrls` (default: every URL unknown), `CdnCache` (default: nothing to invalidate), and\n * `EncryptionConfig` / `HashingConfig` (default: read from build params).\n */\n hostingConfig?: TransportRegistrar;\n /**\n * Real-time (WebSockets) transport, run right after `WebsocketsFeature`. Overrides the\n * NullWebsocketsTransport, otherwise every server→client send() is a silent no-op.\n */\n realtime?: TransportRegistrar;\n /**\n * Scheduler transport, run AFTER `SchedulerFeature` and BEFORE `CmsSchedulerFeature`.\n */\n scheduler?: TransportRegistrar;\n /**\n * File-manager storage transport, run AFTER `FileManagerAppFeature` (which registers the\n * AssetDeliveryRoute + NULL asset-delivery impls). Overrides those nulls with real impls and\n * adds the file-operation features.\n */\n fileManager?: TransportRegistrar;\n };\n}\n\n/**\n * Registers the transport-AGNOSTIC Webiny API request stack. This is shared by all transport\n * composition packages (`@webiny/api-composition-aws`, `-standalone`) so the feature set and its\n * ordering live in ONE place and can't drift between transports.\n *\n * The request container gets only the tenant-neutral part: the raw request values, the tenant\n * registry the request's tenant is loaded from, and `TenantScopes`. Build params come from the\n * deploy, the same for every request and tenant, so the transport registers them once in the root\n * (`registerRootBuildParams`), before any request registers a feature that reads them (features\n * gate themselves on `FeatureFlags`, a build param, at register() time). Everything else is\n * tenant-specific and registers in each tenant scope the request enters, through the\n * `TenantScopeRegistration` registered here ({@link registerApiTenantScope}). The request's own work\n * runs in its tenant's scope (`TenantScopesRootFeature`, which the transport registers in the root).\n *\n * Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}\n * at their exact interleave points. The caller is responsible for the ROOT-container transport wiring\n * (HTTP/event transport, tenant sources, identity loaders, DB + storage) before dispatch reaches\n * this per-request stack. That includes the `Logger`: api-core registers none, so a root without one\n * fails the first time anything that logs is built.\n */\nexport async function registerApiRequestStack(\n container: Container,\n config: RegisterApiRequestStackConfig\n): Promise<void> {\n // Refresh the WCP license BEFORE any feature registers — this is the single per-request refresh.\n // register()-time feature-flag checks (e.g. the private-files gate) and WcpContext.canUse* both\n // read it via the process cache (`WcpLicenseProvider.get()` / `WcpLicenseLoader.getCached()`). Runs here\n // — the shared request stack both hosting types call — so no handler wires it. Process-cached\n // (~5-min TTL) + single-flighted → cheap no-op on warm requests.\n await WcpLicenseLoader.load();\n\n const extensions = config.extensions();\n\n // ── Tenant-neutral request: raw values, tenant registry, TenantScopes ──\n TenantNeutralRequestFeature.register(container);\n\n // ── Everything tenant-specific: per tenant scope ───────────\n container.registerInstance(TenantScopeRegistration, {\n register: scope => registerApiTenantScope(scope, config, extensions)\n });\n}\n\n/**\n * Registers the request stack in ONE container: the tenant-neutral part and a tenant scope's part.\n * For work outside a request that needs everything a request has, without a tenant: the SQL schema\n * setup, which sets up the tables of exactly the storages and modules the API runs.\n *\n * The container is its own `RequestContainer`, as a request's is: services built while it\n * registers (`TenantContext`, through `TenantScopes`) depend on it.\n */\nexport async function registerApiRequestStackInOneContainer(\n container: Container,\n config: RegisterApiRequestStackConfig\n): Promise<void> {\n container.registerInstance(RequestContainer, container);\n await registerApiRequestStack(container, config);\n await registerApiTenantScope(container, config);\n}\n\n/**\n * Registers a tenant scope's part of the request stack: every domain feature + the GraphQL engine,\n * in the correct (order-sensitive) sequence, on top of the tenant-neutral part its parent (the\n * request container) has.\n *\n * ORDER IS LOAD-BEARING — do not reorder. Notably: extensions must be applied before anything that\n * lists + caches the scope's model set; the GraphQL engine must be registered last.\n */\nexport async function registerApiTenantScope(\n container: Container,\n config: RegisterApiRequestStackConfig,\n extensions: ReturnType<RegisterApiRequestStackConfig[\"extensions\"]> = config.extensions()\n): Promise<void> {\n // ── Storage (before ANY feature) ───────────────────────────\n // Every storage that registers per request put a `RequestStorage` in the root; each registers\n // its storages here, in the scope's container. First, because `ApiCoreFeature` resolves the\n // core storage while it registers. A storage that keeps its storages in the root (the DynamoDB\n // variants) registers none, and this does nothing.\n for (const storage of container.resolveAll(RequestStorage)) {\n await storage.register(container);\n }\n\n // ── Core API: tenant/identity contexts, security, users, ... (the tenant registry and the raw\n // request values come from the request container) ─────────\n ApiCoreFeature.register(container, { wcpLicense: undefined, tenantScope: true });\n await config.transports?.hostingConfig?.(container);\n\n // ── CMS ────────────────────────────────────────────────────\n HeadlessCmsFeature.register(container, { type: \"manage\" });\n AcoFeature.register(container);\n AcoHcmsFeature.register(container);\n HcmsTasksFeature.register(container);\n\n // ── File Manager (domain) + storage transport ──────────────\n FileManagerAppFeature.register(container);\n FileManagerAcoFeature.register(container);\n await config.transports?.fileManager?.(container);\n\n // ── Website Builder ────────────────────────────────────────\n WebsiteBuilderFeature.register(container);\n WebsiteBuilderWorkflowsFeature.register(container);\n WebsiteBuilderSchedulerFeature.register(container);\n\n // ── Websockets (domain) + real-time transport ──────────────\n WebsocketsFeature.register(container);\n await config.transports?.realtime?.(container);\n\n // ── Supporting services ────────────────────────────────────\n MailerFeature.register(container);\n RecordLockingAppFeature.register(container, {});\n AuditLogsFeature.register(container, {});\n DashboardAppFeature.register(container);\n BackgroundTasksFeature.register(container);\n\n // ── Workflows ──────────────────────────────────────────────\n WorkflowsFeature.register(container);\n CmsWorkflowsFeature.register(container);\n\n // ── Scheduler + scheduler transport ────────────────────────\n SchedulerFeature.register(container);\n await config.transports?.scheduler?.(container);\n CmsSchedulerFeature.register(container);\n\n // ── Extensions ─────────────────────────────────────────────\n // Apply at register() time so extension features — including code-defined CMS models\n // (ModelFactory), e.g. Languages — are registered before anything populates ModelCache. Anything\n // reaching the model set through GetModel/ListModels (which go via ModelsFetcher ->\n // ModelCache.getOrSet) caches it for the rest of the request, so a set built before extensions\n // register would be missing their models. Every consumer now resolves models at schema-build or\n // resolver time, i.e. after all registration.\n await registerExtensions(container, extensions);\n\n // ── GraphQL engine (always last) ───────────────────────────\n GraphQLEngineFeature.register(container);\n}\n"],"names":["registerApiRequestStack","container","config","WcpLicenseLoader","extensions","TenantNeutralRequestFeature","TenantScopeRegistration","scope","registerApiTenantScope","registerApiRequestStackInOneContainer","RequestContainer","storage","RequestStorage","ApiCoreFeature","undefined","HeadlessCmsFeature","AcoFeature","AcoHcmsFeature","HcmsTasksFeature","FileManagerAppFeature","FileManagerAcoFeature","WebsiteBuilderFeature","WebsiteBuilderWorkflowsFeature","WebsiteBuilderSchedulerFeature","WebsocketsFeature","MailerFeature","RecordLockingAppFeature","AuditLogsFeature","DashboardAppFeature","BackgroundTasksFeature","WorkflowsFeature","CmsWorkflowsFeature","SchedulerFeature","CmsSchedulerFeature","registerExtensions","GraphQLEngineFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4FO,eAAeA,wBAClBC,SAAoB,EACpBC,MAAqC;IAOrC,MAAMC,iBAAiB,IAAI;IAE3B,MAAMC,aAAaF,OAAO,UAAU;IAGpCG,4BAA4B,QAAQ,CAACJ;IAGrCA,UAAU,gBAAgB,CAACK,yBAAyB;QAChD,UAAUC,CAAAA,QAASC,uBAAuBD,OAAOL,QAAQE;IAC7D;AACJ;AAUO,eAAeK,sCAClBR,SAAoB,EACpBC,MAAqC;IAErCD,UAAU,gBAAgB,CAACS,kBAAkBT;IAC7C,MAAMD,wBAAwBC,WAAWC;IACzC,MAAMM,uBAAuBP,WAAWC;AAC5C;AAUO,eAAeM,uBAClBP,SAAoB,EACpBC,MAAqC,EACrCE,aAAsEF,OAAO,UAAU,EAAE;IAOzF,KAAK,MAAMS,WAAWV,UAAU,UAAU,CAACW,gBACvC,MAAMD,QAAQ,QAAQ,CAACV;IAK3BY,eAAe,QAAQ,CAACZ,WAAW;QAAE,YAAYa;QAAW,aAAa;IAAK;IAC9E,MAAMZ,OAAO,UAAU,EAAE,gBAAgBD;IAGzCc,mBAAmB,QAAQ,CAACd,WAAW;QAAE,MAAM;IAAS;IACxDe,WAAW,QAAQ,CAACf;IACpBgB,eAAe,QAAQ,CAAChB;IACxBiB,iBAAiB,QAAQ,CAACjB;IAG1BkB,sBAAsB,QAAQ,CAAClB;IAC/BmB,sBAAsB,QAAQ,CAACnB;IAC/B,MAAMC,OAAO,UAAU,EAAE,cAAcD;IAGvCoB,sBAAsB,QAAQ,CAACpB;IAC/BqB,+BAA+B,QAAQ,CAACrB;IACxCsB,+BAA+B,QAAQ,CAACtB;IAGxCuB,kBAAkB,QAAQ,CAACvB;IAC3B,MAAMC,OAAO,UAAU,EAAE,WAAWD;IAGpCwB,cAAc,QAAQ,CAACxB;IACvByB,wBAAwB,QAAQ,CAACzB,WAAW,CAAC;IAC7C0B,iBAAiB,QAAQ,CAAC1B,WAAW,CAAC;IACtC2B,oBAAoB,QAAQ,CAAC3B;IAC7B4B,uBAAuB,QAAQ,CAAC5B;IAGhC6B,iBAAiB,QAAQ,CAAC7B;IAC1B8B,oBAAoB,QAAQ,CAAC9B;IAG7B+B,iBAAiB,QAAQ,CAAC/B;IAC1B,MAAMC,OAAO,UAAU,EAAE,YAAYD;IACrCgC,oBAAoB,QAAQ,CAAChC;IAS7B,MAAMiC,mBAAmBjC,WAAWG;IAGpC+B,qBAAqB,QAAQ,CAAClC;AAClC"}
|
package/auth/getHeader.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads one header from a plain header map. Header names are case-insensitive, and the casing that
|
|
3
|
-
* reaches us depends on the transport and on the client, so this matches on the lowercased key.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getHeader(headers: Record<string, string> | undefined, name: string): string;
|
package/auth/getHeader.js
DELETED
package/auth/getHeader.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth/getHeader.js","sources":["../../src/auth/getHeader.ts"],"sourcesContent":["/**\n * Reads one header from a plain header map. Header names are case-insensitive, and the casing that\n * reaches us depends on the transport and on the client, so this matches on the lowercased key.\n */\nexport function getHeader(headers: Record<string, string> | undefined, name: string): string {\n if (!headers) {\n return \"\";\n }\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === name) {\n return headers[key] ?? \"\";\n }\n }\n return \"\";\n}\n"],"names":["getHeader","headers","name","key","Object"],"mappings":"AAIO,SAASA,UAAUC,OAA2C,EAAEC,IAAY;IAC/E,IAAI,CAACD,SACD,OAAO;IAEX,KAAK,MAAME,OAAOC,OAAO,IAAI,CAACH,SAC1B,IAAIE,IAAI,WAAW,OAAOD,MACtB,OAAOD,OAAO,CAACE,IAAI,IAAI;IAG/B,OAAO;AACX"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { registerBuildParams } from "@webiny/handler";
|
|
2
|
-
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
3
|
-
type Extensions = Parameters<typeof registerBuildParams>[1];
|
|
4
|
-
/**
|
|
5
|
-
* The build params the project was built with, read in a throwaway container. Requests register
|
|
6
|
-
* them in their own containers; this copy is for the root, which needs a setting from them (or wants
|
|
7
|
-
* to check them) before any request runs. Call it once per process.
|
|
8
|
-
*/
|
|
9
|
-
export declare function readBuildParams(extensions: Extensions): Promise<BuildParams.Interface>;
|
|
10
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Container } from "@webiny/di";
|
|
2
|
-
import { registerBuildParams } from "@webiny/handler";
|
|
3
|
-
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
4
|
-
import { BuildParamsFeature } from "@webiny/api-core/features/buildParams/feature.js";
|
|
5
|
-
async function readBuildParams(extensions) {
|
|
6
|
-
const container = new Container();
|
|
7
|
-
BuildParamsFeature.register(container);
|
|
8
|
-
await registerBuildParams(container, extensions);
|
|
9
|
-
return container.resolve(BuildParams);
|
|
10
|
-
}
|
|
11
|
-
export { readBuildParams };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=readBuildParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildParams/readBuildParams.js","sources":["../../src/buildParams/readBuildParams.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\nimport { registerBuildParams } from \"@webiny/handler\";\nimport { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { BuildParamsFeature } from \"@webiny/api-core/features/buildParams/feature.js\";\n\ntype Extensions = Parameters<typeof registerBuildParams>[1];\n\n/**\n * The build params the project was built with, read in a throwaway container. Requests register\n * them in their own containers; this copy is for the root, which needs a setting from them (or wants\n * to check them) before any request runs. Call it once per process.\n */\nexport async function readBuildParams(extensions: Extensions): Promise<BuildParams.Interface> {\n const container = new Container();\n BuildParamsFeature.register(container);\n await registerBuildParams(container, extensions);\n return container.resolve(BuildParams);\n}\n"],"names":["readBuildParams","extensions","container","Container","BuildParamsFeature","registerBuildParams","BuildParams"],"mappings":";;;;AAYO,eAAeA,gBAAgBC,UAAsB;IACxD,MAAMC,YAAY,IAAIC;IACtBC,mBAAmB,QAAQ,CAACF;IAC5B,MAAMG,oBAAoBH,WAAWD;IACrC,OAAOC,UAAU,OAAO,CAACI;AAC7B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import { NodeHttpInputHandler } from "@webiny/api-kernel-core/nodeHttp/index.js";
|
|
3
|
-
import { RawAssumePermissions } from "@webiny/api-core/features/requestContext/index.js";
|
|
4
|
-
import type { InputContext } from "@webiny/api-kernel-core";
|
|
5
|
-
import type { NextFunction } from "@webiny/api-kernel-core";
|
|
6
|
-
/**
|
|
7
|
-
* EXTRACT (transport-specific): reads the `x-webiny-assume-permissions` header of a Node
|
|
8
|
-
* `IncomingMessage` into RawAssumePermissions. Node mirror of ApiGatewayAssumePermissionsDecorator.
|
|
9
|
-
*/
|
|
10
|
-
declare class NodeHttpAssumePermissionsDecoratorImpl implements NodeHttpInputHandler.Interface {
|
|
11
|
-
private rawAssumePermissions;
|
|
12
|
-
private decoratee;
|
|
13
|
-
constructor(rawAssumePermissions: RawAssumePermissions.Interface, decoratee: NodeHttpInputHandler.Interface);
|
|
14
|
-
execute(ctx: InputContext<IncomingMessage>, next: NextFunction): Promise<any>;
|
|
15
|
-
}
|
|
16
|
-
export declare const NodeHttpAssumePermissionsDecorator: typeof NodeHttpAssumePermissionsDecoratorImpl & {
|
|
17
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-kernel-core/nodeHttp/index.js").INodeHttpInputHandler>;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { NodeHttpInputHandler } from "@webiny/api-kernel-core/nodeHttp/index.js";
|
|
2
|
-
import { RawAssumePermissions, extractAssumePermissions } from "@webiny/api-core/features/requestContext/index.js";
|
|
3
|
-
class NodeHttpAssumePermissionsDecoratorImpl {
|
|
4
|
-
constructor(rawAssumePermissions, decoratee){
|
|
5
|
-
this.rawAssumePermissions = rawAssumePermissions;
|
|
6
|
-
this.decoratee = decoratee;
|
|
7
|
-
}
|
|
8
|
-
async execute(ctx, next) {
|
|
9
|
-
const headers = ctx.input?.headers;
|
|
10
|
-
const requested = extractAssumePermissions(headers);
|
|
11
|
-
this.rawAssumePermissions.set(requested);
|
|
12
|
-
return this.decoratee.execute(ctx, next);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const NodeHttpAssumePermissionsDecorator = NodeHttpInputHandler.createDecorator({
|
|
16
|
-
decorator: NodeHttpAssumePermissionsDecoratorImpl,
|
|
17
|
-
dependencies: [
|
|
18
|
-
RawAssumePermissions
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
export { NodeHttpAssumePermissionsDecorator };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=NodeHttpAssumePermissionsDecorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHttp/NodeHttpAssumePermissionsDecorator.js","sources":["../../src/nodeHttp/NodeHttpAssumePermissionsDecorator.ts"],"sourcesContent":["import type { IncomingMessage } from \"node:http\";\nimport { NodeHttpInputHandler } from \"@webiny/api-kernel-core/nodeHttp/index.js\";\nimport { RawAssumePermissions } from \"@webiny/api-core/features/requestContext/index.js\";\nimport { extractAssumePermissions } from \"@webiny/api-core/features/requestContext/index.js\";\nimport type { InputContext } from \"@webiny/api-kernel-core\";\nimport type { NextFunction } from \"@webiny/api-kernel-core\";\n\n/**\n * EXTRACT (transport-specific): reads the `x-webiny-assume-permissions` header of a Node\n * `IncomingMessage` into RawAssumePermissions. Node mirror of ApiGatewayAssumePermissionsDecorator.\n */\nclass NodeHttpAssumePermissionsDecoratorImpl implements NodeHttpInputHandler.Interface {\n constructor(\n private rawAssumePermissions: RawAssumePermissions.Interface,\n private decoratee: NodeHttpInputHandler.Interface\n ) {}\n\n async execute(ctx: InputContext<IncomingMessage>, next: NextFunction): Promise<any> {\n const headers = ctx.input?.headers;\n const requested = extractAssumePermissions(headers);\n\n this.rawAssumePermissions.set(requested);\n\n return this.decoratee.execute(ctx, next);\n }\n}\n\nexport const NodeHttpAssumePermissionsDecorator = NodeHttpInputHandler.createDecorator({\n decorator: NodeHttpAssumePermissionsDecoratorImpl,\n dependencies: [RawAssumePermissions]\n});\n"],"names":["NodeHttpAssumePermissionsDecoratorImpl","rawAssumePermissions","decoratee","ctx","next","headers","requested","extractAssumePermissions","NodeHttpAssumePermissionsDecorator","NodeHttpInputHandler","RawAssumePermissions"],"mappings":";;AAWA,MAAMA;IACF,YACYC,oBAAoD,EACpDC,SAAyC,CACnD;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,GAAkC,EAAEC,IAAkB,EAAgB;QAChF,MAAMC,UAAUF,IAAI,KAAK,EAAE;QAC3B,MAAMG,YAAYC,yBAAyBF;QAE3C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAACC;QAE9B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACH,KAAKC;IACvC;AACJ;AAEO,MAAMI,qCAAqCC,qBAAqB,eAAe,CAAC;IACnF,WAAWT;IACX,cAAc;QAACU;KAAqB;AACxC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import { NodeHttpInputHandler } from "@webiny/api-kernel-core/nodeHttp/index.js";
|
|
3
|
-
import { RawAuthToken } from "@webiny/api-core/features/requestContext/index.js";
|
|
4
|
-
import type { IRequestIdentityLoader } from "@webiny/api-core/features/requestContext/abstractions.js";
|
|
5
|
-
import type { InputContext, NextFunction } from "@webiny/api-kernel-core";
|
|
6
|
-
/**
|
|
7
|
-
* EXTRACT (transport-specific): reads the auth token from a Node `IncomingMessage` —
|
|
8
|
-
* `x-webiny-authorization` first, then the bearer `Authorization` header, then the `wby-id-token`
|
|
9
|
-
* cookie (private file reads only) — into RawAuthToken, then invokes the shared LOAD step (RequestIdentityLoader) which
|
|
10
|
-
* authenticates it (via the registered identity provider, e.g. the self-hosted JWT IdP) and sets
|
|
11
|
-
* IdentityContext.
|
|
12
|
-
*
|
|
13
|
-
* `x-webiny-authorization` exists for AWS parity: behind CloudFront with Origin Access Control, SigV4
|
|
14
|
-
* occupies the `Authorization` header, so clients that may traverse such an origin send the token in
|
|
15
|
-
* that header instead. Standalone has no such constraint, but it accepts the same header so one
|
|
16
|
-
* client works against both deployments.
|
|
17
|
-
*
|
|
18
|
-
* A token an identity provider rejects ends the request with a 401. Any other error propagates.
|
|
19
|
-
*
|
|
20
|
-
* Node counterpart of ApiGatewayIdentityLoaderDecorator. Registered before the tenant loader, which
|
|
21
|
-
* makes it the inner wrapper: the tenant is loaded first, because API-key authentication looks the key up
|
|
22
|
-
* in the tenant's partition.
|
|
23
|
-
*/
|
|
24
|
-
declare class NodeHttpIdentityLoaderDecoratorImpl implements NodeHttpInputHandler.Interface {
|
|
25
|
-
private rawAuthToken;
|
|
26
|
-
private identityLoader;
|
|
27
|
-
private decoratee;
|
|
28
|
-
constructor(rawAuthToken: RawAuthToken.Interface, identityLoader: IRequestIdentityLoader, decoratee: NodeHttpInputHandler.Interface);
|
|
29
|
-
execute(ctx: InputContext<IncomingMessage>, next: NextFunction): Promise<any>;
|
|
30
|
-
}
|
|
31
|
-
export declare const NodeHttpIdentityLoaderDecorator: typeof NodeHttpIdentityLoaderDecoratorImpl & {
|
|
32
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-kernel-core/nodeHttp/index.js").INodeHttpInputHandler>;
|
|
33
|
-
};
|
|
34
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHttp/NodeHttpIdentityLoaderDecorator.js","sources":["../../src/nodeHttp/NodeHttpIdentityLoaderDecorator.ts"],"sourcesContent":["import type { IncomingMessage } from \"node:http\";\nimport { NodeHttpInputHandler } from \"@webiny/api-kernel-core/nodeHttp/index.js\";\nimport {\n RawAuthToken,\n RequestIdentityLoader\n} from \"@webiny/api-core/features/requestContext/index.js\";\nimport type { IRequestIdentityLoader } from \"@webiny/api-core/features/requestContext/abstractions.js\";\nimport { AuthenticationError } from \"@webiny/api-core/features/security/authentication/AuthenticationContext/index.js\";\nimport type { InputContext, NextFunction } from \"@webiny/api-kernel-core\";\nimport { extractAuthToken } from \"~/auth/extractAuthToken.js\";\nimport { rejectedTokenResponse } from \"~/auth/rejectedTokenResponse.js\";\nimport { headersFromIncomingMessage } from \"./headersFromIncomingMessage.js\";\n\n/**\n * EXTRACT (transport-specific): reads the auth token from a Node `IncomingMessage` —\n * `x-webiny-authorization` first, then the bearer `Authorization` header, then the `wby-id-token`\n * cookie (private file reads only) — into RawAuthToken, then invokes the shared LOAD step (RequestIdentityLoader) which\n * authenticates it (via the registered identity provider, e.g. the self-hosted JWT IdP) and sets\n * IdentityContext.\n *\n * `x-webiny-authorization` exists for AWS parity: behind CloudFront with Origin Access Control, SigV4\n * occupies the `Authorization` header, so clients that may traverse such an origin send the token in\n * that header instead. Standalone has no such constraint, but it accepts the same header so one\n * client works against both deployments.\n *\n * A token an identity provider rejects ends the request with a 401. Any other error propagates.\n *\n * Node counterpart of ApiGatewayIdentityLoaderDecorator. Registered before the tenant loader, which\n * makes it the inner wrapper: the tenant is loaded first, because API-key authentication looks the key up\n * in the tenant's partition.\n */\nclass NodeHttpIdentityLoaderDecoratorImpl implements NodeHttpInputHandler.Interface {\n constructor(\n private rawAuthToken: RawAuthToken.Interface,\n private identityLoader: IRequestIdentityLoader,\n private decoratee: NodeHttpInputHandler.Interface\n ) {}\n\n async execute(ctx: InputContext<IncomingMessage>, next: NextFunction): Promise<any> {\n const headers = headersFromIncomingMessage(ctx.input);\n const authToken = extractAuthToken(headers, {\n method: ctx.input.method,\n path: ctx.input.url\n });\n this.rawAuthToken.set(authToken);\n try {\n await this.identityLoader.establish();\n } catch (error) {\n if (error instanceof AuthenticationError) {\n return rejectedTokenResponse(error, headers);\n }\n throw error;\n }\n return this.decoratee.execute(ctx, next);\n }\n}\n\nexport const NodeHttpIdentityLoaderDecorator = NodeHttpInputHandler.createDecorator({\n decorator: NodeHttpIdentityLoaderDecoratorImpl,\n dependencies: [RawAuthToken, RequestIdentityLoader]\n});\n"],"names":["NodeHttpIdentityLoaderDecoratorImpl","rawAuthToken","identityLoader","decoratee","ctx","next","headers","headersFromIncomingMessage","authToken","extractAuthToken","error","AuthenticationError","rejectedTokenResponse","NodeHttpIdentityLoaderDecorator","NodeHttpInputHandler","RawAuthToken","RequestIdentityLoader"],"mappings":";;;;;;AA+BA,MAAMA;IACF,YACYC,YAAoC,EACpCC,cAAsC,EACtCC,SAAyC,CACnD;aAHUF,YAAY,GAAZA;aACAC,cAAc,GAAdA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,GAAkC,EAAEC,IAAkB,EAAgB;QAChF,MAAMC,UAAUC,2BAA2BH,IAAI,KAAK;QACpD,MAAMI,YAAYC,iBAAiBH,SAAS;YACxC,QAAQF,IAAI,KAAK,CAAC,MAAM;YACxB,MAAMA,IAAI,KAAK,CAAC,GAAG;QACvB;QACA,IAAI,CAAC,YAAY,CAAC,GAAG,CAACI;QACtB,IAAI;YACA,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS;QACvC,EAAE,OAAOE,OAAO;YACZ,IAAIA,iBAAiBC,qBACjB,OAAOC,sBAAsBF,OAAOJ;YAExC,MAAMI;QACV;QACA,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACN,KAAKC;IACvC;AACJ;AAEO,MAAMQ,kCAAkCC,qBAAqB,eAAe,CAAC;IAChF,WAAWd;IACX,cAAc;QAACe;QAAcC;KAAsB;AACvD"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import { NodeHttpInputHandler } from "@webiny/api-kernel-core/nodeHttp/index.js";
|
|
3
|
-
import { RawTenantId } from "@webiny/api-core/features/requestContext/index.js";
|
|
4
|
-
import type { IRequestTenantLoader } from "@webiny/api-core/features/requestContext/abstractions.js";
|
|
5
|
-
import type { InputContext, NextFunction } from "@webiny/api-kernel-core";
|
|
6
|
-
/**
|
|
7
|
-
* EXTRACT (transport-specific): reads the tenant id from the `x-tenant` header of a Node
|
|
8
|
-
* `IncomingMessage` into RawTenantId, then invokes the shared LOAD step (RequestTenantLoader) which
|
|
9
|
-
* resolves the Tenant and sets TenantContext. A missing header leaves RawTenantId null → the loader
|
|
10
|
-
* defaults to the "root" tenant.
|
|
11
|
-
*
|
|
12
|
-
* Node mirror of ApiGatewayTenantLoaderDecorator. Registered AFTER the identity loader.
|
|
13
|
-
*/
|
|
14
|
-
declare class NodeHttpTenantLoaderDecoratorImpl implements NodeHttpInputHandler.Interface {
|
|
15
|
-
private rawTenantId;
|
|
16
|
-
private tenantLoader;
|
|
17
|
-
private decoratee;
|
|
18
|
-
constructor(rawTenantId: RawTenantId.Interface, tenantLoader: IRequestTenantLoader, decoratee: NodeHttpInputHandler.Interface);
|
|
19
|
-
execute(ctx: InputContext<IncomingMessage>, next: NextFunction): Promise<any>;
|
|
20
|
-
}
|
|
21
|
-
export declare const NodeHttpTenantLoaderDecorator: typeof NodeHttpTenantLoaderDecoratorImpl & {
|
|
22
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-kernel-core/nodeHttp/index.js").INodeHttpInputHandler>;
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { NodeHttpInputHandler } from "@webiny/api-kernel-core/nodeHttp/index.js";
|
|
2
|
-
import { RawTenantId, RequestTenantLoader } from "@webiny/api-core/features/requestContext/index.js";
|
|
3
|
-
import { extractTenantId } from "../auth/extractTenantId.js";
|
|
4
|
-
import { headersFromIncomingMessage } from "./headersFromIncomingMessage.js";
|
|
5
|
-
class NodeHttpTenantLoaderDecoratorImpl {
|
|
6
|
-
constructor(rawTenantId, tenantLoader, decoratee){
|
|
7
|
-
this.rawTenantId = rawTenantId;
|
|
8
|
-
this.tenantLoader = tenantLoader;
|
|
9
|
-
this.decoratee = decoratee;
|
|
10
|
-
}
|
|
11
|
-
async execute(ctx, next) {
|
|
12
|
-
const headers = headersFromIncomingMessage(ctx.input);
|
|
13
|
-
const tenantId = extractTenantId(headers);
|
|
14
|
-
this.rawTenantId.set(tenantId);
|
|
15
|
-
await this.tenantLoader.establish();
|
|
16
|
-
return this.decoratee.execute(ctx, next);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const NodeHttpTenantLoaderDecorator = NodeHttpInputHandler.createDecorator({
|
|
20
|
-
decorator: NodeHttpTenantLoaderDecoratorImpl,
|
|
21
|
-
dependencies: [
|
|
22
|
-
RawTenantId,
|
|
23
|
-
RequestTenantLoader
|
|
24
|
-
]
|
|
25
|
-
});
|
|
26
|
-
export { NodeHttpTenantLoaderDecorator };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=NodeHttpTenantLoaderDecorator.js.map
|