openvibers/openvibe.network Commits
Link answers a machine's old sub-paths on its hub (#746)
Changes
@@@ -202,7 +202,7 @@ server {proxy_set_header X-Forwarded-Proto $scheme;add_header Cache-Control "no-store" always;}-- location ~ ^/(|install|machines|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {++ location ~ ^/(|install|machines(/.*)?|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {limit_except GET HEAD { deny all; }proxy_pass http://127.0.0.1:4000;proxy_http_version 1.1;@@@ -86,6 +86,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {if (path === '/machines') {return res.set('Cache-Control', 'no-store').sendFile(pathLib.join(__dirname, '..', '..', 'public', 'my.html'));}++ // Older links name a machine's screen, desks or pairing below /machines (Actor's Watch links, Bot's old++ // pages). The hub is the one page this host has, so they land on it instead of the catch-all's Network 404.++ if (path.startsWith('/machines/')) {++ return res.set('Cache-Control', 'no-store').redirect(301, `${SITE}/machines`);++ }if (path === '/pair' || path === '/panel') {return res.set('Cache-Control', 'no-store').redirect(302, `${SITE}/machines`);}@@@ -61,7 +61,7 @@ const SHAPED = {// The vhost must send /machines and /pair to the app (which signposts them), not the catch-all to Network.const vhost = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'parked-domains.conf'), 'utf8');-- assert.ok(/location ~ \^\/\(\|install\|machines\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js) and the Locker bundle to Network');++ assert.ok(/location ~ \^\/\(\|install\|machines(?:\(\/\.\*\)\?)?\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js), the machine hub and its old sub-paths, and the Locker bundle to Network');const sendApi = vhost.slice(vhost.indexOf('location ~ ^/api/v1/me/nodes/(send-keys|send)$ {'));assert.ok(sendApi.length < vhost.length && /client_max_body_size 40m;/.test(sendApi.slice(0, sendApi.indexOf('\n }'))), 'the Link Send API has its own location with a body limit that fits a file');// …and /auth/* to Link's own sign-in (Network#664), or openvibe.link never signs anyone in (11-08 audit).@@@ -216,6 +216,12 @@ const SHAPED = {assert.strictEqual(hub.status, 302, `${p} opens the Link machine hub`);assert.strictEqual(hub.headers.location, 'https://openvibe.link/machines');}++ // Bot's old sub-paths (and Actor's Watch links) land on the hub rather than the catch-all's Network 404.++ for (const p of ['/machines/dev_01ABC/screen?desk=desk-task-a', '/machines/dev_01ABC/desks']) {++ const sub = await get(p, 'openvibe.link');++ assert.strictEqual(sub.status, 301, `${p} goes to the hub`);++ assert.strictEqual(sub.headers.location, 'https://openvibe.link/machines');++ }const www = await get('/', 'www.openvibe.link');assert.strictEqual(www.status, 301, 'www 301s');
@@ -202,7 +202,7 @@ server {
@@ -202,7 +202,7 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
add_header Cache-Control "no-store" always;
add_header Cache-Control "no-store" always;
}
}
- location ~ ^/(|install|machines|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {
+ location ~ ^/(|install|machines(/.*)?|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {
limit_except GET HEAD { deny all; }
limit_except GET HEAD { deny all; }
proxy_pass http://127.0.0.1:4000;
proxy_pass http://127.0.0.1:4000;
proxy_http_version 1.1;
proxy_http_version 1.1;
@@ -86,6 +86,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {
@@ -86,6 +86,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {
if (path === '/machines') {
if (path === '/machines') {
return res.set('Cache-Control', 'no-store').sendFile(pathLib.join(__dirname, '..', '..', 'public', 'my.html'));
return res.set('Cache-Control', 'no-store').sendFile(pathLib.join(__dirname, '..', '..', 'public', 'my.html'));
}
}
+ // Older links name a machine's screen, desks or pairing below /machines (Actor's Watch links, Bot's old
+ // pages). The hub is the one page this host has, so they land on it instead of the catch-all's Network 404.
+ if (path.startsWith('/machines/')) {
+ return res.set('Cache-Control', 'no-store').redirect(301, `${SITE}/machines`);
+ }
if (path === '/pair' || path === '/panel') {
if (path === '/pair' || path === '/panel') {
return res.set('Cache-Control', 'no-store').redirect(302, `${SITE}/machines`);
return res.set('Cache-Control', 'no-store').redirect(302, `${SITE}/machines`);
}
}
@@ -61,7 +61,7 @@ const SHAPED = {
@@ -61,7 +61,7 @@ const SHAPED = {
// The vhost must send /machines and /pair to the app (which signposts them), not the catch-all to Network.
// The vhost must send /machines and /pair to the app (which signposts them), not the catch-all to Network.
const vhost = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'parked-domains.conf'), 'utf8');
const vhost = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'parked-domains.conf'), 'utf8');
- assert.ok(/location ~ \^\/\(\|install\|machines\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js) and the Locker bundle to Network');
+ assert.ok(/location ~ \^\/\(\|install\|machines(?:\(\/\.\*\)\?)?\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js), the machine hub and its old sub-paths, and the Locker bundle to Network');
const sendApi = vhost.slice(vhost.indexOf('location ~ ^/api/v1/me/nodes/(send-keys|send)$ {'));
const sendApi = vhost.slice(vhost.indexOf('location ~ ^/api/v1/me/nodes/(send-keys|send)$ {'));
assert.ok(sendApi.length < vhost.length && /client_max_body_size 40m;/.test(sendApi.slice(0, sendApi.indexOf('\n }'))), 'the Link Send API has its own location with a body limit that fits a file');
assert.ok(sendApi.length < vhost.length && /client_max_body_size 40m;/.test(sendApi.slice(0, sendApi.indexOf('\n }'))), 'the Link Send API has its own location with a body limit that fits a file');
// …and /auth/* to Link's own sign-in (Network#664), or openvibe.link never signs anyone in (11-08 audit).
// …and /auth/* to Link's own sign-in (Network#664), or openvibe.link never signs anyone in (11-08 audit).
@@ -216,6 +216,12 @@ const SHAPED = {
@@ -216,6 +216,12 @@ const SHAPED = {
assert.strictEqual(hub.status, 302, `${p} opens the Link machine hub`);
assert.strictEqual(hub.status, 302, `${p} opens the Link machine hub`);
assert.strictEqual(hub.headers.location, 'https://openvibe.link/machines');
assert.strictEqual(hub.headers.location, 'https://openvibe.link/machines');
}
}
+ // Bot's old sub-paths (and Actor's Watch links) land on the hub rather than the catch-all's Network 404.
+ for (const p of ['/machines/dev_01ABC/screen?desk=desk-task-a', '/machines/dev_01ABC/desks']) {
+ const sub = await get(p, 'openvibe.link');
+ assert.strictEqual(sub.status, 301, `${p} goes to the hub`);
+ assert.strictEqual(sub.headers.location, 'https://openvibe.link/machines');
+ }
const www = await get('/', 'www.openvibe.link');
const www = await get('/', 'www.openvibe.link');
assert.strictEqual(www.status, 301, 'www 301s');
assert.strictEqual(www.status, 301, 'www 301s');