@webiny/api-composition-core 0.0.0-unstable.e1999482d0 → 6.6.0-alpha.14

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.
Files changed (67) hide show
  1. package/auth/extractAuthToken.d.ts +3 -6
  2. package/auth/extractAuthToken.js +5 -4
  3. package/auth/extractAuthToken.js.map +1 -1
  4. package/auth/extractTenantId.d.ts +2 -1
  5. package/auth/extractTenantId.js +3 -3
  6. package/auth/extractTenantId.js.map +1 -1
  7. package/auth/index.d.ts +0 -2
  8. package/auth/index.js +0 -1
  9. package/auth/rejectedTokenResponse.d.ts +3 -6
  10. package/auth/rejectedTokenResponse.js +2 -6
  11. package/auth/rejectedTokenResponse.js.map +1 -1
  12. package/buildParams/registerRootBuildParams.d.ts +15 -0
  13. package/buildParams/registerRootBuildParams.js +11 -0
  14. package/buildParams/registerRootBuildParams.js.map +1 -0
  15. package/http/HttpAssumePermissionsDecorator.d.ts +19 -0
  16. package/http/HttpAssumePermissionsDecorator.js +22 -0
  17. package/http/HttpAssumePermissionsDecorator.js.map +1 -0
  18. package/http/HttpIdentityLoaderDecorator.d.ts +28 -0
  19. package/{nodeHttp/NodeHttpIdentityLoaderDecorator.js → http/HttpIdentityLoaderDecorator.js} +10 -15
  20. package/http/HttpIdentityLoaderDecorator.js.map +1 -0
  21. package/http/HttpInputTenantSource.d.ts +13 -0
  22. package/http/HttpInputTenantSource.js +11 -0
  23. package/http/HttpInputTenantSource.js.map +1 -0
  24. package/http/HttpRequestContextFeature.d.ts +20 -0
  25. package/http/HttpRequestContextFeature.js +13 -0
  26. package/http/HttpRequestContextFeature.js.map +1 -0
  27. package/http/HttpTenantScopeRouter.d.ts +33 -0
  28. package/http/HttpTenantScopeRouter.js +58 -0
  29. package/http/HttpTenantScopeRouter.js.map +1 -0
  30. package/http/index.d.ts +3 -0
  31. package/http/index.js +2 -0
  32. package/http/readStreamInScope.d.ts +12 -0
  33. package/http/readStreamInScope.js +43 -0
  34. package/http/readStreamInScope.js.map +1 -0
  35. package/http/registerHttpTransport.d.ts +23 -0
  36. package/http/registerHttpTransport.js +13 -0
  37. package/http/registerHttpTransport.js.map +1 -0
  38. package/http/registerRootAllowedRequestHeaders.d.ts +26 -0
  39. package/http/registerRootAllowedRequestHeaders.js +39 -0
  40. package/http/registerRootAllowedRequestHeaders.js.map +1 -0
  41. package/index.d.ts +5 -5
  42. package/index.js +4 -3
  43. package/package.json +26 -26
  44. package/registerApiRequestStack.d.ts +36 -6
  45. package/registerApiRequestStack.js +26 -6
  46. package/registerApiRequestStack.js.map +1 -1
  47. package/requestRegistration/abstractions.d.ts +13 -3
  48. package/requestRegistration/abstractions.js.map +1 -1
  49. package/auth/getHeader.d.ts +0 -5
  50. package/auth/getHeader.js +0 -8
  51. package/auth/getHeader.js.map +0 -1
  52. package/buildParams/readBuildParams.d.ts +0 -10
  53. package/buildParams/readBuildParams.js +0 -13
  54. package/buildParams/readBuildParams.js.map +0 -1
  55. package/nodeHttp/NodeHttpAssumePermissionsDecorator.d.ts +0 -19
  56. package/nodeHttp/NodeHttpAssumePermissionsDecorator.js +0 -23
  57. package/nodeHttp/NodeHttpAssumePermissionsDecorator.js.map +0 -1
  58. package/nodeHttp/NodeHttpIdentityLoaderDecorator.d.ts +0 -34
  59. package/nodeHttp/NodeHttpIdentityLoaderDecorator.js.map +0 -1
  60. package/nodeHttp/NodeHttpTenantLoaderDecorator.d.ts +0 -24
  61. package/nodeHttp/NodeHttpTenantLoaderDecorator.js +0 -28
  62. package/nodeHttp/NodeHttpTenantLoaderDecorator.js.map +0 -1
  63. package/nodeHttp/headersFromIncomingMessage.d.ts +0 -6
  64. package/nodeHttp/headersFromIncomingMessage.js +0 -9
  65. package/nodeHttp/headersFromIncomingMessage.js.map +0 -1
  66. package/nodeHttp/index.d.ts +0 -3
  67. 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";
2
- export type { RegisterApiRequestStackConfig } from "./registerApiRequestStack.js";
1
+ export { registerApiRequestStack, registerApiRequestStackInOneContainer, registerApiTenantScope } from "./registerApiRequestStack.js";
2
+ export type { RegisterApiRequestStackConfig, RegisterApiRequestStackInOneContainerOptions } 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 { rejectedTokenResponse } from "./auth/index.js";
8
- export { readBuildParams } from "./buildParams/readBuildParams.js";
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, rejectedTokenResponse } from "./auth/index.js";
4
- export { readBuildParams } from "./buildParams/readBuildParams.js";
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": "0.0.0-unstable.e1999482d0",
3
+ "version": "6.6.0-alpha.14",
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": "0.0.0-unstable.e1999482d0",
22
- "@webiny/api-audit-logs": "0.0.0-unstable.e1999482d0",
23
- "@webiny/api-core": "0.0.0-unstable.e1999482d0",
24
- "@webiny/api-dashboard": "0.0.0-unstable.e1999482d0",
25
- "@webiny/api-file-manager": "0.0.0-unstable.e1999482d0",
26
- "@webiny/api-file-manager-aco": "0.0.0-unstable.e1999482d0",
27
- "@webiny/api-graphql": "0.0.0-unstable.e1999482d0",
28
- "@webiny/api-headless-cms": "0.0.0-unstable.e1999482d0",
29
- "@webiny/api-headless-cms-aco": "0.0.0-unstable.e1999482d0",
30
- "@webiny/api-headless-cms-scheduler": "0.0.0-unstable.e1999482d0",
31
- "@webiny/api-headless-cms-tasks": "0.0.0-unstable.e1999482d0",
32
- "@webiny/api-headless-cms-workflows": "0.0.0-unstable.e1999482d0",
33
- "@webiny/api-kernel-core": "0.0.0-unstable.e1999482d0",
34
- "@webiny/api-mailer": "0.0.0-unstable.e1999482d0",
35
- "@webiny/api-record-locking": "0.0.0-unstable.e1999482d0",
36
- "@webiny/api-scheduler": "0.0.0-unstable.e1999482d0",
37
- "@webiny/api-website-builder": "0.0.0-unstable.e1999482d0",
38
- "@webiny/api-website-builder-scheduler": "0.0.0-unstable.e1999482d0",
39
- "@webiny/api-website-builder-workflows": "0.0.0-unstable.e1999482d0",
40
- "@webiny/api-websockets": "0.0.0-unstable.e1999482d0",
41
- "@webiny/api-workflows": "0.0.0-unstable.e1999482d0",
42
- "@webiny/background-tasks": "0.0.0-unstable.e1999482d0",
43
- "@webiny/feature": "0.0.0-unstable.e1999482d0",
44
- "@webiny/handler": "0.0.0-unstable.e1999482d0",
21
+ "@webiny/api-aco": "6.6.0-alpha.14",
22
+ "@webiny/api-audit-logs": "6.6.0-alpha.14",
23
+ "@webiny/api-core": "6.6.0-alpha.14",
24
+ "@webiny/api-dashboard": "6.6.0-alpha.14",
25
+ "@webiny/api-file-manager": "6.6.0-alpha.14",
26
+ "@webiny/api-file-manager-aco": "6.6.0-alpha.14",
27
+ "@webiny/api-graphql": "6.6.0-alpha.14",
28
+ "@webiny/api-headless-cms": "6.6.0-alpha.14",
29
+ "@webiny/api-headless-cms-aco": "6.6.0-alpha.14",
30
+ "@webiny/api-headless-cms-scheduler": "6.6.0-alpha.14",
31
+ "@webiny/api-headless-cms-tasks": "6.6.0-alpha.14",
32
+ "@webiny/api-headless-cms-workflows": "6.6.0-alpha.14",
33
+ "@webiny/api-kernel-core": "6.6.0-alpha.14",
34
+ "@webiny/api-mailer": "6.6.0-alpha.14",
35
+ "@webiny/api-record-locking": "6.6.0-alpha.14",
36
+ "@webiny/api-scheduler": "6.6.0-alpha.14",
37
+ "@webiny/api-website-builder": "6.6.0-alpha.14",
38
+ "@webiny/api-website-builder-scheduler": "6.6.0-alpha.14",
39
+ "@webiny/api-website-builder-workflows": "6.6.0-alpha.14",
40
+ "@webiny/api-websockets": "6.6.0-alpha.14",
41
+ "@webiny/api-workflows": "6.6.0-alpha.14",
42
+ "@webiny/background-tasks": "6.6.0-alpha.14",
43
+ "@webiny/feature": "6.6.0-alpha.14",
44
+ "@webiny/handler": "6.6.0-alpha.14",
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": "0.0.0-unstable.e1999482d0",
52
+ "@webiny/build-tools": "6.6.0-alpha.14",
53
53
  "@webiny/di": "2.0.0",
54
54
  "jsonwebtoken": "9.0.3",
55
55
  "rimraf": "6.1.4",
@@ -1,5 +1,6 @@
1
1
  import type { Container } from "@webiny/di";
2
2
  import { registerExtensions } from "@webiny/handler";
3
+ import type { TenantStorageBackend } from "@webiny/api-core/features/tenancy/TenantStorages/index.js";
3
4
  /** Installs a hosting-specific transport adapter into the per-request container at its interleave point. */
4
5
  export type TransportRegistrar = (container: Container) => void | Promise<void>;
5
6
  export interface RegisterApiRequestStackConfig {
@@ -41,18 +42,47 @@ export interface RegisterApiRequestStackConfig {
41
42
  };
42
43
  }
43
44
  /**
44
- * Registers the transport-AGNOSTIC Webiny API request stack: every domain feature + the GraphQL
45
- * engine, in the correct (order-sensitive) sequence. This is shared by all transport composition
46
- * packages (`@webiny/api-composition-aws`, and the future `-server`) so the feature set and its
45
+ * Registers the transport-AGNOSTIC Webiny API request stack. This is shared by all transport
46
+ * composition packages (`@webiny/api-composition-aws`, `-standalone`) so the feature set and its
47
47
  * ordering live in ONE place and can't drift between transports.
48
48
  *
49
+ * The request container gets only the tenant-neutral part: the raw request values, the request's
50
+ * tenant cache and `TenantScopes`. It holds no storage: the request's tenant is read in root's scope. Build params come from the
51
+ * deploy, the same for every request and tenant, so the transport registers them once in the root
52
+ * (`registerRootBuildParams`), before any request registers a feature that reads them (features
53
+ * gate themselves on `FeatureFlags`, a build param, at register() time). Everything else is
54
+ * tenant-specific and registers in each tenant scope the request enters, through the
55
+ * `TenantScopeRegistration` registered here ({@link registerApiTenantScope}). The request's own work
56
+ * runs in its tenant's scope (`TenantScopesRootFeature`, which the transport registers in the root).
57
+ *
49
58
  * Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}
50
59
  * at their exact interleave points. The caller is responsible for the ROOT-container transport wiring
51
- * (HTTP/event transport, auth/tenant loaders, identity provider, DB + storage) before dispatch reaches
60
+ * (HTTP/event transport, tenant sources, identity loaders, DB + storage) before dispatch reaches
52
61
  * this per-request stack. That includes the `Logger`: api-core registers none, so a root without one
53
62
  * fails the first time anything that logs is built.
63
+ */
64
+ export declare function registerApiRequestStack(container: Container, config: RegisterApiRequestStackConfig): Promise<void>;
65
+ export interface RegisterApiRequestStackInOneContainerOptions {
66
+ /** The storage's backend to register. Default: the default storage's. */
67
+ backend?: TenantStorageBackend.Interface;
68
+ }
69
+ /**
70
+ * Registers the request stack in ONE container: the tenant-neutral part and a tenant scope's part on
71
+ * the default storage, or on the storage of `options.backend`. For work outside a request that needs
72
+ * everything a request has, without a tenant: the SQL schema setup, which sets up the tables of
73
+ * exactly the storages and modules the API runs, once per storage.
74
+ *
75
+ * The container is its own `RequestContainer`, as a request's is: services built while it
76
+ * registers (`TenantContext`, through `TenantScopes`) depend on it.
77
+ */
78
+ export declare function registerApiRequestStackInOneContainer(container: Container, config: RegisterApiRequestStackConfig, options?: RegisterApiRequestStackInOneContainerOptions): Promise<void>;
79
+ /**
80
+ * Registers a tenant scope's part of the request stack: every domain feature + the GraphQL engine,
81
+ * in the correct (order-sensitive) sequence, on top of the tenant-neutral part its parent (the
82
+ * request container) has. The scope's storage is already there: `TenantScopes` registers the
83
+ * scope's storage backend first.
54
84
  *
55
85
  * ORDER IS LOAD-BEARING — do not reorder. Notably: extensions must be applied before anything that
56
- * lists + caches the per-request model set; the GraphQL engine must be registered last.
86
+ * lists + caches the scope's model set; the GraphQL engine must be registered last.
57
87
  */
58
- export declare function registerApiRequestStack(container: Container, config: RegisterApiRequestStackConfig): Promise<void>;
88
+ export declare function registerApiTenantScope(container: Container, config: RegisterApiRequestStackConfig, extensions?: ReturnType<RegisterApiRequestStackConfig["extensions"]>): Promise<void>;
@@ -1,6 +1,9 @@
1
- import { registerBuildParams, registerExtensions } from "@webiny/handler";
1
+ import { registerExtensions } from "@webiny/handler";
2
+ import { RequestContainer } from "@webiny/api-kernel-core";
2
3
  import { GraphQLEngineFeature } from "@webiny/api-graphql";
3
- import { ApiCoreFeature, RequestStorage } from "@webiny/api-core";
4
+ import { ApiCoreFeature } from "@webiny/api-core";
5
+ import { TenantNeutralRequestFeature, TenantScopeRegistration } from "@webiny/api-core/features/tenancy/TenantScopes/index.js";
6
+ import { DEFAULT_TENANT_STORAGE, TenantStorages, createDefaultTenantStorageBackend } from "@webiny/api-core/features/tenancy/TenantStorages/index.js";
4
7
  import { WcpLicenseLoader } from "@webiny/api-core/features/wcp/WcpLicenseLoader.js";
5
8
  import { HeadlessCmsFeature } from "@webiny/api-headless-cms";
6
9
  import { AcoHcmsFeature } from "@webiny/api-headless-cms-aco";
@@ -23,11 +26,28 @@ import { WorkflowsFeature } from "@webiny/api-workflows";
23
26
  import { SchedulerFeature } from "@webiny/api-scheduler";
24
27
  async function registerApiRequestStack(container, config) {
25
28
  await WcpLicenseLoader.load();
26
- for (const storage of container.resolveAll(RequestStorage))await storage.register(container);
27
29
  const extensions = config.extensions();
28
- await registerBuildParams(container, extensions);
30
+ TenantNeutralRequestFeature.register(container);
31
+ container.registerInstance(TenantScopeRegistration, {
32
+ register: (scope)=>registerApiTenantScope(scope, config, extensions)
33
+ });
34
+ }
35
+ async function registerApiRequestStackInOneContainer(container, config, options = {}) {
36
+ container.registerInstance(RequestContainer, container);
37
+ await registerApiRequestStack(container, config);
38
+ const backend = options.backend ?? getDefaultBackend(container);
39
+ await backend.registerScope(container);
40
+ await registerApiTenantScope(container, config);
41
+ }
42
+ const getDefaultBackend = (container)=>{
43
+ const [storages] = container.resolveAll(TenantStorages);
44
+ const declared = storages?.getBackend(DEFAULT_TENANT_STORAGE);
45
+ return declared ?? createDefaultTenantStorageBackend();
46
+ };
47
+ async function registerApiTenantScope(container, config, extensions = config.extensions()) {
29
48
  ApiCoreFeature.register(container, {
30
- wcpLicense: void 0
49
+ wcpLicense: void 0,
50
+ tenantScope: true
31
51
  });
32
52
  await config.transports?.hostingConfig?.(container);
33
53
  HeadlessCmsFeature.register(container, {
@@ -57,6 +77,6 @@ async function registerApiRequestStack(container, config) {
57
77
  await registerExtensions(container, extensions);
58
78
  GraphQLEngineFeature.register(container);
59
79
  }
60
- export { registerApiRequestStack };
80
+ export { registerApiRequestStack, registerApiRequestStackInOneContainer, registerApiTenantScope };
61
81
 
62
82
  //# 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 } from \"@webiny/api-core\";\nimport { TenantNeutralRequestFeature } from \"@webiny/api-core/features/tenancy/TenantScopes/index.js\";\nimport { TenantScopeRegistration } from \"@webiny/api-core/features/tenancy/TenantScopes/index.js\";\nimport { TenantStorages } from \"@webiny/api-core/features/tenancy/TenantStorages/index.js\";\nimport { DEFAULT_TENANT_STORAGE } from \"@webiny/api-core/features/tenancy/TenantStorages/index.js\";\nimport { createDefaultTenantStorageBackend } from \"@webiny/api-core/features/tenancy/TenantStorages/index.js\";\nimport type { TenantStorageBackend } from \"@webiny/api-core/features/tenancy/TenantStorages/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 request's\n * tenant cache and `TenantScopes`. It holds no storage: the request's tenant is read in root's scope. 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 cache, 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\nexport interface RegisterApiRequestStackInOneContainerOptions {\n /** The storage's backend to register. Default: the default storage's. */\n backend?: TenantStorageBackend.Interface;\n}\n\n/**\n * Registers the request stack in ONE container: the tenant-neutral part and a tenant scope's part on\n * the default storage, or on the storage of `options.backend`. For work outside a request that needs\n * everything a request has, without a tenant: the SQL schema setup, which sets up the tables of\n * exactly the storages and modules the API runs, once per storage.\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 options: RegisterApiRequestStackInOneContainerOptions = {}\n): Promise<void> {\n container.registerInstance(RequestContainer, container);\n await registerApiRequestStack(container, config);\n\n // A tenant scope gets its storage from `TenantScopes`; this container is none, so it registers\n // the storage's itself, before any feature.\n const backend = options.backend ?? getDefaultBackend(container);\n await backend.registerScope(container);\n\n await registerApiTenantScope(container, config);\n}\n\nconst getDefaultBackend = (container: Container): TenantStorageBackend.Interface => {\n const [storages] = container.resolveAll(TenantStorages);\n const declared = storages?.getBackend(DEFAULT_TENANT_STORAGE);\n return declared ?? createDefaultTenantStorageBackend();\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. The scope's storage is already there: `TenantScopes` registers the\n * scope's storage backend first.\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 // ── 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","options","RequestContainer","backend","getDefaultBackend","storages","TenantStorages","declared","DEFAULT_TENANT_STORAGE","createDefaultTenantStorageBackend","ApiCoreFeature","undefined","HeadlessCmsFeature","AcoFeature","AcoHcmsFeature","HcmsTasksFeature","FileManagerAppFeature","FileManagerAcoFeature","WebsiteBuilderFeature","WebsiteBuilderWorkflowsFeature","WebsiteBuilderSchedulerFeature","WebsocketsFeature","MailerFeature","RecordLockingAppFeature","AuditLogsFeature","DashboardAppFeature","BackgroundTasksFeature","WorkflowsFeature","CmsWorkflowsFeature","SchedulerFeature","CmsSchedulerFeature","registerExtensions","GraphQLEngineFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8FO,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;AAgBO,eAAeK,sCAClBR,SAAoB,EACpBC,MAAqC,EACrCQ,UAAwD,CAAC,CAAC;IAE1DT,UAAU,gBAAgB,CAACU,kBAAkBV;IAC7C,MAAMD,wBAAwBC,WAAWC;IAIzC,MAAMU,UAAUF,QAAQ,OAAO,IAAIG,kBAAkBZ;IACrD,MAAMW,QAAQ,aAAa,CAACX;IAE5B,MAAMO,uBAAuBP,WAAWC;AAC5C;AAEA,MAAMW,oBAAoB,CAACZ;IACvB,MAAM,CAACa,SAAS,GAAGb,UAAU,UAAU,CAACc;IACxC,MAAMC,WAAWF,UAAU,WAAWG;IACtC,OAAOD,YAAYE;AACvB;AAWO,eAAeV,uBAClBP,SAAoB,EACpBC,MAAqC,EACrCE,aAAsEF,OAAO,UAAU,EAAE;IAIzFiB,eAAe,QAAQ,CAAClB,WAAW;QAAE,YAAYmB;QAAW,aAAa;IAAK;IAC9E,MAAMlB,OAAO,UAAU,EAAE,gBAAgBD;IAGzCoB,mBAAmB,QAAQ,CAACpB,WAAW;QAAE,MAAM;IAAS;IACxDqB,WAAW,QAAQ,CAACrB;IACpBsB,eAAe,QAAQ,CAACtB;IACxBuB,iBAAiB,QAAQ,CAACvB;IAG1BwB,sBAAsB,QAAQ,CAACxB;IAC/ByB,sBAAsB,QAAQ,CAACzB;IAC/B,MAAMC,OAAO,UAAU,EAAE,cAAcD;IAGvC0B,sBAAsB,QAAQ,CAAC1B;IAC/B2B,+BAA+B,QAAQ,CAAC3B;IACxC4B,+BAA+B,QAAQ,CAAC5B;IAGxC6B,kBAAkB,QAAQ,CAAC7B;IAC3B,MAAMC,OAAO,UAAU,EAAE,WAAWD;IAGpC8B,cAAc,QAAQ,CAAC9B;IACvB+B,wBAAwB,QAAQ,CAAC/B,WAAW,CAAC;IAC7CgC,iBAAiB,QAAQ,CAAChC,WAAW,CAAC;IACtCiC,oBAAoB,QAAQ,CAACjC;IAC7BkC,uBAAuB,QAAQ,CAAClC;IAGhCmC,iBAAiB,QAAQ,CAACnC;IAC1BoC,oBAAoB,QAAQ,CAACpC;IAG7BqC,iBAAiB,QAAQ,CAACrC;IAC1B,MAAMC,OAAO,UAAU,EAAE,YAAYD;IACrCsC,oBAAoB,QAAQ,CAACtC;IAS7B,MAAMuC,mBAAmBvC,WAAWG;IAGpCqC,qBAAqB,QAAQ,CAACxC;AAClC"}
@@ -1,11 +1,20 @@
1
1
  import type { Container } from "@webiny/di";
2
+ import type { TenantStorageBackend } from "@webiny/api-core/features/tenancy/TenantStorages/index.js";
3
+ export interface IApiRequestRegistrationOptions {
4
+ /**
5
+ * The storage to register, as a tenant scope on it would: an extra storage's backend (the SQL
6
+ * schema setup binds it to its own connection). Default: the default storage's.
7
+ */
8
+ backend?: TenantStorageBackend.Interface;
9
+ }
2
10
  export interface IApiRequestRegistration {
3
11
  /**
4
12
  * Registers what a request has into `container`, exactly as the transport does for every request
5
- * (its `child` step): the storages (every `RequestStorage`), the API's features with the
6
- * transport's adapters, and the project's extensions.
13
+ * (its `child` step) and the tenant scope on the storage: the storage (the default storage's
14
+ * backend unless `options.backend` names another), the API's features with the transport's
15
+ * adapters, and the project's extensions.
7
16
  */
8
- register(container: Container): Promise<void>;
17
+ register(container: Container, options?: IApiRequestRegistrationOptions): Promise<void>;
9
18
  }
10
19
  /**
11
20
  * The transport's request registration, in the root container. Lets work that runs outside any
@@ -15,4 +24,5 @@ export interface IApiRequestRegistration {
15
24
  export declare const ApiRequestRegistration: import("@webiny/di").Abstraction<IApiRequestRegistration>;
16
25
  export declare namespace ApiRequestRegistration {
17
26
  type Interface = IApiRequestRegistration;
27
+ type Options = IApiRequestRegistrationOptions;
18
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"requestRegistration/abstractions.js","sources":["../../src/requestRegistration/abstractions.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IApiRequestRegistration {\n /**\n * Registers what a request has into `container`, exactly as the transport does for every request\n * (its `child` step): the storages (every `RequestStorage`), the API's features with the\n * transport's adapters, and the project's extensions.\n */\n register(container: Container): Promise<void>;\n}\n\n/**\n * The transport's request registration, in the root container. Lets work that runs outside any\n * request build a container a request would have: the SQL schema setup builds one on its own\n * connection, so it sets up the tables of exactly the storages and modules the API runs.\n */\nexport const ApiRequestRegistration = createAbstraction<IApiRequestRegistration>(\n \"Core/ApiRequestRegistration\"\n);\n\nexport namespace ApiRequestRegistration {\n export type Interface = IApiRequestRegistration;\n}\n"],"names":["ApiRequestRegistration","createAbstraction"],"mappings":";AAiBO,MAAMA,yBAAyBC,kBAClC"}
1
+ {"version":3,"file":"requestRegistration/abstractions.js","sources":["../../src/requestRegistration/abstractions.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { TenantStorageBackend } from \"@webiny/api-core/features/tenancy/TenantStorages/index.js\";\n\nexport interface IApiRequestRegistrationOptions {\n /**\n * The storage to register, as a tenant scope on it would: an extra storage's backend (the SQL\n * schema setup binds it to its own connection). Default: the default storage's.\n */\n backend?: TenantStorageBackend.Interface;\n}\n\nexport interface IApiRequestRegistration {\n /**\n * Registers what a request has into `container`, exactly as the transport does for every request\n * (its `child` step) and the tenant scope on the storage: the storage (the default storage's\n * backend unless `options.backend` names another), the API's features with the transport's\n * adapters, and the project's extensions.\n */\n register(container: Container, options?: IApiRequestRegistrationOptions): Promise<void>;\n}\n\n/**\n * The transport's request registration, in the root container. Lets work that runs outside any\n * request build a container a request would have: the SQL schema setup builds one on its own\n * connection, so it sets up the tables of exactly the storages and modules the API runs.\n */\nexport const ApiRequestRegistration = createAbstraction<IApiRequestRegistration>(\n \"Core/ApiRequestRegistration\"\n);\n\nexport namespace ApiRequestRegistration {\n export type Interface = IApiRequestRegistration;\n export type Options = IApiRequestRegistrationOptions;\n}\n"],"names":["ApiRequestRegistration","createAbstraction"],"mappings":";AA2BO,MAAMA,yBAAyBC,kBAClC"}
@@ -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
@@ -1,8 +0,0 @@
1
- function getHeader(headers, name) {
2
- if (!headers) return "";
3
- for (const key of Object.keys(headers))if (key.toLowerCase() === name) return headers[key] ?? "";
4
- return "";
5
- }
6
- export { getHeader };
7
-
8
- //# sourceMappingURL=getHeader.js.map
@@ -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 {};