ubersearch 1.6.1 → 1.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ubersearch",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "bin": {
@@ -76,6 +76,7 @@ search:
76
76
  # formats: [html, csv, json, rss]
77
77
  formats:
78
78
  - html
79
+ - json
79
80
 
80
81
  server:
81
82
  # Is overwritten by ${SEARXNG_PORT} and ${SEARXNG_BIND_ADDRESS}
@@ -94,7 +95,7 @@ server:
94
95
  # If your instance owns a /etc/searxng/settings.yml file, then set the following
95
96
  # values there.
96
97
 
97
- secret_key: "ultrasecretkey" # Is overwritten by ${SEARXNG_SECRET}
98
+ secret_key: "5d12e53bd34ee628ed8f8f90d796a8ea3f5640eb9b381d2b58945f2a0d210468" # Is overwritten by ${SEARXNG_SECRET}
98
99
  # Proxy image results through SearXNG. Is overwritten by ${SEARXNG_IMAGE_PROXY}
99
100
  image_proxy: false
100
101
  # 1.0 and 1.1 are supported
@@ -9,7 +9,7 @@ services:
9
9
  environment:
10
10
  # SearXNG configuration options
11
11
  - SEARXNG_BIND_ADDRESS=0.0.0.0:8080
12
- - SEARXNG_SECRET_KEY=${SEARXNG_SECRET_KEY:-changeme}
12
+ - SEARXNG_SECRET=${SEARXNG_SECRET}
13
13
  - SEARXNG_DEBUG=false
14
14
  # Enable JSON API
15
15
  - SEARXNG_ENABLE_JSON_API=true
@@ -4,13 +4,43 @@
4
4
  * Manages Docker Compose services for local providers
5
5
  */
6
6
 
7
- import { exec } from "node:child_process";
8
- import { existsSync } from "node:fs";
7
+ import { exec, execSync } from "node:child_process";
8
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { join } from "node:path";
9
10
  import { promisify } from "node:util";
10
11
  import { getSearxngPaths } from "../paths";
11
12
 
12
13
  const execAsync = promisify(exec);
13
14
 
15
+ /**
16
+ * Get or generate a persistent SearXNG secret key
17
+ * Stored in the config directory so it persists across restarts
18
+ */
19
+ function getSearxngSecret(configDir: string): string {
20
+ const secretFile = join(configDir, ".secret");
21
+ try {
22
+ if (existsSync(secretFile)) {
23
+ const secret = readFileSync(secretFile, "utf-8").trim();
24
+ if (secret.length >= 32) {
25
+ return secret;
26
+ }
27
+ }
28
+ } catch {
29
+ // Fall through to generate new secret
30
+ }
31
+
32
+ // Generate a new secret using crypto
33
+ const secret = [...Array(64)]
34
+ .map(() => Math.floor(Math.random() * 16).toString(16))
35
+ .join("");
36
+ try {
37
+ writeFileSync(secretFile, secret, { mode: 0o600 });
38
+ } catch {
39
+ // If we can't write, use a session-only secret
40
+ }
41
+ return secret;
42
+ }
43
+
14
44
  export interface DockerComposeOptions {
15
45
  cwd?: string;
16
46
  timeout?: number;
@@ -44,6 +74,7 @@ export class DockerComposeHelper {
44
74
  ...process.env,
45
75
  SEARXNG_CONFIG: configDir,
46
76
  SEARXNG_DATA: dataDir,
77
+ SEARXNG_SECRET: getSearxngSecret(configDir),
47
78
  },
48
79
  });
49
80