openvibers/openvibe.live Commits
Fix HLS and FLV playback in cross-site Live embeds (#833)
Changes
@@@ -43,7 +43,7 @@ async function page(req, res) {const db = require('../db/database');const channel = await db.getChannelByUsername(username).catch(() => null) || await db.getUserByUsername(username).catch(() => null);if (!channel) return res.sendStatus(404);-- res.set('Content-Security-Policy', `default-src 'self'; script-src 'self' 'unsafe-inline' https://esm.sh; style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:; media-src 'self' blob:; connect-src 'self' wss: https://esm.sh; frame-ancestors ${(await frameSites()).join(' ')}; base-uri 'none'; form-action 'none'`);++ res.set('Content-Security-Policy', `default-src 'self'; script-src 'self' 'unsafe-inline' https://esm.sh https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:; media-src 'self' blob:; connect-src 'self' wss: https://esm.sh; frame-ancestors ${(await frameSites()).join(' ')}; base-uri 'none'; form-action 'none'`);res.set('Cache-Control', 'no-store').set('X-Robots-Tag', 'noindex').type('html').send(html(await frameSites()));}module.exports = { page, frameSites, html, FALLBACK_SITES };@@@ -43,6 +43,7 @@ assert.strictEqual(video.muted, false, 'allowlisted parent can control playback'await embed.page({ params: { username: '@embedcheck' } }, known);assert.strictEqual(known.statusCode, 200, 'known channel route is served');assert.match(known.headers['Content-Security-Policy'], /frame-ancestors 'self' https:\/\/openvibe\.live https:\/\/openvibe\.network https:\/\/\*\.openvibe\.website/);++ assert.match(known.headers['Content-Security-Policy'], /script-src [^;]*https:\/\/cdn\.jsdelivr\.net/, 'embedded HLS and FLV scripts can load under CSP');const missing = response();await embed.page({ params: { username: 'missing' } }, missing);assert.strictEqual(missing.statusCode, 404, 'unknown channel route is 404');
@@ -43,7 +43,7 @@ async function page(req, res) {
@@ -43,7 +43,7 @@ async function page(req, res) {
const db = require('../db/database');
const db = require('../db/database');
const channel = await db.getChannelByUsername(username).catch(() => null) || await db.getUserByUsername(username).catch(() => null);
const channel = await db.getChannelByUsername(username).catch(() => null) || await db.getUserByUsername(username).catch(() => null);
if (!channel) return res.sendStatus(404);
if (!channel) return res.sendStatus(404);
- res.set('Content-Security-Policy', `default-src 'self'; script-src 'self' 'unsafe-inline' https://esm.sh; style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:; media-src 'self' blob:; connect-src 'self' wss: https://esm.sh; frame-ancestors ${(await frameSites()).join(' ')}; base-uri 'none'; form-action 'none'`);
+ res.set('Content-Security-Policy', `default-src 'self'; script-src 'self' 'unsafe-inline' https://esm.sh https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:; media-src 'self' blob:; connect-src 'self' wss: https://esm.sh; frame-ancestors ${(await frameSites()).join(' ')}; base-uri 'none'; form-action 'none'`);
res.set('Cache-Control', 'no-store').set('X-Robots-Tag', 'noindex').type('html').send(html(await frameSites()));
res.set('Cache-Control', 'no-store').set('X-Robots-Tag', 'noindex').type('html').send(html(await frameSites()));
}
}
module.exports = { page, frameSites, html, FALLBACK_SITES };
module.exports = { page, frameSites, html, FALLBACK_SITES };
@@ -43,6 +43,7 @@ assert.strictEqual(video.muted, false, 'allowlisted parent can control playback'
@@ -43,6 +43,7 @@ assert.strictEqual(video.muted, false, 'allowlisted parent can control playback'
await embed.page({ params: { username: '@embedcheck' } }, known);
await embed.page({ params: { username: '@embedcheck' } }, known);
assert.strictEqual(known.statusCode, 200, 'known channel route is served');
assert.strictEqual(known.statusCode, 200, 'known channel route is served');
assert.match(known.headers['Content-Security-Policy'], /frame-ancestors 'self' https:\/\/openvibe\.live https:\/\/openvibe\.network https:\/\/\*\.openvibe\.website/);
assert.match(known.headers['Content-Security-Policy'], /frame-ancestors 'self' https:\/\/openvibe\.live https:\/\/openvibe\.network https:\/\/\*\.openvibe\.website/);
+ assert.match(known.headers['Content-Security-Policy'], /script-src [^;]*https:\/\/cdn\.jsdelivr\.net/, 'embedded HLS and FLV scripts can load under CSP');
const missing = response();
const missing = response();
await embed.page({ params: { username: 'missing' } }, missing);
await embed.page({ params: { username: 'missing' } }, missing);
assert.strictEqual(missing.statusCode, 404, 'unknown channel route is 404');
assert.strictEqual(missing.statusCode, 404, 'unknown channel route is 404');