@honeybbq/teamspeak 1.0.0-beta.11 → 1.0.0-beta.13

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.
Files changed (187) hide show
  1. package/README.md +52 -7
  2. package/dist/client/api/voice.d.ts +13 -0
  3. package/dist/client/api/voice.d.ts.map +1 -1
  4. package/dist/client/api/voice.js +20 -1
  5. package/dist/client/api/voice.js.map +1 -1
  6. package/dist/client/capabilities.d.ts +4 -4
  7. package/dist/client/capabilities.d.ts.map +1 -1
  8. package/dist/client/capabilities.js +3 -8
  9. package/dist/client/capabilities.js.map +1 -1
  10. package/dist/client/client.d.ts.map +1 -1
  11. package/dist/client/client.js +120 -18
  12. package/dist/client/client.js.map +1 -1
  13. package/dist/client/crypto/crypt.d.ts +25 -4
  14. package/dist/client/crypto/crypt.d.ts.map +1 -1
  15. package/dist/client/crypto/crypt.js +41 -9
  16. package/dist/client/crypto/crypt.js.map +1 -1
  17. package/dist/client/crypto/identity.d.ts +2 -0
  18. package/dist/client/crypto/identity.d.ts.map +1 -1
  19. package/dist/client/crypto/identity.js +2 -2
  20. package/dist/client/crypto/identity.js.map +1 -1
  21. package/dist/client/crypto/index.d.ts +1 -1
  22. package/dist/client/crypto/index.d.ts.map +1 -1
  23. package/dist/client/crypto/index.js +1 -1
  24. package/dist/client/crypto/index.js.map +1 -1
  25. package/dist/client/errors.d.ts +14 -0
  26. package/dist/client/errors.d.ts.map +1 -1
  27. package/dist/client/errors.js +28 -0
  28. package/dist/client/errors.js.map +1 -1
  29. package/dist/client/handshake/crypt-handshake.d.ts +8 -2
  30. package/dist/client/handshake/crypt-handshake.d.ts.map +1 -1
  31. package/dist/client/handshake/crypt-handshake.js +26 -20
  32. package/dist/client/handshake/crypt-handshake.js.map +1 -1
  33. package/dist/client/index.d.ts +3 -3
  34. package/dist/client/index.d.ts.map +1 -1
  35. package/dist/client/index.js +2 -2
  36. package/dist/client/index.js.map +1 -1
  37. package/dist/client/trace.d.ts +7 -0
  38. package/dist/client/trace.d.ts.map +1 -1
  39. package/dist/client/transport/handler.d.ts +2 -0
  40. package/dist/client/transport/handler.d.ts.map +1 -1
  41. package/dist/client/transport/handler.js +4 -0
  42. package/dist/client/transport/handler.js.map +1 -1
  43. package/dist/client/types.d.ts +25 -3
  44. package/dist/client/types.d.ts.map +1 -1
  45. package/dist/client/types.js +4 -0
  46. package/dist/client/types.js.map +1 -1
  47. package/dist/client/view.d.ts +71 -4
  48. package/dist/client/view.d.ts.map +1 -1
  49. package/dist/client/view.js +165 -5
  50. package/dist/client/view.js.map +1 -1
  51. package/dist/core/api/channels.d.ts +7 -3
  52. package/dist/core/api/channels.d.ts.map +1 -1
  53. package/dist/core/api/channels.js +5 -3
  54. package/dist/core/api/channels.js.map +1 -1
  55. package/dist/core/api/clients.d.ts +38 -1
  56. package/dist/core/api/clients.d.ts.map +1 -1
  57. package/dist/core/api/clients.js +33 -2
  58. package/dist/core/api/clients.js.map +1 -1
  59. package/dist/core/api/command.d.ts +18 -1
  60. package/dist/core/api/command.d.ts.map +1 -1
  61. package/dist/core/api/command.js +7 -1
  62. package/dist/core/api/command.js.map +1 -1
  63. package/dist/core/api/group-rows.d.ts +12 -0
  64. package/dist/core/api/group-rows.d.ts.map +1 -0
  65. package/dist/core/api/group-rows.js +34 -0
  66. package/dist/core/api/group-rows.js.map +1 -0
  67. package/dist/core/api/groups.d.ts.map +1 -1
  68. package/dist/core/api/groups.js +2 -13
  69. package/dist/core/api/groups.js.map +1 -1
  70. package/dist/core/api/instance.d.ts +10 -2
  71. package/dist/core/api/instance.d.ts.map +1 -1
  72. package/dist/core/api/instance.js +6 -2
  73. package/dist/core/api/instance.js.map +1 -1
  74. package/dist/core/api/moderation.d.ts +7 -0
  75. package/dist/core/api/moderation.d.ts.map +1 -1
  76. package/dist/core/api/moderation.js +7 -0
  77. package/dist/core/api/moderation.js.map +1 -1
  78. package/dist/core/api/parse.d.ts.map +1 -1
  79. package/dist/core/api/parse.js +1 -0
  80. package/dist/core/api/parse.js.map +1 -1
  81. package/dist/core/api/server.d.ts +9 -0
  82. package/dist/core/api/server.d.ts.map +1 -1
  83. package/dist/core/api/server.js +5 -13
  84. package/dist/core/api/server.js.map +1 -1
  85. package/dist/core/command/responses.d.ts.map +1 -1
  86. package/dist/core/command/responses.js +1 -0
  87. package/dist/core/command/responses.js.map +1 -1
  88. package/dist/core/errorcode.d.ts +16 -0
  89. package/dist/core/errorcode.d.ts.map +1 -1
  90. package/dist/core/errorcode.js +16 -0
  91. package/dist/core/errorcode.js.map +1 -1
  92. package/dist/core/events.d.ts +67 -6
  93. package/dist/core/events.d.ts.map +1 -1
  94. package/dist/core/index.d.ts +2 -2
  95. package/dist/core/index.d.ts.map +1 -1
  96. package/dist/core/index.js +1 -1
  97. package/dist/core/index.js.map +1 -1
  98. package/dist/core/internal.d.ts +1 -0
  99. package/dist/core/internal.d.ts.map +1 -1
  100. package/dist/core/internal.js +1 -0
  101. package/dist/core/internal.js.map +1 -1
  102. package/dist/core/notification-name.d.ts +4 -0
  103. package/dist/core/notification-name.d.ts.map +1 -1
  104. package/dist/core/notification-name.js +4 -0
  105. package/dist/core/notification-name.js.map +1 -1
  106. package/dist/core/notifications.d.ts +6 -2
  107. package/dist/core/notifications.d.ts.map +1 -1
  108. package/dist/core/notifications.js +32 -1
  109. package/dist/core/notifications.js.map +1 -1
  110. package/dist/core/types.d.ts +7 -0
  111. package/dist/core/types.d.ts.map +1 -1
  112. package/dist/core/types.js +16 -0
  113. package/dist/core/types.js.map +1 -1
  114. package/dist/query/client.d.ts +16 -7
  115. package/dist/query/client.d.ts.map +1 -1
  116. package/dist/query/client.js +55 -20
  117. package/dist/query/client.js.map +1 -1
  118. package/dist/query/errors.d.ts +21 -0
  119. package/dist/query/errors.d.ts.map +1 -1
  120. package/dist/query/errors.js +34 -0
  121. package/dist/query/errors.js.map +1 -1
  122. package/dist/query/index.d.ts +4 -3
  123. package/dist/query/index.d.ts.map +1 -1
  124. package/dist/query/index.js +3 -2
  125. package/dist/query/index.js.map +1 -1
  126. package/dist/query/options.d.ts +32 -19
  127. package/dist/query/options.d.ts.map +1 -1
  128. package/dist/query/options.js +21 -16
  129. package/dist/query/options.js.map +1 -1
  130. package/dist/query/ssh.d.ts +3 -1
  131. package/dist/query/ssh.d.ts.map +1 -1
  132. package/dist/query/ssh.js +4 -1
  133. package/dist/query/ssh.js.map +1 -1
  134. package/dist/query/stream.d.ts +16 -3
  135. package/dist/query/stream.d.ts.map +1 -1
  136. package/dist/query/stream.js +57 -6
  137. package/dist/query/stream.js.map +1 -1
  138. package/dist/query/tcp.js +1 -1
  139. package/dist/query/tcp.js.map +1 -1
  140. package/dist/query/transport.d.ts +39 -3
  141. package/dist/query/transport.d.ts.map +1 -1
  142. package/dist/query/web.d.ts +25 -7
  143. package/dist/query/web.d.ts.map +1 -1
  144. package/dist/query/web.js +40 -10
  145. package/dist/query/web.js.map +1 -1
  146. package/package.json +6 -5
  147. package/src/client/api/voice.ts +25 -1
  148. package/src/client/capabilities.ts +14 -11
  149. package/src/client/client.ts +128 -14
  150. package/src/client/crypto/crypt.ts +46 -9
  151. package/src/client/crypto/identity.ts +2 -2
  152. package/src/client/crypto/index.ts +1 -0
  153. package/src/client/errors.ts +31 -0
  154. package/src/client/handshake/crypt-handshake.ts +51 -16
  155. package/src/client/index.ts +4 -1
  156. package/src/client/trace.ts +7 -0
  157. package/src/client/transport/handler.ts +5 -0
  158. package/src/client/types.ts +25 -1
  159. package/src/client/view.ts +227 -8
  160. package/src/core/api/channels.ts +9 -3
  161. package/src/core/api/clients.ts +73 -2
  162. package/src/core/api/command.ts +22 -1
  163. package/src/core/api/group-rows.ts +38 -0
  164. package/src/core/api/groups.ts +1 -14
  165. package/src/core/api/instance.ts +20 -2
  166. package/src/core/api/moderation.ts +7 -0
  167. package/src/core/api/parse.ts +1 -0
  168. package/src/core/api/server.ts +13 -15
  169. package/src/core/command/responses.ts +1 -0
  170. package/src/core/errorcode.ts +16 -0
  171. package/src/core/events.ts +68 -6
  172. package/src/core/index.ts +2 -1
  173. package/src/core/internal.ts +1 -0
  174. package/src/core/notification-name.ts +4 -0
  175. package/src/core/notifications.ts +48 -17
  176. package/src/core/types.ts +14 -0
  177. package/src/query/client.ts +63 -20
  178. package/src/query/errors.ts +37 -0
  179. package/src/query/index.ts +9 -3
  180. package/src/query/options.ts +53 -33
  181. package/src/query/ssh.ts +9 -2
  182. package/src/query/stream.ts +65 -7
  183. package/src/query/tcp.ts +1 -1
  184. package/src/query/testing/live.ts +311 -0
  185. package/src/query/testing/ssh-keys.ts +67 -0
  186. package/src/query/transport.ts +40 -3
  187. package/src/query/web.ts +65 -16
@@ -19,7 +19,6 @@ import {
19
19
  big,
20
20
  num,
21
21
  bool,
22
- icon,
23
22
  date,
24
23
  } from "./command.js";
25
24
  import type { Params, PermissionEntry, WireNames } from "./command.js";
@@ -39,6 +38,7 @@ import {
39
38
  asPermissionID,
40
39
  asServerGroupID,
41
40
  } from "../command/ids.js";
41
+ import { parseChannelGroup } from "./group-rows.js";
42
42
  import { PermissionTarget, PrivilegeKeyType } from "../enums.js";
43
43
  import type { GroupType } from "../enums.js";
44
44
  import type { Permission } from "../permission.js";
@@ -69,19 +69,6 @@ export interface ChannelGroup {
69
69
  readonly memberRemovePower: number;
70
70
  }
71
71
 
72
- const parseChannelGroup = (row: Record<string, string>): ChannelGroup => ({
73
- id: asChannelGroupID(big(row, "cgid")),
74
- name: str(row, "name"),
75
- type: num(row, "type"),
76
- iconID: icon(row, "iconid"),
77
- savedInDatabase: bool(row, "savedb"),
78
- sortID: num(row, "sortid"),
79
- nameMode: num(row, "namemode"),
80
- modifyPower: num(row, "n_modifyp"),
81
- memberAddPower: num(row, "n_member_addp"),
82
- memberRemovePower: num(row, "n_member_removep"),
83
- });
84
-
85
72
  /** Every channel group. */
86
73
  export async function listChannelGroups(
87
74
  client: CommandExecutor,
@@ -60,6 +60,14 @@ export interface VirtualServer {
60
60
  readonly machineID: string | undefined;
61
61
  /** Its unique identifier, with `uid`; "" otherwise (`virtualserver_unique_identifier`). */
62
62
  readonly uid: string;
63
+ /** Its UUID, with `uid`; TS6 only (`virtualserver_uuid`). */
64
+ readonly uuid?: string | undefined;
65
+ /** Whether guests may create channels; TS6 only (`guest_can_create_channels`). */
66
+ readonly guestCanCreateChannels?: boolean | undefined;
67
+ /** Whether guests may create a homebase; TS6 only (`guest_can_create_homebase`). */
68
+ readonly guestCanCreateHomebase?: boolean | undefined;
69
+ /** Whether the server is on the public server list; TS6 only (`virtualserver_weblist_enabled`). */
70
+ readonly weblistEnabled?: boolean | undefined;
63
71
  }
64
72
 
65
73
  const optional = <T>(row: Record<string, string>, key: string, read: () => T): T | undefined =>
@@ -83,6 +91,16 @@ const parseVirtualServer = (row: Record<string, string>): VirtualServer => ({
83
91
  autoStart: optional(row, "virtualserver_autostart", () => bool(row, "virtualserver_autostart")),
84
92
  machineID: row["virtualserver_machine_id"],
85
93
  uid: str(row, "virtualserver_unique_identifier"),
94
+ uuid: row["virtualserver_uuid"],
95
+ guestCanCreateChannels: optional(row, "guest_can_create_channels", () =>
96
+ bool(row, "guest_can_create_channels"),
97
+ ),
98
+ guestCanCreateHomebase: optional(row, "guest_can_create_homebase", () =>
99
+ bool(row, "guest_can_create_homebase"),
100
+ ),
101
+ weblistEnabled: optional(row, "virtualserver_weblist_enabled", () =>
102
+ bool(row, "virtualserver_weblist_enabled"),
103
+ ),
86
104
  });
87
105
 
88
106
  /** Which servers {@link listServers} reports, and with what. */
@@ -109,8 +127,8 @@ const serverListFlags: WireNames<ServerListOptions> = {
109
127
  *
110
128
  * Needs `b_serverinstance_virtualserver_list`, which a voice client's Server
111
129
  * Admin lacks (error 2568). TS6 also reports `guest_can_create_channels`,
112
- * `guest_can_create_homebase` and `virtualserver_weblist_enabled`, which are
113
- * not read here.
130
+ * `guest_can_create_homebase` and `virtualserver_weblist_enabled`, and its
131
+ * UUID with `uid`; TS3 sends none of them.
114
132
  */
115
133
  export async function listServers(
116
134
  client: CommandExecutor,
@@ -247,6 +247,13 @@ export async function addBan(
247
247
  * uid, and on TS6 its myTeamSpeak id — and over ServerQuery answers one
248
248
  * `banid` row for each; returning the first left the others to be found by
249
249
  * hand. The voice protocol reports no ids, so there this resolves to `[]`.
250
+ *
251
+ * Measured on TS3 3.13.8 and TS6 beta13.1: two bans, one for the uid and one
252
+ * for the address. TS6 has also answered with no `banid` at all though both
253
+ * bans were made (about once in a hundred calls over SSH and WebQuery), so an
254
+ * empty result does not mean no ban. A caller that must undo the ban lists the
255
+ * bans before and after and removes what is new: a ban on the address refuses
256
+ * every later connection from it.
250
257
  */
251
258
  export async function banClient(
252
259
  client: CommandExecutor,
@@ -89,6 +89,7 @@ export const clientFields: {
89
89
  talkPower: { keys: ["client_talk_power"], read: num },
90
90
  // The wire value is when the request was made; any non-zero is a request.
91
91
  isRequestingTalk: flag("client_talk_request"),
92
+ talkRequestedAt: { keys: ["client_talk_request"], read: date },
92
93
  talkRequestMessage: text("client_talk_request_msg"),
93
94
  description: text("client_description"),
94
95
  metaData: text("client_meta_data"),
@@ -24,8 +24,6 @@ import {
24
24
  str,
25
25
  big,
26
26
  num,
27
- bool,
28
- icon,
29
27
  date,
30
28
  durationMs,
31
29
  SECOND,
@@ -51,6 +49,7 @@ import {
51
49
  } from "../command/ids.js";
52
50
  import type { GroupAutoUpdateType, GroupType } from "../enums.js";
53
51
  import type { GroupDeleteOptions } from "./groups.js";
52
+ import { parseServerGroup } from "./group-rows.js";
54
53
  import type { Permission } from "../permission.js";
55
54
 
56
55
  /** A server group as `servergrouplist` reports it. */
@@ -77,19 +76,6 @@ export interface ServerGroup {
77
76
  readonly memberRemovePower: number;
78
77
  }
79
78
 
80
- const parseServerGroup = (row: Record<string, string>): ServerGroup => ({
81
- id: asServerGroupID(big(row, "sgid")),
82
- name: str(row, "name"),
83
- type: num(row, "type"),
84
- iconID: icon(row, "iconid"),
85
- savedInDatabase: bool(row, "savedb"),
86
- sortID: num(row, "sortid"),
87
- nameMode: num(row, "namemode"),
88
- modifyPower: num(row, "n_modifyp"),
89
- memberAddPower: num(row, "n_member_addp"),
90
- memberRemovePower: num(row, "n_member_removep"),
91
- });
92
-
93
79
  /** Every server group. */
94
80
  export async function listServerGroups(
95
81
  client: CommandExecutor,
@@ -264,6 +250,10 @@ export interface WhoAmI {
264
250
  * it.
265
251
  */
266
252
  readonly uid: UID;
253
+ /** The virtual server's UUID (`virtualserver_uuid`); TS6 only, undefined when not sent. */
254
+ readonly serverUUID?: string | undefined;
255
+ /** The server this client first connected to (`client_origin_server_id`); 0 when not sent. */
256
+ readonly originServerID: ServerID;
267
257
  }
268
258
 
269
259
  /** Which server and client this connection is, as the server sees it. */
@@ -280,6 +270,8 @@ export async function whoAmI(client: CommandExecutor, options?: CommandOptions):
280
270
  databaseID: asClientDBID(big(row, "client_database_id")),
281
271
  loginName: str(row, "client_login_name"),
282
272
  uid: asUID(str(row, "client_unique_identifier")),
273
+ serverUUID: row["virtualserver_uuid"],
274
+ originServerID: asServerID(big(row, "client_origin_server_id")),
283
275
  };
284
276
  }
285
277
 
@@ -688,6 +680,11 @@ export interface TempPassword {
688
680
  readonly endsAt: Date | undefined;
689
681
  /** The channel a client joining with it lands in, or 0 for the default channel. */
690
682
  readonly targetChannelID: ChannelID;
683
+ /**
684
+ * That channel's password, in cleartext (`tcpw`); "" for none. A secret like
685
+ * `password`: store it where it is needed, and do not log it.
686
+ */
687
+ readonly targetChannelPassword: string;
691
688
  }
692
689
 
693
690
  /** The server's temporary passwords. */
@@ -704,6 +701,7 @@ export async function listTempPasswords(
704
701
  startsAt: date(row, "start"),
705
702
  endsAt: date(row, "end"),
706
703
  targetChannelID: asChannelID(big(row, "tcid")),
704
+ targetChannelPassword: str(row, "tcpw"),
707
705
  }));
708
706
  }
709
707
 
@@ -88,6 +88,7 @@ const fileTransfer = (answer: string): ResponseSpec => ({
88
88
  export const RESPONSES: Readonly<Record<string, ResponseSpec>> = {
89
89
  apikeyadd: inline("notifyapikeyadd"),
90
90
  apikeylist: inline("notifyapikeylist"),
91
+ banfind: inline("notifybanfind"),
91
92
  banlist: inline("notifybanlist"),
92
93
  channelclientpermlist: inline("notifychannelclientpermlist"),
93
94
  channelcreate: { notifications: ["notifychannelcreated"], ownRowsOnly: true },
@@ -392,6 +392,22 @@ const errorCodeValues = {
392
392
  ProvisioningTS3ServerNotFound: 0x1119,
393
393
  /** Unknown permissionID. */
394
394
  ProvisioningNoPermission: 0x111a,
395
+ /**
396
+ * Out of scope: WebQuery refused a command outside the scope of the api key
397
+ * that made the request, or outside the guest scope of a request that carried
398
+ * none. HTTP 401.
399
+ */
400
+ APIKeyOutOfScope: 0x1400,
401
+ /**
402
+ * Invalid apikey: WebQuery does not accept the api key sent, or the key may
403
+ * not address the virtual server in the path. HTTP 401.
404
+ */
405
+ APIKeyInvalid: 0x1402,
406
+ /**
407
+ * Missing apikey: the request carried no api key, or an empty one, and the
408
+ * server offers no guest access. HTTP 401.
409
+ */
410
+ APIKeyMissing: 0x1404,
395
411
  } as const;
396
412
  /**
397
413
  * The error codes a TeamSpeak server reports, by name.
@@ -5,7 +5,7 @@
5
5
 
6
6
  import type { ChannelGroupID, ChannelID, ClientID, ServerGroupID, UID } from "./command/ids.js";
7
7
  import type { ClientChanges, ClientEntry } from "./api/clients.js";
8
- import type { ChannelChanges } from "./api/command.js";
8
+ import type { Channel, ChannelChanges } from "./api/command.js";
9
9
  import type { NotificationName } from "./notification-name.js";
10
10
 
11
11
  /** A text message, sent privately, to a channel, or to the whole server. */
@@ -44,6 +44,11 @@ export interface ClientMovedEvent {
44
44
  readonly invokerUID: UID;
45
45
  /** The channel the client is now in. */
46
46
  readonly targetChannelID: ChannelID;
47
+ /**
48
+ * The channel the client came from (`cfid`). Absent when the server sends
49
+ * none: TS3 3.13.8 sends no `cfid` on a move, TS6 6.0.0-beta13.1 does.
50
+ */
51
+ readonly fromChannelID?: ChannelID | undefined;
47
52
  /** Why the client moved; compare it with `Reason`. */
48
53
  readonly reason: number;
49
54
  /** The message that came with the move, such as a channel kick's reason; "" when none. */
@@ -65,12 +70,30 @@ export interface ClientLeaveEvent {
65
70
  readonly reason: number;
66
71
  /** The client that left. */
67
72
  readonly clientID: ClientID;
73
+ /**
74
+ * The channel the client was in (`cfid`); absent when the server sent none.
75
+ * Both servers sent it on every leave measured.
76
+ */
77
+ readonly fromChannelID?: ChannelID | undefined;
78
+ /**
79
+ * The channel the client went to (`ctid`), named as on the move event; 0
80
+ * when it left the server, and absent when the server sent none.
81
+ */
82
+ readonly targetChannelID?: ChannelID | undefined;
68
83
  /** Who kicked or banned the client; empty otherwise. */
69
84
  readonly invokerName: string;
70
85
  /** The kicker's unique identifier; empty unless kicked or banned. */
71
86
  readonly invokerUID: UID;
72
87
  /** The kicker; 0 unless kicked or banned. */
73
88
  readonly invokerID: ClientID;
89
+ /**
90
+ * The client's record as the voice client held it just before it left, so a
91
+ * listener can name who left. Absent when the client never announced it, and
92
+ * always absent on a ServerQuery client, which keeps no such record.
93
+ *
94
+ * @experimental New in 1.x and may change in a minor release.
95
+ */
96
+ readonly previous?: ClientEntry | undefined;
74
97
  }
75
98
 
76
99
  /** This client being kicked from its channel or the server. */
@@ -88,12 +111,28 @@ export interface KickedEvent {
88
111
  }
89
112
 
90
113
  /**
91
- * A client coming into view: the same record `listClients` returns, so one
92
- * type describes a client however it was learned of; its own id is `id`, as
93
- * in every record. The fields only `clientlist -times` reports are undefined
94
- * here.
114
+ * A client coming into view: the record `listClients` returns, so one type
115
+ * describes a client however it was learned of, with what only the
116
+ * notification says. Its own id is `id`, as in every record. The fields only
117
+ * `clientlist -times` reports are undefined here.
118
+ *
119
+ * `fromChannelID` and `reason` belong to the event: the roster and
120
+ * `view.clients` keep the record without them.
95
121
  */
96
- export type ClientEnterEvent = ClientEntry;
122
+ export interface ClientEnterEvent extends ClientEntry {
123
+ /**
124
+ * The channel the client came from (`cfid`); 0 for a client that joined the
125
+ * server, and absent when the server sent none. Measured on TS3 3.13.8 and
126
+ * TS6 6.0.0-beta13.1: 0 on a join and on a client listed by a subscription.
127
+ */
128
+ readonly fromChannelID?: ChannelID | undefined;
129
+ /**
130
+ * Why the client came into view (`reasonid`); compare it with `Reason`.
131
+ * Measured on both servers: 0 on a join, 2 (`Reason.Subscription`) for a
132
+ * client that was already there and came into view by a subscription.
133
+ */
134
+ readonly reason?: number | undefined;
135
+ }
97
136
 
98
137
  /** This client being poked. */
99
138
  export interface PokeEvent {
@@ -217,6 +256,17 @@ export interface ChannelMovedEvent extends Invoked {
217
256
  export interface ChannelDeletedEvent extends Invoked {
218
257
  /** The channel that was deleted. */
219
258
  readonly channelID: ChannelID;
259
+ /**
260
+ * The channel as the voice client's view held it just before the deletion
261
+ * (its `order` derived, its client counts `undefined`), so a listener can name
262
+ * what went. Absent when the view did not hold it, such as before the view is
263
+ * live, and always absent on a ServerQuery client, which has no view. A
264
+ * channel deleted with its children gives one event per child, children
265
+ * first, each with its own record.
266
+ *
267
+ * @experimental New in 1.x and may change in a minor release.
268
+ */
269
+ readonly previous?: Channel | undefined;
220
270
  }
221
271
 
222
272
  /**
@@ -292,6 +342,18 @@ export interface ClientChatComposingEvent {
292
342
  readonly uid: UID;
293
343
  }
294
344
 
345
+ /**
346
+ * A client closed its private chat with this client. It is delivered only to a
347
+ * client the sender has sent a private message to. Delivered by the voice
348
+ * client only.
349
+ */
350
+ export interface ClientChatClosedEvent {
351
+ /** The client that closed the chat. */
352
+ readonly clientID: ClientID;
353
+ /** Its unique identifier. */
354
+ readonly uid: UID;
355
+ }
356
+
295
357
  /** Audio from another client, in the channel or whispered. */
296
358
  export interface VoiceDataEvent {
297
359
  /** Who is speaking. */
package/src/core/index.ts CHANGED
@@ -88,7 +88,7 @@ export { NotificationName } from "./notification-name.js";
88
88
  export { PropertyName } from "./property-name.js";
89
89
  export type { Permission } from "./permission.js";
90
90
 
91
- export { noopLogger, consoleLogger, ClientStatus } from "./types.js";
91
+ export { noopLogger, consoleLogger, ClientStatus, serverFamilyForVersion } from "./types.js";
92
92
  export type {
93
93
  ClientVersion,
94
94
  Listener,
@@ -118,6 +118,7 @@ export type {
118
118
  ChannelUnsubscribedEvent,
119
119
  PluginCommandEvent,
120
120
  ClientChatComposingEvent,
121
+ ClientChatClosedEvent,
121
122
  ClientUpdatedEvent,
122
123
  ClientServerGroupEvent,
123
124
  ClientServerGroupAddedEvent,
@@ -14,6 +14,7 @@ export { buildCommand, buildCommandOrdered } from "./command/command.js";
14
14
  export type { Command } from "./command/command.js";
15
15
  export { clientFields, parseClient, parseClientChanges } from "./api/parse.js";
16
16
  export { channelFields, parseChannel, parseChannelChanges } from "./api/command.js";
17
+ export { parseServerGroup, parseChannelGroup } from "./api/group-rows.js";
17
18
  export { handleNotification } from "./notifications.js";
18
19
  export type { NotificationResult } from "./notifications.js";
19
20
  export { parseIconID } from "./command/ids.js";
@@ -17,8 +17,12 @@ const notificationNameValues = {
17
17
  APIKeyAdd: "notifyapikeyadd",
18
18
  /** `notifyapikeylist`: Reply to apikeylist: one row per API key. */
19
19
  APIKeyList: "notifyapikeylist",
20
+ /** `notifybanfind`: Reply to banfind: one row per ban rule that matches. */
21
+ BanFind: "notifybanfind",
20
22
  /** `notifybanlist`: Reply to banlist: one row per ban rule on the virtual server. */
21
23
  BanList: "notifybanlist",
24
+ /** `notifybanupdate`: A ban changed; sent to a ServerQuery connection registered for `bans`. An addition carries the ban row, a deletion its `banid`, a delete-all neither (TS6 6.0.0-beta13.1, `op` says which). */
25
+ BanUpdate: "notifybanupdate",
22
26
  /** `notifychannelchanged`: A channel's properties changed and this client should fetch them again. */
23
27
  ChannelChanged: "notifychannelchanged",
24
28
  /** `notifychannelclientpermlist`: Reply to channelclientpermlist: one row per permission set for a client in a channel. */
@@ -24,6 +24,8 @@ import { Reason } from "./reason.js";
24
24
  import { applyClientChanges } from "./api/clients.js";
25
25
  import { parseInt10, parseUint16, parseUint64 } from "./helpers.js";
26
26
  import type { Command } from "./command/command.js";
27
+ import type { ChannelID } from "./command/ids.js";
28
+ import type { ClientEntry } from "./api/clients.js";
27
29
  import type {
28
30
  ChannelCreatedEvent,
29
31
  ChannelDeletedEvent,
@@ -33,6 +35,7 @@ import type {
33
35
  ChannelPasswordChangedEvent,
34
36
  ChannelSubscribedEvent,
35
37
  ChannelUnsubscribedEvent,
38
+ ClientChatClosedEvent,
36
39
  ClientChatComposingEvent,
37
40
  ClientEnterEvent,
38
41
  ClientChannelGroupChangedEvent,
@@ -70,6 +73,7 @@ export type NotificationResult =
70
73
  | { kind: "channelUnsubscribed"; event: ChannelUnsubscribedEvent }
71
74
  | { kind: "pluginCommand"; event: PluginCommandEvent }
72
75
  | { kind: "clientChatComposing"; event: ClientChatComposingEvent }
76
+ | { kind: "clientChatClosed"; event: ClientChatClosedEvent }
73
77
  | { kind: "unknown" };
74
78
 
75
79
  /**
@@ -87,7 +91,7 @@ export type NotificationResult =
87
91
  export function handleNotification(
88
92
  cmd: Command,
89
93
  selfCLID: number,
90
- clients: Map<number, ClientEnterEvent>,
94
+ clients: Map<number, ClientEntry>,
91
95
  ): NotificationResult {
92
96
  switch (cmd.name) {
93
97
  case "notifycliententerview":
@@ -137,6 +141,8 @@ export function handleNotification(
137
141
  };
138
142
  case "notifyclientchatcomposing":
139
143
  return handleChatComposing(cmd);
144
+ case "notifyclientchatclosed":
145
+ return handleChatClosed(cmd);
140
146
  default:
141
147
  return { kind: "unknown" };
142
148
  }
@@ -144,19 +150,41 @@ export function handleNotification(
144
150
 
145
151
  function handleClientEnterView(
146
152
  cmd: Command,
147
- clients: Map<number, ClientEnterEvent>,
153
+ clients: Map<number, ClientEntry>,
148
154
  ): NotificationResult {
149
155
  const info = parseClient(cmd.params);
150
156
  // No client has id 0: a row without one describes nobody.
151
157
  if (info.id === 0) return { kind: "unknown" };
158
+ // The roster keeps the record alone; the event adds where it came from and why.
152
159
  clients.set(info.id, info);
153
- return { kind: "clientEnter", info };
160
+ return {
161
+ kind: "clientEnter",
162
+ info: {
163
+ ...info,
164
+ ...channelOf(cmd.params, "cfid", "fromChannelID"),
165
+ ...(cmd.params["reasonid"] === undefined
166
+ ? {}
167
+ : { reason: parseInt10(cmd.params["reasonid"]) }),
168
+ },
169
+ };
170
+ }
171
+
172
+ /** A channel id the row names under `key`, as `{ [name]: id }`; nothing when the row lacks the key. */
173
+ function channelOf<N extends string>(
174
+ params: Readonly<Record<string, string>>,
175
+ key: string,
176
+ name: N,
177
+ ): { [K in N]?: ChannelID } {
178
+ const raw = params[key];
179
+ return raw === undefined
180
+ ? {}
181
+ : ({ [name]: asChannelID(parseUint64(raw)) } as { [K in N]?: ChannelID });
154
182
  }
155
183
 
156
184
  function handleClientLeftView(
157
185
  cmd: Command,
158
186
  selfCLID: number,
159
- clients: Map<number, ClientEnterEvent>,
187
+ clients: Map<number, ClientEntry>,
160
188
  ): NotificationResult {
161
189
  const clid = asClientID(parseUint16(cmd.params["clid"] ?? ""));
162
190
  if (clid === 0) return { kind: "unknown" };
@@ -166,6 +194,8 @@ function handleClientLeftView(
166
194
  kind: "clientLeave",
167
195
  event: {
168
196
  clientID: clid,
197
+ ...channelOf(cmd.params, "cfid", "fromChannelID"),
198
+ ...channelOf(cmd.params, "ctid", "targetChannelID"),
169
199
  reason: parseInt10(cmd.params["reasonid"] ?? ""),
170
200
  reasonMessage: cmd.params["reasonmsg"] ?? "",
171
201
  invokerID: asClientID(parseUint16(cmd.params["invokerid"] ?? "")),
@@ -176,10 +206,7 @@ function handleClientLeftView(
176
206
  };
177
207
  }
178
208
 
179
- function handleClientMoved(
180
- cmd: Command,
181
- clients: Map<number, ClientEnterEvent>,
182
- ): NotificationResult {
209
+ function handleClientMoved(cmd: Command, clients: Map<number, ClientEntry>): NotificationResult {
183
210
  const clid = asClientID(parseUint16(cmd.params["clid"] ?? ""));
184
211
  const ctid = asChannelID(parseUint64(cmd.params["ctid"] ?? ""));
185
212
  if (clid === 0) return { kind: "unknown" };
@@ -197,6 +224,7 @@ function handleClientMoved(
197
224
  event: {
198
225
  clientID: clid,
199
226
  targetChannelID: ctid,
227
+ ...channelOf(cmd.params, "cfid", "fromChannelID"),
200
228
  reason: parseInt10(cmd.params["reasonid"] ?? ""),
201
229
  reasonMessage: cmd.params["reasonmsg"] ?? "",
202
230
  invokerID,
@@ -206,10 +234,7 @@ function handleClientMoved(
206
234
  };
207
235
  }
208
236
 
209
- function handleTextMessage(
210
- cmd: Command,
211
- clients: Map<number, ClientEnterEvent>,
212
- ): NotificationResult {
237
+ function handleTextMessage(cmd: Command, clients: Map<number, ClientEntry>): NotificationResult {
213
238
  const invokerID = asClientID(parseUint16(cmd.params["invokerid"] ?? ""));
214
239
  const invokerInfo = clients.get(invokerID);
215
240
 
@@ -246,10 +271,7 @@ function invoked(params: Readonly<Record<string, string>>): Invoked {
246
271
  };
247
272
  }
248
273
 
249
- function handleClientUpdated(
250
- cmd: Command,
251
- clients: Map<number, ClientEnterEvent>,
252
- ): NotificationResult {
274
+ function handleClientUpdated(cmd: Command, clients: Map<number, ClientEntry>): NotificationResult {
253
275
  const clid = asClientID(parseUint16(cmd.params["clid"] ?? ""));
254
276
  if (clid === 0) return { kind: "unknown" };
255
277
  const changes = parseClientChanges(cmd.params);
@@ -282,7 +304,7 @@ function handleServerGroupMember(
282
304
 
283
305
  function handleClientChannelGroupChanged(
284
306
  cmd: Command,
285
- clients: Map<number, ClientEnterEvent>,
307
+ clients: Map<number, ClientEntry>,
286
308
  ): NotificationResult {
287
309
  const clid = asClientID(parseUint16(cmd.params["clid"] ?? ""));
288
310
  if (clid === 0) return { kind: "unknown" };
@@ -402,3 +424,12 @@ function handleChatComposing(cmd: Command): NotificationResult {
402
424
  event: { clientID: clid, uid: asUID(cmd.params["cluid"] ?? "") },
403
425
  };
404
426
  }
427
+
428
+ function handleChatClosed(cmd: Command): NotificationResult {
429
+ const clid = asClientID(parseUint16(cmd.params["clid"] ?? ""));
430
+ if (clid === 0) return { kind: "unknown" };
431
+ return {
432
+ kind: "clientChatClosed",
433
+ event: { clientID: clid, uid: asUID(cmd.params["cluid"] ?? "") },
434
+ };
435
+ }
package/src/core/types.ts CHANGED
@@ -148,3 +148,17 @@ export type ClientStatus = (typeof ClientStatus)[keyof typeof ClientStatus];
148
148
  * default case.
149
149
  */
150
150
  export type ServerFamily = "ts3" | "ts6" | "unknown";
151
+
152
+ /**
153
+ * Pick the server generation from a `virtualserver_version` string such as
154
+ * "6.0.0-beta13.1" or "3.13.8 [Build: 1779874471]": major version 3 is TS3,
155
+ * 6 and later TS6, anything else, including a string with no number, unknown.
156
+ * Both clients use it, so they cannot disagree about the same server.
157
+ */
158
+ export function serverFamilyForVersion(version: string): ServerFamily {
159
+ const major = Number.parseInt(version, 10);
160
+ if (Number.isNaN(major)) return "unknown";
161
+ if (major === 3) return "ts3";
162
+ if (major >= 6) return "ts6";
163
+ return "unknown";
164
+ }