@honeybbq/teamspeak-client 0.3.1 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +322 -60
- package/dist/abort.d.ts +5 -0
- package/dist/abort.d.ts.map +1 -0
- package/dist/address.d.ts +8 -0
- package/dist/address.d.ts.map +1 -1
- package/dist/api/voice.d.ts +24 -0
- package/dist/api/voice.d.ts.map +1 -0
- package/dist/capabilities.d.ts +62 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/client.d.ts +172 -39
- package/dist/client.d.ts.map +1 -1
- package/dist/commands.d.ts +45 -27
- package/dist/commands.d.ts.map +1 -1
- package/dist/crypto/crypt.d.ts +19 -4
- package/dist/crypto/crypt.d.ts.map +1 -1
- package/dist/crypto/identity.d.ts +87 -8
- package/dist/crypto/identity.d.ts.map +1 -1
- package/dist/crypto/index.d.ts +2 -1
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/diagnostics.d.ts +45 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/discovery/resolver.d.ts +21 -3
- package/dist/discovery/resolver.d.ts.map +1 -1
- package/dist/errors.d.ts +70 -16
- package/dist/errors.d.ts.map +1 -1
- package/dist/events.d.ts +4 -5
- package/dist/events.d.ts.map +1 -1
- package/dist/handshake/crypt-handshake.d.ts +1 -0
- package/dist/handshake/crypt-handshake.d.ts.map +1 -1
- package/dist/handshake/crypt-init2.d.ts.map +1 -1
- package/dist/handshake/license.d.ts +7 -0
- package/dist/handshake/license.d.ts.map +1 -1
- package/dist/handshake.d.ts +14 -5
- package/dist/handshake.d.ts.map +1 -1
- package/dist/helpers.d.ts +0 -8
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +20 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3967 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications.d.ts +7 -15
- package/dist/notifications.d.ts.map +1 -1
- package/dist/reconnect.d.ts +69 -0
- package/dist/reconnect.d.ts.map +1 -0
- package/dist/throttle.d.ts +9 -0
- package/dist/throttle.d.ts.map +1 -1
- package/dist/transfer.d.ts +27 -25
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transport/handler.d.ts +37 -5
- package/dist/transport/handler.d.ts.map +1 -1
- package/dist/transport/quicklz.d.ts +19 -0
- package/dist/transport/quicklz.d.ts.map +1 -1
- package/dist/types.d.ts +277 -97
- package/dist/types.d.ts.map +1 -1
- package/package.json +21 -56
- package/src/abort.ts +24 -0
- package/src/address.ts +74 -0
- package/src/api/voice.ts +61 -0
- package/src/capabilities.ts +92 -0
- package/src/client.ts +1392 -0
- package/src/commands.ts +193 -0
- package/src/crypto/crypt-ops.ts +6 -0
- package/src/crypto/crypt.ts +274 -0
- package/src/crypto/eax.ts +152 -0
- package/src/crypto/identity.ts +484 -0
- package/src/crypto/index.ts +21 -0
- package/src/crypto/primitives.ts +141 -0
- package/src/diagnostics.ts +58 -0
- package/src/discovery/index.ts +1 -0
- package/src/discovery/resolver.ts +272 -0
- package/src/errors.ts +156 -0
- package/src/events.ts +28 -0
- package/src/handshake/crypt-handshake.ts +135 -0
- package/src/handshake/crypt-init2.ts +48 -0
- package/src/handshake/index.ts +3 -0
- package/src/handshake/license.test.ts +49 -0
- package/src/handshake/license.ts +208 -0
- package/src/handshake.ts +136 -0
- package/src/helpers.ts +10 -0
- package/src/index.ts +74 -0
- package/src/notifications.ts +136 -0
- package/src/reconnect.ts +141 -0
- package/src/throttle.ts +92 -0
- package/src/transfer.ts +127 -0
- package/src/transport/generation-window.ts +77 -0
- package/src/transport/handler.ts +914 -0
- package/src/transport/index.ts +14 -0
- package/src/transport/packet.ts +69 -0
- package/src/transport/quicklz.ts +209 -0
- package/src/types.ts +349 -0
- package/dist/address-BR-5unVo.cjs +0 -2
- package/dist/address-BR-5unVo.cjs.map +0 -1
- package/dist/address-BfmovVpp.js +0 -65
- package/dist/address-BfmovVpp.js.map +0 -1
- package/dist/api.d.ts +0 -17
- package/dist/api.d.ts.map +0 -1
- package/dist/command/command.d.ts +0 -12
- package/dist/command/command.d.ts.map +0 -1
- package/dist/command/index.cjs +0 -1
- package/dist/command/index.d.ts +0 -4
- package/dist/command/index.d.ts.map +0 -1
- package/dist/command/index.mjs +0 -3
- package/dist/command/parser.d.ts +0 -3
- package/dist/command/parser.d.ts.map +0 -1
- package/dist/command-BLe-C2L2.js +0 -74
- package/dist/command-BLe-C2L2.js.map +0 -1
- package/dist/command-DAK4pUBP.cjs +0 -4
- package/dist/command-DAK4pUBP.cjs.map +0 -1
- package/dist/crypt-handshake-CQkQreLx.cjs +0 -2
- package/dist/crypt-handshake-CQkQreLx.cjs.map +0 -1
- package/dist/crypt-handshake-DziOY4Lq.js +0 -55
- package/dist/crypt-handshake-DziOY4Lq.js.map +0 -1
- package/dist/crypt-init2-D70ha4LB.js +0 -158
- package/dist/crypt-init2-D70ha4LB.js.map +0 -1
- package/dist/crypt-init2-DparLekm.cjs +0 -2
- package/dist/crypt-init2-DparLekm.cjs.map +0 -1
- package/dist/crypto/index.cjs +0 -1
- package/dist/crypto/index.mjs +0 -3
- package/dist/crypto-Bg02m4ZE.js +0 -165
- package/dist/crypto-Bg02m4ZE.js.map +0 -1
- package/dist/crypto-CDlweUL3.cjs +0 -2
- package/dist/crypto-CDlweUL3.cjs.map +0 -1
- package/dist/discovery/index.cjs +0 -1
- package/dist/discovery/index.mjs +0 -2
- package/dist/handler-DI_abe9c.js +0 -483
- package/dist/handler-DI_abe9c.js.map +0 -1
- package/dist/handler-DuwoO5RC.cjs +0 -2
- package/dist/handler-DuwoO5RC.cjs.map +0 -1
- package/dist/handshake/index.cjs +0 -1
- package/dist/handshake/index.mjs +0 -3
- package/dist/index.cjs +0 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -827
- package/dist/index.mjs.map +0 -1
- package/dist/parser-CL33R9tr.cjs +0 -2
- package/dist/parser-CL33R9tr.cjs.map +0 -1
- package/dist/parser-DZMv3Jm-.js +0 -33
- package/dist/parser-DZMv3Jm-.js.map +0 -1
- package/dist/primitives-cNNAeFCo.cjs +0 -2
- package/dist/primitives-cNNAeFCo.cjs.map +0 -1
- package/dist/primitives-xIr6Tjk4.js +0 -1457
- package/dist/primitives-xIr6Tjk4.js.map +0 -1
- package/dist/resolver-6B8dI9gr.js +0 -141
- package/dist/resolver-6B8dI9gr.js.map +0 -1
- package/dist/resolver-DCcmyWSK.cjs +0 -4
- package/dist/resolver-DCcmyWSK.cjs.map +0 -1
- package/dist/transport/index.cjs +0 -1
- package/dist/transport/index.mjs +0 -2
package/src/api/voice.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands only the voice protocol has.
|
|
3
|
+
*
|
|
4
|
+
* ServerQuery has no subscriptions — a query client hears every channel's
|
|
5
|
+
* events once it registers for them — and no `channelgetdescription`, since its
|
|
6
|
+
* `channelinfo` already carries the description. These run on the voice
|
|
7
|
+
* client alone, which is why they take one rather than any CommandExecutor.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { Client } from "../client.js";
|
|
11
|
+
import type { ChannelID, CommandOptions } from "@honeybbq/teamspeak-core";
|
|
12
|
+
|
|
13
|
+
/** The channel's description, which `listChannels` omits for bandwidth. */
|
|
14
|
+
export async function getChannelDescription(
|
|
15
|
+
client: Client,
|
|
16
|
+
cid: ChannelID,
|
|
17
|
+
options?: CommandOptions,
|
|
18
|
+
): Promise<string> {
|
|
19
|
+
const rows = await client.send(
|
|
20
|
+
{ command: "channelgetdescription", params: [["cid", cid]] },
|
|
21
|
+
options,
|
|
22
|
+
);
|
|
23
|
+
return rows[0]?.["channel_description"] ?? "";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Subscribe to a channel: receive its clients' events and voice without
|
|
28
|
+
* joining it.
|
|
29
|
+
*/
|
|
30
|
+
export async function subscribeChannel(
|
|
31
|
+
client: Client,
|
|
32
|
+
cid: ChannelID,
|
|
33
|
+
options?: CommandOptions,
|
|
34
|
+
): Promise<void> {
|
|
35
|
+
await client.send({ command: "channelsubscribe", params: [["cid", cid]] }, options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Stop receiving a subscribed channel's events and voice. */
|
|
39
|
+
export async function unsubscribeChannel(
|
|
40
|
+
client: Client,
|
|
41
|
+
cid: ChannelID,
|
|
42
|
+
options?: CommandOptions,
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
await client.send({ command: "channelunsubscribe", params: [["cid", cid]] }, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Subscribe to every channel on the server. */
|
|
48
|
+
export async function subscribeAllChannels(
|
|
49
|
+
client: Client,
|
|
50
|
+
options?: CommandOptions,
|
|
51
|
+
): Promise<void> {
|
|
52
|
+
await client.send({ command: "channelsubscribeall" }, options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Unsubscribe from every channel on the server. */
|
|
56
|
+
export async function unsubscribeAllChannels(
|
|
57
|
+
client: Client,
|
|
58
|
+
options?: CommandOptions,
|
|
59
|
+
): Promise<void> {
|
|
60
|
+
await client.send({ command: "channelunsubscribeall" }, options);
|
|
61
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the connected server is, and what that means for the caller.
|
|
3
|
+
*
|
|
4
|
+
* TS3 and TS6 differ in ways that stay invisible until something breaks. The
|
|
5
|
+
* clearest: the server hashes a client's public key with SHA-1 on TS3 and
|
|
6
|
+
* SHA-256 on TS6, so a client that assumes either one computes a
|
|
7
|
+
* `client_unique_identifier` the other server never sends.
|
|
8
|
+
*
|
|
9
|
+
* Everything below comes from the handshake — `initserver` carries
|
|
10
|
+
* `virtualserver_version`, the one place the server names itself, along with
|
|
11
|
+
* its name, icon, banner and welcome message — so reading it costs no extra
|
|
12
|
+
* round trip.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { IconID } from "@honeybbq/teamspeak-core";
|
|
16
|
+
import { parseIconID } from "@honeybbq/teamspeak-core/internal";
|
|
17
|
+
import { uidAlgorithmForVersion, type UIDAlgorithm } from "./crypto/identity.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The server generation a version string belongs to. May gain members in a
|
|
21
|
+
* minor release, as server generations appear: a `switch` over it needs a
|
|
22
|
+
* default case.
|
|
23
|
+
*/
|
|
24
|
+
export type ServerFamily = "ts3" | "ts6" | "unknown";
|
|
25
|
+
|
|
26
|
+
/** What a server said about itself in the handshake. */
|
|
27
|
+
export interface ServerCapabilities {
|
|
28
|
+
/** The `virtualserver_version` string, exactly as the server sent it. */
|
|
29
|
+
readonly version: string;
|
|
30
|
+
/** Major version number, or 0 when it could not be parsed. */
|
|
31
|
+
readonly major: number;
|
|
32
|
+
/** Which server generation this is. */
|
|
33
|
+
readonly family: ServerFamily;
|
|
34
|
+
/**
|
|
35
|
+
* The hash the server uses for `client_unique_identifier`.
|
|
36
|
+
*
|
|
37
|
+
* Read from the family rather than offered as a setting: the server decides
|
|
38
|
+
* this, and a client that picks differently never matches.
|
|
39
|
+
*/
|
|
40
|
+
readonly uidAlgorithm: UIDAlgorithm;
|
|
41
|
+
/** The virtual server's name (`virtualserver_name`). */
|
|
42
|
+
readonly name: string;
|
|
43
|
+
/**
|
|
44
|
+
* The server's icon (`virtualserver_icon_id`), or `undefined` for none. The
|
|
45
|
+
* server sends the icon's CRC32, sometimes as a negative 32-bit number; this
|
|
46
|
+
* is the unsigned value, which names the icon file.
|
|
47
|
+
*/
|
|
48
|
+
readonly iconID: IconID | undefined;
|
|
49
|
+
/** The host banner image's URL (`virtualserver_hostbanner_gfx_url`), if one is set. */
|
|
50
|
+
readonly hostBannerImageURL: string | undefined;
|
|
51
|
+
/** The welcome message shown on connecting (`virtualserver_welcomemessage`). */
|
|
52
|
+
readonly welcomeMessage: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Read what a server says about itself in `initserver`, or a version string
|
|
57
|
+
* alone, such as "6.0.0-beta13.1 [Build: 1]".
|
|
58
|
+
*/
|
|
59
|
+
export function parseServerCapabilities(
|
|
60
|
+
initserver: string | Readonly<Record<string, string>>,
|
|
61
|
+
): ServerCapabilities {
|
|
62
|
+
const params =
|
|
63
|
+
typeof initserver === "string" ? { virtualserver_version: initserver } : initserver;
|
|
64
|
+
const version = params["virtualserver_version"] ?? "";
|
|
65
|
+
const parsed = Number.parseInt(version, 10);
|
|
66
|
+
const major = Number.isNaN(parsed) ? 0 : parsed;
|
|
67
|
+
|
|
68
|
+
let family: ServerFamily = "unknown";
|
|
69
|
+
if (major === 3) family = "ts3";
|
|
70
|
+
else if (major >= 6) family = "ts6";
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
version,
|
|
74
|
+
major,
|
|
75
|
+
family,
|
|
76
|
+
uidAlgorithm: uidAlgorithmForVersion(version),
|
|
77
|
+
name: params["virtualserver_name"] ?? "",
|
|
78
|
+
iconID: parseIconID(params["virtualserver_icon_id"]),
|
|
79
|
+
hostBannerImageURL: params["virtualserver_hostbanner_gfx_url"]?.trim() || undefined,
|
|
80
|
+
welcomeMessage: params["virtualserver_welcomemessage"] ?? "",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Capabilities of a server that has not been connected to yet.
|
|
86
|
+
*
|
|
87
|
+
* The family is `unknown` — nothing has said which server this is — and
|
|
88
|
+
* `uidAlgorithm` is SHA-1, the TS3 hash.
|
|
89
|
+
*/
|
|
90
|
+
export function unknownServerCapabilities(): ServerCapabilities {
|
|
91
|
+
return parseServerCapabilities("");
|
|
92
|
+
}
|