@webiny/api-composition-standalone-sql 0.0.0-stage β 0.0.0-unstable.676006d08e
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/LICENSE +21 -0
- package/README.md +10 -2
- package/createWebinyApiHandler.d.ts +43 -0
- package/createWebinyApiHandler.js +52 -0
- package/createWebinyApiHandler.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +60 -5
- package/readSigningSecret.d.ts +7 -0
- package/readSigningSecret.js +9 -0
- package/readSigningSecret.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @webiny/api-composition-standalone-sql
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webiny API handler for the standalone Node server transport on a SQL storage.
|
|
3
|
+
*
|
|
4
|
+
* Thin variant over the transport base (@webiny/api-composition-standalone): takes the storage
|
|
5
|
+
* (`createSqliteStorage` from @webiny/api-storage-sqlite, or `createPgStorage` from
|
|
6
|
+
* @webiny/api-storage-pg, each built from its connection) and adds the self-hosted identity provider
|
|
7
|
+
* (JWT IdP + SQL credential storage) on the storage's connection.
|
|
8
|
+
*
|
|
9
|
+
* Extra storages (`storages`) are SQL storages built with an `id`: only the tenants whose
|
|
10
|
+
* `settings.storage` names one run on it. Root and the tenant registry stay on the default storage.
|
|
11
|
+
*
|
|
12
|
+
* At start, before the server accepts a request, it runs every storage's schema setup
|
|
13
|
+
* (`runSqlSchemaSetups`) on a container built the way a scope on that storage is, so the storage,
|
|
14
|
+
* the login tables and the modules among the project's extensions set up theirs. Then each storage
|
|
15
|
+
* is schema-managed: no request checks for or creates tables. The JWT signing secret is read from
|
|
16
|
+
* `WEBINY_SELF_HOSTED_AUTH_SECRET` when the handler is created.
|
|
17
|
+
*/
|
|
18
|
+
import type { Container } from "@webiny/di";
|
|
19
|
+
import { type SqlStorage } from "@webiny/api-core-sql";
|
|
20
|
+
import { type CreateWebinyApiHandlerConfig as BaseConfig } from "@webiny/api-composition-standalone";
|
|
21
|
+
export type CreateSqlApiHandlerConfig = Pick<BaseConfig, "extensions"> & {
|
|
22
|
+
/** The SQL storage of the API, built from its connection: the default storage, root's. */
|
|
23
|
+
storage: SqlStorage;
|
|
24
|
+
/**
|
|
25
|
+
* Extra storages tenants can be placed on, each built with its own `id` (`createPgStorage`,
|
|
26
|
+
* `createSqliteStorage`). A tenant runs on one when its `settings.storage` names it.
|
|
27
|
+
*/
|
|
28
|
+
storages?: SqlStorage[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* What the handler puts in the root container, once per process: the default storage (the
|
|
32
|
+
* connection and its settings, its `RequestStorage` and its schema setup runner), each extra storage
|
|
33
|
+
* (its backend and its runner), the login storage's part of every SQL storage (`SqlScopeStorage`),
|
|
34
|
+
* and the self-hosted JWT identity provider. The IdP is in the root so the RequestIdentityLoader
|
|
35
|
+
* (driven by HttpIdentityLoaderDecorator) can resolve it; it only needs the token issuer, and the
|
|
36
|
+
* login use cases it registers resolve the credential storage from the tenant's scope.
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerSqlApiRoot(container: Container, params: {
|
|
39
|
+
storage: SqlStorage;
|
|
40
|
+
storages?: SqlStorage[];
|
|
41
|
+
signingSecret: string;
|
|
42
|
+
}): void;
|
|
43
|
+
export declare function createSqlApiHandler(config: CreateSqlApiHandlerConfig): Promise<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TenantStorageId } from "@webiny/api-core/features/tenancy/TenantStorages/index.js";
|
|
2
|
+
import { SqlScopeStorage, runSqlSchemaSetups } from "@webiny/api-core-sql";
|
|
3
|
+
import { ApiRequestRegistration } from "@webiny/api-composition-core";
|
|
4
|
+
import { createWebinyApiHandler } from "@webiny/api-composition-standalone";
|
|
5
|
+
import { SelfHostedAuthApiFeature } from "@webiny/self-hosted-auth";
|
|
6
|
+
import { SelfHostedAuthSqlFeature } from "@webiny/self-hosted-auth-sql";
|
|
7
|
+
import { readSigningSecret } from "./readSigningSecret.js";
|
|
8
|
+
const SelfHostedAuthScopeStorage = {
|
|
9
|
+
register (container) {
|
|
10
|
+
SelfHostedAuthSqlFeature.register(container);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const assertStorageIds = (storage, storages)=>{
|
|
14
|
+
if (!TenantStorageId.from(storage.id).isDefault()) throw new Error(`The API's storage is the default storage and takes no id, but it has the id "${storage.id}".`);
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
for (const extra of storages){
|
|
17
|
+
if (TenantStorageId.from(extra.id).isDefault()) throw new Error(`An extra storage needs an id of its own: "${TenantStorageId.DEFAULT.toString()}" is the default storage's.`);
|
|
18
|
+
if (seen.has(extra.id)) throw new Error(`Two extra storages have the id "${extra.id}".`);
|
|
19
|
+
seen.add(extra.id);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function registerSqlApiRoot(container, params) {
|
|
23
|
+
const storages = params.storages ?? [];
|
|
24
|
+
assertStorageIds(params.storage, storages);
|
|
25
|
+
params.storage.register(container);
|
|
26
|
+
for (const extra of storages)extra.register(container);
|
|
27
|
+
container.registerInstance(SqlScopeStorage, SelfHostedAuthScopeStorage);
|
|
28
|
+
SelfHostedAuthApiFeature.register(container, {
|
|
29
|
+
signingSecret: params.signingSecret
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function createSqlApiHandler(config) {
|
|
33
|
+
const { storage, storages } = config;
|
|
34
|
+
const signingSecret = readSigningSecret(process.env);
|
|
35
|
+
return createWebinyApiHandler({
|
|
36
|
+
extensions: config.extensions,
|
|
37
|
+
registerRootStorage: async (container)=>{
|
|
38
|
+
registerSqlApiRoot(container, {
|
|
39
|
+
storage,
|
|
40
|
+
storages,
|
|
41
|
+
signingSecret
|
|
42
|
+
});
|
|
43
|
+
await runSqlSchemaSetups({
|
|
44
|
+
root: container,
|
|
45
|
+
request: container.resolve(ApiRequestRegistration)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export { createSqlApiHandler, registerSqlApiRoot };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=createWebinyApiHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWebinyApiHandler.js","sources":["../src/createWebinyApiHandler.ts"],"sourcesContent":["/**\n * Webiny API handler for the standalone Node server transport on a SQL storage.\n *\n * Thin variant over the transport base (@webiny/api-composition-standalone): takes the storage\n * (`createSqliteStorage` from @webiny/api-storage-sqlite, or `createPgStorage` from\n * @webiny/api-storage-pg, each built from its connection) and adds the self-hosted identity provider\n * (JWT IdP + SQL credential storage) on the storage's connection.\n *\n * Extra storages (`storages`) are SQL storages built with an `id`: only the tenants whose\n * `settings.storage` names one run on it. Root and the tenant registry stay on the default storage.\n *\n * At start, before the server accepts a request, it runs every storage's schema setup\n * (`runSqlSchemaSetups`) on a container built the way a scope on that storage is, so the storage,\n * the login tables and the modules among the project's extensions set up theirs. Then each storage\n * is schema-managed: no request checks for or creates tables. The JWT signing secret is read from\n * `WEBINY_SELF_HOSTED_AUTH_SECRET` when the handler is created.\n */\nimport type { Container } from \"@webiny/di\";\nimport { TenantStorageId } from \"@webiny/api-core/features/tenancy/TenantStorages/index.js\";\nimport { runSqlSchemaSetups, SqlScopeStorage, type SqlStorage } from \"@webiny/api-core-sql\";\nimport { ApiRequestRegistration } from \"@webiny/api-composition-core\";\nimport {\n createWebinyApiHandler as createBaseHandler,\n type CreateWebinyApiHandlerConfig as BaseConfig\n} from \"@webiny/api-composition-standalone\";\nimport { SelfHostedAuthApiFeature } from \"@webiny/self-hosted-auth\";\nimport { SelfHostedAuthSqlFeature } from \"@webiny/self-hosted-auth-sql\";\nimport { readSigningSecret } from \"~/readSigningSecret.js\";\n\nexport type CreateSqlApiHandlerConfig = Pick<BaseConfig, \"extensions\"> & {\n /** The SQL storage of the API, built from its connection: the default storage, root's. */\n storage: SqlStorage;\n /**\n * Extra storages tenants can be placed on, each built with its own `id` (`createPgStorage`,\n * `createSqliteStorage`). A tenant runs on one when its `settings.storage` names it.\n */\n storages?: SqlStorage[];\n};\n\n/*\n * The login storage of a tenant scope: the credentials and reset codes, on the scope's SQL\n * connection and table settings (`KnexClient`, `SqlSchemaConfig`), on whichever SQL storage the\n * tenant runs.\n */\nconst SelfHostedAuthScopeStorage: SqlScopeStorage.Interface = {\n register(container) {\n SelfHostedAuthSqlFeature.register(container);\n }\n};\n\n/*\n * The default storage is the one without an id, each extra one has its own: a mix-up would put root\n * or a tenant on the wrong database, so it stops the server.\n */\nconst assertStorageIds = (storage: SqlStorage, storages: SqlStorage[]): void => {\n if (!TenantStorageId.from(storage.id).isDefault()) {\n throw new Error(\n `The API's storage is the default storage and takes no id, but it has the id \"${storage.id}\".`\n );\n }\n const seen = new Set<string>();\n for (const extra of storages) {\n if (TenantStorageId.from(extra.id).isDefault()) {\n throw new Error(\n `An extra storage needs an id of its own: \"${TenantStorageId.DEFAULT.toString()}\" is the default storage's.`\n );\n }\n if (seen.has(extra.id)) {\n throw new Error(`Two extra storages have the id \"${extra.id}\".`);\n }\n seen.add(extra.id);\n }\n};\n\n/**\n * What the handler puts in the root container, once per process: the default storage (the\n * connection and its settings, its `RequestStorage` and its schema setup runner), each extra storage\n * (its backend and its runner), the login storage's part of every SQL storage (`SqlScopeStorage`),\n * and the self-hosted JWT identity provider. The IdP is in the root so the RequestIdentityLoader\n * (driven by HttpIdentityLoaderDecorator) can resolve it; it only needs the token issuer, and the\n * login use cases it registers resolve the credential storage from the tenant's scope.\n */\nexport function registerSqlApiRoot(\n container: Container,\n params: { storage: SqlStorage; storages?: SqlStorage[]; signingSecret: string }\n): void {\n const storages = params.storages ?? [];\n assertStorageIds(params.storage, storages);\n params.storage.register(container);\n for (const extra of storages) {\n extra.register(container);\n }\n container.registerInstance(SqlScopeStorage, SelfHostedAuthScopeStorage);\n SelfHostedAuthApiFeature.register(container, { signingSecret: params.signingSecret });\n}\n\nexport function createSqlApiHandler(config: CreateSqlApiHandlerConfig) {\n const { storage, storages } = 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 registerSqlApiRoot(container, { storage, storages, signingSecret });\n /*\n * Before the server takes traffic: `root` runs before the server is handed back to\n * listen. Each storage's setup container is built as a scope on that storage is\n * (`ApiRequestRegistration`), so the login storage's part adds the login tables. A\n * failure (a missing module, a database that's down) stops the server here.\n */\n await runSqlSchemaSetups({\n root: container,\n request: container.resolve(ApiRequestRegistration)\n });\n }\n });\n}\n"],"names":["SelfHostedAuthScopeStorage","container","SelfHostedAuthSqlFeature","assertStorageIds","storage","storages","TenantStorageId","Error","seen","Set","extra","registerSqlApiRoot","params","SqlScopeStorage","SelfHostedAuthApiFeature","createSqlApiHandler","config","signingSecret","readSigningSecret","process","createBaseHandler","runSqlSchemaSetups","ApiRequestRegistration"],"mappings":";;;;;;;AA4CA,MAAMA,6BAAwD;IAC1D,UAASC,SAAS;QACdC,yBAAyB,QAAQ,CAACD;IACtC;AACJ;AAMA,MAAME,mBAAmB,CAACC,SAAqBC;IAC3C,IAAI,CAACC,gBAAgB,IAAI,CAACF,QAAQ,EAAE,EAAE,SAAS,IAC3C,MAAM,IAAIG,MACN,CAAC,6EAA6E,EAAEH,QAAQ,EAAE,CAAC,EAAE,CAAC;IAGtG,MAAMI,OAAO,IAAIC;IACjB,KAAK,MAAMC,SAASL,SAAU;QAC1B,IAAIC,gBAAgB,IAAI,CAACI,MAAM,EAAE,EAAE,SAAS,IACxC,MAAM,IAAIH,MACN,CAAC,0CAA0C,EAAED,gBAAgB,OAAO,CAAC,QAAQ,GAAG,2BAA2B,CAAC;QAGpH,IAAIE,KAAK,GAAG,CAACE,MAAM,EAAE,GACjB,MAAM,IAAIH,MAAM,CAAC,gCAAgC,EAAEG,MAAM,EAAE,CAAC,EAAE,CAAC;QAEnEF,KAAK,GAAG,CAACE,MAAM,EAAE;IACrB;AACJ;AAUO,SAASC,mBACZV,SAAoB,EACpBW,MAA+E;IAE/E,MAAMP,WAAWO,OAAO,QAAQ,IAAI,EAAE;IACtCT,iBAAiBS,OAAO,OAAO,EAAEP;IACjCO,OAAO,OAAO,CAAC,QAAQ,CAACX;IACxB,KAAK,MAAMS,SAASL,SAChBK,MAAM,QAAQ,CAACT;IAEnBA,UAAU,gBAAgB,CAACY,iBAAiBb;IAC5Cc,yBAAyB,QAAQ,CAACb,WAAW;QAAE,eAAeW,OAAO,aAAa;IAAC;AACvF;AAEO,SAASG,oBAAoBC,MAAiC;IACjE,MAAM,EAAEZ,OAAO,EAAEC,QAAQ,EAAE,GAAGW;IAE9B,MAAMC,gBAAgBC,kBAAkBC,QAAQ,GAAG;IAEnD,OAAOC,uBAAkB;QACrB,YAAYJ,OAAO,UAAU;QAC7B,qBAAqB,OAAMf;YACvBU,mBAAmBV,WAAW;gBAAEG;gBAASC;gBAAUY;YAAc;YAOjE,MAAMI,mBAAmB;gBACrB,MAAMpB;gBACN,SAASA,UAAU,OAAO,CAACqB;YAC/B;QACJ;IACJ;AACJ"}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSqlApiHandler } from "./createWebinyApiHandler.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@webiny/api-composition-standalone-sql",
|
|
3
|
+
"version": "0.0.0-unstable.676006d08e",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./*": "./*"
|
|
9
|
+
},
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"description": "EXPERIMENTAL: Webiny API handler for the Node server transport on a SQL storage (SQLite or Postgres).",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
15
|
+
},
|
|
16
|
+
"contributors": [
|
|
17
|
+
"Webiny Team"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@webiny/api-composition-core": "0.0.0-unstable.676006d08e",
|
|
22
|
+
"@webiny/api-composition-standalone": "0.0.0-unstable.676006d08e",
|
|
23
|
+
"@webiny/api-core": "0.0.0-unstable.676006d08e",
|
|
24
|
+
"@webiny/api-core-sql": "0.0.0-unstable.676006d08e",
|
|
25
|
+
"@webiny/api-mailer": "0.0.0-unstable.676006d08e",
|
|
26
|
+
"@webiny/di": "2.0.0",
|
|
27
|
+
"@webiny/handler": "0.0.0-unstable.676006d08e",
|
|
28
|
+
"@webiny/self-hosted-auth": "0.0.0-unstable.676006d08e",
|
|
29
|
+
"@webiny/self-hosted-auth-sql": "0.0.0-unstable.676006d08e"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@electric-sql/pglite": "0.5.17",
|
|
33
|
+
"@electric-sql/pglite-socket": "0.2.20",
|
|
34
|
+
"@types/ws": "8.18.2",
|
|
35
|
+
"@webiny/api-aco": "0.0.0-unstable.676006d08e",
|
|
36
|
+
"@webiny/api-aco-pg": "0.0.0-unstable.676006d08e",
|
|
37
|
+
"@webiny/api-audit-logs": "0.0.0-unstable.676006d08e",
|
|
38
|
+
"@webiny/api-graphql": "0.0.0-unstable.676006d08e",
|
|
39
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.676006d08e",
|
|
40
|
+
"@webiny/api-headless-cms-pg": "0.0.0-unstable.676006d08e",
|
|
41
|
+
"@webiny/api-kernel-core": "0.0.0-unstable.676006d08e",
|
|
42
|
+
"@webiny/api-object-storage": "0.0.0-unstable.676006d08e",
|
|
43
|
+
"@webiny/api-object-storage-disk": "0.0.0-unstable.676006d08e",
|
|
44
|
+
"@webiny/api-storage-pg": "0.0.0-unstable.676006d08e",
|
|
45
|
+
"@webiny/api-storage-sqlite": "0.0.0-unstable.676006d08e",
|
|
46
|
+
"@webiny/api-websockets": "0.0.0-unstable.676006d08e",
|
|
47
|
+
"@webiny/build-tools": "0.0.0-unstable.676006d08e",
|
|
48
|
+
"@webiny/tenant-manager": "0.0.0-unstable.676006d08e",
|
|
49
|
+
"knex": "3.3.0",
|
|
50
|
+
"rimraf": "6.1.4",
|
|
51
|
+
"typescript": "7.0.2",
|
|
52
|
+
"vitest": "5.1.1",
|
|
53
|
+
"ws": "8.23.0"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"webiny": {
|
|
59
|
+
"publishFrom": "dist"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -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"}
|