chore(release): release v2.0.5

This commit is contained in:
Koala
2026-06-03 11:33:24 +02:00
parent a948780745
commit 595ea297f5
26 changed files with 461 additions and 74 deletions
+36 -2
View File
@@ -9,13 +9,47 @@ if (!fs.existsSync(enPath)) {
process.exit(1);
}
let hasError = false;
// Verify SUPPORTED_LANGUAGES in extension/i18n.js matches JSON files
const i18nPath = path.join(__dirname, '..', 'extension', 'i18n.js');
try {
if (fs.existsSync(i18nPath)) {
const i18nContent = fs.readFileSync(i18nPath, 'utf8');
const langMatch = i18nContent.match(/export const SUPPORTED_LANGUAGES = \[(.*?)\];/);
if (!langMatch) {
hasError = true;
console.error('❌ Could not parse SUPPORTED_LANGUAGES from extension/i18n.js');
} else {
const supportedLangs = langMatch[1].split(',').map(s => s.trim().replace(/['"]/g, ''));
const fileLangs = fs.readdirSync(localesDir)
.filter(file => file.endsWith('.json'))
.map(file => file.replace('.json', ''));
for (const lang of fileLangs) {
if (!supportedLangs.includes(lang)) {
hasError = true;
console.error(`${lang}.json exists in extension/locales but is missing from SUPPORTED_LANGUAGES in extension/i18n.js`);
}
}
for (const lang of supportedLangs) {
if (!fileLangs.includes(lang)) {
hasError = true;
console.error(`${lang} is in SUPPORTED_LANGUAGES in extension/i18n.js but ${lang}.json is missing from extension/locales`);
}
}
}
}
} catch (err) {
hasError = true;
console.error('❌ Failed to verify SUPPORTED_LANGUAGES synchronization:', err.message);
}
const enDict = JSON.parse(fs.readFileSync(enPath, 'utf8'));
const enKeys = Object.keys(enDict);
const localeFiles = fs.readdirSync(localesDir).filter(file => file.endsWith('.json') && file !== 'en.json');
let hasError = false;
console.log(`Auditing i18n locales using ${enKeys.length} baseline keys from en.json...\n`);
for (const file of localeFiles) {
+94
View File
@@ -0,0 +1,94 @@
import assert from 'node:assert/strict';
import {
ADMIN_METRICS_AUTH_RATE_LIMIT_PER_MINUTE,
HEALTH_RATE_LIMIT_PER_MINUTE,
healthCounts,
adminMetricsAuthCounts,
healthResponseCache,
httpServer,
rooms,
startServer,
stopServerForTests
} from '../server/index.js';
const adminToken = process.env.ADMIN_METRICS_TOKEN || 'test-admin-token-with-more-than-32-chars';
const baseHeaders = { 'x-forwarded-for': '203.0.113.10' };
function url(path) {
const address = httpServer.address();
return `http://127.0.0.1:${address.port}${path}`;
}
async function request(path, options = {}) {
return fetch(url(path), {
...options,
headers: {
...baseHeaders,
...(options.headers || {})
}
});
}
try {
await startServer(0, '127.0.0.1');
let res = await request('/');
assert.equal(res.status, 200, 'root health endpoint should respond');
assert.equal(res.headers.get('cache-control'), 'no-store', 'root response should disable HTTP caching');
assert.deepEqual(await res.json(), { status: 'online', service: 'KoalaSync Relay' });
res = await request('/health');
assert.equal(res.status, 200, 'basic health endpoint should respond');
assert.equal(res.headers.get('cache-control'), 'no-store', 'basic health response should disable HTTP caching');
const basicHealth = await res.json();
assert.equal(basicHealth.status, 'ok', 'basic health should report ok');
assert.equal(basicHealth.rooms, 0, 'basic health should include room count');
assert.equal('peers' in basicHealth, false, 'basic health should not expose admin metrics');
assert.equal('memory' in basicHealth, false, 'basic health should not expose memory metrics');
rooms.set('route-test-room', {
peers: new Set(['socket-a', 'socket-b']),
peerData: new Map(),
peerIds: new Map(),
activeLobby: { expectedTitle: 'Episode 1', initiatorPeerId: 'peer-a', readyPeers: ['peer-a'] }
});
healthResponseCache.clear();
healthCounts.clear();
res = await request('/health', {
headers: { authorization: `Bearer ${adminToken}`, 'x-forwarded-for': '203.0.113.20' }
});
assert.equal(res.status, 200, 'authorized admin health endpoint should respond');
const adminHealth = await res.json();
assert.equal(adminHealth.rooms, 1, 'admin health should include room count');
assert.equal(adminHealth.peers, 2, 'admin health should include aggregate peer count');
assert.equal(adminHealth.roomsWithLobby, 1, 'admin health should include aggregate lobby count');
assert.equal(typeof adminHealth.memory?.rss, 'number', 'admin health should include aggregate memory metrics');
assert.equal('route-test-room' in adminHealth, false, 'admin health should not expose room identifiers');
healthCounts.clear();
adminMetricsAuthCounts.clear();
for (let i = 0; i < ADMIN_METRICS_AUTH_RATE_LIMIT_PER_MINUTE; i++) {
res = await request('/health', {
headers: { authorization: 'Bearer wrong-token', 'x-forwarded-for': '203.0.113.30' }
});
assert.equal(res.status, 200, `wrong admin bearer attempt ${i + 1} should still return basic health`);
}
res = await request('/health', {
headers: { authorization: 'Bearer wrong-token', 'x-forwarded-for': '203.0.113.30' }
});
assert.equal(res.status, 429, 'wrong admin bearer attempts should be throttled after the limit');
healthCounts.clear();
for (let i = 0; i < HEALTH_RATE_LIMIT_PER_MINUTE; i++) {
const path = i % 2 === 0 ? '/' : '/health';
res = await request(path, { headers: { 'x-forwarded-for': '203.0.113.40' } });
assert.equal(res.status, 200, `shared health request ${i + 1} should be allowed`);
}
res = await request('/', { headers: { 'x-forwarded-for': '203.0.113.40' } });
assert.equal(res.status, 429, 'root and health should share the public health rate limit');
console.log('server route tests passed');
} finally {
await stopServerForTests();
}
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const checks = [
['server ops', 'node', ['scripts/test-server-ops.mjs']],
['server routes', 'node', ['scripts/test-server-routes.mjs'], {
env: { ADMIN_METRICS_TOKEN: 'verify-admin-token-with-more-than-32-chars' }
}],
['content video finder', 'node', ['scripts/test-content-video-finder.js']],
['popup refresh cooldown', 'node', ['scripts/test-popup-refresh-cooldown.mjs']],
['server syntax index', 'node', ['-c', 'server/index.js']],
['server syntax ops', 'node', ['-c', 'server/ops.js']],
['content syntax', 'node', ['-c', 'extension/content.js']],
['popup syntax', 'node', ['-c', 'extension/popup.js']],
['background syntax', 'node', ['-c', 'extension/background.js']],
['locale coverage', 'node', ['scripts/test-locales.js']],
['lint', 'npm', ['run', 'lint']],
['root production audit', 'npm', ['audit', '--omit=dev']],
['server production audit', 'npm', ['audit', '--omit=dev'], { cwd: path.join(repoRoot, 'server') }],
['extension build', 'npm', ['run', 'build:extension']],
['website build', 'node', ['website/build.js']]
];
function runCheck([label, command, args, options = {}]) {
return new Promise((resolve, reject) => {
console.log(`\n==> ${label}`);
const child = spawn(command, args, {
cwd: options.cwd || repoRoot,
env: { ...process.env, ...(options.env || {}) },
stdio: 'inherit'
});
child.on('error', reject);
child.on('exit', (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`${label} failed with exit code ${code}`));
});
});
}
for (const check of checks) {
await runCheck(check);
}
console.log('\nRelease verification passed');