@honeybbq/teamspeak 0.0.1 → 1.0.0-beta.7
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/LICENSE +21 -0
- package/README.md +726 -2
- package/dist/client/abort.d.ts +5 -0
- package/dist/client/abort.d.ts.map +1 -0
- package/dist/client/abort.js +23 -0
- package/dist/client/abort.js.map +1 -0
- package/dist/client/address.d.ts +17 -0
- package/dist/client/address.d.ts.map +1 -0
- package/dist/client/address.js +66 -0
- package/dist/client/address.js.map +1 -0
- package/dist/client/api/voice.d.ts +24 -0
- package/dist/client/api/voice.d.ts.map +1 -0
- package/dist/client/api/voice.js +33 -0
- package/dist/client/api/voice.js.map +1 -0
- package/dist/client/capabilities.d.ts +68 -0
- package/dist/client/capabilities.d.ts.map +1 -0
- package/dist/client/capabilities.js +59 -0
- package/dist/client/capabilities.js.map +1 -0
- package/dist/client/client.d.ts +196 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +1523 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/commands.d.ts +66 -0
- package/dist/client/commands.d.ts.map +1 -0
- package/dist/client/commands.js +162 -0
- package/dist/client/commands.js.map +1 -0
- package/dist/client/crypto/crypt-ops.d.ts +7 -0
- package/dist/client/crypto/crypt-ops.d.ts.map +1 -0
- package/dist/client/crypto/crypt-ops.js +2 -0
- package/dist/client/crypto/crypt-ops.js.map +1 -0
- package/dist/client/crypto/crypt.d.ts +37 -0
- package/dist/client/crypto/crypt.d.ts.map +1 -0
- package/dist/client/crypto/crypt.js +203 -0
- package/dist/client/crypto/crypt.js.map +1 -0
- package/dist/client/crypto/eax.d.ts +12 -0
- package/dist/client/crypto/eax.d.ts.map +1 -0
- package/dist/client/crypto/eax.js +118 -0
- package/dist/client/crypto/eax.js.map +1 -0
- package/dist/client/crypto/identity.d.ts +97 -0
- package/dist/client/crypto/identity.d.ts.map +1 -0
- package/dist/client/crypto/identity.js +412 -0
- package/dist/client/crypto/identity.js.map +1 -0
- package/dist/client/crypto/index.d.ts +7 -0
- package/dist/client/crypto/index.d.ts.map +1 -0
- package/dist/client/crypto/index.js +5 -0
- package/dist/client/crypto/index.js.map +1 -0
- package/dist/client/crypto/primitives.d.ts +43 -0
- package/dist/client/crypto/primitives.d.ts.map +1 -0
- package/dist/client/crypto/primitives.js +116 -0
- package/dist/client/crypto/primitives.js.map +1 -0
- package/dist/client/diagnostics.d.ts +45 -0
- package/dist/client/diagnostics.d.ts.map +1 -0
- package/dist/client/diagnostics.js +30 -0
- package/dist/client/diagnostics.js.map +1 -0
- package/dist/client/discovery/index.d.ts +2 -0
- package/dist/client/discovery/index.d.ts.map +1 -0
- package/dist/client/discovery/index.js +2 -0
- package/dist/client/discovery/index.js.map +1 -0
- package/dist/client/discovery/resolver.d.ts +26 -0
- package/dist/client/discovery/resolver.d.ts.map +1 -0
- package/dist/client/discovery/resolver.js +275 -0
- package/dist/client/discovery/resolver.js.map +1 -0
- package/dist/client/errors.d.ts +82 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +201 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/events.d.ts +3 -0
- package/dist/client/events.d.ts.map +1 -0
- package/dist/client/events.js +8 -0
- package/dist/client/events.js.map +1 -0
- package/dist/client/handshake/crypt-handshake.d.ts +17 -0
- package/dist/client/handshake/crypt-handshake.d.ts.map +1 -0
- package/dist/client/handshake/crypt-handshake.js +128 -0
- package/dist/client/handshake/crypt-handshake.js.map +1 -0
- package/dist/client/handshake/crypt-init2.d.ts +7 -0
- package/dist/client/handshake/crypt-init2.d.ts.map +1 -0
- package/dist/client/handshake/crypt-init2.js +37 -0
- package/dist/client/handshake/crypt-init2.js.map +1 -0
- package/dist/client/handshake/index.d.ts +4 -0
- package/dist/client/handshake/index.d.ts.map +1 -0
- package/dist/client/handshake/index.js +4 -0
- package/dist/client/handshake/index.js.map +1 -0
- package/dist/client/handshake/license.d.ts +35 -0
- package/dist/client/handshake/license.d.ts.map +1 -0
- package/dist/client/handshake/license.js +169 -0
- package/dist/client/handshake/license.js.map +1 -0
- package/dist/client/handshake.d.ts +27 -0
- package/dist/client/handshake.d.ts.map +1 -0
- package/dist/client/handshake.js +126 -0
- package/dist/client/handshake.js.map +1 -0
- package/dist/client/helpers.d.ts +6 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +13 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/hooks.d.ts +7 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +28 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +28 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/reconnect.d.ts +12 -0
- package/dist/client/reconnect.d.ts.map +1 -0
- package/dist/client/reconnect.js +44 -0
- package/dist/client/reconnect.js.map +1 -0
- package/dist/client/throttle.d.ts +20 -0
- package/dist/client/throttle.d.ts.map +1 -0
- package/dist/client/throttle.js +83 -0
- package/dist/client/throttle.js.map +1 -0
- package/dist/client/trace.d.ts +223 -0
- package/dist/client/trace.d.ts.map +1 -0
- package/dist/client/trace.js +13 -0
- package/dist/client/trace.js.map +1 -0
- package/dist/client/transfer.d.ts +111 -0
- package/dist/client/transfer.d.ts.map +1 -0
- package/dist/client/transfer.js +243 -0
- package/dist/client/transfer.js.map +1 -0
- package/dist/client/transport/generation-window.d.ts +30 -0
- package/dist/client/transport/generation-window.d.ts.map +1 -0
- package/dist/client/transport/generation-window.js +97 -0
- package/dist/client/transport/generation-window.js.map +1 -0
- package/dist/client/transport/handler.d.ts +61 -0
- package/dist/client/transport/handler.d.ts.map +1 -0
- package/dist/client/transport/handler.js +793 -0
- package/dist/client/transport/handler.js.map +1 -0
- package/dist/client/transport/index.d.ts +6 -0
- package/dist/client/transport/index.d.ts.map +1 -0
- package/dist/client/transport/index.js +5 -0
- package/dist/client/transport/index.js.map +1 -0
- package/dist/client/transport/packet.d.ts +36 -0
- package/dist/client/transport/packet.d.ts.map +1 -0
- package/dist/client/transport/packet.js +55 -0
- package/dist/client/transport/packet.js.map +1 -0
- package/dist/client/transport/quicklz.d.ts +24 -0
- package/dist/client/transport/quicklz.d.ts.map +1 -0
- package/dist/client/transport/quicklz.js +179 -0
- package/dist/client/transport/quicklz.js.map +1 -0
- package/dist/client/types.d.ts +226 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +39 -0
- package/dist/client/types.js.map +1 -0
- package/dist/core/api/channels.d.ts +182 -0
- package/dist/core/api/channels.d.ts.map +1 -0
- package/dist/core/api/channels.js +155 -0
- package/dist/core/api/channels.js.map +1 -0
- package/dist/core/api/clients.d.ts +304 -0
- package/dist/core/api/clients.d.ts.map +1 -0
- package/dist/core/api/clients.js +260 -0
- package/dist/core/api/clients.js.map +1 -0
- package/dist/core/api/command.d.ts +305 -0
- package/dist/core/api/command.d.ts.map +1 -0
- package/dist/core/api/command.js +363 -0
- package/dist/core/api/command.js.map +1 -0
- package/dist/core/api/files.d.ts +153 -0
- package/dist/core/api/files.d.ts.map +1 -0
- package/dist/core/api/files.js +181 -0
- package/dist/core/api/files.js.map +1 -0
- package/dist/core/api/groups.d.ts +248 -0
- package/dist/core/api/groups.d.ts.map +1 -0
- package/dist/core/api/groups.js +271 -0
- package/dist/core/api/groups.js.map +1 -0
- package/dist/core/api/moderation.d.ts +205 -0
- package/dist/core/api/moderation.d.ts.map +1 -0
- package/dist/core/api/moderation.js +209 -0
- package/dist/core/api/moderation.js.map +1 -0
- package/dist/core/api/parse.d.ts +16 -0
- package/dist/core/api/parse.d.ts.map +1 -0
- package/dist/core/api/parse.js +40 -0
- package/dist/core/api/parse.js.map +1 -0
- package/dist/core/api/server.d.ts +310 -0
- package/dist/core/api/server.d.ts.map +1 -0
- package/dist/core/api/server.js +290 -0
- package/dist/core/api/server.js.map +1 -0
- package/dist/core/command/command.d.ts +20 -0
- package/dist/core/command/command.d.ts.map +1 -0
- package/dist/core/command/command.js +112 -0
- package/dist/core/command/command.js.map +1 -0
- package/dist/core/command/ids.d.ts +125 -0
- package/dist/core/command/ids.d.ts.map +1 -0
- package/dist/core/command/ids.js +85 -0
- package/dist/core/command/ids.js.map +1 -0
- package/dist/core/command/parser.d.ts +17 -0
- package/dist/core/command/parser.d.ts.map +1 -0
- package/dist/core/command/parser.js +65 -0
- package/dist/core/command/parser.js.map +1 -0
- package/dist/core/command/request.d.ts +61 -0
- package/dist/core/command/request.d.ts.map +1 -0
- package/dist/core/command/request.js +64 -0
- package/dist/core/command/request.js.map +1 -0
- package/dist/core/command/responses.d.ts +59 -0
- package/dist/core/command/responses.d.ts.map +1 -0
- package/dist/core/command/responses.js +74 -0
- package/dist/core/command/responses.js.map +1 -0
- package/dist/core/command-name.d.ts +333 -0
- package/dist/core/command-name.d.ts.map +1 -0
- package/dist/core/command-name.js +331 -0
- package/dist/core/command-name.js.map +1 -0
- package/dist/core/enums.d.ts +146 -0
- package/dist/core/enums.d.ts.map +1 -0
- package/dist/core/enums.js +132 -0
- package/dist/core/enums.js.map +1 -0
- package/dist/core/errorcode.d.ts +413 -0
- package/dist/core/errorcode.d.ts.map +1 -0
- package/dist/core/errorcode.js +410 -0
- package/dist/core/errorcode.js.map +1 -0
- package/dist/core/errors.d.ts +111 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +233 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events.d.ts +207 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +6 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/helpers.d.ts +42 -0
- package/dist/core/helpers.d.ts.map +1 -0
- package/dist/core/helpers.js +156 -0
- package/dist/core/helpers.js.map +1 -0
- package/dist/core/index.d.ts +35 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +23 -0
- package/dist/core/internal.d.ts.map +1 -0
- package/dist/core/internal.js +20 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/middleware.d.ts +14 -0
- package/dist/core/middleware.d.ts.map +1 -0
- package/dist/core/middleware.js +18 -0
- package/dist/core/middleware.js.map +1 -0
- package/dist/core/notification-name.d.ts +154 -0
- package/dist/core/notification-name.d.ts.map +1 -0
- package/dist/core/notification-name.js +152 -0
- package/dist/core/notification-name.js.map +1 -0
- package/dist/core/notifications.d.ts +43 -0
- package/dist/core/notifications.d.ts.map +1 -0
- package/dist/core/notifications.js +116 -0
- package/dist/core/notifications.js.map +1 -0
- package/dist/core/permission-name.d.ts +533 -0
- package/dist/core/permission-name.d.ts.map +1 -0
- package/dist/core/permission-name.js +531 -0
- package/dist/core/permission-name.js.map +1 -0
- package/dist/core/permission.d.ts +31 -0
- package/dist/core/permission.d.ts.map +1 -0
- package/dist/core/permission.js +20 -0
- package/dist/core/permission.js.map +1 -0
- package/dist/core/property-name.d.ts +403 -0
- package/dist/core/property-name.d.ts.map +1 -0
- package/dist/core/property-name.js +405 -0
- package/dist/core/property-name.js.map +1 -0
- package/dist/core/reason.d.ts +39 -0
- package/dist/core/reason.d.ts.map +1 -0
- package/dist/core/reason.js +36 -0
- package/dist/core/reason.js.map +1 -0
- package/dist/core/reconnect.d.ts +59 -0
- package/dist/core/reconnect.d.ts.map +1 -0
- package/dist/core/reconnect.js +55 -0
- package/dist/core/reconnect.js.map +1 -0
- package/dist/core/types.d.ts +110 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +27 -0
- package/dist/core/types.js.map +1 -0
- package/dist/query/client.d.ts +194 -0
- package/dist/query/client.d.ts.map +1 -0
- package/dist/query/client.js +967 -0
- package/dist/query/client.js.map +1 -0
- package/dist/query/errors.d.ts +61 -0
- package/dist/query/errors.d.ts.map +1 -0
- package/dist/query/errors.js +100 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/index.d.ts +36 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +34 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/knownhosts.d.ts +61 -0
- package/dist/query/knownhosts.d.ts.map +1 -0
- package/dist/query/knownhosts.js +223 -0
- package/dist/query/knownhosts.js.map +1 -0
- package/dist/query/lines.d.ts +14 -0
- package/dist/query/lines.d.ts.map +1 -0
- package/dist/query/lines.js +29 -0
- package/dist/query/lines.js.map +1 -0
- package/dist/query/options.d.ts +187 -0
- package/dist/query/options.d.ts.map +1 -0
- package/dist/query/options.js +213 -0
- package/dist/query/options.js.map +1 -0
- package/dist/query/reconnect.d.ts +29 -0
- package/dist/query/reconnect.d.ts.map +1 -0
- package/dist/query/reconnect.js +87 -0
- package/dist/query/reconnect.js.map +1 -0
- package/dist/query/ssh.d.ts +345 -0
- package/dist/query/ssh.d.ts.map +1 -0
- package/dist/query/ssh.js +241 -0
- package/dist/query/ssh.js.map +1 -0
- package/dist/query/stream.d.ts +38 -0
- package/dist/query/stream.d.ts.map +1 -0
- package/dist/query/stream.js +70 -0
- package/dist/query/stream.js.map +1 -0
- package/dist/query/tcp.d.ts +38 -0
- package/dist/query/tcp.d.ts.map +1 -0
- package/dist/query/tcp.js +53 -0
- package/dist/query/tcp.js.map +1 -0
- package/dist/query/transport.d.ts +36 -0
- package/dist/query/transport.d.ts.map +1 -0
- package/dist/query/transport.js +2 -0
- package/dist/query/transport.js.map +1 -0
- package/dist/query/web.d.ts +54 -0
- package/dist/query/web.d.ts.map +1 -0
- package/dist/query/web.js +146 -0
- package/dist/query/web.js.map +1 -0
- package/dist/versions/index.d.ts +3094 -0
- package/dist/versions/index.d.ts.map +1 -0
- package/dist/versions/index.js +9237 -0
- package/dist/versions/index.js.map +1 -0
- package/package.json +118 -4
- package/src/client/abort.ts +24 -0
- package/src/client/address.ts +74 -0
- package/src/client/api/voice.ts +61 -0
- package/src/client/capabilities.ts +106 -0
- package/src/client/client.ts +1809 -0
- package/src/client/commands.ts +193 -0
- package/src/client/crypto/crypt-ops.ts +6 -0
- package/src/client/crypto/crypt.ts +275 -0
- package/src/client/crypto/eax.ts +152 -0
- package/src/client/crypto/identity.ts +484 -0
- package/src/client/crypto/index.ts +21 -0
- package/src/client/crypto/primitives.ts +141 -0
- package/src/client/diagnostics.ts +58 -0
- package/src/client/discovery/index.ts +1 -0
- package/src/client/discovery/resolver.ts +325 -0
- package/src/client/errors.ts +217 -0
- package/src/client/events.ts +12 -0
- package/src/client/handshake/crypt-handshake.ts +157 -0
- package/src/client/handshake/crypt-init2.ts +48 -0
- package/src/client/handshake/index.ts +3 -0
- package/src/client/handshake/license.ts +208 -0
- package/src/client/handshake.ts +150 -0
- package/src/client/helpers.ts +10 -0
- package/src/client/hooks.ts +30 -0
- package/src/client/index.ts +93 -0
- package/src/client/reconnect.ts +43 -0
- package/src/client/throttle.ts +92 -0
- package/src/client/trace.ts +237 -0
- package/src/client/transfer.ts +436 -0
- package/src/client/transport/generation-window.ts +108 -0
- package/src/client/transport/handler.ts +926 -0
- package/src/client/transport/index.ts +14 -0
- package/src/client/transport/packet.ts +69 -0
- package/src/client/transport/quicklz.ts +209 -0
- package/src/client/types.ts +268 -0
- package/src/core/api/channels.ts +396 -0
- package/src/core/api/clients.ts +654 -0
- package/src/core/api/command.ts +563 -0
- package/src/core/api/files.ts +405 -0
- package/src/core/api/groups.ts +622 -0
- package/src/core/api/moderation.ts +525 -0
- package/src/core/api/parse.ts +52 -0
- package/src/core/api/server.ts +709 -0
- package/src/core/command/command.ts +125 -0
- package/src/core/command/ids.ts +149 -0
- package/src/core/command/parser.ts +68 -0
- package/src/core/command/request.ts +119 -0
- package/src/core/command/responses.ts +114 -0
- package/src/core/command-name.ts +334 -0
- package/src/core/enums.ts +167 -0
- package/src/core/errorcode.ts +412 -0
- package/src/core/errors.ts +258 -0
- package/src/core/events.ts +219 -0
- package/src/core/helpers.ts +161 -0
- package/src/core/index.ts +126 -0
- package/src/core/internal.ts +23 -0
- package/src/core/middleware.ts +24 -0
- package/src/core/notification-name.ts +155 -0
- package/src/core/notifications.ts +157 -0
- package/src/core/permission-name.ts +538 -0
- package/src/core/permission.ts +34 -0
- package/src/core/property-name.ts +411 -0
- package/src/core/reason.ts +38 -0
- package/src/core/reconnect.ts +98 -0
- package/src/core/types.ts +138 -0
- package/src/query/client.ts +1132 -0
- package/src/query/errors.ts +108 -0
- package/src/query/index.ts +65 -0
- package/src/query/knownhosts.ts +257 -0
- package/src/query/lines.ts +28 -0
- package/src/query/options.ts +388 -0
- package/src/query/reconnect.ts +84 -0
- package/src/query/ssh.ts +614 -0
- package/src/query/stream.ts +91 -0
- package/src/query/tcp.ts +85 -0
- package/src/query/transport.ts +35 -0
- package/src/query/web.ts +195 -0
- package/src/versions/index.ts +10774 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server and instance commands.
|
|
3
|
+
*
|
|
4
|
+
* "Server" here means the virtual server a client is connected to; "instance"
|
|
5
|
+
* means the process hosting it. The distinction matters because the setting
|
|
6
|
+
* names differ (`virtualserver_*` versus `serverinstance_*`) and the two are
|
|
7
|
+
* easy to mix up.
|
|
8
|
+
*/
|
|
9
|
+
import { nonEmpty, uint, U16, firstRow, exec, query, list, encodeFields, inSeconds, parsePermission, permissionParam, createdGroupID, str, big, num, bool, icon, date, durationMs, SECOND, } from "./command.js";
|
|
10
|
+
import { asChannelID, asClientDBID, asClientID, asServerGroupID, asServerID, asUID, } from "../command/ids.js";
|
|
11
|
+
const parseServerGroup = (row) => ({
|
|
12
|
+
id: asServerGroupID(big(row, "sgid")),
|
|
13
|
+
name: str(row, "name"),
|
|
14
|
+
type: num(row, "type"),
|
|
15
|
+
iconID: icon(row, "iconid"),
|
|
16
|
+
savedInDatabase: bool(row, "savedb"),
|
|
17
|
+
sortID: num(row, "sortid"),
|
|
18
|
+
nameMode: num(row, "namemode"),
|
|
19
|
+
modifyPower: num(row, "n_modifyp"),
|
|
20
|
+
memberAddPower: num(row, "n_member_addp"),
|
|
21
|
+
memberRemovePower: num(row, "n_member_removep"),
|
|
22
|
+
});
|
|
23
|
+
/** Every server group. */
|
|
24
|
+
export async function listServerGroups(client, options) {
|
|
25
|
+
return (await list(client, "servergrouplist", [], options)).map(parseServerGroup);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The virtual server's settings, as `serverinfo` reports them.
|
|
29
|
+
*
|
|
30
|
+
* Raw rather than parsed: `serverinfo` carries well over a hundred
|
|
31
|
+
* `virtualserver_*` fields, which ones appear depends on the server version and
|
|
32
|
+
* on the caller's permissions, and a typed subset would drop the rest. The
|
|
33
|
+
* keys are named in `PropertyName`.
|
|
34
|
+
*/
|
|
35
|
+
export async function getServerInfo(client, options) {
|
|
36
|
+
return firstRow(await query(client, "serverinfo", [], options), "serverinfo");
|
|
37
|
+
}
|
|
38
|
+
/** Raw wire properties, sent as given. */
|
|
39
|
+
const rawProperties = (settings) => Object.entries(settings).filter((entry) => typeof entry[1] === "string");
|
|
40
|
+
/**
|
|
41
|
+
* Change the virtual server's settings. Only the properties you pass are sent.
|
|
42
|
+
*
|
|
43
|
+
* Unlike every other options object, these are the raw `virtualserver_*`
|
|
44
|
+
* wire properties from `serverinfo`, passed through as given rather than
|
|
45
|
+
* enumerated: there are well over a hundred, they are version-dependent, and a
|
|
46
|
+
* value read back from {@link getServerInfo} should be writable straight back.
|
|
47
|
+
* The values are strings, as `getServerInfo` returns them. The editable keys
|
|
48
|
+
* are marked in `PropertyName`.
|
|
49
|
+
*/
|
|
50
|
+
export async function editServer(client, settings, options) {
|
|
51
|
+
await exec(client, "serveredit", rawProperties(settings), options);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The host process's settings, as `hostinfo` reports them, raw.
|
|
55
|
+
*
|
|
56
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
57
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
58
|
+
* Granted, it works over the voice protocol like any other query. The keys are
|
|
59
|
+
* named in `PropertyName`.
|
|
60
|
+
*/
|
|
61
|
+
export async function getHostInfo(client, options) {
|
|
62
|
+
return firstRow(await query(client, "hostinfo", [], options), "hostinfo");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The server instance's settings, as `instanceinfo` reports them, raw.
|
|
66
|
+
*
|
|
67
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
68
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
69
|
+
* Granted, it works over the voice protocol like any other query. The keys are
|
|
70
|
+
* named in `PropertyName`.
|
|
71
|
+
*/
|
|
72
|
+
export async function getInstanceInfo(client, options) {
|
|
73
|
+
return firstRow(await query(client, "instanceinfo", [], options), "instanceinfo");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Change the server instance's settings: raw `serverinstance_*` properties,
|
|
77
|
+
* passed through as given, for the same reasons as {@link editServer}. The
|
|
78
|
+
* editable keys are marked in `PropertyName`.
|
|
79
|
+
*/
|
|
80
|
+
export async function editInstance(client, settings, options) {
|
|
81
|
+
await exec(client, "instanceedit", rawProperties(settings), options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Active IP bindings, when the instance is multi-homed.
|
|
85
|
+
*
|
|
86
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
87
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
88
|
+
* Granted, it works over the voice protocol like any other query.
|
|
89
|
+
*/
|
|
90
|
+
export async function listBindings(client, options = {}) {
|
|
91
|
+
const subsystem = options.subsystem || "voice";
|
|
92
|
+
const rows = await list(client, "bindinglist", [["subsystem", nonEmpty(options.subsystem ?? "")]], options);
|
|
93
|
+
return rows.map((row) => ({
|
|
94
|
+
subsystem: str(row, "subsystem") || subsystem,
|
|
95
|
+
ip: str(row, "ip"),
|
|
96
|
+
port: row["port"] === undefined ? undefined : num(row, "port"),
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
/** The server's build version. */
|
|
100
|
+
export async function getVersion(client, options) {
|
|
101
|
+
const row = firstRow(await query(client, "version", [], options), "version");
|
|
102
|
+
return { version: str(row, "version"), build: num(row, "build"), platform: str(row, "platform") };
|
|
103
|
+
}
|
|
104
|
+
/** Which server and client this connection is, as the server sees it. */
|
|
105
|
+
export async function whoAmI(client, options) {
|
|
106
|
+
const row = firstRow(await query(client, "whoami", [], options), "whoami");
|
|
107
|
+
return {
|
|
108
|
+
serverStatus: str(row, "virtualserver_status"),
|
|
109
|
+
serverID: asServerID(big(row, "virtualserver_id")),
|
|
110
|
+
serverUID: str(row, "virtualserver_unique_identifier"),
|
|
111
|
+
serverPort: num(row, "virtualserver_port"),
|
|
112
|
+
clientID: asClientID(uint(row, "client_id", U16)),
|
|
113
|
+
channelID: asChannelID(big(row, "client_channel_id")),
|
|
114
|
+
nickname: str(row, "client_nickname"),
|
|
115
|
+
databaseID: asClientDBID(big(row, "client_database_id")),
|
|
116
|
+
loginName: str(row, "client_login_name"),
|
|
117
|
+
uid: asUID(str(row, "client_unique_identifier")),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The virtual server's traffic statistics — not this connection's, as the
|
|
122
|
+
* command's name suggests.
|
|
123
|
+
*/
|
|
124
|
+
export async function getConnectionInfo(client, options) {
|
|
125
|
+
const row = firstRow(await query(client, "serverrequestconnectioninfo", [], options), "serverrequestconnectioninfo");
|
|
126
|
+
return {
|
|
127
|
+
fileTransferBandwidthSent: num(row, "connection_filetransfer_bandwidth_sent"),
|
|
128
|
+
fileTransferBandwidthReceived: num(row, "connection_filetransfer_bandwidth_received"),
|
|
129
|
+
fileTransferBytesSent: num(row, "connection_filetransfer_bytes_sent_total"),
|
|
130
|
+
fileTransferBytesReceived: num(row, "connection_filetransfer_bytes_received_total"),
|
|
131
|
+
packetsSent: num(row, "connection_packets_sent_total"),
|
|
132
|
+
bytesSent: num(row, "connection_bytes_sent_total"),
|
|
133
|
+
packetsReceived: num(row, "connection_packets_received_total"),
|
|
134
|
+
bytesReceived: num(row, "connection_bytes_received_total"),
|
|
135
|
+
bandwidthSentLastSecond: num(row, "connection_bandwidth_sent_last_second_total"),
|
|
136
|
+
bandwidthSentLastMinute: num(row, "connection_bandwidth_sent_last_minute_total"),
|
|
137
|
+
bandwidthReceivedLastSecond: num(row, "connection_bandwidth_received_last_second_total"),
|
|
138
|
+
bandwidthReceivedLastMinute: num(row, "connection_bandwidth_received_last_minute_total"),
|
|
139
|
+
connectedTimeMs: durationMs(row, "connection_connected_time", SECOND),
|
|
140
|
+
packetLoss: num(row, "connection_packetloss_total"),
|
|
141
|
+
pingMs: num(row, "connection_ping"),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The numeric id of the virtual server listening on `port`.
|
|
146
|
+
*
|
|
147
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
148
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
149
|
+
* Granted, it works over the voice protocol like any other query.
|
|
150
|
+
*/
|
|
151
|
+
export async function getServerIDByPort(client, port, options) {
|
|
152
|
+
const rows = await query(client, "serveridgetbyport", [["virtualserver_port", port]], options);
|
|
153
|
+
return asServerID(big(firstRow(rows, "serveridgetbyport", "server_id"), "server_id"));
|
|
154
|
+
}
|
|
155
|
+
// ---- Server groups ----------------------------------------------------------
|
|
156
|
+
/**
|
|
157
|
+
* Create a server group.
|
|
158
|
+
*
|
|
159
|
+
* `type` is required, and always sent: the server's own default is
|
|
160
|
+
* `GroupType.Regular`, while the type's first value is `Template`, so leaving
|
|
161
|
+
* it to a default on either side is a trap.
|
|
162
|
+
*/
|
|
163
|
+
export async function createServerGroup(client, name, type, options) {
|
|
164
|
+
const rows = await query(client, "servergroupadd", [
|
|
165
|
+
["name", name],
|
|
166
|
+
["type", type],
|
|
167
|
+
], options);
|
|
168
|
+
return asServerGroupID(createdGroupID(rows, "sgid", name, "servergroupadd"));
|
|
169
|
+
}
|
|
170
|
+
/** Delete a server group. */
|
|
171
|
+
export async function deleteServerGroup(client, sgid, options = {}) {
|
|
172
|
+
await exec(client, "servergroupdel", [
|
|
173
|
+
["sgid", sgid],
|
|
174
|
+
["force", options.force ?? false],
|
|
175
|
+
], options);
|
|
176
|
+
}
|
|
177
|
+
/** Rename a server group. */
|
|
178
|
+
export async function renameServerGroup(client, sgid, name, options) {
|
|
179
|
+
await exec(client, "servergrouprename", [
|
|
180
|
+
["sgid", sgid],
|
|
181
|
+
["name", name],
|
|
182
|
+
], options);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Copy a server group's permissions onto another; a `targetGroupID` of 0 makes
|
|
186
|
+
* the server create a new group named `name`, of `type`.
|
|
187
|
+
*/
|
|
188
|
+
export async function copyServerGroup(client, sourceGroupID, targetGroupID, name, type, options) {
|
|
189
|
+
const rows = await query(client, "servergroupcopy", [
|
|
190
|
+
["ssgid", sourceGroupID],
|
|
191
|
+
["tsgid", targetGroupID],
|
|
192
|
+
["name", name],
|
|
193
|
+
["type", type],
|
|
194
|
+
], options);
|
|
195
|
+
// Copying onto an existing group keeps that group's id.
|
|
196
|
+
if (targetGroupID !== 0n)
|
|
197
|
+
return targetGroupID;
|
|
198
|
+
return asServerGroupID(createdGroupID(rows, "sgid", name, "servergroupcopy"));
|
|
199
|
+
}
|
|
200
|
+
/** Add a client to a server group. */
|
|
201
|
+
export async function addClientToServerGroup(client, sgid, cldbid, options) {
|
|
202
|
+
await exec(client, "servergroupaddclient", [
|
|
203
|
+
["sgid", sgid],
|
|
204
|
+
["cldbid", cldbid],
|
|
205
|
+
], options);
|
|
206
|
+
}
|
|
207
|
+
/** Remove a client from a server group. */
|
|
208
|
+
export async function removeClientFromServerGroup(client, sgid, cldbid, options) {
|
|
209
|
+
await exec(client, "servergroupdelclient", [
|
|
210
|
+
["sgid", sgid],
|
|
211
|
+
["cldbid", cldbid],
|
|
212
|
+
], options);
|
|
213
|
+
}
|
|
214
|
+
const memberFlags = { names: "-names", uids: "-uid" };
|
|
215
|
+
/** Members of a server group, optionally with their nicknames and uids. */
|
|
216
|
+
export async function listServerGroupClients(client, sgid, options = {}) {
|
|
217
|
+
const rows = await list(client, "servergroupclientlist", [["sgid", sgid], ...encodeFields(options, memberFlags)], options);
|
|
218
|
+
return rows.map((row) => ({
|
|
219
|
+
databaseID: asClientDBID(big(row, "cldbid")),
|
|
220
|
+
nickname: str(row, "client_nickname"),
|
|
221
|
+
uid: asUID(str(row, "client_unique_identifier")),
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
/** Server groups a client belongs to. */
|
|
225
|
+
export async function getServerGroupsByClient(client, cldbid, options) {
|
|
226
|
+
const rows = await list(client, "servergroupsbyclientid", [["cldbid", cldbid]], options);
|
|
227
|
+
return rows.map((row) => ({ id: asServerGroupID(big(row, "sgid")), name: str(row, "name") }));
|
|
228
|
+
}
|
|
229
|
+
/** Permissions set on a server group. */
|
|
230
|
+
export async function listServerGroupPermissions(client, sgid, options) {
|
|
231
|
+
return (await list(client, "servergrouppermlist", [["sgid", sgid]], options)).map(parsePermission);
|
|
232
|
+
}
|
|
233
|
+
/** Set a permission on a server group. */
|
|
234
|
+
export async function addServerGroupPermission(client, sgid, permission, value, options = {}) {
|
|
235
|
+
await exec(client, "servergroupaddperm", [
|
|
236
|
+
["sgid", sgid],
|
|
237
|
+
permissionParam(permission),
|
|
238
|
+
["permvalue", value],
|
|
239
|
+
["permnegated", options.negated ?? false],
|
|
240
|
+
["permskip", options.skip ?? false],
|
|
241
|
+
], options);
|
|
242
|
+
}
|
|
243
|
+
/** Remove a permission from a server group. */
|
|
244
|
+
export async function deleteServerGroupPermission(client, sgid, permission, options) {
|
|
245
|
+
await exec(client, "servergroupdelperm", [["sgid", sgid], permissionParam(permission)], options);
|
|
246
|
+
}
|
|
247
|
+
/** The server's temporary passwords. */
|
|
248
|
+
export async function listTempPasswords(client, options) {
|
|
249
|
+
const rows = await list(client, "servertemppasswordlist", [], options);
|
|
250
|
+
return rows.map((row) => ({
|
|
251
|
+
password: str(row, "pw_clear"),
|
|
252
|
+
description: str(row, "desc"),
|
|
253
|
+
creatorNickname: str(row, "nickname"),
|
|
254
|
+
creatorUID: asUID(str(row, "uid")),
|
|
255
|
+
startsAt: date(row, "start"),
|
|
256
|
+
endsAt: date(row, "end"),
|
|
257
|
+
targetChannelID: asChannelID(big(row, "tcid")),
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
const tempPasswordNames = {
|
|
261
|
+
password: "pw",
|
|
262
|
+
description: "desc",
|
|
263
|
+
durationMs: ["duration", inSeconds],
|
|
264
|
+
targetChannelID: "tcid",
|
|
265
|
+
targetChannelPassword: "tcpw",
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Create a temporary server password.
|
|
269
|
+
*
|
|
270
|
+
* The server reports nothing back — the password is the one passed in.
|
|
271
|
+
*/
|
|
272
|
+
export async function addTempPassword(client, temp, options) {
|
|
273
|
+
if (typeof temp.password !== "string" || temp.password === "") {
|
|
274
|
+
throw new TypeError("a temporary password cannot be empty");
|
|
275
|
+
}
|
|
276
|
+
// tcid and tcpw are required on the wire, even for the default channel.
|
|
277
|
+
const fields = {
|
|
278
|
+
...temp,
|
|
279
|
+
targetChannelID: temp.targetChannelID ?? asChannelID(0),
|
|
280
|
+
targetChannelPassword: temp.targetChannelPassword ?? "",
|
|
281
|
+
};
|
|
282
|
+
await exec(client, "servertemppasswordadd", encodeFields(fields, tempPasswordNames), options, [
|
|
283
|
+
"tcpw",
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
/** Delete a temporary password. */
|
|
287
|
+
export async function deleteTempPassword(client, password, options) {
|
|
288
|
+
await exec(client, "servertemppassworddel", [["pw", password]], options);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/core/api/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,QAAQ,EAC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yB,EACzB,OAAwB;IAExB,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;QAC9D,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;IAC9D,CAAC;IACD,wEAAwE;IACxE,MAAM,MAAM,GAAwB;QAClC,GAAG,IAAI;QACP,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,WAAW,CAAC,CAAC,CAAC;QACvD,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,IAAI,EAAE;KACxD,CAAC;IACF,MAAM,IAAI,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,EAAE;QAC5F,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,mCAAmC;AACnC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAuB,EACvB,QAAgB,EAChB,OAAwB;IAExB,MAAM,IAAI,CAAC,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape a value for the command line: the characters that delimit a command
|
|
3
|
+
* (space, `|`, `/`, the backslash itself, control characters) become their
|
|
4
|
+
* two-character escapes.
|
|
5
|
+
*/
|
|
6
|
+
export declare function escape(s: string): string;
|
|
7
|
+
/** Undo {@link escape}, in one pass so that `\\s` comes back as `\s`, not a space. */
|
|
8
|
+
export declare function unescape(s: string): string;
|
|
9
|
+
/** A command line, parsed. */
|
|
10
|
+
export interface Command {
|
|
11
|
+
/** The command's name, or `""` for a data row, which carries no name. */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Its parameters, unescaped. A flag such as `-uid` maps to `""`. */
|
|
14
|
+
readonly params: Readonly<Record<string, string>>;
|
|
15
|
+
}
|
|
16
|
+
/** Build a command line from a parameter map; keys and values are escaped alike. */
|
|
17
|
+
export declare function buildCommand(cmd: string, params: Readonly<Record<string, string>>): string;
|
|
18
|
+
/** Build a TS3 command string preserving parameter order. */
|
|
19
|
+
export declare function buildCommandOrdered(cmd: string, params: ReadonlyArray<readonly [string, string]>): string;
|
|
20
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/core/command/command.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAMxC;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAgE1C;AAED,8BAA8B;AAC9B,MAAM,WAAW,OAAO;IACtB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAM1F;AAED,6DAA6D;AAC7D,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC/C,MAAM,CASR"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const ESCAPE_MAP = [
|
|
2
|
+
["\\", "\\\\"],
|
|
3
|
+
["/", "\\/"],
|
|
4
|
+
[" ", "\\s"],
|
|
5
|
+
["|", "\\p"],
|
|
6
|
+
["\x07", "\\a"],
|
|
7
|
+
["\x08", "\\b"],
|
|
8
|
+
["\x0C", "\\f"],
|
|
9
|
+
["\n", "\\n"],
|
|
10
|
+
["\r", "\\r"],
|
|
11
|
+
["\t", "\\t"],
|
|
12
|
+
["\x0B", "\\v"],
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Escape a value for the command line: the characters that delimit a command
|
|
16
|
+
* (space, `|`, `/`, the backslash itself, control characters) become their
|
|
17
|
+
* two-character escapes.
|
|
18
|
+
*/
|
|
19
|
+
export function escape(s) {
|
|
20
|
+
let result = s;
|
|
21
|
+
for (const [from, to] of ESCAPE_MAP) {
|
|
22
|
+
result = result.split(from).join(to);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
/** Undo {@link escape}, in one pass so that `\\s` comes back as `\s`, not a space. */
|
|
27
|
+
export function unescape(s) {
|
|
28
|
+
// Process escape sequences in a single pass to avoid double-substitution
|
|
29
|
+
let result = "";
|
|
30
|
+
let i = 0;
|
|
31
|
+
while (i < s.length) {
|
|
32
|
+
if (s[i] === "\\" && i + 1 < s.length) {
|
|
33
|
+
const next = s[i + 1];
|
|
34
|
+
switch (next) {
|
|
35
|
+
case "\\":
|
|
36
|
+
result += "\\";
|
|
37
|
+
i += 2;
|
|
38
|
+
break;
|
|
39
|
+
case "/":
|
|
40
|
+
result += "/";
|
|
41
|
+
i += 2;
|
|
42
|
+
break;
|
|
43
|
+
case "s":
|
|
44
|
+
result += " ";
|
|
45
|
+
i += 2;
|
|
46
|
+
break;
|
|
47
|
+
case "p":
|
|
48
|
+
result += "|";
|
|
49
|
+
i += 2;
|
|
50
|
+
break;
|
|
51
|
+
case "a":
|
|
52
|
+
result += "\x07";
|
|
53
|
+
i += 2;
|
|
54
|
+
break;
|
|
55
|
+
case "b":
|
|
56
|
+
result += "\x08";
|
|
57
|
+
i += 2;
|
|
58
|
+
break;
|
|
59
|
+
case "f":
|
|
60
|
+
result += "\x0C";
|
|
61
|
+
i += 2;
|
|
62
|
+
break;
|
|
63
|
+
case "n":
|
|
64
|
+
result += "\n";
|
|
65
|
+
i += 2;
|
|
66
|
+
break;
|
|
67
|
+
case "r":
|
|
68
|
+
result += "\r";
|
|
69
|
+
i += 2;
|
|
70
|
+
break;
|
|
71
|
+
case "t":
|
|
72
|
+
result += "\t";
|
|
73
|
+
i += 2;
|
|
74
|
+
break;
|
|
75
|
+
case "v":
|
|
76
|
+
result += "\x0B";
|
|
77
|
+
i += 2;
|
|
78
|
+
break;
|
|
79
|
+
case undefined:
|
|
80
|
+
default:
|
|
81
|
+
result += s[i] ?? "";
|
|
82
|
+
i++;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
result += s[i] ?? "";
|
|
88
|
+
i++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
/** Build a command line from a parameter map; keys and values are escaped alike. */
|
|
94
|
+
export function buildCommand(cmd, params) {
|
|
95
|
+
const parts = [escape(cmd)];
|
|
96
|
+
for (const [k, v] of Object.entries(params)) {
|
|
97
|
+
parts.push(`${escape(k)}=${escape(v)}`);
|
|
98
|
+
}
|
|
99
|
+
return parts.join(" ");
|
|
100
|
+
}
|
|
101
|
+
/** Build a TS3 command string preserving parameter order. */
|
|
102
|
+
export function buildCommandOrdered(cmd, params) {
|
|
103
|
+
const parts = [escape(cmd)];
|
|
104
|
+
for (const [k, v] of params) {
|
|
105
|
+
// A flag such as `-uid` is a bare switch. `-uid=1` happens to be accepted
|
|
106
|
+
// over the voice protocol, but it is not the documented form and nothing
|
|
107
|
+
// promises another transport tolerates it.
|
|
108
|
+
parts.push(k.startsWith("-") && v === "" ? escape(k) : `${escape(k)}=${escape(v)}`);
|
|
109
|
+
}
|
|
110
|
+
return parts.join(" ");
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/core/command/command.ts"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,YAAY,CAAC,GAAW,EAAE,MAAwC;IAChF,MAAM,KAAK,GAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,mBAAmB,CACjC,GAAW,EACX,MAAgD;IAEhD,MAAM,KAAK,GAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;QAC5B,0EAA0E;QAC1E,yEAAyE;QACzE,2CAA2C;QAC3C,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded identifiers.
|
|
3
|
+
*
|
|
4
|
+
* TeamSpeak uses one 64-bit integer space for several unrelated kinds of id, so
|
|
5
|
+
* a `bigint` alone cannot tell a channel from a client. Branding makes the
|
|
6
|
+
* mistake a compile error instead of a silent move-to-the-wrong-place, and the
|
|
7
|
+
* brands cost nothing at runtime.
|
|
8
|
+
*
|
|
9
|
+
* The ids the protocol defines as 32 bits or narrower — a clid, a permission,
|
|
10
|
+
* an icon — are `number` brands; the 64-bit ones are `bigint` brands.
|
|
11
|
+
*/
|
|
12
|
+
/** A channel (`cid`). */
|
|
13
|
+
export type ChannelID = bigint & {
|
|
14
|
+
readonly __brand: "ChannelID";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A connected client (`clid`): an id for this connection only, assigned anew
|
|
18
|
+
* every time the client connects.
|
|
19
|
+
*/
|
|
20
|
+
export type ClientID = number & {
|
|
21
|
+
readonly __brand: "ClientID";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A client's database record (`cldbid`): stable across connections, unlike its
|
|
25
|
+
* ClientID.
|
|
26
|
+
*/
|
|
27
|
+
export type ClientDBID = bigint & {
|
|
28
|
+
readonly __brand: "ClientDBID";
|
|
29
|
+
};
|
|
30
|
+
/** A server group (`sgid`). */
|
|
31
|
+
export type ServerGroupID = bigint & {
|
|
32
|
+
readonly __brand: "ServerGroupID";
|
|
33
|
+
};
|
|
34
|
+
/** A channel group (`cgid`). */
|
|
35
|
+
export type ChannelGroupID = bigint & {
|
|
36
|
+
readonly __brand: "ChannelGroupID";
|
|
37
|
+
};
|
|
38
|
+
/** A permission's numeric id (`permid`), a 32-bit value assigned by the server build. */
|
|
39
|
+
export type PermissionID = number & {
|
|
40
|
+
readonly __brand: "PermissionID";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* An icon: the unsigned CRC32 of the icon file, which also names the file
|
|
44
|
+
* (`/icon_<id>`) in the server's file area.
|
|
45
|
+
*/
|
|
46
|
+
export type IconID = number & {
|
|
47
|
+
readonly __brand: "IconID";
|
|
48
|
+
};
|
|
49
|
+
/** A ban (`banid`). */
|
|
50
|
+
export type BanID = bigint & {
|
|
51
|
+
readonly __brand: "BanID";
|
|
52
|
+
};
|
|
53
|
+
/** An offline message (`msgid`). */
|
|
54
|
+
export type MessageID = bigint & {
|
|
55
|
+
readonly __brand: "MessageID";
|
|
56
|
+
};
|
|
57
|
+
/** A virtual server on an instance (`sid`, `virtualserver_id`). */
|
|
58
|
+
export type ServerID = bigint & {
|
|
59
|
+
readonly __brand: "ServerID";
|
|
60
|
+
};
|
|
61
|
+
/** The client's id for a file transfer (`clientftfid`), a 16-bit value it chooses. */
|
|
62
|
+
export type ClientFileTransferID = number & {
|
|
63
|
+
readonly __brand: "ClientFileTransferID";
|
|
64
|
+
};
|
|
65
|
+
/** The server's id for a file transfer (`serverftfid`), a 16-bit value. */
|
|
66
|
+
export type ServerFileTransferID = number & {
|
|
67
|
+
readonly __brand: "ServerFileTransferID";
|
|
68
|
+
};
|
|
69
|
+
/** Brand a ban id, an integer from 0 to 2^64-1, from a number or a bigint. */
|
|
70
|
+
export declare const asBanID: (v: bigint | number) => BanID;
|
|
71
|
+
/** Brand an offline message id, an integer from 0 to 2^64-1. */
|
|
72
|
+
export declare const asMessageID: (v: bigint | number) => MessageID;
|
|
73
|
+
/** Brand a virtual server id, an integer from 0 to 2^64-1. */
|
|
74
|
+
export declare const asServerID: (v: bigint | number) => ServerID;
|
|
75
|
+
/** Brand the client's id for a file transfer, an integer from 0 to 65535. */
|
|
76
|
+
export declare const asClientFileTransferID: (v: number) => ClientFileTransferID;
|
|
77
|
+
/** Brand the server's id for a file transfer, an integer from 0 to 65535. */
|
|
78
|
+
export declare const asServerFileTransferID: (v: number) => ServerFileTransferID;
|
|
79
|
+
/** Brand a channel id, an integer from 0 to 2^64-1, from a number or a bigint. */
|
|
80
|
+
export declare const asChannelID: (v: bigint | number) => ChannelID;
|
|
81
|
+
/** Brand a client id, an integer from 0 to 65535: the voice protocol's width. */
|
|
82
|
+
export declare const asClientID: (v: number) => ClientID;
|
|
83
|
+
/** Brand a client database id, an integer from 0 to 2^64-1. */
|
|
84
|
+
export declare const asClientDBID: (v: bigint | number) => ClientDBID;
|
|
85
|
+
/** Brand a server group id, an integer from 0 to 2^64-1. */
|
|
86
|
+
export declare const asServerGroupID: (v: bigint | number) => ServerGroupID;
|
|
87
|
+
/** Brand a channel group id, an integer from 0 to 2^64-1. */
|
|
88
|
+
export declare const asChannelGroupID: (v: bigint | number) => ChannelGroupID;
|
|
89
|
+
/** Brand a permission id, an integer from 0 to 2^32-1. */
|
|
90
|
+
export declare const asPermissionID: (v: number) => PermissionID;
|
|
91
|
+
/**
|
|
92
|
+
* Brand an icon id, an integer from -2^31 to 2^32-1. A negative value is taken
|
|
93
|
+
* as the signed form of the same CRC32, which is how the server sometimes
|
|
94
|
+
* sends one, and stored unsigned.
|
|
95
|
+
*/
|
|
96
|
+
export declare const asIconID: (v: number) => IconID;
|
|
97
|
+
/**
|
|
98
|
+
* Read an icon id as the server sends it: the CRC32, sometimes as a negative
|
|
99
|
+
* 32-bit number, sometimes unsigned. Both name the same icon, so both come back
|
|
100
|
+
* as the unsigned value; 0, garbage and out-of-range values mean no icon.
|
|
101
|
+
*/
|
|
102
|
+
export declare function parseIconID(raw: string | undefined): IconID | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* A unique identifier: `base64(SHA-1(publicKey))` on TeamSpeak 3 and
|
|
105
|
+
* `base64(SHA-256(publicKey))` on TeamSpeak 6.
|
|
106
|
+
*
|
|
107
|
+
* The length differs between versions, so treat it as opaque bytes rather than
|
|
108
|
+
* assuming either width.
|
|
109
|
+
*/
|
|
110
|
+
export type UID = string & {
|
|
111
|
+
readonly __brand: "UID";
|
|
112
|
+
};
|
|
113
|
+
/** Brand a unique identifier. */
|
|
114
|
+
export declare const asUID: (v: string) => UID;
|
|
115
|
+
/**
|
|
116
|
+
* A channel's unique identifier (`channel_unique_identifier`), which TS6
|
|
117
|
+
* gives every channel and TS3 does not send. Opaque text, and not a client's
|
|
118
|
+
* {@link UID}.
|
|
119
|
+
*/
|
|
120
|
+
export type ChannelUID = string & {
|
|
121
|
+
readonly __brand: "ChannelUID";
|
|
122
|
+
};
|
|
123
|
+
/** Brand a channel's unique identifier. */
|
|
124
|
+
export declare const asChannelUID: (v: string) => ChannelUID;
|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