@camstack/server 1.2.541 → 1.2.543

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.
@@ -38,6 +38,7 @@ const fs = __importStar(require("node:fs"));
38
38
  const path = __importStar(require("node:path"));
39
39
  const crypto = __importStar(require("node:crypto"));
40
40
  const os = __importStar(require("node:os"));
41
+ const node_1 = require("@camstack/types/node");
41
42
  /**
42
43
  * Generate a stable nodeId and persist it to the config file.
43
44
  *
@@ -72,9 +73,8 @@ function ensurePersistedNodeId(configPath, dataDir) {
72
73
  const id = envSeed && envSeed.length > 0 ? envSeed : `agent-${crypto.randomBytes(4).toString('hex')}`;
73
74
  raw.nodeId = id;
74
75
  try {
75
- fs.mkdirSync(path.dirname(resolvedPath), { recursive: true });
76
- // 0600: the same file holds the cluster secret.
77
- fs.writeFileSync(resolvedPath, JSON.stringify(raw, null, 2), { encoding: 'utf-8', mode: 0o600 });
76
+ // Owner-only: the same file holds the cluster secret.
77
+ (0, node_1.writeOwnerOnlyFileSync)(resolvedPath, JSON.stringify(raw, null, 2));
78
78
  }
79
79
  catch {
80
80
  /* best-effort */
@@ -58,6 +58,7 @@ const path = __importStar(require("node:path"));
58
58
  const fastify_1 = __importDefault(require("fastify"));
59
59
  const system_1 = require("@camstack/system");
60
60
  const agent_http_auth_js_1 = require("./agent-http-auth.js");
61
+ const node_1 = require("@camstack/types/node");
61
62
  const agent_mesh_enroll_js_1 = require("./agent-mesh-enroll.js");
62
63
  const agent_update_routes_js_1 = require("./agent-update-routes.js");
63
64
  const derive_hub_url_js_1 = require("./derive-hub-url.js");
@@ -158,11 +159,9 @@ function readConfigFile(configPath) {
158
159
  return {};
159
160
  }
160
161
  }
161
- /** agent.json holds the cluster secret (D797): always 0600. */
162
+ /** agent.json holds the cluster secret (D797): owner-only on every OS. */
162
163
  function writeConfigFile(configPath, data) {
163
- fs.mkdirSync(path.dirname(configPath), { recursive: true });
164
- fs.writeFileSync(configPath, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 });
165
- fs.chmodSync(configPath, 0o600);
164
+ (0, node_1.writeOwnerOnlyFileSync)(configPath, JSON.stringify(data, null, 2));
166
165
  }
167
166
  /** Live Moleculer registry snapshot — reused by agent-bootstrap's Option A. */
168
167
  function getRegistryNodes(broker) {
@@ -64,8 +64,8 @@ const node_crypto_1 = require("node:crypto");
64
64
  const fs = __importStar(require("node:fs"));
65
65
  const http = __importStar(require("node:http"));
66
66
  const https = __importStar(require("node:https"));
67
- const path = __importStar(require("node:path"));
68
67
  const system_1 = require("@camstack/system");
68
+ const node_1 = require("@camstack/types/node");
69
69
  class MeshEnrollError extends Error {
70
70
  constructor(message) {
71
71
  super(message);
@@ -283,12 +283,9 @@ function readJsonFile(file) {
283
283
  function withoutJoinToken(record) {
284
284
  return Object.fromEntries(Object.entries(record).filter(([key]) => key !== 'joinToken'));
285
285
  }
286
+ /** Owner-only on every OS (an owner+SYSTEM ACL on Windows, where 0600 is a no-op). */
286
287
  function writeJsonFile0600(file, data) {
287
- fs.mkdirSync(path.dirname(file), { recursive: true });
288
- const tmp = `${file}.tmp`;
289
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 });
290
- fs.renameSync(tmp, file);
291
- fs.chmodSync(file, 0o600);
288
+ (0, node_1.writeOwnerOnlyFileSync)(file, JSON.stringify(data, null, 2));
292
289
  }
293
290
  /**
294
291
  * Write the enrollment into `agent.json` (0600): `meshTls` + the host-only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.541",
3
+ "version": "1.2.543",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "files": [
@@ -38,18 +38,18 @@
38
38
  ]
39
39
  },
40
40
  "dependencies": {
41
- "@camstack/addon-admin-ui": "1.2.407",
41
+ "@camstack/addon-admin-ui": "1.2.409",
42
42
  "@camstack/addon-agent-ui": "1.2.224",
43
43
  "@camstack/addon-auth": "1.2.141",
44
44
  "@camstack/addon-decoder-nodeav": "1.2.123",
45
45
  "@camstack/addon-notifiers": "1.2.134",
46
- "@camstack/addon-pipeline": "1.2.360",
47
- "@camstack/addon-pipeline-orchestrator": "1.2.310",
48
- "@camstack/addon-post-analysis": "1.2.359",
46
+ "@camstack/addon-pipeline": "1.2.361",
47
+ "@camstack/addon-pipeline-orchestrator": "1.2.311",
48
+ "@camstack/addon-post-analysis": "1.2.360",
49
49
  "@camstack/develop": "0.1.5",
50
50
  "@camstack/sdk": "1.2.131",
51
- "@camstack/system": "1.2.417",
52
- "@camstack/types": "1.2.355",
51
+ "@camstack/system": "1.2.419",
52
+ "@camstack/types": "1.2.357",
53
53
  "@camstack/ui-library": "1.2.281",
54
54
  "@fastify/compress": "^9.0.0",
55
55
  "@fastify/cookie": "^11.0.2",