@ours.network/install 2.0.2 → 2.0.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/README.md CHANGED
@@ -521,9 +521,16 @@ removed. Messenger produces message notifications over loopback.
521
521
 
522
522
  `prepare` creates the private configuration once in
523
523
  `storage/state/notifications/config.json`: the owner token, separate Fleet and
524
- Messenger producer tokens, and VAPID keys. Later runs only validate it; rotating
525
- the owner token or VAPID keys would orphan every browser subscription, so a
526
- differing configuration is refused rather than rewritten. Back it up with the
524
+ Messenger producer tokens, and VAPID keys. Fresh setup and updates explicitly grant
525
+ `mission-ownership` only to the installer-selected `owner` / `fleet` producer,
526
+ so Fleet can register and retire its mission notification targets. Messenger
527
+ keeps its existing message-only producer permissions. The migration retains all
528
+ tokens, VAPID keys, preferences and other configuration fields, and is idempotent;
529
+ an existing Fleet delivery token must match the selected producer before any
530
+ grant. A differing or ambiguous configuration is refused for maintenance rather
531
+ than guessed. The gateway passes only the exact mission association, bootstrap
532
+ and deletion POST routes using that producer credential, after checking the
533
+ server credential; Notifications still enforces its account and capability scope. Back it up with the
527
534
  rest of the server state. A local client setup binds the Fleet producer token
528
535
  to this server in `~/.ours-client/notifications-producer.json`; Fleet then sends
529
536
  agent completions through `<serverUrl>/notifications/`. Remote clients and
package/assets/Dockerfile CHANGED
@@ -22,7 +22,7 @@ COPY --chmod=644 scripts/maintenance/build-context.mjs scripts/maintenance/prove
22
22
  COPY --chmod=644 scripts/runtime/runtime-common.mjs /opt/ours/docker/runtime-common.mjs
23
23
  COPY --chmod=644 scripts/runtime/check-client.mjs /opt/ours/docker/check-client.mjs
24
24
  COPY --chmod=644 scripts/runtime/check-start.mjs /opt/ours/docker/check-start.mjs
25
- COPY --chmod=644 scripts/runtime/client-setup.mjs /opt/ours/docker/client-setup.mjs
25
+ COPY --chmod=644 scripts/runtime/client-setup.mjs scripts/runtime/notification-config.mjs /opt/ours/docker/
26
26
  COPY --chmod=644 scripts/runtime/diagnostics.mjs /opt/ours/docker/diagnostics.mjs
27
27
  COPY --chmod=644 scripts/runtime/legacy-import.mjs /opt/ours/docker/legacy-import.mjs
28
28
  COPY --chmod=644 scripts/runtime/entrypoint.sh /opt/ours/docker/entrypoint.sh
@@ -3073,9 +3073,9 @@
3073
3073
  }
3074
3074
  },
3075
3075
  "node_modules/qs": {
3076
- "version": "6.17.0",
3077
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.0.tgz",
3078
- "integrity": "sha512-5LK5BZ2XDHMvcUJaf0CQ5HL3aVgKbpklvByC7qLSxYkfE8COEEbJg5xCHWCTqzqi0Gs4Jn5Mv5v3R38W6edscA==",
3076
+ "version": "6.17.1",
3077
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
3078
+ "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
3079
3079
  "license": "BSD-3-Clause",
3080
3080
  "dependencies": {
3081
3081
  "es-define-property": "^1.0.1",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "channel": "stable",
4
- "installerVersion": "2.0.2",
4
+ "installerVersion": "2.0.3",
5
5
  "packages": {
6
6
  "@ours.network/sdk": {
7
7
  "version": "5.0.1",
@@ -1,7 +1,8 @@
1
+ import { notificationConfig, upgradeFleetMissionCapability } from './notification-config.mjs';
1
2
  import { readBuildRecords, initializeBuildMarker } from '../maintenance/build-context.mjs';
2
3
  import { redactDiagnostic } from './diagnostics.mjs';
3
4
  import { spawnSync } from 'node:child_process';
4
- import { generateKeyPairSync, randomBytes } from 'node:crypto';
5
+ import { randomBytes } from 'node:crypto';
5
6
  import {
6
7
  existsSync, closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync,
7
8
  realpathSync, renameSync, unlinkSync, writeFileSync, readdirSync, chmodSync, chownSync,
@@ -87,7 +88,6 @@ function composeConfig(domain) {
87
88
  return null;
88
89
  }
89
90
 
90
- const NOTIFICATIONS_PORT = 49677;
91
91
  const NOTIFICATION_FILES = {
92
92
  config: '/storage/state/notifications/config.json',
93
93
  messenger: '/storage/state/credentials/messenger/notifications-producer',
@@ -102,32 +102,8 @@ function privateText(path, value) {
102
102
  finally { try { unlinkSync(temp); } catch (error) { if (error.code !== 'ENOENT') throw error; } }
103
103
  }
104
104
 
105
- function notificationConfig() {
106
- const token = () => randomBytes(32).toString('base64url');
107
- const { publicKey, privateKey } = generateKeyPairSync('ec', { namedCurve: 'prime256v1' });
108
- const pub = publicKey.export({ format: 'jwk' }), key = privateKey.export({ format: 'jwk' });
109
- const raw = Buffer.concat([Buffer.from([4]), Buffer.from(pub.x, 'base64url'), Buffer.from(pub.y, 'base64url')]);
110
- return {
111
- host: '0.0.0.0', port: NOTIFICATIONS_PORT, stateFile: '/var/lib/ours-notifications/state.json',
112
- users: [{ userId: 'owner', token: token() }],
113
- producers: [{ userId: 'owner', source: 'fleet', token: token() }, { userId: 'owner', source: 'messenger', token: token() }],
114
- vapid: { subject: 'https://ours.network', publicKey: raw.toString('base64url'), privateKey: key.d },
115
- };
116
- }
117
-
118
- /** Exact retained shape; any other content is operator state the installer will not rewrite. */
119
- function validNotificationConfig(config) {
120
- const tokens = [...(config.users ?? []), ...(config.producers ?? [])].map(entry => entry?.token);
121
- return config.host === '0.0.0.0' && config.port === NOTIFICATIONS_PORT && config.stateFile === '/var/lib/ours-notifications/state.json'
122
- && Array.isArray(config.users) && config.users.length === 1 && config.users[0].userId === 'owner'
123
- && Array.isArray(config.producers) && config.producers.length === 2
124
- && ['fleet', 'messenger'].every(source => config.producers.some(p => p?.source === source && p.userId === 'owner'))
125
- && tokens.every(t => typeof t === 'string' && t.length >= 32) && new Set(tokens).size === tokens.length
126
- && typeof config.vapid?.subject === 'string' && /^[A-Za-z0-9_-]{87}$/.test(config.vapid.publicKey ?? '') && /^[A-Za-z0-9_-]{43}$/.test(config.vapid.privateKey ?? '');
127
- }
128
-
129
105
  /**
130
- * Notification secrets are created once and then only validated: rotating the
106
+ * Notification secrets are created once and retained across capability upgrades: rotating the
131
107
  * owner token or VAPID keys would orphan every browser subscription. Producer
132
108
  * delivery files are derived from the retained configuration on every run.
133
109
  */
@@ -138,7 +114,8 @@ function prepareNotifications() {
138
114
  initializeBuildMarker('/storage/state/notifications/.ours-provenance', readBuildRecords('/opt/ours'));
139
115
  if (!existingPrivate(NOTIFICATION_FILES.config, false)) atomicJson(NOTIFICATION_FILES.config, notificationConfig());
140
116
  const config = jsonObject(NOTIFICATION_FILES.config);
141
- if (!validNotificationConfig(config)) fail('Existing notification configuration differs; use the supported maintenance workflow');
117
+ const deliveredFleetToken = existingPrivate(NOTIFICATION_FILES.fleet, false) ? readFileSync(NOTIFICATION_FILES.fleet, 'utf8') : undefined;
118
+ if (upgradeFleetMissionCapability(config, deliveredFleetToken)) atomicJson(NOTIFICATION_FILES.config, config);
142
119
  for (const source of ['messenger', 'fleet']) privateText(NOTIFICATION_FILES[source], config.producers.find(p => p.source === source).token);
143
120
  }
144
121
 
@@ -0,0 +1,41 @@
1
+ import { generateKeyPairSync, randomBytes } from 'node:crypto';
2
+
3
+ const NOTIFICATIONS_PORT = 49677;
4
+
5
+ export function notificationConfig() {
6
+ const token = () => randomBytes(32).toString('base64url');
7
+ const { publicKey, privateKey } = generateKeyPairSync('ec', { namedCurve: 'prime256v1' });
8
+ const pub = publicKey.export({ format: 'jwk' }), key = privateKey.export({ format: 'jwk' });
9
+ const raw = Buffer.concat([Buffer.from([4]), Buffer.from(pub.x, 'base64url'), Buffer.from(pub.y, 'base64url')]);
10
+ return {
11
+ host: '0.0.0.0', port: NOTIFICATIONS_PORT, stateFile: '/var/lib/ours-notifications/state.json',
12
+ users: [{ userId: 'owner', token: token() }],
13
+ producers: [{ userId: 'owner', source: 'fleet', token: token(), capabilities: ['mission-ownership'] }, { userId: 'owner', source: 'messenger', token: token() }],
14
+ vapid: { subject: 'https://ours.network', publicKey: raw.toString('base64url'), privateKey: key.d },
15
+ };
16
+ }
17
+
18
+ /** Exact retained shape; any other content is operator state the installer will not rewrite. */
19
+ export function validNotificationConfig(config) {
20
+ const tokens = [...(config.users ?? []), ...(config.producers ?? [])].map(entry => entry?.token);
21
+ return config.host === '0.0.0.0' && config.port === NOTIFICATIONS_PORT && config.stateFile === '/var/lib/ours-notifications/state.json'
22
+ && Array.isArray(config.users) && config.users.length === 1 && config.users[0].userId === 'owner'
23
+ && Array.isArray(config.producers) && config.producers.length === 2
24
+ && ['fleet', 'messenger'].every(source => config.producers.some(p => p?.source === source && p.userId === 'owner'))
25
+ && tokens.every(t => typeof t === 'string' && t.length >= 32) && new Set(tokens).size === tokens.length
26
+ && typeof config.vapid?.subject === 'string' && /^[A-Za-z0-9_-]{87}$/.test(config.vapid.publicKey ?? '') && /^[A-Za-z0-9_-]{43}$/.test(config.vapid.privateKey ?? '');
27
+ }
28
+
29
+ /** Upgrade only the installer-selected owner/Fleet credential; tokens and other settings are retained.
30
+ * A delivery file, when already present, must agree before permissions change. */
31
+ export function upgradeFleetMissionCapability(config, deliveredFleetToken) {
32
+ if (!validNotificationConfig(config)) throw new Error('Existing notification configuration differs; use the supported maintenance workflow');
33
+ const fleet = config.producers.find(p => p.source === 'fleet');
34
+ if (deliveredFleetToken !== undefined && deliveredFleetToken !== fleet.token)
35
+ throw new Error('Existing Fleet notification credential binding differs; use the supported maintenance workflow');
36
+ if (fleet.capabilities !== undefined && (!Array.isArray(fleet.capabilities) || fleet.capabilities.some(c => typeof c !== 'string')))
37
+ throw new Error('Existing Fleet notification capabilities are invalid; use the supported maintenance workflow');
38
+ if (fleet.capabilities?.includes('mission-ownership')) return false;
39
+ fleet.capabilities = [...(fleet.capabilities ?? []), 'mission-ownership'];
40
+ return true;
41
+ }
@@ -36,7 +36,7 @@ export function createNotificationsAdapter({ service, userToken, verifyServerCre
36
36
  try { verified = await verifyServerCredential(credential); } catch { return 503; }
37
37
  if (verified !== true) return verified === false ? 401 : 503;
38
38
  const path = new URL(req.url ?? '/', 'http://localhost').pathname;
39
- if (producer !== undefined && !(req.method === 'POST' && ['/api/v1/send', '/api/v1/delete-target'].includes(path))) return 401;
39
+ if (producer !== undefined && !(req.method === 'POST' && ['/api/v1/send', '/api/v1/delete-target', '/api/v1/missions/associate', '/api/v1/missions/bootstrap', '/api/v1/missions/delete'].includes(path))) return 401;
40
40
  req.headers.authorization = `Bearer ${producer ?? userToken}`;
41
41
  return 200;
42
42
  };
@@ -2,7 +2,7 @@
2
2
  "release": {
3
3
  "schema": 1,
4
4
  "channel": "stable",
5
- "installerVersion": "2.0.2",
5
+ "installerVersion": "2.0.3",
6
6
  "packages": {
7
7
  "@ours.network/sdk": {
8
8
  "version": "5.0.1",
package/lib/effects.mjs CHANGED
@@ -1187,9 +1187,11 @@ export function networkEffects(effects) {
1187
1187
  // Execute the shipped installer helper against the SAME selected image
1188
1188
  // and Compose volume/user/environment contract, without retag/rebuild.
1189
1189
  const diagnosticsUrl = `data:text/javascript;base64,${readFileSync(join(INSTALLER_ASSETS, 'scripts/runtime/diagnostics.mjs')).toString('base64')}`;
1190
+ const notificationConfigUrl = `data:text/javascript;base64,${readFileSync(join(INSTALLER_ASSETS, 'scripts/runtime/notification-config.mjs')).toString('base64')}`;
1190
1191
  const helper = `process.argv.splice(1, 0, '/opt/ours/docker/client-setup.mjs');\n` + readFileSync(join(INSTALLER_ASSETS, 'scripts/runtime/client-setup.mjs'), 'utf8')
1191
1192
  .replace("'../maintenance/build-context.mjs'", "'/opt/ours/maintenance/build-context.mjs'")
1192
- .replace("'./diagnostics.mjs'", JSON.stringify(diagnosticsUrl));
1193
+ .replace("'./diagnostics.mjs'", JSON.stringify(diagnosticsUrl))
1194
+ .replace("'./notification-config.mjs'", JSON.stringify(notificationConfigUrl));
1193
1195
  const accessArgs = (...args) => ['--entrypoint', 'node', 'access', '--input-type=module', '-e', helper, '--', ...args];
1194
1196
  if (!output) return compose(record, ['run', '--rm', '--no-deps', '-T', ...accessArgs(operation)], { sensitive: true, env: { OURS_ACCESS_MIGRATE: migrate ? '1' : '0' } });
1195
1197
  privateDirectory(dirname(output));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/install",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "private": false,
5
5
  "description": "The all-in-one ours.network installer: one shared daemon, MCP, cowork, Telegram, Fleet initialization, harness plugins, Human identity, progress UI, and guided next steps.",
6
6
  "type": "module",
@@ -31,6 +31,7 @@
31
31
  "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1 <27"
32
32
  },
33
33
  "scripts": {
34
+ "pretest": "node ../../scripts/prepare-installer.mjs",
34
35
  "test": "node --test",
35
36
  "prepack": "node ../../scripts/prepare-installer.mjs"
36
37
  },