feat: add GitHub skin store and organize instance administration

Adopt the pinned published TeamSpeak SDK and direct relay routing.
Add optional TeamSpeak Query administration with encrypted credentials
and separate WebSpeak access, site, operations and skin management.
Distribute Discord Voice through the GitHub skin index, preserve skin
state during updates, and correct KAAK scaling and screen fullscreen.

Validation: 831 tests; backend and frontend builds; five-language UI
checks from narrow screens through 4K and local Query fixture actions.
This commit is contained in:
illusia committed 2026-10-24 12:52:59 +08:00
1 parent 180bfeb52f
commit 0af3236c30
95 files changed
+7678 -709

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
import assert from "node:assert/strict";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import test from "node:test";
import { DatabaseSync } from "node:sqlite";
import { encryptSecret, decryptSecret } from "../security/secret-crypto.js";
import { DATABASE_SCHEMA_VERSION, WebSpeakDatabase } from "./database.js";
test("relay voice endpoint is stored by the current database migration", (context) => {
const directory = mkdtempSync(path.join(tmpdir(), "webspeak-relay-db-"));
const database = new WebSpeakDatabase(path.join(directory, "webspeak.sqlite"));
context.after(() => {
database.close();
rmSync(directory, { recursive: true, force: true });
});
assert.equal(DATABASE_SCHEMA_VERSION, 12);
assert.equal(database.schemaVersion, DATABASE_SCHEMA_VERSION);
assert.equal(database.getTsAdminSettings().transport, "web");
assert.equal(database.getTsAdminSettings().enabled, false);
database.replaceRelayNodes([{
id: "de-relay",
name: "Germany relay",
enabled: true,
host: "relay.example.com",
port: 39087,
voiceEndpoint: "https://relay.example.com",
tokenEncrypted: null,
}]);
assert.equal(database.listRelayNodes()[0]?.voiceEndpoint, "https://relay.example.com");
});
test("schema 11 migration preserves encrypted SSH credentials and does not silently switch transport", t => {
const directory = mkdtempSync(path.join(tmpdir(), "webspeak-ts-admin-migration-"));
const filename = path.join(directory, "test.sqlite"), master = Buffer.alloc(32, 9);
const encrypted = encryptSecret("fixture-ssh-password", master, "webspeak:ts-admin-query-password:v1");
const original = new WebSpeakDatabase(filename);
original.close();
const old = new DatabaseSync(filename);
old.exec("ALTER TABLE ts_admin_settings DROP COLUMN transport; ALTER TABLE ts_admin_settings DROP COLUMN query_host; ALTER TABLE ts_admin_settings DROP COLUMN web_query_url; ALTER TABLE ts_admin_settings DROP COLUMN api_key_encrypted; ALTER TABLE ts_admin_settings DROP COLUMN server_id; PRAGMA user_version = 11;");
old.prepare("UPDATE ts_admin_settings SET enabled=1, query_port=10222, username='query-owner', password_encrypted=?, host_key_fingerprint=?").run(encrypted, `SHA256:${"A".repeat(43)}`);
old.close();
const migrated = new WebSpeakDatabase(filename);
t.after(() => { migrated.close(); rmSync(directory, { recursive: true, force: true }); });
const settings = migrated.getTsAdminSettings();
assert.equal(migrated.schemaVersion, 12);
assert.equal(settings.transport, "ssh"); assert.equal(settings.enabled, true);
assert.equal(settings.queryPort, 10222); assert.equal(settings.username, "query-owner");
assert.equal(settings.passwordEncrypted, encrypted);
assert.equal(decryptSecret(settings.passwordEncrypted, master, "webspeak:ts-admin-query-password:v1"), "fixture-ssh-password");
assert.equal(settings.apiKeyEncrypted, null); assert.equal(settings.webQueryUrl, ""); assert.equal(settings.serverId, 0);
});
+108 -3
View File
@@ -6,7 +6,7 @@ import type { AdminCredential } from "../security/admin-password.js";
import type { TeamSpeakProtocol } from "../server/teamspeak-adapter.js";
import { DEFAULT_WEBRTC_UDP_PORT_RANGE } from "../server/webrtc-config.js";
export const DATABASE_SCHEMA_VERSION = 9;
export const DATABASE_SCHEMA_VERSION = 12;
export type AccessMode = "fixed" | "open";
export interface PersistedSettings {
@@ -72,6 +72,7 @@ export interface PersistedRelayNode {
enabled: boolean;
host: string;
port: number;
voiceEndpoint: string;
tokenEncrypted: string | null;
createdAt: string;
updatedAt: string;
@@ -92,6 +93,20 @@ export interface ManagedInviteRecord {
revokedAt: string | null;
}
export interface PersistedTsAdminSettings {
enabled: boolean;
transport: "web" | "ssh" | "tcp";
queryHost: string;
webQueryUrl: string;
apiKeyEncrypted: string | null;
serverId: number;
queryPort: number;
username: string;
passwordEncrypted: string | null;
hostKeyFingerprint: string;
updatedAt: string;
}
interface ManagedInviteRow extends Record<string, unknown> {
id: string;
token_hash: string;
@@ -138,12 +153,27 @@ interface SettingsRow extends Record<string, unknown> {
updated_at: string;
}
interface TsAdminSettingsRow extends Record<string, unknown> {
enabled: number;
transport: "web" | "ssh" | "tcp";
query_host: string;
web_query_url: string;
api_key_encrypted: string | null;
server_id: number;
query_port: number;
username: string;
password_encrypted: string | null;
host_key_fingerprint: string;
updated_at: string;
}
interface RelayNodeRow extends Record<string, unknown> {
id: string;
name: string;
enabled: number;
host: string;
port: number;
voice_endpoint: string;
token_encrypted: string | null;
created_at: string;
updated_at: string;
@@ -247,6 +277,7 @@ export class WebSpeakDatabase {
enabled: row.enabled === 1,
host: row.host,
port: row.port,
voiceEndpoint: row.voice_endpoint,
tokenEncrypted: row.token_encrypted,
createdAt: row.created_at,
updatedAt: row.updated_at,
@@ -258,8 +289,8 @@ export class WebSpeakDatabase {
this.transaction(() => {
this.database.exec("DELETE FROM relay_nodes");
const insert = this.database.prepare(
`INSERT INTO relay_nodes (id, name, enabled, host, port, token_encrypted, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
`INSERT INTO relay_nodes (id, name, enabled, host, port, voice_endpoint, token_encrypted, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
);
for (const node of nodes) {
insert.run(
@@ -268,6 +299,7 @@ export class WebSpeakDatabase {
node.enabled ? 1 : 0,
node.host,
node.port,
node.voiceEndpoint,
node.tokenEncrypted,
node.createdAt ?? now,
node.updatedAt ?? now,
@@ -333,6 +365,37 @@ export class WebSpeakDatabase {
return rows.map(mapManagedInviteRow);
}
getTsAdminSettings(): PersistedTsAdminSettings {
const row = this.database.prepare("SELECT * FROM ts_admin_settings WHERE id = 1").get() as TsAdminSettingsRow;
return {
enabled: row.enabled === 1,
transport: row.transport,
queryHost: row.query_host,
webQueryUrl: row.web_query_url,
apiKeyEncrypted: row.api_key_encrypted,
serverId: row.server_id,
queryPort: row.query_port,
username: row.username,
passwordEncrypted: row.password_encrypted,
hostKeyFingerprint: row.host_key_fingerprint,
updatedAt: row.updated_at,
};
}
updateTsAdminSettings(settings: Omit<PersistedTsAdminSettings, "updatedAt">): void {
const now = new Date().toISOString();
this.transaction(() => {
this.database.prepare(
`UPDATE ts_admin_settings
SET enabled = ?, transport = ?, query_host = ?, web_query_url = ?, api_key_encrypted = ?, server_id = ?,
query_port = ?, username = ?, password_encrypted = ?, host_key_fingerprint = ?, updated_at = ?
WHERE id = 1`,
).run(settings.enabled ? 1 : 0, settings.transport, settings.queryHost, settings.webQueryUrl, settings.apiKeyEncrypted, settings.serverId,
settings.queryPort, settings.username, settings.passwordEncrypted, settings.hostKeyFingerprint, now);
this.insertAudit("TS_ADMIN_SETTINGS_UPDATED", { enabled: settings.enabled, transport: settings.transport }, now);
});
}
getManagedInvite(tokenHash: string, now = Date.now()): ManagedInviteRecord | null {
const nowIso = new Date(now).toISOString();
const row = this.database.prepare(
@@ -626,6 +689,48 @@ export class WebSpeakDatabase {
`);
this.database.exec("PRAGMA user_version = 9");
});
version = 9;
}
if (version === 9) {
this.transaction(() => {
this.database.exec(`
CREATE TABLE ts_admin_settings (
id INTEGER PRIMARY KEY CHECK (id = 1),
enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)),
query_port INTEGER NOT NULL DEFAULT 10022 CHECK (query_port BETWEEN 1 AND 65535),
username TEXT NOT NULL DEFAULT '',
password_encrypted TEXT,
host_key_fingerprint TEXT NOT NULL DEFAULT '',
updated_at TEXT NOT NULL
);
`);
this.database.prepare(
`INSERT INTO ts_admin_settings (id, enabled, query_port, username, password_encrypted, host_key_fingerprint, updated_at)
VALUES (1, 0, 10022, '', NULL, '', ?)`,
).run(new Date().toISOString());
this.database.exec("PRAGMA user_version = 10");
});
version = 10;
}
if (version === 10) {
this.transaction(() => {
this.database.exec("ALTER TABLE relay_nodes ADD COLUMN voice_endpoint TEXT NOT NULL DEFAULT ''");
this.database.exec("PRAGMA user_version = 11");
});
version = 11;
}
if (version === 11) {
this.transaction(() => {
this.database.exec(`
ALTER TABLE ts_admin_settings ADD COLUMN transport TEXT NOT NULL DEFAULT 'web' CHECK (transport IN ('web', 'ssh', 'tcp'));
ALTER TABLE ts_admin_settings ADD COLUMN query_host TEXT NOT NULL DEFAULT '';
ALTER TABLE ts_admin_settings ADD COLUMN web_query_url TEXT NOT NULL DEFAULT '';
ALTER TABLE ts_admin_settings ADD COLUMN api_key_encrypted TEXT;
ALTER TABLE ts_admin_settings ADD COLUMN server_id INTEGER NOT NULL DEFAULT 0 CHECK (server_id BETWEEN 0 AND 4294967295);
UPDATE ts_admin_settings SET transport = 'ssh' WHERE enabled = 1 OR password_encrypted IS NOT NULL OR host_key_fingerprint <> '';
PRAGMA user_version = 12;
`);
});
}
}