Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42a0755ad0 | ||
|
|
26c638c2a2 | ||
|
|
c19dad513a | ||
|
|
21ee7c322d | ||
|
|
4910458408 | ||
|
|
292b4073b3 | ||
|
|
48c2fb3948 | ||
|
|
224a641372 | ||
|
|
19274cf0ee | ||
|
|
45bec91daa | ||
|
|
7fd1ea96fe | ||
|
|
c994722016 | ||
|
|
7a6e054fe9 | ||
|
|
d919dbd82a | ||
|
|
f74e211d0f | ||
|
|
458f95c2dc | ||
|
|
319a16f384 | ||
|
|
c6eeb49f44 | ||
|
|
05220b7a6e | ||
|
|
53324ef02b | ||
|
|
2f5cdcba90 | ||
|
|
9c8647df50 | ||
|
|
cec2a81549 | ||
|
|
ff508a8eb9 | ||
|
|
8a46691dbb | ||
|
|
64b24d0452 | ||
|
|
833357e278 | ||
|
|
acdc7a2330 | ||
|
|
42190909e3 | ||
|
|
a4e54d6341 | ||
|
|
13499541e0 | ||
|
|
df2ff79e15 | ||
|
|
d9749ac12f | ||
|
|
8b5db8af1f | ||
|
|
7fe8719812 | ||
|
|
0a77bdcaca | ||
|
|
e800d75b7b | ||
|
|
3476d4716a | ||
|
|
3459c8410c | ||
|
|
10739a7c7e | ||
|
|
fb39aabbe2 | ||
|
|
6c57868903 | ||
|
|
398a4d6c7f | ||
|
|
766a9b9b5a | ||
|
|
96d2ebae01 | ||
|
|
b13bdf1eb2 | ||
|
|
17fb27b89a | ||
|
|
e8164abafe | ||
|
|
a1051b989e | ||
|
|
a84a12ced4 | ||
|
|
938bb0646d | ||
|
|
2f32d47036 | ||
|
|
25148dd343 | ||
|
|
cf692174da | ||
|
|
a43e6750ef | ||
|
|
729e413196 | ||
|
|
93c9c2532a | ||
|
|
74ee82a927 | ||
|
|
b9f3272210 | ||
|
|
0ad7386fcd | ||
|
|
4adc712562 | ||
|
|
f5c0d66c10 | ||
|
|
13f4ddac4d | ||
|
|
16df12e4b2 | ||
|
|
8cde1eae5a | ||
|
|
1391e02dd5 | ||
|
|
f3325458f4 | ||
|
|
72297c79b4 | ||
|
|
bdd8e39a35 | ||
|
|
1e4fa08220 | ||
|
|
9f11d11b55 | ||
|
|
fe578bcb60 | ||
|
|
650c1e0a6a | ||
|
|
5596735d4a | ||
|
|
2ef21a7da5 | ||
|
|
c5146a5734 | ||
|
|
b01127c461 | ||
|
|
2e67eaaa54 | ||
|
|
cb504c95bc | ||
|
|
7c3e32d671 | ||
|
|
2a80ade08b | ||
|
|
2fcea5622b | ||
|
|
62a358796f | ||
|
|
3f68050c81 | ||
|
|
01ad967e30 | ||
|
|
a73a6b1a1e | ||
|
|
0453bc6d4a | ||
|
|
c29109e898 | ||
|
|
794b3f0ae0 | ||
|
|
9cc6e7b765 | ||
|
|
fbcbe994f0 | ||
|
|
1951884d12 | ||
|
|
463f803881 | ||
|
|
61332ed846 | ||
|
|
f3565f9859 | ||
|
|
a3bdee9063 | ||
|
|
2d92ca82f4 | ||
|
|
10379829d8 | ||
|
|
5da11b41f9 | ||
|
|
deb5ca4e43 | ||
|
|
3ff6507943 | ||
|
|
e02ce7c546 | ||
|
|
8e580e7e18 | ||
|
|
70cc6c3bbf | ||
|
|
ed6bf3a6ec | ||
|
|
17a76fc1fd | ||
|
|
ff207df20d | ||
|
|
5ca90c0914 | ||
|
|
19e693c270 | ||
|
|
2b6903f00a | ||
|
|
83902e0fb5 | ||
|
|
bdd0c3473c | ||
|
|
afa1e89136 | ||
|
|
5d27b9e4a8 | ||
|
|
7ea19e14eb | ||
|
|
efa8f76787 | ||
|
|
8105a07171 | ||
|
|
42cf4fbb8a | ||
|
|
a3bf476db6 | ||
|
|
387462d89a | ||
|
|
498a728d04 | ||
|
|
9c0fa35d38 | ||
|
|
afc58799d9 | ||
|
|
212bd9db2c | ||
|
|
5824754912 | ||
|
|
a1f92cedb2 | ||
|
|
8aefed83d1 | ||
|
|
19c85ce1f5 | ||
|
|
7fb5e1d6ea | ||
|
|
b9c017f9aa | ||
|
|
d9b83f12cc | ||
|
|
36ece5e582 | ||
|
|
f1f50d393a | ||
|
|
f6ef471960 | ||
|
|
20bde72c8b | ||
|
|
1c328995aa | ||
|
|
7b31c9106a | ||
|
|
7f5d3e1b3c | ||
|
|
ad0aa5c120 | ||
|
|
54805f8928 | ||
|
|
f2e5695bb6 | ||
|
|
3fd8e76a98 | ||
|
|
da0472383d | ||
|
|
fd4b0c6da2 | ||
|
|
100a8f49ee | ||
|
|
16f28ca348 | ||
|
|
0c4cc344ef | ||
|
|
96c29394f3 | ||
|
|
8f097ec597 | ||
|
|
b0b4a02a21 | ||
|
|
e20219b010 | ||
|
|
1499d60bc0 | ||
|
|
11a07eae0f | ||
|
|
35cb6ad6df | ||
|
|
1aa29158ef | ||
|
|
7650bd650b | ||
|
|
7993b38eee | ||
|
|
26b74c5be4 | ||
|
|
dd0d779e49 | ||
|
|
54c77bcb27 | ||
|
|
c3810a177a | ||
|
|
ab36825a56 | ||
|
|
067f0c4403 | ||
|
|
c243f272fe | ||
|
|
81c35356b4 | ||
|
|
17e4d78e52 | ||
|
|
d137b41b5c | ||
|
|
7047d71678 | ||
|
|
849eb1a6d9 | ||
|
|
d505815f28 | ||
|
|
eabc78f36a | ||
|
|
02441410a0 | ||
|
|
58559cf839 | ||
|
|
b6e4d349a2 | ||
|
|
ae1cd707be | ||
|
|
efa0b85a0e | ||
|
|
75893339c5 | ||
|
|
60d3cfd569 | ||
|
|
35dde81cc2 | ||
|
|
ebca754ca5 | ||
|
|
69f8d66ca9 | ||
|
|
7789758024 | ||
|
|
c211deeb98 | ||
|
|
aad7833509 | ||
|
|
39413cf840 | ||
|
|
50d9d58ad0 | ||
|
|
0a552f7ee8 | ||
|
|
568b8fd8be | ||
|
|
d919df1273 | ||
|
|
921e83dfb3 | ||
|
|
77fef3bed9 | ||
|
|
2c49ee2599 | ||
|
|
81a860c3df | ||
|
|
d327c6f179 | ||
|
|
7baeff00ba | ||
|
|
777c779d79 | ||
|
|
051cb402e5 | ||
|
|
1791d5946d | ||
|
|
39eba1b121 | ||
|
|
a195681e78 | ||
|
|
172347aaa7 | ||
|
|
8e28bca634 | ||
|
|
4ef7ec5ee3 | ||
|
|
f18fa63001 | ||
|
|
6ed8abfb15 | ||
|
|
8b6c998c43 | ||
|
|
d2caaa8f3c | ||
|
|
83b2430d18 | ||
|
|
a416e36bd1 | ||
|
|
a2f91e606f | ||
|
|
9dfded0fb7 | ||
|
|
15e22d3099 | ||
|
|
db08fbda6b | ||
|
|
c16d1d4cfb | ||
|
|
5855d0ba67 | ||
|
|
f11fe26bfe | ||
|
|
1a46ab83a3 | ||
|
|
878e94a93a | ||
|
|
2047e30984 | ||
|
|
3dfd25dab7 | ||
|
|
c8417edd7d | ||
|
|
49481145ef | ||
|
|
3b5c0dfc7d | ||
|
|
525f512f4a | ||
|
|
0785f82386 | ||
|
|
797fc135a9 | ||
|
|
f0712fa3fc | ||
|
|
e2f0a43762 | ||
|
|
8960189bc7 | ||
|
|
f4cbd61cff | ||
|
|
541a216c4d | ||
|
|
aeaeb15965 | ||
|
|
9e2b9bf564 | ||
|
|
0a4fff6f6f | ||
|
|
e0d5916a86 | ||
|
|
e8dc71329b | ||
|
|
30682cd659 | ||
|
|
e09a19b7b4 | ||
|
|
2b7e908d31 | ||
|
|
0ea85752fd | ||
|
|
97b7127ca3 | ||
|
|
db38feba52 | ||
|
|
1bab4df64e | ||
|
|
193130c50f | ||
|
|
c7794a12e7 | ||
|
|
408d8bcda4 | ||
|
|
5a3eebecbd | ||
|
|
713716dacc | ||
|
|
3a7a162f97 | ||
|
|
2f8614d53a | ||
|
|
bdac15afac | ||
|
|
7f49e2f2d7 | ||
|
|
24f1b9a4b8 | ||
|
|
79b91fca44 | ||
|
|
6a821b760e | ||
|
|
6539479d10 | ||
|
|
8ed3e788be | ||
|
|
de8f6a11c9 | ||
|
|
21d53a30c9 | ||
|
|
22656b2e7d | ||
|
|
3a18bcebbc | ||
|
|
7b35c63a74 | ||
|
|
6b9038da6c | ||
|
|
1dd04bf7ca | ||
|
|
15af861389 | ||
|
|
7ea63c525e | ||
|
|
3d0b8a5c97 | ||
|
|
fb39d82c01 | ||
|
|
ae530963bf | ||
|
|
f8554fc991 | ||
|
|
a3dad55c76 | ||
|
|
0b29742bce | ||
|
|
c2c38fa011 | ||
|
|
578217ba41 | ||
|
|
d75bdccfd9 | ||
|
|
412f560677 | ||
|
|
fdccf86458 | ||
|
|
d43a33aa15 | ||
|
|
056b57bcd1 | ||
|
|
688eb3174e | ||
|
|
c38f67bc3b | ||
|
|
67c7a27af6 | ||
|
|
6d1d2a1f92 | ||
|
|
faff7a2237 | ||
|
|
dc63f4b45b | ||
|
|
380fb67090 | ||
|
|
b71632cc29 | ||
|
|
38f7c94a65 | ||
|
|
d91a145657 | ||
|
|
a2e33ff176 | ||
|
|
010b8ef072 | ||
|
|
883703dd0c | ||
|
|
bcf212738b | ||
|
|
fae21ec086 | ||
|
|
22dcf93925 | ||
|
|
4df59b80d0 | ||
|
|
c49b4ec715 | ||
|
|
1c80791109 | ||
|
|
85f87ecd0b | ||
|
|
3d6752a5e4 | ||
|
|
a0921c35b2 | ||
|
|
ace9e84889 | ||
|
|
4ead174c04 | ||
|
|
f628d19ebf | ||
|
|
75de8f1d2b | ||
|
|
1ba8cd5ee1 | ||
|
|
f639825775 | ||
|
|
0b40a69d74 | ||
|
|
6defbff591 | ||
|
|
b5d167e1e7 | ||
|
|
7f97d54206 | ||
|
|
ef3e65ea0b | ||
|
|
d13b3207a9 | ||
|
|
7e08ee54a5 | ||
|
|
6d8e289b81 | ||
|
|
defbb766e4 | ||
|
|
69043748a1 | ||
|
|
8046985574 | ||
|
|
5ce73d2c84 | ||
|
|
2d1d202981 | ||
|
|
73313f9e2d | ||
|
|
097c72bc5d | ||
|
|
71f219b7ca | ||
|
|
bacc9fe07e | ||
|
|
a9c360fb9c | ||
|
|
04926c8491 | ||
|
|
fa1d1ad01b | ||
|
|
c0fc18c344 | ||
|
|
69d69f0a5a | ||
|
|
6d7976e5d8 | ||
|
|
aef1f68875 | ||
|
|
06e5cc6d8b | ||
|
|
7782e9b327 | ||
|
|
b82c4fe0af | ||
|
|
45584810a2 | ||
|
|
bfefd053a0 | ||
|
|
324213de14 | ||
|
|
a041ba90bb | ||
|
|
0dc623eb69 | ||
|
|
3e6876dbe7 | ||
|
|
a60abffd3b | ||
|
|
2b43952c01 | ||
|
|
12f440ab8b | ||
|
|
7221af78bf | ||
|
|
a88b0616f5 | ||
|
|
ea4d5b2a70 | ||
|
|
a439100ad6 | ||
|
|
620d24f796 | ||
|
|
fc3bbd0c59 | ||
|
|
3b5ce9b446 | ||
|
|
37de6067d0 | ||
|
|
45410fcc7d | ||
|
|
166cb543a1 | ||
|
|
a295ff4b27 | ||
|
|
dcc52c4530 | ||
|
|
dc3ad6a598 | ||
|
|
ef59e51e32 | ||
|
|
9bbc22de25 | ||
|
|
335d93a8b8 | ||
|
|
52ff0560d1 | ||
|
|
a5e5dd6592 | ||
|
|
62e41dbc51 | ||
|
|
d8b2fd9e1b | ||
|
|
8ca3249832 | ||
|
|
92574fddb1 | ||
|
|
596114e6a3 | ||
|
|
2868f7a478 | ||
|
|
63ef6b673d | ||
|
|
5a56e1706f | ||
|
|
986814441d | ||
|
|
0ab6fb6f3f | ||
|
|
a966be4db6 | ||
|
|
556084233d | ||
|
|
c38239ec35 | ||
|
|
21041346e3 | ||
|
|
7320aa3bb5 | ||
|
|
d9b8ea625a | ||
|
|
2323e22fef | ||
|
|
b5f8f01301 | ||
|
|
e964ff460e | ||
|
|
21d8d9c3bc | ||
|
|
169cf88306 | ||
|
|
059435f4cb | ||
|
|
4d4d4cdeb1 | ||
|
|
d42e7a033c | ||
|
|
0986c65551 | ||
|
|
694f864d36 | ||
|
|
512854ab9f | ||
|
|
b298496911 | ||
|
|
b6367e2645 | ||
|
|
b0fa4bf5d0 | ||
|
|
cb3dbe4ca4 |
No files matched your search
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: webspeak-skin-development
|
||||
description: Develop, review, package, or validate portable WebSpeak .wskin skins. Keep skin UI and implementation inside the package and use only released runtime APIs.
|
||||
metadata:
|
||||
short-description: Develop portable WebSpeak skins
|
||||
---
|
||||
|
||||
# WebSpeak Skin Development
|
||||
|
||||
Develop the skin as a portable `.wskin` package. A skin task should not require a skin-specific edit to WebSpeak's client, server, shared protocol, or host-widget implementation. The package owns its page/component markup, styling, copy, layout, assets, and supported plugin logic. The host owns TeamSpeak transport, credentials, trusted actions, and the versioned public data/API contract.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Locate the `webspeak-webclient` repository root, then read the single current contract and workflow in `docs/SKIN_DEVELOPMENT.md`. It covers package schemas, runtime data, permissions, actions, security boundaries, and validation. If a request needs an undocumented capability, identify the missing public contract before editing and treat that work as a separate platform change. Inspect the closest example under `docs/examples/`; do not copy unrelated product-specific content.
|
||||
2. Choose the least complex supported package format that can express the request: CSS/assets for appearance, `content.json` for localized copy, `layout.json` for author defaults, `components.json` for declarative structure and supported interactions, and the documented v4 Wasm plugin path only when local logic is required. JavaScript files in a package are not executed by the current runtime.
|
||||
3. Keep all skin-authored implementation in the package. Use stable public skin parts, component schema, published context fields, existing host widgets, and permission-gated actions. Do not add a widget, data field, action, CSS hook, or branch to core code for one skin. If a reusable platform capability is missing, identify the exact contract gap and treat it as separate platform work: define a generic, versioned API and compatibility behavior first; only then use that released API from the package.
|
||||
4. Set a unique skin ID, increment its package version for changed output, and set `minAppVersion` to the lowest compatible WebSpeak runtime. Keep component schema and plugin `apiVersion` aligned with the APIs actually used. Package every referenced image, font, stylesheet, component, and plugin asset. Use only safe package-relative paths; do not depend on local machine files, remote assets, private endpoints, or instance-specific frontend code.
|
||||
5. Build the `.wskin` from its source directory while including only files declared by the manifest. Validate the finished archive with the repository importer and keep any distributable built-in archive synchronized with its example source. An example README or other undeclared file belongs beside the package, not inside it.
|
||||
6. Verify the package at the scope of the change: run the skin package and component-schema tests; run the relevant type/build checks; import the exact archive in a compatible WebSpeak runtime. Check desktop and narrow layouts, all supported interface languages, long text, keyboard focus, reduced motion, contrast, and every interaction the skin replaces. For a portability claim, install the same archive (compare its SHA-256) in two instances with the same compatible runtime/API version; do not treat a successful build alone as proof.
|
||||
|
||||
## Compatibility and truthfulness
|
||||
|
||||
- `minAppVersion` is a lower compatibility bound, not a guarantee that an older or unrelated runtime implements every API. Read the current schema and runtime documentation before using a capability.
|
||||
- Dynamic values such as public connection state or administrator-configured copy are runtime inputs. The package contains how those values are rendered; it must not bundle secrets or assume a particular server's private configuration.
|
||||
- An existing host widget is a stable capability the package may declare. Its presence does not authorize changing that widget's implementation for a skin-specific design; use package CSS/components around it where supported.
|
||||
- Do not describe an unimplemented API as portable, mark a feature complete from schema validation alone, or claim that different runtime versions render identically. Report the tested package hash, compatible runtime/API versions, and any platform gap.
|
||||
|
||||
## References
|
||||
|
||||
- `docs/SKIN_DEVELOPMENT.md` — the single current reference for skin formats, runtime APIs, permissions, data, actions, CSS hooks, security, and QA.
|
||||
- `docs/examples/ILLUSIA-VOICE.md` and `docs/examples/OPEN-VOICE-SURFACE.md` — full skin and surface examples.
|
||||
@@ -3,13 +3,20 @@
|
||||
.claude
|
||||
node_modules
|
||||
web/node_modules
|
||||
mobile/node_modules
|
||||
web/android
|
||||
.local-opus-hook.cjs
|
||||
界面参考
|
||||
dist
|
||||
web/dist
|
||||
data
|
||||
certs
|
||||
release-artifacts
|
||||
scripts/acceleration-poc
|
||||
*.tar.gz
|
||||
*.tar.xz
|
||||
claude.pem
|
||||
config.json
|
||||
.env
|
||||
.env.*
|
||||
*.log
|
||||
@@ -9,20 +9,31 @@ on:
|
||||
version:
|
||||
description: Release version without the v prefix
|
||||
required: true
|
||||
default: 0.1.3
|
||||
default: 0.2.7
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
windows-x64:
|
||||
runs-on: windows-latest
|
||||
verify:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
|
||||
windows:
|
||||
needs: verify
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x64
|
||||
runner: windows-latest
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.22.2
|
||||
architecture: x64
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
@@ -34,7 +45,11 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
$releaseVersion = $env:RELEASE_REF -replace '^v', ''
|
||||
npm ci --no-audit --no-fund
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
npm run prepare:sdk
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
@@ -43,20 +58,21 @@ jobs:
|
||||
npm version --no-git-tag-version $releaseVersion
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
}
|
||||
npm --prefix web run build
|
||||
npm run web:build
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
npm run build
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
npm prune --omit=dev --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
- name: Package and smoke-test Windows x64
|
||||
- name: Package and smoke-test Windows ${{ matrix.arch }}
|
||||
shell: pwsh
|
||||
env:
|
||||
RELEASE_REF: ${{ inputs.version || github.ref_name }}
|
||||
PACKAGE_ARCH: ${{ matrix.arch }}
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
$releaseVersion = $env:RELEASE_REF -replace '^v', ''
|
||||
$packageName = "webspeak-webclient-v$releaseVersion-windows-x64"
|
||||
$packageName = "webspeak-webclient-v$releaseVersion-windows-$env:PACKAGE_ARCH"
|
||||
$packageRoot = Join-Path $env:RUNNER_TEMP $packageName
|
||||
$runtimeRoot = Split-Path -Parent (Get-Command node).Source
|
||||
New-Item -ItemType Directory -Path $packageRoot | Out-Null
|
||||
@@ -84,7 +100,7 @@ jobs:
|
||||
Copy-Item -Recurse -LiteralPath $packageRoot -Destination $smokeRoot
|
||||
@{
|
||||
port = 3040
|
||||
tsHost = "203.0.113.10"
|
||||
tsHost = "127.0.0.1"
|
||||
tsPort = 9987
|
||||
tsServerPassword = ""
|
||||
tsServerProtocol = "ts6"
|
||||
@@ -108,18 +124,28 @@ jobs:
|
||||
Compress-Archive -LiteralPath $packageRoot -DestinationPath (Join-Path $env:GITHUB_WORKSPACE ($packageName + ".zip")) -CompressionLevel Optimal
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-x64
|
||||
path: webspeak-webclient-v*-windows-x64.zip
|
||||
name: windows-${{ matrix.arch }}
|
||||
path: webspeak-webclient-v*-windows-${{ matrix.arch }}.zip
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
|
||||
linux-x64:
|
||||
runs-on: ubuntu-latest
|
||||
linux:
|
||||
needs: verify
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x64
|
||||
runner: ubuntu-latest
|
||||
- arch: arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.22.2
|
||||
architecture: ${{ matrix.arch == 'arm64' && 'arm64' || 'x64' }}
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
@@ -130,22 +156,25 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
release_version="${RELEASE_REF#v}"
|
||||
npm ci --no-audit --no-fund
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
current_version="$(node -p "require('./package.json').version")"
|
||||
if [ "$current_version" != "$release_version" ]; then
|
||||
npm version --no-git-tag-version "$release_version"
|
||||
fi
|
||||
npm --prefix web run build
|
||||
npm run web:build
|
||||
npm run build
|
||||
npm prune --omit=dev --no-audit --no-fund
|
||||
- name: Package and smoke-test Linux x64
|
||||
- name: Package and smoke-test Linux ${{ matrix.arch }}
|
||||
env:
|
||||
RELEASE_REF: ${{ inputs.version || github.ref_name }}
|
||||
PACKAGE_ARCH: ${{ matrix.arch }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
release_version="${RELEASE_REF#v}"
|
||||
package_name="webspeak-webclient-v${release_version}-linux-x64"
|
||||
package_name="webspeak-webclient-v${release_version}-linux-${PACKAGE_ARCH}"
|
||||
package_root="$RUNNER_TEMP/$package_name"
|
||||
runtime_root="$(dirname "$(dirname "$(command -v node)")")"
|
||||
mkdir -p "$package_root/web" "$package_root/runtime"
|
||||
@@ -169,7 +198,7 @@ jobs:
|
||||
cat > "$smoke_root/config.json" <<'CONFIG'
|
||||
{
|
||||
"port": 3040,
|
||||
"tsHost": "203.0.113.10",
|
||||
"tsHost": "127.0.0.1",
|
||||
"tsPort": 9987,
|
||||
"tsServerPassword": "",
|
||||
"tsServerProtocol": "ts6",
|
||||
@@ -194,28 +223,95 @@ jobs:
|
||||
tar -czf "$GITHUB_WORKSPACE/${package_name}.tar.gz" -C "$RUNNER_TEMP" "$package_name"
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-x64
|
||||
path: webspeak-webclient-v*-linux-x64.tar.gz
|
||||
name: linux-${{ matrix.arch }}
|
||||
path: webspeak-webclient-v*-linux-${{ matrix.arch }}.tar.gz
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
|
||||
android:
|
||||
needs: verify
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.22.2
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
web/package-lock.json
|
||||
mobile/package-lock.json
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
- uses: android-actions/setup-android@v4
|
||||
with:
|
||||
packages: platform-tools
|
||||
- name: Build Android APKs
|
||||
env:
|
||||
RELEASE_REF: ${{ inputs.version || github.ref_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
release_version="${RELEASE_REF#v}"
|
||||
version_code="$(node -e 'const [major, minor, patch] = process.argv[1].split(".").map(Number); process.stdout.write(String(major * 10000 + minor * 100 + patch))' "$release_version")"
|
||||
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
current_version="$(node -p "require('./package.json').version")"
|
||||
if [ "$current_version" != "$release_version" ]; then
|
||||
npm version --no-git-tag-version "$release_version"
|
||||
fi
|
||||
npm run prepare:sdk
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
npm --prefix mobile ci --no-audit --no-fund
|
||||
npm run android:sync
|
||||
cd web/android
|
||||
chmod +x gradlew
|
||||
./gradlew --no-daemon assembleDebug -PappVersion="$release_version" -PappVersionCode="$version_code"
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
mkdir -p release-apks
|
||||
for apk in web/android/app/build/outputs/apk/debug/app-*-debug.apk; do
|
||||
abi="${apk##*/app-}"
|
||||
abi="${abi%-debug.apk}"
|
||||
cp "$apk" "release-apks/webspeak-android-v${release_version}-${abi}-debug.apk"
|
||||
done
|
||||
test "$(find release-apks -maxdepth 1 -name '*.apk' | wc -l)" -eq 3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-apks
|
||||
path: release-apks/*.apk
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
|
||||
publish-release:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [windows-x64, linux-x64]
|
||||
needs: [windows, linux, android]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download deployment packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: '*-x64'
|
||||
pattern: '*'
|
||||
path: release-assets
|
||||
merge-multiple: true
|
||||
- name: Create checksums
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd release-assets
|
||||
sha256sum * > SHA256SUMS.txt
|
||||
- name: Publish GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
name: WebSpeak ${{ github.ref_name }}
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
Release notes are maintained in each language's project documentation:
|
||||
- [简体中文](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.zh-CN.md#latest-release-notes)
|
||||
- [English](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.en.md#latest-release-notes)
|
||||
- [Deutsch](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.de.md#latest-release-notes)
|
||||
- [Русский](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.ru.md#latest-release-notes)
|
||||
- [日本語](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.ja.md#latest-release-notes)
|
||||
files: release-assets/*
|
||||
@@ -2,8 +2,10 @@ name: Continuous integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [dev, master]
|
||||
pull_request:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -22,13 +24,12 @@ jobs:
|
||||
web/package-lock.json
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm ci --no-audit --no-fund
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
- name: Test and build
|
||||
run: |
|
||||
npm test
|
||||
npm run build
|
||||
npm --prefix web run build
|
||||
- name: Test and build application
|
||||
run: npm run verify
|
||||
|
||||
docker-smoke:
|
||||
needs: verify
|
||||
|
||||
@@ -14,10 +14,15 @@ env:
|
||||
IMAGE_NAME: ghcr.io/echosixhiya/webspeak
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
|
||||
publish:
|
||||
needs: verify
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- name: Log in to GHCR
|
||||
uses: docker/login-action@v3
|
||||
@@ -39,6 +44,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
node_modules/
|
||||
dist/
|
||||
web/dist/
|
||||
web/skin-wasm-interpreter/target/
|
||||
mobile/node_modules/
|
||||
web/android/.gradle/
|
||||
web/android/build/
|
||||
web/android/app/build/
|
||||
web/android/local.properties
|
||||
web/android/app/src/main/assets/public/
|
||||
web/android/app/src/main/assets/capacitor.config.json
|
||||
data/
|
||||
config.json
|
||||
*.log
|
||||
.env
|
||||
webspeak-update.tar.gz
|
||||
# Local deployment notes and downloaded artifacts.
|
||||
/release-artifacts/
|
||||
/webspeak-deploy*.tar.gz
|
||||
/webspeak-update*.tar.gz
|
||||
/teamspeak6-server-linux-amd64.tar.xz
|
||||
/.local-opus-hook.cjs
|
||||
/界面参考/stitch_teamspeak_web_interface.zip
|
||||
claude.pem
|
||||
|
||||
# Private credentials and deployment notes stay local.
|
||||
.env.*
|
||||
!.env.example
|
||||
*.pem
|
||||
*.key
|
||||
/.claude/
|
||||
/LOCAL-RELEASE-RUNBOOK.md
|
||||
/DEPLOYMENT-*.md
|
||||
@@ -1,106 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to WebSpeak are documented here. Versions follow SemVer.
|
||||
|
||||
## [0.1.4] — 2026-09-03
|
||||
|
||||
### 中文
|
||||
|
||||
- 修复 WebRTC 语音收发与发言状态同步。
|
||||
- 修复频道文字消息在 WebSpeak 客户端之间无法互收。
|
||||
- 优化管理员页面、运行日志换行和移动端顶部布局。
|
||||
- 首页新增 Bilibili 入口,管理员登录页新增返回首页。
|
||||
|
||||
### English
|
||||
|
||||
- Fixed WebRTC voice transport and speaking-state synchronization.
|
||||
- Fixed channel text messages between WebSpeak clients.
|
||||
- Refined admin pages, log wrapping, and narrow-screen header layout.
|
||||
- Added the Bilibili profile link and the admin-login home link.
|
||||
|
||||
## [0.1.3] — 2026-09-03
|
||||
|
||||
### Added
|
||||
|
||||
- Optional WebRTC audio transport for deployments that need lower and more stable realtime voice latency.
|
||||
- A self-contained WebRTC media service controlled by one administrator switch; the gateway derives the media host from the current WebSpeak address and owns a fixed UDP range.
|
||||
- Migrated the TeamSpeak integration to the maintained `EchoSixHIYA/teamspeak-js` fork, including live directory snapshots and member/channel synchronization.
|
||||
|
||||
### Changed
|
||||
|
||||
- WebRTC audio uses negotiated Opus parameters and a bounded newest-frame mixer instead of allowing stale audio to accumulate.
|
||||
- The browser keeps the WebSocket path available for signaling, control, and compatibility fallback; Docker Compose publishes the built-in `40000–40099/UDP` media range alongside the web port.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Prevented duplicate playback when WebRTC and the WebSocket audio path overlap during negotiation or fallback.
|
||||
- Made WebRTC teardown and fallback explicit so a failed negotiation does not leave a server-side media session behind.
|
||||
- Corrected native Opus decoder usage and cleaned up negotiated payload handling for TeamSpeak-to-browser audio.
|
||||
|
||||
### Verification
|
||||
|
||||
- After allowing inbound `40000–40099/UDP` on the public WebSpeak host, two browser sessions were tested against the same TeamSpeak target with WebRTC enabled: audio frames flowed in both directions, packet drops remained at `0`, ingress frame gaps peaked at about `27 ms`, and egress gaps peaked at about `81–83 ms`.
|
||||
- The measured WebRTC path stayed below the previous WebSocket jitter peaks of about `268–376 ms` in the same browser test setup; these figures describe the observed test path, not a universal latency guarantee.
|
||||
|
||||
## [0.1.2] — 2026-09-02
|
||||
|
||||
### Added
|
||||
|
||||
- Current-version badge and a direct changelog link on the welcome page, next to the prominent GitHub repository button.
|
||||
- Mobile member actions through a three-dot menu, while desktop member actions remain available through the context menu.
|
||||
|
||||
### Changed
|
||||
|
||||
- Mobile and narrow-screen header controls now collapse longer labels into icons to preserve usable spacing.
|
||||
- The welcome page and connected workspace now present the GitHub, version, changelog, admin, theme, language, exit, and microphone controls as a consistent responsive control group.
|
||||
- The version shown on the welcome page is read from the gateway's public configuration so it stays aligned with the running backend.
|
||||
- Consolidated the post-0.1.1 mobile voice controls, microphone mute replacement for focus-dependent PTT, automatic protocol detection, simplified Docker Compose startup, and live-demo documentation.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Replaced the visually off-center settings glyph and normalized icon alignment for settings-related controls across the client.
|
||||
- Fixed narrow-screen exit and microphone controls so their text-collapse rules apply correctly.
|
||||
- Bounded browser and gateway voice buffering, reset stale browser playback queues, and exposed low-overhead in-memory audio counters for diagnosing jitter without per-frame log writes.
|
||||
- Moved microphone frame assembly to an `AudioWorklet` with a compatibility fallback to `ScriptProcessorNode`; both paths emit fixed 960-sample frames.
|
||||
|
||||
## [0.1.1] — 2026-09-02
|
||||
|
||||
### 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.
|
||||
- Bilingual README documentation with parallel Chinese and English feature, deployment, security, and operations sections.
|
||||
|
||||
### 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.
|
||||
- The README architecture section now uses GitHub-native Markdown instead of a Mermaid rich-display block.
|
||||
- The README badge set now uses stable static Shields badges without a repository-metadata 404 dependency.
|
||||
- Version tags publish Windows/Linux deployment packages to GitHub Releases and publish the matching Docker image.
|
||||
- Removed the focus-dependent normal browser Space-key PTT mode and replaced it with a one-click microphone mute/unmute control on desktop and mobile.
|
||||
- Persisted the microphone mute state in browser preferences and suppresses upstream audio before it is sent to TeamSpeak while muted.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Late WebSpeak browser sessions now reconcile and merge the complete TeamSpeak directory, so members who joined earlier remain visible.
|
||||
- Private-message delivery no longer disconnects the browser session.
|
||||
- Member actions are presented through the right-click context menu with hover feedback.
|
||||
- Docker release builds copy the root `postinstall` patch script before running `npm ci`.
|
||||
- Release builds skip `npm version` when the project version already matches the requested version, preventing false `Version not changed` failures.
|
||||
|
||||
### Verification
|
||||
|
||||
- `npm test` — 51 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.
|
||||
|
||||
## [0.1.0] — 2026-08-31
|
||||
|
||||
- First normalized release with the browser client, TeamSpeak 3 / 6 gateway, browser audio controls, access modes, administrator operations, and AGPL-3.0-only licensing.
|
||||
@@ -1,90 +1,210 @@
|
||||
# WebSpeak — TeamSpeak Browser Gateway
|
||||
# WebSpeak TeamSpeak Browser Gateway
|
||||
|
||||
Server-side bridge that lets users join TeamSpeak voice channels from a browser. No TS client install needed.
|
||||
WebSpeak connects browser users to TeamSpeak 3 and TeamSpeak 6 through a self-hosted Node.js gateway. Each connected browser session owns an independent TeamSpeak client. The repository also contains a standalone UDP acceleration relay and an Android preview with an embedded local gateway.
|
||||
|
||||
## Architecture
|
||||
## Application boundaries
|
||||
|
||||
```
|
||||
Browser (PCM capture) → WebSocket → Node.js server (PCM→Opus) → TeamSpeak server
|
||||
Browser (playback) ← WebSocket ← Node.js server (Opus relay) ← TeamSpeak server
|
||||
| Location | Responsibility |
|
||||
| --- | --- |
|
||||
| `src/index.ts` | Gateway startup, SQLite, master secret, admin service and shutdown; also supports relay mode |
|
||||
| `src/server/server.ts` | HTTP or HTTPS, public configuration, skins, join tickets, admin routes and static frontend |
|
||||
| `src/server/voice-bridge.ts` | `/ws/voice`, admission, connection/reconnection orchestration and voice transport assembly |
|
||||
| `src/server/voice-commands.ts`, `directory-view.ts`, `audio-stats.ts` | Command execution, public directory projection and diagnostic snapshots |
|
||||
| `src/server/member-avatars.ts` | Generation-bound optional avatar downloads, bounded sequential batches, cached images and timer cleanup |
|
||||
| `src/server/session-events.ts` | Session-owned SDK subscriptions, directory projection, self/channel state, chat mapping and avatar coordination |
|
||||
| `src/server/screen-share-coordinator.ts` | Server/channel-scoped sharing membership and browser/native signaling |
|
||||
| `src/shared/` | Browser-safe wire types and runtime parsers shared by both endpoints |
|
||||
| `src/shared/admin-inputs.ts`, `admin-responses.ts` | Shared admin request types and runtime-checked response projections |
|
||||
| `src/server/ts-client.ts` and `teamspeak-adapter.ts` | SDK integration, TS3/TS6 negotiation, identity, chat, voice and client events |
|
||||
| `src/server/session-manager.ts` and `directory-sync.ts` | Connection state, teardown, admission limits and directory reconciliation |
|
||||
| `src/server/webrtc-audio.ts` and `opus-codec.ts` | WebRTC audio mixing and platform-specific Opus codecs |
|
||||
| `src/server/session-audio.ts` | Per-session PCM encoding, exclusive WebRTC/WebSocket routing, whisper dispatch, bounded egress and audio counters |
|
||||
| `src/admin/`, `src/security/`, `src/persistence/` | Administration, access policies, credentials and persistent settings |
|
||||
| `src/relay.ts` and `src/server/acceleration-relay.ts` | Standalone relay and gateway-side relay transport |
|
||||
| `web/src/views/` and `web/src/composables/` | Vue pages, connection state, audio controls, chat and screen sharing |
|
||||
| `web/src/voice/screen-share.ts` | Per-session screen capture, peer negotiation, cleanup and diagnostics |
|
||||
| `web/src/voice/remote-playback.ts` | Per-speaker compatibility decoding, bounded scheduling, volume and resource cleanup |
|
||||
| `web/src/voice/microphone-test.ts` | Cancellable recording tests, recorder deadline and playback URL ownership |
|
||||
| `web/src/voice/microphone-capture.ts` | Prepared microphone processing graphs, per-context worklet loading, optional RNNoise and independent PCM activation/cleanup |
|
||||
| `web/src/voice/audio-sink.ts` | Serialized device routing per audio endpoint, with stale-operation guards |
|
||||
| `web/src/voice/accompaniment.ts` | Generation-bound display-audio capture, immediate pending-capture cancellation, ended listeners and committed activity |
|
||||
| `web/src/voice/webrtc-input.ts` | Stable WebRTC sender output, microphone gain and transactional accompaniment-source attachment |
|
||||
| `web/src/voice/microphone-meter.ts` | Optional per-peer level sampling, owned analysis nodes and timer, partial-failure cleanup and stale-tick rejection |
|
||||
| `web/src/voice/webrtc-transport.ts`, `webrtc-playback.ts` | Per-attempt peer negotiation, input/meter ownership, compatibility fallback and independently owned playback elements and retries |
|
||||
| `web/src/voice/connection.ts`, `commands.ts` | Cancellable ticket acquisition, socket and connection generations, plus per-command acknowledgement deadlines and cleanup |
|
||||
| `web/src/voice/session-state.ts` | Reactive directory, chat history, events and notifications; complete versus omitted directory data, session resets and private-conversation identity scopes |
|
||||
| `web/src/composables/useWebClientChat.ts`, `useWebClientChannels.ts` | Destination-owned drafts and pending sends, identity-bound private history, and iterative channel-tree projection |
|
||||
| `web/src/composables/useWebClientIdentity.ts`, `web/src/components/web-client/IdentityImportDialog.vue` | Page-owned identity reads, parsing, restoration and exports; a presentation dialog with explicit input and action events |
|
||||
| `web/src/voice/audio-diagnostics.ts`, `web/src/composables/useWebClientPerformance.ts` | Session-owned diagnostic probes and compatibility counters, browser statistics, comparable sample scopes and cancellable UI polling |
|
||||
| `web/src/platform/` | Browser mounting and cancellable Android gateway readiness handshake |
|
||||
| `web/src/services/`, `web/src/i18n/`, `web/src/skins/` | Browser persistence, identity import, skin packages and translations |
|
||||
| `web/src/composables/usePublicSkin.ts`, `web/src/services/skin-operation.ts` | Shared public-page skin initialization and selection, page ownership, cancellation and bounded loading |
|
||||
| `web/src/services/admin-api.ts`, `admin-requests.ts` | Admin HTTP validation and cancellation, session-bound CSRF and per-feature request ownership, including skin uploads and backup downloads |
|
||||
| `web/src/composables/useAdminServerSettings.ts`, `useAdminOperations.ts`, `useAdminSkins.ts` | Admin form merging, probes, operational actions and skin state; the page owns authentication, routing and overview |
|
||||
| `web/src/components/admin/` | Server settings, operations and skin presentation; the parent page retains the feature controller instances across subroute changes |
|
||||
| `web/src/composables/useAdminI18n.ts`, `web/src/i18n/admin.ts` | Admin formatting and error/status mappings; all five languages explicitly implement the same translation keys |
|
||||
| `src/mobile/`, `mobile/`, `web/android/` | Android loopback gateway, asset packaging and Capacitor container |
|
||||
|
||||
## Connection and control protocol
|
||||
|
||||
1. The browser requests `/api/join-ticket`. The gateway validates the request against its access policy and issues a short-lived, single-use ticket.
|
||||
2. The browser presents the ticket to `/ws/voice`. The bridge admits a session, acquires any required identity lease and creates its TeamSpeak client.
|
||||
3. WebSocket text messages carry JSON commands, events, WebRTC negotiation and screen-sharing signaling. The server uses the WebSocket `isBinary` flag to distinguish audio from control messages.
|
||||
4. Register TeamSpeak event listeners before connecting: directory and membership events may arrive during the handshake.
|
||||
|
||||
Channel and member data come from SDK directory snapshots and client-protocol commands, followed by realtime notifications. WebQuery and its API key are not required. `DirectorySynchronizer` reconciles snapshots with membership events.
|
||||
|
||||
`SessionEventCoordinator` subscribes before SDK connection and closes before waiting for peer shutdown. Remove only its own listeners and guard captured callbacks as well as registered ones. Directory events are accepted during authentication, synchronization and the live connection, but not reconnect backoff. SDK adapter listeners must reject events from a replaced client before mutating state or forwarding them. A kick remains terminal if the disconnect notification already started recovery.
|
||||
|
||||
Avatar downloads belong to the connected directory generation. Reset them on SDK interruption and close them before awaiting session teardown. Old success or failure results cannot refill caches, publish images, start another download, or unlock newer work. `isAlive` is only the WebSocket heartbeat acknowledgement flag; it is not a lifecycle predicate. Keep avatar failure optional, the 50-member batch limit and 250 ms continuation delay.
|
||||
|
||||
The SDK avatar method captures its client and connection generation across metadata, transfer initialization and download. Recheck both after each await, including reconnects that reuse the same SDK object; never continue an old transfer through a replacement `this.client`. A retired SDK client's disconnect event must not clear the current connection.
|
||||
|
||||
Session teardown must remain safe when requested more than once or when sockets and codec resources are already closed. Reconnection is governed by `reconnect-policy.ts`; preserve terminal error handling, bounded retries and the previous-channel fallback.
|
||||
|
||||
Invalidate session audio before awaiting peer closure. Each codec and track must be released independently so one disposal failure cannot abandon the remaining resources. WebRTC close callers share one completion promise, including a peer-close rejection. Preserve WebSocketServer's close listener: it owns removal from the server's client set and allows shutdown to finish.
|
||||
|
||||
Late socket messages and media permission/negotiation results must not mutate a replacement session. Screen-sharing ownership is scoped to both the TeamSpeak target and channel; another member moving channels must not stop the current user's share. Preserve these invariants when extracting the remaining audio responsibilities.
|
||||
|
||||
WebRTC offers, answers, playback callbacks and accompaniment capture belong to the session and peer that started them. Invalidate pending negotiation on stop, reconnect or teardown before awaiting resource closure. A stale peer must not publish errors, counters or audio into its successor. Negotiation and track setup failures must restore compatibility capture without misreporting a microphone failure.
|
||||
|
||||
The WebRTC transport owns its peer, input mixer, meter, ICE wait and answer deadline. The capture layer retains ownership of the original microphone and PCM graph; releasing input during microphone preparation must not invalidate the preparing transport. Failed stop signaling cannot prevent local cleanup or compatibility fallback. A fallback permission failure must still belong to the connection and transport generation that initiated it.
|
||||
|
||||
Each remote WebRTC audio element owns its in-flight play attempt and retry listeners. Coalesce overlapping gestures, guard captured callbacks against replacement and release partial element setup. Pause, listener removal, source clearing or peer closure failures must not interrupt release of other resources.
|
||||
|
||||
Ticket acquisition has a 15-second browser deadline covering preference readiness, fetch and response-body reading. Disconnect and replacement abort the owning request immediately; stale success, rejection and deadline callbacks cannot open a socket or update a newer connection. This is separate from the gateway's TeamSpeak handshake policy. Browser cancellation does not undo a server-side invite consumption or ticket issuance. Preserve the gateway close code over generic WebSocket errors, detach retired handlers, and tolerate socket-close failures.
|
||||
|
||||
Every acknowledged command owns its original socket, connection generation and deadline. Success, server rejection, synchronous send failure, timeout and disconnect all use one idempotent completion path; release the registration and timer immediately. Fire-and-forget commands keep the existing shared wire contract.
|
||||
|
||||
Chat sends require a connected TeamSpeak session and append local history only after acknowledgement. A queued acknowledgement cannot append after session resource release. Recovery rejections retain the command request ID. Optional channelId and clientUid command fields let the gateway verify the actual channel and recipient before invoking the SDK; legacy payloads remain accepted without those additional guards. Confirmation is not a read receipt, and a timeout does not prove non-delivery.
|
||||
|
||||
Directory, chat, events and poke lists retain their reactive array identities. Complete channel snapshots replace the member directory, while omitted members remain unknown rather than empty. Channel projections share canonical members. Departure and UID replacement release the old member's playback, speaking state, temporary volume and whisper selection; persisted UID-based preferences remain. A recovered TeamSpeak connection replaces its directory even when the connected message omits members.
|
||||
|
||||
Explicit disconnect, target replacement and ordinary socket closure reset message state and advance the page's session epoch. Same-socket recovery may preserve chat history, but cannot send until connected; recovered directories and events replace old snapshots and clear old pokes. Failed recovery may retain its history for the failure panel until retry or exit.
|
||||
|
||||
Private history uses UID scopes when available and member-lifetime scopes for legacy clients without UIDs. Unknown senders must not become later members merely because a numeric ID matches. Preserve the recipient name in outgoing history. Drafts, pending submissions and errors belong to a destination within a session; switching tabs cannot duplicate an in-flight send. Confirmation clears only the unchanged submitted draft, including when its tab is inactive. Reset or disposal retires late feedback.
|
||||
|
||||
Channel projection uses iterative parent and sibling traversal, emits each ID at most once, keeps the first duplicate, promotes missing-parent channels to roots and starts isolated cycles at their first source entry. Do not reintroduce recursive traversal or silently discard the entire directory on a malformed topology.
|
||||
|
||||
Audio diagnostic probes retain their cancellation entry and deadline until both gateway and browser statistics finish. Bind the result to the original socket, connection generation and peer; disconnect settles pending consumers immediately, and a late browser getStats result cannot mix with a replacement peer. A probe send failure returns no sample.
|
||||
|
||||
Diagnostic samples also include the WebRTC transport generation, so a probe cannot survive a failed attempt that starts and ends without a peer. A browser-local scope ID changes with the source and session resets; compatibility counters reset at session teardown and snapshots stay independent. The scope ID is internal metadata, not part of the gateway protocol. Keep the exported diagnostic types available from the voice composable for existing callers.
|
||||
|
||||
The performance panel only subtracts counters from matching scopes, transports and downlink sources (PCM, RTP or gateway frames). Null or rejected probes clear stale activity and restart the baseline. Check the polling generation before starting work as well as after awaiting results; unmount retires callbacks and manual refresh. Preserve the 2-second polling interval. For loss estimates, packetsSent already includes all sent packets, while packetsReceived requires adding lost packets to form the denominator; keep percentages bounded and treat RTCP/local snapshots as estimates.
|
||||
|
||||
Accompaniment changes keep the WebRTC sender output alive. Prepare and connect the new source before replacing the old one; a failure preserves the current microphone and accompaniment. The input mixer owns its nodes and output track, never the externally owned capture streams. Release partial allocations and continue cleanup if an individual node fails. Application audio bypasses microphone gain/denoising and retains its source level.
|
||||
|
||||
The accompaniment controller owns both active and pending captures. Stop, disconnect and replacement immediately release candidates already returned by the browser, even while optional constraints are pending. Late permissions are stopped on arrival; ended or stale candidates cannot be published. Register ended listeners during preparation and publish activity only after attachment succeeds. Optional content hints and processing constraints may fail without losing capture; distinguish audio attachment errors from permission errors in all five languages.
|
||||
|
||||
Microphone metering is optional and must not interrupt voice. Its nodes and timer belong to one meter instance; a queued old tick cannot read the next session's analyser or publish a level. Allocation, connection and read failures release all meter resources and clear level/speaking presentation, while preserving the capture stream and peer. Keep the 512-sample analyser and 50 ms cadence unless audio validation justifies changing them.
|
||||
|
||||
## Audio and screen sharing
|
||||
|
||||
The compatibility voice path captures 48 kHz mono PCM using an AudioWorklet, with a ScriptProcessor fallback. The browser assembles 960-sample, 20 ms frames and sends 1,920-byte Int16 payloads over WebSocket. The gateway encodes them as Opus for TeamSpeak. Incoming Opus uses a three-byte header containing codec and client ID, then browser WebCodecs decoding and playback.
|
||||
|
||||
When enabled by the administrator, WebRTC provides a separate voice transport between the browser and gateway. The gateway uses `werift` and mixes incoming TeamSpeak speakers for WebRTC playback. Negotiation failures can fall back to the compatibility path. Keep microphone mute, per-member volume and playback behavior consistent across both transports.
|
||||
|
||||
Screen sharing has its own peer connections. The gateway coordinates stream membership and SDP/ICE signaling between browsers and supported TeamSpeak 6 clients. Screen media travels directly or through an externally configured TURN server; the WebSpeak gateway does not carry screen media.
|
||||
|
||||
Preserve bounded audio buffering and stale-playback recovery. Audio counters stay in memory and are exposed in session diagnostics. Do not add per-frame persistent logging to the voice path.
|
||||
|
||||
Remote playback owns each speaker's decoder, gain and source nodes as one resource set. Member departure, decoder failure and session teardown release that set; queued callbacks must not touch its replacement. Preserve the 80 ms playback window and three-frame decoder queue threshold unless audio validation justifies changing them.
|
||||
|
||||
Microphone recording tests own their recorder, timeout and object URL, while the capture layer owns the microphone stream. A normal stop may publish its final recording; replacement and session teardown discard late results and revoke the old URL. Stopping a test while connected must preserve room capture. Test cancellation and stale permission failures must not change a newer test's state.
|
||||
|
||||
Device and noise-suppression changes share one configuration operation. Persist only the last successful settings; stale failures cannot roll back a newer choice. Acquiring a replacement microphone must preserve the current WebRTC peer and compatibility PCM capture until the replacement is ready. Capture callbacks are invalidated when their graph stops, separately from permission-request generations. Closing settings also releases standalone device-preview capture when no recording was started.
|
||||
|
||||
Prepare microphone nodes and streams before replacing the live graph. A failed allocation or delayed worklet load must leave the old capture usable. Aborting preparation releases its candidate resources immediately; only activation enables PCM callbacks. Worklet module caches belong to their AudioContext. Device removal uses the normal input/output configuration transactions, including WebRTC restart and rollback on failed default-device selection. A committed graph becomes the fallback preference before subsequent device enumeration completes.
|
||||
|
||||
Serialize `setSinkId` on each audio context or media element, since an in-flight browser sink change cannot be cancelled. Bind subsequent work to the original endpoint and current operation; session teardown invalidates queued changes and device enumeration results. If one output endpoint rejects after another changed, attempt to restore the last committed output.
|
||||
|
||||
`src/server/opus-codec.ts` loads the native `@discordjs/opus` implementation for server deployments and `opusscript` for the Android bundle. Dispose codec and media resources at the end of their owning session.
|
||||
|
||||
## Configuration and persistence
|
||||
|
||||
Identity file reads belong to the current selection, text revision and dialog lifetime. New files (including invalid selections), manual edits, closing, entering the room, clearing local data and page disposal retire old results. Parsing owns its submitted draft; only a current result may replace the identity or notify. Preserve the 128 KiB limit, UTF-8/UTF-16 BOM decoding and existing busy-close behavior. The dialog disables submission while a selected file is being read and disables edits while parsing.
|
||||
|
||||
Startup identity restoration must not overwrite a newer import or remember preference. Exports belong to the identity and page that started them; coalesce pending clicks, discard late serialization and release download anchors, URLs and timers independently. Keep codec parsing in the existing identity service and persistence in the page/storage layer.
|
||||
|
||||
Admin requests belong to the login session and feature that started them. Invalidate pending work on authentication changes and page disposal; cancel feature work on management subroute exit. A late 401 must not expire a newer session, and late login or backup results must not navigate or download after disposal. Aborted work is not a user-facing failure. Failed logout preserves the authenticated draft; successful logout or session expiry resets private page state.
|
||||
|
||||
Settings responses merge against the submitted snapshot instead of replacing newer edits. Password and action, and relay token and action, are atomic draft groups. Clear acknowledged secret inputs, retain edits made during the request, merge relay nodes by ID, and do not restore obsolete probe metadata. Serialize skin mutations and prevent duplicate invite actions; cancelling browser work does not undo a server mutation already executed.
|
||||
|
||||
| Source | Purpose |
|
||||
| --- | --- |
|
||||
| SQLite `webspeak.db` | Admin credentials, target and access settings, relay nodes, invitations, audit records and visitor metadata |
|
||||
| `master.key` beside the database | Encryption key for persisted secrets; retain it with database backups |
|
||||
| `/admin` | Normal configuration and operational controls |
|
||||
| Legacy `config.json` | One-time import of `tsHost`, `tsPort` and `tsServerPassword`; later changes do not replace database settings |
|
||||
| `WEBSPEAK_DATA_DIR` | Persistent data directory; defaults to project `data/`, while Docker uses `/data` |
|
||||
| `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS` | Screen-sharing ICE configuration read at startup |
|
||||
| Relay environment variables | Standalone relay mode; public gateway relay choices come from saved admin settings |
|
||||
| Browser IndexedDB and localStorage | Local identities, preferences, server history and skin state |
|
||||
|
||||
The current SQLite schema version is defined in `src/persistence/database.ts`. Keep schema migrations separate from structural refactors. Legacy fields such as `voiceToken`, `tsApiKey`, `tsQueryPort`, `port` and `maxClients` do not configure the current gateway.
|
||||
|
||||
The gateway HTTP port is `3040`. Its admission ceiling is `100` sessions, defined in `src/constants.ts`; this is an application limit, not a TeamSpeak license allowance or a measured performance guarantee. Target server capacity and permissions still apply.
|
||||
|
||||
The server uses HTTPS when `certs/cert.pem` and `certs/key.pem` are supplied; otherwise it starts HTTP. It does not generate certificates. Use an appropriate secure browser origin for microphone and screen capture, typically HTTPS in public deployments. Feature support depends on the browser and selected transport; do not infer a universal minimum browser version from WebCodecs alone.
|
||||
|
||||
## Development and verification
|
||||
|
||||
Server deployments require Node.js 22.5 or newer. CI uses Node.js 22.22.2. Root and frontend dependencies are installed separately. The pinned Git SDK and native Opus module require the preparation steps used by CI:
|
||||
|
||||
```sh
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
npm run verify
|
||||
```
|
||||
|
||||
- Each browser user = one independent TS3 virtual client via `@echosixhiya/teamspeak-client`
|
||||
- Frontend captures PCM in an `AudioWorklet` when available (with a `ScriptProcessorNode` fallback), assembles fixed 960-sample frames, and sends Int16 binary over WebSocket
|
||||
- Server encodes PCM → Opus using `@discordjs/opus` (CJS, loaded via `createRequire`)
|
||||
- Server sends Opus to TS via `client.sendVoice(data, codec=4)`
|
||||
- Incoming TS voice → Opus frames → binary WebSocket → browser `AudioDecoder` → playback
|
||||
- Channel/member list fetched via TS6 WebQuery HTTP API (port 10080, requires API key)
|
||||
- WebSocket text frames = JSON commands, binary frames = PCM audio / Opus relay
|
||||
`npm run verify` runs unit tests, the backend build and `npm run web:build`. The latter delegates to the frontend build, including `vue-tsc --noEmit`. Use `npm run dev` and `npm run web:dev` for development, or `npm start` after building both applications.
|
||||
|
||||
## Project Structure
|
||||
Headless Vue tests use Vite middleware mode with both HMR and the WebSocket listener disabled (`hmr: false`, `ws: false`). Disabling HMR alone still reserves Vite's default socket port and causes parallel test processes to conflict.
|
||||
|
||||
```
|
||||
web/ # Vue 3 + Vite frontend (SPA)
|
||||
src/composables/useVoiceWebSocket.ts # Mic capture, VOX/PTT, playback, WS client
|
||||
src/views/WebClient.vue # Connect form + channel/member tree
|
||||
src/
|
||||
index.ts # Entry point, config loading, server startup
|
||||
config.ts # AppConfig interface + load/save
|
||||
logger.ts # Pino wrapper
|
||||
server/
|
||||
server.ts # Express + HTTPS + WS setup
|
||||
voice-bridge.ts # /ws/voice endpoint, PCM→Opus encoding, WebQuery API
|
||||
ts-client.ts # TS3Client wrapper around @echosixhiya/teamspeak-client
|
||||
```
|
||||
CI verifies pushes to `dev` and `master`, pull requests and manual runs. Docker publication on `master` or release tags, and release packaging on tags or manual runs, call the same verification workflow before publishing or packaging. Verification includes the application checks and a Docker HTTP health smoke test; that smoke test does not prove voice or screen-sharing functionality.
|
||||
|
||||
## Key Technical Details
|
||||
Tests requiring a real TeamSpeak server, browser media devices or Android hardware must document their environment and outcome separately. Never substitute a mock codec or an HTTP health response for a successful audio test.
|
||||
|
||||
### Audio Pipeline
|
||||
1. Browser mic → `getUserMedia` (48kHz mono) → `AudioWorklet` frame assembler (960 samples); older browsers use `ScriptProcessorNode` (1024-sample chunks) before the same assembler
|
||||
2. Float32 → Int16 conversion → PTT/VOX gate → WebSocket binary send
|
||||
3. Server encodes each 1920-byte (960-sample, 20ms) PCM frame → `OpusEncoder.encode()` → `tsClient.sendVoice(opus, 4)`
|
||||
4. Incoming: TS → `voiceData` event → 3-byte header `[codec][clientId BE]` → WS binary → browser `AudioDecoder` → playback
|
||||
5. Browser uplink is capped at 10 PCM frames (about 200ms); gateway egress applies a bounded WebSocket byte guard; browser playback resets stale decoder/source queues above 120ms.
|
||||
## Android preview
|
||||
|
||||
Audio flow counters are kept in memory and exposed in admin session summaries. Do not add per-frame persistent logging to the voice path.
|
||||
The Android app starts an embedded Node.js gateway on `127.0.0.1:3040` and opens it in the WebView. This preview disables gateway WebRTC voice and the admin console, while reusing the compatibility voice path. Its dependencies and runtime differ from server deployments.
|
||||
|
||||
### CJS Interop
|
||||
`@discordjs/opus` is CommonJS, loaded via:
|
||||
```ts
|
||||
import { createRequire } from "node:module";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { OpusEncoder } = require("@discordjs/opus");
|
||||
```
|
||||
See `mobile/README.md` for build steps and recorded limitations. The embedded Node.js version, SDK compatibility, real-device connections, background audio and native screen sharing require their own validation. Do not present these capabilities as production-ready based on desktop tests.
|
||||
|
||||
### WebSocket Message Routing
|
||||
- Text frames → JSON commands (`listChannels`, `switchChannel`)
|
||||
- Binary frames → PCM audio (browser→server) or Opus frames (server→browser)
|
||||
- JSON detection: `typeof data === "string"` first, then fallback `data[0] === 0x7b` with try/catch
|
||||
Platform startup owns its message listener, polling interval and deadline, including slow listener registration. Release them on success, failure, timeout and page exit. The retry button repeats the readiness handshake; it does not restart the embedded Node.js runtime.
|
||||
|
||||
### Event Handlers
|
||||
Must be registered BEFORE `tsClient.connect()` because `clientEnter`/`clientLeave` fire during handshake.
|
||||
## Repository maintenance
|
||||
|
||||
### Channel List
|
||||
Uses TS6 WebQuery HTTP API (`http://tsHost:tsQueryPort/1/channellist`) with `x-api-key` header. Falls back empty if `tsApiKey` not configured. Regular TS3 voice clients lack permission for `listChannels`/`listClients`.
|
||||
Routes load their page modules on demand. Document-level page styles must be gated by `html[data-ws-route]` because loaded CSS remains after navigation. The admin stylesheet is independent of public skins. Component extraction must retain `data-ws-part` hooks and account for Vue scoped styles across component boundaries.
|
||||
|
||||
### Config (config.json)
|
||||
```json
|
||||
{
|
||||
"port": 3040, "tsHost": "127.0.0.1", "tsPort": 9987,
|
||||
"tsQueryPort": 10080, "tsServerProtocol": "ts6",
|
||||
"tsApiKey": "", "voiceToken": "change-me", "maxClients": 10
|
||||
}
|
||||
```
|
||||
The identity dialog retains page-owned CSS with narrowly targeted `:deep` selectors so the existing declaration order and specificity remain intact. Shared button rules target its dedicated classes across the component boundary. Its close button is positioned within the modal. Public skin-contract tests include Vue files recursively under `components/web-client`; keep new public parts documented.
|
||||
|
||||
## Build & Deploy
|
||||
```bash
|
||||
npm install && cd web && npm install && npx vite build && cd .. && npx tsc
|
||||
node dist/index.js
|
||||
```
|
||||
The public join form uses explicit named field models and emits page actions. The chat panel receives a presentation subset of the single page-owned chat controller; keep its list ref bound to the rendered scroller so tab changes and new messages retain automatic scrolling. Form grid columns must allow shrinking, and narrow identity/relay controls must wrap without clipping translated text.
|
||||
|
||||
## Git
|
||||
- Remote: `https://github.com/EchoSixHIYA/web-client-for-TeamSpeak`
|
||||
- `webspeak-update.tar.gz` is in .gitignore (deployment artifact)
|
||||
- No secrets in source; config.json is gitignored
|
||||
The member panel and actions menu also share one page-owned member controller. The panel exposes an audio-dock slot; menu placement uses measured viewport bounds, converts through the page CSS zoom, and releases its resize observer/listener on unmount. Only desktop may open the move submenu on hover: mobile bottom-anchored menus change position when expanded and must open on click to avoid moving a member accidentally. Constrain short-window menus and allow scrolling.
|
||||
|
||||
## Known Limitations
|
||||
- Browser must be Chrome/Edge 94+ (WebCodecs AudioDecoder)
|
||||
- HTTPS required (self-signed cert OK, generated in `certs/`)
|
||||
- Max 32 concurrent users (TS3 license limit)
|
||||
- `tsApiKey` required for channel list; voice works without it
|
||||
Voice member cards receive the current channel projection, speaking/avatar helpers and a narrow sharing interface. Keep the sharing refs stable; member menus and stop-sharing actions return to the page through events. Empty, self, speaking, starting, sharing and viewing states must retain their skin hooks and mobile behavior.
|
||||
|
||||
Voice diagnostics and screen-sharing presentation also reuse page-owned controllers. Bind the player and video with explicit element callbacks. Rebind an existing stream when its video element changes, clear the previous element, and never stop the media owner's tracks during presentation cleanup. Fullscreen requires a non-null owned player; removing it exits only its own fullscreen. Known screen owner IDs take precedence over nickname fallback, including duplicate nicknames. Sharing settings use the common dialog focus handling.
|
||||
|
||||
The audio dock and whisper strip share the page-owned audio controller. Push-to-talk belongs to one primary pointer or one Space/Enter press; unrelated releases and key repeats must not change it. Failed pointer capture must not enable whispering. Clear ownership before releasing capture, and stop on blur, hidden controls/pages and disposal. The whisper component owns and releases its window/document listeners; keep media state in the voice layer.
|
||||
|
||||
Audio settings and password dialogs retain one page-owned media/connection state. Dialog focus supports initial focus, Tab cycling, Escape and return to the opener, with a connect-button fallback after pending connections disable that opener. Settings error feedback belongs to the current opening and latest request; closing synchronously stops recording tests, and scope disposal retires pending feedback and stops tests too. A non-password channel error must release the password dialog's pending state and preserve its draft for retry; reject duplicate submissions while pending.
|
||||
|
||||
Admin presentation components receive stable feature controllers; do not instantiate duplicate controllers in children. The welcome-language model remains page-owned and the skin file input belongs to its presentation component. Feature CSS crosses these boundaries with `:deep`, while shell and language-control selectors retain their existing scope. On narrow screens the brand and logout occupy the first row and all four navigation links share a separate row with at least 44 px high targets.
|
||||
|
||||
Keep each repair batch tied to its current plan item. Combine related fixes before running the full verification command; use focused checks during diagnosis and repeat the full suite only when subsequent changes or failures warrant it.
|
||||
|
||||
Keep template/CSS formatting separate from behavior changes. Preserve inline whitespace text nodes when wrapping Vue tags; compare compiled render output when needed. CSS formatting must retain selector meaning, values and declaration/rule order. Layout assertions should tolerate formatting whitespace while still checking the intended rules and values.
|
||||
|
||||
Public skin activation is last-choice-owned across both public pages. Retire previous runtime work before preparing a replacement, and reject results after page disposal, a newer choice or local-data reset. Check ownership before modifying document styles, selected content, asset URLs or stored preferences. An already aborted caller must not cancel a newer page's activation. Release compiled candidate URLs on failed installation.
|
||||
|
||||
Skin initialization has an 8-second total deadline covering preference reads, directory fetch and body, package loading and activation. Network stages also have bounded standalone operations. A timeout reveals a usable built-in palette and retires late work; retain the explicit skin choice for a later retry. Normal initialization still respects the enabled instance default unless the visitor made a deliberate choice. Home and demo use the same controller; do not restore duplicate unguarded refresh paths.
|
||||
|
||||
Skin cache writes and preference persistence accept the owning AbortSignal, including while waiting for IndexedDB to open and during its write transaction. Report storage success at transaction completion. Merge preferences within one transaction so concurrent unrelated settings are preserved. Cancellation of optional persistence must never block page use.
|
||||
|
||||
Validate admin responses before applying them to page state. Network and protocol failures must preserve unsaved input; a failed logout must not be presented as a successful logout. Keep secret keep/replace/remove actions intact and do not persist credentials in UI error messages or diagnostic logs.
|
||||
|
||||
The repository remote is `https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak`. Preserve existing local work and keep private configuration, runtime data, local deployment archives, and machine-specific notes out of source commits. Preserve documented skin hooks and browser persistence formats during component refactors.
|
||||
@@ -2,16 +2,19 @@ FROM node:22-bookworm-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends git python3 make g++ \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates git python3 make g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
COPY web/package.json web/package-lock.json ./web/
|
||||
RUN npm ci
|
||||
RUN npm ci --ignore-scripts --no-audit --no-fund
|
||||
COPY scripts/prepare-sdk.mjs ./scripts/prepare-sdk.mjs
|
||||
RUN npm run prepare:sdk
|
||||
RUN npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
RUN npm --prefix web ci
|
||||
|
||||
COPY . .
|
||||
RUN npm --prefix web run build \
|
||||
RUN npm run web:build \
|
||||
&& npm run build \
|
||||
&& npm prune --omit=dev \
|
||||
&& rm -rf web/node_modules
|
||||
@@ -20,7 +23,7 @@ FROM node:22-bookworm-slim AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates libstdc++6 \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates libstdc++6 iputils-ping \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /data \
|
||||
&& chown node:node /data
|
||||
@@ -32,11 +35,12 @@ COPY --from=build --chown=node:node /app/package.json /app/package-lock.json ./
|
||||
COPY --from=build --chown=node:node /app/node_modules ./node_modules
|
||||
COPY --from=build --chown=node:node /app/dist ./dist
|
||||
COPY --from=build --chown=node:node /app/web/dist ./web/dist
|
||||
COPY --from=build --chown=node:node /app/scripts/docker-healthcheck.mjs ./scripts/docker-healthcheck.mjs
|
||||
|
||||
USER node
|
||||
VOLUME ["/data"]
|
||||
EXPOSE 3040/tcp 40000-40099/udp
|
||||
EXPOSE 3040/tcp 39087/udp 40000-40099/udp
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD node -e "fetch('http://127.0.0.1:3040/health').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"
|
||||
CMD ["node", "scripts/docker-healthcheck.mjs"]
|
||||
|
||||
CMD ["node", "dist/index.js"]
|
||||
@@ -1,332 +1,99 @@
|
||||
<div align="center">
|
||||
<a id="readme-top"></a>
|
||||
|
||||
<img src="./image.png" alt="WebSpeak 项目横幅" width="100%" />
|
||||
|
||||
<h1>WebSpeak</h1>
|
||||
|
||||
<p><strong>让 TeamSpeak 自然地进入浏览器。</strong></p>
|
||||
<p>A self-hosted browser voice client for TeamSpeak 3 and TeamSpeak 6.</p>
|
||||
|
||||
[](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest)
|
||||
[](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/actions/workflows/docker-publish.yml)
|
||||
[](./LICENSE)
|
||||
[](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/stargazers)
|
||||
<br />
|
||||
[](https://www.teamspeak.com/)
|
||||
[](https://nodejs.org/)
|
||||
[](https://vuejs.org/)
|
||||
[](https://www.typescriptlang.org/)
|
||||
[](https://github.com/users/EchoSixHIYA/packages/container/package/webspeak)
|
||||
|
||||
<p>
|
||||
<a href="./docs/README.zh-CN.md">简体中文文档</a> ·
|
||||
<a href="./docs/README.en.md">English documentation</a> ·
|
||||
<a href="./docs/README.de.md">Deutsche Dokumentation</a> ·
|
||||
<a href="./docs/README.ru.md">Русская документация</a> ·
|
||||
<a href="./docs/README.ja.md">日本語ドキュメント</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## 项目简介 · Overview
|
||||
|
||||
| 逻辑 | 中文 | English |
|
||||
| --- | --- | --- |
|
||||
| **WHAT** | WebSpeak 是一个可自行部署的 TeamSpeak 3 / TeamSpeak 6 网页客户端与语音网关。 | WebSpeak is a self-hosted browser client and voice gateway for TeamSpeak 3 and TeamSpeak 6. |
|
||||
| **WHY** | 无需安装桌面客户端,用户打开网页即可加入频道;部署者仍然掌控目标服务器、访问策略和数据。 | Users can join a voice channel from a browser without installing a desktop client, while the operator keeps control of servers, access, and data. |
|
||||
| **HOW** | 部署后在管理员控制台配置 TeamSpeak 目标和访问方式,浏览器负责交互与音频,WebSpeak 负责网关连接。 | Configure the TeamSpeak target and access policy in the administration console. The browser handles interaction and audio; WebSpeak provides the gateway connection. |
|
||||
|
||||
## 文档 · Documentation
|
||||
|
||||
- [简体中文](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.zh-CN.md)
|
||||
- [English](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.en.md)
|
||||
- [Deutsch](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.de.md)
|
||||
- [Русский](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.ru.md)
|
||||
- [日本語](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/README.ja.md)
|
||||
- [皮肤开发指南 / Skin development guide](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/docs/SKIN_DEVELOPMENT.md)
|
||||
- [皮肤开发 Agent Skill / Skin Development Agent Skill](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/master/.agents/skills/webspeak-skin-development/SKILL.md)
|
||||
|
||||
## 社区 · Community
|
||||
|
||||
<div align="center">
|
||||
|
||||
# WebSpeak
|
||||
<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475">
|
||||
<img src="./web/public/qq-group-qr.jpg" alt="WebSpeak QQ 群二维码" width="290" />
|
||||
</a>
|
||||
|
||||
**让 TeamSpeak 真正进入浏览器。**
|
||||
**QQ群 / QQ group:`869500475`**
|
||||
|
||||
自托管的 TeamSpeak 3 / TeamSpeak 6 网页客户端。打开网页即可加入语音、查看频道、发送消息,无需安装桌面客户端。
|
||||
[通过群聊链接直接加入 / Join directly](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475)
|
||||
|
||||
**在线体验:[webspeak.example.invalid](https://webspeak.example.invalid)**
|
||||
|
||||
[](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak)
|
||||
[](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4)
|
||||
[](LICENSE)
|
||||
[](https://www.teamspeak.com/)
|
||||
|
||||
[中文](#中文) · [English](#english) · [更新日志](#更新日志--changelog) · [快速开始](#快速开始--quick-start) · [社区](#社区--community)
|
||||
[Telegram 群组 / Telegram group](https://t.me/+8qShpTcuN9A3MWY9)
|
||||
|
||||
</div>
|
||||
|
||||
## 中文
|
||||
## 友链项目 · Friend projects
|
||||
|
||||
WebSpeak 是一个面向 TeamSpeak 服务器的浏览器客户端。部署一次,用户通过网页即可加入语音空间,不需要安装 TeamSpeak 桌面客户端。
|
||||
### [NeteaseTSBot](https://github.com/yichen11818/NeteaseTSBot)
|
||||
|
||||
### 功能
|
||||
面向 TeamSpeak 3/6 的多平台音乐点播机器人,支持网易云音乐、QQ 音乐和 Bilibili 音频播放,并提供 Web 控制台。<br />
|
||||
A multi-platform music bot for TeamSpeak 3/6 with Netease Cloud Music, QQ Music, and Bilibili playback, plus a web console.<br />
|
||||
Ein plattformübergreifender Musikbot für TeamSpeak 3/6 mit Netease Cloud Music, QQ Music und Bilibili sowie Webkonsole.
|
||||
|
||||
- 支持 TeamSpeak 3 和 TeamSpeak 6,自动识别协议。
|
||||
- 浏览频道、在线成员和实时成员状态。
|
||||
- 加入、切换频道,并显示成员所在频道。
|
||||
- 频道文字聊天、服务器消息、私聊和戳一戳。
|
||||
- 浏览器麦克风和扬声器选择、音量调节、输入电平和本地麦克风测试。
|
||||
- 一键闭麦/开麦、VOX 语音激活、发言状态提示。
|
||||
- 可选 WebRTC 低延迟语音,网络不支持时自动回退。
|
||||
- 固定服务器、开放服务器和一次性邀请链接三种访问方式。
|
||||
- 管理控制台:默认目标、邀请链接、在线会话、日志、诊断和数据库备份。
|
||||
- 中英文界面、主题切换、桌面端和移动端适配。
|
||||
- 移动端提供成员操作菜单,桌面端支持右键菜单。
|
||||
## Contributors · 贡献者
|
||||
|
||||
### 快速开始 · Quick Start
|
||||
感谢通过 PR 改进 WebSpeak 的贡献者。以下按 GitHub 的合并记录列出。
|
||||
|
||||
#### Docker Compose(推荐)
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) 改进浏览器端报错翻译;[PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) 修正缩放、浮动布局和首页脚注。
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [已合并 PR #13、#15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep),涉及 TS6 既有屏幕共享发现、屏幕比例、移动端语音/常亮/皮肤菜单、身份频道选项、PWA/主题、聊天历史、成员音频状态和麦克风权限等改进。
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) 支持通过 TeamSpeak 注册昵称连接,并在设置、收藏和邀请中保留昵称目标。
|
||||
|
||||
要求:安装 Docker Engine 和 Docker Compose。
|
||||
## 许可证 · License · Lizenz · Лицензия · ライセンス
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
WebSpeak 使用 [GNU Affero General Public License v3.0 only](./LICENSE) 发布。你可以使用、研究、修改和再分发本项目;如果修改后的版本通过网络向用户提供服务,需要按照 AGPL-3.0 向这些用户提供对应源代码。
|
||||
|
||||
打开 `http://你的服务器地址:3040/`,首次进入管理后台 `/admin` 使用:
|
||||
WebSpeak is released under the [GNU Affero General Public License v3.0 only](./LICENSE). If a modified version is offered to users over a network, its corresponding source code must be offered under AGPL-3.0.
|
||||
|
||||
```text
|
||||
账号:admin
|
||||
密码:admin
|
||||
```
|
||||
WebSpeak wird unter der [GNU Affero General Public License v3.0 only](./LICENSE) veröffentlicht. Bei Bereitstellung einer veränderten Version über ein Netzwerk muss der entsprechende Quellcode unter AGPL-3.0 angeboten werden.
|
||||
|
||||
首次登录必须修改管理员密码。然后在管理控制台的“服务器”页面设置“默认 TeamSpeak 目标”,例如:
|
||||
WebSpeak распространяется по лицензии [GNU Affero General Public License v3.0 only](./LICENSE). Если изменённая версия предоставляется пользователям через сеть, соответствующий исходный код должен быть доступен этим пользователям на условиях AGPL-3.0.
|
||||
|
||||
```text
|
||||
203.0.113.10#9987
|
||||
```
|
||||
WebSpeak は [GNU Affero General Public License v3.0 only](./LICENSE) の下で公開されています。変更版をネットワーク経由でユーザーに提供する場合は、対応するソースコードを AGPL-3.0 に従ってユーザーに提供する必要があります。
|
||||
|
||||
用户欢迎页没有邀请链接参数时,会自动使用管理员设置的默认目标。开放模式下,用户可以自行输入要连接的服务器地址和端口。
|
||||
## Star History
|
||||
|
||||
数据会保存在 Docker volume `webspeak-data` 中。升级时执行:
|
||||
<a href="https://star-history.com/#EchoSixHIYA/WebSpeak-client-for-TeamSpeak&Date">
|
||||
<img src="https://api.star-history.com/svg?repos=EchoSixHIYA/WebSpeak-client-for-TeamSpeak&type=Date" alt="WebSpeak Star History" width="100%" />
|
||||
</a>
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
不要使用 `docker compose down -v`,否则会删除数据库和管理员配置。
|
||||
|
||||
如需更换网页端口:
|
||||
|
||||
```bash
|
||||
WEBSPEAK_PORT=3041 docker compose up -d
|
||||
```
|
||||
|
||||
#### 源码运行
|
||||
|
||||
需要 Node.js `22.5.0` 或更高版本,以及 `@discordjs/opus` 所需的本地编译工具。
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
node dist/index.js
|
||||
```
|
||||
|
||||
服务默认监听 `3040` 端口。
|
||||
|
||||
### WebRTC 低延迟语音
|
||||
|
||||
WebRTC 是可选功能,由 WebSpeak 自带,不需要额外部署媒体服务器。
|
||||
|
||||
1. 在管理后台打开“WebRTC 语音”。
|
||||
2. 在部署主机所在云平台安全组或上游防火墙放行入站 UDP `40000–40099`。
|
||||
3. 重新进入语音空间即可生效。
|
||||
|
||||
Docker Compose 已自动发布 `40000–40099/UDP`,但无法替你修改云安全组。Ubuntu 使用 UFW 时可执行:
|
||||
|
||||
```bash
|
||||
sudo ufw allow 40000:40099/udp
|
||||
```
|
||||
|
||||
网页和 WSS 使用 TCP `80/443`。TeamSpeak 的 `9987` 只需要让 WebSpeak 主机能够访问目标 TeamSpeak,不需要在 WebSpeak 主机对公网开放。WebRTC 不支持或端口未放行时,客户端会自动使用兼容模式。
|
||||
|
||||
### 管理员设置
|
||||
|
||||
管理员可以在控制台中:
|
||||
|
||||
- 修改默认 TeamSpeak 目标和服务器密码。
|
||||
- 选择固定目标或允许用户自定义目标。
|
||||
- 创建、撤销和设置有效期的邀请链接。
|
||||
- 查看在线会话、运行日志、诊断信息和审计记录。
|
||||
- 下载诊断报告和 SQLite 数据库备份。
|
||||
- 开启或关闭 WebRTC 低延迟语音。
|
||||
|
||||
### 浏览器要求
|
||||
|
||||
- 使用较新的 Chrome、Edge 或其他支持 WebRTC 的现代浏览器。
|
||||
- 使用麦克风需要浏览器权限;公网部署建议使用 HTTPS。
|
||||
- 目标 TeamSpeak 服务器必须能被 WebSpeak 主机访问。
|
||||
|
||||
### 更新日志 · Changelog
|
||||
|
||||
完整记录见 [`CHANGELOG.md`](CHANGELOG.md)。
|
||||
|
||||
#### 2026-09-03 · v0.1.4
|
||||
|
||||
- 修复 WebRTC 语音收发与发言状态同步。
|
||||
- 修复频道文字消息在 WebSpeak 客户端之间无法互收。
|
||||
- 优化管理员页面、运行日志换行和移动端顶部布局;新增 Bilibili 入口及登录页返回首页。
|
||||
|
||||
#### 2026-09-03 · v0.1.3
|
||||
|
||||
- 增加可选 WebRTC 低延迟语音。
|
||||
- 支持在管理员页面直接启用 WebRTC,无需额外媒体服务器。
|
||||
- 更新 TeamSpeak 集成,改善频道、成员和实时状态同步。
|
||||
- 优化语音缓冲和连接回退,减少网络抖动造成的延迟堆积。
|
||||
- 公网部署放行 UDP `40000–40099` 后,双浏览器语音测试稳定运行,实测间隔峰值约 `27–83ms`。
|
||||
|
||||
#### 2026-09-02 · v0.1.2
|
||||
|
||||
- 大幅优化移动端界面和成员操作。
|
||||
- 首页增加 GitHub、当前版本和更新日志入口。
|
||||
- 修复设置按钮错位,优化窄屏布局和滚动体验。
|
||||
- 增加 AudioWorklet、设备选择和更稳定的语音缓冲处理。
|
||||
|
||||
#### 2026-09-02 · v0.1.1
|
||||
|
||||
- 正式提供浏览器客户端、管理控制台、邀请链接和运维功能。
|
||||
- 修复成员同步、私聊断开和频道显示问题。
|
||||
- 增加中英文切换、默认目标、首次登录改密和一键闭麦。
|
||||
- 发布 Windows、Linux 和 Docker 部署方式。
|
||||
|
||||
#### 2026-08-31 · v0.1.0
|
||||
|
||||
- 首个规范化版本。
|
||||
|
||||
### 社区 · Community
|
||||
|
||||
QQ群:`869500475`
|
||||
|
||||
加入 QQ 群获取使用帮助、版本更新和交流支持:
|
||||
|
||||

|
||||
|
||||
### 许可证
|
||||
|
||||
WebSpeak 使用 [GNU Affero General Public License v3.0](LICENSE) 发布。
|
||||
|
||||
## English
|
||||
|
||||
WebSpeak is a self-hosted browser client for TeamSpeak 3 and TeamSpeak 6. Deploy it once and let users join voice channels from a browser without installing the desktop TeamSpeak client.
|
||||
|
||||
**Live demo: [webspeak.example.invalid](https://webspeak.example.invalid)**
|
||||
|
||||
### Features
|
||||
|
||||
- TeamSpeak 3 and TeamSpeak 6 support with automatic protocol detection.
|
||||
- Live channel tree, online members, member locations, and status updates.
|
||||
- Channel switching and member presence grouped under the correct channel.
|
||||
- Channel text chat, server messages, private messages, and poke actions.
|
||||
- Browser microphone and speaker selection, volume control, input level, and local microphone test.
|
||||
- One-click microphone mute/unmute, VOX activation, and speaking indicators.
|
||||
- Optional low-latency WebRTC audio with automatic compatibility fallback.
|
||||
- Fixed targets, open targets, and expiring one-time invite links.
|
||||
- Admin console for targets, invites, sessions, logs, diagnostics, and database backups.
|
||||
- Chinese and English UI, theme switching, and responsive desktop/mobile layouts.
|
||||
- Mobile member action menus and desktop context menus.
|
||||
|
||||
### Quick Start
|
||||
|
||||
#### Docker Compose (recommended)
|
||||
|
||||
Requirements: Docker Engine and Docker Compose.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Open `http://your-server:3040/`. On the first admin login at `/admin`, use:
|
||||
|
||||
```text
|
||||
Username: admin
|
||||
Password: admin
|
||||
```
|
||||
|
||||
You must change the administrator password after the first login. Then configure the **Default TeamSpeak target** in the **Servers** page, for example:
|
||||
|
||||
```text
|
||||
203.0.113.10#9987
|
||||
```
|
||||
|
||||
If a welcome link does not contain an invite target, the default target is pre-filled automatically. In open mode, users may enter their own TeamSpeak address and port.
|
||||
|
||||
Data is stored in the `webspeak-data` Docker volume. To upgrade:
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Do not run `docker compose down -v`, because it removes the database and administrator settings.
|
||||
|
||||
To change the web host port:
|
||||
|
||||
```bash
|
||||
WEBSPEAK_PORT=3041 docker compose up -d
|
||||
```
|
||||
|
||||
#### Run from source
|
||||
|
||||
Requires Node.js `22.5.0` or newer and native build tools for `@discordjs/opus`.
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
node dist/index.js
|
||||
```
|
||||
|
||||
The service listens on port `3040` by default.
|
||||
|
||||
### Low-latency WebRTC audio
|
||||
|
||||
WebRTC is optional and bundled with WebSpeak. No separate media server is required.
|
||||
|
||||
1. Enable **WebRTC audio** in the admin console.
|
||||
2. Allow inbound UDP `40000–40099` in the cloud security group or upstream firewall for the WebSpeak host.
|
||||
3. Re-enter the voice space to apply the setting.
|
||||
|
||||
Docker Compose publishes `40000–40099/UDP` automatically, but it cannot change a cloud security group. With Ubuntu UFW:
|
||||
|
||||
```bash
|
||||
sudo ufw allow 40000:40099/udp
|
||||
```
|
||||
|
||||
The web page and WSS signaling use TCP `80/443`. TeamSpeak port `9987` only needs to be reachable from WebSpeak to the target TeamSpeak server; it does not need to be exposed publicly on the WebSpeak host. If WebRTC is unavailable, the client automatically uses the compatibility mode.
|
||||
|
||||
### Administrator settings
|
||||
|
||||
The admin console can:
|
||||
|
||||
- Set the default TeamSpeak target and server password.
|
||||
- Choose a fixed target or allow users to enter their own target.
|
||||
- Create, revoke, expire, and limit invite links.
|
||||
- View online sessions, runtime logs, diagnostics, and audit records.
|
||||
- Download diagnostic reports and SQLite backups.
|
||||
- Enable or disable low-latency WebRTC audio.
|
||||
|
||||
### Browser requirements
|
||||
|
||||
- A recent Chrome, Edge, or another modern browser with WebRTC support.
|
||||
- Microphone permission is required for voice input; HTTPS is recommended for public deployments.
|
||||
- The target TeamSpeak server must be reachable from the WebSpeak host.
|
||||
|
||||
### Changelog
|
||||
|
||||
See [`CHANGELOG.md`](CHANGELOG.md) for the complete release history.
|
||||
|
||||
#### 2026-09-03 · v0.1.4
|
||||
|
||||
- Fixed WebRTC voice transport and speaking-state synchronization.
|
||||
- Fixed channel text messages between WebSpeak clients.
|
||||
- Refined admin pages, log wrapping, and narrow-screen header layout; added Bilibili and admin-login home links.
|
||||
|
||||
#### 2026-09-03 · v0.1.3
|
||||
|
||||
- Added optional low-latency WebRTC audio.
|
||||
- Added an admin switch for WebRTC without requiring a separate media server.
|
||||
- Updated TeamSpeak integration for better channel, member, and realtime status synchronization.
|
||||
- Improved audio buffering and connection fallback to reduce delay growth during network jitter.
|
||||
- After allowing inbound UDP `40000–40099`, a two-browser voice test ran reliably with observed peak gaps of about `27–83 ms`.
|
||||
|
||||
#### 2026-09-02 · v0.1.2
|
||||
|
||||
- Major mobile UI and member-action improvements.
|
||||
- Added GitHub, current-version, and changelog entries to the welcome page.
|
||||
- Fixed settings-button alignment and improved narrow-screen layout and scrolling.
|
||||
- Added AudioWorklet, device selection, and more stable voice buffering.
|
||||
|
||||
#### 2026-09-02 · v0.1.1
|
||||
|
||||
- Official browser client, admin console, invite links, and operations tools.
|
||||
- Fixed member synchronization, private-message disconnects, and channel display issues.
|
||||
- Added Chinese/English switching, default targets, first-login password rotation, and one-click mute.
|
||||
- Added Windows, Linux, and Docker deployment options.
|
||||
|
||||
#### 2026-08-31 · v0.1.0
|
||||
|
||||
- First normalized release.
|
||||
|
||||
### Community
|
||||
|
||||
QQ group: `869500475`
|
||||
|
||||
Join the group for support, release updates, and discussion:
|
||||
|
||||

|
||||
|
||||
### License
|
||||
|
||||
WebSpeak is released under the [GNU Affero General Public License v3.0](LICENSE).
|
||||
<div align="right"><a href="#readme-top">返回顶部 · Back to top ↑</a></div>
|
||||
@@ -3,9 +3,9 @@ services:
|
||||
image: ${WEBSPEAK_IMAGE:-ghcr.io/echosixhiya/webspeak:latest}
|
||||
pull_policy: missing
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${WEBSPEAK_PORT:-3040}:3040"
|
||||
- "40000-40099:40000-40099/udp"
|
||||
# WebSpeak needs to reach a TeamSpeak server running on the same host.
|
||||
# Host networking also exposes the configured WebRTC UDP range directly.
|
||||
network_mode: host
|
||||
volumes:
|
||||
- webspeak-data:/data
|
||||
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
# WebSpeak · Deutsch
|
||||
|
||||
[Projektstartseite](../README.md) · [简体中文](./README.zh-CN.md) · [English](./README.en.md) · [Русский](./README.ru.md) · [日本語](./README.ja.md)
|
||||
|
||||
WebSpeak ist ein selbst gehosteter Webclient und ein Sprach-Gateway für TeamSpeak 3 und TeamSpeak 6. Nutzer können ohne Desktop-Client im Browser Kanälen beitreten; Administratoren verwalten Zielserver, Zugriff und Laufzeitstatus über die Webkonsole.
|
||||
|
||||
Aktuelle Version: [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7).
|
||||
|
||||
## Live-Demo
|
||||
|
||||
Adresse: <https://webspeak.online>
|
||||
|
||||
Die öffentliche Demo läuft in Hongkong. Netzwerkbedingungen und Auslastung können instabil sein; Latenz, Verbindungsabbrüche oder kurze Ausfälle beschreiben nicht jede eigene Bereitstellung.
|
||||
|
||||
## ✨ Funktionen
|
||||
|
||||
| Funktion | Beschreibung |
|
||||
| --- | --- |
|
||||
| TeamSpeak-Kompatibilität | Unterstützt TeamSpeak 3 und TeamSpeak 6 und erkennt das Zielprotokoll automatisch. |
|
||||
| Plattformübergreifendes P2P-Bildschirmteilen | Browsernutzer und native TeamSpeak-6-Clients können die Bildschirmfreigabe gegenseitig starten und ansehen; WebRTC/ICE überträgt Medien direkt, WebSpeak leitet nur die Signalisierung weiter. |
|
||||
| IPv6-Ziele | IPv6-TeamSpeak-Ziele und über DNS aufgelöste IPv6-Adressen werden standardmäßig unterstützt. |
|
||||
| Kanäle und Mitglieder | Kanalstruktur und aktuelle Mitglieder anzeigen und Kanäle wechseln. |
|
||||
| Echtzeit-Sprache | Opus-Audio mit kompatiblem Transport und optional integriertem WebRTC für geringere Latenz. |
|
||||
| Audiosteuerung | Mikrofon und Lautsprecher auswählen, Lautstärke regeln, testen, stummschalten, VOX und individuelle Mitgliedslautstärke. |
|
||||
| Browserseitige Geräuschunterdrückung | Optionale Mikrofon-Geräuschunterdrückung in der Browseraufnahme, ohne zusätzliche serverseitige Audioverarbeitung. |
|
||||
| Nachrichten und Aktionen | Kanal- und Serverchat, private Nachrichten, Anstupsen und Flüsterziele. |
|
||||
| Desktop-Begleitton | Audio eines freigegebenen Fensters oder Browser-Tabs im aktuellen Kanal teilen. |
|
||||
| Identität und Zugriff | Gespeicherte Identität, eigene Ziele, widerrufbare Einladungen sowie Import, Konvertierung, Prüfung und Export von TeamSpeak-3-Identitäten. |
|
||||
| Administration | Ziele, Zugriff, öffentliche Medienadresse, IPv6-Kandidaten, Sprach-STUN, Relays, Einladungen, Sitzungen, Protokolle, Diagnosen und Backups verwalten. |
|
||||
| Projektstruktur | In 0.2.6 wurden Sprach-Gateway, Sitzungsereignisse, Audio und Bildschirmfreigabe in Module aufgeteilt; Sprach- und Admin-Oberflächen in Komponenten, Composables und Dienste zerlegt und um Lebenszyklus- und Wiederverbindungstests ergänzt. |
|
||||
| Skins | Geschützte Tages-, Nacht- und ILLUSIA-Skins sowie instanzverwaltete `.wskin`-Designs mit Aktivierungs- und Standardauswahl im Adminbereich. |
|
||||
| Oberfläche | Chinesische, englische, deutsche, russische und japanische Oberfläche sowie responsive Desktop-/Mobilansicht. |
|
||||
| Selbsthosting | Daten bleiben beim Betreiber; Pakete für Windows x64 und Linux x64/ARM64, Docker für amd64/arm64 und Android-APKs für arm64-v8a, armeabi-v7a und x86_64. |
|
||||
|
||||
## 🖼️ Screenshots
|
||||
|
||||
Die Screenshots zeigen die deutsche Willkommensseite, den Sprachbereich, die Audiosteuerung und das Mitgliedermenü.
|
||||
|
||||
### Willkommensseite
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-de-home.png" alt="WebSpeak deutsche Willkommensseite" width="100%" /></p>
|
||||
|
||||
### Sprachbereich
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-de.png" alt="WebSpeak deutscher Sprachbereich" width="100%" /></p>
|
||||
|
||||
### Audiosteuerung
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-de-audio.png" alt="WebSpeak deutsche Audiosteuerung" width="100%" /></p>
|
||||
|
||||
### Mitgliedermenü
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-de-menu.png" alt="WebSpeak deutsches Mitgliedermenü" width="100%" /></p>
|
||||
|
||||
## 🧩 Erweiterte Funktionen
|
||||
|
||||
Diese Funktionen sind optional. Ohne sie arbeitet WebSpeak weiterhin mit dem kompatiblen Sprachtransport. Die Einstellungen befinden sich unter **Administration → Server** und gelten für neue Verbindungen.
|
||||
|
||||
### 1. WebRTC-Sprache mit niedriger Latenz
|
||||
|
||||
WebRTC verwendet für Browser-Sprache einen Echtzeit-Medienpfad und ermöglicht außerdem Desktop-Begleitton. Das aktuelle WebSpeak-Gateway stellt WebRTC selbst bereit; ein zusätzlicher Medienserver ist nicht erforderlich.
|
||||
|
||||
1. Unter `/admin` anmelden und auf der Seite **Server** die **Erweiterten Einstellungen** öffnen.
|
||||
2. Bei deaktiviertem WebRTC Start- und Endport für UDP festlegen. Der Standardbereich ist `40000–40099`.
|
||||
3. Den gesamten UDP-Bereich in Sicherheitsgruppe und Firewall des WebSpeak-Hosts freigeben.
|
||||
4. **WebRTC** aktivieren und speichern. Nicht unterstützte Browser oder Netzwerke wechseln automatisch zum kompatiblen Transport.
|
||||
|
||||
Der Portbereich ist bei aktiviertem WebRTC gesperrt. Zum Ändern WebRTC zuerst deaktivieren und speichern, danach die Firewall-Regeln anpassen. Für öffentliche Bereitstellungen ist HTTPS erforderlich.
|
||||
|
||||
### ICE-Kandidaten für Bildschirmfreigabe
|
||||
|
||||
Die Medien der Bildschirmfreigabe versuchen weiterhin eine direkte Browser-zu-Browser-Verbindung; WebSpeak leitet nur die Signalisierung weiter. Standardmäßig werden die öffentlichen TeamSpeak-STUN-Dienste zur Ermittlung öffentlicher Kandidaten verwendet. STUN überträgt keine Medien. Ein autorisierter externer TURN-Dienst kann über `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS` als JSON-Array konfiguriert werden, zum Beispiel:
|
||||
|
||||
```json
|
||||
[{"urls":"stun:turn.teamspeak.com:3478"},{"urls":"turns:turn.example.com:5349","username":"<username>","credential":"<credential>"}]
|
||||
```
|
||||
|
||||
Mit TURN kann die Medienübertragung diesen externen Dienst verwenden, aber niemals das WebSpeak-Gateway. Ohne TURN werden nur direkte ICE-Pfade und STUN verwendet.
|
||||
|
||||
### Plattformübergreifendes P2P-Bildschirmteilen
|
||||
|
||||
Browsernutzer und native TeamSpeak-6-Clients können Bildschirmfreigaben gegenseitig erkennen, starten und ansehen. Zwischen Browsern sowie zwischen Browser und nativem Client werden die Bildschirmmedien möglichst über eine direkte WebRTC/ICE-Peer-to-Peer-Verbindung übertragen; WebSpeak übernimmt Sitzungsberechtigung, Freigabestatus und SDP-/ICE-Signalisierung, transportiert aber keine Bildschirmmedien. Die Oberfläche zeigt Live-Status und Zuschauerzahl und bietet Lautstärke-, Vollbild- und Beenden-Steuerung. Für die Aufnahme stehen bis zu 1080p und 60 FPS sowie WebRTC-Statistiken zur Verfügung.
|
||||
|
||||
### 2. Relay-Modus
|
||||
|
||||
Ein Relay hilft, wenn ein TeamSpeak-Server Verbindungen aus einer anderen Region ablehnt oder der direkte Weg instabil ist. Es ist kein VPN, sondern leitet nur den TeamSpeak-Verkehr der aktuellen WebSpeak-Sitzung weiter.
|
||||
|
||||
Eine Relay-Instanz ist ein dedizierter Weiterleitungsdienst ohne Besucher- oder Administrationsseite. Sie akzeptiert nur Gateway-Sitzungen mit passendem Token. Ein zufälliges Token mit mindestens 16 Zeichen verwenden.
|
||||
|
||||
#### Aus dem Quellcode starten
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm run build
|
||||
WEBSPEAK_MODE=relay \
|
||||
WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
WEBSPEAK_RELAY_HOST='0.0.0.0' \
|
||||
WEBSPEAK_RELAY_PORT='39087' \
|
||||
node dist/index.js
|
||||
```
|
||||
|
||||
Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
$env:WEBSPEAK_MODE = "relay"
|
||||
$env:WEBSPEAK_RELAY_TOKEN = "replace-with-a-long-random-token"
|
||||
$env:WEBSPEAK_RELAY_HOST = "0.0.0.0"
|
||||
$env:WEBSPEAK_RELAY_PORT = "39087"
|
||||
node .\dist\index.js
|
||||
```
|
||||
|
||||
#### Aus einem Release-Paket starten
|
||||
|
||||
Das passende Paket aus den [Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) herunterladen und entpacken:
|
||||
|
||||
```bash
|
||||
# Linux
|
||||
export WEBSPEAK_MODE=relay
|
||||
export WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token'
|
||||
export WEBSPEAK_RELAY_HOST='0.0.0.0'
|
||||
export WEBSPEAK_RELAY_PORT='39087'
|
||||
./runtime/node ./dist/index.js
|
||||
```
|
||||
|
||||
Unter Windows PowerShell dieselben Variablen setzen und `.\runtime\node.exe .\dist\index.js` ausführen.
|
||||
|
||||
#### Mit Docker starten
|
||||
|
||||
```bash
|
||||
docker run -d --name webspeak-relay --restart unless-stopped --network host \
|
||||
-e WEBSPEAK_MODE=relay \
|
||||
-e WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
-e WEBSPEAK_RELAY_PORT='39087' \
|
||||
ghcr.io/echosixhiya/webspeak:latest
|
||||
```
|
||||
|
||||
Den UDP-Listening-Port des Relay-Hosts freigeben, standardmäßig `39087`.
|
||||
|
||||
#### Im Gateway aktivieren
|
||||
|
||||
1. **Administration → Server → Relay-Server** öffnen und einen oder mehrere Knoten hinzufügen.
|
||||
2. Für jeden Knoten einen Anzeigenamen, einen Endpunkt wie `relay.example.com#39087` und das passende Token eintragen und speichern.
|
||||
3. Besucher können auf der Willkommensseite Direktzugriff oder einen konfigurierten Relay-Knoten auswählen.
|
||||
|
||||
Relay deaktivieren und speichern, um die Option von der Willkommensseite zu entfernen.
|
||||
|
||||
### 3. Abhängigkeiten und Hinweise zur Herkunft
|
||||
|
||||
- Der Relay-Dienst ist Bestandteil von WebSpeak und verwendet Node.js-Standardbibliotheken; GOST, sing-box oder ein anderes Proxy-Framework werden nicht verwendet.
|
||||
- WebRTC verwendet [werift](https://github.com/shinyoshiaki/werift-webrtc) `0.24.4`; das Upstream-Projekt steht unter MIT-Lizenz.
|
||||
- Die TeamSpeak-Protokollverbindung verwendet den projektgepflegten [EchoSixHIYA/teamspeak-js](https://github.com/EchoSixHIYA/teamspeak-js)-SDK-Fork.
|
||||
|
||||
## 🧾 Änderungsprotokoll
|
||||
|
||||
<a id="latest-release-notes"></a>
|
||||
|
||||
### [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7) · 2026-10-13
|
||||
|
||||
#### Offeneres Skin-System
|
||||
|
||||
- Ein offenerer Skin-Editor und die zugehörige Laufzeit erlauben es nun, Stil und Position beliebiger Komponenten anzupassen und Widgets hinzuzufügen.
|
||||
- Öffne nach dem Wechsel in den Sprachbereich im selben Browser ein neues Fenster mit der Administrationsoberfläche und melde dich an, um den Skin-Editor zu aktivieren.
|
||||
- Der Skin „KAAK“ ist als Entwicklungsbeispiel enthalten.
|
||||
- Der Agent Skill für die Skin-Entwicklung wurde aktualisiert.
|
||||
|
||||
#### Funktionserweiterungen
|
||||
|
||||
- Serveradressen können nun über SRV-Einträge und TeamSpeak-Nickname-Einträge aufgelöst werden.
|
||||
- Im freien Modus lassen sich mehrere Server-Tabs verwalten; diese Schaltflächen sind im Modus „Fester Server“ nicht verfügbar.
|
||||
- Eine Option für die Bitrate der Bildschirmfreigabe wurde hinzugefügt.
|
||||
- WebSpeak speichert eingegebene Kanalpasswörter nun im Browser.
|
||||
- Gesperrte Kanäle werden mit einem Schlosssymbol angezeigt.
|
||||
- Der Chatverlauf wird nun dauerhaft gespeichert.
|
||||
|
||||
#### Fehlerbehebungen
|
||||
|
||||
- Fehler bei der Adressauflösung behoben.
|
||||
- Fokuskonflikte zwischen Lautstärkeregelung und dem Ziehen von Mitgliedskarten behoben.
|
||||
- Fehler behoben, durch den der Benutzerstatus fälschlich als unbekannt erkannt wurde.
|
||||
|
||||
### [v0.2.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.6) · 2026-10-08
|
||||
|
||||
Gegenüber 0.2.5 wurden Sprach-Gateway, gemeinsame Protokolle, Sprachoberfläche und Admin-Module umfassend umstrukturiert; #6/#7/#10 behoben, #9/#12 umgesetzt und der in PR #13 gemeldete Fall bereits aktiver TS6-Freigaben behoben. Opus- und Sitzungslebenszyklen sowie mobile Steuerung verbessert. Pakete: Windows x64, Linux x64/ARM64, Docker amd64/arm64 und Android arm64-v8a/armeabi-v7a/x86_64.
|
||||
|
||||
### [v0.2.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.5) · 2026-09-27
|
||||
|
||||
`.wskin`-Skins, Aktivierungs-/Standardverwaltung und geschützte Tages-, Nacht- und ILLUSIA-Skins ergänzt; unfertiges Aurora-Voice-Beispiel entfernt, Skin-Ladeblitze, dunkle Bedienelemente und Artwork-Ebenen im Sprachbereich korrigiert sowie offiziellen Skin-Entwicklungs-Agent-Skill hinzugefügt.
|
||||
|
||||
### [v0.2.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.4) · 2026-09-22
|
||||
|
||||
Plattformübergreifendes P2P-Bildschirmteilen zwischen Browsern und nativen TeamSpeak-6-Clients ergänzt; STUN-/externes-TURN-Konfiguration, Live-Player und Zuschauerstatus, Aufnahmeoptionen bis 1080p/60 FPS und WebRTC-Statistiken hinzugefügt; Bildschirmfreigabe-Interaktion verbessert und Besucherzählung ergänzt.
|
||||
|
||||
### [v0.2.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.3) · 2026-09-19
|
||||
|
||||
Mitgliederplanung und direkte Verschiebung nach Berechtigung ergänzt; Avatar-, Stummschaltstatus- und Identitätsunterstützung hinzugefügt; Screenshots und Dokumentation für alle fünf Sprachen aktualisiert.
|
||||
|
||||
### [v0.2.2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.2) · 2026-09-17
|
||||
|
||||
Browserseitige Mikrofon-Geräuschunterdrückung, russische und japanische Oberfläche sowie sprachabhängige Begrüßungstexte ergänzt; Lautstärkeinteraktion und Fehlertexte/-codes auf Basis von PR #2 verbessert.
|
||||
|
||||
### [v0.2.1](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.1) · 2026-09-13
|
||||
|
||||
Verbindungsfehler auf der Willkommensseite verbessert, Fehlercodes erhalten und sicher gekürzt sowie IPv6-Ziele standardmäßig unterstützt.
|
||||
|
||||
### [v0.2.0](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.0) · 2026-09-10
|
||||
|
||||
Passwortabfrage, dedizierter Relay-Modus, Auswahl mehrerer Relays und Ursachendarstellung in der Administration ergänzt.
|
||||
|
||||
### [v0.1.8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.8) · 2026-09-08
|
||||
|
||||
Docker-Bereitstellung vereinfacht, lokale TeamSpeak-Ziele unterstützt, 15-Sekunden-Timeout ergänzt und kontinuierliche Netzwerküberwachung eingeführt.
|
||||
|
||||
### [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) · 2026-09-06
|
||||
|
||||
Deutsch, Telegram, Netzwerkleistung und Gesamtlautstärke ergänzt; Lautstärkeschwankungen beim Begleitton behoben.
|
||||
|
||||
### [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) · 2026-09-04
|
||||
|
||||
Desktop-Begleitton, Hinweise zur gespeicherten Identität und Website-Symbol ergänzt; WebRTC-Mitgliederlautstärke korrigiert.
|
||||
|
||||
### [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) · 2026-09-04
|
||||
|
||||
Identitätsspeicherung korrigiert und Designumschaltung verbessert.
|
||||
|
||||
### [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) · 2026-09-03
|
||||
|
||||
WebRTC und Kanalchat korrigiert sowie Administration, Protokolle und Mobilansicht verbessert.
|
||||
|
||||
### [v0.1.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.3) · 2026-09-03
|
||||
|
||||
Integriertes WebRTC, aktualisiertes TeamSpeak-SDK und bessere Mitgliedersynchronisierung und Sprachpufferung.
|
||||
|
||||
|
||||
## 🚀 Bereitstellung
|
||||
|
||||
| Methode | Geeignet für | Umgebung |
|
||||
| --- | --- | --- |
|
||||
| Docker Compose (empfohlen) | Dauerbetrieb, einfache Updates und persistente Daten | Docker Engine + Docker Compose |
|
||||
| Release-Paket | Betrieb ohne Node.js und Build-Werkzeuge | Windows x64 oder Linux x64/ARM64 |
|
||||
| Aus dem Quellcode | Entwicklung und Anpassungen | Node.js 22.5+, Git und native Build-Werkzeuge |
|
||||
|
||||
### Docker Compose (empfohlen)
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Nach dem Start ist WebSpeak unter `http://<dein-host>:3040` erreichbar. Bei einem Reverse Proxy auf diese Adresse zeigen; für WebRTC den im Adminbereich angezeigten UDP-Bereich freigeben. Die Daten liegen im Volume `webspeak-data`.
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
docker compose logs -f webspeak
|
||||
```
|
||||
|
||||
Upgrade:
|
||||
|
||||
```bash
|
||||
git pull --ff-only
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
`docker compose down -v` nicht ausführen, da dadurch Datenbank und Administratoreinstellungen gelöscht werden.
|
||||
|
||||
### Release-Paket
|
||||
|
||||
Das passende `windows-x64.zip`, `linux-x64.tar.gz` oder `linux-arm64.tar.gz` aus den [GitHub Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) herunterladen und den enthaltenen Starter ausführen. Die Pakete enthalten Node.js und Produktionsabhängigkeiten. Docker unterstützt amd64/arm64.
|
||||
|
||||
Android-APKs für `arm64-v8a`, `armeabi-v7a` und `x86_64` sind ebenfalls verfügbar. Sie sind für Tests per Sideload debug-signiert, keine Google-Play-Pakete; echte TeamSpeak-Sprachtests auf Geräten stehen noch aus.
|
||||
|
||||
### Aus dem Quellcode
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
Für den Bau von `@discordjs/opus` werden Python, Make und eine C/C++-Toolchain benötigt.
|
||||
|
||||
### Erste Konfiguration
|
||||
|
||||
1. `http://<dein-host>:3040/admin` öffnen.
|
||||
2. Mit `admin` / `admin` anmelden und sofort ein neues Passwort mit mindestens 12 Zeichen setzen.
|
||||
3. Unter **Server** TeamSpeak-Ziel und Zugriffsmethode konfigurieren, zum Beispiel `voice.example.com#9987`.
|
||||
4. Für öffentliche Nutzung HTTPS einrichten; bei aktiviertem WebRTC den im Adminbereich angezeigten UDP-Bereich freigeben.
|
||||
|
||||
## ⚠️ Voraussetzungen und Hinweise
|
||||
|
||||
| Bereich | Hinweis |
|
||||
| --- | --- |
|
||||
| Browser | Aktuelles Chrome, Edge oder ein moderner WebRTC-fähiger Browser wird empfohlen. Mikrofon- und Fenster-Audio benötigen normalerweise HTTPS. |
|
||||
| TeamSpeak-Netzwerk | Der WebSpeak-Host muss den Zielserver erreichen können; der Standard-Sprachport ist `9987`. |
|
||||
| Webnetzwerk | Der Dienst verwendet `3040/TCP`; öffentlich sollte ein HTTPS-Reverse-Proxy für Seite und WebSocket verwendet werden. |
|
||||
| IPv6 | Literale Ziele als `[2001:db8::1]#9987` eintragen. Host/Container benötigen geroutetes IPv6, aktiviertes IPv6 in Betriebssystem und Node.js sowie passende Firewall-Regeln. |
|
||||
| WebRTC | Standardbereich `40000–40099/UDP`; den gesamten Bereich freigeben und WebRTC vor einer Änderung deaktivieren. |
|
||||
| Gespeicherte Identität | Eine Browseridentität kann nur eine aktive gespeicherte Verbindung halten. Für parallele Verbindungen deaktivieren oder ein anderes Browserprofil verwenden. |
|
||||
| Begleitton | Nur auf dem Desktop verfügbar und WebRTC erforderlich. Bei Fenster- oder Tab-Freigabe auch Audio freigeben. |
|
||||
| Daten | Docker verwendet `webspeak-data`; Release-Pakete und Quellcode verwenden `data/`. Vor Updates sichern. |
|
||||
| Sitzungslimit | Eine Instanz akzeptiert bis zu 100 aktive Browser-Sitzungen. |
|
||||
|
||||
## Kürzlich zusammengeführte Beiträge
|
||||
|
||||
- Die Liste folgt den GitHub-Merge-Einträgen.
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) verbesserte Browser-Fehlermeldungen; [PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) korrigierte Skalierung, schwebendes Layout und Fußzeile der Startseite.
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [zusammengeführte PRs #13 und #15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep) zu vorhandenen TS6-Freigaben, Seitenverhältnis, mobiler Sprache/Bildschirm-Wachhalten/Skin-Menü, Kanaloptionen der Identität, PWA/Design, Chatverlauf, Mitglieder-Audiozuständen und Mikrofonberechtigungen.
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) ermöglichte Verbindungen über registrierte TeamSpeak-Nicknames und bewahrte Nickname-Ziele in Einstellungen, Favoriten und Einladungen.
|
||||
@@ -0,0 +1,329 @@
|
||||
# WebSpeak · English
|
||||
|
||||
[Project home](../README.md) · [简体中文](./README.zh-CN.md) · [Deutsch](./README.de.md) · [Русский](./README.ru.md) · [日本語](./README.ja.md)
|
||||
|
||||
WebSpeak is a self-hosted browser client and voice gateway for TeamSpeak 3 and TeamSpeak 6. Visitors can join channels without installing a desktop client, while administrators manage the target servers, access policy, and runtime state from the web console.
|
||||
|
||||
Latest release: [read the 0.2.7 changelog on this page](#latest-release-notes).
|
||||
|
||||
Skin authors should start with the [current skin development guide](./SKIN_DEVELOPMENT.md), which combines the `.wskin` package format, current runtime APIs, permission boundaries, and authoring workflow. The repository also includes the [WebSpeak skin development skill for agents](../.agents/skills/webspeak-skin-development/SKILL.md).
|
||||
|
||||
## Live demo
|
||||
|
||||
URL: <https://webspeak.online>
|
||||
|
||||
The public demo is hosted in Hong Kong and its network conditions and load may be unstable. Latency, disconnections, or temporary downtime do not represent every self-hosted deployment.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
| Capability | Description |
|
||||
| --- | --- |
|
||||
| TeamSpeak compatibility | Supports TeamSpeak 3 and TeamSpeak 6 and automatically detects the target protocol. |
|
||||
| Cross-platform P2P screen sharing | Browser users and native TeamSpeak 6 clients can start and watch each other's screen shares; WebRTC/ICE carries media directly while WebSpeak relays negotiation signaling only. |
|
||||
| IPv6 targets | IPv6 TeamSpeak targets and IPv6 addresses resolved from hostnames are supported by default. |
|
||||
| Channels and members | Browse the channel tree, see live member states, and switch channels. |
|
||||
| Realtime voice | Opus audio with a compatibility transport and optional bundled WebRTC low-latency transport. |
|
||||
| Audio controls | Select microphones and speakers, adjust volume, test the microphone, mute, use VOX, and control member volume. |
|
||||
| Browser-side noise suppression | Optional microphone noise suppression runs at the browser capture stage, without adding server-side audio processing. |
|
||||
| Messaging and actions | Channel chat, server chat, private messages, poke actions, and whisper targets. |
|
||||
| Desktop accompaniment | Select an audio-enabled window or browser tab and share its sound with the current channel. |
|
||||
| Identity and access | Remembered identity, visitor-defined targets, revocable expiring invite links, and TeamSpeak 3 identity import, conversion, validation, and export. |
|
||||
| Administration | Manage targets, access policy, public media address, IPv6 candidates, voice STUN, relays, invites, sessions, logs, diagnostics, and backups. |
|
||||
| Engineering structure | In 0.2.6, gateway voice, session events, audio, and screen-share coordination were split into modules; frontend voice and admin pages were decomposed into components, composables, and services, with lifecycle and reconnect tests. |
|
||||
| Skins | Protected Day, Night, and ILLUSIA skins, plus instance-managed `.wskin` appearances with administrator enable/default controls. |
|
||||
| User experience | Chinese, English, German, Russian, and Japanese UI with responsive desktop/mobile layouts. |
|
||||
| Self-hosting | Data stays with the operator; packages include Windows x64 and Linux x64/ARM64, Docker supports amd64/arm64, and Android APKs target arm64-v8a, armeabi-v7a, and x86_64. |
|
||||
|
||||
## 🖼️ Screenshots
|
||||
|
||||
The screenshots show the English welcome page, voice workspace, audio controls, and member menu.
|
||||
|
||||
### Welcome page
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-en-home.png" alt="WebSpeak English welcome page" width="100%" /></p>
|
||||
|
||||
### Voice workspace
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-en.png" alt="WebSpeak English voice workspace" width="100%" /></p>
|
||||
|
||||
### Audio controls
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-en-audio.png" alt="WebSpeak English audio controls" width="100%" /></p>
|
||||
|
||||
### Member menu
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-en-menu.png" alt="WebSpeak English member menu" width="100%" /></p>
|
||||
|
||||
## 🧩 Advanced features
|
||||
|
||||
These features are optional. WebSpeak continues to work with the compatibility voice transport when they are disabled. Configure them under **Administration → Servers**; saved changes apply to new connections.
|
||||
|
||||
### 1. WebRTC low-latency voice
|
||||
|
||||
WebRTC moves browser voice to a realtime media path and also enables desktop accompaniment. The current WebSpeak gateway provides it directly; no separate media server is required.
|
||||
|
||||
1. Sign in at `/admin` and open **Advanced settings** on the **Servers** page.
|
||||
2. While WebRTC is disabled, choose the UDP start and end ports. The default range is `40000–40099`.
|
||||
3. Allow the complete UDP range in the WebSpeak host's security group and firewall.
|
||||
4. Enable **WebRTC** and save. New visitors will negotiate WebRTC; unsupported browsers and networks fall back to the compatibility transport.
|
||||
|
||||
The port range is locked while WebRTC is enabled. Disable and save WebRTC before changing it, then update the firewall rules. Public deployments also need HTTPS.
|
||||
|
||||
### Voice WebRTC behind a reverse proxy or TCP tunnel
|
||||
|
||||
The WebRTC advanced settings now include a **public media address**, **IPv6 candidates**, and a **voice STUN server**. The media address must be a gateway IP or hostname reachable over UDP, without a scheme, path or port. It overrides the address inferred from `Origin`, `X-Forwarded-Host`, or `Host`; DNS names are resolved into IP candidates. IPv6 is opt-in and retains IPv4 candidates.
|
||||
|
||||
Set a UDP STUN URL such as `stun:turn.teamspeak.com:3478` to use the same discovery service in the browser and gateway. Empty preserves the previous behavior: the gateway library uses its built-in STUN service while the browser has none. The gateway requires an IPv4-reachable UDP STUN hostname or IPv4 address; IPv6 literals and TURN credentials are not accepted. IPv6 media candidates work independently of STUN. Save and reconnect to apply changes.
|
||||
|
||||
HTTP/WebSocket reachability does not imply media reachability. Allow the complete configured UDP range and preserve port numbers when using static port forwarding. STUN discovers mappings but cannot relay audio or traverse every NAT. Deployments with only a TCP tunnel and no usable UDP/IPv6 path still fall back to compatibility transport.
|
||||
|
||||
### Screen-share ICE candidates
|
||||
|
||||
Screen-share media still prefers a direct browser-to-browser path; WebSpeak only relays negotiation signaling. By default it uses TeamSpeak's public STUN services to discover server-reflexive candidates; STUN does not carry media. If the deployment has an authorized external TURN service, set `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS` before starting WebSpeak with a JSON array, for example:
|
||||
|
||||
```json
|
||||
[{"urls":"stun:turn.teamspeak.com:3478"},{"urls":"turns:turn.example.com:5349","username":"<username>","credential":"<credential>"}]
|
||||
```
|
||||
|
||||
With TURN configured, media may use that external TURN service but never the WebSpeak gateway; without it, only direct ICE paths and STUN are used.
|
||||
|
||||
### Cross-platform P2P screen sharing
|
||||
|
||||
Browser users and native TeamSpeak 6 clients can discover, start, and watch each other's screen shares. Screen media between browsers, and between a browser and a native client, is sent over a WebRTC/ICE peer-to-peer path whenever possible; WebSpeak handles session authorization, share state, and SDP/ICE signaling, but does not carry the screen media. The UI includes live status, viewer count, player volume, fullscreen, and exit controls. Share settings support up to 1080p and 60 FPS, with live WebRTC statistics for diagnosis.
|
||||
|
||||
### 2. Relay mode
|
||||
|
||||
Use a relay when a TeamSpeak server rejects connections from another region or when the direct path is unstable. It is not a VPN: it forwards only the TeamSpeak traffic of the current WebSpeak session, while the visitor still chooses the target server in the web page.
|
||||
|
||||
A relay instance is a dedicated forwarding service with no visitor page or administration console. It accepts only gateway sessions with a matching token. Use a random token of at least 16 characters.
|
||||
|
||||
#### Run from source
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm run build
|
||||
WEBSPEAK_MODE=relay \
|
||||
WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
WEBSPEAK_RELAY_HOST='0.0.0.0' \
|
||||
WEBSPEAK_RELAY_PORT='39087' \
|
||||
node dist/index.js
|
||||
```
|
||||
|
||||
Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
$env:WEBSPEAK_MODE = "relay"
|
||||
$env:WEBSPEAK_RELAY_TOKEN = "replace-with-a-long-random-token"
|
||||
$env:WEBSPEAK_RELAY_HOST = "0.0.0.0"
|
||||
$env:WEBSPEAK_RELAY_PORT = "39087"
|
||||
node .\dist\index.js
|
||||
```
|
||||
|
||||
#### Run from a release package
|
||||
|
||||
Download and extract the appropriate package from [Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest):
|
||||
|
||||
```bash
|
||||
# Linux
|
||||
export WEBSPEAK_MODE=relay
|
||||
export WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token'
|
||||
export WEBSPEAK_RELAY_HOST='0.0.0.0'
|
||||
export WEBSPEAK_RELAY_PORT='39087'
|
||||
./runtime/node ./dist/index.js
|
||||
```
|
||||
|
||||
On Windows PowerShell, set the same variables and run `.\runtime\node.exe .\dist\index.js`.
|
||||
|
||||
#### Run with Docker
|
||||
|
||||
```bash
|
||||
docker run -d --name webspeak-relay --restart unless-stopped --network host \
|
||||
-e WEBSPEAK_MODE=relay \
|
||||
-e WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
-e WEBSPEAK_RELAY_PORT='39087' \
|
||||
ghcr.io/echosixhiya/webspeak:latest
|
||||
```
|
||||
|
||||
Allow the relay host's UDP listen port, `39087` by default.
|
||||
|
||||
#### Enable it in the gateway
|
||||
|
||||
1. Open **Administration → Servers → Relay server** and add one or more nodes.
|
||||
2. Set a custom display name, endpoint such as `relay.example.com#39087`, and matching token for each node, then save.
|
||||
3. Visitors can choose direct access or one of the configured relays on the welcome page.
|
||||
|
||||
Disable and save the relay configuration to remove the relay option from the welcome page.
|
||||
|
||||
### 3. Dependencies and attribution
|
||||
|
||||
- The relay service is built into WebSpeak with Node.js standard libraries; it does not use GOST, sing-box, or another proxy framework.
|
||||
- WebRTC uses [werift](https://github.com/shinyoshiaki/werift-webrtc) `0.24.4`, whose upstream project is licensed under MIT.
|
||||
- TeamSpeak protocol connectivity uses the project-maintained [EchoSixHIYA/teamspeak-js](https://github.com/EchoSixHIYA/teamspeak-js) SDK fork.
|
||||
|
||||
## 🧾 Changelog
|
||||
|
||||
<a id="latest-release-notes"></a>
|
||||
|
||||
### [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7) · 2026-10-13
|
||||
|
||||
#### A more open skin system
|
||||
|
||||
- A more open skin editor and runtime now let authors customize the style and position of any component and add widgets.
|
||||
- After entering the voice panel, open a new administrator-console window in the same browser and sign in to activate the skin editor.
|
||||
- The KAAK skin is included as a development example.
|
||||
- Updated the skin development Agent Skill.
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- Server addresses can now be resolved through SRV records and TeamSpeak Nickname entries.
|
||||
- Free mode supports managing multiple server tabs; these controls are unavailable in fixed-server mode.
|
||||
- Added a screen-share bitrate option.
|
||||
- WebSpeak now saves entered channel passwords in the browser.
|
||||
- Locked channels now show a lock icon.
|
||||
- Chat history is now stored persistently.
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
- Fixed address parsing.
|
||||
- Fixed focus conflicts between volume controls and dragging member cards.
|
||||
- Fixed user status being incorrectly parsed as unknown.
|
||||
|
||||
### [v0.2.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.6) · 2026-10-08
|
||||
|
||||
Relative to 0.2.5, broadly refactored gateway voice, shared protocol, frontend voice workspace, and admin modules; fixed #6/#7/#10, implemented #9/#12 settings, and fixed the existing-TS6-share discovery case reported in PR #13. Improved Opus/session lifecycles and mobile controls. Packages: Windows x64, Linux x64/ARM64, Docker amd64/arm64, and Android arm64-v8a/armeabi-v7a/x86_64.
|
||||
|
||||
### [v0.2.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.5) · 2026-09-27
|
||||
|
||||
Added `.wskin` skins, administrator enable/default controls, and protected Day/Night/ILLUSIA built-ins; removed the unfinished Aurora Voice sample, fixed skin-load flashes, dark-control contrast, and voice-room artwork layering, and added the official skin-development Agent Skill.
|
||||
|
||||
### [v0.2.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.4) · 2026-09-22
|
||||
|
||||
Added cross-platform P2P screen sharing between browsers and native TeamSpeak 6 clients; added STUN/external-TURN configuration, live player and viewer state, 1080p/60 FPS capture settings, and WebRTC statistics; refined screen-share interactions and added visitor numbering.
|
||||
|
||||
### [v0.2.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.3) · 2026-09-19
|
||||
|
||||
Added channel member scheduling and permission-aware direct moves; added avatar, mute-state, and remembered-identity support; refreshed feature screenshots and documentation for all five languages.
|
||||
|
||||
### [v0.2.2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.2) · 2026-09-17
|
||||
|
||||
Added browser-side microphone noise suppression, Russian and Japanese UI, and per-language welcome text; refined volume interaction and error messages/codes on top of PR #2.
|
||||
|
||||
### [v0.2.1](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.1) · 2026-09-13
|
||||
|
||||
Improved welcome-page connection errors, preserved and safely truncated error codes, and added default IPv6 target support.
|
||||
|
||||
### [v0.2.0](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.0) · 2026-09-10
|
||||
|
||||
Added server-password prompts, formal relay mode, multiple relay selection, and administrator connection-reason reporting.
|
||||
|
||||
### [v0.1.8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.8) · 2026-09-08
|
||||
|
||||
Simplified Docker deployment, supported local TeamSpeak targets, added a 15-second connection timeout, and made network monitoring continuous.
|
||||
|
||||
### [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) · 2026-09-06
|
||||
|
||||
Added German, Telegram, network performance, and master-volume features; fixed accompaniment volume fluctuation.
|
||||
|
||||
### [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) · 2026-09-04
|
||||
|
||||
Added desktop accompaniment, remembered-identity guidance, and the site icon; fixed WebRTC member volume.
|
||||
|
||||
### [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) · 2026-09-04
|
||||
|
||||
Fixed identity persistence and refined the theme toggle.
|
||||
|
||||
### [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) · 2026-09-03
|
||||
|
||||
Fixed WebRTC and channel chat and refined administration, logs, and mobile layouts.
|
||||
|
||||
### [v0.1.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.3) · 2026-09-03
|
||||
|
||||
Added bundled WebRTC, migrated the TeamSpeak SDK, and improved member synchronization and voice buffering.
|
||||
|
||||
|
||||
## 🚀 Deployment
|
||||
|
||||
| Method | Best for | Environment |
|
||||
| --- | --- | --- |
|
||||
| Docker Compose (recommended) | Long-running servers, simple upgrades, and persistent data | Docker Engine + Docker Compose |
|
||||
| Release package | Running without Node.js or build dependencies | Windows x64 or Linux x64/ARM64 |
|
||||
| From source | Development, debugging, and customization | Node.js 22.5+, Git, and native build tools |
|
||||
|
||||
### Docker Compose (recommended)
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Open `http://<your-host>:3040` after startup. If using a reverse proxy, point it to that address. When WebRTC is enabled, allow the UDP range shown in the administration console. Data is stored in the `webspeak-data` volume.
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
docker compose logs -f webspeak
|
||||
```
|
||||
|
||||
Upgrade:
|
||||
|
||||
```bash
|
||||
git pull --ff-only
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Do not run `docker compose down -v`; it removes the database and administrator settings.
|
||||
|
||||
### Release package
|
||||
|
||||
Download the matching `windows-x64.zip`, `linux-x64.tar.gz`, or `linux-arm64.tar.gz` from [GitHub Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest). Extract it and run the included launcher. Packages include the Node.js runtime and production dependencies. Docker images support amd64/arm64.
|
||||
|
||||
Android APKs for `arm64-v8a`, `armeabi-v7a`, and `x86_64` are also attached. They use debug signing for sideload testing; they are not Google Play packages, and real-device voice still needs validation.
|
||||
|
||||
### From source
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
Building `@discordjs/opus` requires Python, Make, and a C/C++ toolchain.
|
||||
|
||||
### First-time setup
|
||||
|
||||
1. Open `http://<your-host>:3040/admin`.
|
||||
2. Sign in with `admin` / `admin` and immediately set a new password of at least 12 characters.
|
||||
3. Configure the TeamSpeak target and access mode under **Servers**, for example `voice.example.com#9987`.
|
||||
4. Configure HTTPS for public access; when WebRTC is enabled, allow the UDP range shown in the console.
|
||||
|
||||
## ⚠️ Requirements and notes
|
||||
|
||||
| Area | Requirement or note |
|
||||
| --- | --- |
|
||||
| Browser | Use a current Chrome, Edge, or other modern browser with WebRTC support. Microphone and window audio normally require HTTPS. |
|
||||
| TeamSpeak network | The WebSpeak host must reach the target TeamSpeak server; the default voice port is `9987`. |
|
||||
| Web network | The service uses `3040/TCP`; public deployments should expose the page and WebSocket through an HTTPS reverse proxy. |
|
||||
| IPv6 | Write literal targets as `[2001:db8::1]#9987`. The host/container needs routed IPv6, IPv6 enabled in the OS and Node.js, and the relevant firewall rules. |
|
||||
| WebRTC | The default range is `40000–40099/UDP`; allow it and disable WebRTC before changing the range. |
|
||||
| Remembered identity | One browser identity can hold one active remembered connection. Disable it for parallel connections or use another browser profile. |
|
||||
| Accompaniment | Desktop only and requires WebRTC. Enable audio sharing when selecting a window or tab. |
|
||||
| Data | Docker data is in `webspeak-data`; release packages and source installs use `data/`. Back up before upgrades. |
|
||||
| Session limit | One instance accepts up to 100 active browser sessions. |
|
||||
|
||||
## Recent contributors
|
||||
|
||||
- Listed from GitHub's merge records; the version summaries above describe only changes included in each release.
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) improved browser error translations; [PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) fixed scaling, floating layout, and the homepage footer.
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [merged PRs #13 and #15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep), covering existing TS6 share discovery, share aspect ratio, mobile voice/wake/skin-menu behavior, identity channel options, PWA/theme work, chat history, member audio states, and microphone permission.
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) added connections through registered TeamSpeak nicknames and preserved nickname targets in settings, favorites, and invitations.
|
||||
@@ -0,0 +1,208 @@
|
||||
# WebSpeak · 日本語
|
||||
|
||||
[プロジェクトトップ](../README.md) · [简体中文](./README.zh-CN.md) · [English](./README.en.md) · [Deutsch](./README.de.md) · [Русский](./README.ru.md)
|
||||
|
||||
## プロジェクト概要
|
||||
|
||||
最新リリース:[v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7)。
|
||||
|
||||
| 観点 | 説明 |
|
||||
| --- | --- |
|
||||
| **WHAT** | WebSpeak は TeamSpeak 3 / TeamSpeak 6 向けのセルフホスト型ブラウザクライアント兼音声ゲートウェイです。 |
|
||||
| **WHY** | デスクトップクライアントをインストールせず、ブラウザからチャンネルに参加できます。運用者はサーバーとデータを管理できます。 |
|
||||
| **HOW** | 起動後、管理コンソールで TeamSpeak の接続先とアクセス方針を設定します。ブラウザが画面と音声を担当し、WebSpeak がゲートウェイとして接続します。 |
|
||||
|
||||
## オンラインデモ
|
||||
|
||||
アドレス: <https://webspeak.online>
|
||||
|
||||
デモは香港にあります。ネットワークと負荷が不安定な場合があるため、遅延、切断、一時的な利用不可は各自の環境での動作を示すものではありません。
|
||||
|
||||
## ✨ 機能
|
||||
|
||||
| 機能 | 説明 |
|
||||
| --- | --- |
|
||||
| TeamSpeak | TeamSpeak 3 / 6 に対応し、対象プロトコルを自動検出します。 |
|
||||
| クロスプラットフォーム P2P 画面共有 | ブラウザユーザーと TeamSpeak 6 ネイティブクライアントが互いに画面共有を開始・視聴できます。メディアは WebRTC/ICE で直接送信し、WebSpeak はシグナリングだけを中継します。 |
|
||||
| IPv6 | IPv6 の接続先と DNS から解決された IPv6 アドレスに標準対応します。 |
|
||||
| チャンネルとメンバー | チャンネルツリー、リアルタイムのメンバー状態、チャンネル移動。 |
|
||||
| リアルタイム音声 | Opus、互換トランスポート、内蔵 WebRTC による低遅延音声。 |
|
||||
| 音声操作 | マイク、スピーカー、音量、VOX、ミュート、メンバーごとの音量調整。 |
|
||||
| ブラウザ側ノイズ抑制 | マイクのノイズ抑制をブラウザの音声取得段階で任意に使用でき、サーバー側の追加処理は不要です。 |
|
||||
| チャットと操作 | チャンネル/サーバーチャット、個人メッセージ、つつく、ウィスパー対象。 |
|
||||
| BGM共有 | デスクトップブラウザで音声付きウィンドウやタブの音をチャンネルに共有。 |
|
||||
| ID とアクセス | ID の保存、接続先の指定、期限・回数付き招待リンクに加え、TeamSpeak 3 ID のインポート、変換、検証、エクスポート。 |
|
||||
| 管理コンソール | 接続先、アクセス、公開メディアアドレス、IPv6 候補、音声 STUN、中継、招待、セッション、ログ、診断、バックアップ。 |
|
||||
| プロジェクト構造 | 0.2.6 では音声ゲートウェイ、セッションイベント、音声処理、画面共有調整を分割し、音声・管理画面をコンポーネント、composable、サービスに整理しました。ライフサイクルと再接続のテストも追加しました。 |
|
||||
| スキン | 保護された昼・夜・ILLUSIA スキンに加え、管理者が有効化とデフォルトを管理するインスタンス `.wskin` に対応。 |
|
||||
| インターフェース | 中文、English、Deutsch、Русский、日本語、レスポンシブ表示。 |
|
||||
| デプロイ | Windows x64、Linux x64/ARM64 パッケージ、Docker amd64/arm64、Android arm64-v8a・armeabi-v7a・x86_64 APK。 |
|
||||
|
||||
## 🖼️ インターフェースのスクリーンショット
|
||||
|
||||
日本語のホーム、音声ワークスペース、オーディオ設定、メンバー操作メニューを掲載しています。
|
||||
|
||||
### ホーム
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ja-home.png" alt="WebSpeak 日本語ホーム" width="100%" /></p>
|
||||
|
||||
### 音声ワークスペース
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ja.png" alt="WebSpeak 日本語音声ワークスペース" width="100%" /></p>
|
||||
|
||||
### オーディオ設定
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ja-audio.png" alt="WebSpeak 日本語オーディオ設定" width="100%" /></p>
|
||||
|
||||
### メンバーメニュー
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ja-menu.png" alt="WebSpeak 日本語メンバーメニュー" width="100%" /></p>
|
||||
|
||||
## 🧩 高度な機能
|
||||
|
||||
### WebRTC
|
||||
|
||||
**管理コンソール → サーバー → 詳細設定** で有効にします。無効の状態で UDP ポート範囲(初期値 `40000–40099`)を設定し、ファイアウォールで許可して保存してください。有効中は範囲がロックされ、新しい接続で WebRTC を使用します。非対応のブラウザは互換トランスポートに戻ります。公開サイトでは HTTPS が必要です。
|
||||
|
||||
### 画面共有の ICE 候補
|
||||
|
||||
画面共有のメディアは引き続きブラウザ間の直接接続を優先し、WebSpeak はシグナリングだけを中継します。初期状態では TeamSpeak の公開 STUN サービスで外部候補を検出します。STUN はメディアを運びません。認可済みの外部 TURN を使う場合は、起動前に `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS` を JSON 配列で設定できます。
|
||||
|
||||
```json
|
||||
[{"urls":"stun:turn.teamspeak.com:3478"},{"urls":"turns:turn.example.com:5349","username":"<username>","credential":"<credential>"}]
|
||||
```
|
||||
|
||||
TURN を設定した場合、メディアは外部 TURN サービスを経由することがありますが、WebSpeak ゲートウェイは経由しません。未設定時は直接接続と STUN のみを使用します。
|
||||
|
||||
### クロスプラットフォーム P2P 画面共有
|
||||
|
||||
ブラウザユーザーと TeamSpeak 6 ネイティブクライアントは、互いの画面共有を検出・開始・視聴できます。ブラウザ間、およびブラウザとネイティブクライアント間の画面メディアは、可能な限り WebRTC/ICE の直接接続で送信されます。WebSpeak はセッション認証、共有状態、SDP/ICE シグナリングを担当しますが、画面メディア自体は転送しません。画面には配信中の状態と視聴者数が表示され、音量、全画面、終了を操作できます。取得設定は最大 1080p / 60 FPS に対応し、WebRTC 統計も確認できます。
|
||||
|
||||
### 中継サーバー
|
||||
|
||||
中継は現在の WebSpeak セッションの TeamSpeak 通信だけを転送し、VPN ではありません。管理コンソールで複数のノードに名前、アドレス、トークンを設定すると、ユーザーは直接接続または中継を選択できます。中継モードは専用の転送サービスとして動作し、ゲスト画面や管理コンソールを提供しません。
|
||||
|
||||
中継サービスは WebSpeak に組み込まれており、Node.js の標準ライブラリを使用します。GOST や sing-box などのプロキシフレームワークは不要です。WebRTC は [werift](https://github.com/shinyoshiaki/werift-webrtc)、TeamSpeak 接続はプロジェクトが保守する [EchoSixHIYA/teamspeak-js](https://github.com/EchoSixHIYA/teamspeak-js) SDK を使用します。
|
||||
|
||||
## 🚀 デプロイ
|
||||
|
||||
| 方法 | 用途 |
|
||||
| --- | --- |
|
||||
| Docker Compose | 常時稼働サーバーと簡単な更新 |
|
||||
| Release パッケージ | Node.js やビルドツールを使わない起動 |
|
||||
| ソースから | 開発やカスタマイズ |
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
起動後に `http://<your-host>:3040/admin` を開き、`admin` / `admin` でログインして直ちにパスワードを変更し、TeamSpeak を設定します。データは `webspeak-data` volume に保存されます。データベースを消さない場合は `docker compose down -v` を実行しないでください。
|
||||
|
||||
### Release パッケージ
|
||||
|
||||
[Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) から `windows-x64.zip`、`linux-x64.tar.gz`、`linux-arm64.tar.gz` のいずれかを取得し、同梱ランチャーを実行します。Docker は amd64/arm64 に対応します。`arm64-v8a`、`armeabi-v7a`、`x86_64` の Android APK もあります。APK は手動インストールとテスト向けのデバッグ署名で、Google Play 用ではありません。実機 TeamSpeak 音声は未検証です。
|
||||
|
||||
### ソースから
|
||||
|
||||
```bash
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
## ⚠️ 要件と注意
|
||||
|
||||
- ソースからのビルドには Node.js `>=22.5` が必要です。Docker と Release には必要な実行環境が含まれます。
|
||||
- WebRTC に対応した最新の Chrome、Edge などを使用してください。マイクとウィンドウ音声には通常 HTTPS が必要です。
|
||||
- WebSpeak のホストから TeamSpeak に到達できる必要があります。標準音声ポートは `9987` です。
|
||||
- Web サービスは `3040/TCP` を使用します。公開時は HTTPS と WebSocket をリバースプロキシ経由で公開してください。
|
||||
- IPv6 にはルーティング可能な IPv6、OS/コンテナで有効な IPv6、適切なファイアウォール設定が必要です。リテラルは `[2001:db8::1]#9987` の形式です。
|
||||
- 保存したブラウザ ID は同じブラウザで同時に1接続だけ使用できます。
|
||||
- BGM共有はデスクトップのみで、WebRTC が必要です。
|
||||
|
||||
## コミュニティと関連プロジェクト
|
||||
|
||||
- [QQ グループ](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475)
|
||||
- [Telegram グループ](https://t.me/+8qShpTcuN9A3MWY9)
|
||||
- [NeteaseTSBot](https://github.com/yichen11818/NeteaseTSBot) — Web コンソール付き TeamSpeak 音楽ボット。
|
||||
|
||||
## 🧾 更新履歴
|
||||
|
||||
<a id="latest-release-notes"></a>
|
||||
|
||||
### [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7) · 2026-10-13
|
||||
|
||||
#### より開かれたスキンシステム
|
||||
|
||||
- より開かれたスキン編集・実行環境を提供し、任意のコンポーネントのスタイルや配置を変更したり、ウィジェットを追加したりできるようになりました。
|
||||
- 音声パネルに入った後、同じブラウザーで管理画面を新しいウィンドウに開いてログインすると、スキンエディターが有効になります。
|
||||
- 開発例として「KAAK」スキンを同梱しました。
|
||||
- スキン開発 Agent Skill を更新しました。
|
||||
|
||||
#### 機能強化
|
||||
|
||||
- SRV レコードと TeamSpeak Nickname 形式のサーバーアドレス解決に対応しました。
|
||||
- 自由モードでは複数サーバーのタブを管理できます。このボタンは「固定サーバー」モードでは使用できません。
|
||||
- 画面共有にビットレート設定を追加しました。
|
||||
- 入力したチャンネルパスワードを WebSpeak がブラウザーに保存するようになりました。
|
||||
- ロックされたチャンネルの前に鍵アイコンを表示します。
|
||||
- チャット履歴を永続的に保存するようになりました。
|
||||
|
||||
#### バグ修正
|
||||
|
||||
- アドレス解析の不具合を修正しました。
|
||||
- 音量操作とメンバーカードのドラッグでフォーカスが競合する問題を修正しました。
|
||||
- ユーザーステータスが誤って「不明」と解析される問題を修正しました。
|
||||
|
||||
### [v0.2.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.6) · 2026-10-08
|
||||
|
||||
0.2.5 から音声ゲートウェイ、共有プロトコル、音声ワークスペース、管理モジュールを大規模に再構成。#6/#7/#10 を修正し、#9/#12 を実装。PR #13 が報告した既存 TS6 画面共有の検出漏れも修正しました。Opus、セッションのライフサイクル、モバイル操作を改善。Windows x64、Linux x64/ARM64、Docker amd64/arm64、Android arm64-v8a/armeabi-v7a/x86_64 APK を提供。
|
||||
|
||||
### [v0.2.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.5) · 2026-09-27
|
||||
|
||||
`.wskin` スキン、管理者向けの有効化/デフォルト設定、保護された昼・夜・ILLUSIA 内蔵スキンを追加。未完成の Aurora Voice サンプルを削除し、読み込み時のちらつき、ダークモードの視認性、音声画面のアートレイヤーを修正。公式スキン開発 Agent Skill も追加しました。
|
||||
|
||||
### [v0.2.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.4) · 2026-09-22
|
||||
|
||||
ブラウザと TeamSpeak 6 ネイティブクライアント間のクロスプラットフォーム P2P 画面共有を追加しました。STUN/外部 TURN 設定、プレーヤーと視聴者状態、1080p/60 FPS 取得設定、WebRTC 統計に対応し、共有操作と訪問者番号も改善しました。
|
||||
|
||||
### [v0.2.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.3) · 2026-09-19
|
||||
|
||||
チャンネルメンバーの移動操作と権限に応じた直接移動を追加し、アバター表示、ミュート状態の同期、保存 ID の復元に対応しました。5 言語のスクリーンショットとドキュメントも更新しました。
|
||||
|
||||
### [v0.2.2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.2) · 2026-09-17
|
||||
|
||||
ブラウザ側マイクノイズ抑制、ロシア語・日本語 UI、言語別ウェルカム文を追加。音量操作と PR #2 を基にしたエラー表示・エラーコードを改善しました。
|
||||
|
||||
### [v0.2.1](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.1) · 2026-09-13
|
||||
|
||||
接続エラー表示を改善し、IPv6 接続先を標準対応しました。
|
||||
|
||||
### [v0.2.0](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.0) · 2026-09-10
|
||||
|
||||
パスワード案内、正式な中継モード、複数中継選択、接続診断を追加しました。
|
||||
|
||||
### [v0.1.8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.8) · 2026-09-08
|
||||
|
||||
Docker 起動を簡略化し、15秒の接続タイムアウトと継続的なネットワーク監視を追加しました。
|
||||
|
||||
|
||||
## ライセンス
|
||||
|
||||
WebSpeak は [GNU Affero General Public License v3.0 only](../LICENSE) の下で公開されています。
|
||||
|
||||
## 最近マージされた貢献
|
||||
|
||||
- GitHub のマージ記録に基づく一覧です。上のバージョン概要には、各リリースに実際に含まれる変更のみを記載しています。
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) でブラウザのエラー翻訳を改善し、[PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) で拡大縮小、フローティングレイアウト、ホームのフッターを修正。
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [マージ済み PR #13、#15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep)。既存 TS6 共有の検出、画面比率、モバイル音声・画面点灯・スキンメニュー、ID のチャンネル設定、PWA/テーマ、チャット履歴、メンバー音声状態、マイク権限などに貢献。
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) で TeamSpeak の登録済みニックネームによる接続に対応し、設定・お気に入り・招待リンクにニックネームの接続先を保持。
|
||||
@@ -0,0 +1,208 @@
|
||||
# WebSpeak · Русский
|
||||
|
||||
[Главная проекта](../README.md) · [简体中文](./README.zh-CN.md) · [English](./README.en.md) · [Deutsch](./README.de.md) · [日本語](./README.ja.md)
|
||||
|
||||
## О проекте
|
||||
|
||||
Последний выпуск: [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7).
|
||||
|
||||
| Логика | Описание |
|
||||
| --- | --- |
|
||||
| **WHAT** | WebSpeak — самостоятельно размещаемый веб-клиент и голосовой шлюз для TeamSpeak 3 и TeamSpeak 6. |
|
||||
| **WHY** | Пользователям не нужно устанавливать настольный клиент: достаточно открыть браузер, а оператор сохраняет контроль над сервером и данными. |
|
||||
| **HOW** | После запуска настройте цель TeamSpeak и политику доступа в панели администратора. Браузер отвечает за интерфейс и аудио, WebSpeak — за шлюз. |
|
||||
|
||||
## Онлайн-демо
|
||||
|
||||
Адрес: <https://webspeak.online>
|
||||
|
||||
Демо-сервер находится в Гонконге; сеть и нагрузка могут быть нестабильными. Задержки, разрывы или временная недоступность демо не характеризуют самостоятельное развертывание.
|
||||
|
||||
## ✨ Возможности
|
||||
|
||||
| Возможность | Описание |
|
||||
| --- | --- |
|
||||
| TeamSpeak | Поддержка TeamSpeak 3 и TeamSpeak 6 с автоматическим определением протокола. |
|
||||
| Кроссплатформенная P2P-трансляция экрана | Пользователи браузера и нативные клиенты TeamSpeak 6 могут запускать и смотреть трансляции друг друга; медиаданные идут напрямую по WebRTC/ICE, а WebSpeak передаёт только сигнальные сообщения. |
|
||||
| IPv6 | IPv6-цели и IPv6-адреса, полученные через DNS, поддерживаются по умолчанию. |
|
||||
| Каналы и участники | Дерево каналов, состояние участников в реальном времени и переход между каналами. |
|
||||
| Голос в реальном времени | Opus, совместимый транспорт и встроенный WebRTC с низкой задержкой. |
|
||||
| Управление аудио | Микрофон, динамики, громкость, VOX, отключение микрофона и отдельная громкость участников. |
|
||||
| Шумоподавление в браузере | Опциональное шумоподавление микрофона на этапе захвата в браузере без дополнительной обработки звука на сервере. |
|
||||
| Чат и действия | Чат канала и сервера, личные сообщения, толчки и цели шёпота. |
|
||||
| Фоновая музыка | На компьютере можно поделиться звуком окна или вкладки с текущим каналом. |
|
||||
| Идентичность и доступ | Сохранение идентичности, собственные цели, приглашения с ограничением срока и числа использований, а также импорт, преобразование, проверка и экспорт идентификаторов TeamSpeak 3. |
|
||||
| Панель администратора | Цели, доступ, публичный адрес медиа, IPv6-кандидаты, голосовой STUN, ретрансляторы, приглашения, сессии, логи, диагностика и резервные копии. |
|
||||
| Структура проекта | В 0.2.6 голосовой шлюз, события сессий, аудио и координация демонстрации разделены на модули; голосовые и административные страницы — на компоненты, composables и сервисы. Добавлены тесты жизненного цикла и переподключения. |
|
||||
| Скины | Защищённые дневная, ночная и ILLUSIA-темы, а также `.wskin` экземпляра с управлением включением и темой по умолчанию в панели администратора. |
|
||||
| Интерфейс | 中文, English, Deutsch, Русский и 日本語, адаптивная верстка. |
|
||||
| Развёртывание | Пакеты Windows x64 и Linux x64/ARM64, Docker amd64/arm64, Android APK для arm64-v8a, armeabi-v7a и x86_64. |
|
||||
|
||||
## 🖼️ Скриншоты интерфейса
|
||||
|
||||
Скриншоты показывают русскую главную страницу, голосовое пространство, настройки аудио и меню участника.
|
||||
|
||||
### Главная страница
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ru-home.png" alt="Главная страница WebSpeak на русском" width="100%" /></p>
|
||||
|
||||
### Голосовое пространство
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ru.png" alt="Русское голосовое пространство WebSpeak" width="100%" /></p>
|
||||
|
||||
### Настройки аудио
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ru-audio.png" alt="Настройки аудио WebSpeak на русском" width="100%" /></p>
|
||||
|
||||
### Меню участника
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-ru-menu.png" alt="Меню участника WebSpeak на русском" width="100%" /></p>
|
||||
|
||||
## 🧩 Расширенные функции
|
||||
|
||||
### WebRTC
|
||||
|
||||
Включается в **Панель администратора → Сервер → Расширенные настройки**. До включения задайте диапазон UDP-портов (по умолчанию `40000–40099`), откройте его в firewall и сохраните. При включённом WebRTC диапазон заблокирован; новые подключения используют WebRTC, а неподдерживаемые браузеры переходят на совместимый транспорт. Для публичного доступа нужен HTTPS.
|
||||
|
||||
### ICE для демонстрации экрана
|
||||
|
||||
Медиа демонстрации экрана по-прежнему предпочитает прямое соединение между браузерами; WebSpeak только передаёт сигнальные сообщения. По умолчанию используются публичные STUN-серверы TeamSpeak для поиска внешних кандидатов, STUN не передаёт медиаданные. Авторизованный внешний TURN можно задать через `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS` в виде JSON-массива, например:
|
||||
|
||||
```json
|
||||
[{"urls":"stun:turn.teamspeak.com:3478"},{"urls":"turns:turn.example.com:5349","username":"<username>","credential":"<credential>"}]
|
||||
```
|
||||
|
||||
При настроенном TURN медиа может идти через этот внешний сервис, но не через шлюз WebSpeak. Без TURN используются только прямые ICE-пути и STUN.
|
||||
|
||||
### Кроссплатформенная P2P-трансляция экрана
|
||||
|
||||
Пользователи браузера и нативные клиенты TeamSpeak 6 могут обнаруживать, запускать и смотреть трансляции друг друга. Между браузерами, а также между браузером и нативным клиентом, экран передаётся по прямому соединению WebRTC/ICE, когда это возможно; WebSpeak отвечает за авторизацию сессии, состояние трансляции и передачу SDP/ICE-сигналов, но не переносит медиаданные экрана. Интерфейс показывает статус трансляции и число зрителей и предоставляет регулировку громкости, полноэкранный режим и выход. Для захвата доступны настройки до 1080p и 60 FPS, а также статистика WebRTC.
|
||||
|
||||
### Ретрансляторы
|
||||
|
||||
Ретранслятор передаёт только TeamSpeak-трафик текущей сессии и не является VPN. В панели администратора добавьте один или несколько узлов, задайте имя, адрес и токен. Пользователь сможет выбрать прямое подключение или настроенный ретранслятор. Режим ретранслятора запускается отдельно и не предоставляет страницу посетителя или панель администратора.
|
||||
|
||||
Сервис ретрансляции встроен в WebSpeak и использует стандартные библиотеки Node.js; GOST, sing-box и другие прокси-фреймворки не требуются. WebRTC использует [werift](https://github.com/shinyoshiaki/werift-webrtc), а TeamSpeak — поддерживаемый проектом [SDK EchoSixHIYA/teamspeak-js](https://github.com/EchoSixHIYA/teamspeak-js).
|
||||
|
||||
## 🚀 Развертывание
|
||||
|
||||
| Способ | Подходит для |
|
||||
| --- | --- |
|
||||
| Docker Compose | Постоянного сервера и простых обновлений |
|
||||
| Пакет Release | Запуска без Node.js и инструментов сборки |
|
||||
| Из исходников | Разработки и настройки проекта |
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
После запуска откройте `http://<ваш-хост>:3040/admin`, войдите с `admin` / `admin`, сразу смените пароль и настройте TeamSpeak. Данные хранятся в volume `webspeak-data`. Не используйте `docker compose down -v`, если не хотите удалить базу и настройки.
|
||||
|
||||
### Пакет Release
|
||||
|
||||
Скачайте подходящий пакет `windows-x64.zip`, `linux-x64.tar.gz` или `linux-arm64.tar.gz` из [Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) и запустите приложенный скрипт. Docker поддерживает amd64/arm64. Также доступны Android APK для `arm64-v8a`, `armeabi-v7a` и `x86_64`; они подписаны отладочным ключом для ручной установки и тестирования, а не для Google Play. Голос TeamSpeak на реальных устройствах пока не проверен.
|
||||
|
||||
### Из исходников
|
||||
|
||||
```bash
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
## ⚠️ Требования и замечания
|
||||
|
||||
- Node.js `>=22.5` нужен для сборки из исходников; Docker и Release уже содержат необходимые компоненты.
|
||||
- Нужен современный Chrome, Edge или другой браузер с WebRTC. Микрофон и звук окна обычно требуют HTTPS.
|
||||
- WebSpeak должен иметь доступ к TeamSpeak; стандартный голосовой порт — `9987`.
|
||||
- Веб-сервис использует `3040/TCP`; для публичного сайта направьте HTTPS и WebSocket через обратный прокси.
|
||||
- Для IPv6 нужен маршрутизируемый IPv6, включённый IPv6 в ОС/контейнере и правила firewall. Литерал задаётся как `[2001:db8::1]#9987`.
|
||||
- Одна сохранённая браузерная идентичность может использоваться только одним активным подключением.
|
||||
- Фоновая музыка доступна только на компьютере и требует WebRTC.
|
||||
|
||||
## Сообщество и проекты
|
||||
|
||||
- [QQ-группа](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475)
|
||||
- [Telegram-группа](https://t.me/+8qShpTcuN9A3MWY9)
|
||||
- [NeteaseTSBot](https://github.com/yichen11818/NeteaseTSBot) — музыкальный бот для TeamSpeak с веб-консолью.
|
||||
|
||||
## 🧾 История изменений
|
||||
|
||||
<a id="latest-release-notes"></a>
|
||||
|
||||
### [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7) · 2026-10-13
|
||||
|
||||
#### Более открытая система скинов
|
||||
|
||||
- Более открытый редактор и среда выполнения скинов позволяют настраивать стиль и расположение любых компонентов, а также добавлять виджеты.
|
||||
- Откройте голосовую панель, затем в том же браузере откройте новое окно панели администратора и войдите в систему, чтобы активировать редактор скинов.
|
||||
- Скин KAAK включён в комплект как пример для разработки.
|
||||
- Обновлён Agent Skill по разработке скинов.
|
||||
|
||||
#### Улучшения функций
|
||||
|
||||
- Добавлено разрешение серверных адресов через записи SRV и записи TeamSpeak Nickname.
|
||||
- В свободном режиме можно управлять вкладками нескольких серверов; эти кнопки недоступны в режиме фиксированного сервера.
|
||||
- Добавлен выбор битрейта демонстрации экрана.
|
||||
- WebSpeak теперь сохраняет введённые пароли каналов в браузере.
|
||||
- Перед закрытыми паролем каналами отображается значок замка.
|
||||
- История чата теперь хранится постоянно.
|
||||
|
||||
#### Исправления ошибок
|
||||
|
||||
- Исправлена ошибка разбора адресов.
|
||||
- Устранён конфликт фокуса между регулировкой громкости и перетаскиванием карточек участников.
|
||||
- Исправлена ошибочная классификация состояния пользователя как неизвестного.
|
||||
|
||||
### [v0.2.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.6) · 2026-10-08
|
||||
|
||||
Относительно 0.2.5 масштабно перестроены голосовой шлюз, общие протоколы, голосовая область и модули администратора; исправлены #6/#7/#10, реализованы #9/#12 и случай с обнаружением уже активной демонстрации TS6 из PR #13. Улучшены Opus, жизненные циклы сессий и мобильное управление. Пакеты: Windows x64, Linux x64/ARM64, Docker amd64/arm64, Android arm64-v8a/armeabi-v7a/x86_64.
|
||||
|
||||
### [v0.2.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.5) · 2026-09-27
|
||||
|
||||
Добавлены скины `.wskin`, управление включением и темой по умолчанию, а также защищённые темы «День», «Ночь» и ILLUSIA; удалён незавершённый пример Aurora Voice, исправлены мерцание при загрузке скина, контраст элементов в тёмном режиме и слои иллюстраций в голосовом пространстве; добавлен официальный Agent Skill для разработки скинов.
|
||||
|
||||
### [v0.2.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.4) · 2026-09-22
|
||||
|
||||
Добавлена кроссплатформенная P2P-трансляция экрана между браузерами и нативными клиентами TeamSpeak 6; добавлены настройка STUN/внешнего TURN, проигрыватель и состояние зрителей, захват до 1080p/60 FPS и статистика WebRTC; улучшено управление трансляцией и добавлен номер посетителя.
|
||||
|
||||
### [v0.2.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.3) · 2026-09-19
|
||||
|
||||
Добавлены управление перемещением участников и прямое перемещение с учётом прав; поддержаны аватары, синхронизация микрофона и восстановление идентичности; обновлены скриншоты и документация для пяти языков.
|
||||
|
||||
### [v0.2.2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.2) · 2026-09-17
|
||||
|
||||
Добавлены браузерное шумоподавление микрофона, русский и японский интерфейсы и отдельные тексты приветствия; улучшены управление громкостью и сообщения/коды ошибок на основе PR #2.
|
||||
|
||||
### [v0.2.1](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.1) · 2026-09-13
|
||||
|
||||
Улучшены ошибки на странице входа и добавлена поддержка IPv6-целей по умолчанию.
|
||||
|
||||
### [v0.2.0](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.0) · 2026-09-10
|
||||
|
||||
Добавлены подсказки пароля, режим ретранслятора, выбор нескольких узлов и диагностика подключений.
|
||||
|
||||
### [v0.1.8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.8) · 2026-09-08
|
||||
|
||||
Упрощён Docker-запуск, добавлен тайм-аут подключения 15 секунд и непрерывный сетевой мониторинг.
|
||||
|
||||
|
||||
## Лицензия
|
||||
|
||||
WebSpeak распространяется по [GNU Affero General Public License v3.0 only](../LICENSE).
|
||||
|
||||
## Недавно объединённые вклады
|
||||
|
||||
- Список составлен по записям о слиянии на GitHub; сводки выше описывают только изменения, вошедшие в соответствующий релиз.
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) улучшил переводы ошибок браузера; [PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) исправил масштабирование, плавающую компоновку и нижний колонтитул главной страницы.
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [объединённые PR #13 и #15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep): обнаружение активных трансляций TS6, пропорции экрана, мобильное аудио/подсветка экрана/меню скинов, канал в настройках идентичности, PWA/темы, история чата, состояние аудио участников и разрешение микрофона.
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) добавил подключение по зарегистрированным именам TeamSpeak и сохранение имени цели в настройках, избранном и приглашениях.
|
||||
@@ -0,0 +1,331 @@
|
||||
# WebSpeak · 简体中文
|
||||
|
||||
[返回项目首页](../README.md) · [English](./README.en.md) · [Deutsch](./README.de.md) · [Русский](./README.ru.md) · [日本語](./README.ja.md)
|
||||
|
||||
WebSpeak 是一个可自行部署的 TeamSpeak 3 / TeamSpeak 6 网页客户端与语音网关。用户无需安装桌面客户端即可从浏览器加入频道,管理员可以在控制台管理目标服务器、访问方式和运行状态。
|
||||
|
||||
皮肤开发请从[当前皮肤开发指南](./SKIN_DEVELOPMENT.md)开始。它整合 `.wskin` 包格式、当前运行时接口、权限边界和制作验收流程。Agent 工作流见[WebSpeak Skin Development Skill](../.agents/skills/webspeak-skin-development/SKILL.md)。
|
||||
|
||||
## 在线 Demo
|
||||
|
||||
地址:<https://webspeak.online>
|
||||
|
||||
公共 Demo 位于香港,网络和负载可能不稳定。延迟、断线或暂时不可用不代表自行部署后的实际表现。
|
||||
|
||||
最新版本:[查看本页的 0.2.7 更新日志](#latest-release-notes)。
|
||||
|
||||
## ✨ 特性
|
||||
|
||||
| 能力 | 说明 |
|
||||
| --- | --- |
|
||||
| TeamSpeak 兼容 | 支持 TeamSpeak 3 与 TeamSpeak 6,并自动探测目标服务器协议。 |
|
||||
| 跨端 P2P 屏幕共享 | 支持浏览器用户与 TeamSpeak 6 原生客户端互相发起和观看屏幕共享;媒体优先通过 WebRTC/ICE 直连,WebSpeak 仅转发协商信令。 |
|
||||
| IPv6 目标 | 默认支持 IPv6 TeamSpeak 目标和域名解析出的 IPv6 地址。 |
|
||||
| 频道与成员 | 浏览频道树、查看实时成员状态并切换频道。 |
|
||||
| 实时语音 | 使用 Opus,支持兼容传输和可选的内置 WebRTC 低延迟传输。 |
|
||||
| 音频控制 | 选择麦克风与扬声器、调节音量、测试麦克风、闭麦、VOX 和成员独立音量。 |
|
||||
| 浏览器端降噪 | 提供可开关的麦克风降噪,在浏览器采集端处理,不增加服务器端音频处理压力。 |
|
||||
| 消息与互动 | 支持频道消息、服务器消息、私聊、戳一戳和耳语目标。 |
|
||||
| 桌面端伴奏 | 在桌面浏览器选择带音频的窗口或标签页,将声音分享给当前频道。 |
|
||||
| 身份与访问 | 支持身份保持、访客自定义目标、可撤销/可过期邀请链接,以及 TeamSpeak 3 身份导入、转换、校验与导出。 |
|
||||
| 工程结构 | 0.2.6 将网关语音、会话事件、音频和屏幕共享拆分为独立模块;前端语音与管理页拆分为组件、composables 和服务,并补充生命周期与重连测试。 |
|
||||
| 管理控制台 | 管理目标、访问策略、WebRTC、中继、邀请、会话、日志、诊断和备份。 |
|
||||
| 皮肤 | 提供日间、夜间和 ILLUSIA 三款受保护皮肤,并支持实例自定义 `.wskin` 外观与管理员默认/启用管理。 |
|
||||
| 界面体验 | 提供中文、English、Deutsch、Русский、日本語及响应式桌面/移动布局。 |
|
||||
| 自托管 | 数据由部署者保存,支持 Docker amd64/arm64、Windows x64、Linux x64/ARM64 服务端包和 Android 客户端。 |
|
||||
|
||||
## 🖼️ 界面截图
|
||||
|
||||
以下截图展示中文界面的欢迎页、语音工作区、音量控制和成员操作菜单。
|
||||
|
||||
### 欢迎页
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-zh-home.png" alt="WebSpeak 中文欢迎页" width="100%" /></p>
|
||||
|
||||
### 语音工作区
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-zh.png" alt="WebSpeak 中文语音工作区" width="100%" /></p>
|
||||
|
||||
### 音量控制
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-zh-audio.png" alt="WebSpeak 中文音量控制" width="100%" /></p>
|
||||
|
||||
### 成员菜单
|
||||
|
||||
<p align="center"><img src="./screenshots/webspeak-zh-menu.png" alt="WebSpeak 中文成员菜单" width="100%" /></p>
|
||||
|
||||
## 🧩 高级功能
|
||||
|
||||
高级功能均为可选项;关闭时仍可使用兼容语音传输。配置入口在管理员控制台的“服务器”页,保存后对新连接生效。
|
||||
|
||||
### 1. WebRTC 低延迟语音
|
||||
|
||||
WebRTC 将浏览器语音切换到实时媒体通道,也支持桌面端伴奏。媒体服务由当前 WebSpeak 网关直接提供,不需要另设媒体服务器。
|
||||
|
||||
1. 登录 `/admin`,打开“服务器”页的“高级参数”。
|
||||
2. 关闭 WebRTC 时设置 UDP 起止端口,默认范围为 `40000–40099`。
|
||||
3. 在 WebSpeak 主机的安全组和防火墙中放行整个 UDP 范围。
|
||||
4. 勾选“启用 WebRTC”并保存,用户重新进入后即可协商;不支持时会回退到兼容传输。
|
||||
|
||||
WebRTC 启用后端口范围会锁定。要修改端口,先关闭 WebRTC 并保存,再修改端口并同步防火墙规则。公网使用还需要 HTTPS。
|
||||
|
||||
### 反向代理 / TCP 隧道下的语音 WebRTC
|
||||
|
||||
在管理后台的 WebRTC 高级参数中可设置:
|
||||
|
||||
- **公网媒体地址**:WebSpeak 网关可被 UDP 访问的 IP 或域名,不含协议、路径或端口。优先于网页入口推断;留空时按 `Origin`、`X-Forwarded-Host`、`Host` 推断。域名会解析为 IP 候选。反代域名不一定是媒体地址。
|
||||
- **启用 IPv6 候选**:默认关闭;开启后保留 IPv4,同时收集 IPv6。需确保 IPv6 路由及 UDP 防火墙放行。
|
||||
- **语音 STUN 服务**:可设置 `stun:turn.teamspeak.com:3478`,浏览器和网关使用同一服务发现公网映射。留空保留旧行为:werift 网关仍使用库内置 STUN,浏览器不配置 STUN。当前字段仅支持可通过 IPv4 访问的 UDP STUN 域名或 IPv4 地址,不接受 IPv6 字面量、TURN 或凭据;IPv6 媒体候选独立于 STUN 开关。
|
||||
|
||||
保存后重新连接。网页和 WebSocket 经反代可达,不代表媒体 UDP 可达;STUN 仅发现地址,不中继音频,也不保证穿透所有 NAT。只有 TCP 隧道而无可用 UDP/IPv6 路径时,仍会回退兼容传输。应开放配置的整个 UDP 端口范围;静态端口转发需保持相同端口映射。
|
||||
|
||||
### 屏幕共享的 ICE 候选
|
||||
|
||||
屏幕共享媒体仍优先走浏览器之间的直连,WebSpeak 只转发协商信令。默认使用 TeamSpeak 官方 STUN 服务发现公网候选地址;STUN 不承载媒体。若部署者有合规的外部 TURN 服务,可在启动 WebSpeak 前设置 `WEBSPEAK_SCREEN_SHARE_ICE_SERVERS`,值为 JSON 数组,例如:
|
||||
|
||||
```json
|
||||
[{"urls":"stun:turn.teamspeak.com:3478"},{"urls":"turns:turn.example.com:5349","username":"<username>","credential":"<credential>"}]
|
||||
```
|
||||
|
||||
配置 TURN 后,媒体可能经过该外部 TURN 服务,但不会经过 WebSpeak 网关;未配置时只使用直连和 STUN。
|
||||
|
||||
### 跨端 P2P 屏幕共享
|
||||
|
||||
浏览器用户与 TeamSpeak 6 原生客户端可以互相发现、发起和观看屏幕共享。浏览器之间以及浏览器与原生客户端之间的屏幕媒体优先通过 WebRTC/ICE 端到端传输;WebSpeak 负责会话鉴权、共享状态和 SDP/ICE 信令转发,不承载屏幕媒体流量。页面提供直播状态、观众人数、播放器音量、全屏和退出控制,也可在共享设置窗口中选择最高 1080p 与 60 FPS,并查看 WebRTC 统计。
|
||||
|
||||
### 2. 中继模式
|
||||
|
||||
中继适用于 TeamSpeak 拒绝境外连接或直连不稳定的情况。它不是 VPN,只转发当前 WebSpeak 会话的 TeamSpeak 数据;目标服务器仍由用户在网页中选择。
|
||||
|
||||
中继实例是专用转发服务,不提供前台和管理员后台,只接受带匹配令牌的 WebSpeak 网关会话。令牌至少使用 16 个字符的随机值。
|
||||
|
||||
#### 源码启动
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm run build
|
||||
WEBSPEAK_MODE=relay \
|
||||
WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
WEBSPEAK_RELAY_HOST='0.0.0.0' \
|
||||
WEBSPEAK_RELAY_PORT='39087' \
|
||||
node dist/index.js
|
||||
```
|
||||
|
||||
Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
$env:WEBSPEAK_MODE = "relay"
|
||||
$env:WEBSPEAK_RELAY_TOKEN = "replace-with-a-long-random-token"
|
||||
$env:WEBSPEAK_RELAY_HOST = "0.0.0.0"
|
||||
$env:WEBSPEAK_RELAY_PORT = "39087"
|
||||
node .\dist\index.js
|
||||
```
|
||||
|
||||
#### 发布包启动
|
||||
|
||||
从 [Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) 下载并解压对应平台的包:
|
||||
|
||||
```bash
|
||||
# Linux
|
||||
export WEBSPEAK_MODE=relay
|
||||
export WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token'
|
||||
export WEBSPEAK_RELAY_HOST='0.0.0.0'
|
||||
export WEBSPEAK_RELAY_PORT='39087'
|
||||
./runtime/node ./dist/index.js
|
||||
```
|
||||
|
||||
Windows PowerShell 使用同名环境变量后运行 `.\runtime\node.exe .\dist\index.js`。
|
||||
|
||||
#### Docker 启动
|
||||
|
||||
```bash
|
||||
docker run -d --name webspeak-relay --restart unless-stopped --network host \
|
||||
-e WEBSPEAK_MODE=relay \
|
||||
-e WEBSPEAK_RELAY_TOKEN='replace-with-a-long-random-token' \
|
||||
-e WEBSPEAK_RELAY_PORT='39087' \
|
||||
ghcr.io/echosixhiya/webspeak:latest
|
||||
```
|
||||
|
||||
放行中继主机的 UDP 监听端口,默认是 `39087`。
|
||||
|
||||
#### 在网关中启用
|
||||
|
||||
1. 管理员控制台 → “服务器” → “中继服务器”,添加一个或多个节点。
|
||||
2. 为每个节点填写自定义名称、地址(例如 `relay.example.com#39087`)和匹配令牌并保存。
|
||||
3. 访客欢迎页即可选择直连或其中一个中继。
|
||||
|
||||
关闭并保存中继配置后,访客页面不会显示中继选项。
|
||||
|
||||
### 3. 依赖与归属
|
||||
|
||||
- 中继服务是 WebSpeak 自带实现,使用 Node.js 标准库,不依赖 GOST、sing-box 或其他代理框架。
|
||||
- WebRTC 使用 [werift](https://github.com/shinyoshiaki/werift-webrtc) `0.24.4`,上游采用 MIT 许可证。
|
||||
- TeamSpeak 协议使用项目维护的 [EchoSixHIYA/teamspeak-js](https://github.com/EchoSixHIYA/teamspeak-js) SDK fork。
|
||||
|
||||
## 🧾 更新日志
|
||||
|
||||
<a id="latest-release-notes"></a>
|
||||
|
||||
### [v0.2.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.7) · 2026-10-13
|
||||
|
||||
#### 更开放的皮肤系统
|
||||
|
||||
- 现在提供更开放的皮肤编辑系统与运行支持,可以自定义任意组件的样式与位置并可添加小组件。
|
||||
- 进入语音面板后,在同一个浏览器中新开并登录一个管理员后台窗口即可激活皮肤编辑器。
|
||||
- 随包提供一款“KAAK”皮肤作为开发示例。
|
||||
- 更新了皮肤开发 Agent Skill。
|
||||
|
||||
#### 功能增强
|
||||
|
||||
- 现在支持 SRV 和 Nickname 形式的服务器地址解析。
|
||||
- 自由模式下,允许用户进行多服务器标签管理(这些按钮在“固定服务器”的模式下不可用)。
|
||||
- 屏幕共享新增码率选项。
|
||||
- 现在 WebSpeak 会将输入过的频道密码保存到浏览器中。
|
||||
- 现在会在上锁的频道前显示带锁的图标。
|
||||
- 现在聊天记录能够持久化存储了。
|
||||
|
||||
#### Bug 修复列表
|
||||
|
||||
- 修复了解析 bug。
|
||||
- 修复了音量和卡片拖动争抢焦点的问题。
|
||||
- 修复了用户状态被错误地解析为未知的问题。
|
||||
|
||||
### [v0.2.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.6) · 2026-10-08
|
||||
|
||||
相对 0.2.5 大范围重构语音网关、共享协议、前端语音工作区与管理模块;修复 #6/#7/#10,完成 #9/#12 配置,并修复 PR #13 报告的既有 TS6 屏幕共享漏发现问题;改善 Opus/重连生命周期和移动端控制。提供 Windows x64、Linux x64/ARM64、Docker amd64/arm64,以及 Android arm64-v8a、armeabi-v7a、x86_64 APK。
|
||||
|
||||
### [v0.2.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.5) · 2026-09-27
|
||||
|
||||
新增 `.wskin` 皮肤系统、管理员启用/默认管理和受保护的日间/夜间/ILLUSIA 内置皮肤;移除未完成 Aurora Voice 样例,修复皮肤加载闪烁、暗色控件可读性与语音界面美术层级,并加入官方皮肤开发 Agent Skill。
|
||||
|
||||
### [v0.2.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.4) · 2026-09-22
|
||||
|
||||
新增浏览器与 TeamSpeak 6 原生客户端之间的跨端 P2P 屏幕共享;提供 STUN/外部 TURN 配置、直播播放器、观众状态、1080p/60 FPS 采集设置和 WebRTC 统计;优化屏幕共享交互并新增访客编号。
|
||||
|
||||
### [v0.2.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.3) · 2026-09-19
|
||||
|
||||
新增频道成员调度与按权限直接移动;支持头像、静音状态同步和身份恢复;更新五种语言的功能截图与文档。
|
||||
|
||||
### [v0.2.2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.2) · 2026-09-17
|
||||
|
||||
提供浏览器端麦克风降噪、俄语和日语支持及按语言欢迎词配置;优化音量交互和 PR #2 基础上的错误提示与错误代码。
|
||||
|
||||
### [v0.2.1](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.1) · 2026-09-13
|
||||
|
||||
优化首页连接错误显示,保留并安全截断错误代码;默认支持 IPv6 TeamSpeak 目标。
|
||||
|
||||
### [v0.2.0](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.2.0) · 2026-09-10
|
||||
|
||||
增加服务器密码提示、正式中继部署模式、多中继选择和管理员日志原因显示。
|
||||
|
||||
### [v0.1.8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.8) · 2026-09-08
|
||||
|
||||
简化 Docker 部署,支持同机 TeamSpeak,增加 15 秒连接超时和持续网络监测。
|
||||
|
||||
### [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) · 2026-09-06
|
||||
|
||||
增加德语、Telegram、网络性能面板和整体音量;修复伴奏音量波动。
|
||||
|
||||
### [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) · 2026-09-04
|
||||
|
||||
增加桌面端伴奏、身份保持提醒和网站图标;修复 WebRTC 成员独立音量。
|
||||
|
||||
### [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) · 2026-09-04
|
||||
|
||||
修复身份保存逻辑并优化主题切换。
|
||||
|
||||
### [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) · 2026-09-03
|
||||
|
||||
修复 WebRTC、频道聊天并优化管理页、日志和移动端布局。
|
||||
|
||||
### [v0.1.3](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.3) · 2026-09-03
|
||||
|
||||
引入内置 WebRTC、迁移 TeamSpeak SDK 并改善成员同步和语音缓冲。
|
||||
|
||||
|
||||
## 🚀 部署方案
|
||||
|
||||
| 方案 | 适用场景 | 环境 |
|
||||
| --- | --- | --- |
|
||||
| Docker Compose(推荐) | 长期运行、升级简单、数据持久化 | Docker Engine + Docker Compose |
|
||||
| 发布包 | 不安装 Node.js 和构建依赖 | Windows x64 或 Linux x64/ARM64 |
|
||||
| 源码运行 | 开发、调试和二次开发 | Node.js 22.5+、Git 和本地编译工具 |
|
||||
|
||||
### Docker Compose(推荐)
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
启动后访问 `http://<你的主机>:3040`。使用反向代理时将上游指向该地址;启用 WebRTC 时放行控制台显示的 UDP 端口范围。数据保存在 `webspeak-data` volume 中。
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
docker compose logs -f webspeak
|
||||
```
|
||||
|
||||
升级:
|
||||
|
||||
```bash
|
||||
git pull --ff-only
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
不要执行 `docker compose down -v`,否则会删除数据库和管理员设置。
|
||||
|
||||
### 发布包
|
||||
|
||||
从 [GitHub Releases](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/latest) 下载与系统和架构匹配的 `windows-x64.zip`、`linux-x64.tar.gz` 或 `linux-arm64.tar.gz`,解压后运行对应启动脚本。发布包自带 Node.js 运行时和生产依赖。Docker 镜像支持 amd64/arm64。
|
||||
|
||||
Release 同时提供 Android `arm64-v8a`、`armeabi-v7a` 和 `x86_64` APK。它们使用 debug 签名,可手动侧载测试;不是 Google Play 发布包,Android 真机语音仍需验收。
|
||||
|
||||
### 源码运行
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
|
||||
cd WebSpeak-client-for-TeamSpeak
|
||||
npm ci --ignore-scripts
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts
|
||||
npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
构建 `@discordjs/opus` 需要 Python、Make 和 C/C++ 编译工具。
|
||||
|
||||
### 首次配置
|
||||
|
||||
1. 打开 `http://<你的主机>:3040/admin`。
|
||||
2. 使用默认账号 `admin` / `admin` 登录,并立即设置至少 12 位的新密码。
|
||||
3. 在“服务器”页配置 TeamSpeak 目标和访问方式,例如 `voice.example.com#9987`。
|
||||
4. 公网使用时配置 HTTPS;启用 WebRTC 时放行控制台显示的 UDP 范围。
|
||||
|
||||
## ⚠️ 要求和注意事项
|
||||
|
||||
| 项目 | 要求或注意事项 |
|
||||
| --- | --- |
|
||||
| 浏览器 | 建议使用最新版 Chrome、Edge 或其他支持 WebRTC 的现代浏览器。麦克风和窗口音频通常要求 HTTPS。 |
|
||||
| TeamSpeak 网络 | WebSpeak 主机必须能够访问目标 TeamSpeak;默认语音端口为 `9987`。 |
|
||||
| Web 服务网络 | 服务使用 `3040/TCP`,公网建议通过 HTTPS 反向代理提供网页和 WebSocket。 |
|
||||
| IPv6 | IPv6 字面量写为 `[2001:db8::1]#9987`。主机/容器需要可路由 IPv6、启用 IPv6 的操作系统和 Node.js,以及相应防火墙放行。 |
|
||||
| WebRTC | 默认使用 `40000–40099/UDP`,启用后需放行整个范围;修改范围前先关闭 WebRTC。 |
|
||||
| 身份保持 | 同一浏览器身份同时只能保持一条活动连接;并行连接请关闭第二条的身份保持或使用其他浏览器配置文件。 |
|
||||
| 伴奏 | 仅桌面端提供且要求 WebRTC;选择窗口或标签页时还要勾选共享音频。 |
|
||||
| 数据 | Docker 数据在 `webspeak-data` volume;发布包和源码运行数据在 `data/`。升级前建议备份。 |
|
||||
| 会话上限 | 单实例最多允许 100 个活动网页会话。 |
|
||||
|
||||
## 近期合并贡献者
|
||||
|
||||
- 以下依据 GitHub 合并记录列出。
|
||||
- [LainHE](https://github.com/LainHE) — [PR #2](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/2) 改进浏览器端报错翻译;[PR #8](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/8) 修正缩放、浮动布局和首页脚注。
|
||||
- [TimmySheep](https://github.com/TimmySheep) — [已合并 PR #13、#15–#24](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pulls?q=is%3Apr+is%3Amerged+author%3ATimmySheep),涉及 TS6 既有屏幕共享发现、屏幕比例、移动端语音/常亮/皮肤菜单、身份频道选项、PWA/主题、聊天历史、成员音频状态和麦克风权限等改进。
|
||||
- [yichen11818](https://github.com/yichen11818) — [PR #25](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/pull/25) 支持通过 TeamSpeak 注册昵称连接,并在设置、收藏和邀请中保留昵称目标。
|
||||
@@ -0,0 +1,466 @@
|
||||
# WebSpeak 0.2.7 皮肤系统开发指南
|
||||
|
||||
本文是 WebSpeak 0.2.7 的唯一皮肤开发说明,整合原皮肤开发规范与开放皮肤系统规格。它覆盖仍受支持的 v1/v2 兼容皮肤、v3 声明式开放皮肤和 v4 插件包,以及当前公开数据、宿主动作、授权、校验与开发流程。v4 有界 Wasm 已在生产构建开放;皮肤 JavaScript 仍只校验和缓存,不会执行。本文件是当前包格式和运行时接口的唯一文档来源。
|
||||
|
||||
## 目标:皮肤是可移植的外挂包
|
||||
|
||||
`.wskin` 是皮肤唯一的交付物。页面结构、样式、文案、布局、图片、字体和皮肤自己的组件/逻辑都应随包分发;导入皮肤不应要求为某款皮肤单独修改、部署或配置 WebSpeak 核心代码。宿主只提供稳定、通用且版本化的渲染和能力接口,皮肤包声明如何使用它们。
|
||||
|
||||
开发皮肤时,优先在包内完成工作:用 `skin.css` 和包内资源做视觉,用 `content.json` 提供皮肤文案,用 `layout.json` 提供默认排布,用 `components.json` 描述页面组件、数据绑定和已支持的交互;需要本地逻辑时,根据当前支持情况使用 v4 有界 Wasm。所有图片、字体、CSS 和插件文件都放进 `.wskin`,引用包内相对路径。不要为了单款皮肤给 `WebClient.vue`、宿主控件注册表、共享协议、服务端或其他核心运行时添加专用实现。
|
||||
|
||||
运行时数据和安全敏感的 TeamSpeak 行为仍由 WebSpeak 提供。皮肤只能读取当前协议明确公开的数据,并调用已支持、经用户授权和宿主复核的动作;包内 UI 消费这些输入并负责呈现。若多个皮肤确实缺少同一项通用数据或动作,应另立平台接口工作:先定义稳定字段/动作、权限和兼容版本,再由皮肤包使用。不要把平台接口改动伪装成某款皮肤的必要步骤,也不要为单个皮肤新增专用宿主控件。
|
||||
|
||||
可移植性由 WebSpeak 运行时与皮肤协议版本决定。清单的 `minAppVersion`、组件 schema、插件 `apiVersion` 必须对应实际使用的接口;兼容同一协议版本的 WebSpeak 实例应能导入并运行相同字节的 `.wskin`,无需单独部署该皮肤的前端代码。实例配置、公开服务器数据、屏幕尺寸和用户授权可以影响显示结果,但不改变包的实现。旧包继续遵循其声明的 schema 和宿主兼容规则。
|
||||
|
||||
开发者 Skill:[WebSpeak Skin Development](../.agents/skills/webspeak-skin-development/SKILL.md)。它给 Agent 提供皮肤任务的决策和交付步骤;本文件是格式、接口与安全边界的事实来源。
|
||||
|
||||
示例展示公开皮肤接口的用法,不代表未记录的运行时接口也可依赖;发现、活动、广告、商城和管理后台不属于语音皮肤范围。
|
||||
|
||||
完整的 KOOK 语音端体验测试皮肤见 [KAAK](./examples/KAAK-VOICE.md):它复用 WebSpeak 可信宿主控件和公开 TeamSpeak 会话数据,不包含站点素材、运营页面或后台。Harbor Voice 保留为通用 surface 格式验证样例。
|
||||
|
||||
v3 保留安全的标准元素和属性白名单;组件可通过完整页面 surface 自己构建界面,不需要把聊天、音频或成员 UI 锁在固定宿主面板里。条件可比较权限化公开数据、重复项和皮肤本地状态,也可判断已登记公开集合是否为空。表单输入先留在宿主渲染的本地状态;宿主动作不能在逐字输入时触发,可在已提交的 `change`、表单提交或显式点击上触发。作者自定义代码逻辑由 v4 有界 Wasm 路径提供。生产构建中的 v4 Wasm 运行时已接入本地摘要授权、页面生命周期、动态 HTML/SVG 节点渲染、插件 CSS、权限化只读数据投影、宿主动作桥、语义挂载槽位和全局 worker 资源治理;目前支持 `session.status.read`、频道/成员/聊天、收藏/最近列表和音频/共享状态读取权限,以及 `ui.surface.replace`、`ui.input.read`。每份公开数据投影最多 48 KiB,只传清单准许的字段;Wasm 可生成自定义节点树、有限本地状态并响应命名 UI 事件。宿主动作只接受可信 UI 事件触发的同一轮输出中的单个请求,并重新检查插件权限、参数和当前会话;`dblclick` 可绑定到加入频道等已授权宿主动作。JavaScript 仍只校验和缓存,不执行。每个 v4 插件有独立布局根,用户可调整插件整体、组件根和 DOM 节点的位置、尺寸、显隐、安全外观及 Flex/Grid 同级显示顺序;`plugins.json` 可将 widget 放到公开页面的注册槽位,也可通过 surface 重做整页。这个边界能承载完整自定义客户端界面,但不等于已完成插件商城和作者管理平台;跨浏览器测试与独立安全审查尚未完成。
|
||||
|
||||
`.wskin` 包可为公开页面定制艺术表现。v1 提供 CSS 与美术资源;v2 另外携带受校验的布局 JSON;v3 可自由安排公开组件,并用 components.json 声明由宿主渲染的安全组件。所有版本均由 WebSpeak 保留基础组件的业务逻辑和 TeamSpeak 行为。
|
||||
|
||||
页面结构、必要控件和所有基础翻译均由 WebSpeak 提供。皮肤包不必携带文案;如果只包含样式与美术素材,所有界面文字仍由 WebSpeak 按当前语言显示。`content.json` 仅用于可选覆盖,缺少的语言或字段回退到 WebSpeak 的基础内容。皮肤不注入 HTML 或 JavaScript;授权后的交互只调用 WebSpeak 登记并校验过的 TeamSpeak 功能。**管理后台 `/admin/**` 不属于皮肤范围,始终使用 WebSpeak 自己的固定样式。**
|
||||
|
||||
可直接查看 [ILLUSIA 风示例源码](examples/illusia-voice/) 与 [示例说明](examples/ILLUSIA-VOICE.md)。它使用本地美术素材和 CSS 完整定制首页、语音房间、成员区、聊天空状态及播放器,同时沿用 WebSpeak 提供的基础翻译;也是管理控制台内置且不可移除的示例皮肤。
|
||||
|
||||
## 使用与发布
|
||||
|
||||
管理员在 `/admin/skins` 查看三款随 WebSpeak 提供的内置皮肤,并可导入、替换、启用/停用或删除实例自定义皮肤;还可指定访客首次访问时使用的默认皮肤。默认日间、默认夜间和 ILLUSIA 风为受保护内置项,不可替换、停用或移除。访客手动选择的皮肤保存在该浏览器,后续实例默认值变更不会覆盖该明确选择;仅自动套用过旧默认值的浏览器会采用最新实例默认值。皮肤包会缓存在浏览器本地;页面启动时会查询实例目录,目录可用且版本更新时拉取新包。若网络不可用,已缓存的版本仍可使用。
|
||||
|
||||
选择器提供默认日间、默认夜间、内置 ILLUSIA 风和已启用的实例皮肤;没有“跟随系统”选项。停用的实例皮肤不向访客展示,也不能从服务端下载;若它是当前默认皮肤,系统会安全回退到默认日间。管理员设置的默认值只影响未手动选择皮肤的访客。自定义皮肤是独立的外观选择,不继承之前的日间或夜间模式;皮肤未覆盖的部件回退到浅色基础外观,避免一套组件混入另一套模式。自定义皮肤可自行声明 `color-scheme` 并定义深色外观;切换为日间或夜间时,会停用当前自定义包。文档级 `data-theme` 仍由 WebSpeak 保留给管理后台使用。
|
||||
|
||||
## 包结构
|
||||
|
||||
`.wskin` 是标准 ZIP 容器,推荐把下列文件直接放在 ZIP 根目录:
|
||||
|
||||
```text
|
||||
manifest.json # 必需:身份、版本与入口
|
||||
skin.css # 必需:皮肤样式
|
||||
content.json # 可选:首页内容与多语言界面文案
|
||||
assets/preview.jpg # 可选:管理后台显示的预览图,也可在 CSS 中使用
|
||||
assets/background.webp # 可选:页面艺术素材
|
||||
assets/brand.woff2 # 可选:自带字体
|
||||
components.json # v3 可选:声明式组件或完整页面 surface
|
||||
plugins.json # v4 必需:插件入口、页面、模式、权限与包内文件
|
||||
plugins/<plugin-id>/index.js # v4 插件代码,目前只校验和缓存
|
||||
plugins/<plugin-id>/index.wasm # v4 有界 Wasm 插件入口
|
||||
plugins/<plugin-id>/style.css # v4 可选:插件样式,目前只校验和缓存
|
||||
plugins/<plugin-id>/assets/ # v4 插件专属的本地图片或字体素材
|
||||
```
|
||||
|
||||
所有资源路径使用 `/`,区分大小写,并相对于包根目录。CSS 的 `url()` 使用同样的包根相对路径,例如 `url("assets/background.webp")`。不得使用机器本地路径、站点绝对路径或远程 URL。说明文档放在源码目录旁边,不能打进 `.wskin`;导入器会拒绝 `README.md` 等未声明文件。
|
||||
|
||||
### `manifest.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "community.example-skin",
|
||||
"name": "Example skin",
|
||||
"version": "1.0.0",
|
||||
"author": "Example author",
|
||||
"license": "CC-BY-4.0",
|
||||
"description": "A visual-only art skin using the WebSpeak interface translations.",
|
||||
"entry": "skin.css",
|
||||
"preview": "assets/background-composite.webp",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 规则 |
|
||||
| --- | --- |
|
||||
| `schemaVersion` | 当前必须为数字 `1`。 |
|
||||
| `id` | 必需,最多 80 个字符;只允许小写字母、数字、点和连字符;不能以 `builtin.` 开头,也不能使用受保护 ID `builtin.light`、`builtin.dark` 或 `community.illusia-voice`。发布后不要更改。 |
|
||||
| `name`、`author`、`license` | 必需,各最多 80 个字符。资源授权由作者负责确认。 |
|
||||
| `version`、`minAppVersion` | 必需,使用语义化版本号,例如 `1.2.0`。 |
|
||||
| `entry` | 必需,包内 CSS 文件路径,最多 120 个字符。 |
|
||||
| `content` | 可选,包内 JSON 文件路径,最多 120 个字符。 |
|
||||
| `preview` | 可选,包内 PNG、JPG/JPEG、WebP、AVIF 或 GIF 图片路径,最多 120 个字符。 |
|
||||
| `description` | 可选,最多 400 个字符。 |
|
||||
|
||||
清单不得重复声明同一个文件为 CSS、内容或预览入口。
|
||||
|
||||
### schemaVersion 2:声明式布局皮肤
|
||||
|
||||
v2 为 v1 增加一个必需布局文件。清单和布局 JSON 会在导入端及服务端分别验证;未知清单字段、权限、组件、布局字段及越界数值都会导致包被拒绝。v2 不支持 HTML、JavaScript、WebAssembly、远程资源或扩展插件代码。皮肤 CSS 仍使用当前解析器规则,不能控制几何布局和交互区域。
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"packageType": "layout-skin",
|
||||
"id": "community.example-layout",
|
||||
"name": "Example layout",
|
||||
"version": "1.0.0",
|
||||
"author": "Example author",
|
||||
"license": "CC-BY-4.0",
|
||||
"entry": "skin.css",
|
||||
"layout": "layout.json",
|
||||
"permissions": [],
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
```
|
||||
|
||||
布局只引用 WebSpeak 登记的稳定组件 ID。当前支持 `home`、`voice`、`demo` 页面及 `desktop`、`tablet`、`mobile` 三种设备配置。组件位置使用有界的水平/垂直偏移,尺寸使用缩放、宽、高,外观字段只接受六位十六进制颜色和受限圆角;`visible` 控制显示状态;`order` 在 -100 到 100 之间,仅当父容器使用 Flex 或 Grid 时改变同级显示顺序,不改变 DOM 和键盘焦点顺序。`home.security-note`、身份安全提示、连接状态与屏幕共享错误属于可信宿主 UI,不允许布局隐藏或改写。
|
||||
|
||||
示例 `layout.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"pages": {
|
||||
"home": {
|
||||
"desktop": {
|
||||
"home.feature": { "x": 12, "y": 8, "scale": 1.05, "order": -1 },
|
||||
"home.features": { "visible": false }
|
||||
},
|
||||
"tablet": { "home.join-card": { "width": 680 } },
|
||||
"mobile": { "home.header": { "x": 0, "y": 4 } }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
作者包中的布局是初始默认值。用户编辑内容单独存放在本地浏览器,覆盖作者默认值;支持撤销/重做、单个组件重置、整套布局恢复、导入和导出。更换设备宽度会选择对应设备配置,不会删除其他设备的值。恢复入口由宿主在皮肤根节点之外绘制,即使用户隐藏了页面组件,也能再次打开编辑器并恢复默认值。
|
||||
|
||||
v1 和 v2 都只支持公开页面。`/admin/**` 不加载布局、用户覆盖和皮肤组件编辑器。布局包没有数据/API 权限;后续插件必须另行设计独立沙箱与授权协议,不能通过增加 v2 清单字段取得能力。
|
||||
|
||||
### schemaVersion 3:开放皮肤和完整声明式页面
|
||||
|
||||
v3 清单的 packageType 固定为 open-skin,entry 指向 CSS,components 可选指向 components.json;与 v2 不同,v3 不声明 permissions,但可以可选声明 layout 指向作者默认布局 `layout.json`。组件文件可以省略。仅 v3 开放公开页面的 CSS 排版能力,v1/v2 仍按旧 CSS 规则校验。客户端导入和服务端登记使用同一共享组件 schema 与权限白名单。
|
||||
|
||||
components.json 顶层接受 schemaVersion 1、2 或 3 和 components 数组。schema v1 维持旧兼容;schema v2 引入 `mode: "widget"`(默认)或 `mode: "surface"`,并提供可选宿主控件节点;schema v3 保持这些能力,扩大声明式 UI 的节点/状态/动作边界,并增加用户操作事件和语音功能动作。v3 仍使用固定元素/属性、公开数据集合和宿主动作白名单,不是任意 HTML 或任意脚本。每个组件需声明 id、name、page、accessibleName、permissions、actions 和 root,可选 state。page 接受 home、voice、demo;surface 仅可用于 home 和 voice,并且必须请求 `ui.surface.replace`。用户批准前不会显示 surface,撤销后宿主立即恢复普通页面。所有皮肤组件根节点及其中的每个可见元素都以动态布局项加入本地布局编辑器,可独立移动、缩放、改尺寸、改外观或隐藏。按钮、输入框及显式用户操作节点保留 44 px 最小触控区域。为让用户覆盖在树结构调整后仍能指向同一元素,请给重要节点设置稳定的 `part` 名称;未设置时按组件树位置生成标识。v4 插件格式与运行时见本指南的 v4 章节;Wasm 生产运行已开启,作者 JavaScript 仍关闭。
|
||||
|
||||
普通节点使用白名单 HTML/SVG 元素。节点可包含 text、part、className、受限 attributes、包内图片 asset、bindValue、本地 repeat/when、events 和 children。文本与属性支持简单的双大括号数据路径;不支持表达式、HTML 字符串或脚本。重复列表可使用注册的公开集合;频道重复项仅能再重复其 `channel.members`,并且需要额外批准 `session.members.read`。宿主每个组件的实际渲染节点最多 8192 个,防止嵌套集合放大界面。v3/v4 的作者默认布局使用与 v2 相同的有界 layout schema;可通过 `skin.<page>.<component-id>` 指定声明式自定义组件,通过 `skin.<page>.runtime_plugin_root_<plugin-id>` 指定 v4 插件根。用户的本地布局覆盖优先于包默认值。schema v2 另允许固定宿主控件节点,例如:
|
||||
|
||||
申请 `session.channels.read` 的 `session.channels` 列表还提供 `memberCount`、两位数显示用的 `memberCountLabel`、`maxClients` 和 `maxClientsLimited`。后两个字段仅在 TeamSpeak 返回有效上限数据时出现;`maxClientsLimited: false` 表示频道不限人数。它们与频道树一起属于公开只读数据,不会授予服务器写入能力。
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"components": [{
|
||||
"id": "example-voice-surface",
|
||||
"name": "Example voice surface",
|
||||
"page": "voice",
|
||||
"mode": "surface",
|
||||
"accessibleName": "Example voice workspace",
|
||||
"permissions": ["ui.surface.replace"],
|
||||
"actions": {},
|
||||
"root": {
|
||||
"tag": "main",
|
||||
"children": [
|
||||
{ "widget": "voice.channel-panel" },
|
||||
{ "widget": "voice.member-cards" },
|
||||
{ "widget": "voice.chat-panel" },
|
||||
{ "widget": "voice.audio-controls" },
|
||||
{ "widget": "voice.disconnect-control" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
当前可选宿主控件 ID:`home.connection-form`、`home.connection-status`、`home.visitor-count`、`home.server-announcement`、`home.social-links`、`home.identity-provider`、`app.skin-switcher`、`app.language-switcher`、`voice.channel-panel`、`voice.member-cards`、`voice.chat-panel`、`voice.audio-controls`、`voice.screen-share-player`、`voice.screen-share-start`、`voice.whisper-controls`、`voice.performance-panel`、`voice.connection-controls`、`voice.disconnect-control`、`voice.server-header`、`voice.server-banner`、`voice.server-switcher`、`voice.channel-tree`。未知控件和同页重复控件会被拒绝;每个控件的状态和业务动作仍由 WebSpeak 内部处理。`home.identity-provider` 是通用身份提供方入口,需用 `options.identityProviderId` 和 `options.identityProviderLabel` 指定稳定提供方标识与显示名;宿主会把点击转交给应用代码的 `registerIdentityProviderAdapter` 分发接口,皮肤只能发起请求、不能注册适配器。当前没有 MyTS 适配器,所以 MyTS 入口仍提示开发中;这不代表已经实现登录认证。schema v3 会检查受保护控件所需权限:音频控件需 `audio.status.read`、`audio.microphone.control` 和 `audio.output.control`;聊天需 `chat.channel.read` 与 `chat.channel.send`;成员卡片始终需 `session.members.read` 和 `session.memberAvatars.read`;schema v3 可为成员卡片设置 `options.memberActions: true`,在非本人卡片上显示可信宿主成员操作入口(包含现有个人音量控件);也可为 `voice.channel-tree` 设置该选项,在非本人频道树成员行上启用右键菜单;菜单仍由 WebSpeak 宿主处理,皮肤不获得额外动作或数据接口。频道树还可单独设置 `options.memberDragDrop: true`,将非本人成员拖到另一频道行时复用 WebSpeak 现有移动成员操作;悬停和拖入高亮由皮肤样式控制,此选项默认关闭且只适用于频道树。成员卡片或性能卡片可设置 `options.screenShare: false`,同时隐藏共享 UI/指标并免除成员卡片所需的屏幕共享权限;默认成员共享操作仍需屏幕共享读取/控制权限;头像只在可信宿主控件内显示,不暴露给皮肤代码;屏幕共享播放器需 `voice.screenShare.read` 与 `voice.screenShare.control`;悄悄话控件需对应状态读取和控制权限;断开/连接控件需 `voice.disconnect`。既有 v2 包维持旧校验行为,`voice.screen-share-start` 仍像此前一样要求 `voice.screenShare.control`。该控件仅能放在语音页;宿主按钮在可信点击处理器内直接启动屏幕采集,避免异步 Wasm 回调丢失浏览器瞬时用户激活。自定义 UI 可以完全用普通声明式节点搭建,不需要采用这些控件。只显示收藏时可用 `favorites.items` 和 `favorites.switch`;若要将收藏与最近连接放在同一自定义栏,可用 `servers.quickList` 数据与 `quickServers.switch` 动作。服务器目标始终使用本机生成的不透明令牌,不把地址、密码或身份材料交给组件。频道行也可把 `voice.joinChannel` 绑定到双击事件,切房继续走 TeamSpeak 原有权限和密码流程。v3 还提供经独立权限保护的麦克风/扬声器、输出音量、噪声抑制、伴奏、离开状态、悄悄话、断开连接和屏幕共享动作;噪声抑制使用 `audio.toggleNoiseSuppression` 与 `audio.microphone.control`,伴奏使用 `audio.toggleAccompaniment` 与 `audio.output.control`。它们只调用 WebSpeak 已有操作,屏幕采集仍由浏览器或操作系统询问用户。
|
||||
|
||||
首页访客统计使用公开宿主控件 `home.visitor-count`:它展示当前访客序号与累计访客数,文本跟随当前界面语言,并在统计数据尚不可用时隐藏;不需声明权限。该控件复用 WebSpeak 日间首页的同一结构与基础样式,皮肤通过包内 CSS 定位,不需要自建统计逻辑。组件节点可用稳定的 `part` 名称(例如 `visitor-stats`)控制位置;内部 `home.visitors`、`home.visitors.orbit`、`home.visitors.icon`、`home.visitors.label`、`home.visitors.divider`、`home.visitors.total` 和 `home.visitors.spark` 是稳定样式部件。控件只能放在 `home` 页面。
|
||||
|
||||
可信语音导航控件包括 `voice.channel-tree`、`voice.server-switcher` 和 `voice.server-header`。频道树要求 `session.channels.read`、`session.members.read`、`session.memberAvatars.read` 与 `session.channel.join`;头像只由宿主读取并在频道树中绘制。它可选 `layout: "server-sidebar"` 展示频道成员并让频道行与成员行分别控制折叠;未指定时保留默认呈现。独立服务器切换器要求 `servers.quickList.read` 与 `servers.quickList.switch`。服务器头部还要求 `session.status.read`,并在同一可信部件中组合服务器身份、状态、频道搜索和快速切换。两种入口都只接收不透明本地标识,点击后复用 WebSpeak 当前连接流程。v3 还可用 `session.invite.copy` 授权 `session.copyInviteLink`,让宿主复制当前公开服务器与频道的邀请链接并排除连接凭据。语音状态投影中的 `serverLabel` 会在看起来像 IP、域名或连接目标时省略,避免把地址显示为服务器名称。
|
||||
|
||||
示例包见 [KAAK voice 示例](./examples/KAAK-VOICE.md),其 components.json 使用完整首页与语音工作区 surface,展示收藏服务器、频道树、在线成员、聊天和可信语音控制的组合;[Open Voice Surface](./examples/OPEN-VOICE-SURFACE.md) 保留为通用格式验证脚手架。KAAK 的语音视觉参考来自用户授权进入的前两个语音房间;只记录布局,不保留服务器/房间标识、成员名或聊天内容。组件按本地用户授权后才渲染;权限对每个皮肤版本、页面和组件分别保存,可在宿主权限入口撤销。页面替换时,宿主会额外显示“返回标准界面”和“恢复内置皮肤”入口;拒绝授权或离开 surface 后,普通页面可立即恢复。
|
||||
|
||||
组件树有硬上限:components.json 256 KiB。schema v1/v2 上限为 32 个组件、每组件 256 个模板节点、16 层深度和 100 条重复记录;schema v3 上限为 128 个组件、每组件 2048 个模板节点、32 层深度和 250 个重复行,并允许 64 个本地标量状态与 64 个动作。Wasm 动态 UI 输出的 schema v4/v5/v6 有 256 KiB 总输出上限、最多 64 个组件、每个节点最多 64 个属性和 256 个子节点,并沿用每组件节点/深度限制;渲染器接受标准 HTML/SVG 元素及普通属性,而不是由元素/属性展示白名单限制。脚本、嵌入式浏览器、网络/导航属性、事件属性和行内 style 仍拒绝;样式通过经过隔离校验的插件 CSS 提供。包内图片通过专用资源字段引用,自定义元素映射为惰性 `div`。宿主只通过 `isTrusted` 用户事件发出剥离 DOM/Event 对象后的 `extension-event`,Wasm 侧只能经 `env.ui_input_read` 一次读取最多 64 KiB 的 JSON,包含插件本地状态、安全事件和宿主按插件读取权限投影的数据。每份数据投影最多 48 KiB,只含公开字段;地址、凭据、SDK 对象和未声明字段不会进入 guest。输入字段限长;生成界面中的 password/file/hidden 类型输入会拒绝。UI 循环已经接入 WebClient 授权生命周期,可把可信事件或最新数据快照作为下一次独立 Wasm 调用输入,最多串行排队 8 项并验证回调/状态归属;动作桥复核清单权限和会话状态。单个页面实例最多并发运行 2 个 Wasm worker,并限制最多排队 64 项。
|
||||
|
||||
图片资源只能从包内引用,CSS 不能读取外部 URL、脚本或浏览器存储。宿主动作需显式权限,并只能绑定可信的用户事件;输入或 change 事件不能触发宿主动作。focus/blur、hover 和 drag-start/over 等被动事件只可改动组件本地状态,不能触发语音操作。
|
||||
|
||||
注意:v3 CSS 和 surface 可以隐藏或遮挡普通语音控件。权限和返回标准界面提示由宿主在皮肤根之外绘制;其他界面控件仍受皮肤排版影响。测试时务必确保麦克风、设置、退出语音、屏幕共享操作和移动端导航仍有可达路径。组件演示页 /demo 使用合成数据,加入频道和聊天动作只更新演示状态;它不支持宿主控件或整页替换。
|
||||
|
||||
### 本地组件结构编辑器
|
||||
|
||||
公开客户端页可打开“组件结构”编辑器,直接管理当前皮肤版本的声明式组件树。它支持创建、复制、删除组件和节点、添加子节点或同级节点、调整顺序、编辑组件元数据与节点 JSON、撤销/重做,以及导入/导出 components.json。该编辑器不属于管理员面板,不加载到 /admin/**。
|
||||
|
||||
编辑器只保存本地 authoring 覆盖,键按皮肤 ID 和版本隔离;原始皮肤包不会被改写。导入及每次提交都会走 parseSkinPluginDocument 的同一 schema 和权限校验,运行时也再次验证从本地存储读出的文档。不能通过编辑器新增任意脚本、事件处理器属性、外部资源、未知数据路径、宿主保留的 data-ws-* 属性、未授权宿主动作或未登记的宿主控件。旧 v2 组件首次升级到 v3 时,编辑器会为受保护的内置宿主控件补齐对应权限声明;这不会自动批准权限,控件继续等待宿主授权 UI 明确确认。
|
||||
|
||||
旧 schema v1/v2 皮肤可以保持原样使用,第一次结构编辑时会把已验证的数据规范化为 schema v3;旧包自身不被升级或覆盖。schema v3 允许 components 为空:删除最后一个皮肤组件会恢复基础 WebSpeak 页面,宿主授权与恢复控件始终在皮肤内容之外。节点不能脱离组件根单独删除;重要节点应设置稳定 part 名称,避免树顺序变化后基于路径生成的布局覆盖指向其他节点。
|
||||
|
||||
### schemaVersion 4:插件包描述与有界 Wasm 运行时
|
||||
|
||||
v4 在 open-skin 包中增加必需的 `plugins` 路径,并允许沿用可选 `layout` 路径提供插件根和节点的作者默认布局。服务端登记和客户端导入共用 `plugins.json` schema v1 校验器;校验插件 ID、页面、模式、权限、文件归属、路径唯一性和包内文件大小,并将插件文件与普通皮肤素材分别缓存。客户端还会对 Wasm 入口执行固定导入/导出 ABI 预检。SHA-256 授权基础会绑定插件描述、入口、样式和全部素材;本机授权记录还会绑定皮肤/插件版本、API 版本和权限策略版本。摘要只能发现已授权内容被替换,不能证明发布者身份。WebClient 有本地授权对话框和 Wasm 运行生命周期;目前支持安全 UI 输出、可信 UI 事件回调、插件专属 CSS、按清单权限过滤的公开数据投影(单份最多 48 KiB)和首版单动作宿主桥。支持的数据读取权限包括 `session.status.read`、`session.channels.read`、`session.members.read`、`chat.channel.read`、`favorites.read`、`servers.quickList.read`、`audio.status.read`、`voice.whisper.status.read`、`voice.screenShare.status.read` 和 `voice.screenShare.read`,另支持 `ui.surface.replace`。`ui.input.read` 单独控制插件是否能收到用户在插件自有输入框中输入或被浏览器自动填入的值;未获授权时仍可收到事件类型,但不会收到文本或勾选值。密码、文件和隐藏输入始终拒绝。宿主动作仅可由可信 UI 事件触发,按清单权限、动作参数和会话状态再次校验;生产构建也有全局 worker 上限。跨浏览器验证和独立安全审查仍待完成。
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 4,
|
||||
"packageType": "open-skin",
|
||||
"id": "community.example-plugin-skin",
|
||||
"name": "Example plugin skin",
|
||||
"version": "1.0.0",
|
||||
"author": "Example author",
|
||||
"license": "MIT",
|
||||
"entry": "skin.css",
|
||||
"plugins": "plugins.json",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
```
|
||||
|
||||
`plugins.json` 顶层 `schemaVersion` 当前为 `1`,并包含 1–64 个插件。每个插件声明 `id`、`name`、`version`、`apiVersion: 1`、`page`(`home` 或 `voice`)、`mode`(`widget` 或 `surface`)、必需的 `entry`、可选的 `mount`、`runtime`、`style`、素材路径数组 `assets` 和 `permissions`。入口扩展名 `.js` 默认对应 `javascript`,`.wasm` 默认对应 `wasm`;显式 `runtime` 必须与入口扩展名一致。入口及样式必须位于 `plugins/<id>/`;素材必须位于该插件自己的 `assets/` 子目录,只能是本地图片或 woff2 字体。插件不能共享文件;同一公开页面最多有一个 `surface`,且必须申请 `ui.surface.replace`。surface 不能声明 `mount`;widget 可选声明一个与 page 相符的宿主槽位。未指定时放在页面级插件宿主中。`ui.input.read` 是单独的输入值读取权限,授权提示会说明浏览器自动填入的值也可能被读取;不得让用户在皮肤输入框中输入密码或其他秘密。其余权限只能从 `src/shared/skin-plugin.ts` 的现有权限表中选择。
|
||||
|
||||
`plugins.json` 不超过 256 KiB;每个入口 JS 或 Wasm 不超过 256 KiB,每个样式 CSS 不超过 512 KiB;每个插件最多声明 32 个素材。客户端导入会拒绝不符合固定内存、导入、导出和 Wasm 模块结构限制的入口。皮肤包整体仍受通用 ZIP 文件数、展开大小、图像和字体限额约束。v1–v3 不接受插件代码。v4 JavaScript 仍只校验、缓存,不执行。生产 Wasm 仅在用户显式授权、摘要匹配时通过有界解释器启动一次性任务;它已支持上述权限化只读投影、安全 UI 更新和首版宿主动作桥。动作由可信 UI 事件引发、由宿主按插件权限和会话状态复核;浏览器瞬时手势不会跨越异步 Wasm 执行,因此屏幕采集必须通过可信宿主控件直接开始。数据变化会触发一轮新的有界执行。不要将有 DOM 的 iframe 当作网络沙箱:sandbox 不阻止 iframe 自己导航,`navigate-to` 也不能作为跨浏览器安全保证。
|
||||
|
||||
widget 的可选 `mount` 只接受这些公开锚点:`home.header.after`、`home.content.before`、`home.content.after`、`home.footer.before`、`voice.server-rail.before`、`voice.server-rail.after`、`voice.header.before`、`voice.header.after`、`voice.activity.before`、`voice.activity.after`、`voice.chat.before`、`voice.chat.after`、`voice.channel-panel.before`、`voice.channel-panel.after`、`voice.audio-dock.before`、`voice.audio-dock.after`、`voice.mobile-nav.before`、`voice.mobile-nav.after` 和 `voice.workspace.overlay`。它们提供初始语义位置;作者仍可用插件 CSS 和本地布局编辑器自由调整位置、尺寸、显隐、安全外观及同级顺序。surface 替换内置页面时,如果声明的槽位不存在,插件会回退到页面级宿主,避免 UI 丢失。专用的插件挂载管理界面仍未实现。布局权限只覆盖当前皮肤中实际渲染的插件节点,不能越过自身节点调整其他插件或宿主恢复控件。生产 v4 宿主已按 descriptor 管理当前页 widget/surface、授权、输出、事件循环、样式和清理。
|
||||
|
||||
## 当前运行时数据与权限
|
||||
|
||||
以下数据权限按组件或插件单独声明。授权按皮肤/插件版本、页面、组件和权限策略绑定;拒绝或撤销后,相应组件不再渲染或调用动作。服务端地址、密码、身份密钥、访问令牌、Cookie、私聊内容、原始音频和屏幕流不会传给皮肤。
|
||||
|
||||
| 权限 | 公开内容 |
|
||||
| --- | --- |
|
||||
| `session.status.read` | 当前连接状态、频道和显示名称。 |
|
||||
| `session.channels.read` | 可见频道树、名称、层级、当前人数、服务器公布的人数上限和当前频道标记;不包含密码或服务器地址。 |
|
||||
| `session.members.read` | 可见成员名称、频道、在线/说话状态及本人标记;不含头像图像。 |
|
||||
| `session.memberAvatars.read` | 允许可信 `voice.member-cards` 控件在宿主内显示已缓存头像,图像字节和 URL 不进入皮肤数据。 |
|
||||
| `chat.channel.read` | 当前公开文字频道中可见的消息,不含私聊。 |
|
||||
| `favorites.read` | 收藏名称、类型、当前标记和不透明本地令牌,不含地址或凭据。 |
|
||||
| `servers.quickList.read` | 收藏与最近服务器的名称、类型、当前标记和不透明本地令牌,不含地址或凭据。 |
|
||||
| `audio.status.read` | 用户自己的麦克风/扬声器静音、降噪和伴奏状态,不含音频。 |
|
||||
| `voice.whisper.status.read` | 悄悄话状态和已配置目标数量。 |
|
||||
| `voice.screenShare.status.read` | 用户自己的屏幕共享状态。 |
|
||||
| `voice.screenShare.read` | 当前可见共享的名称、来源、所有者名称、音频标记和观看人数,不含媒体流。 |
|
||||
|
||||
`ui.surface.replace` 授权公开首页或语音页的整页替换。`ui.input.read` 是独立的输入读取权限;用户同意后,插件可读取其输入框文本或浏览器自动填入值。密码、文件和隐藏输入始终不提供给插件。不要在插件输入框中要求用户输入密码或其他秘密。
|
||||
|
||||
宿主动作只允许从公开运行时 API 中选择,并在调用时重新核对权限、参数和当前会话:
|
||||
|
||||
- `session.copyInviteLink`(`session.invite.copy`)复制不含连接凭据的当前服务器/频道邀请链接。
|
||||
- `voice.joinChannel`(`session.channel.join`)仅请求加入当前公开可见的频道,继续使用宿主的频道密码和权限流程。
|
||||
- `favorites.switch`(`favorites.switch`)与 `quickServers.switch`(`servers.quickList.switch`)使用不透明令牌选择本机已有目标,并复用宿主连接流程。
|
||||
- `chat.sendMessage`(`chat.channel.send`)只向当前公开文字频道发送消息,不包括私聊。
|
||||
- `ui.setState` 和 schema v3 的 `ui.toggleState` 只修改该组件隔离的本地状态。
|
||||
- schema v3 还支持经相应权限验证的本人麦克风/扬声器静音、降噪、伴奏、输出音量、音频设置、断开连接、离开状态、悄悄话和屏幕共享操作。`voice.startScreenShare` 必须通过可信宿主控件触发,以保留浏览器的用户操作授权。
|
||||
- 屏幕共享成员标记可读取 `session.members` 中的 `screenSharing` 和 `screenShareStreamId`;观看操作 `voice.joinScreenShare` 还需 `voice.screenShare.control`。
|
||||
|
||||
控件节点将 WebSpeak 原生控件放进皮肤布局,但不会暴露其内部状态或数据对象。事件可包含 click、dblclick、键盘、焦点、指针和拖放等受限类型;被动事件只能改动组件本地状态,敏感动作必须由可信的明确用户操作触发。宿主再次校验目标、令牌、共享 ID 和当前权限。
|
||||
|
||||
## v4 Wasm 运行限制与恢复
|
||||
|
||||
每个 v4 插件使用按皮肤、插件、版本、API、文件摘要和权限策略绑定的本地授权。安装不等于运行;内容或权限变化后须重新授权。运行时通过宿主过滤权限字段后提供结构化快照,不传递 DOM、原生 TeamSpeak 对象或网络/持久化 API。
|
||||
|
||||
| 资源 | 当前上限 |
|
||||
| --- | ---: |
|
||||
| 单份插件数据快照 | 48 KiB |
|
||||
| 单次 UI 输入 | 64 KiB |
|
||||
| 单次动态 UI 输出 | 256 KiB |
|
||||
| Wasm 客体线性内存 | 4 MiB |
|
||||
| Wasm 指令燃料 | 10,000,000 |
|
||||
| 每个页面实例并发运行 | 2 个 worker |
|
||||
| 等待队列 | 64 个任务;等待 120 秒后拒绝 |
|
||||
|
||||
Wasm 每轮最多读取一次输入并提交一个 UI 输出;首版宿主动作桥只接受可信 UI 事件同一轮执行提出的一个动作。共享屏幕采集不允许从异步动作启动,必须走可信宿主按钮。动态输出由宿主校验后创建安全 HTML/SVG 节点,不按 HTML 字符串执行;作者 CSS 限定在皮肤或插件容器中。切页、撤权、超时或插件错误会停止相应任务并恢复宿主界面。插件不能创建 DOM iframe、调用外部资源、导航页面或读写任意浏览器存储。
|
||||
|
||||
## 首页内容和文案
|
||||
|
||||
`content.json` 完全可选。WebSpeak 自带中文、英语、德语、俄语和日语的基础内容,因此纯美术皮肤无需复制翻译文件。若希望为皮肤定制部分文案,可按 locale 覆盖连接首页内容和公开界面文案;未定义的语言、字段或翻译键会回退到 WebSpeak 内容,不要求皮肤重复提供整套文字。当前允许 1–20 个 locale,locale 写作 `en`、`zh-CN`、`ja-JP` 等形式。`defaultLocale` 必须指向一个已定义的 locale。示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"defaultLocale": "en",
|
||||
"locales": {
|
||||
"en": {
|
||||
"home": {
|
||||
"eyebrow": "A room of your own",
|
||||
"title": "Talk",
|
||||
"titleAccent": "together",
|
||||
"description": "Join a voice room from your browser.",
|
||||
"welcomeTitle": "Join the room",
|
||||
"welcomeDescription": "Choose a name and connect.",
|
||||
"features": [
|
||||
{ "title": "Clear voice", "description": "Low-latency Opus audio." }
|
||||
]
|
||||
},
|
||||
"messages": {
|
||||
"home.connect": "Enter the room",
|
||||
"voice.activity-heading": "Voice activity",
|
||||
"demo.heroLead": "A preview customized by this skin."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`home` 支持 `brandName`、`eyebrow`、`title`、`titleAccent`、`description`、`welcomeTitle`、`welcomeDescription` 和 `features`。普通文字最多 500 个字符;`features` 最多 8 项,每项的 `title` 最多 80 个字符、`description` 最多 240 个字符。功能卡片图标和状态由应用提供,皮肤不能通过 JSON 注入节点。
|
||||
|
||||
`messages` 的键是公开页面中翻译调用使用的键;首页/语音页键可在 `web/src/i18n/web-client.ts` 查找,演示页键使用 `demo.` 前缀加字段名(例如 `demo.heroLead`、`demo.speakingNow`)。每个 locale 最多覆盖 200 条,每条文案最多 500 个字符。键只能由小写字母开头,并包含字母、数字或点。语言回退顺序为默认 locale、当前语言和更具体的 locale;之后回退到 WebSpeak 原文。
|
||||
|
||||
管理后台的文字不读取皮肤包,不能通过 `messages` 修改。
|
||||
|
||||
## CSS 皮肤接口
|
||||
|
||||
### 自动隔离
|
||||
|
||||
运行时把 `skin.css` 的每个选择器限定在皮肤自己的公开页面根节点内:
|
||||
|
||||
```css
|
||||
/* 选择器必须使用公开的页面/部件钩子;运行时再加上皮肤根作用域。 */
|
||||
[data-ws-page="voice"] [data-ws-part="voice.member.avatar"] {
|
||||
outline: 2px solid var(--skin-accent);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
```
|
||||
|
||||
实际规则会被限定在类似下面的根节点内,不会匹配 `/admin/**`:
|
||||
|
||||
```css
|
||||
[data-ws-page="voice"] [data-ws-part="voice.member.avatar"]
|
||||
```
|
||||
|
||||
也可以写 `:root { --skin-accent: ... }` 设置皮肤自己的变量;`:root` 会被转换成当前皮肤根。选择器必须包含 `:root`、`[data-ws-page]` 或 `[data-ws-part]`。不要写 `:global()`、`html`、`body` 或 Vue 内部 class 作为公开接口。组件 class 可能随版本调整,`data-ws-part` 才是皮肤作者接口。自定义变量名必须使用 `--skin-` 前缀,不能覆盖 WebSpeak 的内部令牌。
|
||||
|
||||
页面根节点使用 `data-ws-page` 区分 `home`、`voice` 和 `demo`。使用 `data-ws-state` 选择明确状态,如 `active`、`idle`、`current`、`open`、`closed`、`drag-over`、`dragging`、`speaking`、`connected`、`self`、`mine` 或 `other`。语音成员还提供 `data-ws-speaking="true|false"` 和 `data-ws-self="true|false"`。交互元素会带有 `data-ws-critical="true"`;没有专属部件名称的按钮、链接、输入框、滑块和可拖动成员会使用通用部件 `data-ws-part="control"`,并以 `data-ws-control-kind` 标出 `button`、`link`、`input`、`checkbox`、`range`、`select`、`textarea`、`menuitem` 或 `draggable`。
|
||||
|
||||
### 已发布的部件名称
|
||||
|
||||
下列名称来自当前前端模板。对新功能,作者可以先用通用 `control` 部件;后续新增稳定部件会更新本目录。
|
||||
|
||||
服务器和频道密码弹窗共用 `auth.password.backdrop`、`auth.password.dialog`、`auth.password.decoration`、`auth.password.eyebrow`、`auth.password.title`、`auth.password.lead`、`auth.password.form`、`auth.password.label`、`auth.password.field`、`auth.password.field-icon`、`auth.password.error` 和 `auth.password.actions`。
|
||||
|
||||
服务器和频道密码弹窗共用 `auth.password.backdrop`、`auth.password.dialog`、`auth.password.close`、`auth.password.close-icon`、`auth.password.decoration`、`auth.password.eyebrow`、`auth.password.title`、`auth.password.lead`、`auth.password.form`、`auth.password.label`、`auth.password.field`、`auth.password.field-icon`、`auth.password.input`、`auth.password.error`、`auth.password.actions`、`auth.password.cancel`、`auth.password.submit`、`auth.password.spinner` 和 `auth.password.submit-icon`。
|
||||
|
||||
| 页面区域 | `data-ws-part` |
|
||||
| --- | --- |
|
||||
| 通用 | `app`、`app.toast`、`control`、`skin.trigger`、`skin.menu`、`skin.option`、`language.trigger`、`language.menu`、`language.option` |
|
||||
| 首页 | `home`、`home.header`、`home.brand`、`home.header-tools`、`home.gateway-status`、`home.content`、`home.hero`、`home.hero.eyebrow`、`home.hero.title`、`home.hero.description`、`home.features`、`home.feature`、`home.visitors`、`home.visitors.orbit`、`home.visitors.icon`、`home.visitors.label`、`home.visitors.divider`、`home.visitors.total`、`home.visitors.spark`、`home.join-card`、`home.join-card.waveform`、`home.join-card.sonar`、`home.join-title`、`home.join-description`、`home.notice`、`home.form`、`home.server-target`、`home.field-label`、`home.field`、`home.relay-choice`、`home.relay-choice.copy`、`home.server-history`、`home.server-history.group`、`home.server-history.item`、`home.server-history.select`、`home.server-history.favorite-toggle`、`home.favorite-toggle`、`home.identity`、`home.identity-actions`、`home.identity-provider.button`、`home.identity-provider.label`、`home.identity-import.open`、`home.identity-export.button`、`home.identity-import-dialog`、`home.identity-import.header`、`home.identity-import.close`、`home.identity-import.textarea`、`home.identity-import.drop-zone`、`home.identity-import.file-button`、`home.identity-import.error`、`home.identity-import.security`、`home.identity-import.footer`、`home.identity-import.cancel`、`home.identity-import.submit`、`home.server-announcement`、`home.server-announcement.title`、`home.server-announcement.body`、`home.social-links`、`home.connection-status`、`home.connect`、`home.security-note`、`home.footer`、`home.community-dialog` |
|
||||
| 语音工作区 | `voice.shell`、`voice.workspace`、`voice.header`、`voice.header-actions`、`voice.breadcrumbs`、`voice.performance`、`voice.performance.panel`、`voice.performance.route`、`voice.performance.metrics`、`voice.performance.status`、`voice.performance.webrtc-stats`、`voice.connection-status`、`voice.audio-status`、`voice.poke`、`voice.scroll`、`voice.content`、`voice.activity`、`voice.activity.artwork`、`voice.activity-heading`、`voice.screen-share-error`、`voice.members`、`voice.members.empty`、`voice.member`、`voice.member.action-trigger`、`voice.member.avatar-wrap`、`voice.member.avatar`、`voice.member.mic-status`、`voice.member.name`、`voice.member.status`、`voice.member.live-indicator`、`voice.member.stop-share`、`voice.member.share-actions`、`voice.member-panel`、`voice.member-panel.heading`、`voice.member-panel.search`、`voice.member-panel.channels`、`voice.channel-group`、`voice.channel-group.heading`、`voice.channel-group.members`、`voice.member-row`、`voice.member-row.avatar`、`voice.member-row.copy`、`voice.member-row.flags`、`voice.member-row.volume`、`voice.whisper-strip`、`voice.audio-dock`、`voice.audio-dock.microphone`、`voice.audio-dock.microphone-panel`、`voice.audio-dock.output`、`voice.audio-dock.output-panel`、`voice.audio-settings`、`voice.audio-settings.device-select`、`voice.audio-settings.device-select-trigger`、`voice.audio-settings.device-select-chevron`、`voice.audio-settings.device-select-menu`、`voice.audio-settings.device-select-option`、`voice.mobile-more`、`voice.mobile-nav` |
|
||||
| KOOK 频道树与服务器切换 | `voice.server-switcher`、`voice.server-switcher.trigger`、`voice.server-switcher.menu`、`voice.server-switcher.item`、`voice.server-switcher.icon`、`voice.server-switcher.label`、`voice.server-switcher.current`、`voice.server-switcher.empty`、`voice.channel-tree.list`、`voice.channel-tree.empty`、`voice.channel-tree.node`、`voice.channel-tree.line`、`voice.channel-tree.expander`、`voice.channel-tree.row`、`voice.channel-tree.icon`、`voice.channel-tree.join-hint`、`voice.channel-tree.name`、`voice.channel-tree.count`、`voice.channel-tree.branch`、`voice.channel-tree.member`、`voice.channel-tree.avatar`、`voice.channel-tree.member-name`、`voice.channel-tree.member-muted`、`voice.channel-tree.member-screen-share`、`voice.channel-tree.member-speaking`、`voice.channel-tree.member-away` |
|
||||
| 快速服务器 | `voice.favorite-servers.rail`、`voice.favorite-servers.rail.list`、`voice.favorite-servers.rail.item`、`voice.favorite-servers.server`、`voice.favorite-servers.avatar`、`voice.favorite-servers.tooltip`、`voice.favorite-servers.favorite-toggle`、`voice.favorite-servers.add`、`voice.favorite-servers.strip`、`voice.favorite-servers.strip.item`、`voice.favorite-servers.strip.server`、`voice.favorite-servers.strip.favorite-toggle`、`voice.favorite-servers.strip.add`、`voice.favorite-servers.switch-status`、`voice.favorite-servers.current-toggle`、`voice.favorite-servers.dialog-backdrop`、`voice.favorite-servers.dialog`、`voice.favorite-servers.dialog.header`、`voice.favorite-servers.dialog.close`、`voice.favorite-servers.dialog.form`、`voice.favorite-servers.dialog.field`、`voice.favorite-servers.dialog.input`、`voice.favorite-servers.dialog.target`、`voice.favorite-servers.dialog.hint`、`voice.favorite-servers.dialog.actions`、`voice.favorite-servers.dialog.cancel`、`voice.favorite-servers.dialog.submit` |
|
||||
| 聊天与菜单 | `voice.chat`、`voice.chat.tabs`、`voice.chat.tab`、`voice.chat.heading`、`voice.chat.messages`、`voice.chat.event`、`voice.chat.message`、`voice.chat.message-avatar`、`voice.chat.message-body`、`voice.chat.message-bubble`、`voice.chat.empty`、`voice.chat.composer`、`voice.chat.status`、`voice.context-menu-backdrop`、`voice.context-menu`、`voice.context-menu.header`、`voice.context-menu.move-submenu` |
|
||||
| 屏幕共享 | `voice.screen-share-settings`、`voice.screen-share-settings.heading`、`voice.screen-share-settings.fields`、`voice.screen-share-settings.note`、`voice.screen-share-settings.actions`、`voice.screen-player`、`voice.screen-player.stage`、`voice.screen-player.video`、`voice.screen-player.placeholder`、`voice.screen-player.exit`、`voice.screen-player.viewers`、`voice.screen-player.viewer-avatar`、`voice.screen-player.live`、`voice.screen-player.source`、`voice.screen-player.controls`、`voice.screen-player.volume`、`voice.screen-player.fullscreen` |
|
||||
| `/demo` 演示页 | `demo.header`、`demo.brand`、`demo.header-tools`、`demo.badge`、`demo.skin-switcher`、`demo.language-switcher`、`demo.home-link`、`demo.reconnect`、`demo.reconnect.restore`、`demo.layout`、`demo.channels`、`demo.channels.heading`、`demo.channel`、`demo.channel.select`、`demo.channel.members`、`demo.main`、`demo.hero`、`demo.live`、`demo.hero.title`、`demo.hero.description`、`demo.hero.online`、`demo.wave`、`demo.voice-heading`、`demo.voice-grid`、`demo.voice-card`、`demo.avatar`、`demo.member-name`、`demo.member-status`、`demo.chat.heading`、`demo.chat.tabs`、`demo.chat.tab`、`demo.chat.messages`、`demo.chat.message`、`demo.chat.empty`、`demo.chat.composer`、`demo.chat.input`、`demo.chat.send`、`demo.actions`、`demo.actions.heading`、`demo.action.speaking`、`demo.action.poke`、`demo.action.reconnect`、`demo.note`、`demo.user`、`demo.poke-notification`、`demo.poke.dismiss` |
|
||||
|
||||
`voice.member.avatar` 是语音活动区头像;`voice.member.mic-status` 在成员麦克风静音时显示,状态值为 `muted`;`voice.member.action-trigger` 是打开宿主成员操作菜单的按钮,由成员卡片小组件的 `options.memberActions` 控制;`voice.member-row.avatar` 是右侧成员树头像。语音成员列表的动态项提供 `.ws-voice-member-enter-active`、`.ws-voice-member-leave-active`、`.ws-voice-member-enter-from`、`.ws-voice-member-leave-to` 和 `.ws-voice-member-move` 动效钩子,可分别设置加入、离开和排序变化的过渡。状态属性还会使用 `current`、`drag-over`、`dragging`、`self`、`events-empty` 和 `messages-empty`。当前根节点以及屏幕共享播放器、弹窗、菜单都属于同一皮肤作用域。
|
||||
|
||||
`voice.channel-tree`、`voice.server-switcher`、`voice.server-header` 和 `voice.server-banner` 是 WebSpeak 可信宿主控件。频道树按 TeamSpeak 返回的层级展示语音频道与成员;展开按钮只改变本地显示,双击频道或聚焦后按 Enter 才加入频道。服务器栏布局让频道成员保持可见,折叠按钮只收起子频道。成员头像和语音状态只在宿主渲染的频道树中出现,不会传给皮肤插件。服务器头部在宿主中展示状态并按频道名筛选;切换入口只列出本机收藏和最近连接,可用不透明本地标识触发既有连接流程;地址、密码和身份材料不会传给皮肤组件。服务器欢迎区需 `session.status.read`,从 TeamSpeak `serverinfo` 读取横幅 URL 和欢迎语;没有可用内容时隐藏。欢迎语作为纯文本渲染;`voice.server-banner.image`、`voice.server-banner.welcome`、`voice.server-banner.icon`、`voice.server-banner.title` 与 `voice.server-banner.body` 可由布局编辑器调整。
|
||||
|
||||
首页快速连接和语音工作区的服务器栏共用同一列表:收藏项排在前面,最近连接补在后面;地址相同的收藏与历史只显示一项。每项的星标按钮可在两个位置收藏或取消收藏,取消收藏后若该服务器仍在最近连接中,它会留在列表的最近连接位置。皮肤可通过 `data-ws-state="favorite|recent"` 区分首页条目,通过 `data-ws-server-kind="favorite|recent"` 区分语音栏条目。
|
||||
|
||||
首页身份选项支持导入 TeamSpeak `.ini` 或身份字段,并可导出为 TeamSpeak `.ini`;导入弹窗解析身份的过程在浏览器本地完成。自定义皮肤可以分别调整身份操作按钮、粘贴区、拖放区域、安全提示和弹窗按钮,但不得隐藏或弱化权限继承与私钥安全提示。
|
||||
|
||||
`voice.activity.artwork` 是位于语音活动区内容上方的固定装饰平面。皮肤可以在其上绘制带透明背景的立绘,让角色压住成员卡片或直播画面的边缘;平面本身不占布局空间、不拦截点击,成员和播放器控件仍保持可交互。只通过背景图及背景定位/缩放来适配素材,不改变其定位和层级。
|
||||
|
||||
`voice.member-panel` 的 `::before` 是成员栏耳机/场景插画层,宿主已固定它的尺寸、位置、透视和前后层级;皮肤只需提供透明背景素材并调整背景显示、滤镜或阴影,不能自行定位或改变尺寸。消息空状态的 `::before` / `::after` 预留给气泡等小型装饰,宿主负责形状位置;皮肤可以绘制边框、底色和点状背景,但标题和说明文字仍由 WebSpeak 翻译并保持可见。
|
||||
|
||||
皮肤与语言选择器的触发按钮、菜单和每个选项都提供上述通用部件钩子。`skin.option` 另带有 `data-ws-skin-id`(内置项为 `builtin.light`、`builtin.dark` 和 `community.illusia-voice`,实例皮肤项为其清单 ID);`language.option` 带有 `data-ws-language`。皮肤可以据此只装饰自己的选择项,而不影响其他皮肤、语言选项或选择器交互。例如:
|
||||
|
||||
```css
|
||||
[data-ws-part="skin.option"][data-ws-skin-id="community.illusia-voice"][role="option"] {
|
||||
background-image: linear-gradient(110deg, #efffff, #c8f3f2);
|
||||
}
|
||||
```
|
||||
|
||||
### 令牌、字体、动效和图片
|
||||
|
||||
皮肤只负责“画什么样”,不负责“放在哪里”。可用的视觉规则包括文字/背景颜色、背景图片及其裁切、圆角、轮廓、阴影、滤镜和动画;边框可用不占空间的内阴影绘制。推荐先定义皮肤变量,再为公开部件编写视觉规则:
|
||||
|
||||
```css
|
||||
:root {
|
||||
--skin-page-bg: #091317;
|
||||
--skin-panel: #142329;
|
||||
--skin-text: #edf8f5;
|
||||
--skin-muted: #9db5af;
|
||||
--skin-accent: #47dcc4;
|
||||
--skin-card-radius: 20px;
|
||||
}
|
||||
|
||||
[data-ws-part="voice.screen-player"] {
|
||||
border-radius: var(--skin-card-radius);
|
||||
box-shadow: 0 18px 50px #0008, inset 0 0 0 1px color-mix(in srgb, var(--skin-accent) 50%, transparent);
|
||||
}
|
||||
```
|
||||
|
||||
`url()` 只允许引用包内图片或 WOFF2 字体。支持 PNG、JPG/JPEG、WebP、AVIF、GIF 和 WOFF2;SVG 不接受。自带字体示例:
|
||||
|
||||
```css
|
||||
@font-face {
|
||||
font-family: "ILLUSIA Sans";
|
||||
src: url("assets/illusia-sans.woff2") format("woff2");
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
[data-ws-page="voice"] { font-family: "ILLUSIA Sans", sans-serif; }
|
||||
```
|
||||
|
||||
字体必须随包附带并拥有可再分发许可。自定义字体可能改变不同语言的字宽,因此校验器会给出提示;发布前必须检查中文、英语、德语、俄语和日语下的标题、按钮和长文案是否仍完整可读。字体族名和 `@keyframes` / `@layer` 名称会自动隔离,避免与其他皮肤冲突。请支持 `prefers-reduced-motion`,并确保焦点、错误、静音、正在说话等状态仍容易辨认。
|
||||
|
||||
### 固定布局与交互边界
|
||||
|
||||
以下 CSS 限制适用于 v1 和 v2:校验器会拒绝改变布局、定位、尺寸、文字流向/换行或交互命中区域的声明,包括 display、position、inset、z-index、宽高、内外边距、网格/弹性布局、间距、溢出裁切、变换、指针事件和字号等。v2 的位置和尺寸只从经过 schema 校验的 layout.json 生效。v3 为支持自由布局而允许这些声明,但仍限制皮肤根作用域、公开钩子、危险值和外部资源;只通过 CSS 隔离不能阻止皮肤作者遮挡控件。
|
||||
|
||||
因此,v1/v2 CSS 可以更换艺术素材、颜色和表面风格,但不能重排组件。v3 可以用 CSS 重新安排界面和组件盒子,也能隐藏普通界面部分;基础组件由宿主继续创建,宿主的恢复和权限 UI 位于皮肤作用域外。所有版本都应确保焦点、文字、键盘和触屏操作可用。
|
||||
|
||||
v1/v2 外观可以因窄屏而更换图片裁切或装饰,但 @media 规则也受固定布局限制。v2 应在布局数据中分别设置桌面、平板和手机配置;v3 可用媒体查询构建响应式 CSS。上线前仍需预览各设备尺寸、所有五种语言、键盘焦点、减少动效偏好,并确认必要控件可用、文字未被裁切。
|
||||
|
||||
## 安全边界和限制
|
||||
|
||||
校验在上传端和服务端执行;服务端只登记有效皮肤包,访客只能下载登记的包。当前限制如下:
|
||||
|
||||
| 项目 | 上限 |
|
||||
| --- | ---: |
|
||||
| ZIP `.wskin` | 20 MiB |
|
||||
| 解压总大小 | 50 MiB |
|
||||
| ZIP 条目数 | 128 |
|
||||
| 单个 CSS 文件 | 512 KiB |
|
||||
| `content.json` / `components.json` | 256 KiB |
|
||||
| 单张图片(包括预览) | 16 MiB |
|
||||
| 单个 WOFF2 字体 | 4 MiB |
|
||||
| 每实例皮肤数 | 50 |
|
||||
| 每实例皮肤包总存储 | 200 MiB |
|
||||
|
||||
压缩包路径穿越、重复/冲突路径、符号链接、异常 ZIP 元数据和本地文件头/目录不一致都会被拒绝。仅允许受支持的 CSS at-rule:`@media`、`@supports`、`@container`、具名 `@layer`、`@font-face` 和 keyframes。`@import`、脚本、HTML、外部网络资源会被拒绝;`!important` 可用于皮肤作用域内的样式。字体 `local()` 也会拒绝,避免绕过包内字体来源。
|
||||
|
||||
v1/v2 校验器会阻止隐藏必要操作控件和其容器。v3 可改变显示状态,因此皮肤开发者必须保留语音操作路径;授权界面、皮肤选择和恢复入口由宿主在皮肤作用域之外提供。以下选择器是旧格式对可选装饰部件的透明度白名单:
|
||||
|
||||
```css
|
||||
[data-ws-part="home.hero.eyebrow"]
|
||||
[data-ws-part="home.gateway-status"]
|
||||
[data-ws-part="home.features"]
|
||||
[data-ws-part="home.feature"]
|
||||
[data-ws-part="home.visitors"]
|
||||
[data-ws-part="voice.activity-heading"]
|
||||
[data-ws-part="voice.member.avatar"]
|
||||
[data-ws-part="voice.member.live-indicator"]
|
||||
[data-ws-part="voice.member-row.avatar"]
|
||||
[data-ws-part="voice.screen-player.viewer-avatar"]
|
||||
[data-ws-part="voice.screen-player.live"]
|
||||
[data-ws-part="demo.badge"]
|
||||
[data-ws-part="demo.wave"]
|
||||
[data-ws-part="demo.avatar"]
|
||||
[data-ws-part="demo.member-status"]
|
||||
[data-ws-part="demo.note"]
|
||||
```
|
||||
|
||||
上面必须使用单独的精确属性选择器;不能通过父容器、组合选择器或子元素间接隐藏/重置内容。关键帧只有在其动画仅被这些可选部件引用时,才可使用透明度归零;若关键帧也被必要控件引用或动画名通过变量指定,则会被拒绝。`clip`、`clip-path` 和 `mask` 一律不允许,避免视觉裁切误伤真实控件。校验器是防止布局回归的边界,不是视觉质量证明;自定义字体、复杂背景和高对比特效仍需人工检查文字可读性与控件辨识度。
|
||||
|
||||
皮肤可以重画控制外观。v1/v2 不能重新布置必要操作;v3 可以,因此须人工实测加入/退出、麦克风状态、设置、菜单、屏幕共享退出、音量、全屏等操作的可达性。校验成功不代表设计质量合格;提交前要逐页实测窄屏和桌面尺寸、所有界面语言、键盘焦点与减少动效设置。
|
||||
|
||||
CSS 被限定在 `.ws-skin-root` 内,管理员页面不会继承皮肤。删除实例里的包会停止从服务器提供该包;已经下载过的浏览器副本会保留在本地存储,因此仍可能在该浏览器的选择器中出现。清除该站点的浏览器数据可移除本地副本。
|
||||
|
||||
## 制作与验收
|
||||
|
||||
1. 选择最接近目标的 `docs/examples/` 示例,复制其皮肤源码目录,并修改 `manifest.json` 的唯一 `id`、名称、作者、版本和授权。ILLUSIA 是美术参考,不要求沿用它的角色或配色。
|
||||
2. 先查本文件和系统规格中已经发布的公开钩子、数据、控件和动作。不要依赖 Vue 内部 class、未公开的数据路径或某个实例的本地文件。
|
||||
3. 将皮肤的页面/组件结构、样式、文案、布局及所有资源放在包目录中:CSS/图片/字体写入 `skin.css` 和 `assets/`,可选多语言文案写入 `content.json`,声明式组件写入 `components.json`,作者默认布局写入 `layout.json`,当前支持的插件逻辑和资源放进 v4 `plugins/`。运行时动态数据使用公开上下文;TeamSpeak 行为使用已发布的宿主动作。
|
||||
4. 皮肤任务中不要修改 WebSpeak 核心客户端、服务端、共享协议或宿主控件。若没有足够的通用公开接口,先写明需要的数据/动作、权限和兼容性,再将它作为独立的平台工作处理;不要给某款皮肤增加专用核心分支。
|
||||
5. 在包根目录生成 ZIP,再改扩展名为 `.wskin`,只包含 manifest 声明的文件。PowerShell 示例:
|
||||
|
||||
```powershell
|
||||
Compress-Archive -Path .\docs\examples\illusia-voice\* -DestinationPath .\illusia-voice.zip -Force
|
||||
Rename-Item .\illusia-voice.zip illusia-voice.wskin
|
||||
```
|
||||
|
||||
6. 使用皮肤导入器验证生成的 `.wskin`,再在 `/admin/skins` 导入这个确切文件。用访客浏览器分别检查连接首页、语音页和 `/demo`;测试自定义图片、交互控件、会话状态、成员、聊天、屏幕共享及设置。v1/v2 检查固定布局;v2 检查作者默认布局和用户本地覆盖;v3/v4 检查授权拒绝/撤销、数据边界和失效恢复。
|
||||
7. 检查窄屏与桌面、所有支持的语言、长文案、键盘焦点、对比度和减少动效偏好,并确认素材可再分发。若声称跨实例可移植,应在两个兼容版本的实例导入同一份 `.wskin`,记录并比较文件 SHA-256;不要为第二个实例复制核心代码改动。
|
||||
|
||||
当前自动化回归涵盖 ZIP/清单验证、资源路径、CSS 隔离与拒绝规则、文案结构和服务端皮肤目录读写。视觉排版、内容遮挡和浏览器间表现仍须人工预览。
|
||||
|
||||
自绘成员列表时,`session.members` 可读取 `screenSharing` 与 `screenShareStreamId`;这两个成员字段和 `screenShare.streams` 一样要求 `voice.screenShare.read`。用 `member.screenSharing` 显示共享标记,再将 `member.screenShareStreamId` 绑定到 `voice.joinScreenShare`(还需 `voice.screenShare.control`)即可让用户观看。未声明/未获共享读取权限的皮肤不会收到这两个字段;整页替换皮肤仍须在自己的成员列表中绘制标记或观看入口。
|
||||
|
||||
\n
|
||||
@@ -0,0 +1,11 @@
|
||||
# ILLUSIA风
|
||||
|
||||
ILLUSIA 风格 is a schema v3 open-skin example built from the local artwork in [illusia-voice/assets](./illusia-voice/assets/). Version 2.0.2 keeps its existing light-glass CSS and current-channel card, adds matching visual treatment for the host member-card screen-share status and watch action, and uses a black letterbox background for the fixed WebSpeak screen-share player. The package still uses WebSpeak's base translations and contains no executable skin code.
|
||||
|
||||
The new voice-page component is defined in [components.json](./illusia-voice/components.json). It reads only the current public channel name through session.status.read and uses a local mascot image for a compact, non-interactive glass badge. The component needs the user's local approval before it renders; that approval is scoped to this skin version and can be revoked from the host access control. It cannot switch channels, read favorites, access a server address, or control audio.
|
||||
|
||||
The CSS continues to style the WebSpeak home page, voice workspace, screen-share player and /demo with cyan accents and original art. The homepage includes translucent navigation and selectors, animated mascot details, feature tiles, a visitor badge, a join action and a curved footer. The voice workspace includes the shared quick-server list, channel/member views, chat empty state, screen-share art and audio controls. The shared member cards detect active screen shares and show a themed live badge and watch button. The mobile view keeps WebSpeak's responsive host navigation while applying ILLUSIA colors and artwork.
|
||||
|
||||
The distributable package and the copy served from web/public/skins are built from the source folder. After changing source files, run `npm run skin:illusia:build` to recreate both copies. Run the package import test to confirm both copies stay byte-identical and valid.
|
||||
|
||||
Use only artwork you have permission to redistribute when publishing a skin to other WebSpeak instances.
|
||||
@@ -0,0 +1,48 @@
|
||||
# KAAK voice skin
|
||||
|
||||
The participant stage uses larger profile portraits (104px on desktop, reduced for narrow layouts). A live speaking state adds a pulsing accent ring and a visible waveform marker, including when participant names are hidden while chat is open. The ring and speaking status use KAAK's shared green accent.
|
||||
|
||||
The server sidebar can show the connected TeamSpeak virtual server's configured host-banner image and welcome message between the server header and channel tree. Both fields come from live server information; the card disappears when neither is configured, and a missing or failed banner image does not hide the welcome text. Welcome content is rendered as plain text.
|
||||
|
||||
The server sidebar can show the connected TeamSpeak virtual server's configured host-banner image and welcome message between the server header and channel tree. Both fields come from live server information; the card disappears when neither is configured, and a missing or failed banner image does not hide the welcome text. Welcome content is rendered as plain text.
|
||||
|
||||
The voice-channel sidebar follows KOOK's observed typography: 16px/700 server title, 12px/700 group title, 14px/700 channel title, and 12px/400 low-contrast member count.
|
||||
|
||||
Chat visibility is kept separately for each active TeamSpeak channel, so collapsing one room does not collapse the next room. TeamSpeak does not expose KOOK's music-channel category; a new channel therefore starts expanded until the user changes its chat visibility.
|
||||
|
||||
While the WebSpeak performance card is sampling, its refresh icon spins to show the busy state; the animation is disabled when reduced motion is requested.
|
||||
|
||||
KAAK is a schema v3 open-skin package with full connection and voice-workspace surfaces. Its desktop voice page follows KOOK's proportions: an 86px server rail with 58px icons and 18px vertical spacing, a 290px channel pane, a 40px top bar, a central participant stage, right-side chat attached to the current voice channel, and a lower-left voice dock. The server rail uses KOOK's rounded-square silhouette, a 2px green active outline and left-edge marker, with neutral fallback tiles and the muted purple active tile from the reference. The identity tile stays pinned at the bottom with a 54px circular monogram and connection-aware online dot; the server list scrolls when the window is short. The host provides a stable color-tone value derived only from the privacy-safe label, but the rail keeps the KOOK neutral tile treatment rather than exposing those tones. The KOOK voice room is the point-to-point visual reference: composition, member presentation, styling, and motion should be compared directly, rather than treating matching component types or approximate placement as sufficient. The left tree contains the TeamSpeak voice channels only; KOOK's separate text-channel group is outside this pass because TeamSpeak has no equivalent channel type. The current voice channel's text chat remains on the right. Closing it hides the entire panel, expands the participant stage, and leaves a reopen button in the stage heading; this happens without leaving the voice room. Its header uses the `#` channel mark and an unobtrusive close control; the composer sits at the bottom edge. Messages use author monograms, a separate identity/time line, and readable message text. The central stage uses WebSpeak's reusable member-card widget so available TeamSpeak profile avatars appear inside KAAK's participant tiles; the tiles use a wide 1.82:1 layout with a responsive grid to match KOOK's participant presentation. Member names stay hidden at rest while chat is open and fade upward into the lower-left label on hover; they remain visible while chat is collapsed. KAAK's CSS adds hover depth and a smoothly transitioning speaking ring driven by live voice state. Active screen shares appear on member cards with a live badge and a themed watch action; the share player remains a WebSpeak host component. The dock retains WebSpeak's trusted connection-quality, audio, and disconnect controls. Input/output volume buttons open hover or keyboard-focus panels with live numeric levels; sliders use a skin-colored progress track, a distinct thumb, and visible focus feedback. Audio input and output devices use a reusable keyboard-accessible picker with a scrollable option list, selected/highlighted states, and an animated chevron; KAAK styles the trigger and open list. The connection surface, voice workspace, and audio settings share KOOK's PingFang SC-first font stack; audio settings use 16px/600 section headings and observed 14px/400 field labels. Audio sliders use a 16px thumb with hover/focus feedback. The performance card opens with a short entrance motion and readable network/audio metrics. No real device, volume, or microphone state is changed during visual checks. The roster shows connected TeamSpeak clients only; it does not invent an offline list. Channel selection is single-click; joining is double-click. The narrow layout keeps the host's mobile controls available while retaining readable member tiles.
|
||||
|
||||
The single TeamSpeak voice-channel group in the left tree collapses and expands with a short two-way height and fade transition like KOOK's voice group; the separate KOOK text-channel group remains outside this pass. A first click selects a channel and reveals a brief “双击加入” hint; the hint disappears on the active room. The current voice-room heading keeps the channel name and live member count visible above the participant stage while the attached chat is expanded, matching KOOK's room view. Member cards expose WebSpeak's trusted member-actions menu from a small hover or keyboard-focus control; desktop cards also open it on right-click, and touch layouts keep the control visible. KAAK gives the host menu KOOK's compact dark panel, separated volume section, and highlighted action rows while keeping WebSpeak's own individual-volume slider and member actions; it does not add KOOK menu actions or skin-side audio logic.
|
||||
|
||||
The design target is the voice-client portion of KOOK, as requested by the project owner. It does not include discovery, companion/party, event, store, advertising, administrator, or other service-operator pages. It does not add a KOOK account flow, direct messages, server administration, or channels absent from the connected TeamSpeak server. The voice performance card also closes on outside click or Escape; Escape returns focus to its trigger, and its entrance/exit motion respects reduced-motion preferences.
|
||||
|
||||
The device picker now follows the public KOOK style geometry: a 40px trigger with 12px corners, a menu with 12px corners and 8px inset, and 32px rows with 2px gaps and 8px corners. Hover and selected rows use distinct low-contrast fills. The shared host measures the rendered menu before applying viewport limits, so skin-defined padding and row spacing stay visible without a KAAK-specific placement path. KAAK uses KOOK's dark-theme brand green (`#6cbf00`, `#7ac51a` hover) for speaker, slider, and control highlights. The performance trigger, metric values, volume readouts, audio settings icons, and sliders reuse the same accent tokens. Volume sliders use a 4px track, a 16px white thumb with a 2px brand-green border, and a 3px hover/focus halo without extra hover scaling.
|
||||
|
||||
The audio settings surface now follows the observed KOOK form proportions: a 660px dark card, 16px corners, 72px field rows, and a two-column label/control layout. Device and volume controls keep their WebSpeak behavior; only their shared form grouping and KAAK skin presentation changed. The layout stacks fields on narrow screens. KOOK's settings typography remains PingFang SC-first, with a 32px/600 title, 16px/600 section headings, and 14px/400 field labels.
|
||||
|
||||
The existing WebSpeak noise-suppression switch is available in the audio settings on desktop and mobile, matching its placement in KOOK's voice settings. It remains the browser's current noise-suppression control; KAAK does not claim to reproduce KOOK's branded processing modes.
|
||||
|
||||
## Reference access note
|
||||
|
||||
The owner authorized inspection of the first two voice rooms in the KOOK server. Both rooms were entered and viewed; the microphone remained off and no message was sent. The in-room view confirmed a single large participant tile in the center, a separate right-side panel for the active voice channel's text chat, a narrow server rail, grouped voice channels, and a compact voice-control dock near the lower left. The chat was empty, so no message contents were recorded. Server/room identifiers and member names were not recorded.
|
||||
|
||||
## Components and permissions
|
||||
|
||||
The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, cached profile-avatar display inside the trusted member-card widget, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen-share status/read/control. Its member-card widget explicitly enables share status and watch actions; the KAAK dock uses the host's screen-share control. The performance panel hides only share transport metrics. The host renders trusted connection, language, skin, and audio controls. KAAK 3.1.78 keeps the shared-screen player inside the central voice-stage column with an explicit responsive height, so the player cannot collapse when the host applies its inline video sizing; member cards scroll in the remaining area. The full source image remains visible with black letterboxing. Server and channel password prompts use the compact dark KAAK dialog style while retaining WebSpeak's trusted password, error, cancel, and retry behavior. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control.
|
||||
|
||||
The server header uses the live, privacy-filtered TeamSpeak server label and a trusted `voice.server-switcher` menu backed by favorites and recent connections. Its click handler reuses WebSpeak's existing connection flow with an opaque local ID; addresses and credentials never enter skin data. The left panel uses the trusted `voice.channel-tree` widget to retain TeamSpeak channel nesting, member counts and capacity, available avatars, and mute/speaking/away states. Expanding a branch is local UI state, a single click selects a channel, and double-click joins it. With `memberActions` enabled, right-clicking another member row opens WebSpeak's existing host-owned action menu. With `memberDragDrop` enabled, another member can be dragged onto a different channel row; the member row and target channel receive visual feedback, and the host reuses its existing move-client operation. Both options default off for other skins. The skin does not add KOOK's separate text-channel list.
|
||||
|
||||
On desktop, right-clicking another member row in the channel tree or member card opens WebSpeak's existing host-owned member actions menu. Member cards also retain their accessible action button; keyboard activation remains anchored to that button, and touch layouts keep it available. The menu's actions come from WebSpeak and are unchanged by the skin.
|
||||
|
||||
Member cards are rendered by WebSpeak's trusted `voice.member-cards` widget. It displays an already available TeamSpeak profile avatar, or the host-generated nickname initial when no avatar is available; image bytes stay in the host and are not exposed in the skin's data context or Wasm runtime. The skin does not receive server addresses, passwords, identity keys, raw audio, private messages, or arbitrary network/storage APIs. Its markup is data-only; it contains no executable JavaScript or Wasm. The `/demo` page uses synthetic data and does not connect to TeamSpeak.
|
||||
|
||||
## Files
|
||||
|
||||
- Source package: [kaak-voice](./kaak-voice/)
|
||||
- Component schema: [components.json](./kaak-voice/components.json)
|
||||
- Distributable archive: [kaak-voice.wskin](./kaak-voice.wskin)
|
||||
- Shared format and safety rules: [SKIN_DEVELOPMENT.md](../SKIN_DEVELOPMENT.md)
|
||||
|
||||
KAAK is included in the public skin selector and its `.wskin` archive is also available as a standalone package. After changing the source, run `npm run skin:kaak:build` to rebuild both copies, then run the package tests and verify the connection page, approval, denial, revoke, desktop, and narrow-screen paths in the local browser. The connected voice surface can be verified when a TeamSpeak session is available.
|
||||
@@ -0,0 +1,10 @@
|
||||
# Open Voice Surface scaffold
|
||||
|
||||
This importable schema v3 surface package exercises complete public home and voice pages using only declarative nodes and WebSpeak-owned controls. It includes server switching, channel navigation, visible members, per-member screen-share status and a watch action, chat, audio, whisper, connection controls, and the built-in language and skin selectors. It contains no discovery, events, shop, companion, advertising, or administration pages.
|
||||
|
||||
This is an implementation scaffold for testing the open-skin format, not a pixel-matched KOOK skin. The visual reference was read in the in-app browser in the first two user-authorized voice rooms. The separate [KAAK voice sample](./KAAK-VOICE.md) records the voice-only layout findings and applies them to the channel and member sidebars. No server/room identifiers, member names, or chat contents were retained. Discovery, companion shop, events, ads, and operator/admin pages are outside the sample's scope.
|
||||
|
||||
- Source: [open-voice-surface](./open-voice-surface/)
|
||||
- Importable package: [open-voice-surface.wskin](./open-voice-surface.wskin)
|
||||
- Shared component and permission rules: [skin development guide](../SKIN_DEVELOPMENT.md)
|
||||
- Current runtime contract and safety boundaries: [skin development guide](../SKIN_DEVELOPMENT.md)
|
||||
@@ -0,0 +1,9 @@
|
||||
# Harbor Voice Workspace
|
||||
|
||||
这是一个 KOOK 语音工作区风格的完整皮肤测试包,参考范围只限语音客户端:服务器快捷栏、频道列表、中央聊天、成员列表和底部语音控制。没有复用 KOOK 的图片、标志、广告或站点文案,也没有加入发现、陪玩、派对、商城、活动通知、排行榜或管理后台。
|
||||
|
||||
皮肤使用 `components.json` 的完整声明式 surface 自己构建频道树、聊天消息与输入框、成员状态和悄悄话控制;底部音频区嵌入 WebSpeak 的可信音频控件,继续使用现有麦克风/扬声器开关和音频设置(包括麦克风灵敏度)。样例隐藏与语音布局无关的伴奏开关;断开和频道控制仍由 WebSpeak 校验并执行。频道缩进直接映射 TeamSpeak 公开树深度;频道单击只改变皮肤本地选中态,双击才请求 TeamSpeak 切换频道。语音成员列表显示公开的说话、静音和离开状态。消息、频道和成员数据由权限筛选后提供。屏幕共享启动保留一个可自行排版和换肤的可信宿主按钮,以保留浏览器要求的真实用户手势;视频流和设备 API 不交给皮肤代码。皮肤不读取服务器地址、账号凭据或连接密钥,也不包含可执行 JavaScript/Wasm;这个样例用于验证 v3 surface 的可定制界面和交互,v4 Wasm 插件运行时另由运行时测试覆盖。
|
||||
|
||||
桌面布局保留四个区域:服务器快捷栏、频道树、聊天区和成员区;服务器栏底部展示当前 TeamSpeak 昵称,连接后语音控制坞固定在频道栏底部。昵称项只呈现当前会话身份,不模拟 KOOK 账号或资料运营功能。窄屏下服务器栏保持可用,频道项转为横向滚动,成员与语音控制各自占一行,基础连接控制不被隐藏。
|
||||
|
||||
`manifest.json`、`components.json` 与 `skin.css` 是可编辑源码。根目录的 `../harbor-voice.wskin` 是源码打包后的本地导入包;源码修改后运行 `npm run skin:harbor:build` 重新打包,再在测试实例的皮肤管理页导入验证。当前没有加入公共皮肤目录或发布到服务器。
|
||||
@@ -0,0 +1,480 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"components": [
|
||||
{
|
||||
"id": "harbor-home",
|
||||
"name": "Harbor connection home",
|
||||
"page": "home",
|
||||
"mode": "surface",
|
||||
"accessibleName": "WebSpeak connection page",
|
||||
"permissions": ["ui.surface.replace"],
|
||||
"actions": {},
|
||||
"root": {
|
||||
"tag": "main",
|
||||
"part": "home",
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "home-header",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
|
||||
{ "tag": "span", "part": "brand-name", "children": [{ "text": "WEBSPEAK" }] },
|
||||
{ "widget": "app.language-switcher", "part": "language" },
|
||||
{ "widget": "app.skin-switcher", "part": "skin" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "section",
|
||||
"part": "connection-card",
|
||||
"children": [
|
||||
{ "tag": "p", "part": "eyebrow", "children": [{ "text": "VOICE CLIENT" }] },
|
||||
{ "tag": "h1", "part": "title", "children": [{ "text": "Connect with your community" }] },
|
||||
{ "tag": "p", "part": "description", "children": [{ "text": "Choose a TeamSpeak server and return to your voice channels." }] },
|
||||
{ "widget": "home.connection-form", "part": "connection-form" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "footer",
|
||||
"part": "home-footer",
|
||||
"children": [{ "text": "Your connection and identity stay under WebSpeak's control." }]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "harbor-workspace",
|
||||
"name": "Harbor voice workspace",
|
||||
"page": "voice",
|
||||
"mode": "surface",
|
||||
"accessibleName": "WebSpeak voice workspace",
|
||||
"permissions": [
|
||||
"ui.surface.replace",
|
||||
"session.status.read",
|
||||
"session.channels.read",
|
||||
"session.members.read",
|
||||
"session.channel.join",
|
||||
"servers.quickList.read",
|
||||
"servers.quickList.switch",
|
||||
"chat.channel.read",
|
||||
"chat.channel.send",
|
||||
"audio.status.read",
|
||||
"audio.microphone.control",
|
||||
"audio.output.control",
|
||||
"voice.whisper.status.read",
|
||||
"voice.whisper.control",
|
||||
"voice.disconnect",
|
||||
"voice.screenShare.read",
|
||||
"voice.screenShare.control"
|
||||
],
|
||||
"actions": {
|
||||
"switch-server": {
|
||||
"type": "quickServers.switch",
|
||||
"args": { "quickServerId": "{{server.id}}" }
|
||||
},
|
||||
"select-channel": {
|
||||
"type": "ui.setState",
|
||||
"args": { "key": "selectedchannel", "value": "{{channel.id}}" }
|
||||
},
|
||||
"join-channel": {
|
||||
"type": "voice.joinChannel",
|
||||
"args": { "channelId": "{{channel.id}}" }
|
||||
},
|
||||
"send-message": {
|
||||
"type": "chat.sendMessage",
|
||||
"args": { "text": "{{state.message}}" }
|
||||
},
|
||||
"disconnect": { "type": "voice.disconnect", "args": {} },
|
||||
"whisper-on": { "type": "voice.setWhisperActive", "args": { "active": true } },
|
||||
"whisper-off": { "type": "voice.setWhisperActive", "args": { "active": false } },
|
||||
"watch-screen-share": {
|
||||
"type": "voice.joinScreenShare",
|
||||
"args": { "streamId": "{{member.screenShareStreamId}}" }
|
||||
},
|
||||
"watch-channel-member-screen-share": {
|
||||
"type": "voice.joinScreenShare",
|
||||
"args": { "streamId": "{{voicemember.screenShareStreamId}}" }
|
||||
}
|
||||
},
|
||||
"state": { "selectedchannel": "", "message": "" },
|
||||
"root": {
|
||||
"tag": "main",
|
||||
"part": "workspace",
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "topbar",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
|
||||
{ "tag": "span", "part": "brand-name", "children": [{ "text": "WEBSPEAK" }] },
|
||||
{ "tag": "span", "part": "server-title", "children": [{ "text": "{{session.status.serverLabel}}" }] },
|
||||
{ "widget": "app.language-switcher", "part": "language" },
|
||||
{ "widget": "app.skin-switcher", "part": "skin" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "nav",
|
||||
"part": "server-rail",
|
||||
"attributes": { "aria-label": "Favorite and recent servers" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "quick-server-item",
|
||||
"repeat": { "path": "servers.quickList", "as": "server" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "quick-server",
|
||||
"attributes": {
|
||||
"type": "button",
|
||||
"aria-current": "{{server.current}}",
|
||||
"aria-label": "Switch to {{server.label}}"
|
||||
},
|
||||
"events": { "click": "switch-server" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "server-monogram", "children": [{ "text": "{{server.label}}" }] },
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "server-kind",
|
||||
"when": { "path": "server.favorite", "equals": true },
|
||||
"children": [{ "text": "Saved" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "server-kind",
|
||||
"when": { "path": "server.kind", "equals": "recent" },
|
||||
"children": [{ "text": "Recent" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "aside",
|
||||
"part": "channel-panel",
|
||||
"attributes": { "aria-label": "Server channels" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "server-summary",
|
||||
"children": [
|
||||
{ "tag": "strong", "part": "server-name", "children": [{ "text": "{{session.status.serverLabel}}" }] },
|
||||
{ "tag": "small", "part": "server-subtitle", "children": [{ "text": "VOICE CHANNELS" }] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "nav",
|
||||
"part": "channel-list",
|
||||
"attributes": { "aria-label": "Channels" },
|
||||
"children": [
|
||||
{ "tag": "h2", "part": "section-label", "children": [{ "text": "CHANNELS" }] },
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "channel-item",
|
||||
"repeat": { "path": "session.channels", "as": "channel" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "channel-row",
|
||||
"attributes": {
|
||||
"type": "button",
|
||||
"aria-current": "{{channel.current}}",
|
||||
"aria-label": "Double-click to join {{channel.name}}",
|
||||
"data-depth": "{{channel.depth}}"
|
||||
},
|
||||
"events": { "click": "select-channel", "dblclick": "join-channel" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "channel-glyph", "children": [{ "text": "◉" }] },
|
||||
{ "tag": "span", "part": "channel-name", "children": [{ "text": "{{channel.name}}" }] },
|
||||
{ "tag": "small", "part": "channel-count", "children": [{ "text": "{{channel.memberCount}}" }] },
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "selected-channel-indicator",
|
||||
"when": { "path": "state.selectedchannel", "equals": "{{channel.id}}" },
|
||||
"attributes": { "aria-label": "Selected" }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "ul",
|
||||
"part": "channel-voice-members",
|
||||
"when": { "path": "channel.current", "equals": true },
|
||||
"attributes": { "aria-label": "Members connected to this channel" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "li",
|
||||
"part": "channel-voice-member",
|
||||
"repeat": { "path": "channel.members", "as": "voicemember" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "channel-member-avatar", "children": [{ "text": "{{voicemember.name}}" }] },
|
||||
{ "tag": "span", "part": "channel-member-name", "children": [{ "text": "{{voicemember.name}}" }] },
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "channel-member-muted",
|
||||
"when": { "path": "voicemember.status", "equals": "muted" },
|
||||
"attributes": { "aria-label": "Microphone muted" },
|
||||
"children": [{ "text": "MIC OFF" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "channel-member-away",
|
||||
"when": { "path": "voicemember.status", "equals": "away" },
|
||||
"attributes": { "aria-label": "Away" },
|
||||
"children": [{ "text": "AWAY" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "channel-member-state",
|
||||
"when": { "path": "voicemember.self", "equals": true },
|
||||
"children": [{ "text": "YOU" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "channel-member-state",
|
||||
"when": { "path": "voicemember.speaking", "equals": true },
|
||||
"attributes": { "aria-label": "Speaking" },
|
||||
"children": [{ "text": "●" }]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "channel-member-screen-share",
|
||||
"when": { "path": "voicemember.screenSharing", "equals": true },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "channel-member-screen-share-live", "children": [{ "text": "SHARING" }] },
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "channel-member-screen-share-watch",
|
||||
"when": { "path": "voicemember.self", "equals": false },
|
||||
"attributes": { "type": "button", "aria-label": "Watch {{voicemember.name}}'s screen" },
|
||||
"events": { "click": "watch-channel-member-screen-share" },
|
||||
"children": [{ "text": "WATCH" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "section",
|
||||
"part": "conversation",
|
||||
"attributes": { "aria-label": "Current channel conversation" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "conversation-heading",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "conversation-glyph", "children": [{ "text": "◉" }] },
|
||||
{ "tag": "h1", "part": "channel-title", "children": [{ "text": "{{session.status.channelName}}" }] },
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "connection-state",
|
||||
"when": { "path": "session.status.connected", "equals": true },
|
||||
"children": [{ "text": "CONNECTED" }]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "chat",
|
||||
"children": [
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "chat-message-list",
|
||||
"attributes": { "aria-label": "Current channel messages", "role": "log", "aria-live": "polite" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "p",
|
||||
"part": "chat-empty",
|
||||
"when": { "path": "chat.messages", "empty": true },
|
||||
"children": [{ "text": "No messages yet. Say hello to the channel." }]
|
||||
},
|
||||
{
|
||||
"tag": "article",
|
||||
"part": "chat-message",
|
||||
"repeat": { "path": "chat.messages", "as": "message" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "chat-message-heading",
|
||||
"children": [
|
||||
{ "tag": "strong", "part": "chat-message-author", "children": [{ "text": "{{message.author}}" }] },
|
||||
{ "tag": "time", "part": "chat-message-time", "children": [{ "text": "{{message.time}}" }] }
|
||||
]
|
||||
},
|
||||
{ "tag": "p", "part": "chat-message-text", "children": [{ "text": "{{message.text}}" }] }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "form",
|
||||
"part": "chat-composer",
|
||||
"events": { "submit": "send-message" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "input",
|
||||
"part": "chat-input",
|
||||
"bindValue": "message",
|
||||
"attributes": {
|
||||
"type": "text",
|
||||
"maxlength": 1000,
|
||||
"autocomplete": "off",
|
||||
"placeholder": "Message this channel",
|
||||
"aria-label": "Message this channel"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "chat-send",
|
||||
"attributes": { "type": "submit", "aria-label": "Send message" },
|
||||
"children": [{ "text": "Send" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "widget": "voice.screen-share-player", "part": "screen-player" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "aside",
|
||||
"part": "members-panel",
|
||||
"attributes": { "aria-label": "Members in this channel" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "members-heading",
|
||||
"children": [
|
||||
{ "tag": "h2", "part": "section-label", "children": [{ "text": "MEMBERS" }] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "ul",
|
||||
"part": "member-list",
|
||||
"children": [
|
||||
{
|
||||
"tag": "li",
|
||||
"part": "member-row",
|
||||
"repeat": { "path": "session.members", "as": "member" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "member-avatar", "children": [{ "text": "{{member.name}}" }] },
|
||||
{ "tag": "span", "part": "member-name", "children": [{ "text": "{{member.name}}" }] },
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "speaking-indicator",
|
||||
"when": { "path": "member.speaking", "equals": true },
|
||||
"attributes": { "aria-label": "Speaking" },
|
||||
"children": [{ "text": "SPEAKING" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "member-muted-state",
|
||||
"when": { "path": "member.status", "equals": "muted" },
|
||||
"attributes": { "aria-label": "Microphone muted" },
|
||||
"children": [{ "text": "MIC OFF" }]
|
||||
},
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "member-away-state",
|
||||
"when": { "path": "member.status", "equals": "away" },
|
||||
"attributes": { "aria-label": "Away" },
|
||||
"children": [{ "text": "AWAY" }]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "member-screen-share",
|
||||
"when": { "path": "member.screenSharing", "equals": true },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "member-screen-share-live", "children": [{ "text": "SHARING" }] },
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "member-screen-share-watch",
|
||||
"when": { "path": "member.self", "equals": false },
|
||||
"attributes": { "type": "button", "aria-label": "Watch {{member.name}}'s screen" },
|
||||
"events": { "click": "watch-screen-share" },
|
||||
"children": [{ "text": "WATCH" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "whisper-controls",
|
||||
"children": [
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "whisper-start",
|
||||
"when": { "path": "whisper.status.active", "equals": false },
|
||||
"attributes": { "type": "button", "aria-label": "Start whisper" },
|
||||
"events": { "click": "whisper-on" },
|
||||
"children": [{ "text": "Whisper" }]
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "whisper-stop",
|
||||
"when": { "path": "whisper.status.active", "equals": true },
|
||||
"attributes": { "type": "button", "aria-label": "Stop whisper" },
|
||||
"events": { "click": "whisper-off" },
|
||||
"children": [{ "text": "Whisper on" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "footer",
|
||||
"part": "voice-dock",
|
||||
"attributes": { "aria-label": "Voice controls" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "voice-dock-heading",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "connection-indicator", "children": [{ "text": "●" }] },
|
||||
{ "tag": "strong", "part": "voice-channel-name", "children": [{ "text": "{{session.status.channelName}}" }] },
|
||||
{ "tag": "span", "part": "voice-dock-caption", "children": [{ "text": "VOICE CONNECTED" }] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "voice-dock-actions",
|
||||
"children": [
|
||||
{ "widget": "voice.screen-share-start", "part": "screen-share-start" },
|
||||
{ "widget": "voice.audio-controls", "part": "audio-controls" },
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "disconnect-control",
|
||||
"attributes": { "type": "button", "aria-label": "Disconnect voice" },
|
||||
"events": { "click": "disconnect" },
|
||||
"children": [{ "text": "Leave" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "identity-entry",
|
||||
"when": { "path": "session.status.userName" },
|
||||
"attributes": { "role": "group", "aria-label": "Current TeamSpeak identity" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "identity-monogram", "children": [{ "text": "TS" }] },
|
||||
{ "tag": "span", "part": "identity-name", "children": [{ "text": "{{session.status.userName}}" }] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"packageType": "open-skin",
|
||||
"id": "community.harbor-voice",
|
||||
"name": "Harbor Voice Workspace",
|
||||
"version": "1.1.1",
|
||||
"author": "WebSpeak Project",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "A KOOK-inspired dark voice workspace using only WebSpeak host controls and public session data.",
|
||||
"entry": "skin.css",
|
||||
"components": "components.json",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--skin-harbor-bg: #17181b;
|
||||
--skin-harbor-rail: #141518;
|
||||
--skin-harbor-panel: #1d1e22;
|
||||
--skin-harbor-raised: #292a2f;
|
||||
--skin-harbor-hover: #303137;
|
||||
--skin-harbor-border: #303136;
|
||||
--skin-harbor-text: #f0f1f3;
|
||||
--skin-harbor-muted: #a0a2a8;
|
||||
--skin-harbor-dim: #777a82;
|
||||
--skin-harbor-accent: #58c877;
|
||||
--skin-harbor-danger: #e36b6b;
|
||||
--skin-harbor-radius: 9px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home"] {
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
justify-items: center;
|
||||
min-height: 100dvh;
|
||||
gap: 28px;
|
||||
padding: clamp(16px, 4vw, 42px);
|
||||
color: var(--skin-harbor-text);
|
||||
background:
|
||||
radial-gradient(ellipse at 50% 44%, #25272b 0, transparent 58%),
|
||||
var(--skin-harbor-bg);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.home-header"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
width: min(100%, 1080px);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.brand-mark"],
|
||||
[data-ws-plugin-part="harbor-workspace.brand-mark"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: 0 0 34px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
color: #101512;
|
||||
background: var(--skin-harbor-accent);
|
||||
font-size: 14px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.brand-name"],
|
||||
[data-ws-plugin-part="harbor-workspace.brand-name"] {
|
||||
color: var(--skin-harbor-text);
|
||||
font-size: 12px;
|
||||
font-weight: 850;
|
||||
letter-spacing: .1em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.language"] { margin-left: auto; }
|
||||
|
||||
[data-ws-plugin-part="harbor-home.connection-card"] {
|
||||
align-self: center;
|
||||
width: min(100%, 510px);
|
||||
padding: clamp(22px, 5vw, 40px);
|
||||
border: 1px solid var(--skin-harbor-border);
|
||||
border-radius: 16px;
|
||||
background: color-mix(in srgb, var(--skin-harbor-panel) 96%, transparent);
|
||||
box-shadow: 0 24px 70px #0007;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.eyebrow"] {
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .14em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.title"] {
|
||||
margin: 12px 0 8px;
|
||||
font-size: clamp(26px, 5vw, 38px);
|
||||
letter-spacing: -.04em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.description"],
|
||||
[data-ws-plugin-part="harbor-home.home-footer"] {
|
||||
color: var(--skin-harbor-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home.home-footer"] {
|
||||
width: min(100%, 1080px);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home"] .join-card {
|
||||
color: var(--skin-harbor-text);
|
||||
background: transparent;
|
||||
border-color: var(--skin-harbor-border);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home"] .field-wrap,
|
||||
[data-ws-plugin-part="harbor-home"] .settings-select {
|
||||
color: var(--skin-harbor-muted);
|
||||
background: var(--skin-harbor-raised);
|
||||
border-color: var(--skin-harbor-border);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-home"] .field-wrap input,
|
||||
[data-ws-plugin-part="harbor-home"] .settings-select {
|
||||
color: var(--skin-harbor-text);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] {
|
||||
display: grid;
|
||||
grid-template-columns: 68px 276px minmax(340px, 1fr) 244px;
|
||||
grid-template-rows: 54px minmax(0, 1fr);
|
||||
width: 100%;
|
||||
height: 100dvh;
|
||||
min-height: 560px;
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-text);
|
||||
background: var(--skin-harbor-bg);
|
||||
font-family: Inter, "Segoe UI", system-ui, sans-serif;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"],
|
||||
[data-ws-plugin-part="harbor-workspace"] * {
|
||||
scrollbar-color: #4a4c51 transparent;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] *::-webkit-scrollbar { width: 6px; height: 6px; }
|
||||
[data-ws-plugin-part="harbor-workspace"] *::-webkit-scrollbar-thumb { background: #4a4c51; border-radius: 6px; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.topbar"] {
|
||||
z-index: 2;
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
min-width: 0;
|
||||
padding: 0 14px;
|
||||
border-bottom: 1px solid var(--skin-harbor-border);
|
||||
background: var(--skin-harbor-rail);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-title"] {
|
||||
overflow: hidden;
|
||||
margin-right: auto;
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-rail"] {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 13px 7px;
|
||||
background: var(--skin-harbor-rail);
|
||||
border-right: 1px solid #ffffff08;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"] {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 3px;
|
||||
width: 52px;
|
||||
min-height: 54px;
|
||||
padding: 4px;
|
||||
border: 0;
|
||||
border-radius: 13px;
|
||||
color: var(--skin-harbor-muted);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"]:hover,
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"]:focus-visible {
|
||||
color: var(--skin-harbor-text);
|
||||
background: var(--skin-harbor-raised);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"][aria-current="true"] {
|
||||
color: var(--skin-harbor-text);
|
||||
background: var(--skin-harbor-raised);
|
||||
box-shadow: inset 3px 0 var(--skin-harbor-accent);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-monogram"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #ffffff12;
|
||||
border-radius: 13px;
|
||||
color: var(--skin-harbor-text);
|
||||
background: linear-gradient(145deg, #383a40, #222429);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-kind"] {
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 8px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.identity-entry"] {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
margin-top: auto;
|
||||
padding: 9px 1px 1px;
|
||||
border-top: 1px solid var(--skin-harbor-border);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.identity-monogram"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border: 1px solid #ffffff18;
|
||||
border-radius: 50%;
|
||||
color: var(--skin-harbor-text);
|
||||
background: linear-gradient(145deg, #4a4c53, #292a30);
|
||||
font-size: 10px;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.identity-name"] {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-panel"] {
|
||||
z-index: 1;
|
||||
grid-column: 2;
|
||||
grid-row: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 12px 9px 118px;
|
||||
border-right: 1px solid var(--skin-harbor-border);
|
||||
background: var(--skin-harbor-panel);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-summary"] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-height: 49px;
|
||||
padding: 3px 9px 13px;
|
||||
border-bottom: 1px solid #ffffff0b;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-name"] {
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-text);
|
||||
font-size: 13px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-subtitle"],
|
||||
[data-ws-plugin-part="harbor-workspace.section-label"] {
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-list"] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-height: 0;
|
||||
padding-top: 13px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.section-label"] { margin: 0 8px 7px; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"] {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
width: 100%;
|
||||
min-height: 38px;
|
||||
padding: 6px 9px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
color: var(--skin-harbor-muted);
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.selected-channel-indicator"] {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: 1px solid var(--skin-harbor-accent);
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"]:hover,
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][aria-current="true"] {
|
||||
color: var(--skin-harbor-text);
|
||||
background: var(--skin-harbor-raised);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][aria-current="true"] {
|
||||
box-shadow: inset 2px 0 var(--skin-harbor-accent);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="1"] { padding-inline-start: 19px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="2"] { padding-inline-start: 29px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="3"] { padding-inline-start: 39px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="4"] { padding-inline-start: 49px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="5"] { padding-inline-start: 59px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="6"] { padding-inline-start: 69px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="7"] { padding-inline-start: 79px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth="8"] { padding-inline-start: 89px; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-glyph"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 18px;
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-name"] {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-count"] {
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-voice-members"] {
|
||||
display: grid;
|
||||
gap: 1px;
|
||||
margin: 0 0 6px 29px;
|
||||
padding: 2px 0 3px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-voice-member"] {
|
||||
display: grid;
|
||||
grid-template-columns: 18px minmax(0, 1fr) auto auto;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-height: 21px;
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-avatar"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
color: var(--skin-harbor-text);
|
||||
background: #393b41;
|
||||
font-size: 7px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-name"] {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-state"] {
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-muted"],
|
||||
[data-ws-plugin-part="harbor-workspace.member-muted-state"] {
|
||||
color: var(--skin-harbor-danger);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-away"],
|
||||
[data-ws-plugin-part="harbor-workspace.member-away-state"] {
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-screen-share"] {
|
||||
grid-column: 2 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-screen-share-watch"],
|
||||
[data-ws-plugin-part="harbor-workspace.member-screen-share-watch"] {
|
||||
min-height: 28px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid #7ed95755;
|
||||
border-radius: 5px;
|
||||
color: var(--skin-harbor-text);
|
||||
background: var(--skin-harbor-raised);
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-member-screen-share-watch"]:hover,
|
||||
[data-ws-plugin-part="harbor-workspace.member-screen-share-watch"]:hover {
|
||||
color: var(--skin-harbor-accent);
|
||||
background: #313238;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.conversation"] {
|
||||
grid-column: 3;
|
||||
grid-row: 2;
|
||||
display: grid;
|
||||
grid-template-rows: 48px minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
padding: 0 17px 12px;
|
||||
background: var(--skin-harbor-bg);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.conversation-heading"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
min-width: 0;
|
||||
border-bottom: 1px solid var(--skin-harbor-border);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.conversation-glyph"] {
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-title"] {
|
||||
min-width: 0;
|
||||
margin: 0 auto 0 0;
|
||||
overflow: hidden;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.connection-state"] {
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .06em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] [data-ws-part="voice.chat"] {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
color: var(--skin-harbor-text);
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat"] {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-text);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message-list"] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
gap: 14px;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 8px 4px 16px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-empty"] {
|
||||
align-self: center;
|
||||
margin: auto;
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message"] { min-width: 0; }
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message-heading"] { display: flex; align-items: baseline; gap: 8px; }
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message-author"] { color: var(--skin-harbor-text); font-size: 12px; }
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message-time"] { color: var(--skin-harbor-dim); font-size: 10px; }
|
||||
[data-ws-plugin-part="harbor-workspace.chat-message-text"] { margin: 3px 0 0; color: var(--skin-harbor-muted); font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-composer"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--skin-harbor-border);
|
||||
border-radius: 9px;
|
||||
background: var(--skin-harbor-panel);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-input"] {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 38px;
|
||||
padding: 0 10px;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
color: var(--skin-harbor-text);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.chat-send"] {
|
||||
min-width: 54px;
|
||||
min-height: 36px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: #111;
|
||||
background: var(--skin-harbor-accent);
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] .chat-panel { min-height: 0; background: transparent; }
|
||||
[data-ws-plugin-part="harbor-workspace"] .chat-heading { border-color: var(--skin-harbor-border); }
|
||||
[data-ws-plugin-part="harbor-workspace"] .message-bubble { color: var(--skin-harbor-text); background: var(--skin-harbor-panel); }
|
||||
[data-ws-plugin-part="harbor-workspace"] .message-composer { border-color: var(--skin-harbor-border); background: var(--skin-harbor-panel); }
|
||||
[data-ws-plugin-part="harbor-workspace"] .message-composer input { color: var(--skin-harbor-text); }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.members-panel"] {
|
||||
grid-column: 4;
|
||||
grid-row: 2;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 16px 11px 118px;
|
||||
border-left: 1px solid var(--skin-harbor-border);
|
||||
background: var(--skin-harbor-panel);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.members-heading"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.members-heading"] .section-label { margin: 0; }
|
||||
[data-ws-plugin-part="harbor-workspace.member-total"] { color: var(--skin-harbor-dim); font-size: 11px; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-list"] {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
margin: 8px 0 16px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-row"] {
|
||||
display: grid;
|
||||
grid-template-columns: 32px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
column-gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 4px 5px;
|
||||
border-radius: 6px;
|
||||
color: var(--skin-harbor-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-row"]:hover { background: var(--skin-harbor-raised); }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-avatar"] {
|
||||
grid-row: span 2;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
color: var(--skin-harbor-text);
|
||||
background: #393b41;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-name"] {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-text);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.speaking-indicator"] {
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .05em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-muted-state"],
|
||||
[data-ws-plugin-part="harbor-workspace.member-away-state"],
|
||||
[data-ws-plugin-part="harbor-workspace.speaking-indicator"] { grid-column: 2 / -1; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.member-screen-share"] {
|
||||
grid-column: 2 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 8px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock"] {
|
||||
z-index: 4;
|
||||
grid-column: 2;
|
||||
grid-row: 2;
|
||||
align-self: end;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px 8px;
|
||||
min-width: 0;
|
||||
padding: 9px;
|
||||
border: 1px solid var(--skin-harbor-border);
|
||||
border-radius: 10px;
|
||||
background: #222328;
|
||||
box-shadow: 0 8px 20px #0005;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-heading"] {
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
grid-template-columns: 10px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 2px 7px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-actions"] {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.connection-indicator"] {
|
||||
grid-row: span 2;
|
||||
color: var(--skin-harbor-accent);
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-channel-name"] {
|
||||
overflow: hidden;
|
||||
color: var(--skin-harbor-text);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-caption"] {
|
||||
color: var(--skin-harbor-dim);
|
||||
font-size: 8px;
|
||||
letter-spacing: .05em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.audio-controls"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.microphone-control"],
|
||||
[data-ws-plugin-part="harbor-workspace.output-control"],
|
||||
[data-ws-plugin-part="harbor-workspace.disconnect-control"],
|
||||
[data-ws-plugin-part="harbor-workspace.whisper-start"],
|
||||
[data-ws-plugin-part="harbor-workspace.whisper-stop"] {
|
||||
min-width: 38px;
|
||||
min-height: 38px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid var(--skin-harbor-border);
|
||||
border-radius: 7px;
|
||||
color: var(--skin-harbor-muted);
|
||||
background: var(--skin-harbor-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.microphone-control"][aria-pressed="true"],
|
||||
[data-ws-plugin-part="harbor-workspace.output-control"][aria-pressed="true"] { color: var(--skin-harbor-danger); }
|
||||
[data-ws-plugin-part="harbor-workspace.disconnect-control"] { color: var(--skin-harbor-danger); }
|
||||
[data-ws-plugin-part="harbor-workspace.output-volume"] { width: 72px; accent-color: var(--skin-harbor-accent); }
|
||||
[data-ws-plugin-part="harbor-workspace.whisper-controls"] { display: flex; gap: 6px; margin-top: 12px; }
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] { flex: 0 0 auto; }
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--skin-harbor-border);
|
||||
border-radius: 7px;
|
||||
color: var(--skin-harbor-muted);
|
||||
background: var(--skin-harbor-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button:hover:not(:disabled),
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button:focus-visible { color: var(--skin-harbor-accent); }
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button:disabled { opacity: .45; cursor: not-allowed; }
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button span {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace"] .desktop-audio-dock {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 4px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace"] .desktop-audio-dock-copy { display: none; }
|
||||
[data-ws-plugin-part="harbor-workspace"] .desktop-audio-dock-actions { gap: 2px; }
|
||||
[data-ws-plugin-part="harbor-workspace"] .dock-audio-button { width: 34px; height: 34px; color: var(--skin-harbor-muted); }
|
||||
[data-ws-plugin-part="harbor-workspace"] .dock-audio-button:hover,
|
||||
[data-ws-plugin-part="harbor-workspace"] .dock-audio-button:focus-visible { color: var(--skin-harbor-accent); background: var(--skin-harbor-raised); border-color: var(--skin-harbor-border); }
|
||||
[data-ws-plugin-part="harbor-workspace.audio-controls"] .accompaniment-toggle { display: none; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.disconnect-control"] {
|
||||
display: grid;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] .ws-plugin-disconnect-control {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
color: var(--skin-harbor-danger);
|
||||
background: var(--skin-harbor-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] .ws-plugin-disconnect-control:hover { background: #3a292b; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace"] button:focus-visible,
|
||||
[data-ws-plugin-part="harbor-home"] button:focus-visible,
|
||||
[data-ws-plugin-part="harbor-home"] input:focus-visible {
|
||||
outline: 2px solid var(--skin-harbor-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
@media (max-width: 1060px) {
|
||||
[data-ws-plugin-part="harbor-workspace"] {
|
||||
grid-template-columns: 60px 236px minmax(300px, 1fr) 204px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
[data-ws-plugin-part="harbor-workspace"] {
|
||||
grid-template-columns: 56px minmax(0, 1fr);
|
||||
grid-template-rows: 50px 126px minmax(220px, 1fr) 82px 74px;
|
||||
height: 100dvh;
|
||||
min-height: 540px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.topbar"] { padding: 0 8px; gap: 7px; }
|
||||
[data-ws-plugin-part="harbor-workspace.brand-mark"] { flex-basis: 28px; width: 28px; height: 28px; }
|
||||
[data-ws-plugin-part="harbor-workspace.brand-name"] { font-size: 10px; }
|
||||
[data-ws-plugin-part="harbor-workspace.server-title"] { font-size: 10px; }
|
||||
[data-ws-plugin-part="harbor-workspace.server-rail"] { grid-column: 1; grid-row: 2 / 6; padding: 8px 3px; }
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"] { width: 48px; min-height: 48px; }
|
||||
[data-ws-plugin-part="harbor-workspace.server-monogram"] { width: 36px; height: 36px; }
|
||||
[data-ws-plugin-part="harbor-workspace.identity-monogram"] { width: 34px; height: 34px; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.channel-panel"] {
|
||||
grid-column: 2;
|
||||
grid-row: 2;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: 30px minmax(0, 1fr);
|
||||
gap: 4px;
|
||||
overflow: hidden;
|
||||
padding: 5px 8px;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--skin-harbor-border);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-summary"] {
|
||||
min-height: 0;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 2px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.server-name"] { max-width: 60%; font-size: 11px; }
|
||||
[data-ws-plugin-part="harbor-workspace.server-subtitle"],
|
||||
[data-ws-plugin-part="harbor-workspace.channel-list"] > [data-ws-plugin-part="harbor-workspace.section-label"] { display: none; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-list"] {
|
||||
flex-direction: row;
|
||||
gap: 5px;
|
||||
overflow: auto hidden;
|
||||
padding: 0;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.channel-item"] { flex: 0 0 auto; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"] { width: max-content; min-width: 116px; min-height: 42px; margin: 0; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-row"][data-depth] { padding-inline-start: 9px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-voice-members"] { display: none; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.conversation"] {
|
||||
grid-column: 2;
|
||||
grid-row: 3;
|
||||
grid-template-rows: 40px minmax(0, 1fr) auto;
|
||||
gap: 6px;
|
||||
padding: 0 8px 6px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.members-panel"] {
|
||||
grid-column: 2;
|
||||
grid-row: 4;
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
overflow: hidden;
|
||||
padding: 5px 8px;
|
||||
border-top: 1px solid var(--skin-harbor-border);
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.members-heading"] { gap: 5px; }
|
||||
[data-ws-plugin-part="harbor-workspace.members-heading"] .section-label { max-width: 60px; font-size: 8px; }
|
||||
[data-ws-plugin-part="harbor-workspace.member-list"] {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
overflow: auto hidden;
|
||||
margin: 0;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.member-row"] { flex: 0 0 auto; grid-template-columns: 28px auto; min-height: 38px; padding: 2px 4px; }
|
||||
[data-ws-plugin-part="harbor-workspace.member-avatar"] { width: 26px; height: 26px; }
|
||||
[data-ws-plugin-part="harbor-workspace.speaking-indicator"] { display: none; }
|
||||
[data-ws-plugin-part="harbor-workspace.member-muted-state"],
|
||||
[data-ws-plugin-part="harbor-workspace.member-away-state"] { display: none; }
|
||||
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock"] {
|
||||
grid-column: 2;
|
||||
grid-row: 5;
|
||||
align-self: stretch;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-heading"] { grid-column: auto; grid-row: auto; }
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-actions"] { grid-column: 2; grid-row: 1; justify-content: flex-end; gap: 3px; }
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock-caption"] { display: none; }
|
||||
[data-ws-plugin-part="harbor-workspace.disconnect-control"] { grid-column: 2; grid-row: 1; }
|
||||
[data-ws-plugin-part="harbor-workspace.audio-controls"] .mobile-voice-controls { display: flex; gap: 4px; }
|
||||
[data-ws-plugin-part="harbor-workspace.audio-controls"] .mobile-voice-toggle { min-width: 44px; min-height: 44px; border-radius: 7px; color: var(--skin-harbor-muted); background: var(--skin-harbor-raised); }
|
||||
[data-ws-plugin-part="harbor-workspace.microphone-control"],
|
||||
[data-ws-plugin-part="harbor-workspace.output-control"],
|
||||
[data-ws-plugin-part="harbor-workspace.disconnect-control"] { min-width: 42px; min-height: 44px; }
|
||||
[data-ws-plugin-part="harbor-workspace.output-volume"] { width: 58px; }
|
||||
[data-ws-plugin-part="harbor-workspace.screen-share-start"] button { width: 42px; height: 44px; }
|
||||
}
|
||||
|
||||
@media (max-width: 460px) {
|
||||
[data-ws-plugin-part="harbor-workspace"] { grid-template-columns: 50px minmax(0, 1fr); }
|
||||
[data-ws-plugin-part="harbor-workspace.server-rail"] { padding-inline: 1px; }
|
||||
[data-ws-plugin-part="harbor-workspace.quick-server"] { width: 44px; }
|
||||
[data-ws-plugin-part="harbor-workspace.identity-name"] { max-width: 43px; }
|
||||
[data-ws-plugin-part="harbor-workspace.topbar"] { padding-inline: 5px; }
|
||||
[data-ws-plugin-part="harbor-workspace.brand-name"] { display: none; }
|
||||
[data-ws-plugin-part="harbor-workspace.server-title"] { max-width: 100px; }
|
||||
[data-ws-plugin-part="harbor-workspace.channel-panel"] { grid-column: 2; }
|
||||
[data-ws-plugin-part="harbor-workspace.conversation"] { grid-column: 2; }
|
||||
[data-ws-plugin-part="harbor-workspace.members-panel"] { grid-column: 2; }
|
||||
[data-ws-plugin-part="harbor-workspace.voice-dock"] { grid-column: 2; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[data-ws-plugin-part="harbor-home"] *,
|
||||
[data-ws-plugin-part="harbor-workspace"] * {
|
||||
scroll-behavior: auto;
|
||||
animation-duration: .01ms;
|
||||
animation-iteration-count: 1;
|
||||
transition-duration: .01ms;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1014 KiB |
|
After Width: | Height: | Size: 365 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 738 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 249 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 85 KiB |
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"components": [
|
||||
{
|
||||
"id": "illusia-now-playing",
|
||||
"name": "ILLUSIA 当前频道 / current channel",
|
||||
"page": "voice",
|
||||
"accessibleName": "当前语音频道 / Current voice channel",
|
||||
"permissions": ["session.status.read"],
|
||||
"actions": {},
|
||||
"root": {
|
||||
"tag": "aside",
|
||||
"part": "room-card",
|
||||
"className": "illusia-now-playing",
|
||||
"attributes": { "role": "status" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "small",
|
||||
"part": "eyebrow",
|
||||
"children": [{ "text": "ILLUSIA · 当前频道 / NOW IN" }]
|
||||
},
|
||||
{
|
||||
"tag": "strong",
|
||||
"part": "channel-name",
|
||||
"children": [{ "text": "{{session.status.channelName}}" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"packageType": "open-skin",
|
||||
"id": "community.illusia-voice",
|
||||
"name": "ILLUSIA风",
|
||||
"version": "2.0.2",
|
||||
"author": "WebSpeak Project",
|
||||
"license": "All rights reserved",
|
||||
"description": "A bright original-character art skin with a safe declarative live-channel badge.",
|
||||
"entry": "skin.css",
|
||||
"components": "components.json",
|
||||
"preview": "assets/background-composite.webp",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"defaultLocale": "zh-CN",
|
||||
"locales": {
|
||||
"zh-CN": { "home": { "brandName": "KAAK" }, "messages": { "passwordDialogConfirm": "确定" } },
|
||||
"en": { "home": { "brandName": "KAAK" }, "messages": { "passwordDialogConfirm": "Confirm" } },
|
||||
"de": { "home": { "brandName": "KAAK" }, "messages": { "passwordDialogConfirm": "Bestätigen" } },
|
||||
"ru": { "home": { "brandName": "KAAK" }, "messages": { "passwordDialogConfirm": "Подтвердить" } },
|
||||
"ja": { "home": { "brandName": "KAAK" }, "messages": { "passwordDialogConfirm": "確定" } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"packageType": "open-skin",
|
||||
"id": "community.kaak-voice",
|
||||
"name": "KAAK",
|
||||
"version": "3.1.115",
|
||||
"author": "WebSpeak Project",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "A KOOK-inspired WebSpeak skin with a split-screen connection home, searchable server header, TeamSpeak banner, nested channel members, unified chat with local history, and a compact audio dock.",
|
||||
"entry": "skin.css",
|
||||
"components": "components.json",
|
||||
"content": "content.json",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"components": [
|
||||
{
|
||||
"id": "open-voice-home",
|
||||
"name": "Open voice connection page",
|
||||
"page": "home",
|
||||
"mode": "surface",
|
||||
"accessibleName": "WebSpeak connection page",
|
||||
"permissions": ["ui.surface.replace"],
|
||||
"actions": {},
|
||||
"root": {
|
||||
"tag": "main",
|
||||
"part": "home",
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "home-header",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
|
||||
{ "tag": "span", "part": "brand-name", "children": [{ "text": "VOICE SPACE" }] },
|
||||
{ "widget": "app.language-switcher", "part": "language" },
|
||||
{ "widget": "app.skin-switcher", "part": "skin" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "section",
|
||||
"part": "connection-card",
|
||||
"children": [
|
||||
{ "tag": "p", "part": "eyebrow", "children": [{ "text": "TEAM SPEAK · VOICE CLIENT" }] },
|
||||
{ "tag": "h1", "part": "title", "children": [{ "text": "Connect with your people" }] },
|
||||
{ "tag": "p", "part": "description", "children": [{ "text": "Join a voice server and continue where your community meets." }] },
|
||||
{ "widget": "home.connection-form", "part": "connection-form" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "footer",
|
||||
"part": "home-footer",
|
||||
"children": [{ "text": "Your connection and identity remain managed by WebSpeak." }]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "open-voice-workspace",
|
||||
"name": "Open voice workspace",
|
||||
"page": "voice",
|
||||
"mode": "surface",
|
||||
"accessibleName": "WebSpeak voice workspace",
|
||||
"permissions": [
|
||||
"ui.surface.replace",
|
||||
"session.status.read",
|
||||
"servers.quickList.read",
|
||||
"servers.quickList.switch",
|
||||
"session.channels.read",
|
||||
"session.members.read",
|
||||
"session.channel.join",
|
||||
"chat.channel.read",
|
||||
"chat.channel.send",
|
||||
"audio.status.read",
|
||||
"audio.microphone.control",
|
||||
"audio.output.control",
|
||||
"voice.whisper.status.read",
|
||||
"voice.whisper.control",
|
||||
"voice.disconnect",
|
||||
"voice.screenShare.read",
|
||||
"voice.screenShare.control"
|
||||
],
|
||||
"actions": {
|
||||
"switch-server": {
|
||||
"type": "quickServers.switch",
|
||||
"args": { "quickServerId": "{{server.id}}" }
|
||||
},
|
||||
"join-channel": {
|
||||
"type": "voice.joinChannel",
|
||||
"args": { "channelId": "{{channel.id}}" }
|
||||
},
|
||||
"watch-screen-share": {
|
||||
"type": "voice.joinScreenShare",
|
||||
"args": { "streamId": "{{member.screenShareStreamId}}" }
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"tag": "main",
|
||||
"part": "workspace",
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "workspace-header",
|
||||
"children": [
|
||||
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
|
||||
{ "tag": "strong", "part": "server-title", "children": [{ "text": "{{session.status.channelName}}" }] },
|
||||
{ "widget": "app.language-switcher", "part": "language" },
|
||||
{ "widget": "app.skin-switcher", "part": "skin" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "nav",
|
||||
"part": "quick-rail",
|
||||
"attributes": { "aria-label": "Favorite and recent servers" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "quick-server-item",
|
||||
"repeat": { "path": "servers.quickList", "as": "server" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "quick-server",
|
||||
"attributes": {
|
||||
"type": "button",
|
||||
"aria-current": "{{server.current}}",
|
||||
"aria-label": "Switch to {{server.label}}"
|
||||
},
|
||||
"events": { "click": "switch-server" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "server-monogram", "children": [{ "text": "{{server.label}}" }] },
|
||||
{
|
||||
"tag": "small",
|
||||
"part": "server-kind",
|
||||
"when": { "path": "server.favorite", "equals": true },
|
||||
"children": [{ "text": "Favorite" }]
|
||||
},
|
||||
{
|
||||
"tag": "small",
|
||||
"part": "server-kind",
|
||||
"when": { "path": "server.kind", "equals": "recent" },
|
||||
"children": [{ "text": "Recent" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "nav",
|
||||
"part": "channels",
|
||||
"attributes": { "aria-label": "Voice channels" },
|
||||
"children": [
|
||||
{ "tag": "h2", "part": "section-title", "children": [{ "text": "VOICE CHANNELS" }] },
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "channel-item",
|
||||
"repeat": { "path": "session.channels", "as": "channel" },
|
||||
"children": [
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "channel-row",
|
||||
"attributes": {
|
||||
"type": "button",
|
||||
"aria-current": "{{channel.current}}",
|
||||
"aria-label": "Join {{channel.name}}"
|
||||
},
|
||||
"events": { "dblclick": "join-channel", "keydown": "join-channel" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "channel-glyph", "children": [{ "text": "◖" }] },
|
||||
{ "tag": "span", "part": "channel-name", "children": [{ "text": "{{channel.name}}" }] },
|
||||
{ "tag": "small", "part": "channel-count", "children": [{ "text": "{{channel.memberCount}}" }] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "section",
|
||||
"part": "conversation",
|
||||
"children": [
|
||||
{
|
||||
"tag": "header",
|
||||
"part": "conversation-heading",
|
||||
"children": [
|
||||
{ "tag": "h1", "part": "channel-title", "children": [{ "text": "{{session.status.channelName}}" }] },
|
||||
{ "tag": "span", "part": "connection-state", "children": [{ "text": "Connected" }] }
|
||||
]
|
||||
},
|
||||
{ "widget": "voice.chat-panel", "part": "chat" },
|
||||
{ "widget": "voice.screen-share-player", "part": "screen-share" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "aside",
|
||||
"part": "members-and-controls",
|
||||
"children": [
|
||||
{ "tag": "h2", "part": "section-title", "children": [{ "text": "IN THIS CHANNEL" }] },
|
||||
{
|
||||
"tag": "ul",
|
||||
"part": "member-list",
|
||||
"children": [
|
||||
{
|
||||
"tag": "li",
|
||||
"part": "member-row",
|
||||
"repeat": { "path": "session.members", "as": "member" },
|
||||
"children": [
|
||||
{ "tag": "span", "part": "member-avatar", "children": [{ "text": "{{member.name}}" }] },
|
||||
{ "tag": "span", "part": "member-name", "children": [{ "text": "{{member.name}}" }] },
|
||||
{
|
||||
"tag": "small",
|
||||
"part": "speaking-indicator",
|
||||
"when": { "path": "member.speaking", "equals": true },
|
||||
"attributes": { "aria-label": "Speaking" },
|
||||
"children": [{ "text": "Speaking" }]
|
||||
},
|
||||
{
|
||||
"tag": "div",
|
||||
"part": "member-screen-share",
|
||||
"when": { "path": "member.screenSharing", "equals": true },
|
||||
"children": [
|
||||
{
|
||||
"tag": "span",
|
||||
"part": "member-screen-share-live",
|
||||
"attributes": { "role": "status" },
|
||||
"children": [{ "text": "Sharing screen" }]
|
||||
},
|
||||
{
|
||||
"tag": "button",
|
||||
"part": "member-screen-share-watch",
|
||||
"when": { "path": "member.self", "equals": false },
|
||||
"attributes": { "type": "button", "aria-label": "Watch {{member.name}}'s screen" },
|
||||
"events": { "click": "watch-screen-share" },
|
||||
"children": [{ "text": "Watch" }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "widget": "voice.whisper-controls", "part": "whisper" },
|
||||
{ "widget": "voice.audio-controls", "part": "audio" },
|
||||
{ "widget": "voice.connection-controls", "part": "connection" },
|
||||
{ "widget": "voice.disconnect-control", "part": "disconnect" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"schemaVersion": 3,
|
||||
"packageType": "open-skin",
|
||||
"id": "community.open-voice-surface",
|
||||
"name": "Open Voice Surface",
|
||||
"version": "1.0.1",
|
||||
"author": "WebSpeak Project",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "A complete, script-free public voice client surface scaffold.",
|
||||
"entry": "skin.css",
|
||||
"components": "components.json",
|
||||
"minAppVersion": "0.2.7"
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--skin-voice-bg: #111318;
|
||||
--skin-voice-panel: #191c24;
|
||||
--skin-voice-raised: #222631;
|
||||
--skin-voice-text: #f0f1f5;
|
||||
--skin-voice-muted: #969baa;
|
||||
--skin-voice-accent: #8e7bff;
|
||||
--skin-voice-live: #62d5a7;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home"] {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
justify-items: center;
|
||||
gap: 32px;
|
||||
padding: clamp(18px, 5vw, 56px);
|
||||
color: var(--skin-voice-text);
|
||||
background: radial-gradient(ellipse at 50% 42%, #25253c 0, var(--skin-voice-bg) 66%);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.home-header"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: min(100%, 1080px);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.brand-mark"],
|
||||
[data-ws-plugin-part="open-voice-workspace.brand-mark"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 14px;
|
||||
color: white;
|
||||
background: var(--skin-voice-accent);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.brand-name"] {
|
||||
margin-right: auto;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .14em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.connection-card"] {
|
||||
align-self: center;
|
||||
width: min(100%, 520px);
|
||||
padding: clamp(22px, 5vw, 42px);
|
||||
border: 1px solid #ffffff17;
|
||||
border-radius: 24px;
|
||||
background: color-mix(in srgb, var(--skin-voice-panel) 94%, transparent);
|
||||
box-shadow: 0 28px 90px #0008;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.eyebrow"],
|
||||
[data-ws-plugin-part="open-voice-workspace.section-title"] {
|
||||
color: var(--skin-voice-muted);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .14em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.title"] {
|
||||
margin: 10px 0;
|
||||
font-size: clamp(27px, 5vw, 40px);
|
||||
letter-spacing: -.04em;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-home.description"],
|
||||
[data-ws-plugin-part="open-voice-home.home-footer"] {
|
||||
color: var(--skin-voice-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace"] {
|
||||
display: grid;
|
||||
grid-template-columns: 72px 228px minmax(320px, 1fr) 252px;
|
||||
grid-template-rows: 62px minmax(0, 1fr);
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
color: var(--skin-voice-text);
|
||||
background: var(--skin-voice-bg);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.workspace-header"] {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 0 18px;
|
||||
border-bottom: 1px solid #ffffff12;
|
||||
background: #171920;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.server-title"] { margin-right: auto; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.quick-rail"] {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
overflow-y: auto;
|
||||
padding: 14px 8px;
|
||||
background: #171920;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.quick-server"] {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 4px;
|
||||
width: 52px;
|
||||
min-height: 58px;
|
||||
padding: 5px;
|
||||
border: 0;
|
||||
border-radius: 16px;
|
||||
color: var(--skin-voice-muted);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.quick-server"][aria-current="true"] {
|
||||
color: white;
|
||||
background: var(--skin-voice-accent);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.server-monogram"] {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
overflow: hidden;
|
||||
border-radius: 12px;
|
||||
background: #ffffff18;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.server-kind"] { font-size: 8px; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channels"],
|
||||
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 18px 12px;
|
||||
background: var(--skin-voice-panel);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channels"] { grid-column: 2; grid-row: 2; }
|
||||
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] { grid-column: 4; grid-row: 2; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-row"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
padding: 9px 10px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
color: var(--skin-voice-muted);
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-row"][aria-current="true"] {
|
||||
color: var(--skin-voice-text);
|
||||
background: var(--skin-voice-raised);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-name"] { flex: 1; }
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-count"] { font-size: 11px; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.conversation"] {
|
||||
grid-column: 3;
|
||||
grid-row: 2;
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr) auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
padding: 18px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.conversation-heading"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-height: 46px;
|
||||
border-bottom: 1px solid #ffffff12;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-title"] { margin-right: auto; }
|
||||
[data-ws-plugin-part="open-voice-workspace.connection-state"] { color: var(--skin-voice-live); font-size: 12px; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.member-list"] {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 12px 0 20px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.member-row"] {
|
||||
display: grid;
|
||||
grid-template-columns: 34px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
column-gap: 10px;
|
||||
color: var(--skin-voice-text);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.member-avatar"] {
|
||||
grid-row: span 2;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
color: white;
|
||||
background: var(--skin-voice-raised);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.speaking-indicator"] { color: var(--skin-voice-live); font-size: 10px; }
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.member-screen-share"] {
|
||||
grid-column: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--skin-voice-live);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.member-screen-share-watch"] {
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid color-mix(in srgb, var(--skin-voice-live) 50%, transparent);
|
||||
border-radius: 7px;
|
||||
color: var(--skin-voice-text);
|
||||
background: var(--skin-voice-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.chat"],
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.audio-controls"],
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.connection-controls"],
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.disconnect-control"],
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.whisper-controls"],
|
||||
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.screen-player"] {
|
||||
border-radius: 12px;
|
||||
color: var(--skin-voice-text);
|
||||
background-color: var(--skin-voice-panel);
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace"] button:focus-visible {
|
||||
outline: 2px solid var(--skin-voice-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
[data-ws-plugin-part="open-voice-workspace"] {
|
||||
grid-template-columns: 58px minmax(0, 1fr);
|
||||
grid-template-rows: 56px minmax(320px, 1fr) auto;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
|
||||
[data-ws-plugin-part="open-voice-workspace.workspace-header"] { padding: 0 10px; }
|
||||
[data-ws-plugin-part="open-voice-workspace.quick-rail"] { grid-column: 1; grid-row: 2; }
|
||||
[data-ws-plugin-part="open-voice-workspace.channels"] {
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 3;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
padding: 8px;
|
||||
}
|
||||
[data-ws-plugin-part="open-voice-workspace.section-title"] { display: none; }
|
||||
[data-ws-plugin-part="open-voice-workspace.channel-row"] { width: max-content; min-width: 130px; margin: 0; }
|
||||
[data-ws-plugin-part="open-voice-workspace.conversation"] {
|
||||
grid-column: 2;
|
||||
grid-row: 2;
|
||||
padding: 10px;
|
||||
}
|
||||
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] {
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 4;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
[data-ws-plugin-part="open-voice-workspace.member-list"] { grid-column: 1 / -1; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[data-ws-plugin-part="open-voice-workspace"] *,
|
||||
[data-ws-plugin-part="open-voice-home"] * {
|
||||
scroll-behavior: auto;
|
||||
animation-duration: .01ms;
|
||||
animation-iteration-count: 1;
|
||||
transition-duration: .01ms;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 61 KiB |
@@ -0,0 +1,38 @@
|
||||
# Android client
|
||||
|
||||
The Android app packages the Vue client with a small local gateway. Capacitor starts the embedded Node.js runtime, the gateway listens on `127.0.0.1:3040`, and the WebView opens that local address. The gateway is loopback-only; it does not expose an HTTP listener to the LAN. Release APKs are debug-signed sideload packages, not Google Play builds.
|
||||
|
||||
## Build on Windows
|
||||
|
||||
Use a short checkout path such as `C:\src\webspeak`. The Node.js plugin's CMake/Ninja object paths can exceed the Windows toolchain limit in deeply nested workspaces. A clean build in a nested validation directory failed with CMake's 250-character object-path warning and a Ninja `mkdir` error; the same source and dependencies built successfully from a shorter path. Changing application code or the embedded runtime is not required for this build-host issue.
|
||||
|
||||
Use the server development Node.js version (22.5 or newer) on the build host. Install all three dependency sets, then prepare and sync the Android project:
|
||||
|
||||
```powershell
|
||||
npm ci --ignore-scripts --no-audit --no-fund
|
||||
npm run prepare:sdk
|
||||
npm rebuild @discordjs/opus --foreground-scripts --no-audit --no-fund
|
||||
npm --prefix web ci --no-audit --no-fund
|
||||
npm --prefix mobile ci --no-audit --no-fund
|
||||
npm run android:sync
|
||||
```
|
||||
|
||||
Build the debug APKs with Android Studio's JDK and the checked-in Gradle wrapper:
|
||||
|
||||
```powershell
|
||||
$env:JAVA_HOME = "C:\Program Files\Android\Android Studio\jbr"
|
||||
$env:ANDROID_HOME = "$env:LOCALAPPDATA\Android\Sdk"
|
||||
Set-Location web\android
|
||||
.\gradlew.bat assembleDebug
|
||||
```
|
||||
|
||||
Gradle writes one APK per supported CPU architecture under `web/android/app/build/outputs/apk/debug/`: `arm64-v8a`, `armeabi-v7a`, and `x86_64`. Use `arm64-v8a` for most modern Android phones and `x86_64` for the Android emulator. GitHub Releases contains all three APKs with versioned filenames.
|
||||
|
||||
## Current scope
|
||||
|
||||
- Platform startup is isolated in `web/src/platform/`. Ordinary browser sessions mount directly; the native shell loads the Node.js plugin only while waiting for its loopback gateway. Startup errors, timeouts and page exit release polling and message listeners. Retry repeats the readiness handshake without restarting the embedded Node.js runtime.
|
||||
- The local gateway serves the join page, public configuration, skin package, join-ticket endpoint, and voice WebSocket bridge.
|
||||
- The admin console and server-side skin management are not available in the Android package.
|
||||
- Mobile audio encoding uses the JavaScript/WASM Opus codec. The normal server build continues to use the native Opus codec.
|
||||
- The embedded runtime supplied by the current Capacitor Node.js plugin is Node.js 18.20.4. The gateway, identity parsing, and Opus encode/decode paths have been smoke-checked on that runtime. The TeamSpeak SDK declares Node.js 20.19 or newer, so real TeamSpeak connectivity and two-way audio remain unverified on Android; the APKs are for sideload testing.
|
||||
- Android WebView on the tested emulator does not expose `getDisplayMedia`; screen sharing needs a native MediaProjection integration. A persistent Android foreground service and real-device background audio behavior also remain to be implemented and verified.
|
||||
@@ -0,0 +1,33 @@
|
||||
const path = require("node:path");
|
||||
const os = require("node:os");
|
||||
let app;
|
||||
let channel;
|
||||
try {
|
||||
({ app, channel } = require("bridge"));
|
||||
} catch (error) {
|
||||
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
||||
app = { datadir: () => path.join(os.tmpdir(), "webspeak-android-gateway-dev") };
|
||||
channel = { on: () => {}, post: () => {} };
|
||||
}
|
||||
|
||||
process.env.WEBSPEAK_MOBILE = "1";
|
||||
process.env.WEBSPEAK_DATA_DIR = app.datadir();
|
||||
process.env.WEBSPEAK_MOBILE_WWW = path.join(__dirname, "www");
|
||||
process.env.WEBSPEAK_VERSION = require("./package.json").version;
|
||||
|
||||
let gatewayReady = false;
|
||||
const gatewayPort = Number(process.env.WEBSPEAK_MOBILE_PORT || 3040);
|
||||
channel.on("webspeak-health", () => {
|
||||
channel.post("webspeak-health", { ready: gatewayReady, port: gatewayPort });
|
||||
});
|
||||
|
||||
import("./dist/mobile/index.js")
|
||||
.then(() => {
|
||||
gatewayReady = true;
|
||||
channel.post("webspeak-health", { ready: true, port: gatewayPort });
|
||||
})
|
||||
.catch((error) => {
|
||||
const message = error instanceof Error ? error.stack || error.message : String(error);
|
||||
console.error("WebSpeak mobile gateway failed:", message);
|
||||
channel.post("webspeak-error", { message });
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { cp, mkdir, readdir, copyFile, stat, readFile, writeFile, rm } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const mobileDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(mobileDir, "..");
|
||||
const webDist = path.join(rootDir, "web", "dist");
|
||||
const outputDir = path.join(webDist, "nodejs");
|
||||
|
||||
for (const required of [path.join(rootDir, "dist", "mobile", "index.js"), path.join(mobileDir, "node_modules"), path.join(webDist, "index.html")]) {
|
||||
if (!(await stat(required).catch(() => null))) throw new Error(`Missing Android build input: ${required}`);
|
||||
}
|
||||
|
||||
await rm(outputDir, { recursive: true, force: true });
|
||||
await mkdir(path.join(outputDir, "www"), { recursive: true });
|
||||
await cp(path.join(rootDir, "dist"), path.join(outputDir, "dist"), { recursive: true, force: true });
|
||||
await cp(path.join(mobileDir, "node_modules"), path.join(outputDir, "node_modules"), { recursive: true, force: true });
|
||||
await copyFile(path.join(mobileDir, "index.cjs"), path.join(outputDir, "index.cjs"));
|
||||
const appPackage = JSON.parse(await readFile(path.join(rootDir, "package.json"), "utf8"));
|
||||
const mobilePackage = JSON.parse(await readFile(path.join(mobileDir, "package.json"), "utf8"));
|
||||
mobilePackage.version = appPackage.version;
|
||||
await writeFile(path.join(outputDir, "package.json"), `${JSON.stringify(mobilePackage, null, 2)}\n`);
|
||||
|
||||
for (const entry of await readdir(webDist, { withFileTypes: true })) {
|
||||
if (entry.name === "nodejs") continue;
|
||||
await cp(path.join(webDist, entry.name), path.join(outputDir, "www", entry.name), { recursive: entry.isDirectory(), force: true });
|
||||
}
|
||||
|
||||
console.log(`Android gateway assets prepared at ${outputDir}`);
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "webspeak-android-gateway",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"dependencies": {
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#56d426d24852c39439f7bfe1d5850b574a1b0811",
|
||||
"express": "^4.21.2",
|
||||
"opusscript": "^0.1.1",
|
||||
"pino": "^10.3.1",
|
||||
"werift": "0.24.4",
|
||||
"ws": "^8.20.0"
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
{
|
||||
"name": "webspeak-webclient",
|
||||
"version": "0.1.4",
|
||||
"version": "0.2.7",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "webspeak-webclient",
|
||||
"version": "0.1.4",
|
||||
"version": "0.2.7",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#f38dee6",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#758a0d7d9120b0f5777d9451fb6b134f0b606f65",
|
||||
"express": "^5.2.1",
|
||||
"pino": "^10.3.1",
|
||||
"postcss": "^8.5.29",
|
||||
"postcss-selector-parser": "^7.1.6",
|
||||
"postcss-value-parser": "^4.2.0",
|
||||
"werift": "0.24.4",
|
||||
"ws": "^8.20.0"
|
||||
},
|
||||
@@ -62,8 +65,8 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@echosixhiya/teamspeak-client": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#f38dee6cd83c0fd4f6e00fc9c1ff4ec79dcbfd55",
|
||||
"version": "0.2.5",
|
||||
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#758a0d7d9120b0f5777d9451fb6b134f0b606f65",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@noble/curves": "^2.0.1"
|
||||
@@ -1198,6 +1201,18 @@
|
||||
"node": ">=6.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cssesc": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
|
||||
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"cssesc": "bin/cssesc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
@@ -1901,6 +1916,24 @@
|
||||
"multicast-dns": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.20",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
|
||||
"integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
||||
@@ -2046,6 +2079,12 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/pino": {
|
||||
"version": "10.3.1",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-10.3.1.tgz",
|
||||
@@ -2083,6 +2122,53 @@
|
||||
"integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.29",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz",
|
||||
"integrity": "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.19",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss-selector-parser": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz",
|
||||
"integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cssesc": "^3.0.0",
|
||||
"util-deprecate": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss-value-parser": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/process-warning": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz",
|
||||
@@ -2427,6 +2513,15 @@
|
||||
"atomic-sleep": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
|
||||
"integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
|
||||
@@ -1,39 +1,55 @@
|
||||
{
|
||||
"name": "webspeak-webclient",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"type": "module",
|
||||
"description": "Server-side browser gateway for TeamSpeak — deploy on your server, users join from any browser",
|
||||
"engines": {
|
||||
"node": ">=22.5.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx src/index.ts",
|
||||
"build": "tsc",
|
||||
"test": "tsx --test \"test/**/*.test.ts\"",
|
||||
"start": "node dist/index.js",
|
||||
"web:dev": "cd web && npx vite --host",
|
||||
"web:build": "cd web && npx vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#f38dee6",
|
||||
"express": "^5.2.1",
|
||||
"pino": "^10.3.1",
|
||||
"werift": "0.24.4",
|
||||
"ws": "^8.20.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/node": "^22.15.0",
|
||||
"@types/ws": "^8.18.1",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^6.0.2"
|
||||
},
|
||||
"overrides": {
|
||||
"body-parser": "^2.3.0",
|
||||
"esbuild": "^0.28.2",
|
||||
"tar": "^7.5.22"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "webspeak-webclient",
|
||||
"version": "0.2.7",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"type": "module",
|
||||
"description": "Server-side browser gateway for TeamSpeak — deploy on your server, users join from any browser",
|
||||
"engines": {
|
||||
"node": ">=22.5.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx src/index.ts",
|
||||
"build": "tsc",
|
||||
"test": "node --import tsx --test web/src/services/voice-channel-tree.test.ts src/admin/skin-registry.test.ts web/test/admin-api.integration.test.ts web/test/admin-view.test.mjs web/src/services/admin-api.test.ts src/security/open-target-policy.test.ts src/server/visitor-count.test.ts src/server/voice-protocol.test.ts src/server/teamspeak-resolver.test.ts src/server/ts-client.test.ts src/server/join-ticket.test.ts src/server/identity-lease.test.ts src/server/session-manager.test.ts src/server/directory-sync.test.ts src/server/session-events.test.ts src/server/reconnect-policy.test.ts src/server/voice-commands.test.ts src/server/voice-bridge.test.ts src/server/session-audio.test.ts src/server/voice-bridge.integration.test.ts src/server/webrtc-audio.test.ts src/server/webrtc-config.test.ts src/server/audio-stats.test.ts src/server/channel-capacity.test.ts src/server/directory-view.test.ts src/server/member-avatars.test.ts src/server/screen-share-coordinator.test.ts src/shared/client-commands.test.ts src/shared/skin-layout.test.ts src/shared/skin-plugin.test.ts src/shared/skin-runtime-plugin-context.test.ts src/shared/skin-runtime-plugins.test.ts src/shared/skin-runtime-plugin-approval.test.ts src/shared/server-messages.test.ts src/shared/webrtc.test.ts scripts/docker-healthcheck.test.mjs web/test/voice-session.test.mjs web/test/audio-controls.test.mjs web/test/connection-dialogs.test.mjs web/test/voice-performance.test.mjs web/test/screen-share.test.ts web/test/screen-share-ui.test.mjs web/test/android-gateway.test.ts web/src/services/skin-catalog.test.ts web/src/services/skin-plugin-runtime.test.ts web/src/services/skin-plugin-authoring.test.ts web/src/services/skin-editor-mode.test.ts web/src/services/skin-plugin-approval.test.ts web/src/services/host-editor-top-layer.test.ts web/src/services/skin-extension-ui.test.ts web/src/services/member-menu-placement.test.ts web/src/services/audio-device-menu-placement.test.ts web/src/services/mobile-viewport.test.ts web/src/services/mobile-away.test.ts web/src/services/screen-wake-lock.test.ts web/src/services/microphone-start.test.ts web/src/services/skin-pack.test.ts web/src/services/skin-runtime-plugin-approval.test.ts web/src/services/skin-layout-storage.test.ts web/src/services/skin-layout-geometry.test.ts web/src/services/skin-layout-focus.test.ts web/test/skin-layout-runtime.test.mjs web/test/skin-plugin-editor.test.mjs web/src/services/identity-import.test.ts web/src/services/identity-provider.test.ts web/test/identity-dialog.test.mjs web/test/skin-lifecycle.test.mjs web/src/services/local-persistence.test.ts web/src/services/quick-servers.test.ts src/server/teamspeak-alias.test.ts src/server/teamspeak-alias-integration.test.ts web/src/services/teamspeak-target.test.ts web/src/services/skin-extension-sandbox.test.ts web/src/services/skin-extension-wasm-policy.test.ts web/src/services/skin-extension-wasm-sandbox.test.ts web/src/services/skin-runtime-plugin-wasm.test.ts web/src/services/skin-extension-wasm-ui-loop.test.ts web/src/services/skin-wasm-interpreter.test.ts",
|
||||
"verify": "npm test && npm run build && npm run web:build",
|
||||
"skin:harbor:build": "node web/scripts/build-harbor-voice-skin.mjs",
|
||||
"skin:open-voice:build": "node web/scripts/build-open-voice-surface-skin.mjs",
|
||||
"skin:kaak:build": "node web/scripts/build-kaak-voice-skin.mjs",
|
||||
"skin:illusia:build": "node web/scripts/build-illusia-voice-skin.mjs",
|
||||
"start": "node dist/index.js",
|
||||
"web:dev": "cd web && npx vite --host",
|
||||
"web:build": "npm --prefix web run build",
|
||||
"skin:wasm:build": "node scripts/build-skin-wasm-interpreter.mjs",
|
||||
"android:prepare": "npm run build && npm --prefix web run build && node mobile/pack.mjs",
|
||||
"android:sync": "npm run android:prepare && cd web && npx cap sync android",
|
||||
"prepare:sdk": "node scripts/prepare-sdk.mjs",
|
||||
"acceleration:poc": "node scripts/acceleration-poc/smoke.mjs",
|
||||
"acceleration:ipv6-smoke": "node scripts/acceleration-poc/smoke-ipv6.mjs",
|
||||
"acceleration:sdk-smoke": "node scripts/acceleration-poc/sdk-smoke.mjs",
|
||||
"acceleration:relay": "node dist/relay.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#758a0d7d9120b0f5777d9451fb6b134f0b606f65",
|
||||
"express": "^5.2.1",
|
||||
"pino": "^10.3.1",
|
||||
"postcss": "^8.5.29",
|
||||
"postcss-selector-parser": "^7.1.6",
|
||||
"postcss-value-parser": "^4.2.0",
|
||||
"werift": "0.24.4",
|
||||
"ws": "^8.20.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/node": "^22.15.0",
|
||||
"@types/ws": "^8.18.1",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^6.0.2"
|
||||
},
|
||||
"overrides": {
|
||||
"body-parser": "^2.3.0",
|
||||
"esbuild": "^0.28.2",
|
||||
"tar": "^7.5.22"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# WebSpeak 加速通道 PoC
|
||||
|
||||
这是第一版隔离测试 Demo,不属于 WebSpeak 生产运行链路,也不会被复制到 Docker 镜像或发布包中。
|
||||
|
||||
它验证以下核心能力:
|
||||
|
||||
- 客户端向远端中继发起认证;
|
||||
- 每个会话动态指定 TeamSpeak 目标地址;
|
||||
- 双向 UDP 数据报转发,并保持数据包边界;
|
||||
- 会话之间按随机 ID 隔离;
|
||||
- 错误密钥不能建立会话;
|
||||
- 不修改系统路由,因此不是 VPN。
|
||||
|
||||
## 本地冒烟
|
||||
|
||||
在仓库根目录运行:
|
||||
|
||||
```bash
|
||||
npm run acceleration:poc
|
||||
```
|
||||
|
||||
成功时会输出 `ACCELERATION_POC_OK`,并显示数据包数量、丢包率和往返延迟。
|
||||
|
||||
IPv6 回环验证:
|
||||
|
||||
```bash
|
||||
npm run acceleration:ipv6-smoke
|
||||
```
|
||||
|
||||
## 通过隧道连接指定 TeamSpeak
|
||||
|
||||
必须先将下方示例域名替换为你获准测试的 TeamSpeak 地址;脚本不内置真实服务器默认值。下面的命令会让 SDK 连接本地代理端口,再由 PoC 中继把 UDP 数据转发到指定 TeamSpeak。它不进入指定频道,只验证 TeamSpeak 握手和断开:
|
||||
|
||||
```bash
|
||||
$env:WEBSPEAK_ACCEL_TS_TARGET="ts.example.invalid#9987"
|
||||
npm run acceleration:sdk-smoke
|
||||
```
|
||||
|
||||
跨机器验证时,需要在目标服务器启动 `relay-server.mjs`,再把 `WEBSPEAK_ACCEL_RELAY` 指向中继地址。当前项目不会自动部署或启动该远程进程。
|
||||
|
||||
## 手动启动中继
|
||||
|
||||
仅用于实验,不要直接暴露到公网:
|
||||
|
||||
```bash
|
||||
WEBSPEAK_ACCEL_TOKEN="change-this-to-a-long-random-token" \
|
||||
WEBSPEAK_ACCEL_HOST="0.0.0.0" \
|
||||
WEBSPEAK_ACCEL_PORT="39087" \
|
||||
node scripts/acceleration-poc/relay-server.mjs
|
||||
```
|
||||
|
||||
当前 Demo 的 UDP 帧协议是实验协议,尚未接入 SDK,也没有替代 GOST 的生产安全审计。正式接入前仍需验证 TeamSpeak 长时间语音、并发会话、IPv6、断线重连和目标地址安全策略。
|
||||
@@ -0,0 +1,116 @@
|
||||
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
||||
|
||||
export const VERSION = 1;
|
||||
export const HEADER_SIZE = 34;
|
||||
export const MAX_PAYLOAD_SIZE = 60_000;
|
||||
|
||||
export const FrameType = Object.freeze({
|
||||
OPEN: 1,
|
||||
OPEN_OK: 2,
|
||||
OPEN_ERR: 3,
|
||||
DATA: 4,
|
||||
CLOSE: 5,
|
||||
PING: 6,
|
||||
PONG: 7,
|
||||
});
|
||||
|
||||
function asSecret(secret) {
|
||||
if (typeof secret !== "string" || secret.length < 16) {
|
||||
throw new Error("The PoC token must contain at least 16 characters");
|
||||
}
|
||||
return Buffer.from(secret, "utf8");
|
||||
}
|
||||
|
||||
function signFrame(frame, secret, payload) {
|
||||
return createHmac("sha256", asSecret(secret))
|
||||
.update(frame.subarray(0, 18))
|
||||
.update(payload)
|
||||
.digest()
|
||||
.subarray(0, 16);
|
||||
}
|
||||
|
||||
export function encodeFrame(type, sessionId, sequence, payload = Buffer.alloc(0), secret) {
|
||||
const body = Buffer.from(payload);
|
||||
if (!Number.isInteger(type) || type < 1 || type > 255) throw new Error("Invalid frame type");
|
||||
if (!Number.isInteger(sessionId) || sessionId < 0 || sessionId > 0xffffffff) throw new Error("Invalid session id");
|
||||
if (!Number.isInteger(sequence) || sequence < 0 || sequence > 0xffffffff) throw new Error("Invalid sequence");
|
||||
if (body.length > MAX_PAYLOAD_SIZE) throw new Error(`Payload exceeds ${MAX_PAYLOAD_SIZE} bytes`);
|
||||
|
||||
const frame = Buffer.alloc(HEADER_SIZE + body.length);
|
||||
MAGIC.copy(frame, 0);
|
||||
frame[4] = VERSION;
|
||||
frame[5] = type;
|
||||
frame.writeUInt16BE(0, 6);
|
||||
frame.writeUInt32BE(sessionId >>> 0, 8);
|
||||
frame.writeUInt32BE(sequence >>> 0, 12);
|
||||
frame.writeUInt16BE(body.length, 16);
|
||||
body.copy(frame, HEADER_SIZE);
|
||||
signFrame(frame, secret, body).copy(frame, 18);
|
||||
return frame;
|
||||
}
|
||||
|
||||
export function decodeFrame(packet) {
|
||||
const frame = Buffer.from(packet);
|
||||
if (frame.length < HEADER_SIZE || !frame.subarray(0, 4).equals(MAGIC)) return null;
|
||||
if (frame[4] !== VERSION) return null;
|
||||
const payloadLength = frame.readUInt16BE(16);
|
||||
if (frame.length !== HEADER_SIZE + payloadLength || payloadLength > MAX_PAYLOAD_SIZE) return null;
|
||||
return {
|
||||
type: frame[5],
|
||||
sessionId: frame.readUInt32BE(8),
|
||||
sequence: frame.readUInt32BE(12),
|
||||
payload: frame.subarray(HEADER_SIZE),
|
||||
auth: frame.subarray(18, HEADER_SIZE),
|
||||
raw: frame,
|
||||
};
|
||||
}
|
||||
|
||||
export function verifyFrame(frame, secret) {
|
||||
const expected = signFrame(frame.raw, secret, frame.payload);
|
||||
return timingSafeEqual(expected, frame.auth);
|
||||
}
|
||||
|
||||
export function randomSessionId() {
|
||||
let id = randomBytes(4).readUInt32BE(0);
|
||||
if (id === 0) id = 1;
|
||||
return id;
|
||||
}
|
||||
|
||||
export function jsonPayload(value) {
|
||||
return Buffer.from(JSON.stringify(value), "utf8");
|
||||
}
|
||||
|
||||
export function parseJsonPayload(payload) {
|
||||
try {
|
||||
return JSON.parse(Buffer.from(payload).toString("utf8"));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function parseEndpoint(value, defaultPort) {
|
||||
if (typeof value !== "string" || !value.trim()) throw new Error("Endpoint is required");
|
||||
const text = value.trim();
|
||||
if (text.startsWith("[")) {
|
||||
const end = text.indexOf("]");
|
||||
if (end < 0) throw new Error(`Invalid endpoint: ${value}`);
|
||||
const host = text.slice(1, end);
|
||||
const portText = text.slice(end + 1).replace(/^[:#]/, "");
|
||||
return { host, port: parsePort(portText || defaultPort, value) };
|
||||
}
|
||||
const hash = text.lastIndexOf("#");
|
||||
if (hash > 0) return { host: text.slice(0, hash), port: parsePort(text.slice(hash + 1), value) };
|
||||
const colon = text.lastIndexOf(":");
|
||||
if (colon > 0 && text.indexOf(":") === colon) {
|
||||
return { host: text.slice(0, colon), port: parsePort(text.slice(colon + 1), value) };
|
||||
}
|
||||
return { host: text, port: parsePort(defaultPort, value) };
|
||||
}
|
||||
|
||||
function parsePort(value, original) {
|
||||
const port = Number(value);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(`Invalid port in endpoint: ${original}`);
|
||||
return port;
|
||||
}
|
||||
|
||||
const MAGIC = Buffer.from("WSAT");
|
||||
@@ -0,0 +1,106 @@
|
||||
import { createSocket } from "node:dgram";
|
||||
import { isIP } from "node:net";
|
||||
import { decodeFrame, encodeFrame, FrameType, jsonPayload, randomSessionId, parseEndpoint, verifyFrame } from "./protocol.mjs";
|
||||
|
||||
export async function createRelayClient({
|
||||
relayHost,
|
||||
relayPort,
|
||||
targetHost,
|
||||
targetPort,
|
||||
token,
|
||||
localHost = "127.0.0.1",
|
||||
localPort = 0,
|
||||
timeoutMs = 5_000,
|
||||
} = {}) {
|
||||
if (!relayHost || !Number.isInteger(relayPort)) throw new Error("Relay endpoint is required");
|
||||
if (!targetHost || !Number.isInteger(targetPort)) throw new Error("Target endpoint is required");
|
||||
const relayFamily = isIP(relayHost) === 6 ? "udp6" : "udp4";
|
||||
const localFamily = isIP(localHost) === 6 ? "udp6" : "udp4";
|
||||
const relaySocket = createSocket(relayFamily);
|
||||
const localSocket = createSocket(localFamily);
|
||||
const sessionId = randomSessionId();
|
||||
let sequence = 1;
|
||||
let peer = null;
|
||||
let ready = false;
|
||||
let closed = false;
|
||||
let resolveReady;
|
||||
let rejectReady;
|
||||
const readyPromise = new Promise((resolve, reject) => { resolveReady = resolve; rejectReady = reject; });
|
||||
|
||||
function sendFrame(type, payload = Buffer.alloc(0)) {
|
||||
const packet = encodeFrame(type, sessionId, sequence++, payload, token);
|
||||
relaySocket.send(packet, relayPort, relayHost);
|
||||
}
|
||||
|
||||
function closeSockets() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
try { relaySocket.close(); } catch {}
|
||||
try { localSocket.close(); } catch {}
|
||||
}
|
||||
|
||||
relaySocket.on("message", (packet) => {
|
||||
const frame = decodeFrame(packet);
|
||||
if (!frame || frame.sessionId !== sessionId || !verifyFrame(frame, token)) return;
|
||||
if (frame.type === FrameType.OPEN_OK) {
|
||||
ready = true;
|
||||
resolveReady();
|
||||
} else if (frame.type === FrameType.OPEN_ERR) {
|
||||
const detail = (() => { try { return JSON.parse(frame.payload.toString("utf8")); } catch { return {}; } })();
|
||||
rejectReady(new Error(detail.code ?? "ACCELERATION_OPEN_FAILED"));
|
||||
closeSockets();
|
||||
} else if (frame.type === FrameType.DATA && peer) {
|
||||
localSocket.send(frame.payload, peer.port, peer.address);
|
||||
} else if (frame.type === FrameType.CLOSE) {
|
||||
closeSockets();
|
||||
}
|
||||
});
|
||||
|
||||
const onSocketError = (error) => {
|
||||
if (!ready) rejectReady(error);
|
||||
closeSockets();
|
||||
};
|
||||
relaySocket.once("error", onSocketError);
|
||||
localSocket.once("error", onSocketError);
|
||||
|
||||
await Promise.all([
|
||||
new Promise((resolve) => relaySocket.bind(0, relayFamily === "udp6" ? "::" : "0.0.0.0", resolve)),
|
||||
new Promise((resolve) => localSocket.bind(localPort, localHost, resolve)),
|
||||
]);
|
||||
|
||||
localSocket.on("message", (payload, rinfo) => {
|
||||
if (closed) return;
|
||||
peer = { address: rinfo.address, port: rinfo.port };
|
||||
if (ready) sendFrame(FrameType.DATA, payload);
|
||||
});
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
rejectReady(new Error("ACCELERATION_OPEN_TIMEOUT"));
|
||||
closeSockets();
|
||||
}, timeoutMs);
|
||||
sendFrame(FrameType.OPEN, jsonPayload({ targetHost, targetPort }));
|
||||
try {
|
||||
await readyPromise;
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
|
||||
const localAddress = localSocket.address();
|
||||
return {
|
||||
sessionId,
|
||||
localHost,
|
||||
localPort: typeof localAddress === "object" ? localAddress.port : localPort,
|
||||
waitReady: () => readyPromise,
|
||||
close() {
|
||||
if (closed) return;
|
||||
if (ready) {
|
||||
try { sendFrame(FrameType.CLOSE); } catch {}
|
||||
}
|
||||
closeSockets();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function parseRelayEndpoint(value) {
|
||||
return parseEndpoint(value, 39087);
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import { createSocket } from "node:dgram";
|
||||
import { lookup } from "node:dns/promises";
|
||||
import { isIP } from "node:net";
|
||||
import { decodeFrame, encodeFrame, FrameType, jsonPayload, parseJsonPayload, verifyFrame } from "./protocol.mjs";
|
||||
|
||||
function endpointKey(address, port) {
|
||||
return `${address}/${port}`;
|
||||
}
|
||||
|
||||
function isPrivateAddress(host) {
|
||||
const family = isIP(host);
|
||||
if (family === 4) {
|
||||
const octets = host.split(".").map(Number);
|
||||
return octets[0] === 10
|
||||
|| (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31)
|
||||
|| octets[0] === 192 && octets[1] === 168
|
||||
|| octets[0] === 127
|
||||
|| octets[0] === 169 && octets[1] === 254
|
||||
|| octets[0] === 0;
|
||||
}
|
||||
if (family === 6) {
|
||||
const normalized = host.toLowerCase();
|
||||
return normalized === "::1"
|
||||
|| normalized === "::"
|
||||
|| normalized.startsWith("fc")
|
||||
|| normalized.startsWith("fd")
|
||||
|| normalized.startsWith("fe8")
|
||||
|| normalized.startsWith("fe9")
|
||||
|| normalized.startsWith("fea")
|
||||
|| normalized.startsWith("feb");
|
||||
}
|
||||
return host === "localhost" || host.endsWith(".localhost");
|
||||
}
|
||||
|
||||
async function resolveTarget(host) {
|
||||
const family = isIP(host);
|
||||
if (family) return { host, family };
|
||||
const records = await lookup(host, { all: true, verbatim: true });
|
||||
const record = records.find((item) => item.family === 4) ?? records[0];
|
||||
if (!record) throw new Error("TARGET_DNS_EMPTY");
|
||||
return { host: record.address, family: record.family };
|
||||
}
|
||||
|
||||
export async function createRelayServer({
|
||||
host = "127.0.0.1",
|
||||
port = 0,
|
||||
token,
|
||||
allowPrivate = false,
|
||||
idleTimeoutMs = 30_000,
|
||||
} = {}) {
|
||||
const serverFamily = isIP(host) === 6 ? "udp6" : "udp4";
|
||||
const socket = createSocket(serverFamily);
|
||||
const sessions = new Map();
|
||||
let closed = false;
|
||||
|
||||
function sendToClient(session, type, payload = Buffer.alloc(0)) {
|
||||
if (closed) return;
|
||||
const packet = encodeFrame(type, session.id, session.outSequence++, payload, token);
|
||||
socket.send(packet, session.client.port, session.client.address);
|
||||
}
|
||||
|
||||
function cleanup(session) {
|
||||
if (!session || session.closed) return;
|
||||
session.closed = true;
|
||||
sessions.delete(session.id);
|
||||
session.targetSocket?.close();
|
||||
}
|
||||
|
||||
async function openSession(frame, client) {
|
||||
const request = parseJsonPayload(frame.payload);
|
||||
if (!request || typeof request.targetHost !== "string" || !Number.isInteger(request.targetPort)) {
|
||||
return;
|
||||
}
|
||||
if (!allowPrivate && (isPrivateAddress(request.targetHost) || request.targetHost === "localhost")) {
|
||||
const error = { code: "PRIVATE_TARGET_BLOCKED" };
|
||||
socket.send(encodeFrame(FrameType.OPEN_ERR, frame.sessionId, 0, jsonPayload(error), token), client.port, client.address);
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = sessions.get(frame.sessionId);
|
||||
if (existing) cleanup(existing);
|
||||
const session = {
|
||||
id: frame.sessionId,
|
||||
client,
|
||||
clientKey: endpointKey(client.address, client.port),
|
||||
outSequence: 1,
|
||||
lastActivity: Date.now(),
|
||||
targetSocket: null,
|
||||
closed: false,
|
||||
};
|
||||
sessions.set(session.id, session);
|
||||
|
||||
try {
|
||||
const target = await resolveTarget(request.targetHost);
|
||||
const targetSocket = createSocket(target.family === 6 ? "udp6" : "udp4");
|
||||
session.targetSocket = targetSocket;
|
||||
targetSocket.on("message", (payload) => {
|
||||
session.lastActivity = Date.now();
|
||||
sendToClient(session, FrameType.DATA, payload);
|
||||
});
|
||||
targetSocket.on("error", (error) => {
|
||||
if (!session.closed) sendToClient(session, FrameType.OPEN_ERR, jsonPayload({ code: "TARGET_SOCKET_ERROR", message: error.message }));
|
||||
cleanup(session);
|
||||
});
|
||||
targetSocket.connect(request.targetPort, target.host, () => {
|
||||
session.lastActivity = Date.now();
|
||||
sendToClient(session, FrameType.OPEN_OK, jsonPayload({ targetHost: target.host, targetPort: request.targetPort }));
|
||||
});
|
||||
} catch (error) {
|
||||
cleanup(session);
|
||||
socket.send(encodeFrame(FrameType.OPEN_ERR, frame.sessionId, 0, jsonPayload({ code: "TARGET_OPEN_FAILED", message: error.message }), token), client.port, client.address);
|
||||
}
|
||||
}
|
||||
|
||||
socket.on("message", (packet, rinfo) => {
|
||||
const frame = decodeFrame(packet);
|
||||
if (!frame || !verifyFrame(frame, token)) return;
|
||||
const client = { address: rinfo.address, port: rinfo.port };
|
||||
if (frame.type === FrameType.OPEN) {
|
||||
void openSession(frame, client);
|
||||
return;
|
||||
}
|
||||
|
||||
const session = sessions.get(frame.sessionId);
|
||||
if (!session || session.clientKey !== endpointKey(rinfo.address, rinfo.port)) return;
|
||||
session.lastActivity = Date.now();
|
||||
if (frame.type === FrameType.DATA && session.targetSocket) {
|
||||
session.targetSocket.send(frame.payload);
|
||||
} else if (frame.type === FrameType.CLOSE) {
|
||||
sendToClient(session, FrameType.CLOSE);
|
||||
cleanup(session);
|
||||
} else if (frame.type === FrameType.PING) {
|
||||
sendToClient(session, FrameType.PONG);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("error", (error) => {
|
||||
for (const session of sessions.values()) cleanup(session);
|
||||
if (!closed) throw error;
|
||||
});
|
||||
|
||||
const sweep = setInterval(() => {
|
||||
const now = Date.now();
|
||||
for (const session of sessions.values()) {
|
||||
if (now - session.lastActivity > idleTimeoutMs) cleanup(session);
|
||||
}
|
||||
}, Math.max(1000, Math.min(idleTimeoutMs, 5000)));
|
||||
sweep.unref();
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const onError = (error) => { socket.off("listening", onListening); reject(error); };
|
||||
const onListening = () => { socket.off("error", onError); resolve(); };
|
||||
socket.once("error", onError);
|
||||
socket.once("listening", onListening);
|
||||
socket.bind({ address: host, port });
|
||||
});
|
||||
|
||||
const address = socket.address();
|
||||
return {
|
||||
host,
|
||||
port: typeof address === "object" ? address.port : port,
|
||||
family: serverFamily,
|
||||
close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
clearInterval(sweep);
|
||||
for (const session of sessions.values()) cleanup(session);
|
||||
socket.close();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]?.replaceAll("\\", "/")}`) {
|
||||
const token = process.env.WEBSPEAK_ACCEL_TOKEN;
|
||||
if (!token) throw new Error("Set WEBSPEAK_ACCEL_TOKEN before starting the PoC relay");
|
||||
const host = process.env.WEBSPEAK_ACCEL_HOST ?? "0.0.0.0";
|
||||
const port = Number(process.env.WEBSPEAK_ACCEL_PORT ?? 39087);
|
||||
const server = await createRelayServer({ host, port, token });
|
||||
console.log(`ACCELERATION_RELAY_LISTEN ${server.host}:${server.port}`);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Client, generateIdentity } from "../../../teamspeak-js/dist/index.mjs";
|
||||
import { createRelayClient } from "./relay-client.mjs";
|
||||
import { createRelayServer } from "./relay-server.mjs";
|
||||
import { parseEndpoint } from "./protocol.mjs";
|
||||
|
||||
const token = process.env.WEBSPEAK_ACCEL_TOKEN ?? "local-acceleration-poc-token";
|
||||
const targetAddress = process.env.WEBSPEAK_ACCEL_TS_TARGET;
|
||||
if (!targetAddress?.trim()) {
|
||||
throw new Error("Set WEBSPEAK_ACCEL_TS_TARGET to your authorized TeamSpeak test endpoint");
|
||||
}
|
||||
const target = parseEndpoint(targetAddress, 9987);
|
||||
const relayEndpoint = process.env.WEBSPEAK_ACCEL_RELAY;
|
||||
let relayServer = null;
|
||||
let relayClient = null;
|
||||
let tsClient = null;
|
||||
|
||||
function withTimeout(promise, timeoutMs, label) {
|
||||
return Promise.race([
|
||||
promise,
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error(`${label}_TIMEOUT`)), timeoutMs)),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
let relay;
|
||||
if (relayEndpoint) {
|
||||
relay = parseEndpoint(relayEndpoint, 39087);
|
||||
} else {
|
||||
relayServer = await createRelayServer({ host: "127.0.0.1", port: 0, token, allowPrivate: true });
|
||||
relay = { host: "127.0.0.1", port: relayServer.port };
|
||||
}
|
||||
|
||||
relayClient = await createRelayClient({
|
||||
relayHost: relay.host,
|
||||
relayPort: relay.port,
|
||||
targetHost: target.host,
|
||||
targetPort: target.port,
|
||||
token,
|
||||
});
|
||||
|
||||
tsClient = new Client(generateIdentity(8), `127.0.0.1:${relayClient.localPort}`, "acceleration-sdk-smoke");
|
||||
await withTimeout(tsClient.connect(), 15_000, "TS_CONNECT");
|
||||
console.log(`TS_ACCEL_CONNECTED target=${target.host}#${target.port}`);
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
await tsClient.disconnect();
|
||||
console.log("TS_ACCEL_DISCONNECTED");
|
||||
} catch (error) {
|
||||
console.error("TS_ACCEL_SMOKE_FAILED", error);
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
try { await tsClient?.disconnect(); } catch {}
|
||||
relayClient?.close();
|
||||
relayServer?.close();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createSocket } from "node:dgram";
|
||||
import { createRelayServer } from "./relay-server.mjs";
|
||||
import { createRelayClient } from "./relay-client.mjs";
|
||||
|
||||
const TOKEN = "local-ipv6-acceleration-poc-token";
|
||||
const PACKET_COUNT = 50;
|
||||
|
||||
function bind(socket, port = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
socket.once("error", reject);
|
||||
socket.bind(port, "::1", () => {
|
||||
socket.off("error", reject);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const target = createSocket("udp6");
|
||||
target.on("message", (payload, rinfo) => target.send(payload, rinfo.port, rinfo.address));
|
||||
await bind(target);
|
||||
const targetPort = target.address().port;
|
||||
|
||||
const relay = await createRelayServer({ host: "::1", port: 0, token: TOKEN, allowPrivate: true });
|
||||
const client = await createRelayClient({
|
||||
relayHost: "::1",
|
||||
relayPort: relay.port,
|
||||
targetHost: "::1",
|
||||
targetPort,
|
||||
token: TOKEN,
|
||||
localHost: "::1",
|
||||
});
|
||||
|
||||
const sender = createSocket("udp6");
|
||||
await bind(sender);
|
||||
const pending = new Set(Array.from({ length: PACKET_COUNT }, (_, index) => index));
|
||||
sender.on("message", (payload) => pending.delete(payload.readUInt32BE(0)));
|
||||
for (let index = 0; index < PACKET_COUNT; index++) {
|
||||
const payload = Buffer.alloc(512, index & 0xff);
|
||||
payload.writeUInt32BE(index, 0);
|
||||
sender.send(payload, client.localPort, "::1");
|
||||
}
|
||||
|
||||
const deadline = Date.now() + 3000;
|
||||
while (pending.size && Date.now() < deadline) await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
const received = PACKET_COUNT - pending.size;
|
||||
|
||||
sender.close();
|
||||
client.close();
|
||||
relay.close();
|
||||
target.close();
|
||||
console.log(`ipv6_packets=${PACKET_COUNT} received=${received} loss=${((pending.size / PACKET_COUNT) * 100).toFixed(2)}%`);
|
||||
if (received !== PACKET_COUNT) throw new Error("IPV6_ACCELERATION_POC_FAILED");
|
||||
console.log("IPV6_ACCELERATION_POC_OK");
|
||||
}
|
||||
|
||||
run().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
import { createSocket } from "node:dgram";
|
||||
import { createRelayServer } from "./relay-server.mjs";
|
||||
import { createRelayClient } from "./relay-client.mjs";
|
||||
|
||||
const TOKEN = "local-acceleration-poc-token";
|
||||
const PACKET_COUNT = 200;
|
||||
const PACKET_SIZE = 1920;
|
||||
|
||||
function bind(socket, port = 0) {
|
||||
return new Promise((resolve) => socket.bind(port, "127.0.0.1", resolve));
|
||||
}
|
||||
|
||||
function close(socket) {
|
||||
try { socket.close(); } catch {}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const target = createSocket("udp4");
|
||||
target.on("message", (payload, rinfo) => {
|
||||
target.send(payload, rinfo.port, rinfo.address);
|
||||
});
|
||||
await bind(target);
|
||||
const targetAddress = target.address();
|
||||
|
||||
const relay = await createRelayServer({
|
||||
host: "127.0.0.1",
|
||||
port: 0,
|
||||
token: TOKEN,
|
||||
allowPrivate: true,
|
||||
});
|
||||
const client = await createRelayClient({
|
||||
relayHost: "127.0.0.1",
|
||||
relayPort: relay.port,
|
||||
targetHost: "127.0.0.1",
|
||||
targetPort: targetAddress.port,
|
||||
token: TOKEN,
|
||||
});
|
||||
|
||||
let rejectedBadToken = false;
|
||||
try {
|
||||
const badClient = await createRelayClient({
|
||||
relayHost: "127.0.0.1",
|
||||
relayPort: relay.port,
|
||||
targetHost: "127.0.0.1",
|
||||
targetPort: targetAddress.port,
|
||||
token: "wrong-token-that-is-long-enough",
|
||||
timeoutMs: 250,
|
||||
});
|
||||
badClient.close();
|
||||
} catch {
|
||||
rejectedBadToken = true;
|
||||
}
|
||||
|
||||
const sender = createSocket("udp4");
|
||||
await bind(sender);
|
||||
const pending = new Map();
|
||||
const samples = [];
|
||||
sender.on("message", (payload) => {
|
||||
const id = payload.readUInt32BE(0);
|
||||
const sentAt = pending.get(id);
|
||||
if (sentAt !== undefined) {
|
||||
pending.delete(id);
|
||||
samples.push(Number(process.hrtime.bigint() - sentAt) / 1_000_000);
|
||||
}
|
||||
});
|
||||
|
||||
for (let id = 0; id < PACKET_COUNT; id++) {
|
||||
const payload = Buffer.alloc(PACKET_SIZE, id & 0xff);
|
||||
payload.writeUInt32BE(id, 0);
|
||||
pending.set(id, process.hrtime.bigint());
|
||||
sender.send(payload, client.localPort, "127.0.0.1");
|
||||
await new Promise((resolve) => setTimeout(resolve, 1));
|
||||
}
|
||||
|
||||
const deadline = Date.now() + 5_000;
|
||||
while (pending.size && Date.now() < deadline) await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
const received = samples.length;
|
||||
const loss = ((PACKET_COUNT - received) / PACKET_COUNT) * 100;
|
||||
const sorted = [...samples].sort((a, b) => a - b);
|
||||
const percentile = (ratio) => sorted.length ? sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * ratio))] : 0;
|
||||
const average = sorted.length ? sorted.reduce((sum, value) => sum + value, 0) / sorted.length : 0;
|
||||
|
||||
sender.close();
|
||||
client.close();
|
||||
relay.close();
|
||||
target.close();
|
||||
|
||||
console.log(`relay=127.0.0.1:${relay.port}`);
|
||||
console.log(`packets=${PACKET_COUNT} received=${received} loss=${loss.toFixed(2)}%`);
|
||||
console.log(`rtt_ms_avg=${average.toFixed(3)} p95=${Number(percentile(0.95)).toFixed(3)} max=${Number(percentile(0.99)).toFixed(3)}`);
|
||||
console.log(`bad_token_rejected=${rejectedBadToken}`);
|
||||
if (received !== PACKET_COUNT || !rejectedBadToken) throw new Error("ACCELERATION_POC_FAILED");
|
||||
console.log("ACCELERATION_POC_OK");
|
||||
}
|
||||
|
||||
run().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { copyFile, mkdir, readFile, stat } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const interpreterRoot = path.join(repositoryRoot, "web", "skin-wasm-interpreter");
|
||||
const sourceArtifact = path.join(interpreterRoot, "target", "wasm32-unknown-unknown", "release", "webspeak_skin_wasm_interpreter.wasm");
|
||||
const publicDirectory = path.join(repositoryRoot, "web", "public");
|
||||
const publicArtifact = path.join(publicDirectory, "skin-wasm-interpreter.wasm");
|
||||
const rustFlags = "-C link-arg=--max-memory=67108864 -C panic=abort";
|
||||
|
||||
const result = spawnSync("cargo", ["build", "--locked", "--release", "--target", "wasm32-unknown-unknown"], {
|
||||
cwd: interpreterRoot,
|
||||
env: { ...process.env, RUSTFLAGS: rustFlags },
|
||||
stdio: "inherit",
|
||||
});
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) process.exit(result.status ?? 1);
|
||||
|
||||
const artifactInfo = await stat(sourceArtifact);
|
||||
if (artifactInfo.size < 8 || artifactInfo.size > 8 * 1024 * 1024) {
|
||||
throw new Error(`The Wasmi interpreter artifact has an unexpected size: ${artifactInfo.size} bytes.`);
|
||||
}
|
||||
const header = await readFile(sourceArtifact, { encoding: null, flag: "r" });
|
||||
if (header[0] !== 0 || header[1] !== 0x61 || header[2] !== 0x73 || header[3] !== 0x6d) {
|
||||
throw new Error("The Wasmi interpreter build did not produce a WebAssembly module.");
|
||||
}
|
||||
|
||||
await mkdir(publicDirectory, { recursive: true });
|
||||
await copyFile(sourceArtifact, publicArtifact);
|
||||
console.log(`Built bounded Wasmi interpreter (${artifactInfo.size} bytes) at web/public/skin-wasm-interpreter.wasm.`);
|
||||
@@ -0,0 +1,38 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import http from "node:http";
|
||||
import https from "node:https";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
|
||||
const appRoot = path.resolve(scriptDirectory, "..");
|
||||
const defaultCertDirectory = path.join(appRoot, "certs");
|
||||
|
||||
export function healthcheckUsesHttps(certDirectory = defaultCertDirectory) {
|
||||
return existsSync(path.join(certDirectory, "cert.pem"));
|
||||
}
|
||||
|
||||
export function runDockerHealthcheck({ mode = process.env.WEBSPEAK_MODE, certDirectory = defaultCertDirectory } = {}) {
|
||||
if (mode?.trim().toLowerCase() === "relay") {
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const secure = healthcheckUsesHttps(certDirectory);
|
||||
const client = secure ? https : http;
|
||||
const request = client.get({
|
||||
hostname: "127.0.0.1",
|
||||
port: 3040,
|
||||
path: "/health",
|
||||
...(secure ? { rejectUnauthorized: false } : {}),
|
||||
}, (response) => {
|
||||
response.resume();
|
||||
process.exitCode = response.statusCode >= 200 && response.statusCode < 300 ? 0 : 1;
|
||||
});
|
||||
request.setTimeout(4_000, () => request.destroy(new Error("Healthcheck timed out")));
|
||||
request.on("error", () => { process.exitCode = 1; });
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
runDockerHealthcheck();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { healthcheckUsesHttps } from "./docker-healthcheck.mjs";
|
||||
|
||||
test("Docker healthcheck selects HTTP or HTTPS from the same certificate marker as the server", (context) => {
|
||||
const directory = mkdtempSync(path.join(tmpdir(), "webspeak-healthcheck-"));
|
||||
context.after(() => rmSync(directory, { recursive: true, force: true }));
|
||||
|
||||
assert.equal(healthcheckUsesHttps(directory), false);
|
||||
mkdirSync(directory, { recursive: true });
|
||||
writeFileSync(path.join(directory, "cert.pem"), "test certificate marker");
|
||||
assert.equal(healthcheckUsesHttps(directory), true);
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$width = 3200
|
||||
$height = 116
|
||||
$outputPath = Join-Path $PSScriptRoot "..\docs\examples\illusia-voice\assets\footer-wave.png"
|
||||
$bitmap = [System.Drawing.Bitmap]::new($width, $height, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||
$graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
$graphics.CompositingQuality = [System.Drawing.Drawing2D.CompositingQuality]::HighQuality
|
||||
$graphics.Clear([System.Drawing.Color]::Transparent)
|
||||
|
||||
$topEdge = [System.Drawing.Drawing2D.GraphicsPath]::new()
|
||||
$topEdge.StartFigure()
|
||||
$topEdge.AddBezier(
|
||||
[System.Drawing.PointF]::new(0, 20),
|
||||
[System.Drawing.PointF]::new(240, 4),
|
||||
[System.Drawing.PointF]::new(460, 0),
|
||||
[System.Drawing.PointF]::new(700, 10)
|
||||
)
|
||||
$topEdge.AddBezier(
|
||||
[System.Drawing.PointF]::new(700, 10),
|
||||
[System.Drawing.PointF]::new(1000, 26),
|
||||
[System.Drawing.PointF]::new(1200, 36),
|
||||
[System.Drawing.PointF]::new(1600, 36)
|
||||
)
|
||||
$topEdge.AddBezier(
|
||||
[System.Drawing.PointF]::new(1600, 36),
|
||||
[System.Drawing.PointF]::new(2000, 36),
|
||||
[System.Drawing.PointF]::new(2200, 26),
|
||||
[System.Drawing.PointF]::new(2500, 10)
|
||||
)
|
||||
$topEdge.AddBezier(
|
||||
[System.Drawing.PointF]::new(2500, 10),
|
||||
[System.Drawing.PointF]::new(2740, 0),
|
||||
[System.Drawing.PointF]::new(2960, 4),
|
||||
[System.Drawing.PointF]::new(3200, 20)
|
||||
)
|
||||
|
||||
$surface = [System.Drawing.Drawing2D.GraphicsPath]::new()
|
||||
$surface.AddPath($topEdge, $false)
|
||||
$surface.AddLine(3200, 20, 3200, $height)
|
||||
$surface.AddLine(3200, $height, 0, $height)
|
||||
$surface.CloseFigure()
|
||||
|
||||
$brush = [System.Drawing.Drawing2D.LinearGradientBrush]::new(
|
||||
[System.Drawing.Rectangle]::new(0, 0, $width, $height),
|
||||
[System.Drawing.Color]::FromArgb(138, 244, 252, 254),
|
||||
[System.Drawing.Color]::FromArgb(245, 252, 255, 255),
|
||||
[System.Drawing.Drawing2D.LinearGradientMode]::Vertical
|
||||
)
|
||||
$blend = [System.Drawing.Drawing2D.ColorBlend]::new(3)
|
||||
$blend.Colors = [System.Drawing.Color[]]@(
|
||||
[System.Drawing.Color]::FromArgb(138, 244, 252, 254),
|
||||
[System.Drawing.Color]::FromArgb(194, 248, 253, 254),
|
||||
[System.Drawing.Color]::FromArgb(245, 252, 255, 255)
|
||||
)
|
||||
$blend.Positions = [single[]]@(0.0, 0.58, 1.0)
|
||||
$brush.InterpolationColors = $blend
|
||||
$pen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(118, 103, 210, 221), 1.5)
|
||||
$pen.LineJoin = [System.Drawing.Drawing2D.LineJoin]::Round
|
||||
$accentBrush = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(150, 99, 216, 225))
|
||||
$accentPath = [System.Drawing.Drawing2D.GraphicsPath]::new()
|
||||
$leftDiamond = [System.Drawing.PointF[]]@(
|
||||
[System.Drawing.PointF]::new(126, 47),
|
||||
[System.Drawing.PointF]::new(136, 58),
|
||||
[System.Drawing.PointF]::new(126, 69),
|
||||
[System.Drawing.PointF]::new(116, 58)
|
||||
)
|
||||
$rightDiamond = [System.Drawing.PointF[]]@(
|
||||
[System.Drawing.PointF]::new(3074, 47),
|
||||
[System.Drawing.PointF]::new(3084, 58),
|
||||
[System.Drawing.PointF]::new(3074, 69),
|
||||
[System.Drawing.PointF]::new(3064, 58)
|
||||
)
|
||||
$accentPen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(94, 91, 211, 223), 1.2)
|
||||
$accentPen.StartCap = [System.Drawing.Drawing2D.LineCap]::Round
|
||||
$accentPen.EndCap = [System.Drawing.Drawing2D.LineCap]::Round
|
||||
|
||||
$graphics.FillPath($brush, $surface)
|
||||
$graphics.DrawPath($pen, $topEdge)
|
||||
$graphics.DrawLine($accentPen, 82, 58, 116, 58)
|
||||
$graphics.DrawLine($accentPen, 136, 58, 170, 58)
|
||||
$graphics.DrawLine($accentPen, 3030, 58, 3064, 58)
|
||||
$graphics.DrawLine($accentPen, 3084, 58, 3118, 58)
|
||||
$accentPath.AddPolygon($leftDiamond)
|
||||
$accentPath.AddPolygon($rightDiamond)
|
||||
$graphics.FillPath($accentBrush, $accentPath)
|
||||
[System.IO.Directory]::CreateDirectory((Split-Path -Parent $outputPath)) | Out-Null
|
||||
$bitmap.Save($outputPath, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
|
||||
$accentPen.Dispose()
|
||||
$accentBrush.Dispose()
|
||||
$accentPath.Dispose()
|
||||
$pen.Dispose()
|
||||
$brush.Dispose()
|
||||
$surface.Dispose()
|
||||
$topEdge.Dispose()
|
||||
$graphics.Dispose()
|
||||
$bitmap.Dispose()
|
||||
@@ -0,0 +1,48 @@
|
||||
import { cpSync, existsSync, mkdtempSync, mkdirSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import process from "node:process";
|
||||
|
||||
const root = process.cwd();
|
||||
const sdkPackage = "@echosixhiya/teamspeak-client";
|
||||
const packageJson = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
||||
const dependency = packageJson.dependencies?.[sdkPackage];
|
||||
const match = typeof dependency === "string" ? /^git\+(.+?)#(.+)$/.exec(dependency) : null;
|
||||
|
||||
if (!match) {
|
||||
throw new Error(`${sdkPackage} must be pinned to a Git repository commit`);
|
||||
}
|
||||
|
||||
const [, repository, commit] = match;
|
||||
const temporaryRoot = mkdtempSync(join(tmpdir(), "webspeak-sdk-build-"));
|
||||
const destination = join(root, "node_modules", "@echosixhiya", "teamspeak-client", "dist");
|
||||
|
||||
try {
|
||||
execFileSync("git", ["clone", "--no-checkout", repository, temporaryRoot], { stdio: "inherit" });
|
||||
execFileSync("git", ["checkout", "--detach", commit], { cwd: temporaryRoot, stdio: "inherit" });
|
||||
const npmOptions = { cwd: temporaryRoot, stdio: "inherit" };
|
||||
const runNpm = (args) => {
|
||||
if (process.platform === "win32") {
|
||||
execFileSync(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `npm.cmd ${args.join(" ")}`], npmOptions);
|
||||
} else {
|
||||
execFileSync("npm", args, npmOptions);
|
||||
}
|
||||
};
|
||||
runNpm(["install", "--ignore-scripts", "--no-audit", "--no-fund"]);
|
||||
runNpm(["run", "build"]);
|
||||
|
||||
const source = join(temporaryRoot, "dist");
|
||||
if (!existsSync(join(source, "index.mjs"))) {
|
||||
throw new Error(`SDK build did not produce ${join(source, "index.mjs")}`);
|
||||
}
|
||||
|
||||
mkdirSync(dirname(destination), { recursive: true });
|
||||
mkdirSync(destination, { recursive: true });
|
||||
for (const entry of readdirSync(source)) {
|
||||
cpSync(join(source, entry), join(destination, entry), { recursive: true, force: true });
|
||||
}
|
||||
console.log(`Prepared ${sdkPackage} from ${commit}`);
|
||||
} finally {
|
||||
rmSync(temporaryRoot, { recursive: true, force: true });
|
||||
}
|
||||
@@ -1,11 +1,28 @@
|
||||
import { Router, type NextFunction, type Request, type Response } from "express";
|
||||
import { Router, raw as expressRaw, type NextFunction, type Request, type Response } from "express";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { AdminInputError, AdminService, type AdminSettingsInput } from "./admin-service.js";
|
||||
import { AdminInputError, AdminService, type AdminSettingsInput, type RelayNodeInput } from "./admin-service.js";
|
||||
import { AdminSessionStore, isSecureRequest } from "./admin-session.js";
|
||||
import { AdminLoginRateLimiter, waitFor } from "./login-rate-limit.js";
|
||||
import { TeamSpeakProbeError } from "../server/teamspeak-probe.js";
|
||||
import type { AdminSessionSummary } from "../server/voice-bridge.js";
|
||||
import { SkinRegistry, SkinRegistryError } from "./skin-registry.js";
|
||||
|
||||
export interface AdminConnectionRecord {
|
||||
id: string;
|
||||
nickname: string;
|
||||
clientIp: string;
|
||||
target: string;
|
||||
relayName: string | null;
|
||||
relayTarget: string | null;
|
||||
startedAt: string;
|
||||
connectedAt: string | null;
|
||||
disconnectedAt: string | null;
|
||||
durationSeconds: number | null;
|
||||
status: "active" | "connecting" | "disconnected" | "failed";
|
||||
reason: string | null;
|
||||
failureDetail: string | null;
|
||||
}
|
||||
|
||||
export interface AdminRouterOptions {
|
||||
service: AdminService;
|
||||
@@ -18,6 +35,7 @@ export interface AdminRouterOptions {
|
||||
terminateSession?: (id: string) => Promise<boolean>;
|
||||
version?: string;
|
||||
logFile?: string;
|
||||
skinRegistry?: SkinRegistry;
|
||||
startedAt: number;
|
||||
}
|
||||
|
||||
@@ -104,6 +122,81 @@ export function createAdminRouter(options: AdminRouterOptions): Router {
|
||||
response.json(options.service.getAdminSettings());
|
||||
});
|
||||
|
||||
router.get("/skins", async (_request, response) => {
|
||||
response.json({
|
||||
skins: await options.skinRegistry?.list() ?? [],
|
||||
defaultSkinId: await options.skinRegistry?.getDefaultSkinId() ?? "builtin.light",
|
||||
});
|
||||
});
|
||||
|
||||
router.put("/skins/default", requireSameOrigin, requireCsrf(options.sessions), async (request, response) => {
|
||||
try {
|
||||
if (!options.skinRegistry) throw new SkinRegistryError("Skin storage is unavailable.", "SKIN_STORAGE_UNAVAILABLE");
|
||||
const id = typeof asRecord(request.body).id === "string" ? (asRecord(request.body).id as string).trim() : "";
|
||||
const settings = await options.skinRegistry.setDefaultSkin(id);
|
||||
response.json({ ok: true, defaultSkinId: settings.defaultSkinId });
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SkinRegistryError) {
|
||||
response.status(error.code === "SKIN_DEFAULT_INVALID" ? 400 : 409).json({ ok: false, code: error.code, message: error.message });
|
||||
return;
|
||||
}
|
||||
sendAdminError(response, error);
|
||||
}
|
||||
});
|
||||
|
||||
router.put("/skins/:id/enabled", requireSameOrigin, requireCsrf(options.sessions), async (request, response) => {
|
||||
try {
|
||||
const id = typeof request.params.id === "string" ? request.params.id : "";
|
||||
const body = asRecord(request.body);
|
||||
if (!options.skinRegistry || typeof body.enabled !== "boolean") throw new SkinRegistryError("A skin and boolean enabled value are required.", "SKIN_ENABLE_INVALID");
|
||||
const skin = await options.skinRegistry.setEnabled(id, body.enabled);
|
||||
options.service.database.addAudit(body.enabled ? "ADMIN_SKIN_ENABLED" : "ADMIN_SKIN_DISABLED", { id });
|
||||
response.json({ ok: true, skin, defaultSkinId: await options.skinRegistry.getDefaultSkinId() });
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SkinRegistryError) {
|
||||
const status = error.code === "SKIN_NOT_FOUND" ? 404 : error.code === "SKIN_ENABLE_INVALID" ? 400 : 409;
|
||||
response.status(status).json({ ok: false, code: error.code, message: error.message });
|
||||
return;
|
||||
}
|
||||
sendAdminError(response, error);
|
||||
}
|
||||
});
|
||||
|
||||
router.put("/skins/:id", requireSameOriginBinary, requireCsrf(options.sessions), expressRaw({ type: "application/octet-stream", limit: "20mb" }), async (request, response) => {
|
||||
try {
|
||||
const id = typeof request.params.id === "string" ? request.params.id : "";
|
||||
if (!options.skinRegistry || !Buffer.isBuffer(request.body)) throw new SkinRegistryError("Skin storage is unavailable.", "SKIN_STORAGE_UNAVAILABLE");
|
||||
const skin = await options.skinRegistry.save(request.body, id);
|
||||
options.service.database.addAudit("ADMIN_SKIN_INSTALLED", { id: skin.id, version: skin.version });
|
||||
response.status(201).json({ ok: true, skin });
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SkinRegistryError) {
|
||||
const status = error.code === "SKIN_LIMIT" || error.code === "SKIN_STORAGE_LIMIT" || error.code === "SKIN_BUILTIN_PROTECTED" ? 409 : 400;
|
||||
response.status(status).json({ ok: false, code: error.code, message: error.message });
|
||||
return;
|
||||
}
|
||||
sendAdminError(response, error);
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/skins/:id", requireSameOrigin, requireCsrf(options.sessions), async (request, response) => {
|
||||
const id = typeof request.params.id === "string" ? request.params.id : "";
|
||||
try {
|
||||
if (!options.skinRegistry || !await options.skinRegistry.remove(id)) {
|
||||
response.status(404).json({ ok: false, code: "SKIN_NOT_FOUND" });
|
||||
return;
|
||||
}
|
||||
options.service.database.addAudit("ADMIN_SKIN_REMOVED", { id });
|
||||
response.json({ ok: true });
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SkinRegistryError) {
|
||||
response.status(error.code === "SKIN_BUILTIN_PROTECTED" ? 409 : 400).json({ ok: false, code: error.code, message: error.message });
|
||||
return;
|
||||
}
|
||||
sendAdminError(response, error);
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/sessions", (_request, response) => {
|
||||
response.json({ sessions: options.getSessionSummaries?.() ?? [] });
|
||||
});
|
||||
@@ -155,7 +248,12 @@ export function createAdminRouter(options: AdminRouterOptions): Router {
|
||||
});
|
||||
|
||||
router.get("/logs", (request, response) => {
|
||||
response.json({ available: Boolean(options.logFile && existsSync(options.logFile)), entries: readRecentLogs(options.logFile, readLimit(request.query.limit, 100)) });
|
||||
const limit = readLimit(request.query.limit, 100);
|
||||
response.json({
|
||||
available: Boolean(options.logFile && existsSync(options.logFile)),
|
||||
entries: readRecentLogs(options.logFile, limit),
|
||||
sessions: readConnectionHistory(options.logFile, limit),
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/diagnostics", (_request, response) => {
|
||||
@@ -163,7 +261,7 @@ export function createAdminRouter(options: AdminRouterOptions): Router {
|
||||
options.getActiveSessions(),
|
||||
options.getPeakSessions(),
|
||||
options.startedAt,
|
||||
) as unknown as AdminOverview;
|
||||
);
|
||||
response.json({
|
||||
generatedAt: new Date().toISOString(),
|
||||
gateway: {
|
||||
@@ -190,7 +288,7 @@ export function createAdminRouter(options: AdminRouterOptions): Router {
|
||||
options.getActiveSessions(),
|
||||
options.getPeakSessions(),
|
||||
options.startedAt,
|
||||
) as unknown as AdminOverview;
|
||||
);
|
||||
const report = {
|
||||
generatedAt: new Date().toISOString(),
|
||||
gateway: {
|
||||
@@ -306,6 +404,22 @@ function requireSameOrigin(request: Request, response: Response, next: NextFunct
|
||||
next();
|
||||
}
|
||||
|
||||
function requireSameOriginBinary(request: Request, response: Response, next: NextFunction): void {
|
||||
if (!request.is("application/octet-stream")) {
|
||||
response.status(415).json({ ok: false, code: "BINARY_REQUIRED" });
|
||||
return;
|
||||
}
|
||||
const origin = request.header("origin");
|
||||
const host = request.header("host");
|
||||
try {
|
||||
if (!origin || !host || new URL(origin).host !== host) throw new Error("origin mismatch");
|
||||
} catch {
|
||||
response.status(403).json({ ok: false, code: "ORIGIN_REJECTED" });
|
||||
return;
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
async function runProbe(
|
||||
service: AdminService,
|
||||
response: Response,
|
||||
@@ -325,6 +439,19 @@ async function runProbe(
|
||||
}
|
||||
|
||||
function readSettingsInput(body: Record<string, unknown>): AdminSettingsInput {
|
||||
const relayNodes = Array.isArray(body.relayNodes)
|
||||
? body.relayNodes.map((value): RelayNodeInput => {
|
||||
const node = asRecord(value);
|
||||
return {
|
||||
id: typeof node.id === "string" ? node.id.slice(0, 110) : undefined,
|
||||
name: typeof node.name === "string" ? node.name.slice(0, 80) : "",
|
||||
target: typeof node.target === "string" ? node.target.slice(0, 300) : "",
|
||||
enabled: node.enabled === true,
|
||||
token: typeof node.token === "string" ? node.token.slice(0, 512) : undefined,
|
||||
tokenAction: readPasswordAction(node.tokenAction),
|
||||
};
|
||||
})
|
||||
: undefined;
|
||||
return {
|
||||
target: readString(body, "target", 300),
|
||||
serverPassword: typeof body.serverPassword === "string" ? body.serverPassword.slice(0, 512) : undefined,
|
||||
@@ -332,12 +459,30 @@ function readSettingsInput(body: Record<string, unknown>): AdminSettingsInput {
|
||||
accessMode: body.accessMode === "open" ? "open" : body.accessMode === "fixed" ? "fixed" : body.accessMode as never,
|
||||
siteName: readString(body, "siteName", 80),
|
||||
welcomeText: readOptionalString(body, "welcomeText", 500),
|
||||
welcomeTextEn: typeof body.welcomeTextEn === "string" ? body.welcomeTextEn.slice(0, 500) : undefined,
|
||||
welcomeTextDe: typeof body.welcomeTextDe === "string" ? body.welcomeTextDe.slice(0, 500) : undefined,
|
||||
welcomeTextRu: typeof body.welcomeTextRu === "string" ? body.welcomeTextRu.slice(0, 500) : undefined,
|
||||
welcomeTextJa: typeof body.welcomeTextJa === "string" ? body.welcomeTextJa.slice(0, 500) : undefined,
|
||||
webRtcEnabled: body.webRtcEnabled === true,
|
||||
webRtcPublicHost: body.webRtcPublicHost as string | undefined,
|
||||
webRtcIpv6Enabled: body.webRtcIpv6Enabled as boolean | undefined,
|
||||
webRtcStunServer: body.webRtcStunServer as string | undefined,
|
||||
webRtcUdpStart: readOptionalInteger(body, "webRtcUdpStart"),
|
||||
webRtcUdpEnd: readOptionalInteger(body, "webRtcUdpEnd"),
|
||||
relaySettingsAction: readRelaySettingsAction(body.relaySettingsAction),
|
||||
relayEnabled: body.relayEnabled === true,
|
||||
relayName: typeof body.relayName === "string" ? body.relayName.slice(0, 80) : undefined,
|
||||
relayTarget: typeof body.relayTarget === "string" ? body.relayTarget.slice(0, 300) : undefined,
|
||||
relayToken: typeof body.relayToken === "string" ? body.relayToken.slice(0, 512) : undefined,
|
||||
relayTokenAction: readPasswordAction(body.relayTokenAction),
|
||||
relayNodes,
|
||||
};
|
||||
}
|
||||
|
||||
function readRelaySettingsAction(value: unknown): "keep" | "replace" | "remove" {
|
||||
return value === "replace" || value === "remove" ? value : "keep";
|
||||
}
|
||||
|
||||
function readPasswordAction(value: unknown): "keep" | "replace" | "remove" {
|
||||
return value === "replace" || value === "remove" ? value : "keep";
|
||||
}
|
||||
@@ -388,7 +533,7 @@ function readRecentLogs(logFile: string | undefined, limit: number): AdminLogEnt
|
||||
try {
|
||||
const raw = JSON.parse(line) as Record<string, unknown>;
|
||||
const context: Record<string, string | number | boolean> = {};
|
||||
for (const key of ["component", "entryId", "code", "reason", "attempt", "target", "nickname", "channel", "reconnect", "port"]) {
|
||||
for (const key of ["component", "entryId", "code", "reason", "attempt", "target", "nickname", "clientIp", "relayName", "relayTarget", "channel", "reconnect", "port"]) {
|
||||
const value = raw[key];
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") context[key] = value;
|
||||
}
|
||||
@@ -407,15 +552,143 @@ function readRecentLogs(logFile: string | undefined, limit: number): AdminLogEnt
|
||||
}
|
||||
}
|
||||
|
||||
interface AdminOverview {
|
||||
gateway: { uptimeSeconds: number };
|
||||
teamSpeak: {
|
||||
interface StructuredLogEntry {
|
||||
timestamp: string | null;
|
||||
message: string;
|
||||
raw: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export function readConnectionHistory(logFile: string | undefined, limit: number): AdminConnectionRecord[] {
|
||||
if (!logFile) return [];
|
||||
const records = new Map<string, {
|
||||
id: string;
|
||||
nickname: string;
|
||||
clientIp: string;
|
||||
target: string;
|
||||
status: string;
|
||||
lastTestAt: string | null;
|
||||
latencyMs: number | null;
|
||||
lastError: string | null;
|
||||
};
|
||||
relayName: string;
|
||||
relayTarget: string;
|
||||
startedAt: string | null;
|
||||
connectedAt: string | null;
|
||||
disconnectedAt: string | null;
|
||||
durationSeconds: number | null;
|
||||
status: AdminConnectionRecord["status"];
|
||||
reason: string | null;
|
||||
failureDetail: string | null;
|
||||
}>();
|
||||
for (const log of readStructuredLogs(logFile)) {
|
||||
const entryId = typeof log.raw.entryId === "string" ? log.raw.entryId : "";
|
||||
if (!entryId || !log.timestamp) continue;
|
||||
const current = records.get(entryId) ?? {
|
||||
id: entryId,
|
||||
nickname: "",
|
||||
clientIp: "",
|
||||
target: "",
|
||||
relayName: "",
|
||||
relayTarget: "",
|
||||
startedAt: null,
|
||||
connectedAt: null,
|
||||
disconnectedAt: null,
|
||||
durationSeconds: null,
|
||||
status: "connecting" as const,
|
||||
reason: null,
|
||||
failureDetail: null,
|
||||
};
|
||||
const nickname = typeof log.raw.nickname === "string" ? log.raw.nickname : "";
|
||||
const clientIp = typeof log.raw.clientIp === "string" ? log.raw.clientIp : "";
|
||||
const target = typeof log.raw.target === "string" ? log.raw.target : "";
|
||||
const relayName = typeof log.raw.relayName === "string" ? log.raw.relayName : "";
|
||||
const relayTarget = typeof log.raw.relayTarget === "string" ? log.raw.relayTarget : "";
|
||||
if (nickname) current.nickname = nickname;
|
||||
if (clientIp) current.clientIp = clientIp;
|
||||
if (target) current.target = target;
|
||||
if (relayName) current.relayName = relayName;
|
||||
if (relayTarget) current.relayTarget = relayTarget;
|
||||
if (typeof log.raw.failureDetail === "string" && log.raw.failureDetail) current.failureDetail = log.raw.failureDetail;
|
||||
if (log.message === "WebClient connecting") {
|
||||
current.startedAt ??= log.timestamp;
|
||||
current.status = "connecting";
|
||||
} else if (log.message === "TS connect failed") {
|
||||
current.reason = typeof log.raw.code === "string" ? log.raw.code : current.reason;
|
||||
current.status = "failed";
|
||||
} else if (log.message === "Web client connected to TeamSpeak") {
|
||||
current.startedAt ??= log.timestamp;
|
||||
current.connectedAt = log.timestamp;
|
||||
current.status = "active";
|
||||
} else if (log.message === "Client session torn down") {
|
||||
current.startedAt ??= log.timestamp;
|
||||
current.disconnectedAt = log.timestamp;
|
||||
current.durationSeconds = current.connectedAt && typeof log.raw.durationSeconds === "number"
|
||||
? Math.max(0, Math.floor(log.raw.durationSeconds))
|
||||
: current.connectedAt
|
||||
? Math.max(0, Math.floor((Date.parse(log.timestamp) - Date.parse(current.connectedAt)) / 1000))
|
||||
: null;
|
||||
current.status = current.connectedAt ? "disconnected" : "failed";
|
||||
// `reason` is also used for ordinary lifecycle teardown (for example
|
||||
// websocket-close when a user clicks Leave). Only preserve an explicit
|
||||
// TeamSpeak failure code here; otherwise a normal disconnect would be
|
||||
// rendered by the admin UI as the generic request-failed message.
|
||||
current.reason = typeof log.raw.failureCode === "string" && log.raw.failureCode
|
||||
? log.raw.failureCode
|
||||
: current.reason;
|
||||
}
|
||||
records.set(entryId, current);
|
||||
}
|
||||
const now = Date.now();
|
||||
return [...records.values()]
|
||||
.filter((record): record is typeof record & { startedAt: string } => Boolean(record.startedAt))
|
||||
.map((record) => {
|
||||
const start = record.connectedAt ?? record.startedAt;
|
||||
const end = record.disconnectedAt ? Date.parse(record.disconnectedAt) : now;
|
||||
return {
|
||||
id: record.id,
|
||||
nickname: record.nickname || "—",
|
||||
clientIp: record.clientIp || "—",
|
||||
target: record.target || "—",
|
||||
relayName: record.relayName || null,
|
||||
relayTarget: record.relayTarget || null,
|
||||
startedAt: record.startedAt,
|
||||
connectedAt: record.connectedAt,
|
||||
disconnectedAt: record.disconnectedAt,
|
||||
durationSeconds: record.durationSeconds ?? (record.status === "active" || record.status === "connecting"
|
||||
? Math.max(0, Math.floor((end - Date.parse(start)) / 1000))
|
||||
: null),
|
||||
status: record.status,
|
||||
// Older sessions may only contain a teardown record without a
|
||||
// structured failure code. Keep normal disconnects quiet, but make
|
||||
// an untraceable failed connection explicitly visible as the generic
|
||||
// request-failed message instead of implying a guessed cause.
|
||||
reason: record.reason ?? (record.status === "failed" ? "CONNECTION_FAILED" : null),
|
||||
failureDetail: record.failureDetail,
|
||||
};
|
||||
})
|
||||
.sort((left, right) => Date.parse(right.disconnectedAt ?? right.startedAt) - Date.parse(left.disconnectedAt ?? left.startedAt))
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
||||
function readStructuredLogs(logFile: string): StructuredLogEntry[] {
|
||||
const paths = [logFile, `${logFile}.1`, `${logFile}.2`, `${logFile}.3`].filter((value, index, all) => value && all.indexOf(value) === index);
|
||||
const entries: StructuredLogEntry[] = [];
|
||||
for (const path of paths) {
|
||||
if (!existsSync(path)) continue;
|
||||
try {
|
||||
for (const line of readFileSync(path, "utf8").split(/\r?\n/).filter(Boolean)) {
|
||||
try {
|
||||
const raw = JSON.parse(line) as Record<string, unknown>;
|
||||
entries.push({
|
||||
timestamp: typeof raw.time === "string" ? raw.time : null,
|
||||
message: typeof raw.msg === "string" ? raw.msg : "",
|
||||
raw,
|
||||
});
|
||||
} catch {
|
||||
// Non-JSON lines are still shown by the normal log viewer, but cannot
|
||||
// be associated with a user session safely.
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// A rotated file can disappear between existsSync and readFileSync.
|
||||
}
|
||||
}
|
||||
return entries.sort((left, right) => Date.parse(left.timestamp ?? "") - Date.parse(right.timestamp ?? ""));
|
||||
}
|
||||
|
||||
function logLevelName(level: unknown): string {
|
||||
|
||||
@@ -1,39 +1,30 @@
|
||||
import type { AdminSettingsInput, RelayNodeInput, ManagedInviteInput } from "../shared/admin-inputs.js";
|
||||
export type { AdminSettingsInput, RelayNodeInput, ManagedInviteInput } from "../shared/admin-inputs.js";
|
||||
import type { AdminOverview, AdminSettings } from "../shared/admin-responses.js";
|
||||
import { createHash, randomBytes } from "node:crypto";
|
||||
import { existsSync } from "node:fs";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { loadConfig } from "../config.js";
|
||||
import { formatTeamSpeakTarget, parseTeamSpeakTarget, type TeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { type AccessMode, type ManagedInviteRecord, type SettingsUpdate, WebSpeakDatabase } from "../persistence/database.js";
|
||||
import { DEFAULT_TEAM_SPEAK_PORT, formatTeamSpeakTarget, parseTeamSpeakTarget, type TeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { formatTeamSpeakConnectionTarget, parseTeamSpeakConnectionTarget, type TeamSpeakConnectionTarget } from "../domain/teamspeak-connection-target.js";
|
||||
import { resolveTeamSpeakTarget, TeamSpeakAliasLookupError } from "../server/teamspeak-alias.js";
|
||||
import { type AccessMode, type ManagedInviteRecord, type PersistedRelayNode, type SettingsUpdate, WebSpeakDatabase } from "../persistence/database.js";
|
||||
import { hashAdminPassword, validateAdminPassword, verifyAdminPassword } from "../security/admin-password.js";
|
||||
import { decryptSecret, encryptSecret } from "../security/secret-crypto.js";
|
||||
import { probeTeamSpeak, TeamSpeakProbeError, type TeamSpeakProbeResult } from "../server/teamspeak-probe.js";
|
||||
import { probeTeamSpeak, TeamSpeakProbeError } from "../server/teamspeak-probe.js";
|
||||
import { pingTeamSpeakHost } from "../server/network-probe.js";
|
||||
import { normalizeVoiceMediaHost, normalizeVoiceStunServer } from "../shared/voice-ice.js";
|
||||
import type { WebRtcAudioOptions } from "../server/webrtc-audio.js";
|
||||
import { DEFAULT_ACCELERATION_RELAY_PORT, type ConfiguredAccelerationRelay } from "../server/acceleration-relay.js";
|
||||
import { DEFAULT_WEBRTC_UDP_PORT_RANGE, WEBRTC_UDP_PORT_MAX, WEBRTC_UDP_PORT_MIN } from "../server/webrtc-config.js";
|
||||
|
||||
export interface AdminSettingsInput {
|
||||
target: string;
|
||||
serverPassword?: string;
|
||||
passwordAction?: "keep" | "replace" | "remove";
|
||||
accessMode: AccessMode;
|
||||
siteName: string;
|
||||
welcomeText: string;
|
||||
webRtcEnabled: boolean;
|
||||
webRtcUdpStart?: number;
|
||||
webRtcUdpEnd?: number;
|
||||
}
|
||||
import { DEFAULT_WELCOME_TEXTS, resolveWelcomeTexts } from "../site-copy.js";
|
||||
|
||||
export interface ConnectionPolicy {
|
||||
defaultTarget: TeamSpeakTarget;
|
||||
defaultTarget: string;
|
||||
serverPassword: string;
|
||||
accessMode: AccessMode;
|
||||
}
|
||||
|
||||
export interface ManagedInviteInput {
|
||||
channel: string;
|
||||
expiresInHours: number;
|
||||
maxUses: number;
|
||||
}
|
||||
|
||||
export interface ManagedInviteView {
|
||||
id: string;
|
||||
target: string;
|
||||
@@ -92,30 +83,55 @@ export class AdminService {
|
||||
|
||||
getPublicConfig(): Record<string, unknown> {
|
||||
const settings = this.database.getSettings();
|
||||
const welcomeTexts = resolveWelcomeTexts({
|
||||
zh: settings.welcomeText,
|
||||
en: settings.welcomeTextEn,
|
||||
de: settings.welcomeTextDe,
|
||||
ru: settings.welcomeTextRu,
|
||||
ja: settings.welcomeTextJa,
|
||||
});
|
||||
return {
|
||||
version: this.version,
|
||||
initialized: this.isInitialized(),
|
||||
siteName: settings.siteName,
|
||||
welcomeText: settings.welcomeText,
|
||||
// Keep the old fields for older clients, but return the complete,
|
||||
// already-fallback-resolved map for current clients.
|
||||
welcomeText: welcomeTexts.zh,
|
||||
welcomeTextEn: welcomeTexts.en,
|
||||
welcomeTexts,
|
||||
accessMode: settings.accessMode,
|
||||
target: formatTeamSpeakTarget({ host: settings.tsHost, port: settings.tsPort }),
|
||||
target: settingsTarget(settings),
|
||||
};
|
||||
}
|
||||
|
||||
getAdminSettings(): Record<string, unknown> {
|
||||
getAdminSettings(): AdminSettings {
|
||||
const settings = this.database.getSettings();
|
||||
return {
|
||||
target: formatTeamSpeakTarget({ host: settings.tsHost, port: settings.tsPort }),
|
||||
target: settingsTarget(settings),
|
||||
hasPassword: Boolean(settings.tsPasswordEncrypted),
|
||||
accessMode: settings.accessMode,
|
||||
siteName: settings.siteName,
|
||||
welcomeText: settings.welcomeText,
|
||||
welcomeTextEn: settings.welcomeTextEn,
|
||||
welcomeTextDe: settings.welcomeTextDe,
|
||||
welcomeTextRu: settings.welcomeTextRu,
|
||||
welcomeTextJa: settings.welcomeTextJa,
|
||||
welcomeDefaults: DEFAULT_WELCOME_TEXTS,
|
||||
lastTestAt: settings.lastTestAt,
|
||||
lastTestLatencyMs: settings.lastTestLatencyMs,
|
||||
lastTestError: settings.lastTestError,
|
||||
webRtcEnabled: settings.webRtcEnabled,
|
||||
webRtcPublicHost: settings.webRtcPublicHost,
|
||||
webRtcIpv6Enabled: settings.webRtcIpv6Enabled,
|
||||
webRtcStunServer: settings.webRtcStunServer,
|
||||
webRtcUdpStart: settings.webRtcUdpStart,
|
||||
webRtcUdpEnd: settings.webRtcUdpEnd,
|
||||
relayConfigured: settings.relayConfigured,
|
||||
relayEnabled: settings.relayEnabled,
|
||||
relayName: settings.relayName,
|
||||
relayTarget: settings.relayHost ? formatRelayTarget(settings.relayHost, settings.relayPort) : "",
|
||||
hasRelayToken: Boolean(settings.relayTokenEncrypted),
|
||||
relayNodes: this.getRelayNodeViews(),
|
||||
internalPort: 3040,
|
||||
updatedAt: settings.updatedAt,
|
||||
};
|
||||
@@ -125,15 +141,42 @@ export class AdminService {
|
||||
const settings = this.database.getSettings();
|
||||
return {
|
||||
enabled: settings.webRtcEnabled,
|
||||
publicHost: settings.webRtcPublicHost,
|
||||
ipv6Enabled: settings.webRtcIpv6Enabled,
|
||||
stunServer: settings.webRtcStunServer,
|
||||
udpPortRange: [settings.webRtcUdpStart, settings.webRtcUdpEnd],
|
||||
};
|
||||
}
|
||||
|
||||
getAccelerationRelayOptions(): ConfiguredAccelerationRelay[] {
|
||||
const relays: ConfiguredAccelerationRelay[] = [];
|
||||
for (const node of this.database.listRelayNodes()) {
|
||||
if (!node.enabled || !node.host || !node.tokenEncrypted) continue;
|
||||
try {
|
||||
const token = decryptSecret(node.tokenEncrypted, this.masterSecret);
|
||||
relays.push({ id: node.id, name: node.name, relayHost: node.host, relayPort: node.port, token });
|
||||
} catch (error: unknown) {
|
||||
this.logger.error({ err: error instanceof Error ? error.message : String(error), relayId: node.id }, "Stored acceleration relay token could not be decrypted");
|
||||
}
|
||||
}
|
||||
return relays;
|
||||
}
|
||||
|
||||
getAccelerationRelayName(): string | undefined {
|
||||
return this.getAccelerationRelayOptions()[0]?.name;
|
||||
}
|
||||
|
||||
updateSettings(input: AdminSettingsInput): void {
|
||||
const current = this.database.getSettings();
|
||||
const settings = this.normalizeSettings(input, current);
|
||||
const targetChanged = current.tsHost !== settings.tsHost || current.tsPort !== settings.tsPort;
|
||||
const relayNodes = input.relayNodes === undefined ? undefined : this.normalizeRelayNodes(input.relayNodes);
|
||||
const settings = this.normalizeSettings(input, current, relayNodes);
|
||||
const targetChanged = current.tsHost !== settings.tsHost || current.tsPort !== settings.tsPort || current.tsTarget !== settings.tsTarget;
|
||||
this.database.updateSettings(settings);
|
||||
if (relayNodes !== undefined) {
|
||||
this.database.replaceRelayNodes(relayNodes);
|
||||
} else if (input.relaySettingsAction && input.relaySettingsAction !== "keep") {
|
||||
this.database.replaceRelayNodes(this.legacyRelayNodesFromSettings(settings));
|
||||
}
|
||||
if (targetChanged) this.database.clearConnectionTest();
|
||||
}
|
||||
|
||||
@@ -146,31 +189,62 @@ export class AdminService {
|
||||
this.logger.error({ err: error instanceof Error ? error.message : String(error) }, "Stored TeamSpeak password could not be decrypted");
|
||||
}
|
||||
return {
|
||||
defaultTarget: { host: settings.tsHost, port: settings.tsPort },
|
||||
defaultTarget: settingsTarget(settings),
|
||||
serverPassword,
|
||||
accessMode: settings.accessMode,
|
||||
};
|
||||
}
|
||||
|
||||
async testConnection(targetText: string, password: string, persistResult: boolean): Promise<Omit<TeamSpeakProbeResult, "protocol">> {
|
||||
async testConnection(targetText: string, password: string, persistResult: boolean): Promise<{ ok: boolean; checkType: "network" | "protocol"; passwordVerified: boolean; latencyMs: number; serverName: string | null; requiresPassword: boolean; packetLossPercent?: number; attempts?: number; successfulAttempts?: number; errorCode?: string }> {
|
||||
let target: TeamSpeakTarget;
|
||||
try {
|
||||
target = parseTeamSpeakTarget(targetText);
|
||||
parseTeamSpeakConnectionTarget(targetText);
|
||||
} catch {
|
||||
throw new AdminInputError("INVALID_TARGET", "TeamSpeak target is invalid");
|
||||
}
|
||||
try {
|
||||
target = await resolveTeamSpeakTarget(targetText);
|
||||
// The admin connection test must not create a temporary TeamSpeak
|
||||
// client: that client becomes visible in the target channel. Use the
|
||||
// WebSpeak host's ICMP route measurement instead. The injected probe is
|
||||
// retained for unit tests and explicit protocol-probe callers.
|
||||
if (this.probe === probeTeamSpeak) {
|
||||
const result = await pingTeamSpeakHost(target.host, { attempts: 4 });
|
||||
const publicResult = {
|
||||
ok: result.ok,
|
||||
checkType: "network" as const,
|
||||
passwordVerified: false,
|
||||
latencyMs: result.latencyMs ?? 0,
|
||||
serverName: null,
|
||||
requiresPassword: false,
|
||||
packetLossPercent: result.packetLossPercent,
|
||||
attempts: result.attempts,
|
||||
successfulAttempts: result.successfulAttempts,
|
||||
...(result.errorCode ? { errorCode: result.errorCode } : {}),
|
||||
};
|
||||
if (persistResult) {
|
||||
this.database.recordConnectionTest({ protocol: null, latencyMs: result.latencyMs, error: result.ok ? null : (result.errorCode ?? "UNREACHABLE") });
|
||||
this.database.addAudit(result.ok ? "CONNECTION_TEST_SUCCEEDED" : "CONNECTION_TEST_FAILED", {
|
||||
latencyMs: result.latencyMs,
|
||||
packetLossPercent: result.packetLossPercent,
|
||||
...(result.errorCode ? { code: result.errorCode } : {}),
|
||||
});
|
||||
}
|
||||
return publicResult;
|
||||
}
|
||||
const result = await this.probe(target, password, this.logger);
|
||||
if (persistResult) {
|
||||
this.database.recordConnectionTest({ protocol: result.protocol, latencyMs: result.latencyMs, error: null });
|
||||
this.database.addAudit("CONNECTION_TEST_SUCCEEDED", { protocol: result.protocol, latencyMs: result.latencyMs });
|
||||
}
|
||||
const { protocol: _protocol, ...publicResult } = result;
|
||||
return publicResult;
|
||||
return { ...publicResult, checkType: "protocol", passwordVerified: true };
|
||||
} catch (error: unknown) {
|
||||
const probeError = error instanceof TeamSpeakProbeError
|
||||
? error
|
||||
: new TeamSpeakProbeError("INTERNAL_ERROR", "Connection test failed", error);
|
||||
: error instanceof TeamSpeakAliasLookupError
|
||||
? new TeamSpeakProbeError("HOST_NOT_FOUND", "TeamSpeak server nickname could not be resolved", error)
|
||||
: new TeamSpeakProbeError("INTERNAL_ERROR", "Connection test failed", error);
|
||||
if (persistResult) {
|
||||
this.database.recordConnectionTest({ protocol: null, latencyMs: null, error: probeError.code });
|
||||
this.database.addAudit("CONNECTION_TEST_FAILED", { code: probeError.code });
|
||||
@@ -179,7 +253,7 @@ export class AdminService {
|
||||
}
|
||||
}
|
||||
|
||||
getOverview(activeSessions: number, peakSessions: number, startedAt: number): Record<string, unknown> {
|
||||
getOverview(activeSessions: number, peakSessions: number, startedAt: number): AdminOverview {
|
||||
const settings = this.database.getSettings();
|
||||
return {
|
||||
gateway: {
|
||||
@@ -188,7 +262,7 @@ export class AdminService {
|
||||
uptimeSeconds: Math.max(0, Math.floor((Date.now() - startedAt) / 1000)),
|
||||
},
|
||||
teamSpeak: {
|
||||
target: formatTeamSpeakTarget({ host: settings.tsHost, port: settings.tsPort }),
|
||||
target: settingsTarget(settings),
|
||||
status: settings.lastTestError ? "unreachable" : settings.lastTestAt ? "reachable" : "unknown",
|
||||
lastTestAt: settings.lastTestAt,
|
||||
latencyMs: settings.lastTestLatencyMs,
|
||||
@@ -216,6 +290,7 @@ export class AdminService {
|
||||
tokenHash: hashInviteToken(token),
|
||||
targetHost: settings.tsHost,
|
||||
targetPort: settings.tsPort,
|
||||
targetText: settings.tsTarget,
|
||||
serverPasswordEncrypted: settings.tsPasswordEncrypted,
|
||||
channel,
|
||||
expiresAt: new Date(Date.now() + input.expiresInHours * 60 * 60 * 1000).toISOString(),
|
||||
@@ -236,7 +311,17 @@ export class AdminService {
|
||||
return revoked;
|
||||
}
|
||||
|
||||
consumeManagedInvite(token: string): { target: TeamSpeakTarget; serverPassword: string; channel: string } | null {
|
||||
getManagedInvite(token: string): { target: string; channel: string } | null {
|
||||
if (!/^[A-Za-z0-9_-]{32,128}$/.test(token)) return null;
|
||||
const record = this.database.getManagedInvite(hashInviteToken(token));
|
||||
if (!record) return null;
|
||||
return {
|
||||
target: record.targetText ?? formatTeamSpeakTarget({ host: record.targetHost, port: record.targetPort }),
|
||||
channel: record.channel,
|
||||
};
|
||||
}
|
||||
|
||||
consumeManagedInvite(token: string): { target: string; serverPassword: string; channel: string } | null {
|
||||
if (!/^[A-Za-z0-9_-]{32,128}$/.test(token)) return null;
|
||||
const record = this.database.consumeManagedInvite(hashInviteToken(token));
|
||||
if (!record) return null;
|
||||
@@ -247,30 +332,44 @@ export class AdminService {
|
||||
this.logger.error({ err: error instanceof Error ? error.message : String(error), inviteId: record.id }, "Managed invite password could not be decrypted");
|
||||
}
|
||||
this.database.addAudit("INVITE_CONSUMED", { id: record.id });
|
||||
return { target: { host: record.targetHost, port: record.targetPort }, serverPassword, channel: record.channel };
|
||||
return { target: record.targetText ?? formatTeamSpeakTarget({ host: record.targetHost, port: record.targetPort }), serverPassword, channel: record.channel };
|
||||
}
|
||||
|
||||
dismissLegacyImportNotice(): void {
|
||||
this.database.setMeta("legacy_import_notice_pending", "0");
|
||||
}
|
||||
|
||||
private normalizeSettings(input: AdminSettingsInput, current: ReturnType<WebSpeakDatabase["getSettings"]>): SettingsUpdate {
|
||||
let target: TeamSpeakTarget;
|
||||
private normalizeSettings(input: AdminSettingsInput, current: ReturnType<WebSpeakDatabase["getSettings"]>, relayNodes?: PersistedRelayNode[]): SettingsUpdate {
|
||||
let target: TeamSpeakConnectionTarget;
|
||||
try {
|
||||
target = parseTeamSpeakTarget(input.target);
|
||||
target = parseTeamSpeakConnectionTarget(input.target);
|
||||
} catch {
|
||||
throw new AdminInputError("INVALID_TARGET", "TeamSpeak target is invalid");
|
||||
}
|
||||
const siteName = input.siteName.trim();
|
||||
const welcomeText = input.welcomeText.trim();
|
||||
const welcomeTextEn = typeof input.welcomeTextEn === "string" ? input.welcomeTextEn.trim() : current.welcomeTextEn;
|
||||
const welcomeTextDe = typeof input.welcomeTextDe === "string" ? input.welcomeTextDe.trim() : current.welcomeTextDe;
|
||||
const welcomeTextRu = typeof input.welcomeTextRu === "string" ? input.welcomeTextRu.trim() : current.welcomeTextRu;
|
||||
const welcomeTextJa = typeof input.welcomeTextJa === "string" ? input.welcomeTextJa.trim() : current.welcomeTextJa;
|
||||
if (!siteName || siteName.length > 80) throw new AdminInputError("INVALID_SITE_NAME", "Site name must contain 1 to 80 characters");
|
||||
if (welcomeText.length > 500) throw new AdminInputError("INVALID_WELCOME_TEXT", "Welcome text cannot exceed 500 characters");
|
||||
if (welcomeTextEn.length > 500) throw new AdminInputError("INVALID_WELCOME_TEXT_EN", "English welcome text cannot exceed 500 characters");
|
||||
if (welcomeTextDe.length > 500) throw new AdminInputError("INVALID_WELCOME_TEXT_DE", "German welcome text cannot exceed 500 characters");
|
||||
if (welcomeTextRu.length > 500) throw new AdminInputError("INVALID_WELCOME_TEXT_RU", "Russian welcome text cannot exceed 500 characters");
|
||||
if (welcomeTextJa.length > 500) throw new AdminInputError("INVALID_WELCOME_TEXT_JA", "Japanese welcome text cannot exceed 500 characters");
|
||||
if (input.accessMode !== "fixed" && input.accessMode !== "open") {
|
||||
throw new AdminInputError("INVALID_ACCESS_MODE", "Access mode is invalid");
|
||||
}
|
||||
if (typeof input.webRtcEnabled !== "boolean") {
|
||||
throw new AdminInputError("INVALID_WEBRTC_ENABLED", "WebRTC enabled value is invalid");
|
||||
}
|
||||
const webRtcPublicHost = normalizeVoiceMediaHost(input.webRtcPublicHost === undefined ? current.webRtcPublicHost : input.webRtcPublicHost);
|
||||
const webRtcStunServer = normalizeVoiceStunServer(input.webRtcStunServer === undefined ? current.webRtcStunServer : input.webRtcStunServer);
|
||||
const webRtcIpv6Enabled = input.webRtcIpv6Enabled === undefined ? current.webRtcIpv6Enabled : input.webRtcIpv6Enabled;
|
||||
if (webRtcPublicHost === null) throw new AdminInputError("INVALID_WEBRTC_PUBLIC_HOST", "Use an IP address or hostname without a scheme, path or port");
|
||||
if (webRtcStunServer === null) throw new AdminInputError("INVALID_WEBRTC_STUN_SERVER", "Use a UDP STUN URL: stun:host:port");
|
||||
if (typeof webRtcIpv6Enabled !== "boolean") throw new AdminInputError("INVALID_WEBRTC_IPV6", "WebRTC IPv6 value must be boolean");
|
||||
const webRtcUdpStart = input.webRtcUdpStart ?? current.webRtcUdpStart ?? DEFAULT_WEBRTC_UDP_PORT_RANGE[0];
|
||||
const webRtcUdpEnd = input.webRtcUdpEnd ?? current.webRtcUdpEnd ?? DEFAULT_WEBRTC_UDP_PORT_RANGE[1];
|
||||
if (!Number.isInteger(webRtcUdpStart) || webRtcUdpStart < WEBRTC_UDP_PORT_MIN || webRtcUdpStart > WEBRTC_UDP_PORT_MAX) {
|
||||
@@ -290,26 +389,163 @@ export class AdminService {
|
||||
const action = input.passwordAction ?? (input.serverPassword === undefined ? "keep" : "replace");
|
||||
if (action === "remove") encryptedPassword = null;
|
||||
if (action === "replace") encryptedPassword = input.serverPassword ? encryptSecret(input.serverPassword, this.masterSecret) : null;
|
||||
|
||||
let relayConfigured = current.relayConfigured;
|
||||
let relayEnabled = current.relayEnabled;
|
||||
let relayName = current.relayName;
|
||||
let relayHost = current.relayHost;
|
||||
let relayPort = current.relayPort || DEFAULT_ACCELERATION_RELAY_PORT;
|
||||
let relayTokenEncrypted = current.relayTokenEncrypted;
|
||||
const relaySettingsAction = input.relaySettingsAction ?? "keep";
|
||||
if (relaySettingsAction === "remove") {
|
||||
relayConfigured = true;
|
||||
relayEnabled = false;
|
||||
relayName = "";
|
||||
relayHost = "";
|
||||
relayPort = DEFAULT_ACCELERATION_RELAY_PORT;
|
||||
relayTokenEncrypted = null;
|
||||
} else if (relaySettingsAction === "replace") {
|
||||
const relayTarget = (input.relayTarget ?? "").trim();
|
||||
relayEnabled = input.relayEnabled === true;
|
||||
relayName = (input.relayName ?? "").trim();
|
||||
if (relayName.length > 80) throw new AdminInputError("INVALID_RELAY_NAME", "Relay name must contain 80 characters or fewer");
|
||||
if (relayEnabled && !relayName) throw new AdminInputError("INVALID_RELAY_NAME", "Relay name is required when the relay is enabled");
|
||||
if (relayEnabled && !relayTarget) throw new AdminInputError("INVALID_RELAY_TARGET", "Relay target is required when the relay is enabled");
|
||||
if (relayTarget) {
|
||||
try {
|
||||
const relay = parseTeamSpeakTarget(relayTarget, DEFAULT_ACCELERATION_RELAY_PORT);
|
||||
relayHost = relay.host;
|
||||
relayPort = relay.port;
|
||||
} catch {
|
||||
throw new AdminInputError("INVALID_RELAY_TARGET", "Relay target is invalid");
|
||||
}
|
||||
} else {
|
||||
relayHost = "";
|
||||
relayPort = DEFAULT_ACCELERATION_RELAY_PORT;
|
||||
}
|
||||
const relayTokenAction = input.relayTokenAction ?? (input.relayToken === undefined ? "keep" : "replace");
|
||||
if (relayTokenAction === "remove") relayTokenEncrypted = null;
|
||||
if (relayTokenAction === "replace") relayTokenEncrypted = input.relayToken ? encryptSecret(input.relayToken, this.masterSecret) : null;
|
||||
if (relayEnabled && !relayTokenEncrypted) throw new AdminInputError("INVALID_RELAY_TOKEN", "Relay token is required when the relay is enabled");
|
||||
relayConfigured = true;
|
||||
}
|
||||
if (relayNodes) {
|
||||
const primary = relayNodes.find((node) => node.enabled) ?? relayNodes[0];
|
||||
relayConfigured = relayNodes.length > 0;
|
||||
relayEnabled = primary?.enabled === true;
|
||||
relayName = primary?.name ?? "";
|
||||
relayHost = primary?.host ?? "";
|
||||
relayPort = primary?.port ?? DEFAULT_ACCELERATION_RELAY_PORT;
|
||||
relayTokenEncrypted = primary?.tokenEncrypted ?? null;
|
||||
}
|
||||
return {
|
||||
siteName,
|
||||
welcomeText,
|
||||
welcomeTextEn,
|
||||
welcomeTextDe,
|
||||
welcomeTextRu,
|
||||
welcomeTextJa,
|
||||
accessMode: input.accessMode,
|
||||
tsHost: target.host,
|
||||
tsPort: target.port,
|
||||
tsHost: target.kind === "nickname" ? target.name : target.target.host,
|
||||
tsPort: target.kind === "nickname" ? target.port ?? DEFAULT_TEAM_SPEAK_PORT : target.target.port,
|
||||
tsTarget: target.kind === "nickname" ? formatTeamSpeakConnectionTarget(target) : null,
|
||||
tsPasswordEncrypted: encryptedPassword,
|
||||
webRtcEnabled: input.webRtcEnabled,
|
||||
webRtcPublicHost, webRtcIpv6Enabled, webRtcStunServer,
|
||||
webRtcUdpStart,
|
||||
webRtcUdpEnd,
|
||||
relayConfigured,
|
||||
relayEnabled,
|
||||
relayName,
|
||||
relayHost,
|
||||
relayPort,
|
||||
relayTokenEncrypted,
|
||||
};
|
||||
}
|
||||
|
||||
private normalizeRelayNodes(inputs: RelayNodeInput[]): PersistedRelayNode[] {
|
||||
if (!Array.isArray(inputs) || inputs.length > 16) throw new AdminInputError("INVALID_RELAY_NODES", "At most 16 relay nodes may be configured");
|
||||
const current = new Map(this.database.listRelayNodes().map((node) => [node.id, node]));
|
||||
const seen = new Set<string>();
|
||||
const now = new Date().toISOString();
|
||||
return inputs.map((input) => {
|
||||
const name = typeof input.name === "string" ? input.name.trim() : "";
|
||||
const targetText = typeof input.target === "string" ? input.target.trim() : "";
|
||||
if (!name || name.length > 80) throw new AdminInputError("INVALID_RELAY_NAME", "Relay name must contain 1 to 80 characters");
|
||||
if (!targetText || targetText.length > 300) throw new AdminInputError("INVALID_RELAY_TARGET", "Relay target is invalid");
|
||||
let target: TeamSpeakTarget;
|
||||
try { target = parseTeamSpeakTarget(targetText, DEFAULT_ACCELERATION_RELAY_PORT); }
|
||||
catch { throw new AdminInputError("INVALID_RELAY_TARGET", "Relay target is invalid"); }
|
||||
const id = typeof input.id === "string" && /^relay-[a-z0-9-]{1,100}$/i.test(input.id)
|
||||
? input.id
|
||||
: `relay-${randomBytes(8).toString("hex")}`;
|
||||
if (seen.has(id)) throw new AdminInputError("INVALID_RELAY_ID", "Relay id must be unique");
|
||||
seen.add(id);
|
||||
const previous = current.get(id);
|
||||
const tokenAction = input.tokenAction ?? (input.token === undefined ? "keep" : "replace");
|
||||
let tokenEncrypted = previous?.tokenEncrypted ?? null;
|
||||
if (tokenAction === "remove") tokenEncrypted = null;
|
||||
if (tokenAction === "replace") {
|
||||
const token = typeof input.token === "string" ? input.token.trim() : "";
|
||||
tokenEncrypted = token ? encryptSecret(token, this.masterSecret) : null;
|
||||
}
|
||||
if (input.enabled === true && (!tokenEncrypted || !this.canDecryptToken(tokenEncrypted))) {
|
||||
throw new AdminInputError("INVALID_RELAY_TOKEN", "A relay token of at least 16 characters is required when the relay is enabled");
|
||||
}
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
enabled: input.enabled === true,
|
||||
host: target.host,
|
||||
port: target.port,
|
||||
tokenEncrypted,
|
||||
createdAt: previous?.createdAt ?? now,
|
||||
updatedAt: now,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private canDecryptToken(encrypted: string): boolean {
|
||||
try {
|
||||
return decryptSecret(encrypted, this.masterSecret).length >= 16;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private getRelayNodeViews(): Array<{ id: string; name: string; enabled: boolean; target: string; hasToken: boolean }> {
|
||||
return this.database.listRelayNodes().map((node) => ({
|
||||
id: node.id,
|
||||
name: node.name,
|
||||
enabled: node.enabled,
|
||||
target: formatRelayTarget(node.host, node.port),
|
||||
hasToken: Boolean(node.tokenEncrypted),
|
||||
}));
|
||||
}
|
||||
|
||||
private legacyRelayNodesFromSettings(settings: SettingsUpdate): PersistedRelayNode[] {
|
||||
if (!settings.relayConfigured || !settings.relayHost || !settings.relayTokenEncrypted) return [];
|
||||
const previous = this.database.listRelayNodes()[0];
|
||||
const now = new Date().toISOString();
|
||||
return [{
|
||||
id: previous?.id ?? "relay-default",
|
||||
name: settings.relayName || "中继加速",
|
||||
enabled: settings.relayEnabled,
|
||||
host: settings.relayHost,
|
||||
port: settings.relayPort || DEFAULT_ACCELERATION_RELAY_PORT,
|
||||
tokenEncrypted: settings.relayTokenEncrypted,
|
||||
createdAt: previous?.createdAt ?? now,
|
||||
updatedAt: now,
|
||||
}];
|
||||
}
|
||||
|
||||
private toInviteView(record: ManagedInviteRecord): ManagedInviteView {
|
||||
const now = Date.now();
|
||||
const expired = Date.parse(record.expiresAt) <= now;
|
||||
const exhausted = record.maxUses > 0 && record.useCount >= record.maxUses;
|
||||
return {
|
||||
id: record.id,
|
||||
target: formatTeamSpeakTarget({ host: record.targetHost, port: record.targetPort }),
|
||||
target: record.targetText ?? formatTeamSpeakTarget({ host: record.targetHost, port: record.targetPort }),
|
||||
channel: record.channel,
|
||||
expiresAt: record.expiresAt,
|
||||
maxUses: record.maxUses,
|
||||
@@ -324,13 +560,27 @@ export class AdminService {
|
||||
return {
|
||||
siteName: settings.siteName,
|
||||
welcomeText: settings.welcomeText,
|
||||
welcomeTextEn: settings.welcomeTextEn,
|
||||
welcomeTextDe: settings.welcomeTextDe,
|
||||
welcomeTextRu: settings.welcomeTextRu,
|
||||
welcomeTextJa: settings.welcomeTextJa,
|
||||
accessMode: settings.accessMode,
|
||||
tsHost: settings.tsHost,
|
||||
tsPort: settings.tsPort,
|
||||
tsTarget: settings.tsTarget,
|
||||
tsPasswordEncrypted: settings.tsPasswordEncrypted,
|
||||
webRtcEnabled: settings.webRtcEnabled,
|
||||
webRtcPublicHost: settings.webRtcPublicHost,
|
||||
webRtcIpv6Enabled: settings.webRtcIpv6Enabled,
|
||||
webRtcStunServer: settings.webRtcStunServer,
|
||||
webRtcUdpStart: settings.webRtcUdpStart,
|
||||
webRtcUdpEnd: settings.webRtcUdpEnd,
|
||||
relayConfigured: settings.relayConfigured,
|
||||
relayEnabled: settings.relayEnabled,
|
||||
relayName: settings.relayName,
|
||||
relayHost: settings.relayHost,
|
||||
relayPort: settings.relayPort,
|
||||
relayTokenEncrypted: settings.relayTokenEncrypted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -342,13 +592,27 @@ export class AdminService {
|
||||
this.database.updateSettings({
|
||||
siteName: current.siteName,
|
||||
welcomeText: current.welcomeText,
|
||||
welcomeTextEn: current.welcomeTextEn,
|
||||
welcomeTextDe: current.welcomeTextDe,
|
||||
welcomeTextRu: current.welcomeTextRu,
|
||||
welcomeTextJa: current.welcomeTextJa,
|
||||
accessMode: current.accessMode,
|
||||
tsHost: legacy.tsHost,
|
||||
tsPort: legacy.tsPort,
|
||||
tsTarget: legacy.tsTarget ?? null,
|
||||
tsPasswordEncrypted: legacy.tsServerPassword ? encryptSecret(legacy.tsServerPassword, this.masterSecret) : null,
|
||||
webRtcEnabled: current.webRtcEnabled,
|
||||
webRtcPublicHost: current.webRtcPublicHost,
|
||||
webRtcIpv6Enabled: current.webRtcIpv6Enabled,
|
||||
webRtcStunServer: current.webRtcStunServer,
|
||||
webRtcUdpStart: current.webRtcUdpStart,
|
||||
webRtcUdpEnd: current.webRtcUdpEnd,
|
||||
relayConfigured: current.relayConfigured,
|
||||
relayEnabled: current.relayEnabled,
|
||||
relayName: current.relayName,
|
||||
relayHost: current.relayHost,
|
||||
relayPort: current.relayPort,
|
||||
relayTokenEncrypted: current.relayTokenEncrypted,
|
||||
}, "LEGACY_CONFIG_IMPORTED");
|
||||
this.database.setMeta("legacy_config_imported", "1");
|
||||
this.database.setMeta("legacy_import_notice_pending", "1");
|
||||
@@ -362,6 +626,14 @@ function hashInviteToken(token: string): string {
|
||||
return createHash("sha256").update(token).digest("hex");
|
||||
}
|
||||
|
||||
function settingsTarget(settings: { tsHost: string; tsPort: number; tsTarget?: string | null }): string {
|
||||
return settings.tsTarget ?? formatTeamSpeakTarget({ host: settings.tsHost, port: settings.tsPort });
|
||||
}
|
||||
|
||||
function formatRelayTarget(host: string, port: number): string {
|
||||
return `${host.includes(":") ? `[${host}]` : host}#${port}`;
|
||||
}
|
||||
|
||||
export class AdminInputError extends Error {
|
||||
constructor(readonly code: string, message: string) {
|
||||
super(message);
|
||||
|
||||
@@ -0,0 +1,451 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { SkinRegistry, SkinRegistryError } from "./skin-registry.js";
|
||||
|
||||
const manifest = {
|
||||
schemaVersion: 1,
|
||||
id: "sample-skin",
|
||||
name: "Sample skin",
|
||||
version: "1.0.0",
|
||||
author: "WebSpeak test",
|
||||
license: "MIT",
|
||||
minAppVersion: "0.2.4",
|
||||
entry: "skin.css",
|
||||
content: "content.json",
|
||||
preview: "assets/preview.png",
|
||||
};
|
||||
|
||||
test("skin registry validates, lists, replaces, serves, and removes packages", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-registry-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
|
||||
assert.equal(await registry.readArchive("sample-skin"), null);
|
||||
const firstArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifest))],
|
||||
["skin.css", Buffer.from('[data-ws-part="voice.member"] { background: url(assets/background.png); }')],
|
||||
["content.json", Buffer.from(JSON.stringify({ defaultLocale: "en", locales: { en: { home: { title: "Hello" } } } }))],
|
||||
["assets/background.png", Buffer.from([1, 2, 3, 4])],
|
||||
["assets/preview.png", Buffer.from([5, 6, 7, 8])],
|
||||
]);
|
||||
const first = await registry.save(firstArchive, "sample-skin");
|
||||
assert.equal(first.id, "sample-skin");
|
||||
assert.equal(first.previewUrl, "/api/skins/sample-skin/preview");
|
||||
assert.equal((await registry.list()).length, 1);
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), firstArchive);
|
||||
assert.deepEqual((await registry.readPreview("sample-skin"))?.bytes, Buffer.from([5, 6, 7, 8]));
|
||||
await registry.setEnabled("sample-skin", false);
|
||||
assert.equal(await registry.readArchive("sample-skin"), null);
|
||||
assert.equal(await registry.readPreview("sample-skin"), null);
|
||||
await registry.setEnabled("sample-skin", true);
|
||||
|
||||
const replacement = { ...manifest, version: "2.0.0", content: undefined, preview: undefined };
|
||||
const secondArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(replacement))],
|
||||
["skin.css", Buffer.from('[data-ws-part="voice.member"] { border-radius: 0; }')],
|
||||
]);
|
||||
const second = await registry.save(secondArchive, "sample-skin");
|
||||
assert.equal(second.version, "2.0.0");
|
||||
assert.equal(second.installedAt, first.installedAt);
|
||||
assert.equal(await registry.readPreview("sample-skin"), null);
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), secondArchive);
|
||||
|
||||
assert.equal(await registry.remove("sample-skin"), true);
|
||||
assert.deepEqual(await registry.list(), []);
|
||||
assert.equal(await registry.readArchive("sample-skin"), null);
|
||||
assert.equal(await registry.remove("sample-skin"), false);
|
||||
});
|
||||
|
||||
test("custom skins can be enabled, disabled, and selected as the instance default", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-settings-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const archive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifest, content: undefined, preview: undefined }))],
|
||||
["skin.css", Buffer.from("[data-ws-part=\"demo.voice-card\"] { color: teal; }")],
|
||||
]);
|
||||
|
||||
const skin = await registry.save(archive, "sample-skin");
|
||||
assert.equal(skin.enabled, true);
|
||||
assert.equal(await registry.getDefaultSkinId(), "builtin.light");
|
||||
await registry.setDefaultSkin("sample-skin");
|
||||
assert.equal(await registry.getDefaultSkinId(), "sample-skin");
|
||||
|
||||
const disabled = await registry.setEnabled("sample-skin", false);
|
||||
assert.equal(disabled.enabled, false);
|
||||
assert.equal(await registry.readArchive("sample-skin"), null);
|
||||
assert.equal(await registry.getDefaultSkinId(), "builtin.light");
|
||||
await assert.rejects(registry.setDefaultSkin("sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_DEFAULT_INVALID");
|
||||
|
||||
await registry.setEnabled("sample-skin", true);
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
|
||||
await registry.setDefaultSkin("sample-skin");
|
||||
assert.equal(await registry.remove("sample-skin"), true);
|
||||
assert.equal(await registry.getDefaultSkinId(), "builtin.light");
|
||||
});
|
||||
|
||||
test("the bundled KAAK skin can be selected as the instance default without a custom installation", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-kaak-default-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
|
||||
await registry.setDefaultSkin("community.kaak-voice");
|
||||
|
||||
assert.equal(await registry.getDefaultSkinId(), "community.kaak-voice");
|
||||
assert.deepEqual(await registry.list(), []);
|
||||
});
|
||||
|
||||
test("server accepts validated declarative v2 layouts and rejects permissions or unregistered components", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-v2-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const manifestV2 = {
|
||||
...manifest,
|
||||
schemaVersion: 2,
|
||||
packageType: "layout-skin",
|
||||
permissions: [],
|
||||
layout: "layout.json",
|
||||
content: undefined,
|
||||
preview: undefined,
|
||||
};
|
||||
const layout = {
|
||||
schemaVersion: 1,
|
||||
pages: { home: { desktop: { "home.header": { x: 24, visible: true, background: "#123456" } } } },
|
||||
};
|
||||
const archive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV2))],
|
||||
["skin.css", Buffer.from('[data-ws-part="home.header"] { color: teal; }')],
|
||||
["layout.json", Buffer.from(JSON.stringify(layout))],
|
||||
]);
|
||||
const saved = await registry.save(archive, "sample-skin");
|
||||
assert.equal(saved.id, "sample-skin");
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
|
||||
|
||||
const permissionsArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV2, permissions: ["network.fetch"] }))],
|
||||
["skin.css", Buffer.from("")],
|
||||
["layout.json", Buffer.from(JSON.stringify(layout))],
|
||||
]);
|
||||
await assert.rejects(registry.save(permissionsArchive, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_PERMISSION_INVALID");
|
||||
const unknownManifestField = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV2, capabilities: ["network.fetch"] }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="home.header"] { color: teal; }')],
|
||||
["layout.json", Buffer.from(JSON.stringify({ schemaVersion: 1, pages: {} }))],
|
||||
]);
|
||||
await assert.rejects(registry.save(unknownManifestField, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_MANIFEST_INVALID");
|
||||
|
||||
const unknownComponentArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV2))],
|
||||
["skin.css", Buffer.from('[data-ws-part="voice.member"] { color: teal; }')],
|
||||
["layout.json", Buffer.from(JSON.stringify({ schemaVersion: 1, pages: { home: { desktop: { "home.unknown": { x: 1 } } } } }))],
|
||||
]);
|
||||
await assert.rejects(registry.save(unknownComponentArchive, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_LAYOUT_INVALID");
|
||||
});
|
||||
|
||||
test("server accepts v3 declarative components and rejects unapproved capability declarations", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-v3-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const manifestV3 = {
|
||||
...manifest,
|
||||
schemaVersion: 3,
|
||||
packageType: "open-skin",
|
||||
content: undefined,
|
||||
preview: undefined,
|
||||
components: "components.json",
|
||||
};
|
||||
const components = {
|
||||
schemaVersion: 1,
|
||||
components: [{
|
||||
id: "channels",
|
||||
name: "Channels",
|
||||
page: "voice",
|
||||
accessibleName: "TeamSpeak channels",
|
||||
permissions: ["session.channels.read", "session.channel.join"],
|
||||
actions: { join: { type: "voice.joinChannel", args: { channelId: "{{channel.id}}" } } },
|
||||
root: { tag: "nav", repeat: { path: "session.channels", as: "channel" }, children: [{ tag: "button", events: { dblclick: "join" }, children: [{ text: "{{channel.name}}" }] }] },
|
||||
}],
|
||||
};
|
||||
const archive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV3))],
|
||||
["skin.css", Buffer.from('[data-ws-part="voice.channel-group"] { display: none; }')],
|
||||
["components.json", Buffer.from(JSON.stringify(components))],
|
||||
]);
|
||||
const saved = await registry.save(archive, "sample-skin");
|
||||
assert.equal(saved.id, "sample-skin");
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
|
||||
|
||||
const unapproved = structuredClone(components) as typeof components;
|
||||
unapproved.components[0].permissions = ["network.fetch"];
|
||||
const unsafeArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV3))],
|
||||
["skin.css", Buffer.from("[data-ws-part=app] { color: red; }")],
|
||||
["components.json", Buffer.from(JSON.stringify(unapproved))],
|
||||
]);
|
||||
await assert.rejects(registry.save(unsafeArchive, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_PLUGIN_INVALID");
|
||||
});
|
||||
|
||||
test("server accepts a v3 open visual skin without a components document", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-v3-visual-only-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const archive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifest, schemaVersion: 3, packageType: "open-skin", content: undefined, preview: undefined }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
|
||||
]);
|
||||
const saved = await registry.save(archive, "sample-skin");
|
||||
assert.equal(saved.id, "sample-skin");
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
|
||||
});
|
||||
|
||||
test("server applies the browser CSS scope and package-only resource policy to every stylesheet", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-css-policy-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const unsafeLegacySelector = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifest, content: undefined, preview: undefined }))],
|
||||
["skin.css", Buffer.from(".private-class { color: teal; }")],
|
||||
]);
|
||||
await assert.rejects(registry.save(unsafeLegacySelector, "sample-skin"), (error: unknown) =>
|
||||
error instanceof SkinRegistryError && error.code === "SKIN_CSS_SELECTOR");
|
||||
|
||||
const remoteSkinCss = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifest, content: undefined, preview: undefined }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { background-image: url("https://example.invalid/track.png"); }')],
|
||||
]);
|
||||
await assert.rejects(registry.save(remoteSkinCss, "sample-skin"), (error: unknown) =>
|
||||
error instanceof SkinRegistryError && error.code === "SKIN_EXTERNAL_RESOURCE");
|
||||
|
||||
const manifestV4 = {
|
||||
...manifest,
|
||||
schemaVersion: 4,
|
||||
packageType: "open-skin",
|
||||
content: undefined,
|
||||
preview: undefined,
|
||||
plugins: "plugins.json",
|
||||
};
|
||||
const plugins = {
|
||||
schemaVersion: 1,
|
||||
plugins: [{
|
||||
id: "voice-toolbar",
|
||||
name: "Voice toolbar",
|
||||
version: "1.0.0",
|
||||
apiVersion: 1,
|
||||
page: "voice",
|
||||
mode: "widget",
|
||||
entry: "plugins/voice-toolbar/index.js",
|
||||
style: "plugins/voice-toolbar/style.css",
|
||||
assets: [],
|
||||
permissions: [],
|
||||
}],
|
||||
};
|
||||
const remotePluginCss = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV4))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { color: teal; }')],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
["plugins/voice-toolbar/index.js", Buffer.from("export {}; ")],
|
||||
["plugins/voice-toolbar/style.css", Buffer.from('.toolbar { background-image: u\\72l("https://example.invalid/track.png"); }')],
|
||||
]);
|
||||
await assert.rejects(registry.save(remotePluginCss, "sample-skin"), (error: unknown) =>
|
||||
error instanceof SkinRegistryError && error.code === "SKIN_EXTERNAL_RESOURCE");
|
||||
});
|
||||
|
||||
test("server validates v4 plugin manifests and package files without executing author code", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-v4-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const manifestV4 = {
|
||||
...manifest,
|
||||
schemaVersion: 4,
|
||||
packageType: "open-skin",
|
||||
content: undefined,
|
||||
preview: undefined,
|
||||
plugins: "plugins.json",
|
||||
};
|
||||
const plugins = {
|
||||
schemaVersion: 1,
|
||||
plugins: [{
|
||||
id: "voice-toolbar",
|
||||
name: "Voice toolbar",
|
||||
version: "1.0.0",
|
||||
apiVersion: 1,
|
||||
page: "voice",
|
||||
mode: "widget",
|
||||
entry: "plugins/voice-toolbar/index.js",
|
||||
style: "plugins/voice-toolbar/style.css",
|
||||
assets: ["plugins/voice-toolbar/assets/icon.png"],
|
||||
permissions: ["session.channels.read"],
|
||||
}],
|
||||
};
|
||||
const archive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV4))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
["plugins/voice-toolbar/index.js", Buffer.from("export const render = () => document.createElement('button');")],
|
||||
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
|
||||
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
|
||||
]);
|
||||
const saved = await registry.save(archive, "sample-skin");
|
||||
assert.equal(saved.id, "sample-skin");
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
|
||||
|
||||
const layout = {
|
||||
schemaVersion: 1,
|
||||
pages: { voice: { desktop: { "skin.voice.runtime_plugin_root_voice-toolbar": { order: 2, visible: true } } } },
|
||||
};
|
||||
const archiveWithLayout = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV4, layout: "layout.json" }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
["plugins/voice-toolbar/index.js", Buffer.from("export const render = () => document.createElement('button');")],
|
||||
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
|
||||
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
|
||||
["layout.json", Buffer.from(JSON.stringify(layout))],
|
||||
]);
|
||||
const layoutSaved = await registry.save(archiveWithLayout, "sample-skin");
|
||||
assert.equal(layoutSaved.id, "sample-skin");
|
||||
assert.deepEqual(await registry.readArchive("sample-skin"), archiveWithLayout);
|
||||
|
||||
const invalidLayoutArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV4, layout: "layout.json" }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
["plugins/voice-toolbar/index.js", Buffer.from("export {}; ")],
|
||||
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
|
||||
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
|
||||
["layout.json", Buffer.from(JSON.stringify({ schemaVersion: 1, pages: { voice: { desktop: { "voice.not-registered": { order: 2 } } } } }))],
|
||||
]);
|
||||
await assert.rejects(registry.save(invalidLayoutArchive, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_LAYOUT_INVALID");
|
||||
|
||||
const wasmPlugins = {
|
||||
schemaVersion: 1,
|
||||
plugins: [{
|
||||
id: "bounded-widget",
|
||||
name: "Bounded widget",
|
||||
version: "1.0.0",
|
||||
apiVersion: 1,
|
||||
runtime: "wasm",
|
||||
page: "voice",
|
||||
mode: "widget",
|
||||
entry: "plugins/bounded-widget/index.wasm",
|
||||
assets: [],
|
||||
permissions: [],
|
||||
}],
|
||||
};
|
||||
const wasmManifest = { ...manifestV4, id: "wasm-skin" };
|
||||
const wasmArchive = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(wasmManifest))],
|
||||
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
|
||||
["plugins.json", Buffer.from(JSON.stringify(wasmPlugins))],
|
||||
["plugins/bounded-widget/index.wasm", Buffer.from([0, 97, 115, 109, 1, 0, 0, 0])],
|
||||
]);
|
||||
const wasmSaved = await registry.save(wasmArchive, "wasm-skin");
|
||||
assert.equal(wasmSaved.id, "wasm-skin");
|
||||
assert.deepEqual(await registry.readArchive("wasm-skin"), wasmArchive);
|
||||
|
||||
const missingEntry = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV4))],
|
||||
["skin.css", Buffer.from("[data-ws-part=app] { color: teal; }")],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
]);
|
||||
await assert.rejects(registry.save(missingEntry, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_RUNTIME_PLUGIN_FILE_MISSING");
|
||||
|
||||
const unlistedScript = createZip([
|
||||
["manifest.json", Buffer.from(JSON.stringify(manifestV4))],
|
||||
["skin.css", Buffer.from("[data-ws-part=app] { color: teal; }")],
|
||||
["plugins.json", Buffer.from(JSON.stringify(plugins))],
|
||||
["plugins/voice-toolbar/index.js", Buffer.from("export {};")],
|
||||
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
|
||||
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
|
||||
["plugins/other/rogue.js", Buffer.from("export {};")],
|
||||
]);
|
||||
await assert.rejects(registry.save(unlistedScript, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_FILE_UNSUPPORTED");
|
||||
});
|
||||
|
||||
test("skin registry rejects path traversal and mismatched local ZIP headers", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-invalid-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
const goodFiles: Array<[string, Buffer]> = [
|
||||
["manifest.json", Buffer.from(JSON.stringify({ ...manifest, content: undefined, preview: undefined }))],
|
||||
["skin.css", Buffer.from('[data-ws-part="voice.member"] { color: teal; }')],
|
||||
];
|
||||
|
||||
await assert.rejects(registry.save(createZip([["../escape.png", Buffer.from([1])], ...goodFiles]), "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_PATH_INVALID");
|
||||
const mismatched = createZip(goodFiles);
|
||||
mismatched[30] ^= 1;
|
||||
await assert.rejects(registry.save(mismatched, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_ZIP_INVALID");
|
||||
|
||||
await writeFile(path.join(directory, "orphan.wskin"), createZip(goodFiles));
|
||||
assert.equal(await registry.readArchive("orphan"), null);
|
||||
assert.deepEqual(await registry.list(), []);
|
||||
});
|
||||
|
||||
test("the four bundled skins cannot be replaced or removed through the registry", async (context) => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "webspeak-skin-builtins-"));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const registry = new SkinRegistry(directory);
|
||||
for (const id of ["builtin.light", "builtin.dark", "community.illusia-voice", "community.kaak-voice"]) {
|
||||
await assert.rejects(registry.save(Buffer.alloc(22), id), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_BUILTIN_PROTECTED");
|
||||
await assert.rejects(registry.remove(id), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_BUILTIN_PROTECTED");
|
||||
await assert.rejects(registry.setEnabled(id, false), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_BUILTIN_PROTECTED");
|
||||
}
|
||||
});
|
||||
|
||||
function createZip(files: Array<[string, Buffer]>): Buffer {
|
||||
const localRecords: Buffer[] = [];
|
||||
const centralRecords: Buffer[] = [];
|
||||
let localOffset = 0;
|
||||
for (const [name, bytes] of files) {
|
||||
const filename = Buffer.from(name, "utf8");
|
||||
const checksum = crc32(bytes);
|
||||
const local = Buffer.alloc(30 + filename.length + bytes.length);
|
||||
local.writeUInt32LE(0x04034b50, 0);
|
||||
local.writeUInt16LE(20, 4);
|
||||
local.writeUInt16LE(0, 6);
|
||||
local.writeUInt16LE(0, 8);
|
||||
local.writeUInt32LE(checksum, 14);
|
||||
local.writeUInt32LE(bytes.length, 18);
|
||||
local.writeUInt32LE(bytes.length, 22);
|
||||
local.writeUInt16LE(filename.length, 26);
|
||||
filename.copy(local, 30);
|
||||
bytes.copy(local, 30 + filename.length);
|
||||
localRecords.push(local);
|
||||
|
||||
const central = Buffer.alloc(46 + filename.length);
|
||||
central.writeUInt32LE(0x02014b50, 0);
|
||||
central.writeUInt16LE(0x0314, 4);
|
||||
central.writeUInt16LE(20, 6);
|
||||
central.writeUInt16LE(0, 8);
|
||||
central.writeUInt16LE(0, 10);
|
||||
central.writeUInt32LE(checksum, 16);
|
||||
central.writeUInt32LE(bytes.length, 20);
|
||||
central.writeUInt32LE(bytes.length, 24);
|
||||
central.writeUInt16LE(filename.length, 28);
|
||||
central.writeUInt32LE(0x81a40000, 38);
|
||||
central.writeUInt32LE(localOffset, 42);
|
||||
filename.copy(central, 46);
|
||||
centralRecords.push(central);
|
||||
localOffset += local.length;
|
||||
}
|
||||
const centralDirectory = Buffer.concat(centralRecords);
|
||||
const end = Buffer.alloc(22);
|
||||
end.writeUInt32LE(0x06054b50, 0);
|
||||
end.writeUInt16LE(files.length, 8);
|
||||
end.writeUInt16LE(files.length, 10);
|
||||
end.writeUInt32LE(centralDirectory.length, 12);
|
||||
end.writeUInt32LE(localOffset, 16);
|
||||
return Buffer.concat([...localRecords, centralDirectory, end]);
|
||||
}
|
||||
|
||||
function crc32(bytes: Buffer): number {
|
||||
let crc = 0xffffffff;
|
||||
for (const byte of bytes) {
|
||||
crc ^= byte;
|
||||
for (let bit = 0; bit < 8; bit += 1) crc = crc & 1 ? (crc >>> 1) ^ 0xedb88320 : crc >>> 1;
|
||||
}
|
||||
return (crc ^ 0xffffffff) >>> 0;
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
import type { SkinCatalogEntry as SharedSkinCatalogEntry } from "../shared/skin-catalog.js";
|
||||
import { compileSkinCss, SkinCssValidationError, type SkinCssSchemaVersion } from "../shared/skin-css.js";
|
||||
import { parseSkinLayoutJson } from "../shared/skin-layout.js";
|
||||
import { listSkinPluginAssetPaths, parseSkinPluginJson, type SkinPluginDocument } from "../shared/skin-plugin.js";
|
||||
import {
|
||||
listSkinRuntimePluginFilePaths,
|
||||
parseSkinRuntimePluginJson,
|
||||
SKIN_RUNTIME_PLUGIN_DOCUMENT_LIMIT_BYTES,
|
||||
SKIN_RUNTIME_PLUGIN_SOURCE_LIMIT_BYTES,
|
||||
SKIN_RUNTIME_PLUGIN_STYLE_LIMIT_BYTES,
|
||||
type SkinRuntimePluginDocument,
|
||||
} from "../shared/skin-runtime-plugins.js";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { mkdir, readFile, readdir, rename, stat, unlink, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { inflateRawSync } from "node:zlib";
|
||||
|
||||
const MAX_ARCHIVE_BYTES = 20 * 1024 * 1024;
|
||||
const MAX_EXPANDED_BYTES = 50 * 1024 * 1024;
|
||||
const MAX_FILE_COUNT = 128;
|
||||
const MAX_CSS_BYTES = 512 * 1024;
|
||||
const MAX_CONTENT_BYTES = 256 * 1024;
|
||||
const MAX_IMAGE_BYTES = 16 * 1024 * 1024;
|
||||
const MAX_FONT_BYTES = 4 * 1024 * 1024;
|
||||
const MAX_SKINS = 50;
|
||||
const MAX_TOTAL_ARCHIVES = 200 * 1024 * 1024;
|
||||
export const BUILTIN_SKIN_IDS = ["builtin.light", "builtin.dark", "community.illusia-voice", "community.kaak-voice"] as const;
|
||||
const BUILTIN_SKIN_ID_SET = new Set<string>(BUILTIN_SKIN_IDS);
|
||||
const EOCD_SIGNATURE = 0x06054b50;
|
||||
const CENTRAL_SIGNATURE = 0x02014b50;
|
||||
const LOCAL_SIGNATURE = 0x04034b50;
|
||||
|
||||
export interface SkinCatalogEntry extends SharedSkinCatalogEntry {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface SkinRegistrySettings {
|
||||
defaultSkinId: string;
|
||||
}
|
||||
|
||||
interface SkinArchiveEntry {
|
||||
path: string;
|
||||
compressedSize: number;
|
||||
expandedSize: number;
|
||||
compression: number;
|
||||
crc: number;
|
||||
localOffset: number;
|
||||
flags: number;
|
||||
isDirectory: boolean;
|
||||
unixFileType: number;
|
||||
}
|
||||
|
||||
type ParsedSkinManifest = Omit<SkinCatalogEntry, "installedAt" | "previewUrl" | "previewMimeType" | "enabled"> & {
|
||||
schemaVersion: 1 | 2 | 3 | 4;
|
||||
packageType?: "layout-skin" | "open-skin";
|
||||
entry: string;
|
||||
layout?: string;
|
||||
content?: string;
|
||||
components?: string;
|
||||
plugins?: string;
|
||||
preview?: string;
|
||||
};
|
||||
|
||||
export class SkinRegistryError extends Error {
|
||||
constructor(message: string, readonly code: string) {
|
||||
super(message);
|
||||
this.name = "SkinRegistryError";
|
||||
}
|
||||
}
|
||||
|
||||
export function isBuiltinSkinId(id: string): boolean {
|
||||
return BUILTIN_SKIN_ID_SET.has(id);
|
||||
}
|
||||
|
||||
export class SkinRegistry {
|
||||
constructor(private readonly directory: string) {}
|
||||
|
||||
async list(): Promise<SkinCatalogEntry[]> {
|
||||
await mkdir(this.directory, { recursive: true });
|
||||
const names = await readdir(this.directory);
|
||||
const entries: SkinCatalogEntry[] = [];
|
||||
for (const filename of names.filter((item) => item.endsWith(".json"))) {
|
||||
try {
|
||||
const value: unknown = JSON.parse(await readFile(path.join(this.directory, filename), "utf8"));
|
||||
if (!isCatalogEntry(value) || filename !== `${value.id}.json`) continue;
|
||||
const archiveInfo = await stat(path.join(this.directory, `${value.id}.wskin`)).catch(() => null);
|
||||
if (!archiveInfo?.isFile() || archiveInfo.size < 22 || archiveInfo.size > MAX_ARCHIVE_BYTES) continue;
|
||||
entries.push({ ...value, enabled: value.enabled !== false });
|
||||
} catch {
|
||||
// Ignore incomplete or stale metadata. The archive itself remains untouched.
|
||||
}
|
||||
}
|
||||
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
||||
}
|
||||
|
||||
async save(bytes: Buffer, expectedId: string): Promise<SkinCatalogEntry> {
|
||||
if (isBuiltinSkinId(expectedId)) throw new SkinRegistryError("Built-in skins cannot be replaced.", "SKIN_BUILTIN_PROTECTED");
|
||||
if (!isSafeSkinId(expectedId)) throw new SkinRegistryError("Skin ID is invalid.", "SKIN_ID_INVALID");
|
||||
const parsed = validateSkinArchive(bytes, expectedId);
|
||||
await mkdir(this.directory, { recursive: true });
|
||||
const current = await this.list();
|
||||
const replacing = current.some((entry) => entry.id === expectedId);
|
||||
if (!replacing && current.length >= MAX_SKINS) throw new SkinRegistryError("The instance already has the maximum number of skins.", "SKIN_LIMIT");
|
||||
const archivePaths = await Promise.all(current.map(async (entry) => ({ id: entry.id, size: (await stat(path.join(this.directory, `${entry.id}.wskin`)).catch(() => ({ size: 0 }))).size })));
|
||||
const totalBytes = archivePaths.reduce((sum, entry) => sum + (entry.id === expectedId ? 0 : entry.size), bytes.byteLength);
|
||||
if (totalBytes > MAX_TOTAL_ARCHIVES) throw new SkinRegistryError("The total skin storage limit is 200 MiB.", "SKIN_STORAGE_LIMIT");
|
||||
|
||||
const previous = current.find((entry) => entry.id === expectedId);
|
||||
const installedAt = previous?.installedAt ?? Date.now();
|
||||
const catalog: SkinCatalogEntry = {
|
||||
...parsed.manifest,
|
||||
installedAt,
|
||||
enabled: previous?.enabled ?? true,
|
||||
...(parsed.previewMime ? { previewUrl: `/api/skins/${expectedId}/preview`, previewMimeType: parsed.previewMime } : {}),
|
||||
};
|
||||
const nonce = randomBytes(6).toString("hex");
|
||||
const archiveTemp = path.join(this.directory, `.${expectedId}.${nonce}.tmp`);
|
||||
const catalogTemp = path.join(this.directory, `.${expectedId}.${nonce}.json.tmp`);
|
||||
const previewTemp = path.join(this.directory, `.${expectedId}.${nonce}.preview.tmp`);
|
||||
try {
|
||||
await writeFile(archiveTemp, bytes, { flag: "wx", mode: 0o600 });
|
||||
await writeFile(catalogTemp, JSON.stringify(catalog), { flag: "wx", mode: 0o600 });
|
||||
if (parsed.previewBytes) await writeFile(previewTemp, parsed.previewBytes, { flag: "wx", mode: 0o600 });
|
||||
await rename(archiveTemp, path.join(this.directory, `${expectedId}.wskin`));
|
||||
await rename(catalogTemp, path.join(this.directory, `${expectedId}.json`));
|
||||
const previewPath = path.join(this.directory, `${expectedId}.preview`);
|
||||
if (parsed.previewBytes) await rename(previewTemp, previewPath);
|
||||
else await unlink(previewPath).catch(() => undefined);
|
||||
} catch (error) {
|
||||
await Promise.all([archiveTemp, catalogTemp, previewTemp].map((file) => unlink(file).catch(() => undefined)));
|
||||
throw error;
|
||||
}
|
||||
return catalog;
|
||||
}
|
||||
|
||||
async readArchive(id: string): Promise<Buffer | null> {
|
||||
if (!isSafeSkinId(id)) return null;
|
||||
if (!(await this.list()).some((entry) => entry.id === id && entry.enabled)) return null;
|
||||
try { return await readFile(path.join(this.directory, `${id}.wskin`)); }
|
||||
catch { return null; }
|
||||
}
|
||||
|
||||
async readPreview(id: string): Promise<{ bytes: Buffer; mimeType: string } | null> {
|
||||
if (!isSafeSkinId(id)) return null;
|
||||
const catalog = (await this.list()).find((entry) => entry.id === id);
|
||||
if (!catalog?.enabled || !catalog.previewUrl) return null;
|
||||
const mimeType = catalog.previewMimeType || "application/octet-stream";
|
||||
try {
|
||||
const bytes = await readFile(path.join(this.directory, `${id}.preview`));
|
||||
return { bytes, mimeType };
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
async remove(id: string): Promise<boolean> {
|
||||
if (isBuiltinSkinId(id)) throw new SkinRegistryError("Built-in skins cannot be removed.", "SKIN_BUILTIN_PROTECTED");
|
||||
if (!isSafeSkinId(id)) return false;
|
||||
const wasDefault = await this.getDefaultSkinId() === id;
|
||||
const archive = path.join(this.directory, `${id}.wskin`);
|
||||
const catalog = path.join(this.directory, `${id}.json`);
|
||||
const preview = path.join(this.directory, `${id}.preview`);
|
||||
const present = await Promise.all([archive, catalog, preview].map((file) => stat(file).then(() => true).catch(() => false))).then((items) => items.some(Boolean));
|
||||
if (!present) return false;
|
||||
await Promise.all([archive, catalog, preview].map((file) => unlink(file).catch((error: unknown) => {
|
||||
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
|
||||
})));
|
||||
if (wasDefault) await this.setDefaultSkin("builtin.light");
|
||||
return true;
|
||||
}
|
||||
|
||||
async setEnabled(id: string, enabled: boolean): Promise<SkinCatalogEntry> {
|
||||
if (isBuiltinSkinId(id)) throw new SkinRegistryError("Built-in skins cannot be disabled.", "SKIN_BUILTIN_PROTECTED");
|
||||
const entry = (await this.list()).find((item) => item.id === id);
|
||||
if (!entry) throw new SkinRegistryError("The skin was not found.", "SKIN_NOT_FOUND");
|
||||
const wasDefault = await this.getDefaultSkinId() === id;
|
||||
const updated = { ...entry, enabled };
|
||||
await writeAtomicJson(path.join(this.directory, `${id}.json`), updated);
|
||||
if (!enabled && wasDefault) await this.setDefaultSkin("builtin.light");
|
||||
return updated;
|
||||
}
|
||||
|
||||
async getDefaultSkinId(): Promise<string> {
|
||||
try {
|
||||
const value: unknown = JSON.parse(await readFile(path.join(this.directory, "settings.json"), "utf8"));
|
||||
const id = value && typeof value === "object" ? (value as Record<string, unknown>).defaultSkinId : null;
|
||||
if (typeof id !== "string") return "builtin.light";
|
||||
if (isBuiltinSkinId(id)) return id;
|
||||
const entry = (await this.list()).find((skin) => skin.id === id && skin.enabled);
|
||||
return entry ? id : "builtin.light";
|
||||
} catch {
|
||||
return "builtin.light";
|
||||
}
|
||||
}
|
||||
|
||||
async setDefaultSkin(id: string): Promise<SkinRegistrySettings> {
|
||||
if (!isBuiltinSkinId(id)) {
|
||||
const entry = (await this.list()).find((skin) => skin.id === id && skin.enabled);
|
||||
if (!entry) throw new SkinRegistryError("The default skin must be enabled and installed.", "SKIN_DEFAULT_INVALID");
|
||||
}
|
||||
await mkdir(this.directory, { recursive: true });
|
||||
const settings = { defaultSkinId: id };
|
||||
await writeAtomicJson(path.join(this.directory, "settings.json"), settings);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
async function writeAtomicJson(filename: string, value: unknown): Promise<void> {
|
||||
const temporary = `${filename}.${randomBytes(6).toString("hex")}.tmp`;
|
||||
try {
|
||||
await writeFile(temporary, JSON.stringify(value), { flag: "wx", mode: 0o600 });
|
||||
await rename(temporary, filename);
|
||||
} catch (error) {
|
||||
await unlink(temporary).catch(() => undefined);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function validateSkinArchive(bytes: Buffer, expectedId?: string): { manifest: ParsedSkinManifest; previewBytes?: Buffer; previewMime?: string } {
|
||||
const entries = inspectArchive(bytes);
|
||||
const regularEntries = entries.filter((entry) => !entry.isDirectory);
|
||||
const rootPrefix = singleRootPrefix(regularEntries.map((entry) => entry.path));
|
||||
const fileBytes = new Map<string, Buffer>();
|
||||
for (const entry of regularEntries) {
|
||||
const packagePath = rootPrefix ? entry.path.slice(rootPrefix.length) : entry.path;
|
||||
if (!isSafePackagePath(packagePath)) throw new SkinRegistryError("The package contains an unsafe path.", "SKIN_PATH_INVALID");
|
||||
const content = extractEntry(bytes, entry);
|
||||
if (content.byteLength !== entry.expandedSize || crc32(content) !== entry.crc) throw new SkinRegistryError("The package has a damaged file entry.", "SKIN_ZIP_INVALID");
|
||||
if (fileBytes.has(packagePath.toLowerCase())) throw new SkinRegistryError("The package contains duplicate paths.", "SKIN_PATH_DUPLICATE");
|
||||
fileBytes.set(packagePath, content);
|
||||
}
|
||||
const manifestBytes = fileBytes.get("manifest.json");
|
||||
if (!manifestBytes || manifestBytes.byteLength > 32 * 1024) throw new SkinRegistryError("The package needs a small root-level manifest.json.", "SKIN_MANIFEST_MISSING");
|
||||
const manifest = parseManifest(manifestBytes);
|
||||
if (expectedId && manifest.id !== expectedId) throw new SkinRegistryError("The skin ID does not match the upload target.", "SKIN_ID_MISMATCH");
|
||||
const cssBytes = fileBytes.get(manifest.entry);
|
||||
if (!cssBytes || !cssBytes.byteLength || cssBytes.byteLength > MAX_CSS_BYTES) throw new SkinRegistryError("The CSS entry is missing or exceeds 512 KiB.", "SKIN_CSS_SIZE");
|
||||
const cssSource = decodeUtf8(cssBytes, "The CSS entry is not valid UTF-8.");
|
||||
|
||||
let runtimePlugins: SkinRuntimePluginDocument | undefined;
|
||||
if (manifest.plugins) {
|
||||
const pluginsBytes = fileBytes.get(manifest.plugins);
|
||||
if (!pluginsBytes || pluginsBytes.byteLength > SKIN_RUNTIME_PLUGIN_DOCUMENT_LIMIT_BYTES) {
|
||||
throw new SkinRegistryError("plugins.json is missing or exceeds 256 KiB.", "SKIN_RUNTIME_PLUGIN_SIZE");
|
||||
}
|
||||
try { runtimePlugins = parseSkinRuntimePluginJson(decodeUtf8(pluginsBytes, "plugins.json is not valid UTF-8.")); }
|
||||
catch (error) { throw new SkinRegistryError("plugins.json is invalid: " + (error instanceof Error ? error.message : "unknown plugin error"), "SKIN_RUNTIME_PLUGIN_INVALID"); }
|
||||
}
|
||||
const runtimePluginPaths = runtimePlugins ? listSkinRuntimePluginFilePaths(runtimePlugins) : [];
|
||||
const runtimePluginPathSet = new Set(runtimePluginPaths.map((packagePath) => packagePath.toLowerCase()));
|
||||
const manifestPathSet = ["manifest.json", manifest.entry, manifest.layout, manifest.content, manifest.components, manifest.plugins, manifest.preview]
|
||||
.filter((packagePath): packagePath is string => Boolean(packagePath)).map((packagePath) => packagePath.toLowerCase());
|
||||
if (runtimePluginPaths.some((packagePath) => manifestPathSet.includes(packagePath))) {
|
||||
throw new SkinRegistryError("Plugin files cannot reuse skin manifest, CSS, content, component, or preview paths.", "SKIN_RUNTIME_PLUGIN_FILE_DUPLICATE");
|
||||
}
|
||||
for (const pluginPath of runtimePluginPaths) {
|
||||
const data = fileBytes.get(pluginPath);
|
||||
if (!data) throw new SkinRegistryError(`A declared plugin file is missing: ${pluginPath}`, "SKIN_RUNTIME_PLUGIN_FILE_MISSING");
|
||||
const lowerPath = pluginPath.toLowerCase();
|
||||
if (lowerPath.endsWith(".js")) {
|
||||
if (data.byteLength > SKIN_RUNTIME_PLUGIN_SOURCE_LIMIT_BYTES) throw new SkinRegistryError("Plugin entry files must be smaller than 256 KiB.", "SKIN_RUNTIME_PLUGIN_SOURCE_SIZE");
|
||||
decodeUtf8(data, "Plugin entry files must contain valid UTF-8.");
|
||||
} else if (lowerPath.endsWith(".wasm")) {
|
||||
if (data.byteLength > SKIN_RUNTIME_PLUGIN_SOURCE_LIMIT_BYTES) throw new SkinRegistryError("Wasm plugin entry files must be smaller than 256 KiB.", "SKIN_RUNTIME_PLUGIN_SOURCE_SIZE");
|
||||
} else if (lowerPath.endsWith(".css")) {
|
||||
if (data.byteLength > SKIN_RUNTIME_PLUGIN_STYLE_LIMIT_BYTES) throw new SkinRegistryError("Plugin style files must be smaller than 512 KiB.", "SKIN_RUNTIME_PLUGIN_STYLE_SIZE");
|
||||
decodeUtf8(data, "Plugin style files must contain valid UTF-8.");
|
||||
} else {
|
||||
const mimeType = imageMime(pluginPath) ?? (lowerPath.endsWith(".woff2") ? "font/woff2" : null);
|
||||
if (!mimeType) throw new SkinRegistryError(`Unsupported plugin asset: ${pluginPath}`, "SKIN_RUNTIME_PLUGIN_ASSET_INVALID");
|
||||
if (mimeType.startsWith("image/") && data.byteLength > MAX_IMAGE_BYTES) throw new SkinRegistryError("Plugin images must be smaller than 16 MiB.", "SKIN_IMAGE_SIZE");
|
||||
if (mimeType.startsWith("font/") && data.byteLength > MAX_FONT_BYTES) throw new SkinRegistryError("Plugin fonts must be smaller than 4 MiB.", "SKIN_FONT_SIZE");
|
||||
}
|
||||
}
|
||||
|
||||
let previewBytes: Buffer | undefined;
|
||||
let previewMime: string | undefined;
|
||||
for (const [packagePath, data] of fileBytes) {
|
||||
if (["manifest.json", manifest.entry, manifest.layout, manifest.content, manifest.components, manifest.plugins, manifest.preview].includes(packagePath)
|
||||
|| runtimePluginPathSet.has(packagePath.toLowerCase())) continue;
|
||||
const mimeType = imageMime(packagePath) ?? (packagePath.toLowerCase().endsWith(".woff2") ? "font/woff2" : null);
|
||||
if (!mimeType) throw new SkinRegistryError(`Unsupported package file: ${packagePath}`, "SKIN_FILE_UNSUPPORTED");
|
||||
if (mimeType.startsWith("image/") && data.byteLength > MAX_IMAGE_BYTES) throw new SkinRegistryError("Each image must be smaller than 16 MiB.", "SKIN_IMAGE_SIZE");
|
||||
if (mimeType.startsWith("font/") && data.byteLength > MAX_FONT_BYTES) throw new SkinRegistryError("Fonts must be smaller than 4 MiB.", "SKIN_FONT_SIZE");
|
||||
}
|
||||
const cssAssets = new Set([...fileBytes.keys()].filter((packagePath) =>
|
||||
imageMime(packagePath) !== null || packagePath.toLowerCase().endsWith(".woff2")));
|
||||
validateSkinCss(cssSource, manifest.id, cssAssets, manifest.schemaVersion);
|
||||
for (const plugin of runtimePlugins?.plugins ?? []) {
|
||||
if (!plugin.style) continue;
|
||||
const styleBytes = fileBytes.get(plugin.style);
|
||||
if (!styleBytes) throw new SkinRegistryError(`A declared plugin style is missing: ${plugin.style}`, "SKIN_RUNTIME_PLUGIN_FILE_MISSING");
|
||||
const pluginCssAssets = new Set([...cssAssets].filter((packagePath) =>
|
||||
packagePath.startsWith("assets/") || packagePath.startsWith(`plugins/${plugin.id}/assets/`)));
|
||||
validateSkinCss(
|
||||
decodeUtf8(styleBytes, "Plugin style files must contain valid UTF-8."),
|
||||
manifest.id,
|
||||
pluginCssAssets,
|
||||
manifest.schemaVersion,
|
||||
plugin.id,
|
||||
);
|
||||
}
|
||||
if (manifest.content) {
|
||||
const content = fileBytes.get(manifest.content);
|
||||
if (!content || content.byteLength > MAX_CONTENT_BYTES) throw new SkinRegistryError("content.json is missing or exceeds 256 KiB.", "SKIN_CONTENT_SIZE");
|
||||
decodeUtf8(content, "content.json is not valid UTF-8.");
|
||||
try { JSON.parse(content.toString("utf8")); }
|
||||
catch { throw new SkinRegistryError("content.json is not valid JSON.", "SKIN_CONTENT_INVALID"); }
|
||||
}
|
||||
if (manifest.layout) {
|
||||
const layout = fileBytes.get(manifest.layout);
|
||||
if (!layout || layout.byteLength > 128 * 1024) throw new SkinRegistryError("layout.json is missing or exceeds 128 KiB.", "SKIN_LAYOUT_SIZE");
|
||||
try { parseSkinLayoutJson(decodeUtf8(layout, "layout.json is not valid UTF-8.")); }
|
||||
catch (error) { throw new SkinRegistryError("layout.json is invalid: " + (error instanceof Error ? error.message : "unknown layout error"), "SKIN_LAYOUT_INVALID"); }
|
||||
}
|
||||
if (manifest.components) {
|
||||
const components = fileBytes.get(manifest.components);
|
||||
if (!components || components.byteLength > MAX_CONTENT_BYTES) throw new SkinRegistryError("components.json is missing or exceeds 256 KiB.", "SKIN_PLUGIN_SIZE");
|
||||
let document: SkinPluginDocument;
|
||||
try { document = parseSkinPluginJson(decodeUtf8(components, "components.json is not valid UTF-8.")); }
|
||||
catch (error) { throw new SkinRegistryError("components.json is invalid: " + (error instanceof Error ? error.message : "unknown plugin error"), "SKIN_PLUGIN_INVALID"); }
|
||||
for (const assetPath of listSkinPluginAssetPaths(document)) {
|
||||
if (!fileBytes.has(assetPath) || !imageMime(assetPath)) throw new SkinRegistryError(`Component image asset is missing or unsupported: ${assetPath}`, "SKIN_PLUGIN_ASSET_INVALID");
|
||||
}
|
||||
}
|
||||
if (manifest.preview) {
|
||||
previewBytes = fileBytes.get(manifest.preview);
|
||||
previewMime = imageMime(manifest.preview) ?? undefined;
|
||||
if (!previewBytes || !previewMime || previewBytes.byteLength > MAX_IMAGE_BYTES) throw new SkinRegistryError("The preview must be a supported image inside the package.", "SKIN_PREVIEW_INVALID");
|
||||
}
|
||||
return { manifest, ...(previewBytes ? { previewBytes, previewMime } : {}) };
|
||||
}
|
||||
|
||||
function validateSkinCss(
|
||||
source: string,
|
||||
skinId: string,
|
||||
assets: Set<string>,
|
||||
schemaVersion: SkinCssSchemaVersion,
|
||||
pluginId?: string,
|
||||
): void {
|
||||
try { compileSkinCss(source, skinId, assets, schemaVersion, pluginId); }
|
||||
catch (error) {
|
||||
const cssError = error instanceof SkinCssValidationError
|
||||
? error
|
||||
: new SkinCssValidationError(error instanceof Error ? error.message : "The CSS file is invalid.", "SKIN_CSS_INVALID");
|
||||
throw new SkinRegistryError(cssError.message, cssError.code);
|
||||
}
|
||||
}
|
||||
|
||||
function inspectArchive(bytes: Buffer): SkinArchiveEntry[] {
|
||||
if (bytes.byteLength < 22 || bytes.byteLength > MAX_ARCHIVE_BYTES) throw new SkinRegistryError("A skin package must be smaller than 20 MiB.", "SKIN_ARCHIVE_SIZE");
|
||||
const minOffset = Math.max(0, bytes.byteLength - 22 - 0xffff);
|
||||
let endOffset = -1;
|
||||
for (let offset = bytes.byteLength - 22; offset >= minOffset; offset -= 1) {
|
||||
if (bytes.readUInt32LE(offset) === EOCD_SIGNATURE) { endOffset = offset; break; }
|
||||
}
|
||||
if (endOffset < 0) throw new SkinRegistryError("The upload is not a valid ZIP package.", "SKIN_ZIP_INVALID");
|
||||
const disk = bytes.readUInt16LE(endOffset + 4);
|
||||
const centralDisk = bytes.readUInt16LE(endOffset + 6);
|
||||
const entriesOnDisk = bytes.readUInt16LE(endOffset + 8);
|
||||
const entryCount = bytes.readUInt16LE(endOffset + 10);
|
||||
const centralSize = bytes.readUInt32LE(endOffset + 12);
|
||||
const centralOffset = bytes.readUInt32LE(endOffset + 16);
|
||||
const commentLength = bytes.readUInt16LE(endOffset + 20);
|
||||
if (disk !== 0 || centralDisk !== 0 || entriesOnDisk !== entryCount || entryCount === 0xffff || centralSize === 0xffffffff || centralOffset === 0xffffffff || endOffset + 22 + commentLength !== bytes.byteLength) {
|
||||
throw new SkinRegistryError("Multi-disk and ZIP64 packages are not supported.", "SKIN_ZIP_FORMAT");
|
||||
}
|
||||
if (!entryCount || entryCount > MAX_FILE_COUNT || centralOffset + centralSize !== endOffset) throw new SkinRegistryError("The ZIP directory is invalid or contains too many files.", "SKIN_FILE_COUNT");
|
||||
|
||||
const decoder = new TextDecoder("utf-8", { fatal: true });
|
||||
const entries: SkinArchiveEntry[] = [];
|
||||
const seenPaths = new Set<string>();
|
||||
let offset = centralOffset;
|
||||
let totalExpanded = 0;
|
||||
for (let index = 0; index < entryCount; index += 1) {
|
||||
if (offset + 46 > endOffset || bytes.readUInt32LE(offset) !== CENTRAL_SIGNATURE) throw new SkinRegistryError("The ZIP directory entry is invalid.", "SKIN_ZIP_INVALID");
|
||||
const madeBy = bytes.readUInt16LE(offset + 4);
|
||||
const flags = bytes.readUInt16LE(offset + 8);
|
||||
const compression = bytes.readUInt16LE(offset + 10);
|
||||
const crc = bytes.readUInt32LE(offset + 16);
|
||||
const compressedSize = bytes.readUInt32LE(offset + 20);
|
||||
const expandedSize = bytes.readUInt32LE(offset + 24);
|
||||
const nameLength = bytes.readUInt16LE(offset + 28);
|
||||
const extraLength = bytes.readUInt16LE(offset + 30);
|
||||
const fileCommentLength = bytes.readUInt16LE(offset + 32);
|
||||
const diskStart = bytes.readUInt16LE(offset + 34);
|
||||
const externalAttributes = bytes.readUInt32LE(offset + 38);
|
||||
const localOffset = bytes.readUInt32LE(offset + 42);
|
||||
const recordEnd = offset + 46 + nameLength + extraLength + fileCommentLength;
|
||||
if (recordEnd > endOffset || diskStart !== 0 || flags & ~0x0800 || (compression !== 0 && compression !== 8) || compressedSize === 0xffffffff || expandedSize === 0xffffffff || localOffset === 0xffffffff) {
|
||||
throw new SkinRegistryError("Encrypted, multi-disk, and unsupported ZIP entries are not allowed.", "SKIN_ZIP_FORMAT");
|
||||
}
|
||||
let entryPath: string;
|
||||
try { entryPath = decoder.decode(bytes.subarray(offset + 46, offset + 46 + nameLength)); }
|
||||
catch { throw new SkinRegistryError("ZIP filenames must be valid UTF-8.", "SKIN_PATH_INVALID"); }
|
||||
if (!(flags & 0x800) && /[^\x00-\x7f]/.test(entryPath)) throw new SkinRegistryError("Non-ASCII ZIP filenames must be encoded as UTF-8.", "SKIN_PATH_INVALID");
|
||||
if (!isSafePackagePath(entryPath, entryPath.endsWith("/"))) throw new SkinRegistryError("The package contains an unsafe path.", "SKIN_PATH_INVALID");
|
||||
const normalizedPath = entryPath.toLowerCase();
|
||||
if (seenPaths.has(normalizedPath)) throw new SkinRegistryError("The package contains duplicate or case-conflicting paths.", "SKIN_PATH_DUPLICATE");
|
||||
seenPaths.add(normalizedPath);
|
||||
const unixFileType = madeBy >> 8 === 3 ? (externalAttributes >>> 16) & 0xf000 : 0;
|
||||
if (unixFileType !== 0 && unixFileType !== 0x8000 && unixFileType !== 0x4000) throw new SkinRegistryError("Only regular files and directories are allowed in a skin package.", "SKIN_FILE_TYPE");
|
||||
const isDirectory = entryPath.endsWith("/");
|
||||
if ((unixFileType === 0x4000) !== isDirectory && unixFileType !== 0) throw new SkinRegistryError("ZIP file type does not match its path.", "SKIN_FILE_TYPE");
|
||||
if (isDirectory && (compressedSize !== 0 || expandedSize !== 0)) throw new SkinRegistryError("ZIP directory entries cannot contain data.", "SKIN_ZIP_INVALID");
|
||||
if (compression === 0 && compressedSize !== expandedSize) throw new SkinRegistryError("A stored ZIP entry has inconsistent sizes.", "SKIN_ZIP_INVALID");
|
||||
if (!isDirectory) {
|
||||
totalExpanded += expandedSize;
|
||||
if (totalExpanded > MAX_EXPANDED_BYTES) throw new SkinRegistryError("The expanded package exceeds 50 MiB.", "SKIN_EXPANDED_SIZE");
|
||||
if (expandedSize > 1024 * 1024 && expandedSize > Math.max(compressedSize, 1) * 250) throw new SkinRegistryError("The package has an abnormal compression ratio.", "SKIN_COMPRESSION_RATIO");
|
||||
}
|
||||
entries.push({ path: entryPath, compressedSize, expandedSize, compression, crc, localOffset, flags, isDirectory, unixFileType });
|
||||
offset = recordEnd;
|
||||
}
|
||||
if (offset !== centralOffset + centralSize) throw new SkinRegistryError("The ZIP directory length is inconsistent.", "SKIN_ZIP_INVALID");
|
||||
validateLocalEntries(bytes, entries, centralOffset, decoder);
|
||||
return entries;
|
||||
}
|
||||
|
||||
function validateLocalEntries(bytes: Buffer, entries: SkinArchiveEntry[], centralOffset: number, decoder: TextDecoder): void {
|
||||
const spans: Array<{ start: number; end: number }> = [];
|
||||
for (const entry of entries) {
|
||||
const offset = entry.localOffset;
|
||||
if (offset + 30 > centralOffset || bytes.readUInt32LE(offset) !== LOCAL_SIGNATURE) throw new SkinRegistryError("A ZIP local file header is invalid.", "SKIN_ZIP_INVALID");
|
||||
const flags = bytes.readUInt16LE(offset + 6);
|
||||
const compression = bytes.readUInt16LE(offset + 8);
|
||||
const crc = bytes.readUInt32LE(offset + 14);
|
||||
const compressedSize = bytes.readUInt32LE(offset + 18);
|
||||
const expandedSize = bytes.readUInt32LE(offset + 22);
|
||||
const nameLength = bytes.readUInt16LE(offset + 26);
|
||||
const extraLength = bytes.readUInt16LE(offset + 28);
|
||||
const headerEnd = offset + 30 + nameLength + extraLength;
|
||||
if (headerEnd > centralOffset || flags !== entry.flags || compression !== entry.compression || crc !== entry.crc || compressedSize !== entry.compressedSize || expandedSize !== entry.expandedSize) {
|
||||
throw new SkinRegistryError("ZIP local and central headers disagree.", "SKIN_ZIP_INVALID");
|
||||
}
|
||||
let localPath: string;
|
||||
try { localPath = decoder.decode(bytes.subarray(offset + 30, offset + 30 + nameLength)); }
|
||||
catch { throw new SkinRegistryError("ZIP filenames must be valid UTF-8.", "SKIN_PATH_INVALID"); }
|
||||
if (localPath !== entry.path) throw new SkinRegistryError("ZIP local and central filenames disagree.", "SKIN_ZIP_INVALID");
|
||||
const end = headerEnd + entry.compressedSize;
|
||||
if (end > centralOffset) throw new SkinRegistryError("A ZIP entry overlaps the central directory.", "SKIN_ZIP_INVALID");
|
||||
spans.push({ start: offset, end });
|
||||
}
|
||||
spans.sort((left, right) => left.start - right.start);
|
||||
for (let index = 1; index < spans.length; index += 1) {
|
||||
if (spans[index].start < spans[index - 1].end) throw new SkinRegistryError("ZIP local file entries overlap.", "SKIN_ZIP_INVALID");
|
||||
}
|
||||
}
|
||||
|
||||
function extractEntry(archive: Buffer, entry: SkinArchiveEntry): Buffer {
|
||||
const offset = entry.localOffset;
|
||||
if (offset + 30 > archive.byteLength || archive.readUInt32LE(offset) !== LOCAL_SIGNATURE) throw new SkinRegistryError("A ZIP local file header is invalid.", "SKIN_ZIP_INVALID");
|
||||
const flags = archive.readUInt16LE(offset + 6);
|
||||
const compression = archive.readUInt16LE(offset + 8);
|
||||
const nameLength = archive.readUInt16LE(offset + 26);
|
||||
const extraLength = archive.readUInt16LE(offset + 28);
|
||||
if (flags !== entry.flags || compression !== entry.compression) throw new SkinRegistryError("ZIP headers disagree about file compression.", "SKIN_ZIP_INVALID");
|
||||
const dataStart = offset + 30 + nameLength + extraLength;
|
||||
const dataEnd = dataStart + entry.compressedSize;
|
||||
if (dataEnd > archive.byteLength) throw new SkinRegistryError("A ZIP entry extends past the archive.", "SKIN_ZIP_INVALID");
|
||||
const compressed = archive.subarray(dataStart, dataEnd);
|
||||
if (entry.compression === 0) return Buffer.from(compressed);
|
||||
try { return inflateRawSync(compressed, { maxOutputLength: entry.expandedSize + 1 }); }
|
||||
catch { throw new SkinRegistryError("A ZIP entry could not be safely decompressed.", "SKIN_ZIP_INVALID"); }
|
||||
}
|
||||
|
||||
function parseManifest(bytes: Buffer): ParsedSkinManifest {
|
||||
let raw: unknown;
|
||||
try { raw = JSON.parse(decodeUtf8(bytes, "manifest.json is not valid UTF-8.")); }
|
||||
catch { throw new SkinRegistryError("manifest.json must contain valid JSON.", "SKIN_MANIFEST_INVALID"); }
|
||||
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new SkinRegistryError("manifest.json must be an object.", "SKIN_MANIFEST_INVALID");
|
||||
const value = raw as Record<string, unknown>;
|
||||
const schemaVersion = value.schemaVersion;
|
||||
if (schemaVersion !== 1 && schemaVersion !== 2 && schemaVersion !== 3 && schemaVersion !== 4) throw new SkinRegistryError("The skin schema version or ID is unsupported.", "SKIN_SCHEMA_VERSION");
|
||||
if (schemaVersion >= 2) {
|
||||
const fields = new Set(["schemaVersion", "packageType", "id", "name", "version", "author", "license", "description", "entry", "layout", "permissions", "content", "minAppVersion", "preview"]);
|
||||
if (schemaVersion >= 3) { fields.delete("permissions"); fields.add("components"); }
|
||||
if (schemaVersion === 4) fields.add("plugins");
|
||||
const unknown = Object.keys(value).find((key) => !fields.has(key));
|
||||
if (unknown) throw new SkinRegistryError(`Version 2 skin manifest contains an unsupported field: ${unknown}.`, "SKIN_MANIFEST_INVALID");
|
||||
}
|
||||
const read = (key: string, max: number): string => {
|
||||
const item = value[key];
|
||||
if (typeof item !== "string" || !item.trim() || item.length > max) throw new SkinRegistryError(`manifest.json has an invalid ${key} field.`, "SKIN_MANIFEST_INVALID");
|
||||
return item.trim();
|
||||
};
|
||||
const id = read("id", 80);
|
||||
if (!isSafeSkinId(id)) throw new SkinRegistryError("The skin schema version or ID is unsupported.", "SKIN_SCHEMA_VERSION");
|
||||
if (schemaVersion === 2 && (value.packageType !== "layout-skin" || !Array.isArray(value.permissions) || value.permissions.length !== 0)) {
|
||||
throw new SkinRegistryError("Layout skin packages must declare the layout-skin type and no executable permissions.", "SKIN_PERMISSION_INVALID");
|
||||
}
|
||||
if (schemaVersion === 3 && value.packageType !== "open-skin") throw new SkinRegistryError("Version 3 skin packages must declare the open-skin type.", "SKIN_MANIFEST_INVALID");
|
||||
if (schemaVersion === 4 && value.packageType !== "open-skin") throw new SkinRegistryError("Version 4 skin packages must declare the open-skin type.", "SKIN_MANIFEST_INVALID");
|
||||
if (schemaVersion === 1 && (value.layout !== undefined || value.packageType !== undefined || value.permissions !== undefined || value.components !== undefined || value.plugins !== undefined)) {
|
||||
throw new SkinRegistryError("Version 1 skin packages cannot declare layout or plugin fields.", "SKIN_SCHEMA_VERSION");
|
||||
}
|
||||
const version = read("version", 32);
|
||||
const minAppVersion = read("minAppVersion", 32);
|
||||
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(version) || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(minAppVersion)) throw new SkinRegistryError("Skin and minimum app versions must use semantic version format.", "SKIN_MANIFEST_INVALID");
|
||||
const entry = read("entry", 120);
|
||||
const readOptional = (key: string, max: number): string | undefined => value[key] == null ? undefined : read(key, max);
|
||||
const layout = schemaVersion === 2 ? read("layout", 120) : schemaVersion >= 3 ? readOptional("layout", 120) : undefined;
|
||||
const content = readOptional("content", 120);
|
||||
const components = schemaVersion >= 3 && value.components != null ? read("components", 120) : undefined;
|
||||
const plugins = schemaVersion === 4 ? read("plugins", 120) : undefined;
|
||||
const preview = readOptional("preview", 120);
|
||||
for (const candidate of [entry, layout, content, components, plugins, preview].filter((item): item is string => Boolean(item))) if (!isSafePackagePath(candidate)) throw new SkinRegistryError("The manifest references an unsafe path.", "SKIN_PATH_INVALID");
|
||||
if (!entry.toLowerCase().endsWith(".css") || (layout && !layout.toLowerCase().endsWith(".json")) || (content && !content.toLowerCase().endsWith(".json")) || (components && !components.toLowerCase().endsWith(".json")) || (plugins && !plugins.toLowerCase().endsWith(".json")) || (preview && !imageMime(preview))) throw new SkinRegistryError("The CSS entry, layout, content, plugin, or preview path is invalid.", "SKIN_MANIFEST_INVALID");
|
||||
const declaredFiles = ["manifest.json", entry, ...(layout ? [layout] : []), ...(content ? [content] : []), ...(components ? [components] : []), ...(plugins ? [plugins] : []), ...(preview ? [preview] : [])].map((item) => item.toLowerCase());
|
||||
if (new Set(declaredFiles).size !== declaredFiles.length) throw new SkinRegistryError("Manifest files must use separate package paths.", "SKIN_MANIFEST_INVALID");
|
||||
const description = readOptional("description", 400);
|
||||
return { schemaVersion, ...(schemaVersion === 2 ? { packageType: "layout-skin" as const } : schemaVersion >= 3 ? { packageType: "open-skin" as const } : {}), id, name: read("name", 80), version, author: read("author", 80), license: read("license", 80), minAppVersion, entry, ...(layout ? { layout } : {}), ...(content ? { content } : {}), ...(components ? { components } : {}), ...(plugins ? { plugins } : {}), ...(preview ? { preview } : {}), ...(description ? { description } : {}) };
|
||||
}
|
||||
|
||||
function singleRootPrefix(paths: string[]): string {
|
||||
if (!paths.length) return "";
|
||||
const firstSlash = paths[0].indexOf("/");
|
||||
if (firstSlash < 1) return "";
|
||||
const prefix = paths[0].slice(0, firstSlash + 1);
|
||||
return paths.every((item) => item.startsWith(prefix)) ? prefix : "";
|
||||
}
|
||||
|
||||
function isSafePackagePath(value: string, allowDirectory = false): boolean {
|
||||
const candidate = allowDirectory ? value.slice(0, -1) : value;
|
||||
return Boolean(candidate) && !candidate.startsWith("/") && !candidate.includes("\\") && !candidate.includes("\0") && !/^[a-z]:/i.test(candidate)
|
||||
&& candidate.split("/").every((part) => Boolean(part) && part !== "." && part !== ".." && !part.includes(":"));
|
||||
}
|
||||
|
||||
function isSafeSkinId(value: unknown): value is string {
|
||||
return typeof value === "string" && value.length <= 80 && /^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/.test(value) && !value.startsWith("builtin.");
|
||||
}
|
||||
|
||||
function imageMime(filename: string): string | null {
|
||||
switch (path.extname(filename).toLowerCase()) {
|
||||
case ".png": return "image/png";
|
||||
case ".jpg": case ".jpeg": return "image/jpeg";
|
||||
case ".webp": return "image/webp";
|
||||
case ".avif": return "image/avif";
|
||||
case ".gif": return "image/gif";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
function decodeUtf8(bytes: Buffer, message: string): string {
|
||||
try { return new TextDecoder("utf-8", { fatal: true }).decode(bytes); }
|
||||
catch { throw new SkinRegistryError(message, "SKIN_ENCODING_INVALID"); }
|
||||
}
|
||||
|
||||
function isCatalogEntry(value: unknown): value is SkinCatalogEntry {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
||||
const item = value as Record<string, unknown>;
|
||||
const semver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
||||
if (!isSafeSkinId(item.id) || !isShortText(item.name, 80) || !isShortText(item.author, 80) || !isShortText(item.license, 80)) return false;
|
||||
if (typeof item.version !== "string" || !semver.test(item.version) || typeof item.minAppVersion !== "string" || !semver.test(item.minAppVersion)) return false;
|
||||
if (!Number.isSafeInteger(item.installedAt) || (item.installedAt as number) < 0) return false;
|
||||
if (item.enabled !== undefined && typeof item.enabled !== "boolean") return false;
|
||||
if (item.description !== undefined && (typeof item.description !== "string" || item.description.length > 400)) return false;
|
||||
const hasPreview = item.previewUrl !== undefined || item.previewMimeType !== undefined;
|
||||
return !hasPreview || (item.previewUrl === `/api/skins/${item.id}/preview` && ["image/png", "image/jpeg", "image/webp", "image/avif", "image/gif"].includes(String(item.previewMimeType)));
|
||||
}
|
||||
|
||||
function isShortText(value: unknown, limit: number): value is string {
|
||||
return typeof value === "string" && value.trim().length > 0 && value.length <= limit;
|
||||
}
|
||||
|
||||
const crcTable = (() => {
|
||||
const table = new Uint32Array(256);
|
||||
for (let index = 0; index < table.length; index += 1) {
|
||||
let value = index;
|
||||
for (let bit = 0; bit < 8; bit += 1) value = value & 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
|
||||
table[index] = value >>> 0;
|
||||
}
|
||||
return table;
|
||||
})();
|
||||
|
||||
function crc32(bytes: Buffer): number {
|
||||
let value = 0xffffffff;
|
||||
for (const byte of bytes) value = crcTable[(value ^ byte) & 0xff] ^ (value >>> 8);
|
||||
return (value ^ 0xffffffff) >>> 0;
|
||||
}
|
||||
@@ -3,12 +3,15 @@ import { dirname } from "node:path";
|
||||
import {
|
||||
DEFAULT_TEAM_SPEAK_PORT,
|
||||
parseTeamSpeakTargetParts,
|
||||
parseTeamSpeakPort,
|
||||
} from "./domain/teamspeak-target.js";
|
||||
import { formatTeamSpeakConnectionTarget, parseTeamSpeakConnectionTarget } from "./domain/teamspeak-connection-target.js";
|
||||
|
||||
/** The only TeamSpeak state still read from the legacy JSON config. */
|
||||
export interface AppConfig {
|
||||
tsHost: string;
|
||||
tsPort: number;
|
||||
tsTarget?: string;
|
||||
tsServerPassword: string;
|
||||
}
|
||||
|
||||
@@ -34,8 +37,21 @@ export function migrateConfig(input: unknown): AppConfig {
|
||||
: defaults.tsHost;
|
||||
const rawPort = input.tsPort === undefined ? undefined : input.tsPort;
|
||||
let target;
|
||||
let tsTarget: string | undefined;
|
||||
try {
|
||||
target = parseTeamSpeakTargetParts(rawHost, toPortValue(rawPort), defaults.tsPort);
|
||||
const connection = /^[0-9a-f:]+$/i.test(rawHost) && rawHost.indexOf(":") !== rawHost.lastIndexOf(":") && input.tsTarget === undefined
|
||||
? { kind: "address" as const, target: parseTeamSpeakTargetParts(rawHost, toPortValue(rawPort), defaults.tsPort) }
|
||||
: parseTeamSpeakConnectionTarget(typeof input.tsTarget === "string" ? input.tsTarget : rawHost);
|
||||
if (connection.kind === "nickname") {
|
||||
const port = toPortValue(rawPort);
|
||||
if (input.tsTarget === undefined && port !== undefined && String(port).trim()) {
|
||||
connection.port = parseTeamSpeakPort(port);
|
||||
}
|
||||
target = { host: connection.name, port: connection.port ?? defaults.tsPort };
|
||||
tsTarget = formatTeamSpeakConnectionTarget(connection);
|
||||
} else {
|
||||
target = parseTeamSpeakTargetParts(rawHost, toPortValue(rawPort), defaults.tsPort);
|
||||
}
|
||||
} catch {
|
||||
target = { host: defaults.tsHost, port: defaults.tsPort };
|
||||
}
|
||||
@@ -43,6 +59,7 @@ export function migrateConfig(input: unknown): AppConfig {
|
||||
return {
|
||||
tsHost: target.host,
|
||||
tsPort: target.port,
|
||||
...(tsTarget ? { tsTarget } : {}),
|
||||
tsServerPassword: typeof input.tsServerPassword === "string" ? input.tsServerPassword : defaults.tsServerPassword,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import {
|
||||
InvalidTeamSpeakTargetError,
|
||||
formatTeamSpeakTarget,
|
||||
parseTeamSpeakTarget,
|
||||
parseTeamSpeakPort,
|
||||
type TeamSpeakTarget,
|
||||
} from "./teamspeak-target.js";
|
||||
|
||||
export const TEAM_SPEAK_NICKNAME_LOOKUP = "https://named.myteamspeak.com/lookup";
|
||||
|
||||
export type TeamSpeakConnectionTarget =
|
||||
| { kind: "address"; target: TeamSpeakTarget }
|
||||
| { kind: "nickname"; name: string; port?: number; lookupOnly?: true };
|
||||
|
||||
/** Single-label names follow the TeamSpeak nickname convention; localhost stays local. */
|
||||
export function parseTeamSpeakConnectionTarget(value: string): TeamSpeakConnectionTarget {
|
||||
const input = value.trim();
|
||||
if (!input) throw new InvalidTeamSpeakTargetError("TeamSpeak server address is required");
|
||||
|
||||
if (/^https?:\/\//i.test(input)) {
|
||||
let url: URL;
|
||||
try { url = new URL(input); }
|
||||
catch { throw new InvalidTeamSpeakTargetError("Invalid TeamSpeak nickname lookup URL"); }
|
||||
if (url.origin !== "https://named.myteamspeak.com" || url.pathname !== "/lookup" || url.username || url.password) {
|
||||
throw new InvalidTeamSpeakTargetError("Invalid TeamSpeak nickname lookup URL");
|
||||
}
|
||||
const names = url.searchParams.getAll("name");
|
||||
if (names.length !== 1) throw new InvalidTeamSpeakTargetError("One TeamSpeak nickname is required");
|
||||
// URLSearchParams decodes the query once, including form-encoded spaces.
|
||||
const target = nicknameTarget(names[0]!, url.hash ? parseTeamSpeakPort(url.hash.slice(1)) : undefined);
|
||||
// Keep an explicit registry lookup distinct from a local service name
|
||||
// when the target is saved or split into the address and port fields.
|
||||
if (/^[a-z0-9_-]+$/i.test(target.name)) target.lookupOnly = true;
|
||||
return target;
|
||||
}
|
||||
|
||||
if (input.startsWith("[") || input.indexOf(":") !== input.lastIndexOf(":")) {
|
||||
return { kind: "address", target: parseTeamSpeakTarget(input) };
|
||||
}
|
||||
const separator = Math.max(input.indexOf("#"), input.indexOf(":"));
|
||||
const host = (separator >= 0 ? input.slice(0, separator) : input).trim();
|
||||
const port = separator >= 0 ? parseTeamSpeakPort(input.slice(separator + 1)) : undefined;
|
||||
if (host.toLowerCase() === "localhost" || /^[a-z0-9._-]+\.[a-z0-9._-]*$/i.test(host)) {
|
||||
return { kind: "address", target: parseTeamSpeakTarget(input) };
|
||||
}
|
||||
if (/[\/\\?#@\[\]:]/.test(host)) throw new InvalidTeamSpeakTargetError();
|
||||
return nicknameTarget(host, port);
|
||||
}
|
||||
|
||||
export function formatTeamSpeakConnectionTarget(target: TeamSpeakConnectionTarget): string {
|
||||
if (target.kind === "address") return formatTeamSpeakTarget(target.target);
|
||||
// A lookup URL preserves names that could otherwise be mistaken for a host or port.
|
||||
if (target.lookupOnly || /[.\/\\?#@\[\]:]/.test(target.name) || target.name.toLowerCase() === "localhost") {
|
||||
const url = createTeamSpeakNicknameLookup(target.name);
|
||||
if (target.port !== undefined) url.hash = String(target.port);
|
||||
return url.href;
|
||||
}
|
||||
return target.port === undefined ? target.name : `${target.name}:${target.port}`;
|
||||
}
|
||||
|
||||
export function createTeamSpeakNicknameLookup(name: string): URL {
|
||||
const url = new URL(TEAM_SPEAK_NICKNAME_LOOKUP);
|
||||
url.searchParams.set("name", name);
|
||||
return url;
|
||||
}
|
||||
|
||||
function nicknameTarget(nameValue: string, port?: number): Extract<TeamSpeakConnectionTarget, { kind: "nickname" }> {
|
||||
const name = nameValue.trim();
|
||||
if (!name || name.length > 255 || /[\u0000-\u001f\u007f]/.test(name)) {
|
||||
throw new InvalidTeamSpeakTargetError("Invalid TeamSpeak server nickname");
|
||||
}
|
||||
return { kind: "nickname", name, ...(port === undefined ? {} : { port }) };
|
||||
}
|
||||
|
||||
@@ -89,11 +89,15 @@ function createTarget(hostValue: string, portValue: string | number): TeamSpeakT
|
||||
throw new InvalidTeamSpeakTargetError("Invalid TeamSpeak server address");
|
||||
}
|
||||
|
||||
return { host, port: parseTeamSpeakPort(portValue) };
|
||||
}
|
||||
|
||||
export function parseTeamSpeakPort(portValue: string | number): number {
|
||||
const portText = String(portValue).trim();
|
||||
if (!/^\d+$/.test(portText)) throw new InvalidTeamSpeakTargetError("TeamSpeak port must be a number");
|
||||
const port = Number(portText);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
throw new InvalidTeamSpeakTargetError("TeamSpeak port must be between 1 and 65535");
|
||||
}
|
||||
return { host, port };
|
||||
return port;
|
||||
}
|
||||
@@ -1,45 +1,416 @@
|
||||
export type WebSpeakErrorCode =
|
||||
| "invalid_target"
|
||||
| "invalid_nickname"
|
||||
| "nickname_in_use"
|
||||
| "host_not_found"
|
||||
| "unreachable"
|
||||
| "connection_refused"
|
||||
| "connection_reset"
|
||||
| "timeout"
|
||||
| "authentication_failed"
|
||||
| "protocol_negotiation_failed"
|
||||
| "channel_password_required"
|
||||
| "identity_security_level_too_low"
|
||||
| "identity_limit_reached"
|
||||
| "client_version_outdated"
|
||||
| "flooding"
|
||||
| "banned"
|
||||
| "kicked"
|
||||
| "server_shutting_down"
|
||||
| "server_full"
|
||||
| "invalid_parameter_size"
|
||||
| "connection_initialisation_failed"
|
||||
| "protocol_negotiation_failed"
|
||||
| "unknown";
|
||||
|
||||
export type ClientConnectionFailureCode =
|
||||
| "INVALID_TARGET"
|
||||
| "INVALID_NICKNAME"
|
||||
| "NICKNAME_IN_USE"
|
||||
| "HOST_NOT_FOUND"
|
||||
| "UNREACHABLE"
|
||||
| "CONNECTION_REFUSED"
|
||||
| "CONNECTION_RESET"
|
||||
| "TIMEOUT"
|
||||
| "SERVER_PASSWORD_REQUIRED"
|
||||
| "INVALID_SERVER_PASSWORD"
|
||||
| "CHANNEL_PASSWORD_REQUIRED"
|
||||
| "IDENTITY_SECURITY_LEVEL_TOO_LOW"
|
||||
| "IDENTITY_LIMIT_REACHED"
|
||||
| "CLIENT_VERSION_OUTDATED"
|
||||
| "FLOOD_PROTECTION"
|
||||
| "BANNED"
|
||||
| "KICKED"
|
||||
| "SERVER_SHUTTING_DOWN"
|
||||
| "SERVER_FULL"
|
||||
| "INVALID_PARAMETER"
|
||||
| "PROTOCOL_NEGOTIATION_FAILED"
|
||||
| "CONNECTION_INITIALISATION_FAILED"
|
||||
| "CONNECTION_FAILED";
|
||||
|
||||
export interface TeamSpeakErrorDiagnostics {
|
||||
name?: string;
|
||||
code?: string;
|
||||
id?: string;
|
||||
serverMessage?: string;
|
||||
message?: string;
|
||||
syscall?: string;
|
||||
address?: string;
|
||||
port?: number | string;
|
||||
cause?: string;
|
||||
}
|
||||
|
||||
export class WebSpeakError extends Error {
|
||||
readonly code: WebSpeakErrorCode;
|
||||
readonly retryable: boolean;
|
||||
readonly cause?: unknown;
|
||||
readonly diagnostics: TeamSpeakErrorDiagnostics;
|
||||
|
||||
constructor(code: WebSpeakErrorCode, message: string, retryable: boolean, cause?: unknown) {
|
||||
constructor(code: WebSpeakErrorCode, message: string, retryable: boolean, cause?: unknown, diagnostics: TeamSpeakErrorDiagnostics = {}) {
|
||||
super(message);
|
||||
this.name = "WebSpeakError";
|
||||
this.code = code;
|
||||
this.retryable = retryable;
|
||||
this.cause = cause;
|
||||
this.diagnostics = diagnostics;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TeamSpeak server error ids (SDK `public_errors.h`, shared by TS3 and TS6) that
|
||||
* the gateway can name precisely. Ids that are absent on purpose fall through to
|
||||
* the text heuristics below and finally to `unknown`, which still carries the raw
|
||||
* server detail to the browser.
|
||||
*/
|
||||
export const TEAMSPEAK_SERVER_ERROR_IDS: Readonly<Record<string, WebSpeakErrorCode>> = {
|
||||
// Client (0x02xx): nickname, capacity, identity, password, version, flooding.
|
||||
"513": "nickname_in_use",
|
||||
"515": "server_full",
|
||||
"519": "identity_security_level_too_low",
|
||||
"520": "authentication_failed",
|
||||
"521": "identity_limit_reached",
|
||||
"522": "client_version_outdated",
|
||||
"524": "flooding",
|
||||
// Parameter (0x06xx). 1541 is the generic "invalid parameter size" error;
|
||||
// connection-specific classification decides whether that means a nickname.
|
||||
"1536": "invalid_parameter_size",
|
||||
"1537": "invalid_parameter_size",
|
||||
"1538": "invalid_parameter_size",
|
||||
"1539": "invalid_parameter_size",
|
||||
"1540": "invalid_parameter_size",
|
||||
"1541": "invalid_parameter_size",
|
||||
"1542": "invalid_parameter_size",
|
||||
"1543": "protocol_negotiation_failed",
|
||||
// Connection (0x07xx). Keep only ids whose official meaning matches the
|
||||
// normalized code; unrelated SDK operation errors must not be relabelled.
|
||||
"1797": "connection_initialisation_failed",
|
||||
"1798": "host_not_found",
|
||||
"1805": "protocol_negotiation_failed",
|
||||
"1806": "protocol_negotiation_failed",
|
||||
// Server (0x04xx).
|
||||
"1026": "server_shutting_down",
|
||||
"1027": "server_full",
|
||||
"1028": "authentication_failed",
|
||||
"781": "channel_password_required",
|
||||
// Accounting (0x0bxx): the slot and virtual-server limits both surface as a
|
||||
// full server from the user's point of view.
|
||||
"2816": "server_full",
|
||||
"2817": "server_full",
|
||||
// Ban (0x0dxx).
|
||||
"3329": "banned",
|
||||
"3330": "banned",
|
||||
"3331": "flooding",
|
||||
};
|
||||
|
||||
/**
|
||||
* Default (English) message per normalized code. The browser translates these
|
||||
* strings for zh/en/de, so keep them stable and never embed a raw server id here:
|
||||
* the raw detail travels separately in `diagnostics`.
|
||||
*/
|
||||
export const WEBSPEAK_ERROR_MESSAGES: Readonly<Record<WebSpeakErrorCode, string>> = {
|
||||
invalid_target: "The TeamSpeak server address is invalid",
|
||||
invalid_nickname: "TeamSpeak refused the nickname: it must be 3-30 characters long",
|
||||
nickname_in_use: "This nickname is already used by another user on the TeamSpeak server",
|
||||
host_not_found: "TeamSpeak server hostname could not be resolved",
|
||||
unreachable: "TeamSpeak server is unreachable",
|
||||
connection_refused: "TeamSpeak server refused the connection",
|
||||
connection_reset: "TeamSpeak connection was reset",
|
||||
timeout: "TeamSpeak connection timed out",
|
||||
authentication_failed: "TeamSpeak authentication failed",
|
||||
channel_password_required: "The TeamSpeak channel requires a password",
|
||||
identity_security_level_too_low: "This TeamSpeak identity's security level is below the server requirement",
|
||||
identity_limit_reached: "This TeamSpeak identity already holds the maximum number of connections",
|
||||
client_version_outdated: "The TeamSpeak server requires a newer client version",
|
||||
flooding: "The TeamSpeak server's flood protection refused the connection",
|
||||
banned: "You are banned from this TeamSpeak server",
|
||||
kicked: "You were kicked from the TeamSpeak server",
|
||||
server_shutting_down: "The TeamSpeak server is shutting down",
|
||||
connection_initialisation_failed: "The TeamSpeak server refused the connection during initialisation",
|
||||
server_full: "The TeamSpeak server is full",
|
||||
invalid_parameter_size: "TeamSpeak refused a parameter because its length or value is out of range",
|
||||
protocol_negotiation_failed: "TeamSpeak protocol negotiation failed",
|
||||
unknown: "TeamSpeak connection failed",
|
||||
};
|
||||
|
||||
// 不可重连的错误码集合:这些错误原样重连必然失败(如被封禁、昵称被占用等),
|
||||
// 集合与消息表相邻存放便于审计重连决策;unknown 保持不可重连,防止未映射的
|
||||
// 服务器拒绝演变成无限重连循环。
|
||||
/**
|
||||
* Codes for which reconnecting unchanged cannot succeed. Keeping the list next to
|
||||
* the messages makes the retry decision auditable; `unknown` stays non-retryable
|
||||
* so an unmapped server refusal can never turn into a reconnect loop.
|
||||
*/
|
||||
const NON_RETRYABLE_CODES: ReadonlySet<WebSpeakErrorCode> = new Set<WebSpeakErrorCode>([
|
||||
"invalid_target",
|
||||
"invalid_nickname",
|
||||
"nickname_in_use",
|
||||
"authentication_failed",
|
||||
"channel_password_required",
|
||||
"identity_security_level_too_low",
|
||||
"identity_limit_reached",
|
||||
"client_version_outdated",
|
||||
"banned",
|
||||
"kicked",
|
||||
"invalid_parameter_size",
|
||||
"connection_initialisation_failed",
|
||||
"unknown",
|
||||
]);
|
||||
|
||||
function createTeamSpeakError(code: WebSpeakErrorCode, cause: unknown, diagnostics: TeamSpeakErrorDiagnostics): WebSpeakError {
|
||||
return new WebSpeakError(code, WEBSPEAK_ERROR_MESSAGES[code], !NON_RETRYABLE_CODES.has(code), cause, diagnostics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a raw TeamSpeak server error id to a normalized code. Accepts the
|
||||
* decimal form the SDK forwards (`err.id`, `id=515`) and the hex form used by the
|
||||
* official headers (`0x0203`), because both shapes show up in logs.
|
||||
*/
|
||||
export function teamSpeakServerErrorCode(id: unknown): WebSpeakErrorCode | null {
|
||||
if (id === undefined || id === null) return null;
|
||||
const text = String(id).trim().toLocaleLowerCase();
|
||||
if (/^\d{1,6}$/.test(text)) return TEAMSPEAK_SERVER_ERROR_IDS[String(Number(text))] ?? null;
|
||||
const hexMatch = /^(?:0x)?([0-9a-f]{4,6})$/.exec(text);
|
||||
if (hexMatch) return TEAMSPEAK_SERVER_ERROR_IDS[String(parseInt(hexMatch[1], 16))] ?? null;
|
||||
return null;
|
||||
}
|
||||
|
||||
// 归一化入口:按「服务器错误ID → 关键词启发式 → 异常类名 → 传输层特征」的
|
||||
// 优先级,把 SDK/Node 抛出的原始错误收敛为带稳定错误码的 WebSpeakError。
|
||||
export function normalizeTeamSpeakError(error: unknown): WebSpeakError {
|
||||
if (error instanceof WebSpeakError) return error;
|
||||
|
||||
const candidate = error as { code?: unknown; message?: unknown } | null;
|
||||
const code = typeof candidate?.code === "string" ? candidate.code : "";
|
||||
const message = typeof candidate?.message === "string" ? candidate.message : String(error);
|
||||
const text = `${code} ${message}`.toLocaleLowerCase();
|
||||
const diagnostics = collectDiagnostics(error);
|
||||
const text = diagnosticText(error).toLocaleLowerCase();
|
||||
|
||||
if (/password|authenticate|authentication|not authorized|invalid.*(credential|password)/.test(text)) {
|
||||
return new WebSpeakError("authentication_failed", "TeamSpeak authentication failed", false, error);
|
||||
// 1) A TeamSpeak server error id names the exact reason, so it outranks every
|
||||
// keyword heuristic below. The inline scan keeps the `id=515` shape
|
||||
// working even when the SDK does not attach the id as a structured field.
|
||||
const inlineId = /\bid[\s=:]*(\d{3,5})\b/.exec(text)?.[1];
|
||||
const serverErrorCode =
|
||||
teamSpeakServerErrorCode(diagnostics.id) ?? teamSpeakServerErrorCode(diagnostics.code) ?? teamSpeakServerErrorCode(inlineId);
|
||||
if (serverErrorCode) return createTeamSpeakError(serverErrorCode, error, diagnostics);
|
||||
|
||||
// 2) Explicit refusals that arrive without a stable id. Every pattern stays
|
||||
// narrow on purpose: bare words such as "password", "network", "socket",
|
||||
// "crypto" or "denied" also appear in unrelated Teamspeak messages and used
|
||||
// to steal the classification from the real cause.
|
||||
if (/nickname.{0,20}(length|size)/.test(text)) {
|
||||
return createTeamSpeakError("invalid_nickname", error, diagnostics);
|
||||
}
|
||||
if (/timeout|timed out|ack timeout|idle timeout/.test(text)) {
|
||||
return new WebSpeakError("timeout", "TeamSpeak connection timed out", true, error);
|
||||
if (/invalid[\s_-]*parameter[\s_-]*size|parameter.{0,20}(size|out of range)/.test(text)) {
|
||||
return createTeamSpeakError("invalid_parameter_size", error, diagnostics);
|
||||
}
|
||||
if (/econnrefused|enotfound|ehostunreach|enetunreach|network|socket|dns/.test(text)) {
|
||||
return new WebSpeakError("unreachable", "TeamSpeak server is unreachable", true, error);
|
||||
if (/nickname.{0,30}(in use|already (in )?use|taken|exists)|nickname_in_use/.test(text)) {
|
||||
return createTeamSpeakError("nickname_in_use", error, diagnostics);
|
||||
}
|
||||
if (/protocol|handshake|crypto|init1/.test(text)) {
|
||||
return new WebSpeakError("protocol_negotiation_failed", "TeamSpeak protocol negotiation failed", true, error);
|
||||
if (/channel.{0,30}password|password.{0,30}channel|i_channel_password/.test(text)) {
|
||||
return createTeamSpeakError("channel_password_required", error, diagnostics);
|
||||
}
|
||||
return new WebSpeakError("unknown", "TeamSpeak connection failed", false, error);
|
||||
if (/security ?level|insufficient security|could not validate identity/.test(text)) {
|
||||
return createTeamSpeakError("identity_security_level_too_low", error, diagnostics);
|
||||
}
|
||||
if (/too many clones|clone.{0,20}(limit|connected)|identity.{0,20}(limit|maximum|max).{0,20}connection/.test(text)) {
|
||||
return createTeamSpeakError("identity_limit_reached", error, diagnostics);
|
||||
}
|
||||
if (/version.{0,25}(outdated|out of date|too old|not allowed|unsupported)|outdated.{0,25}version/.test(text)) {
|
||||
return createTeamSpeakError("client_version_outdated", error, diagnostics);
|
||||
}
|
||||
if (/flood/.test(text)) {
|
||||
return createTeamSpeakError("flooding", error, diagnostics);
|
||||
}
|
||||
if (/\bban(ned)?\b|blacklist|you may retry in/.test(text)) {
|
||||
return createTeamSpeakError("banned", error, diagnostics);
|
||||
}
|
||||
if (/kicked/.test(text)) {
|
||||
return createTeamSpeakError("kicked", error, diagnostics);
|
||||
}
|
||||
if (/server.{0,20}shut ?down|server_shutdown|server is shutting down/.test(text)) {
|
||||
return createTeamSpeakError("server_shutting_down", error, diagnostics);
|
||||
}
|
||||
if (/failed[\s_-]*connection[\s_-]*initiali[sz]ation|connection initiali[sz]ation failed|failed to (initialise|initialize) the connection/.test(text)) {
|
||||
return createTeamSpeakError("connection_initialisation_failed", error, diagnostics);
|
||||
}
|
||||
if (/server.{0,25}full|server is full|maximum (number of )?(clients|slots)|slot limit|client protocol limit/.test(text)) {
|
||||
return createTeamSpeakError("server_full", error, diagnostics);
|
||||
}
|
||||
if (/invalid (server )?password|wrong (server )?password|password (is )?(invalid|incorrect|wrong)|password required|i_server_password|authentication failed|not authorized|invalid credential|login (failed|refused)/.test(text)) {
|
||||
return createTeamSpeakError("authentication_failed", error, diagnostics);
|
||||
}
|
||||
|
||||
// 3) SDK handshake/crypto error classes carry no numeric id at all, so match
|
||||
// the class name before falling back to the message text.
|
||||
const errorName = (diagnostics.name ?? "").toLocaleLowerCase();
|
||||
if (/eaxtagmismatch|fakesignaturemismatch|cryptoinit|invalididentity|license/.test(errorName)) {
|
||||
return createTeamSpeakError("protocol_negotiation_failed", error, diagnostics);
|
||||
}
|
||||
if (/alreadyconnected/.test(errorName)) {
|
||||
return createTeamSpeakError("identity_limit_reached", error, diagnostics);
|
||||
}
|
||||
if (/timeout/.test(errorName)) {
|
||||
return createTeamSpeakError("timeout", error, diagnostics);
|
||||
}
|
||||
|
||||
// 4) Transport level failures reported by Node or the TLS layer.
|
||||
if (/enotfound|eai_again|host not found|name or service not known|getaddrinfo/.test(text)) {
|
||||
return createTeamSpeakError("host_not_found", error, diagnostics);
|
||||
}
|
||||
if (/econnrefused|connection refused/.test(text)) {
|
||||
return createTeamSpeakError("connection_refused", error, diagnostics);
|
||||
}
|
||||
if (/econnreset|econnaborted|connection reset|connection aborted|socket hang up/.test(text)) {
|
||||
return createTeamSpeakError("connection_reset", error, diagnostics);
|
||||
}
|
||||
if (/timeout|timed out|ack timeout|idle timeout|etimedout/.test(text)) {
|
||||
return createTeamSpeakError("timeout", error, diagnostics);
|
||||
}
|
||||
if (/ehostunreach|enetunreach|network is unreachable|no route to host|unable to connect|transport error|unexpected eof/.test(text)) {
|
||||
return createTeamSpeakError("unreachable", error, diagnostics);
|
||||
}
|
||||
if (/handshake|protocol|eax|crypto ?(init|handshake|setup)|init1|signature|license/.test(text)) {
|
||||
return createTeamSpeakError("protocol_negotiation_failed", error, diagnostics);
|
||||
}
|
||||
return createTeamSpeakError("unknown", error, diagnostics);
|
||||
}
|
||||
|
||||
export function clientConnectionFailureCode(error: WebSpeakError, serverPassword = ""): ClientConnectionFailureCode {
|
||||
if (error.code === "authentication_failed") {
|
||||
return serverPassword.trim() ? "INVALID_SERVER_PASSWORD" : "SERVER_PASSWORD_REQUIRED";
|
||||
}
|
||||
const mapping: Record<WebSpeakErrorCode, ClientConnectionFailureCode> = {
|
||||
invalid_target: "INVALID_TARGET",
|
||||
invalid_nickname: "INVALID_NICKNAME",
|
||||
nickname_in_use: "NICKNAME_IN_USE",
|
||||
host_not_found: "HOST_NOT_FOUND",
|
||||
unreachable: "UNREACHABLE",
|
||||
connection_refused: "CONNECTION_REFUSED",
|
||||
connection_reset: "CONNECTION_RESET",
|
||||
timeout: "TIMEOUT",
|
||||
authentication_failed: "SERVER_PASSWORD_REQUIRED",
|
||||
channel_password_required: "CHANNEL_PASSWORD_REQUIRED",
|
||||
identity_security_level_too_low: "IDENTITY_SECURITY_LEVEL_TOO_LOW",
|
||||
identity_limit_reached: "IDENTITY_LIMIT_REACHED",
|
||||
client_version_outdated: "CLIENT_VERSION_OUTDATED",
|
||||
flooding: "FLOOD_PROTECTION",
|
||||
banned: "BANNED",
|
||||
kicked: "KICKED",
|
||||
server_shutting_down: "SERVER_SHUTTING_DOWN",
|
||||
connection_initialisation_failed: "CONNECTION_INITIALISATION_FAILED",
|
||||
server_full: "SERVER_FULL",
|
||||
// During the initial connect handshake this generic TeamSpeak id is most
|
||||
// commonly emitted for an invalid nickname length/format. Operation errors
|
||||
// still retain the generic invalid_parameter_size message.
|
||||
invalid_parameter_size: "INVALID_NICKNAME",
|
||||
protocol_negotiation_failed: "PROTOCOL_NEGOTIATION_FAILED",
|
||||
unknown: "CONNECTION_FAILED",
|
||||
};
|
||||
return mapping[error.code];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the SDK `kicked` event. TeamSpeak reports a kick/ban as a
|
||||
* `clientleftview` whose reason id is 4 (kicked) or 5 (kicked with ban) and whose
|
||||
* `reasonMsg` is written by the admin, e.g. "Slow down!" or "you may retry in
|
||||
* 300 seconds". Before this helper existed the reason text was dropped and the
|
||||
* browser only showed a generic connection failure, which is exactly the
|
||||
* experience this translation layer removes. The ban/kick split prefers the
|
||||
* server text and falls back to reason id 5.
|
||||
*/
|
||||
export function normalizeTeamSpeakKickedReason(reasonMsg: unknown, reasonId?: unknown): WebSpeakError {
|
||||
const text = typeof reasonMsg === "string" ? reasonMsg.trim() : "";
|
||||
const numericReasonId = typeof reasonId === "number" ? reasonId : Number(reasonId);
|
||||
const isBan = /\bban(ned)?\b|blacklist|you may retry in/i.test(text) || numericReasonId === 5;
|
||||
const diagnostics: TeamSpeakErrorDiagnostics = { name: isBan ? "TeamSpeakBan" : "TeamSpeakKick" };
|
||||
if (text) diagnostics.serverMessage = text;
|
||||
if (Number.isFinite(numericReasonId)) diagnostics.id = String(numericReasonId);
|
||||
return createTeamSpeakError(isBan ? "banned" : "kicked", reasonMsg, diagnostics);
|
||||
}
|
||||
|
||||
/** Format useful SDK/Node details for a safe operational log field. */
|
||||
export function describeTeamSpeakError(error: WebSpeakError): string {
|
||||
const details = error.diagnostics;
|
||||
const parts = [
|
||||
details.name,
|
||||
details.code,
|
||||
details.id ? `id=${details.id}` : "",
|
||||
details.serverMessage,
|
||||
details.syscall,
|
||||
details.address ? `address=${details.address}` : "",
|
||||
details.port !== undefined ? `port=${details.port}` : "",
|
||||
details.cause,
|
||||
details.message,
|
||||
].filter(Boolean);
|
||||
return parts.length ? parts.join("; ") : error.message;
|
||||
}
|
||||
|
||||
function diagnosticText(error: unknown): string {
|
||||
const values: string[] = [];
|
||||
let current: unknown = error;
|
||||
const seen = new Set<unknown>();
|
||||
for (let depth = 0; depth < 4 && current && !seen.has(current); depth += 1) {
|
||||
seen.add(current);
|
||||
if (current instanceof Error) values.push(current.name, current.message);
|
||||
else values.push(String(current));
|
||||
if (typeof current === "object") {
|
||||
const candidate = current as { code?: unknown; id?: unknown; serverMessage?: unknown; cause?: unknown };
|
||||
for (const value of [candidate.code, candidate.id, candidate.serverMessage]) if (value !== undefined) values.push(String(value));
|
||||
current = candidate.cause;
|
||||
} else break;
|
||||
}
|
||||
return values.join(" ");
|
||||
}
|
||||
|
||||
function collectDiagnostics(error: unknown): TeamSpeakErrorDiagnostics {
|
||||
const result: TeamSpeakErrorDiagnostics = {};
|
||||
let current: unknown = error;
|
||||
const seen = new Set<unknown>();
|
||||
for (let depth = 0; depth < 4 && current && !seen.has(current); depth += 1) {
|
||||
seen.add(current);
|
||||
if (current instanceof Error) {
|
||||
result.name ??= current.name;
|
||||
result.message ??= current.message;
|
||||
const errorRecord = current as Error & Record<string, unknown>;
|
||||
if (typeof errorRecord.code === "string" || typeof errorRecord.code === "number") result.code ??= String(errorRecord.code);
|
||||
if (typeof errorRecord.id === "string" || typeof errorRecord.id === "number") result.id ??= String(errorRecord.id);
|
||||
if (typeof errorRecord.serverMessage === "string") result.serverMessage ??= errorRecord.serverMessage;
|
||||
if (typeof errorRecord.syscall === "string") result.syscall ??= errorRecord.syscall;
|
||||
if (typeof errorRecord.address === "string") result.address ??= errorRecord.address;
|
||||
if (typeof errorRecord.port === "string" || typeof errorRecord.port === "number") result.port ??= errorRecord.port;
|
||||
const cause = current.cause;
|
||||
if (cause && cause !== current) { current = cause; continue; }
|
||||
break;
|
||||
}
|
||||
if (typeof current !== "object") { result.cause ??= String(current); break; }
|
||||
const candidate = current as Record<string, unknown>;
|
||||
if (typeof candidate.name === "string") result.name ??= candidate.name;
|
||||
if (typeof candidate.code === "string" || typeof candidate.code === "number") result.code ??= String(candidate.code);
|
||||
if (typeof candidate.id === "string" || typeof candidate.id === "number") result.id ??= String(candidate.id);
|
||||
if (typeof candidate.serverMessage === "string") result.serverMessage ??= candidate.serverMessage;
|
||||
if (typeof candidate.message === "string") result.message ??= candidate.message;
|
||||
if (typeof candidate.syscall === "string") result.syscall ??= candidate.syscall;
|
||||
if (typeof candidate.address === "string") result.address ??= candidate.address;
|
||||
if (typeof candidate.port === "string" || typeof candidate.port === "number") result.port ??= candidate.port;
|
||||
const cause = candidate.cause;
|
||||
if (cause && cause !== current) { current = cause; continue; }
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
import path from "node:path";
|
||||
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createLogger } from "./logger.js";
|
||||
import { createWebServer } from "./server/server.js";
|
||||
import { APP_PORT } from "./constants.js";
|
||||
import { WebSpeakDatabase } from "./persistence/database.js";
|
||||
import { loadOrCreateMasterSecret } from "./security/master-secret.js";
|
||||
import { AdminService } from "./admin/admin-service.js";
|
||||
import { JoinTicketStore } from "./server/join-ticket.js";
|
||||
import { createAccelerationRelayServer } from "./server/acceleration-relay.js";
|
||||
import { normalizeScreenShareIceServers, type ScreenShareIceServer } from "./server/screen-share.js";
|
||||
import { SkinRegistry } from "./admin/skin-registry.js";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT_DIR = path.resolve(__dirname, "..");
|
||||
@@ -19,8 +15,22 @@ const DATA_DIR = process.env.WEBSPEAK_DATA_DIR?.trim() || path.join(ROOT_DIR, "d
|
||||
const LOG_DIR = path.join(DATA_DIR, "logs");
|
||||
const STATIC_DIR = path.join(ROOT_DIR, "web", "dist");
|
||||
const APP_VERSION = readPackageVersion();
|
||||
const SCREEN_SHARE_ICE_SERVERS = readScreenShareIceServers(process.env.WEBSPEAK_SCREEN_SHARE_ICE_SERVERS);
|
||||
|
||||
async function main() {
|
||||
if (process.env.WEBSPEAK_MODE?.trim().toLowerCase() === "relay") {
|
||||
await runRelayMode();
|
||||
return;
|
||||
}
|
||||
const [{ createLogger }, { createWebServer }, { APP_PORT }, { WebSpeakDatabase }, { loadOrCreateMasterSecret }, { AdminService }, { JoinTicketStore }] = await Promise.all([
|
||||
import("./logger.js"),
|
||||
import("./server/server.js"),
|
||||
import("./constants.js"),
|
||||
import("./persistence/database.js"),
|
||||
import("./security/master-secret.js"),
|
||||
import("./admin/admin-service.js"),
|
||||
import("./server/join-ticket.js"),
|
||||
]);
|
||||
const logger = createLogger(LOG_DIR);
|
||||
const database = new WebSpeakDatabase(path.join(DATA_DIR, "webspeak.db"));
|
||||
const masterSecret = loadOrCreateMasterSecret(path.join(DATA_DIR, "master.key"));
|
||||
@@ -49,9 +59,19 @@ async function main() {
|
||||
voiceBridgeOptions: {
|
||||
joinTickets,
|
||||
webRtc: () => adminService.getWebRtcAudioOptions(),
|
||||
screenShareIceServers: () => SCREEN_SHARE_ICE_SERVERS,
|
||||
// The public gateway only uses the relay configuration explicitly
|
||||
// saved in the admin console. Environment variables belong to the
|
||||
// standalone relay process and must never make the relay option appear
|
||||
// in the visitor UI after an administrator disables it.
|
||||
acceleration: () => adminService.getAccelerationRelayOptions(),
|
||||
accelerationName: () => adminService.getAccelerationRelayName(),
|
||||
},
|
||||
adminService,
|
||||
skinRegistry: new SkinRegistry(path.join(DATA_DIR, "skins")),
|
||||
logger,
|
||||
nextVisitorNumber: () => database.nextVisitorNumber(),
|
||||
visitorCount: () => database.getVisitorCount(),
|
||||
});
|
||||
|
||||
await webServer.start();
|
||||
@@ -67,6 +87,22 @@ async function main() {
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
}
|
||||
|
||||
async function runRelayMode(): Promise<void> {
|
||||
const token = (process.env.WEBSPEAK_RELAY_TOKEN || process.env.WEBSPEAK_ACCELERATION_RELAY_TOKEN)?.trim();
|
||||
if (!token) throw new Error("WEBSPEAK_RELAY_TOKEN is required in relay mode");
|
||||
const host = (process.env.WEBSPEAK_RELAY_HOST || process.env.WEBSPEAK_ACCELERATION_RELAY_HOST)?.trim() || "0.0.0.0";
|
||||
const port = parsePort(process.env.WEBSPEAK_RELAY_PORT || process.env.WEBSPEAK_ACCELERATION_RELAY_PORT, 39087);
|
||||
const allowPrivate = parseBoolean(process.env.WEBSPEAK_RELAY_ALLOW_PRIVATE || process.env.WEBSPEAK_ACCELERATION_RELAY_ALLOW_PRIVATE);
|
||||
const server = await createAccelerationRelayServer({ host, port, token, allowPrivate });
|
||||
console.log(`WebSpeak relay mode listening on ${server.host}:${server.port}`);
|
||||
const shutdown = (): void => {
|
||||
server.close();
|
||||
process.exit(0);
|
||||
};
|
||||
process.once("SIGINT", shutdown);
|
||||
process.once("SIGTERM", shutdown);
|
||||
}
|
||||
|
||||
function readPackageVersion(): string {
|
||||
try {
|
||||
const packageJson = JSON.parse(readFileSync(path.join(ROOT_DIR, "package.json"), "utf8")) as { version?: unknown };
|
||||
@@ -84,6 +120,28 @@ function removeObsoleteBootstrapFile(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function parsePort(value: string | undefined, fallback: number): number {
|
||||
const port = value ? Number(value) : fallback;
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid relay port");
|
||||
return port;
|
||||
}
|
||||
|
||||
function parseBoolean(value: string | undefined): boolean {
|
||||
return value === "1" || value?.toLowerCase() === "true";
|
||||
}
|
||||
|
||||
function readScreenShareIceServers(value: string | undefined): ScreenShareIceServer[] {
|
||||
const raw = value?.trim();
|
||||
if (!raw) return normalizeScreenShareIceServers();
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(raw);
|
||||
return normalizeScreenShareIceServers(Array.isArray(parsed) ? parsed : undefined);
|
||||
} catch {
|
||||
// A simple comma/space-separated list is convenient for STUN-only setups.
|
||||
return normalizeScreenShareIceServers(raw.split(/[\s,]+/).filter(Boolean).map((urls) => ({ urls })));
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("Fatal error:", err);
|
||||
process.exit(1);
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
import express from "express";
|
||||
import { createServer } from "node:http";
|
||||
import path from "node:path";
|
||||
import { existsSync } from "node:fs";
|
||||
import { identityFromString } from "@echosixhiya/teamspeak-client";
|
||||
import { createLogger } from "../logger.js";
|
||||
import { parseTeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { JoinTicketStore } from "../server/join-ticket.js";
|
||||
import { JoinRateLimiter } from "../server/join-rate-limit.js";
|
||||
import { VoiceBridge } from "../server/voice-bridge.js";
|
||||
import { DEFAULT_WELCOME_TEXTS } from "../site-copy.js";
|
||||
|
||||
const port = Number(process.env.WEBSPEAK_MOBILE_PORT || 3040);
|
||||
const host = "127.0.0.1";
|
||||
const dataDir = process.env.WEBSPEAK_DATA_DIR;
|
||||
const staticDir = process.env.WEBSPEAK_MOBILE_WWW;
|
||||
if (!dataDir || !staticDir || !existsSync(path.join(staticDir, "index.html"))) {
|
||||
throw new Error("Android gateway data or web assets are missing");
|
||||
}
|
||||
|
||||
const logger = createLogger(path.join(dataDir, "logs"));
|
||||
const app = express();
|
||||
const server = createServer(app);
|
||||
const joinTickets = new JoinTicketStore();
|
||||
const joinRateLimiter = new JoinRateLimiter();
|
||||
const voiceBridge = new VoiceBridge({ joinTickets, webRtc: { enabled: false } }, logger);
|
||||
|
||||
app.use(express.json({ limit: "100kb" }));
|
||||
app.get("/health", (_request, response) => response.json({ status: "ok", engine: "webspeak-android" }));
|
||||
app.get("/api/health", (_request, response) => response.json({ status: "ok", engine: "webspeak-android" }));
|
||||
app.get("/api/public-config", (_request, response) => {
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
response.json({
|
||||
version: process.env.WEBSPEAK_VERSION ?? "0.2.6",
|
||||
initialized: true,
|
||||
siteName: "WebSpeak",
|
||||
welcomeText: DEFAULT_WELCOME_TEXTS.zh,
|
||||
welcomeTextEn: DEFAULT_WELCOME_TEXTS.en,
|
||||
welcomeTexts: DEFAULT_WELCOME_TEXTS,
|
||||
accessMode: "open",
|
||||
target: "",
|
||||
targetPrefillBlocked: false,
|
||||
accelerationAvailable: false,
|
||||
accelerationRelays: [],
|
||||
mobile: true,
|
||||
});
|
||||
});
|
||||
app.get("/api/skins", (_request, response) => {
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.json({ skins: [], defaultSkinId: "builtin.light" });
|
||||
});
|
||||
app.post("/api/join-ticket", (request, response) => {
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
if (!request.is("application/json") || !isSameOrigin(request)) {
|
||||
response.status(403).json({ ok: false, code: "ORIGIN_REJECTED" });
|
||||
return;
|
||||
}
|
||||
if (!joinRateLimiter.allow(request.socket.remoteAddress ?? "unknown")) {
|
||||
response.status(429).json({ ok: false, code: "RATE_LIMITED" });
|
||||
return;
|
||||
}
|
||||
const body = request.body && typeof request.body === "object" && !Array.isArray(request.body)
|
||||
? request.body as Record<string, unknown>
|
||||
: {};
|
||||
const nickname = typeof body.nickname === "string" ? body.nickname.trim().slice(0, 30) : "";
|
||||
const channel = typeof body.channel === "string" ? body.channel.trim().slice(0, 100) : "";
|
||||
const serverPassword = typeof body.serverPassword === "string" ? body.serverPassword.slice(0, 512) : "";
|
||||
if (!nickname) {
|
||||
response.status(400).json({ ok: false, code: "INVALID_NICKNAME" });
|
||||
return;
|
||||
}
|
||||
let target;
|
||||
try {
|
||||
target = parseTeamSpeakTarget(typeof body.target === "string" ? body.target : "");
|
||||
} catch {
|
||||
response.status(400).json({ ok: false, code: "TARGET_NOT_ALLOWED" });
|
||||
return;
|
||||
}
|
||||
let identity: string | undefined;
|
||||
if (typeof body.identity === "string" && body.identity.length <= 8192) {
|
||||
try {
|
||||
identityFromString(body.identity);
|
||||
identity = body.identity;
|
||||
} catch {
|
||||
// Corrupt local identity should not prevent an ephemeral join.
|
||||
}
|
||||
}
|
||||
const ticket = joinTickets.create({
|
||||
target,
|
||||
serverPassword,
|
||||
nickname,
|
||||
...(channel ? { channel } : {}),
|
||||
...(identity ? { identity, rememberIdentity: true } : body.rememberIdentity === true ? { rememberIdentity: true } : {}),
|
||||
});
|
||||
response.status(201).json({ ok: true, ticket });
|
||||
});
|
||||
|
||||
app.use(express.static(staticDir));
|
||||
app.get(/^(?!\/api|\/ws)/, (_request, response) => response.sendFile(path.join(staticDir, "index.html")));
|
||||
voiceBridge.attach(server);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.once("error", reject);
|
||||
server.listen(port, host, () => {
|
||||
server.off("error", reject);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
logger.info({ host, port, dataDir }, "Android gateway started");
|
||||
|
||||
async function shutdown(): Promise<void> {
|
||||
await voiceBridge.shutdown();
|
||||
server.close();
|
||||
}
|
||||
process.once("SIGTERM", () => { void shutdown(); });
|
||||
process.once("SIGINT", () => { void shutdown(); });
|
||||
|
||||
function isSameOrigin(request: express.Request): boolean {
|
||||
const origin = request.header("origin");
|
||||
const requestHost = request.header("host");
|
||||
try {
|
||||
return Boolean(origin && requestHost && new URL(origin).host === requestHost);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||