mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
chore: harden release operations and freeze docs
This commit is contained in:
1 parent
87fcd736be
commit
6337789afa
9 files changed
+176
-23
No files matched your search
@@ -0,0 +1,27 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to WebSpeak are documented here. Versions follow SemVer.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- M009 admin operations dashboard for managed invites, active-session inspection, per-session termination, diagnostics, logs, audit access, diagnostic report download, and SQLite backup export.
|
||||
- Persistent managed invites with expiry, optional maximum uses, revocation, hashed opaque tokens, and encrypted TeamSpeak credentials at rest.
|
||||
- Mobile-aware invite joining through the `invite` URL parameter without placing a TeamSpeak password in the URL.
|
||||
- M010 hardening for per-peer join-ticket rate limiting and bounded rotating runtime logs.
|
||||
|
||||
### Changed
|
||||
|
||||
- Database schema is now version 2 and migrates existing version 1 installations transactionally with a migration copy.
|
||||
- Admin overview and diagnostics use the application package version instead of a hard-coded display value.
|
||||
|
||||
### Verification
|
||||
|
||||
- `npm test` — 46 tests passed.
|
||||
- `npm run build` — backend TypeScript build passed.
|
||||
- `npm run web:build` — frontend production build passed.
|
||||
- `npm audit --omit=dev --audit-level=high` — no high or critical vulnerabilities reported.
|
||||
- Local `/demo` browser checks passed at the documented narrow and desktop widths; `/demo` does not connect to TeamSpeak.
|
||||
|
||||
Real TS3/TS6 interoperability, Android microphone behavior, multi-client smoke, and the 24-hour long-run gate require their respective test environments and are not claimed by this local release check.
|
||||
@@ -22,6 +22,7 @@ WebSpeak 是一个自托管的 TeamSpeak 浏览器客户端与访客接入网关
|
||||
- Away、成员状态图标、Session 内服务器事件日志和人类可读的 TeamSpeak 权限错误。
|
||||
- 中英文访客页面和中英文管理控制台。
|
||||
- Web 管理闭环:默认账号首次登录强制改密、单管理员登录、概览、服务器设置和真实连接测试。
|
||||
- 运维控制台:受控邀请创建/撤销/过期/限次、活动会话列表与单会话断开、审计事件、结构化日志查看、脱敏诊断报告和 SQLite 备份导出。
|
||||
- `fixed` 与 `open` 两种访问模式。
|
||||
- 可选的持久 TeamSpeak identity:身份私钥仅保存在浏览器 IndexedDB,可导入/导出;访客也可继续使用临时身份。
|
||||
- 浏览器本地收藏、最近服务器、昵称、语言、音频设备/模式/音量和按 TeamSpeak UID 保存的成员音量。
|
||||
@@ -29,6 +30,7 @@ WebSpeak 是一个自托管的 TeamSpeak 浏览器客户端与访客接入网关
|
||||
- TeamSpeak 密码使用安装级主密钥加密保存,不向管理 API 返回明文。
|
||||
- 旧 `config.json` 一次性导入,导入后不再作为实时配置源。
|
||||
- `/demo` 提供不连接真实 TeamSpeak 的交互式模拟页面,可用于产品预览和录屏。
|
||||
- 当前实现按 `webspeak-spec` 的 M000–M010 顺序推进;M010 的真实 TS3/TS6、Android 麦克风和 24 小时长稳测试必须在对应环境完成,不能用本地模拟替代。
|
||||
|
||||
### 环境要求
|
||||
|
||||
@@ -117,6 +119,8 @@ data/
|
||||
logs/ 本地日志
|
||||
```
|
||||
|
||||
日志文件单个最多 10 MiB,服务会保留 3 个轮转文件。管理控制台中的“导出数据库备份”只导出 SQLite 数据库,不导出 `master.key`;数据库内的 TeamSpeak 密码仍是加密密文,完整恢复需要同时保管数据目录和主密钥。
|
||||
|
||||
- 管理员密码使用 Node.js `crypto.scrypt`、随机 salt 和 constant-time compare。
|
||||
- 新部署首次使用 `admin/admin` 登录后必须立即修改密码;修改完成后默认密码失效。
|
||||
- TeamSpeak 服务器密码使用 AES-256-GCM 加密。
|
||||
@@ -194,7 +198,7 @@ npm run web:dev
|
||||
# 浏览器打开演示页(不会连接真实 TeamSpeak)
|
||||
# http://localhost:5173/demo
|
||||
|
||||
# 自动测试(覆盖 M000–M007 已实现的后端协议与安全边界)
|
||||
# 自动测试(覆盖 M000–M010 已实现的后端协议与安全边界)
|
||||
npm test
|
||||
|
||||
# 后端类型检查与构建
|
||||
@@ -211,16 +215,17 @@ npm audit
|
||||
|
||||
```text
|
||||
src/
|
||||
admin/ 管理服务、API、Session 与登录限速
|
||||
admin/ 管理服务、API、Session、邀请与运维接口
|
||||
persistence/database.ts SQLite schema、repository 和迁移边界
|
||||
security/ 主密钥、秘密加密、scrypt 与网络策略
|
||||
domain/teamspeak-target.ts host[:port] 规范化解析
|
||||
server/teamspeak-adapter.ts TeamSpeak 协议边界与 endpoint 协议缓存
|
||||
server/teamspeak-probe.ts 可清理的短连接测试
|
||||
server/join-ticket.ts 一次性访客连接票据
|
||||
server/join-rate-limit.ts 访客票据创建限速
|
||||
server/voice-bridge.ts 每用户语音 WebSocket 桥接
|
||||
web/src/views/
|
||||
AdminView.vue 双语 Login/Password change/Overview/Server UI
|
||||
AdminView.vue 双语登录、设置、概览与运维控制台
|
||||
WebClient.vue 双语访客与语音工作台
|
||||
```
|
||||
|
||||
@@ -243,6 +248,7 @@ WebSpeak is a self-hosted TeamSpeak web client and guest gateway. Every browser
|
||||
- Away, member status icons, a session-local server event log, and readable TeamSpeak permission errors.
|
||||
- Bilingual guest UI and bilingual admin console.
|
||||
- Browser-based admin login, mandatory first-login password change, Overview, server settings, and a real short-lived connection test.
|
||||
- Operations dashboard for managed invites, session termination, audit events, logs, sanitized diagnostic reports, and SQLite backup export.
|
||||
- Fixed and open guest access modes.
|
||||
- Optional persistent TeamSpeak identity stored only in browser IndexedDB, with local import/export; guests can still join ephemerally.
|
||||
- Browser-local favorites, recent servers, nickname/language/audio preferences, and per-TeamSpeak-UID member volume.
|
||||
@@ -250,6 +256,7 @@ WebSpeak is a self-hosted TeamSpeak web client and guest gateway. Every browser
|
||||
- Encrypted TeamSpeak server password and one-time legacy config import.
|
||||
- No ServerQuery, WebQuery, admin token, or maintenance bot.
|
||||
- `/demo` is a clearly labeled interactive simulation and never opens a real TeamSpeak connection.
|
||||
- Join-ticket creation is rate-limited per peer; runtime logs rotate at a bounded size.
|
||||
|
||||
### Requirements and startup
|
||||
|
||||
@@ -306,6 +313,8 @@ In fixed mode, guests cannot override the configured target. In open mode, arbit
|
||||
|
||||
When the welcome page has no target parameters from an invite link, its address and port field is prefilled from the admin-configured default TeamSpeak target. Invite-link target parameters take precedence.
|
||||
|
||||
Administrators can create managed invite links from `/admin/operations`. An invite stores only a token hash and encrypted connection secret, can expire or be limited to a number of uses, and can be revoked. The raw token is returned only at creation time and is passed as an `invite` URL parameter; no TeamSpeak password is placed in that URL. The database backup and diagnostic report are separate: the report is sanitized for issue sharing, while the database backup is for local recovery and must be protected.
|
||||
|
||||
If a legacy `config.json` exists on the first upgraded start, only `tsHost`, `tsPort`, and `tsServerPassword` are imported. The original file is preserved, and SQLite becomes the sole live settings source.
|
||||
|
||||
### Development
|
||||
@@ -319,6 +328,8 @@ npm --prefix web run build
|
||||
npm audit
|
||||
```
|
||||
|
||||
The Windows development environment may need the native build toolchain required by `@discordjs/opus`. The browser UI can still be verified locally with `npm run web:dev` and `/demo`; that route is deliberately simulated and does not prove a real TeamSpeak connection.
|
||||
|
||||
### License
|
||||
|
||||
WebSpeak is licensed under the [GNU Affero General Public License v3.0 only](LICENSE) (`AGPL-3.0-only`). If you run a modified version as a network service, you must offer its users the corresponding source code as required by the license.
|
||||
|
||||
@@ -50,6 +50,7 @@ export class AdminService {
|
||||
private readonly logger: Logger,
|
||||
private readonly legacyConfigPath: string,
|
||||
private readonly probe: ProbeFunction = probeTeamSpeak,
|
||||
private readonly version = "0.1.0",
|
||||
) {}
|
||||
|
||||
async initialize(): Promise<void> {
|
||||
@@ -166,7 +167,7 @@ export class AdminService {
|
||||
return {
|
||||
gateway: {
|
||||
status: "running",
|
||||
version: "0.1.0",
|
||||
version: this.version,
|
||||
uptimeSeconds: Math.max(0, Math.floor((Date.now() - startedAt) / 1000)),
|
||||
},
|
||||
teamSpeak: {
|
||||
|
||||
+55
-16
@@ -1,5 +1,9 @@
|
||||
import pino from "pino";
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { appendFile, existsSync, mkdirSync, renameSync, statSync } from "node:fs";
|
||||
import { Writable } from "node:stream";
|
||||
|
||||
const MAX_LOG_BYTES = 10 * 1024 * 1024;
|
||||
const MAX_ROTATED_LOGS = 3;
|
||||
|
||||
export interface Logger {
|
||||
debug(obj: Record<string, unknown>, msg: string): void;
|
||||
@@ -14,23 +18,17 @@ export interface Logger {
|
||||
}
|
||||
|
||||
export function createLogger(logDir?: string): Logger {
|
||||
const targets: pino.TransportTargetOptions[] = [
|
||||
{ target: "pino/file", options: { destination: 1 }, level: "info" },
|
||||
];
|
||||
if (logDir) {
|
||||
mkdirSync(logDir, { recursive: true });
|
||||
targets.push({
|
||||
target: "pino/file",
|
||||
options: { destination: `${logDir}/webspeak.log` },
|
||||
level: "debug",
|
||||
});
|
||||
}
|
||||
|
||||
const baseLogger = pino({
|
||||
const loggerOptions = {
|
||||
level: "debug",
|
||||
timestamp: pino.stdTimeFunctions.isoTime,
|
||||
...(targets.length > 1 ? { transport: { targets } } : {}),
|
||||
});
|
||||
redact: {
|
||||
paths: ["password", "*.password", "serverPassword", "*.serverPassword", "token", "*.token", "identity", "*.identity"],
|
||||
censor: "[Redacted]",
|
||||
},
|
||||
};
|
||||
const baseLogger = logDir
|
||||
? createFileLogger(loggerOptions, `${logDir}/webspeak.log`)
|
||||
: pino(loggerOptions, pino.destination(1));
|
||||
|
||||
function wrap(l: pino.Logger): Logger {
|
||||
function doLog(
|
||||
@@ -60,3 +58,44 @@ export function createLogger(logDir?: string): Logger {
|
||||
|
||||
return wrap(baseLogger);
|
||||
}
|
||||
|
||||
function createFileLogger(options: { level: string; timestamp: typeof pino.stdTimeFunctions.isoTime }, logPath: string): pino.Logger {
|
||||
mkdirSync(logPath.replace(/[\\/][^\\/]+$/, ""), { recursive: true });
|
||||
return pino(options, pino.multistream([
|
||||
{ level: "info", stream: process.stdout },
|
||||
{ level: "debug", stream: new RotatingFileStream(logPath) },
|
||||
]));
|
||||
}
|
||||
|
||||
class RotatingFileStream extends Writable {
|
||||
private bytes: number;
|
||||
|
||||
constructor(private readonly filePath: string) {
|
||||
super();
|
||||
this.bytes = existsSync(filePath) ? statSync(filePath).size : 0;
|
||||
if (this.bytes >= MAX_LOG_BYTES) this.rotate();
|
||||
}
|
||||
|
||||
override _write(chunk: unknown, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
||||
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), encoding);
|
||||
try {
|
||||
if (this.bytes + buffer.length > MAX_LOG_BYTES) this.rotate();
|
||||
appendFile(this.filePath, buffer, (error) => {
|
||||
if (!error) this.bytes += buffer.length;
|
||||
callback(error);
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
callback(error instanceof Error ? error : new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
private rotate(): void {
|
||||
for (let index = MAX_ROTATED_LOGS - 1; index >= 1; index--) {
|
||||
const source = `${this.filePath}.${index}`;
|
||||
const destination = `${this.filePath}.${index + 1}`;
|
||||
if (existsSync(source)) renameSync(source, destination);
|
||||
}
|
||||
if (existsSync(this.filePath)) renameSync(this.filePath, `${this.filePath}.1`);
|
||||
this.bytes = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
const WINDOW_MS = 60 * 1000;
|
||||
const MAX_REQUESTS = 30;
|
||||
|
||||
interface PeerWindow {
|
||||
startedAt: number;
|
||||
requests: number;
|
||||
}
|
||||
|
||||
/** Bounds opaque join-ticket creation so one peer cannot fill the in-memory store. */
|
||||
export class JoinRateLimiter {
|
||||
private readonly peers = new Map<string, PeerWindow>();
|
||||
|
||||
constructor(private readonly maxTrackedPeers = 2048) {}
|
||||
|
||||
allow(peer: string, now = Date.now()): boolean {
|
||||
const current = this.peers.get(peer);
|
||||
if (!current || now - current.startedAt >= WINDOW_MS) {
|
||||
this.prune(now);
|
||||
while (this.peers.size >= this.maxTrackedPeers) {
|
||||
const oldest = this.peers.keys().next().value;
|
||||
if (!oldest) break;
|
||||
this.peers.delete(oldest);
|
||||
}
|
||||
this.peers.set(peer, { startedAt: now, requests: 1 });
|
||||
return true;
|
||||
}
|
||||
if (current.requests >= MAX_REQUESTS) return false;
|
||||
current.requests += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
private prune(now: number): void {
|
||||
for (const [peer, window] of this.peers) {
|
||||
if (now - window.startedAt >= WINDOW_MS) this.peers.delete(peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import type { AdminService } from "../admin/admin-service.js";
|
||||
import { AdminSessionStore } from "../admin/admin-session.js";
|
||||
import { resolveSafeOpenTarget } from "../security/open-target-policy.js";
|
||||
import { identityFromString } from "@honeybbq/teamspeak-client";
|
||||
import { JoinRateLimiter } from "./join-rate-limit.js";
|
||||
|
||||
export interface WebServerOptions {
|
||||
port: number;
|
||||
@@ -47,6 +48,7 @@ export function createWebServer(options: WebServerOptions): WebServer {
|
||||
|
||||
const voiceBridge = new VoiceBridge(options.voiceBridgeOptions, logger);
|
||||
const adminSessions = new AdminSessionStore();
|
||||
const joinRateLimiter = new JoinRateLimiter();
|
||||
const startedAt = Date.now();
|
||||
|
||||
const healthHandler: express.RequestHandler = (_request, response) => {
|
||||
@@ -70,6 +72,10 @@ export function createWebServer(options: WebServerOptions): WebServer {
|
||||
response.status(503).json({ ok: false, code: "NOT_INITIALIZED" });
|
||||
return;
|
||||
}
|
||||
if (!joinRateLimiter.allow(request.socket.remoteAddress ?? "unknown")) {
|
||||
response.status(429).json({ ok: false, code: "RATE_LIMITED" });
|
||||
return;
|
||||
}
|
||||
const body = isRecord(request.body) ? request.body : {};
|
||||
const nickname = typeof body.nickname === "string" ? body.nickname.trim().slice(0, 30) : "";
|
||||
const requestedChannel = typeof body.channel === "string" ? body.channel.trim().slice(0, 100) : "";
|
||||
|
||||
@@ -87,11 +87,26 @@ test("managed invites are opaque, bounded, revocable, and included in database b
|
||||
assert.equal(service.consumeManagedInvite(created.token), null);
|
||||
assert.equal(service.listManagedInvites()[0]?.status, "exhausted");
|
||||
|
||||
database.createManagedInvite({
|
||||
id: "invite-expired-test",
|
||||
tokenHash: "expired-token-hash",
|
||||
targetHost: "127.0.0.1",
|
||||
targetPort: 9987,
|
||||
serverPasswordEncrypted: null,
|
||||
channel: "Expired",
|
||||
expiresAt: new Date(Date.now() - 1).toISOString(),
|
||||
maxUses: 0,
|
||||
});
|
||||
assert.equal(database.consumeManagedInvite("expired-token-hash"), null);
|
||||
const revocable = service.createManagedInvite({ channel: "Revocable", expiresInHours: 2, maxUses: 0 });
|
||||
assert.equal(service.revokeManagedInvite(revocable.invite.id), true);
|
||||
assert.equal(service.listManagedInvites().find((invite) => invite.id === revocable.invite.id)?.status, "revoked");
|
||||
|
||||
const backup = database.exportBackup();
|
||||
assert.ok(backup.length > 100);
|
||||
database.close();
|
||||
const reopened = new WebSpeakDatabase(path.join(directory, "webspeak.db"));
|
||||
assert.equal(reopened.schemaVersion, 2);
|
||||
assert.equal(reopened.listManagedInvites().length, 1);
|
||||
assert.equal(reopened.listManagedInvites().length, 3);
|
||||
reopened.close();
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { JoinRateLimiter } from "../src/server/join-rate-limit.js";
|
||||
|
||||
test("join ticket creation is bounded per peer and resets after its window", () => {
|
||||
const limiter = new JoinRateLimiter(2);
|
||||
let now = 10_000;
|
||||
for (let attempt = 0; attempt < 30; attempt++) assert.equal(limiter.allow("peer-a", now), true);
|
||||
assert.equal(limiter.allow("peer-a", now), false);
|
||||
assert.equal(limiter.allow("peer-b", now), true);
|
||||
now += 60_000;
|
||||
assert.equal(limiter.allow("peer-a", now), true);
|
||||
});
|
||||
@@ -200,6 +200,7 @@ const copy = {
|
||||
endSession: "断开",
|
||||
terminating: "断开中…",
|
||||
sessionTerminated: "会话已断开。",
|
||||
confirmTerminate: "确定断开「{{nickname}}」吗?",
|
||||
invites: "受控邀请",
|
||||
invitesLead: "创建可过期、可限次的邀请链接;链接中不包含服务器密码。",
|
||||
inviteChannel: "目标频道",
|
||||
@@ -215,6 +216,7 @@ const copy = {
|
||||
defaultChannel: "默认频道",
|
||||
revoke: "撤销",
|
||||
inviteRevoked: "邀请链接已撤销。",
|
||||
confirmRevoke: "确定撤销这个邀请链接吗?",
|
||||
active: "有效",
|
||||
expired: "已过期",
|
||||
exhausted: "已用尽",
|
||||
@@ -332,6 +334,7 @@ const copy = {
|
||||
endSession: "Terminate",
|
||||
terminating: "Terminating…",
|
||||
sessionTerminated: "Session terminated.",
|
||||
confirmTerminate: "Terminate “{{nickname}}”?",
|
||||
invites: "Managed invites",
|
||||
invitesLead: "Create expiring, usage-limited invite links without putting the server password in the URL.",
|
||||
inviteChannel: "Target channel",
|
||||
@@ -347,6 +350,7 @@ const copy = {
|
||||
defaultChannel: "Default channel",
|
||||
revoke: "Revoke",
|
||||
inviteRevoked: "Invite link revoked.",
|
||||
confirmRevoke: "Revoke this invite link?",
|
||||
active: "Active",
|
||||
expired: "Expired",
|
||||
exhausted: "Exhausted",
|
||||
@@ -384,9 +388,9 @@ async function logout() { try { await sendJson("/api/admin/logout", "POST", {});
|
||||
async function loadOverview() { Object.assign(overview, await getJson("/api/admin/overview")); }
|
||||
async function loadServerSettings() { const value = await getJson("/api/admin/server"); Object.assign(serverForm, value, { serverPassword: "", passwordAction: "keep" }); }
|
||||
async function loadOperations() { operationsLoading.value = true; try { const [sessions, invites, diagnostics, logs] = await Promise.all([getJson("/api/admin/sessions"), getJson("/api/admin/invites"), getJson("/api/admin/diagnostics"), getJson("/api/admin/logs?limit=100")]); operations.sessions = Array.isArray(sessions.sessions) ? sessions.sessions : []; operations.invites = Array.isArray(invites.invites) ? invites.invites : []; operations.diagnostics = { node: String(diagnostics.gateway?.node || ""), platform: String(diagnostics.gateway?.platform || ""), arch: String(diagnostics.gateway?.arch || ""), schemaVersion: Number(diagnostics.database?.schemaVersion || 0), createdSessions: Number(diagnostics.sessions?.created || 0) }; operations.logs = { available: Boolean(logs.available), entries: Array.isArray(logs.entries) ? logs.entries : [] }; } catch (error) { errorMessage.value = errorText((error as ApiError).code); } finally { operationsLoading.value = false; } }
|
||||
async function terminateSession(session: AdminSession) { if (!window.confirm(`${tr('endSession')}「${session.nickname}」?`)) return; terminatingSession.value = session.id; errorMessage.value = ""; try { await sendJson(`/api/admin/sessions/${encodeURIComponent(session.id)}/terminate`, "POST", {}); await Promise.all([loadOperations(), loadOverview()]); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } finally { terminatingSession.value = ""; } }
|
||||
async function terminateSession(session: AdminSession) { if (!window.confirm(tr('confirmTerminate', { nickname: session.nickname }))) return; terminatingSession.value = session.id; errorMessage.value = ""; try { await sendJson(`/api/admin/sessions/${encodeURIComponent(session.id)}/terminate`, "POST", {}); await Promise.all([loadOperations(), loadOverview()]); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } finally { terminatingSession.value = ""; } }
|
||||
async function createInvite() { submitting.value = true; errorMessage.value = ""; createdInvite.value = null; try { const result = await sendJson("/api/admin/invites", "POST", { channel: inviteForm.channel, expiresInHours: inviteForm.expiresInHours, maxUses: inviteForm.maxUses }); if (typeof result.token !== "string") throw new Error("INVITE_CREATE_FAILED"); createdInvite.value = { token: result.token, link: `${location.origin}/?invite=${encodeURIComponent(result.token)}` }; inviteForm.channel = ""; await loadOperations(); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } finally { submitting.value = false; } }
|
||||
async function revokeInvite(invite: ManagedInvite) { if (!window.confirm(`${tr('revoke')}「${invite.channel || tr('defaultChannel')}」?`)) return; try { await sendJson(`/api/admin/invites/${encodeURIComponent(invite.id)}/revoke`, "POST", {}); await loadOperations(); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } }
|
||||
async function revokeInvite(invite: ManagedInvite) { if (!window.confirm(tr('confirmRevoke'))) return; try { await sendJson(`/api/admin/invites/${encodeURIComponent(invite.id)}/revoke`, "POST", {}); await loadOperations(); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } }
|
||||
async function copyInviteLink() { if (!createdInvite.value) return; try { await navigator.clipboard.writeText(createdInvite.value.link); showOperationNotice(tr('copiedLink')); } catch { errorMessage.value = tr('operationFailed'); } }
|
||||
function showOperationNotice(message: string) { errorMessage.value = message; window.setTimeout(() => { if (errorMessage.value === message) errorMessage.value = ""; }, 2200); }
|
||||
async function downloadBackup() { try { const response = await fetch("/api/admin/backup", { headers: { accept: "application/octet-stream" } }); if (!response.ok) throw new Error("BACKUP_FAILED"); const blob = await response.blob(); const url = URL.createObjectURL(blob); const anchor = document.createElement("a"); anchor.href = url; anchor.download = `webspeak-backup-${new Date().toISOString().slice(0, 10)}.db`; anchor.click(); URL.revokeObjectURL(url); await loadOperations(); } catch (error) { errorMessage.value = errorText((error as ApiError).code); } }
|
||||
|
||||
Reference in new issue
Block a user