openvibers/openvibe.network Commits
openvibe.link serves its egress settings script (#734)
Changes
@@@ -114,8 +114,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {'Access-Control-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff' });return res.end(req.method === 'HEAD' ? undefined : source);}-- if (path === '/send.js' && (req.method === 'GET' || req.method === 'HEAD')) {-- const source = fs.readFileSync(pathLib.join(__dirname, 'send.js'), 'utf8');++ // The page's two scripts, from this folder: send.js and egress-settings.js. The second had no route, so++ // openvibe.link/egress-settings.js fell through to the host's 301 onto openvibe.network, where it 404s and its++ // same-origin resource policy blocks it (found 11-09): the egress form never got its script.++ if ((path === '/send.js' || path === '/egress-settings.js') && (req.method === 'GET' || req.method === 'HEAD')) {++ const source = fs.readFileSync(pathLib.join(__dirname, path.slice(1)), 'utf8');res.set({ 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'public, max-age=600', 'X-Content-Type-Options': 'nosniff' });return res.end(req.method === 'HEAD' ? undefined : source);}@@@ -188,6 +188,11 @@ const SHAPED = {const sendScript = await get('/send.js', 'openvibe.link');assert.strictEqual(sendScript.status, 200, 'Link Send script is served on the Link host');assert.ok(sendScript.body.includes('locker.seal'), 'the page seals content before upload');++ // Every script the page names is served on the Link host itself (egress-settings.js 301'd to Network and 404'd).++ for (const src of [...html.matchAll(/<script[^>]+src="(\/[^"/][^"]*)"/g)].map((m) => m[1]).filter((s) => !s.startsWith('/shared/'))) {++ const script = await get(src, 'openvibe.link');++ assert.strictEqual(script.status, 200, `${src} is served on openvibe.link`);++ }const locker = await get('/locker.mjs', 'openvibe.link');assert.strictEqual(locker.status, 200, 'the SDK browser bundle is served for Link');assert.strictEqual(locker.headers['access-control-allow-origin'], '*', 'the public SDK bundle can be imported by Link\'s loopback window');
@@ -114,8 +114,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {
@@ -114,8 +114,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {
'Access-Control-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff' });
'Access-Control-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff' });
return res.end(req.method === 'HEAD' ? undefined : source);
return res.end(req.method === 'HEAD' ? undefined : source);
}
}
- if (path === '/send.js' && (req.method === 'GET' || req.method === 'HEAD')) {
- const source = fs.readFileSync(pathLib.join(__dirname, 'send.js'), 'utf8');
+ // The page's two scripts, from this folder: send.js and egress-settings.js. The second had no route, so
+ // openvibe.link/egress-settings.js fell through to the host's 301 onto openvibe.network, where it 404s and its
+ // same-origin resource policy blocks it (found 11-09): the egress form never got its script.
+ if ((path === '/send.js' || path === '/egress-settings.js') && (req.method === 'GET' || req.method === 'HEAD')) {
+ const source = fs.readFileSync(pathLib.join(__dirname, path.slice(1)), 'utf8');
res.set({ 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'public, max-age=600', 'X-Content-Type-Options': 'nosniff' });
res.set({ 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'public, max-age=600', 'X-Content-Type-Options': 'nosniff' });
return res.end(req.method === 'HEAD' ? undefined : source);
return res.end(req.method === 'HEAD' ? undefined : source);
}
}
@@ -188,6 +188,11 @@ const SHAPED = {
@@ -188,6 +188,11 @@ const SHAPED = {
const sendScript = await get('/send.js', 'openvibe.link');
const sendScript = await get('/send.js', 'openvibe.link');
assert.strictEqual(sendScript.status, 200, 'Link Send script is served on the Link host');
assert.strictEqual(sendScript.status, 200, 'Link Send script is served on the Link host');
assert.ok(sendScript.body.includes('locker.seal'), 'the page seals content before upload');
assert.ok(sendScript.body.includes('locker.seal'), 'the page seals content before upload');
+ // Every script the page names is served on the Link host itself (egress-settings.js 301'd to Network and 404'd).
+ for (const src of [...html.matchAll(/<script[^>]+src="(\/[^"/][^"]*)"/g)].map((m) => m[1]).filter((s) => !s.startsWith('/shared/'))) {
+ const script = await get(src, 'openvibe.link');
+ assert.strictEqual(script.status, 200, `${src} is served on openvibe.link`);
+ }
const locker = await get('/locker.mjs', 'openvibe.link');
const locker = await get('/locker.mjs', 'openvibe.link');
assert.strictEqual(locker.status, 200, 'the SDK browser bundle is served for Link');
assert.strictEqual(locker.status, 200, 'the SDK browser bundle is served for Link');
assert.strictEqual(locker.headers['access-control-allow-origin'], '*', 'the public SDK bundle can be imported by Link\'s loopback window');
assert.strictEqual(locker.headers['access-control-allow-origin'], '*', 'the public SDK bundle can be imported by Link\'s loopback window');