@hivemagnus/magnus 2.10.3 → 3.0.1

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/init.js CHANGED
@@ -119,7 +119,7 @@ export async function init(io, options) {
119
119
  writeFileSync(project.envFile('server'), serverEnv({
120
120
  databaseUrl: databaseUrl, redisUrl: redisUrl, port: options.serverPort, publicUrl: `https://${host}:${options.serverPort}`,
121
121
  uiOrigin, tlsCert: tls.cert, tlsKey: tls.key, home: project.path('data'), backupDir: project.path('backups'), autoMigrate: options.autoMigrate,
122
- projectDir: project.dir, runtimeFile: project.path('run', 'server-runtime.json'),
122
+ projectDir: project.dir, runtimeFile: project.path('run', 'server-runtime.json'), version,
123
123
  ...(tls.selfSigned ? { extraCaFile: tls.cert } : {}),
124
124
  }, {}), { mode: 0o600 });
125
125
  const password = options.adminPassword ?? randomBytes(12).toString('base64url');
@@ -8,6 +8,14 @@ import type { Project } from './project.js';
8
8
  */
9
9
  export declare const ALLOW_SCRIPTS: Readonly<Record<string, true>>;
10
10
  export declare const SERVER_SECRET_NAMES: readonly ["API_SECRET", "JWT_SECRET", "NODE_MANAGER_SECRET", "AUDIT_HMAC_SECRET", "RESULT_SIGNING_SECRET", "LOG_INGEST_SIGNING_SECRET", "CREDENTIAL_ROTATION_KEY", "METRICS_TOKEN", "WEBHOOK_ENCRYPTION_KEY"];
11
+ /**
12
+ * The shared node credentials. From 3.0.0 the server runs in NODE_AUTH_MODE=enforce by default and
13
+ * needs neither (agents enroll with their own keys), so a new project of 3.0.0 or later does not get
14
+ * them; an older release still requires them. Add both by hand only to run an explicit compat mode.
15
+ */
16
+ export declare const SHARED_NODE_SECRET_NAMES: readonly string[];
17
+ /** The secrets a new project of `version` gets. */
18
+ export declare function serverSecretNames(version: string | undefined): readonly string[];
11
19
  export interface ServiceUnitOptions {
12
20
  project: Project;
13
21
  nodePath: string;
@@ -61,6 +69,8 @@ export interface ServerEnvSettings {
61
69
  autoMigrate: boolean;
62
70
  projectDir: string;
63
71
  runtimeFile: string;
72
+ /** The release the project starts on: from 3.0.0 the shared node credentials are left out. */
73
+ version?: string;
64
74
  }
65
75
  export declare function serverEnv(settings: ServerEnvSettings, secrets: Record<string, string>): string;
66
76
  /**
package/dist/templates.js CHANGED
@@ -26,6 +26,17 @@ export const SERVER_SECRET_NAMES = [
26
26
  'METRICS_TOKEN',
27
27
  'WEBHOOK_ENCRYPTION_KEY',
28
28
  ];
29
+ /**
30
+ * The shared node credentials. From 3.0.0 the server runs in NODE_AUTH_MODE=enforce by default and
31
+ * needs neither (agents enroll with their own keys), so a new project of 3.0.0 or later does not get
32
+ * them; an older release still requires them. Add both by hand only to run an explicit compat mode.
33
+ */
34
+ export const SHARED_NODE_SECRET_NAMES = ['NODE_MANAGER_SECRET', 'RESULT_SIGNING_SECRET'];
35
+ /** The secrets a new project of `version` gets. */
36
+ export function serverSecretNames(version) {
37
+ const major = Number(/^(\d+)\./.exec(version ?? '')?.[1] ?? 'NaN');
38
+ return Number.isFinite(major) && major >= 3 ? SERVER_SECRET_NAMES.filter((name) => !SHARED_NODE_SECRET_NAMES.includes(name)) : SERVER_SECRET_NAMES;
39
+ }
29
40
  export const UNIT_MARKER = '# Generated by `magnus init`';
30
41
  /** At most three failed starts in five minutes: a crash loop stops instead of filling the disk with dumps. */
31
42
  export const START_LIMIT = ['StartLimitIntervalSec=300', 'StartLimitBurst=3'];
@@ -192,7 +203,7 @@ export function serverEnv(settings, secrets) {
192
203
  { name: 'TLS_KEY_PATH', value: settings.tlsKey },
193
204
  ...(settings.extraCaFile ? [{ name: 'NODE_EXTRA_CA_CERTS', value: settings.extraCaFile, comment: 'Agent certificates the server trusts (this host\'s self-signed one; append your CA).' }] : []),
194
205
  ] },
195
- { title: 'Secrets (generated; each one distinct)', entries: entries(SERVER_SECRET_NAMES) },
206
+ { title: 'Secrets (generated; each one distinct)', entries: entries(serverSecretNames(settings.version)) },
196
207
  { title: 'Upgrades (set any of these to false to run your own release process)', entries: [
197
208
  { name: 'MAGNUS_AUTO_MIGRATE', value: String(settings.autoMigrate), comment: 'Back up and apply pending migrations at startup.' },
198
209
  { name: 'MAGNUS_AUTO_MIGRATE_BACKUP', value: 'true' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivemagnus/magnus",
3
- "version": "2.10.3",
3
+ "version": "3.0.1",
4
4
  "description": "Install, upgrade and roll back a Magnus server and console with one command: `npx @hivemagnus/magnus init`, then `magnus upgrade`. Pins exact, tested component versions, backs up PostgreSQL before every migration and reverts automatically when the new version fails its health check.",
5
5
  "keywords": [
6
6
  "magnus",
@@ -47,7 +47,7 @@
47
47
  "clean": "node -e \"const fs=require('node:fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true})\""
48
48
  },
49
49
  "dependencies": {
50
- "@hivemagnus/magnus-contracts": "2.10.3"
50
+ "@hivemagnus/magnus-contracts": "3.0.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^24.19.2",
@@ -56,18 +56,18 @@
56
56
  },
57
57
  "magnusRelease": {
58
58
  "schema": 1,
59
- "version": "2.10.3",
59
+ "version": "3.0.1",
60
60
  "engines": {
61
61
  "node": "^24.22.3 || ^26.13.1"
62
62
  },
63
63
  "components": {
64
- "@hivemagnus/magnus-server": "2.10.3",
65
- "@hivemagnus/magnus-ui": "2.10.3",
66
- "@hivemagnus/magnus-contracts": "2.10.3",
67
- "@hivemagnus/magnus-agent": "2.10.3"
64
+ "@hivemagnus/magnus-server": "3.0.1",
65
+ "@hivemagnus/magnus-ui": "3.0.1",
66
+ "@hivemagnus/magnus-contracts": "3.0.1",
67
+ "@hivemagnus/magnus-agent": "3.0.1"
68
68
  },
69
69
  "breaking": false,
70
- "minUpgradeFrom": "1.0.0",
70
+ "minUpgradeFrom": "2.10.2",
71
71
  "engineProtocol": 2,
72
72
  "newRequiredEnv": [],
73
73
  "newOptionalEnv": [],
@@ -77,8 +77,8 @@
77
77
  "selfUpgradeProtocol": 1,
78
78
  "minLauncher": 1
79
79
  },
80
- "summary": "Stepping stone to 3.0.x agents: the 2.10.3 agent accepts a self-upgrade across a major version only when the request carries an authorization signed by the server key it pins, for this node, the version it runs, the target version and its tarball integrity, with an expiry (3.0.1 servers send it with agents upgrade --allow-major). Without one it refuses the major as before. Nothing else changes. 2.10.x agents reach 2.10.3 with the usual managed upgrade. On npm 2.10.3 is tagged maintenance-2.10; latest stays on 3.0.x. No migrations and no new settings.",
81
- "notesUrl": "https://github.com/ChefTaco/magnus/releases/tag/v2.10.3",
80
+ "summary": "Agents can now be moved across a major version through the managed upgrade. magnus-server agents upgrade --to <3.x> --allow-major (allowMajor in POST /api/v1/agents/upgrade) adds to each request that crosses a major an authorization signed with the server key for that node, the version it runs, the target and its tarball integrity, valid one hour; 2.10.3 and later agents with a bound key verify it against the server key they pin, and refuse anything else. Without --allow-major such nodes stay MAJOR_VERSION. The dry run lists agents 2.10.0 to 2.10.2 as needing the 2.10.3 stepping stone, which this server installs as an ordinary patch. Procedure for a 2.10.2 fleet: agents upgrade --to 2.10.3, then --to 3.0.1 --allow-major. The 3.0.1 agent verifies the same authorization. No migrations and no new settings. See docs/NODE_CREDENTIALS.md, Moving agents across a major version.",
81
+ "notesUrl": "https://github.com/ChefTaco/magnus/releases/tag/v3.0.1",
82
82
  "allowScripts": {
83
83
  "@prisma/engines": true,
84
84
  "argon2": true,