@opengis/fastify-table 2.6.6 → 2.6.7
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/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,MAAM,KAA8D,CAAC;AAsD3E,eAAe,MAAM,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -3,6 +3,7 @@ import dotenv from "dotenv";
|
|
|
3
3
|
dotenv.config(); // ! load .env (workaround for node)
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import unflattenObject from "./server/plugins/util/funcs/unflattenObject.js";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
6
7
|
const fileName = ["config.json", "/data/local/config.json"].find((el) => existsSync(el) ? el : null);
|
|
7
8
|
const config = fileName ? JSON.parse(readFileSync(fileName, "utf-8")) : {};
|
|
8
9
|
const { skipKeys = ["windir"] } = config;
|
|
@@ -38,6 +39,11 @@ function loadEnvConfig() {
|
|
|
38
39
|
(key.charAt(0) === key.charAt(0)?.toLowerCase?.() || key.includes(".")))
|
|
39
40
|
.reduce((acc, curr) => ({ ...acc, [curr]: process.env[curr] }), {});
|
|
40
41
|
Object.assign(config, unflattenObject(configKeys));
|
|
42
|
+
if (!config.auth?.secret) {
|
|
43
|
+
config.auth = config.auth || {};
|
|
44
|
+
config.auth.secret = randomUUID().replace(/-/g, "");
|
|
45
|
+
console.warn("environment variable auth.secret not set");
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
loadEnvConfig();
|
|
43
49
|
export default config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAYxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAYxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,wBAAsB,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,iBAiIxE;AAED,iBAAS,MAAM,CAAC,OAAO,EAAE,eAAe,QAmCvC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -8,9 +8,6 @@ import getRedis from "../redis/funcs/getRedis.js";
|
|
|
8
8
|
import { ForbiddenError } from "../../../errors.js";
|
|
9
9
|
const { prefix = "/api" } = config;
|
|
10
10
|
const { auth } = config || {};
|
|
11
|
-
if (!auth?.secret && process.platform !== 'win32') {
|
|
12
|
-
throw new Error("environment variable auth.secret not set");
|
|
13
|
-
}
|
|
14
11
|
const fastifyPassport = new Authenticator();
|
|
15
12
|
export async function onRequest(req, reply) {
|
|
16
13
|
const { hostname, headers, routeOptions } = req;
|
|
@@ -127,7 +124,7 @@ function plugin(fastify) {
|
|
|
127
124
|
parseOptions: config?.auth?.cookieOptions || { secure: false },
|
|
128
125
|
});
|
|
129
126
|
fastify.register(session, {
|
|
130
|
-
secret: auth?.secret ||
|
|
127
|
+
secret: auth?.secret || "fastify-session-redis-store-secret",
|
|
131
128
|
cookieName: "session_auth",
|
|
132
129
|
cookie: config?.auth?.cookieOptions || { secure: false },
|
|
133
130
|
store: new RedisStore({
|