@honeybbq/teamspeak-client 0.3.0 → 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/eax.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/generation-window.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 -57
- 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/address.test.d.ts +0 -2
- package/dist/address.test.d.ts.map +0 -1
- package/dist/api.d.ts +0 -17
- package/dist/api.d.ts.map +0 -1
- package/dist/api.test.d.ts +0 -2
- package/dist/api.test.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/command.test.d.ts +0 -2
- package/dist/command/command.test.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/eax.test.d.ts +0 -2
- package/dist/crypto/eax.test.d.ts.map +0 -1
- package/dist/crypto/identity.test.d.ts +0 -2
- package/dist/crypto/identity.test.d.ts.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/handshake.test.d.ts +0 -2
- package/dist/handshake.test.d.ts.map +0 -1
- package/dist/helpers.test.d.ts +0 -2
- package/dist/helpers.test.d.ts.map +0 -1
- package/dist/index.cjs +0 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -796
- package/dist/index.mjs.map +0 -1
- package/dist/integration.test.d.ts +0 -12
- package/dist/integration.test.d.ts.map +0 -1
- package/dist/notifications.test.d.ts +0 -2
- package/dist/notifications.test.d.ts.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/throttle.test.d.ts +0 -2
- package/dist/throttle.test.d.ts.map +0 -1
- package/dist/transport/generation-window.test.d.ts +0 -2
- package/dist/transport/generation-window.test.d.ts.map +0 -1
- package/dist/transport/index.cjs +0 -1
- package/dist/transport/index.mjs +0 -2
- package/dist/transport/packet.test.d.ts +0 -2
- package/dist/transport/packet.test.d.ts.map +0 -1
- package/dist/transport/quicklz.test.d.ts +0 -2
- package/dist/transport/quicklz.test.d.ts.map +0 -1
- package/dist/transport/whisper.test.d.ts +0 -2
- package/dist/transport/whisper.test.d.ts.map +0 -1
package/dist/notifications.d.ts
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
import type { Command } from "
|
|
2
|
-
import type {
|
|
1
|
+
import type { Command } from "@honeybbq/teamspeak-core/internal";
|
|
2
|
+
import type { ClientEnterEvent, ClientLeaveEvent, ClientMovedEvent, TextMessageEvent, PokeEvent } from "./types.js";
|
|
3
3
|
export type NotificationResult = {
|
|
4
4
|
kind: "clientEnter";
|
|
5
|
-
info:
|
|
5
|
+
info: ClientEnterEvent;
|
|
6
6
|
} | {
|
|
7
7
|
kind: "clientLeave";
|
|
8
|
-
event:
|
|
8
|
+
event: ClientLeaveEvent;
|
|
9
9
|
isSelf: boolean;
|
|
10
10
|
} | {
|
|
11
11
|
kind: "clientMoved";
|
|
12
12
|
event: ClientMovedEvent;
|
|
13
|
+
reasonMessage: string;
|
|
13
14
|
} | {
|
|
14
15
|
kind: "textMessage";
|
|
15
|
-
message:
|
|
16
|
+
message: TextMessageEvent;
|
|
16
17
|
} | {
|
|
17
18
|
kind: "poked";
|
|
18
19
|
event: PokeEvent;
|
|
19
|
-
} | {
|
|
20
|
-
kind: "startUpload";
|
|
21
|
-
info: FileUploadInfo;
|
|
22
|
-
} | {
|
|
23
|
-
kind: "startDownload";
|
|
24
|
-
info: FileDownloadInfo;
|
|
25
|
-
} | {
|
|
26
|
-
kind: "fileTransferStatus";
|
|
27
|
-
info: FileTransferStatusInfo;
|
|
28
20
|
} | {
|
|
29
21
|
kind: "unknown";
|
|
30
22
|
};
|
|
31
|
-
export declare function handleNotification(cmd: Command, selfCLID: number, clients: Map<number,
|
|
23
|
+
export declare function handleNotification(cmd: Command, selfCLID: number, clients: Map<number, ClientEnterEvent>, _nickname: string): NotificationResult;
|
|
32
24
|
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../src/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../src/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,YAAY,CAAC;AASpB,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAExB,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,SAAS,EAAE,MAAM,GAChB,kBAAkB,CAepB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconnection policy.
|
|
3
|
+
*
|
|
4
|
+
* A dropped connection is normal on a UDP voice session, so a bot that cannot
|
|
5
|
+
* recover is not usable unattended. Reconnecting is opt-in rather than
|
|
6
|
+
* automatic: a silent reconnect makes a dropped session look like a healthy
|
|
7
|
+
* one, and a caller that wanted to know about the drop never finds out.
|
|
8
|
+
*
|
|
9
|
+
* Backoff is not a nicety here. TeamSpeak bans an IP that opens several
|
|
10
|
+
* connections in quick succession — measured at roughly three, after which the
|
|
11
|
+
* server answers `error id=3329` and refuses everything. A reconnect loop
|
|
12
|
+
* without a delay therefore bans itself, and the ban outlasts the outage it was
|
|
13
|
+
* recovering from.
|
|
14
|
+
*/
|
|
15
|
+
/** How long to wait before each attempt. */
|
|
16
|
+
export interface BackoffPolicy {
|
|
17
|
+
/** Delay before the first retry, in milliseconds. */
|
|
18
|
+
readonly initialDelayMs: number;
|
|
19
|
+
/** Ceiling for the delay; it never grows past this. */
|
|
20
|
+
readonly maxDelayMs: number;
|
|
21
|
+
/** Multiplier applied after each failed attempt. */
|
|
22
|
+
readonly factor: number;
|
|
23
|
+
/**
|
|
24
|
+
* Fraction of the delay to randomise, 0 to 1.
|
|
25
|
+
*
|
|
26
|
+
* A fleet of bots that drop together would otherwise retry in lockstep and
|
|
27
|
+
* hit the server in a burst. Jitter spreads them out.
|
|
28
|
+
*/
|
|
29
|
+
readonly jitter: number;
|
|
30
|
+
/** Give up after this many consecutive failures. 0 means never give up. */
|
|
31
|
+
readonly maxAttempts: number;
|
|
32
|
+
}
|
|
33
|
+
/** One second, doubling, capped at a minute, with 20% jitter, never giving up. */
|
|
34
|
+
export declare const defaultBackoffPolicy: Readonly<BackoffPolicy>;
|
|
35
|
+
/**
|
|
36
|
+
* How a client reconnects after its connection drops. Supplying it, even as
|
|
37
|
+
* `{}`, turns reconnecting on; a deliberate `disconnect()` never reconnects.
|
|
38
|
+
*/
|
|
39
|
+
export interface ReconnectOptions {
|
|
40
|
+
/** Tuning for the retry delays; unset fields keep {@link defaultBackoffPolicy}'s. */
|
|
41
|
+
readonly backoff?: {
|
|
42
|
+
readonly [K in keyof BackoffPolicy]?: BackoffPolicy[K] | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Decide whether a given failure is worth retrying. Returning false stops the
|
|
46
|
+
* loop. Defaults to {@link defaultShouldRetry}.
|
|
47
|
+
*/
|
|
48
|
+
readonly shouldRetry?: ((error: Error | undefined, attempt: number) => boolean) | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Compute the delay before an attempt.
|
|
52
|
+
*
|
|
53
|
+
* `attempt` is 1-based: the delay before the first retry is `initialDelayMs`,
|
|
54
|
+
* give or take the jitter, and the delay never grows past `maxDelayMs`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function backoffDelay(policy: Readonly<BackoffPolicy>, attempt: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Whether a failure is worth another attempt.
|
|
59
|
+
*
|
|
60
|
+
* Transport failures are retried; so is a server that stopped, and a server
|
|
61
|
+
* error other than the known refusals — a ban, flooding, a wrong server or
|
|
62
|
+
* channel password, missing permissions — since some, such as 521 "too many
|
|
63
|
+
* clones" right after a drop, clear by themselves. A kick or a ban is not:
|
|
64
|
+
* someone removed the client on purpose. Nor is an AlreadyConnectedError: the
|
|
65
|
+
* client was connected by other means; nor an InvalidAddressError.
|
|
66
|
+
*/
|
|
67
|
+
export declare function defaultShouldRetry(error: Error | undefined): boolean;
|
|
68
|
+
export declare function resolveBackoffPolicy(options: ReconnectOptions): BackoffPolicy;
|
|
69
|
+
//# sourceMappingURL=reconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect.d.ts","sourceRoot":"","sources":["../src/reconnect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,aAAa,CAMvD,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EACb;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS;KAAE,GACtE,SAAS,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CAC7F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErF;AA0CD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CASpE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAO7E"}
|
package/dist/throttle.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Token-bucket limiter for outbound TS3 commands.
|
|
3
3
|
* Mirrors Go's commandThrottle.
|
|
4
|
+
*
|
|
5
|
+
* Waiters are released in the order they arrived: each used to poll for a
|
|
6
|
+
* token on its own timer, so a command that came later could take the turn of
|
|
7
|
+
* one that had waited longer, and the commands went out of order.
|
|
4
8
|
*/
|
|
5
9
|
export declare class CommandThrottle {
|
|
6
10
|
#private;
|
|
7
11
|
static readonly TOKEN_RATE = 4;
|
|
8
12
|
static readonly TOKEN_MAX = 8;
|
|
13
|
+
/**
|
|
14
|
+
* Wait for a token, behind every earlier waiter. Aborting `signal` rejects
|
|
15
|
+
* with its reason and gives the place in line up; the abort listener is
|
|
16
|
+
* removed however the wait ends.
|
|
17
|
+
*/
|
|
9
18
|
wait(signal?: AbortSignal): Promise<void>;
|
|
10
19
|
}
|
|
11
20
|
//# sourceMappingURL=throttle.d.ts.map
|
package/dist/throttle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../src/throttle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../src/throttle.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,qBAAa,eAAe;;IAC1B,MAAM,CAAC,QAAQ,CAAC,UAAU,KAAO;IACjC,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAO;IAOhC;;;;OAIG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBxC;CAyCF"}
|
package/dist/transfer.d.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
import type { FileUploadInfo, FileDownloadInfo } from "./types.js";
|
|
3
|
-
import { FileTransferError, FileTransferTimeoutError } from "./errors.js";
|
|
4
|
-
type FtNotification = FileUploadInfo | FileDownloadInfo | import("./types.js").FileTransferStatusInfo;
|
|
5
|
-
export declare class FileTransferTracker {
|
|
6
|
-
#private;
|
|
7
|
-
register(): [cftid: number, promise: Promise<FtNotification>];
|
|
8
|
-
unregister(cftid: number): void;
|
|
9
|
-
notify(cftid: number, value: FtNotification): void;
|
|
10
|
-
reset(): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Open a TCP connection to the TS3 file transfer port and perform the
|
|
14
|
-
* ftkey handshake. The caller is responsible for closing the socket.
|
|
15
|
-
*/
|
|
16
|
-
export declare function dialFileTransfer(host: string, port: number, key: string): Promise<import("node:net").Socket>;
|
|
17
|
-
/** Upload data via a TS3 file transfer connection. */
|
|
18
|
-
export declare function uploadFileData(host: string, info: FileUploadInfo, data: Readable): Promise<void>;
|
|
19
|
-
/** Download data via a TS3 file transfer connection. */
|
|
20
|
-
export declare function downloadFileData(host: string, info: FileDownloadInfo, dest: Writable): Promise<void>;
|
|
21
1
|
/**
|
|
22
|
-
*
|
|
2
|
+
* File transfer data.
|
|
3
|
+
*
|
|
4
|
+
* Negotiating a transfer is a command (`initFileUpload`, `initFileDownload`);
|
|
5
|
+
* the bytes then go over a separate TCP connection to the server's file
|
|
6
|
+
* transfer port, opened with the key the negotiation returned.
|
|
23
7
|
*/
|
|
24
|
-
|
|
8
|
+
import type { Duplex, Readable, Writable } from "node:stream";
|
|
9
|
+
import type { FileUploadInfo, FileDownloadInfo } from "@honeybbq/teamspeak-core";
|
|
10
|
+
import type { FileTransferSocketFactory } from "./types.js";
|
|
11
|
+
import { FileTransferError } from "./errors.js";
|
|
12
|
+
/** Options for a file transfer. */
|
|
13
|
+
export interface FileTransferOptions {
|
|
14
|
+
/** Abandons the transfer; it then rejects with the signal's reason. */
|
|
15
|
+
readonly signal?: AbortSignal | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Opens the connection instead of a direct TCP dial, to route the transfer
|
|
18
|
+
* through a proxy or tunnel.
|
|
19
|
+
*/
|
|
20
|
+
readonly socketFactory?: FileTransferSocketFactory | undefined;
|
|
21
|
+
}
|
|
25
22
|
/**
|
|
26
|
-
*
|
|
23
|
+
* Open a connection to the file transfer port and send the transfer key.
|
|
24
|
+
* The caller owns the returned stream and must end or destroy it.
|
|
27
25
|
*/
|
|
28
|
-
export declare function
|
|
29
|
-
|
|
26
|
+
export declare function dialFileTransfer(host: string, port: number, key: string, options?: FileTransferOptions): Promise<Duplex>;
|
|
27
|
+
/** Upload `data` over a negotiated transfer. Resolves once every byte is sent. */
|
|
28
|
+
export declare function uploadFileData(host: string, info: FileUploadInfo, data: Readable, options?: FileTransferOptions): Promise<void>;
|
|
29
|
+
/** Download a negotiated transfer into `dest`. Resolves once the file is written. */
|
|
30
|
+
export declare function downloadFileData(host: string, info: FileDownloadInfo, dest: Writable, options?: FileTransferOptions): Promise<void>;
|
|
31
|
+
export { FileTransferError };
|
|
30
32
|
//# sourceMappingURL=transfer.d.ts.map
|
package/dist/transfer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKhD,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CAChE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAuCD,kFAAkF;AAClF,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,qFAAqF;AACrF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-window.d.ts","sourceRoot":"","sources":["../../src/transport/generation-window.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;;
|
|
1
|
+
{"version":3,"file":"generation-window.d.ts","sourceRoot":"","sources":["../../src/transport/generation-window.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;;IAM3B,YAAY,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAG1C;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAQ5B;IAED,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAI3C;IAED,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAIhC;IAED,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAMvC;IAED,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAKzC;IAED,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAExC;IAED,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE3C;IASD,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGzC;IAED,KAAK,IAAI,IAAI,CAGZ;CACF"}
|
|
@@ -1,20 +1,52 @@
|
|
|
1
|
-
import { type Socket as UdpSocket } from "node:dgram";
|
|
2
1
|
import type { Crypt } from "../crypto/crypt.js";
|
|
3
|
-
import type {
|
|
2
|
+
import type { DatagramSocket, SocketFactory } from "../types.js";
|
|
3
|
+
import type { Logger } from "@honeybbq/teamspeak-core";
|
|
4
4
|
import { type Packet, PacketType } from "./packet.js";
|
|
5
|
+
/**
|
|
6
|
+
* The largest datagram taken. TeamSpeak's packets are at most 500 bytes; a
|
|
7
|
+
* larger one is no packet of the protocol's, and is dropped before anything
|
|
8
|
+
* is decrypted or held.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_DATAGRAM_SIZE: number;
|
|
11
|
+
/**
|
|
12
|
+
* The most command bytes held, across both receive queues, waiting for the
|
|
13
|
+
* packets before them. A server's in-order traffic drains at once and a full
|
|
14
|
+
* window of real packets is under a megabyte; past this, a packet is dropped
|
|
15
|
+
* unacknowledged, so the server sends it again once there is room.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MAX_QUEUED_BYTES: number;
|
|
5
18
|
export declare class PacketHandler {
|
|
6
19
|
#private;
|
|
7
20
|
onPacket: ((p: Packet) => void) | null;
|
|
8
21
|
onClosed: ((err: Error | null) => void) | null;
|
|
9
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A received datagram could not be handled: it was malformed, or handling it
|
|
24
|
+
* threw. The datagram is dropped either way; the owner decides whether that
|
|
25
|
+
* ends the connection. Without an owner the error is logged.
|
|
26
|
+
*/
|
|
27
|
+
onReceiveError: ((error: unknown) => void) | null;
|
|
28
|
+
constructor(crypt: Crypt, logger?: Logger, socketFactory?: SocketFactory);
|
|
10
29
|
setClientID(id: number): void;
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Resolve `addr`, open a socket to it and start the handshake.
|
|
32
|
+
*
|
|
33
|
+
* Aborting `signal`, or closing the handler, while this runs abandons it: the
|
|
34
|
+
* lookup's answer is ignored, and a socket that finishes connecting
|
|
35
|
+
* afterwards is closed rather than started, so no handshake begins after
|
|
36
|
+
* the connection was given up.
|
|
37
|
+
*/
|
|
38
|
+
connect(addr: string, signal?: AbortSignal): Promise<void>;
|
|
39
|
+
/** Take over a connected socket and start the handshake on it. A closed handler closes it instead. */
|
|
40
|
+
start(conn: DatagramSocket): void;
|
|
13
41
|
receivedFinalInitAck(): void;
|
|
14
42
|
sendPacket(pType: PacketType, data: Uint8Array, flags: number): void;
|
|
15
43
|
sendVoicePacket(data: Uint8Array, codec: number): void;
|
|
16
44
|
/** Send an unencrypted TeamSpeak voice whisper packet to up to 32 clients. */
|
|
17
45
|
sendWhisperPacket(data: Uint8Array, targetClientIds: number[], codec: number): void;
|
|
46
|
+
/** How many packets have been sent again for want of an acknowledgement. */
|
|
47
|
+
get resends(): number;
|
|
48
|
+
/** Whether there is a live socket to send on. */
|
|
49
|
+
get isOpen(): boolean;
|
|
18
50
|
close(): void;
|
|
19
51
|
}
|
|
20
52
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/transport/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/transport/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,KAAK,MAAM,EACX,UAAU,EAMX,MAAM,aAAa,CAAC;AA4BrB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAa,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAgB,CAAC;AA4BhD,qBAAa,aAAa;;IACxB,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IAC9C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IACtD;;;;OAIG;IACH,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IAoCzD,YAAY,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,MAAmB,EAAE,aAAa,CAAC,EAAE,aAAa,EAInF;IAED,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE5B;IAED;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD/D;IAOD,sGAAsG;IACtG,KAAK,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CA2ChC;IAED,oBAAoB,IAAI,IAAI,CAE3B;IAED,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOnE;IAED,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CA6BrD;IAED,8EAA8E;IAC9E,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAwClF;IAED,4EAA4E;IAC5E,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,iDAAiD;IACjD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,KAAK,IAAI,IAAI,CAmBZ;CAigBF"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The largest decompressed command accepted. A command is reassembled from at
|
|
3
|
+
* most a receive window of fragments, and the largest real answers (a full
|
|
4
|
+
* permission list, the welcome channel list of a big server) are a few
|
|
5
|
+
* hundred kilobytes; a header declaring more is refused before anything is
|
|
6
|
+
* allocated.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_DECOMPRESSED_SIZE: number;
|
|
9
|
+
/** A QuickLZ block that cannot be decompressed: truncated, oversized or inconsistent. */
|
|
10
|
+
export declare class QuickLZError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* QuickLZ level 1 decompression, as the server compresses large commands.
|
|
15
|
+
*
|
|
16
|
+
* The input comes from the network, so every read and every back-reference is
|
|
17
|
+
* checked, and malformed input throws a QuickLZError rather than reading out
|
|
18
|
+
* of range or producing a partly filled buffer.
|
|
19
|
+
*/
|
|
1
20
|
export declare class Qlz {
|
|
2
21
|
#private;
|
|
3
22
|
decompress(data: Uint8Array): Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quicklz.d.ts","sourceRoot":"","sources":["../../src/transport/quicklz.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quicklz.d.ts","sourceRoot":"","sources":["../../src/transport/quicklz.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAgB,CAAC;AAiBrD,yFAAyF;AACzF,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;GAMG;AACH,qBAAa,GAAG;;IAGd,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAoCvC;CAoGF"}
|