@iletai/nzb 1.1.2 → 1.1.3

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/cli.js CHANGED
@@ -1,8 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from "fs";
2
+ import { spawnSync } from "child_process";
3
+ import { existsSync, readFileSync } from "fs";
3
4
  import { dirname, join } from "path";
4
5
  import { fileURLToPath } from "url";
5
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ // Auto-detect system CA bundle for corporate environments with TLS inspection.
8
+ // NODE_EXTRA_CA_CERTS must be set BEFORE the Node.js process starts — setting it
9
+ // at runtime via process.env does NOT work for Node.js 24's fetch() (undici).
10
+ // When missing, we re-exec the current process with the env var set.
11
+ if (!process.env.NODE_EXTRA_CA_CERTS && !process.env.__NZB_CA_INJECTED) {
12
+ const found = [
13
+ "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu
14
+ "/etc/pki/tls/certs/ca-bundle.crt", // RHEL/CentOS/Fedora
15
+ "/etc/ssl/cert.pem", // macOS / Alpine
16
+ ].find((p) => existsSync(p));
17
+ if (found) {
18
+ const result = spawnSync(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
19
+ stdio: "inherit",
20
+ env: { ...process.env, NODE_EXTRA_CA_CERTS: found, __NZB_CA_INJECTED: "1" },
21
+ });
22
+ process.exit(result.status ?? 1);
23
+ }
24
+ }
6
25
  function getVersion() {
7
26
  try {
8
27
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
package/dist/daemon.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { spawn } from "child_process";
2
- import { existsSync } from "fs";
3
2
  import { broadcastToSSE, startApiServer } from "./api/server.js";
4
3
  import { config } from "./config.js";
5
4
  import { getClient, stopClient } from "./copilot/client.js";
@@ -7,20 +6,9 @@ import { getWorkers, initOrchestrator, setMessageLogger, setProactiveNotify } fr
7
6
  import { closeDb, getDb } from "./store/db.js";
8
7
  import { createBot, sendProactiveMessage, startBot, stopBot } from "./telegram/bot.js";
9
8
  import { checkForUpdate } from "./update.js";
10
- // Auto-detect system CA bundle for corporate environments with TLS inspection.
11
- // NODE_EXTRA_CA_CERTS must be set before any TLS connection is made.
12
- // Users can override via NODE_EXTRA_CA_CERTS env var or NODE_EXTRA_CA_CERTS in ~/.nzb/.env.
13
- if (!process.env.NODE_EXTRA_CA_CERTS) {
14
- const knownCaBundles = [
15
- "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu
16
- "/etc/pki/tls/certs/ca-bundle.crt", // RHEL/CentOS/Fedora
17
- "/etc/ssl/cert.pem", // macOS / Alpine
18
- ];
19
- const found = knownCaBundles.find((p) => existsSync(p));
20
- if (found) {
21
- process.env.NODE_EXTRA_CA_CERTS = found;
22
- console.log(`[nzb] Auto-detected system CA bundle: ${found}`);
23
- }
9
+ // Log the active CA bundle (injected by cli.ts via re-exec).
10
+ if (process.env.NODE_EXTRA_CA_CERTS) {
11
+ console.log(`[nzb] Using system CA bundle: ${process.env.NODE_EXTRA_CA_CERTS}`);
24
12
  }
25
13
  function truncate(text, max = 200) {
26
14
  const oneLine = text.replace(/\n/g, " ").trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iletai/nzb",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "NZB — a personal AI assistant for developers, built on the GitHub Copilot SDK",
5
5
  "bin": {
6
6
  "nzb": "dist/cli.js"