@ours.network/fleet 1.2.0-nightly.39 → 1.2.0-nightly.40
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/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-nightly.
|
|
3
|
-
"buildId": "
|
|
4
|
-
"commit": "
|
|
2
|
+
"version": "1.2.0-nightly.40",
|
|
3
|
+
"buildId": "de6076ea1748",
|
|
4
|
+
"commit": "147b0e1859d9dc59f46140b0171329e9a479d3cc",
|
|
5
5
|
"dirty": true,
|
|
6
|
-
"builtAt": "2026-10-
|
|
6
|
+
"builtAt": "2026-10-03T11:45:41.330Z",
|
|
7
7
|
"capabilities": [
|
|
8
8
|
"workspace.enroll.preserve-profile-v1",
|
|
9
9
|
"cowork.http-management-v1",
|
|
@@ -9,6 +9,12 @@ export interface ServiceTarget {
|
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
10
|
/** Dedicated credential-authenticated services reject direct browser context. */
|
|
11
11
|
stripBrowserContext?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Service paths (below the prefix) where the account App may open a WebSocket with its device
|
|
14
|
+
* credential. A browser cannot set Authorization on a WebSocket, so only there it is accepted
|
|
15
|
+
* as a subprotocol.
|
|
16
|
+
*/
|
|
17
|
+
deviceSocketPaths?: string[];
|
|
12
18
|
}
|
|
13
19
|
export interface GatewayOptions {
|
|
14
20
|
/** Backend mode is for a separate loopback machine-client listener; browsers are rejected. */
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { createServer, request as httpRequest } from 'node:http';
|
|
2
2
|
import { request as httpsRequest } from 'node:https';
|
|
3
|
+
/** The App offers exactly these two subprotocols; only the marker is ever answered or forwarded. */
|
|
4
|
+
const DEVICE_SOCKET_PROTOCOL = 'ours.workspace.v1';
|
|
5
|
+
const DEVICE_SOCKET_BEARER = 'ours.workspace.bearer.';
|
|
6
|
+
/** The device credential a WebSocket offered as a subprotocol; undefined when it offered none of ours. */
|
|
7
|
+
function deviceSocketCredential(req) {
|
|
8
|
+
const offered = String(req.headers['sec-websocket-protocol'] ?? '').split(',').map(value => value.trim()).filter(Boolean);
|
|
9
|
+
if (!offered.some(value => value === DEVICE_SOCKET_PROTOCOL || value.startsWith(DEVICE_SOCKET_BEARER)))
|
|
10
|
+
return undefined;
|
|
11
|
+
const credentials = offered.filter(value => value.startsWith(DEVICE_SOCKET_BEARER));
|
|
12
|
+
const token = credentials[0]?.slice(DEVICE_SOCKET_BEARER.length) ?? '';
|
|
13
|
+
if (offered.length !== 2 || credentials.length !== 1 || !offered.includes(DEVICE_SOCKET_PROTOCOL) || !/^[A-Za-z0-9_.-]{16,256}$/.test(token))
|
|
14
|
+
throw new Error('invalid workspace socket subprotocol');
|
|
15
|
+
return token;
|
|
16
|
+
}
|
|
3
17
|
const hopHeaders = new Set(['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade']);
|
|
4
18
|
function headersFor(message) {
|
|
5
19
|
const denied = new Set([...hopHeaders, ...(message.headers.connection ?? '').split(',').map(x => x.trim().toLowerCase())]);
|
|
@@ -32,7 +46,18 @@ export function createPrefixGateway(options) {
|
|
|
32
46
|
};
|
|
33
47
|
const prepare = (req, upgrade = false) => {
|
|
34
48
|
const route = select(req);
|
|
35
|
-
|
|
49
|
+
// The device credential of an App WebSocket: accepted only on an upgrade, from the exact
|
|
50
|
+
// account origin, on a path the service declares, and never beside another credential.
|
|
51
|
+
const socketCredential = upgrade && auth ? deviceSocketCredential(req) : undefined;
|
|
52
|
+
if (socketCredential !== undefined) {
|
|
53
|
+
const path = route.service ? (req.url ?? '/').split('?')[0].slice(route.service.prefix.length) : undefined;
|
|
54
|
+
if (!route.service?.deviceSocketPaths?.includes(path ?? '') || req.headers.authorization !== undefined || req.headers.cookie !== undefined
|
|
55
|
+
|| !req.headers.origin || auth.accountOrigin(req) !== req.headers.origin)
|
|
56
|
+
throw new Error('workspace socket credential is not accepted here');
|
|
57
|
+
}
|
|
58
|
+
// Authentication sees the credential as the bearer it is; the request's own headers are untouched.
|
|
59
|
+
const authHeaders = socketCredential !== undefined ? { ...req.headers, authorization: `Bearer ${socketCredential}` } : req.headers;
|
|
60
|
+
const request = { headers: authHeaders, method: req.method, url: route.path };
|
|
36
61
|
if (!auth && (req.headers.origin || req.headers['sec-fetch-site'] || !route.service))
|
|
37
62
|
throw new Error('machine-client listener rejects browser requests');
|
|
38
63
|
auth?.validateBoundary(request, upgrade);
|
|
@@ -59,14 +84,17 @@ export function createPrefixGateway(options) {
|
|
|
59
84
|
headers.connection = 'Upgrade';
|
|
60
85
|
headers.upgrade = 'websocket';
|
|
61
86
|
}
|
|
62
|
-
|
|
87
|
+
// The credential subprotocol ends here: the service is not offered it, on any request.
|
|
88
|
+
if (socketCredential !== undefined || String(headers['sec-websocket-protocol'] ?? '').includes(DEVICE_SOCKET_BEARER))
|
|
89
|
+
delete headers['sec-websocket-protocol'];
|
|
90
|
+
return { ...route, headers, session, authHeaders, deviceSocket: socketCredential !== undefined };
|
|
63
91
|
};
|
|
64
|
-
const track = (
|
|
92
|
+
const track = (authHeaders, session, close) => {
|
|
65
93
|
if (!session)
|
|
66
94
|
return () => { };
|
|
67
95
|
const unbind = auth.bindTransport(session.id, close);
|
|
68
96
|
const timer = setInterval(() => { try {
|
|
69
|
-
auth.authenticate({ headers:
|
|
97
|
+
auth.authenticate({ headers: authHeaders });
|
|
70
98
|
}
|
|
71
99
|
catch {
|
|
72
100
|
close();
|
|
@@ -126,7 +154,7 @@ export function createPrefixGateway(options) {
|
|
|
126
154
|
res.writeHead(502, { ...(route.service ? cors : {}), 'content-type': 'application/json' });
|
|
127
155
|
res.end(JSON.stringify({ error: { code: 'upstream_unavailable', message: 'Service is unavailable' } }));
|
|
128
156
|
});
|
|
129
|
-
const untrack = track(
|
|
157
|
+
const untrack = track(route.authHeaders, route.session, () => { upstream.destroy(); res.destroy(); });
|
|
130
158
|
res.on('close', untrack);
|
|
131
159
|
req.on('aborted', () => upstream.destroy());
|
|
132
160
|
res.on('close', () => upstream.destroy());
|
|
@@ -151,12 +179,15 @@ export function createPrefixGateway(options) {
|
|
|
151
179
|
headers.connection = 'Upgrade';
|
|
152
180
|
headers.upgrade = 'websocket';
|
|
153
181
|
delete headers['set-cookie'];
|
|
182
|
+
// A browser that offered subprotocols needs one answered; only the marker, never the credential.
|
|
183
|
+
if (route.deviceSocket)
|
|
184
|
+
headers['sec-websocket-protocol'] = DEVICE_SOCKET_PROTOCOL;
|
|
154
185
|
socket.write(`HTTP/1.1 101 Switching Protocols\r\n${Object.entries(headers).flatMap(([k, v]) => (Array.isArray(v) ? v : [v]).map(value => `${k}: ${value}\r\n`)).join('')}\r\n`);
|
|
155
186
|
if (head.length)
|
|
156
187
|
peer.write(head);
|
|
157
188
|
if (upstreamHead.length)
|
|
158
189
|
socket.write(upstreamHead);
|
|
159
|
-
const untrack = track(
|
|
190
|
+
const untrack = track(route.authHeaders, route.session, () => { peer.destroy(); socket.destroy(); });
|
|
160
191
|
socket.on('close', untrack);
|
|
161
192
|
peer.pipe(socket);
|
|
162
193
|
socket.pipe(peer);
|
package/dist/web/runtime.js
CHANGED
|
@@ -246,7 +246,9 @@ export async function startWebConsole(options) {
|
|
|
246
246
|
try {
|
|
247
247
|
const profile = readClientProfile(), provider = new URL(profile.serverUrl), credential = readPrivateFile(profile.credentialPath, 4096).toString('utf8').trim();
|
|
248
248
|
const basePath = provider.pathname.replace(/\/$/, '');
|
|
249
|
-
const services = ['daemon', 'cowork', 'messenger', 'notifications'].map(name => ({ prefix: '/' + name, origin: provider.origin, upstreamPrefix: basePath + '/' + name, stripBrowserContext: true, headers: { 'X-Ours-Api-Token': credential, ...(name === 'messenger' ? { Origin: provider.origin, 'X-Ours-Messenger-CSRF': '1' } : name === 'cowork' ? { Origin: provider.origin } : {}) }
|
|
249
|
+
const services = ['daemon', 'cowork', 'messenger', 'notifications'].map(name => ({ prefix: '/' + name, origin: provider.origin, upstreamPrefix: basePath + '/' + name, stripBrowserContext: true, headers: { 'X-Ours-Api-Token': credential, ...(name === 'messenger' ? { Origin: provider.origin, 'X-Ours-Messenger-CSRF': '1' } : name === 'cowork' ? { Origin: provider.origin } : {}) },
|
|
250
|
+
// The App reports a visible page to the notification service, so an open app is not sent a push.
|
|
251
|
+
...(name === 'notifications' ? { deviceSocketPaths: ['/api/v1/presence'] } : {}) }));
|
|
250
252
|
gateway = createPrefixGateway({ auth: server.auth, fleetOrigin: address, services });
|
|
251
253
|
const listen = (port) => new Promise((resolve, reject) => { gateway.server.once('error', reject); gateway.server.listen(port, bind, () => { gateway.server.off('error', reject); resolve(); }); });
|
|
252
254
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/fleet",
|
|
3
|
-
"version": "1.2.0-nightly.
|
|
3
|
+
"version": "1.2.0-nightly.40",
|
|
4
4
|
"description": "Harness-agnostic fleet of persistent, identity-bound AI agents. Declarative fleet.yaml, managed native/ACP sessions, supervision, and ours.network messaging.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|