@honeybbq/teamspeak 0.0.1 → 1.0.0-beta.8
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 +969 -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 +1129 -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,83 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
/**
|
|
3
|
+
* Token-bucket limiter for outbound TS3 commands.
|
|
4
|
+
* Mirrors Go's commandThrottle.
|
|
5
|
+
*
|
|
6
|
+
* Waiters are released in the order they arrived: each used to poll for a
|
|
7
|
+
* token on its own timer, so a command that came later could take the turn of
|
|
8
|
+
* one that had waited longer, and the commands went out of order.
|
|
9
|
+
*/
|
|
10
|
+
export class CommandThrottle {
|
|
11
|
+
static TOKEN_RATE = 4.0; // tokens per second
|
|
12
|
+
static TOKEN_MAX = 8.0; // bucket capacity
|
|
13
|
+
#tokens = 5.0;
|
|
14
|
+
#lastUpdate = performance.now();
|
|
15
|
+
#waiters = [];
|
|
16
|
+
#timer;
|
|
17
|
+
/**
|
|
18
|
+
* Wait for a token, behind every earlier waiter. Aborting `signal` rejects
|
|
19
|
+
* with its reason and gives the place in line up; the abort listener is
|
|
20
|
+
* removed however the wait ends.
|
|
21
|
+
*/
|
|
22
|
+
wait(signal) {
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
return Promise.reject(signal.reason);
|
|
25
|
+
this.#refill();
|
|
26
|
+
if (this.#waiters.length === 0 && this.#tokens >= 1.0) {
|
|
27
|
+
this.#tokens -= 1.0;
|
|
28
|
+
return Promise.resolve();
|
|
29
|
+
}
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const waiter = {
|
|
32
|
+
resolve,
|
|
33
|
+
signal,
|
|
34
|
+
onAbort: () => {
|
|
35
|
+
const index = this.#waiters.indexOf(waiter);
|
|
36
|
+
if (index >= 0)
|
|
37
|
+
this.#waiters.splice(index, 1);
|
|
38
|
+
if (this.#waiters.length === 0)
|
|
39
|
+
this.#stopTimer();
|
|
40
|
+
reject(signal.reason);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
signal?.addEventListener("abort", waiter.onAbort, { once: true });
|
|
44
|
+
this.#waiters.push(waiter);
|
|
45
|
+
this.#schedule();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
#refill() {
|
|
49
|
+
const now = performance.now();
|
|
50
|
+
const elapsed = (now - this.#lastUpdate) / 1000;
|
|
51
|
+
this.#tokens = Math.min(this.#tokens + elapsed * _a.TOKEN_RATE, _a.TOKEN_MAX);
|
|
52
|
+
this.#lastUpdate = now;
|
|
53
|
+
}
|
|
54
|
+
/** Arm the timer for when the next token is due, unless it already is. */
|
|
55
|
+
#schedule() {
|
|
56
|
+
if (this.#timer !== undefined || this.#waiters.length === 0)
|
|
57
|
+
return;
|
|
58
|
+
const waitMs = this.#tokens >= 1.0
|
|
59
|
+
? 0
|
|
60
|
+
: Math.ceil(((1.0 - this.#tokens) / _a.TOKEN_RATE) * 1000) + 10;
|
|
61
|
+
this.#timer = setTimeout(() => {
|
|
62
|
+
this.#timer = undefined;
|
|
63
|
+
this.#release();
|
|
64
|
+
}, waitMs);
|
|
65
|
+
}
|
|
66
|
+
#stopTimer() {
|
|
67
|
+
clearTimeout(this.#timer);
|
|
68
|
+
this.#timer = undefined;
|
|
69
|
+
}
|
|
70
|
+
/** Hand the tokens there are to the waiters at the head of the line. */
|
|
71
|
+
#release() {
|
|
72
|
+
this.#refill();
|
|
73
|
+
while (this.#waiters.length > 0 && this.#tokens >= 1.0) {
|
|
74
|
+
this.#tokens -= 1.0;
|
|
75
|
+
const waiter = this.#waiters.shift();
|
|
76
|
+
waiter.signal?.removeEventListener("abort", waiter.onAbort);
|
|
77
|
+
waiter.resolve();
|
|
78
|
+
}
|
|
79
|
+
this.#schedule();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
_a = CommandThrottle;
|
|
83
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/client/throttle.ts"],"names":[],"mappings":";AAMA;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAU,UAAU,GAAG,GAAG,CAAC,CAAC,oBAAoB;IACtD,MAAM,CAAU,SAAS,GAAG,GAAG,CAAC,CAAC,kBAAkB;IAEnD,OAAO,GAAG,GAAG,CAAC;IACd,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACvB,QAAQ,GAAa,EAAE,CAAC;IACjC,MAAM,CAA4C;IAElD;;;;OAIG;IACH,IAAI,CAAC,MAAoB;QACvB,IAAI,MAAM,EAAE,OAAO;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;YACtD,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC;YACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAW;gBACrB,OAAO;gBACP,MAAM;gBACN,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAA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AC;QACjF,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC,EAAE,MAAM,CAAC,CAAC;IACb,CAAC;IAED,UAAU;QACR,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,wEAAwE;IACxE,QAAQ;QACN,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;YACvD,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC;YACpB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAG,CAAC;YACtC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5D,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { ChannelID, ClientID } from "@honeybbq/teamspeak";
|
|
2
|
+
import type { ServerCapabilities } from "./capabilities.js";
|
|
3
|
+
import type { ResolvedAddr } from "./types.js";
|
|
4
|
+
/** The values of the table below, before freezing. */
|
|
5
|
+
declare const connectPhaseValues: {
|
|
6
|
+
/** Opening the socket, or the address was not usable once resolved. */
|
|
7
|
+
readonly Open: "open";
|
|
8
|
+
/** The handshake, from the first packet until the shared secret exists. */
|
|
9
|
+
readonly Handshake: "handshake";
|
|
10
|
+
/** After the handshake, waiting for the server to accept the client: a wrong password, a ban or an invalid nickname end here. */
|
|
11
|
+
readonly Join: "join";
|
|
12
|
+
};
|
|
13
|
+
/** Where a connection attempt can fail; see {@link AttemptFailedInfo}. */
|
|
14
|
+
export declare const ConnectPhase: typeof connectPhaseValues;
|
|
15
|
+
/**
|
|
16
|
+
* One of {@link ConnectPhase}. May gain members in a minor release: a
|
|
17
|
+
* `switch` over it needs a default case.
|
|
18
|
+
*/
|
|
19
|
+
export type ConnectPhase = (typeof ConnectPhase)[keyof typeof ConnectPhase];
|
|
20
|
+
/** What every milestone of one connection attempt says about the attempt. */
|
|
21
|
+
interface AttemptInfo {
|
|
22
|
+
/**
|
|
23
|
+
* The attempt's number, from 1. The attempt `connect()` starts is 1; a
|
|
24
|
+
* reconnection attempt carries the retry number the reconnect policy uses,
|
|
25
|
+
* the one `shouldRetry` and the backoff see.
|
|
26
|
+
*/
|
|
27
|
+
readonly attempt: number;
|
|
28
|
+
/** Whether the reconnect loop started this attempt rather than a call to `connect()`. */
|
|
29
|
+
readonly reconnect: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** The address is about to be resolved. */
|
|
32
|
+
export interface ResolveStartInfo extends AttemptInfo {
|
|
33
|
+
/** The address as the client was given it. */
|
|
34
|
+
readonly addr: string;
|
|
35
|
+
}
|
|
36
|
+
/** The address has been resolved, or the lookup failed and the address is used as given. */
|
|
37
|
+
export interface ResolveDoneInfo extends AttemptInfo {
|
|
38
|
+
/** The address as the client was given it. */
|
|
39
|
+
readonly addr: string;
|
|
40
|
+
/** The `host:port` that will be dialled. */
|
|
41
|
+
readonly target: string;
|
|
42
|
+
/** What the resolver reports as the source of the answer dialled; may be empty. */
|
|
43
|
+
readonly source: string;
|
|
44
|
+
/** Every answer the resolver gave, in order; empty when the address is used as given. */
|
|
45
|
+
readonly candidates: readonly ResolvedAddr[];
|
|
46
|
+
/** Why the lookup failed, when the address is used as given; `undefined` otherwise. */
|
|
47
|
+
readonly error: unknown;
|
|
48
|
+
/** How long the resolution took, in milliseconds. */
|
|
49
|
+
readonly durationMs: number;
|
|
50
|
+
}
|
|
51
|
+
/** The socket is about to be opened. */
|
|
52
|
+
export interface ConnectStartInfo extends AttemptInfo {
|
|
53
|
+
/** The `host:port` being dialled. */
|
|
54
|
+
readonly target: string;
|
|
55
|
+
}
|
|
56
|
+
/** The socket is open; the first handshake packet has not been sent yet. */
|
|
57
|
+
export interface ConnectDoneInfo extends AttemptInfo {
|
|
58
|
+
/** The `host:port` being dialled. */
|
|
59
|
+
readonly target: string;
|
|
60
|
+
/** The local socket's `host:port`; empty when the socket does not say. */
|
|
61
|
+
readonly localAddr: string;
|
|
62
|
+
/** Milliseconds since `connectStart`. */
|
|
63
|
+
readonly durationMs: number;
|
|
64
|
+
}
|
|
65
|
+
/** The encrypted session exists; `clientinit` has not been sent yet. */
|
|
66
|
+
export interface HandshakeDoneInfo extends AttemptInfo {
|
|
67
|
+
/** Milliseconds since `connectStart`. */
|
|
68
|
+
readonly durationMs: number;
|
|
69
|
+
/** The level of the RSA puzzle the server demanded; 0 if it sent none. */
|
|
70
|
+
readonly puzzleLevel: number;
|
|
71
|
+
/** Milliseconds spent solving the puzzle. */
|
|
72
|
+
readonly puzzleDurationMs: number;
|
|
73
|
+
/**
|
|
74
|
+
* The packets sent again from `connectStart` to now, for want of an
|
|
75
|
+
* acknowledgement: the Init1 steps and the handshake's command packets.
|
|
76
|
+
*/
|
|
77
|
+
readonly resends: number;
|
|
78
|
+
/**
|
|
79
|
+
* The server's public key exactly as it sent it, base64, so that a caller can
|
|
80
|
+
* pin a server's identity.
|
|
81
|
+
*/
|
|
82
|
+
readonly serverPublicKey: string;
|
|
83
|
+
}
|
|
84
|
+
/** The server accepted the client, which is now connected. */
|
|
85
|
+
export interface SessionStartInfo extends AttemptInfo {
|
|
86
|
+
/** The client's ID on the server, the same as `client.clientID`. */
|
|
87
|
+
readonly clientID: ClientID;
|
|
88
|
+
/**
|
|
89
|
+
* The nickname the server accepted (`acn`), which differs from the one asked
|
|
90
|
+
* for when that was taken. The one asked for when the server did not say.
|
|
91
|
+
*/
|
|
92
|
+
readonly nickname: string;
|
|
93
|
+
/** The client's talk power (`client_talk_power`); 0 when the server did not say. */
|
|
94
|
+
readonly talkPower: number;
|
|
95
|
+
/**
|
|
96
|
+
* Every parameter of `initserver`, unescaped, except those that could carry a
|
|
97
|
+
* secret: `client_server_password`, `client_default_channel_password`,
|
|
98
|
+
* `client_default_token` and `client_key_offset`. Frozen.
|
|
99
|
+
*/
|
|
100
|
+
readonly initServer: Readonly<Record<string, string>>;
|
|
101
|
+
/** What the server said about itself in this handshake. */
|
|
102
|
+
readonly capabilities: ServerCapabilities;
|
|
103
|
+
/** Milliseconds since `connectStart`. */
|
|
104
|
+
readonly durationMs: number;
|
|
105
|
+
}
|
|
106
|
+
/** The server's welcome sequence ended: the channel list and the clients already there have arrived. */
|
|
107
|
+
export interface WelcomeDoneInfo extends AttemptInfo {
|
|
108
|
+
/**
|
|
109
|
+
* The channel the client is in at the end of the welcome: where it landed,
|
|
110
|
+
* which differs from the default channel asked for when that was refused.
|
|
111
|
+
*/
|
|
112
|
+
readonly channelID: ChannelID;
|
|
113
|
+
/** How many channel rows the welcome delivered. */
|
|
114
|
+
readonly channels: number;
|
|
115
|
+
/** How many clients are in view at the end of the welcome, this client included. */
|
|
116
|
+
readonly clients: number;
|
|
117
|
+
/** Milliseconds since `connectStart`. */
|
|
118
|
+
readonly durationMs: number;
|
|
119
|
+
}
|
|
120
|
+
/** An attempt ended without a session. */
|
|
121
|
+
export interface AttemptFailedInfo extends AttemptInfo {
|
|
122
|
+
/** Where the attempt failed. */
|
|
123
|
+
readonly phase: ConnectPhase;
|
|
124
|
+
/** Why: the error `connect()` rejects with, or the one that ended the reconnection attempt. */
|
|
125
|
+
readonly error: unknown;
|
|
126
|
+
/** The `host:port` being dialled; empty when the attempt failed before `resolveDone`. */
|
|
127
|
+
readonly target: string;
|
|
128
|
+
/** Milliseconds since `resolveStart`. */
|
|
129
|
+
readonly durationMs: number;
|
|
130
|
+
}
|
|
131
|
+
/** The reconnect loop will retry, after a wait. */
|
|
132
|
+
export interface ReconnectScheduledInfo {
|
|
133
|
+
/** The attempt that will follow, numbered as in {@link ResolveStartInfo.attempt}. */
|
|
134
|
+
readonly attempt: number;
|
|
135
|
+
/** How long the loop waits first, in milliseconds. */
|
|
136
|
+
readonly delayMs: number;
|
|
137
|
+
/** The error that ended the previous connection or attempt. */
|
|
138
|
+
readonly cause: unknown;
|
|
139
|
+
}
|
|
140
|
+
/** A connected session is about to be left with `disconnect()`. It has no fields yet. */
|
|
141
|
+
export interface DisconnectStartInfo {
|
|
142
|
+
}
|
|
143
|
+
/** The goodbye of `disconnect()` is over. */
|
|
144
|
+
export interface DisconnectDoneInfo {
|
|
145
|
+
/** Whether the server acknowledged the goodbye before the goodbye timeout. */
|
|
146
|
+
readonly acknowledged: boolean;
|
|
147
|
+
/** Milliseconds since `disconnectStart`. */
|
|
148
|
+
readonly durationMs: number;
|
|
149
|
+
}
|
|
150
|
+
/** A session that had a `sessionStart` has ended, however it ended. */
|
|
151
|
+
export interface SessionEndInfo {
|
|
152
|
+
/** The client's ID on the server during the session. */
|
|
153
|
+
readonly clientID: ClientID;
|
|
154
|
+
/**
|
|
155
|
+
* `undefined` after `disconnect()`, and otherwise the cause the
|
|
156
|
+
* `disconnected` event gets.
|
|
157
|
+
*/
|
|
158
|
+
readonly error: unknown;
|
|
159
|
+
/** Milliseconds since `sessionStart`. */
|
|
160
|
+
readonly durationMs: number;
|
|
161
|
+
/** The number of the attempt that started the session. */
|
|
162
|
+
readonly attempt: number;
|
|
163
|
+
/** Whether the reconnect loop started the attempt that started the session. */
|
|
164
|
+
readonly reconnect: boolean;
|
|
165
|
+
}
|
|
166
|
+
/** The reconnect loop ended without a session. */
|
|
167
|
+
export interface ReconnectStoppedInfo {
|
|
168
|
+
/** How many reconnection attempts the loop made. */
|
|
169
|
+
readonly attempts: number;
|
|
170
|
+
/**
|
|
171
|
+
* The error `shouldRetry` declined, or the last attempt's when the attempts
|
|
172
|
+
* ran out; `undefined` when `disconnect()` stopped the loop.
|
|
173
|
+
*/
|
|
174
|
+
readonly cause: unknown;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Hooks that observe a client for timing, metrics, logs or a progress
|
|
178
|
+
* display: the milestones of every connection attempt, the end of a session,
|
|
179
|
+
* and the reconnect loop. Every hook is optional.
|
|
180
|
+
*
|
|
181
|
+
* A hook is called synchronously, at the moment of the milestone, and the
|
|
182
|
+
* client waits for it to return: keep it quick, and hand slow work to your own
|
|
183
|
+
* task. What it returns is ignored, and a returned promise is never awaited. A
|
|
184
|
+
* hook that throws, or whose promise rejects, is reported the way a throwing
|
|
185
|
+
* event listener is, and the client carries on. A hook may read the
|
|
186
|
+
* client's state. It must not call `connect()` or `disconnect()`: to give up
|
|
187
|
+
* on an attempt, abort the signal passed to `connect()`, and to leave once
|
|
188
|
+
* connected, call `disconnect()` from a `connected` listener.
|
|
189
|
+
*
|
|
190
|
+
* Every attempt ends with exactly one of `sessionStart` and `attemptFailed`,
|
|
191
|
+
* and every session that started with exactly one `sessionEnd`. The hooks are
|
|
192
|
+
* read when the client is made, from a copy of this object.
|
|
193
|
+
*/
|
|
194
|
+
export interface ClientTrace {
|
|
195
|
+
/** Before the address is resolved. */
|
|
196
|
+
readonly resolveStart?: (info: ResolveStartInfo) => void;
|
|
197
|
+
/** After the address is resolved, also when it fell back to the address as given. */
|
|
198
|
+
readonly resolveDone?: (info: ResolveDoneInfo) => void;
|
|
199
|
+
/** Right before the socket is opened. */
|
|
200
|
+
readonly connectStart?: (info: ConnectStartInfo) => void;
|
|
201
|
+
/** Once the socket is open, before the first handshake packet is sent. */
|
|
202
|
+
readonly connectDone?: (info: ConnectDoneInfo) => void;
|
|
203
|
+
/** When the shared secret is derived, before `clientinit` is sent. */
|
|
204
|
+
readonly handshakeDone?: (info: HandshakeDoneInfo) => void;
|
|
205
|
+
/** When the server accepts the client: before `connect()` resolves and before `connected` is delivered. */
|
|
206
|
+
readonly sessionStart?: (info: SessionStartInfo) => void;
|
|
207
|
+
/** When the server's welcome sequence ends; at most once per attempt, and only after `sessionStart`. */
|
|
208
|
+
readonly welcomeDone?: (info: WelcomeDoneInfo) => void;
|
|
209
|
+
/** When an attempt ends without `sessionStart`, for any reason, an abort or `disconnect()` included. */
|
|
210
|
+
readonly attemptFailed?: (info: AttemptFailedInfo) => void;
|
|
211
|
+
/** When `disconnect()` begins saying goodbye to a connected session. */
|
|
212
|
+
readonly disconnectStart?: (info: DisconnectStartInfo) => void;
|
|
213
|
+
/** When that goodbye is over. */
|
|
214
|
+
readonly disconnectDone?: (info: DisconnectDoneInfo) => void;
|
|
215
|
+
/** When a session ends, however it ends; before `disconnected` is queued. */
|
|
216
|
+
readonly sessionEnd?: (info: SessionEndInfo) => void;
|
|
217
|
+
/** When the reconnect loop has decided to retry and is about to wait. */
|
|
218
|
+
readonly reconnectScheduled?: (info: ReconnectScheduledInfo) => void;
|
|
219
|
+
/** When the reconnect loop ends without a session. */
|
|
220
|
+
readonly reconnectStopped?: (info: ReconnectStoppedInfo) => void;
|
|
221
|
+
}
|
|
222
|
+
export {};
|
|
223
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/client/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,sDAAsD;AACtD,QAAA,MAAM,kBAAkB;IACtB,uEAAuE;aACvE,IAAI,EAAE,MAAM;IACZ,2EAA2E;aAC3E,SAAS,EAAE,WAAW;IACtB,iIAAiI;aACjI,IAAI,EAAE,MAAM;CACJ,CAAC;AACX,0EAA0E;AAC1E,eAAO,MAAM,YAAY,EAAE,OAAO,kBACiB,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OA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ACvD,yCAAyC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IACvD,sEAAsE;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D,2GAA2G;IAC3G,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD,wGAAwG;IACxG,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IACvD,wGAAwG;IACxG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D,wEAAwE;IACxE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,iCAAiC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7D,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,yEAAyE;IACzE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrE,sDAAsD;IACtD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAClE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The values of the table below, before freezing. */
|
|
2
|
+
const connectPhaseValues = {
|
|
3
|
+
/** Opening the socket, or the address was not usable once resolved. */
|
|
4
|
+
Open: "open",
|
|
5
|
+
/** The handshake, from the first packet until the shared secret exists. */
|
|
6
|
+
Handshake: "handshake",
|
|
7
|
+
/** After the handshake, waiting for the server to accept the client: a wrong password, a ban or an invalid nickname end here. */
|
|
8
|
+
Join: "join",
|
|
9
|
+
};
|
|
10
|
+
/** Where a connection attempt can fail; see {@link AttemptFailedInfo}. */
|
|
11
|
+
export const ConnectPhase =
|
|
12
|
+
/* @__PURE__ */ Object.freeze(connectPhaseValues);
|
|
13
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/client/trace.ts"],"names":[],"mappings":"AAIA,sDAAsD;AACtD,MAAM,kBAAkB,GAAG;IACzB,uEAAuE;IACvE,IAAI,EAAE,MAAM;IACZ,2EAA2E;IAC3E,SAAS,EAAE,WAAW;IACtB,iIAAiI;IACjI,IAAI,EAAE,MAAM;CACJ,CAAC;AACX,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY;AACvB,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
import { type Duplex, type Readable, type Writable } from "node:stream";
|
|
9
|
+
import type { FileUploadInfo, FileDownloadInfo } from "@honeybbq/teamspeak";
|
|
10
|
+
import type { FileTransferSocketFactory } from "./types.js";
|
|
11
|
+
import { FileTransferError } from "./errors.js";
|
|
12
|
+
/** Where a failed transfer failed. */
|
|
13
|
+
export type FileTransferStage = "dial" | "transfer";
|
|
14
|
+
/** The file transfer port is about to be dialled. */
|
|
15
|
+
export interface FileTransferDialStartInfo {
|
|
16
|
+
/** The `host:port` being dialled. */
|
|
17
|
+
readonly addr: string;
|
|
18
|
+
}
|
|
19
|
+
/** The connection is open and the transfer key has been sent. */
|
|
20
|
+
export interface FileTransferDialDoneInfo {
|
|
21
|
+
/** The `host:port` dialled. */
|
|
22
|
+
readonly addr: string;
|
|
23
|
+
/** The local socket's `host:port`; empty when the socket does not say. */
|
|
24
|
+
readonly localAddr: string;
|
|
25
|
+
/** Milliseconds since `dialStart`. */
|
|
26
|
+
readonly durationMs: number;
|
|
27
|
+
}
|
|
28
|
+
/** Data has moved. */
|
|
29
|
+
export interface FileTransferProgressInfo {
|
|
30
|
+
/** The bytes moved so far. */
|
|
31
|
+
readonly bytes: number;
|
|
32
|
+
/** The size the negotiation gave; 0 when it is not known, as for an upload. */
|
|
33
|
+
readonly total: number;
|
|
34
|
+
}
|
|
35
|
+
/** The transfer succeeded. */
|
|
36
|
+
export interface FileTransferDoneInfo {
|
|
37
|
+
/** The bytes moved. */
|
|
38
|
+
readonly bytes: number;
|
|
39
|
+
/** Milliseconds since `dialStart`. */
|
|
40
|
+
readonly durationMs: number;
|
|
41
|
+
}
|
|
42
|
+
/** The transfer failed. */
|
|
43
|
+
export interface FileTransferFailedInfo {
|
|
44
|
+
/** Why: the error the transfer function rejects with. */
|
|
45
|
+
readonly error: unknown;
|
|
46
|
+
/** The bytes moved before it failed. */
|
|
47
|
+
readonly bytes: number;
|
|
48
|
+
/** Milliseconds since `dialStart`. */
|
|
49
|
+
readonly durationMs: number;
|
|
50
|
+
/** Whether the failure came while dialling or while the data moved. */
|
|
51
|
+
readonly stage: FileTransferStage;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Hooks that observe one file transfer. Every hook is optional, and none ever
|
|
55
|
+
* sees the transfer key.
|
|
56
|
+
*
|
|
57
|
+
* A hook runs synchronously on the task doing the transfer, and its return
|
|
58
|
+
* value is ignored: a returned promise is not awaited. A hook that throws, or
|
|
59
|
+
* whose promise rejects, is reported the way a throwing event listener is, and
|
|
60
|
+
* the transfer goes on. Keep hooks quick.
|
|
61
|
+
*
|
|
62
|
+
* A call of `uploadFileData` or `downloadFileData` ends with exactly one of
|
|
63
|
+
* `done` and `failed`; `dialFileTransfer` on its own reports `dialStart`, then
|
|
64
|
+
* `dialDone` or `failed` with the stage `"dial"`.
|
|
65
|
+
*/
|
|
66
|
+
export interface FileTransferTrace {
|
|
67
|
+
/** Before the file transfer port is dialled. */
|
|
68
|
+
readonly dialStart?: (info: FileTransferDialStartInfo) => void;
|
|
69
|
+
/** When the connection is open and the transfer key is sent. */
|
|
70
|
+
readonly dialDone?: (info: FileTransferDialDoneInfo) => void;
|
|
71
|
+
/** While data moves, at most once per 64 KiB, and once more at the end with the final count. */
|
|
72
|
+
readonly progress?: (info: FileTransferProgressInfo) => void;
|
|
73
|
+
/** When the transfer function is about to resolve. */
|
|
74
|
+
readonly done?: (info: FileTransferDoneInfo) => void;
|
|
75
|
+
/** When the transfer function is about to reject, a failed dial included. */
|
|
76
|
+
readonly failed?: (info: FileTransferFailedInfo) => void;
|
|
77
|
+
}
|
|
78
|
+
/** Options for a file transfer. */
|
|
79
|
+
export interface FileTransferOptions {
|
|
80
|
+
/** Abandons the transfer; it then rejects with the signal's reason. */
|
|
81
|
+
readonly signal?: AbortSignal | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Opens the connection instead of a direct TCP dial, to route the transfer
|
|
84
|
+
* through a proxy or tunnel.
|
|
85
|
+
*/
|
|
86
|
+
readonly socketFactory?: FileTransferSocketFactory | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Hooks called at each milestone of this transfer. The object is copied when
|
|
89
|
+
* the call starts. See {@link FileTransferTrace}.
|
|
90
|
+
*/
|
|
91
|
+
readonly trace?: FileTransferTrace | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The longest, in milliseconds, the transfer may go without moving a byte,
|
|
94
|
+
* the write of the transfer key included. When it passes, the transfer
|
|
95
|
+
* rejects with a {@link FileTransferError} whose `cause` is a `TimeoutError`
|
|
96
|
+
* and the connection is destroyed. `undefined` means the default, 30 000;
|
|
97
|
+
* `0` turns the limit off.
|
|
98
|
+
*/
|
|
99
|
+
readonly idleTimeoutMs?: number | undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Open a connection to the file transfer port and send the transfer key.
|
|
103
|
+
* The caller owns the returned stream and must end or destroy it.
|
|
104
|
+
*/
|
|
105
|
+
export declare function dialFileTransfer(host: string, port: number, key: string, options?: FileTransferOptions): Promise<Duplex>;
|
|
106
|
+
/** Upload `data` over a negotiated transfer. Resolves once every byte is sent. */
|
|
107
|
+
export declare function uploadFileData(host: string, info: FileUploadInfo, data: Readable, options?: FileTransferOptions): Promise<void>;
|
|
108
|
+
/** Download a negotiated transfer into `dest`. Resolves once the file is written. */
|
|
109
|
+
export declare function downloadFileData(host: string, info: FileDownloadInfo, dest: Writable, options?: FileTransferOptions): Promise<void>;
|
|
110
|
+
export { FileTransferError };
|
|
111
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/client/transfer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAa,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAchD,sCAAsC;AACtC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpD,qDAAqD;AACrD,MAAM,WAAW,yBAAyB;IACxC,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,WAAW,wBAAwB;IACv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