@webiny/api-event-handler-standalone-sql 0.0.0-unstable.7c2def32a7 → 0.0.0-unstable.9609e4e0c9
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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* remain legacy RegisterExtensionPlugins applied via `registerExtensions`.
|
|
8
8
|
*
|
|
9
9
|
* The caller supplies the Knex client (there is no single canonical connection for a standalone DB).
|
|
10
|
-
* The JWT signing secret is
|
|
10
|
+
* The JWT signing secret is read from `WEBINY_SELF_HOSTED_AUTH_SECRET` when the handler is created.
|
|
11
11
|
*/
|
|
12
12
|
import type { Knex } from "knex";
|
|
13
13
|
import { type CreateWebinyApiHandlerConfig as BaseConfig } from "@webiny/api-event-handler-standalone";
|
|
@@ -6,9 +6,11 @@ import { registerAcoSqlStorageOperations } from "@webiny/api-aco-sql";
|
|
|
6
6
|
import { registerAuditLogsSqlStorageOperations } from "@webiny/api-audit-logs-sql";
|
|
7
7
|
import { WebsocketsSqlFeature } from "@webiny/api-websockets-sql";
|
|
8
8
|
import { SelfHostedAuthApiFeature } from "@webiny/self-hosted-auth";
|
|
9
|
+
import { readSigningSecret } from "./readSigningSecret.js";
|
|
9
10
|
import { SelfHostedAuthSqlFeature } from "@webiny/self-hosted-auth-sql";
|
|
10
11
|
function createSqlApiHandler(config) {
|
|
11
12
|
const { knex, tableNamePrefix } = config;
|
|
13
|
+
const signingSecret = readSigningSecret(process.env);
|
|
12
14
|
return createWebinyApiHandler({
|
|
13
15
|
extensions: config.extensions,
|
|
14
16
|
registerRootStorage: async (container)=>{
|
|
@@ -23,7 +25,9 @@ function createSqlApiHandler(config) {
|
|
|
23
25
|
knex,
|
|
24
26
|
tableNamePrefix
|
|
25
27
|
});
|
|
26
|
-
SelfHostedAuthApiFeature.register(container
|
|
28
|
+
SelfHostedAuthApiFeature.register(container, {
|
|
29
|
+
signingSecret
|
|
30
|
+
});
|
|
27
31
|
HeadlessCmsSqlFeature.register(container, {
|
|
28
32
|
knex,
|
|
29
33
|
tableNamePrefix
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWebinyApiHandler.js","sources":["../src/createWebinyApiHandler.ts"],"sourcesContent":["/**\n * Webiny API handler for the standalone Node server transport with SQL storage.\n *\n * Thin variant over the transport base (@webiny/api-event-handler-standalone): supplies the SQL storage\n * wiring AND the self-hosted identity provider (JWT IdP + SQL credential storage). CMS, core, and\n * websockets storage are DI Features registered directly on the container. ACO and audit-logs\n * remain legacy RegisterExtensionPlugins applied via `registerExtensions`.\n *\n * The caller supplies the Knex client (there is no single canonical connection for a standalone DB).\n * The JWT signing secret is
|
|
1
|
+
{"version":3,"file":"createWebinyApiHandler.js","sources":["../src/createWebinyApiHandler.ts"],"sourcesContent":["/**\n * Webiny API handler for the standalone Node server transport with SQL storage.\n *\n * Thin variant over the transport base (@webiny/api-event-handler-standalone): supplies the SQL storage\n * wiring AND the self-hosted identity provider (JWT IdP + SQL credential storage). CMS, core, and\n * websockets storage are DI Features registered directly on the container. ACO and audit-logs\n * remain legacy RegisterExtensionPlugins applied via `registerExtensions`.\n *\n * The caller supplies the Knex client (there is no single canonical connection for a standalone DB).\n * The JWT signing secret is read from `WEBINY_SELF_HOSTED_AUTH_SECRET` when the handler is created.\n */\nimport type { Knex } from \"knex\";\nimport { registerExtensions } from \"@webiny/handler\";\nimport {\n createWebinyApiHandler as createBaseHandler,\n type CreateWebinyApiHandlerConfig as BaseConfig\n} from \"@webiny/api-event-handler-standalone\";\nimport { ApiCoreSqlFeature, registerSQLCore } from \"@webiny/api-core-sql\";\nimport { HeadlessCmsSqlFeature } from \"@webiny/api-headless-cms-sql\";\nimport { registerAcoSqlStorageOperations } from \"@webiny/api-aco-sql\";\nimport { registerAuditLogsSqlStorageOperations } from \"@webiny/api-audit-logs-sql\";\nimport { WebsocketsSqlFeature } from \"@webiny/api-websockets-sql\";\nimport { SelfHostedAuthApiFeature } from \"@webiny/self-hosted-auth\";\nimport { readSigningSecret } from \"~/readSigningSecret.js\";\nimport { SelfHostedAuthSqlFeature } from \"@webiny/self-hosted-auth-sql\";\n\nexport type CreateSqlApiHandlerConfig = Pick<BaseConfig, \"extensions\"> & {\n /**\n * Knex client for the SQL database. Required — the caller owns the connection (there is no single\n * canonical standalone DB connection to default to).\n */\n knex: Knex;\n /**\n * Optional table-name prefix, threaded to every SQL storage operation.\n */\n tableNamePrefix?: string;\n};\n\nexport function createSqlApiHandler(config: CreateSqlApiHandlerConfig) {\n const { knex, tableNamePrefix } = config;\n // Read once, so a missing secret stops the server at boot instead of failing the first login.\n const signingSecret = readSigningSecret(process.env);\n\n return createBaseHandler({\n extensions: config.extensions,\n registerRootStorage: async container => {\n // Clean DI Features: SQL core storage-ops factory + websockets storage.\n ApiCoreSqlFeature.register(container, { knex, tableNamePrefix });\n WebsocketsSqlFeature.register(container, { tableNamePrefix });\n\n // Identity provider: the self-hosted JWT IdP + its SQL credential storage. Registered in\n // the root so the RequestIdentityLoader (driven by NodeHttpIdentityLoaderDecorator) can\n // resolve it. SelfHostedAuthSqlFeature supplies the credential storage operations over Knex.\n SelfHostedAuthSqlFeature.register(container, { knex, tableNamePrefix });\n SelfHostedAuthApiFeature.register(container, { signingSecret });\n\n HeadlessCmsSqlFeature.register(container, { knex, tableNamePrefix });\n\n await registerExtensions(container, [\n registerSQLCore({ knex }),\n registerAcoSqlStorageOperations({ knex, tableNamePrefix }),\n registerAuditLogsSqlStorageOperations({ knex, tableNamePrefix })\n ]);\n }\n });\n}\n"],"names":["createSqlApiHandler","config","knex","tableNamePrefix","signingSecret","readSigningSecret","process","createBaseHandler","container","ApiCoreSqlFeature","WebsocketsSqlFeature","SelfHostedAuthSqlFeature","SelfHostedAuthApiFeature","HeadlessCmsSqlFeature","registerExtensions","registerSQLCore","registerAcoSqlStorageOperations","registerAuditLogsSqlStorageOperations"],"mappings":";;;;;;;;;;AAsCO,SAASA,oBAAoBC,MAAiC;IACjE,MAAM,EAAEC,IAAI,EAAEC,eAAe,EAAE,GAAGF;IAElC,MAAMG,gBAAgBC,kBAAkBC,QAAQ,GAAG;IAEnD,OAAOC,uBAAkB;QACrB,YAAYN,OAAO,UAAU;QAC7B,qBAAqB,OAAMO;YAEvBC,kBAAkB,QAAQ,CAACD,WAAW;gBAAEN;gBAAMC;YAAgB;YAC9DO,qBAAqB,QAAQ,CAACF,WAAW;gBAAEL;YAAgB;YAK3DQ,yBAAyB,QAAQ,CAACH,WAAW;gBAAEN;gBAAMC;YAAgB;YACrES,yBAAyB,QAAQ,CAACJ,WAAW;gBAAEJ;YAAc;YAE7DS,sBAAsB,QAAQ,CAACL,WAAW;gBAAEN;gBAAMC;YAAgB;YAElE,MAAMW,mBAAmBN,WAAW;gBAChCO,gBAAgB;oBAAEb;gBAAK;gBACvBc,gCAAgC;oBAAEd;oBAAMC;gBAAgB;gBACxDc,sCAAsC;oBAAEf;oBAAMC;gBAAgB;aACjE;QACL;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-event-handler-standalone-sql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.9609e4e0c9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -18,31 +18,31 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api-aco-sql": "0.0.0-unstable.
|
|
22
|
-
"@webiny/api-audit-logs-sql": "0.0.0-unstable.
|
|
23
|
-
"@webiny/api-core-sql": "0.0.0-unstable.
|
|
24
|
-
"@webiny/api-event-handler-standalone": "0.0.0-unstable.
|
|
25
|
-
"@webiny/api-headless-cms-sql": "0.0.0-unstable.
|
|
26
|
-
"@webiny/api-websockets-sql": "0.0.0-unstable.
|
|
27
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
28
|
-
"@webiny/self-hosted-auth": "0.0.0-unstable.
|
|
29
|
-
"@webiny/self-hosted-auth-sql": "0.0.0-unstable.
|
|
21
|
+
"@webiny/api-aco-sql": "0.0.0-unstable.9609e4e0c9",
|
|
22
|
+
"@webiny/api-audit-logs-sql": "0.0.0-unstable.9609e4e0c9",
|
|
23
|
+
"@webiny/api-core-sql": "0.0.0-unstable.9609e4e0c9",
|
|
24
|
+
"@webiny/api-event-handler-standalone": "0.0.0-unstable.9609e4e0c9",
|
|
25
|
+
"@webiny/api-headless-cms-sql": "0.0.0-unstable.9609e4e0c9",
|
|
26
|
+
"@webiny/api-websockets-sql": "0.0.0-unstable.9609e4e0c9",
|
|
27
|
+
"@webiny/handler": "0.0.0-unstable.9609e4e0c9",
|
|
28
|
+
"@webiny/self-hosted-auth": "0.0.0-unstable.9609e4e0c9",
|
|
29
|
+
"@webiny/self-hosted-auth-sql": "0.0.0-unstable.9609e4e0c9",
|
|
30
30
|
"@webiny/stdlib": "0.0.21",
|
|
31
31
|
"better-sqlite3": "13.0.3",
|
|
32
32
|
"knex": "3.3.0",
|
|
33
|
-
"pg": "8.23.
|
|
33
|
+
"pg": "8.23.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@webiny/api-aco": "0.0.0-unstable.
|
|
37
|
-
"@webiny/api-audit-logs": "0.0.0-unstable.
|
|
38
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
39
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
40
|
-
"@webiny/api-websockets": "0.0.0-unstable.
|
|
41
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
36
|
+
"@webiny/api-aco": "0.0.0-unstable.9609e4e0c9",
|
|
37
|
+
"@webiny/api-audit-logs": "0.0.0-unstable.9609e4e0c9",
|
|
38
|
+
"@webiny/api-core": "0.0.0-unstable.9609e4e0c9",
|
|
39
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.9609e4e0c9",
|
|
40
|
+
"@webiny/api-websockets": "0.0.0-unstable.9609e4e0c9",
|
|
41
|
+
"@webiny/build-tools": "0.0.0-unstable.9609e4e0c9",
|
|
42
42
|
"@webiny/di": "2.0.0",
|
|
43
43
|
"rimraf": "6.1.3",
|
|
44
44
|
"typescript": "7.0.2",
|
|
45
|
-
"vitest": "
|
|
45
|
+
"vitest": "5.0.5"
|
|
46
46
|
},
|
|
47
47
|
"adio": {
|
|
48
48
|
"ignore": {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type Env = Record<string, string | undefined>;
|
|
2
|
+
/**
|
|
3
|
+
* The self-hosted auth signing secret, from env. Throws when it is missing or blank: without it no
|
|
4
|
+
* one can log in, and falling back to a known value would let anyone mint a login token.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readSigningSecret(env: Env): string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SIGNING_SECRET_ENV_VAR } from "@webiny/self-hosted-auth";
|
|
2
|
+
function readSigningSecret(env) {
|
|
3
|
+
const secret = env[SIGNING_SECRET_ENV_VAR];
|
|
4
|
+
if (!secret?.trim()) throw new Error(`The standalone API is missing required configuration: ${SIGNING_SECRET_ENV_VAR} is not set.`);
|
|
5
|
+
return secret;
|
|
6
|
+
}
|
|
7
|
+
export { readSigningSecret };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=readSigningSecret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readSigningSecret.js","sources":["../src/readSigningSecret.ts"],"sourcesContent":["import { SIGNING_SECRET_ENV_VAR } from \"@webiny/self-hosted-auth\";\n\ntype Env = Record<string, string | undefined>;\n\n/**\n * The self-hosted auth signing secret, from env. Throws when it is missing or blank: without it no\n * one can log in, and falling back to a known value would let anyone mint a login token.\n */\nexport function readSigningSecret(env: Env): string {\n /*\n * Blank means unset, but the value itself is used as given: `webiny reset-password` signs with\n * the untrimmed value, and existing tokens were signed with it.\n */\n const secret = env[SIGNING_SECRET_ENV_VAR];\n if (!secret?.trim()) {\n throw new Error(\n `The standalone API is missing required configuration: ${SIGNING_SECRET_ENV_VAR} is not set.`\n );\n }\n\n return secret;\n}\n"],"names":["readSigningSecret","env","secret","SIGNING_SECRET_ENV_VAR","Error"],"mappings":";AAQO,SAASA,kBAAkBC,GAAQ;IAKtC,MAAMC,SAASD,GAAG,CAACE,uBAAuB;IAC1C,IAAI,CAACD,QAAQ,QACT,MAAM,IAAIE,MACN,CAAC,sDAAsD,EAAED,uBAAuB,YAAY,CAAC;IAIrG,OAAOD;AACX"}
|