@honeybbq/teamspeak-client 0.3.0 → 0.3.2
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/dist/address-BR-5unVo.cjs.map +1 -1
- package/dist/address-BfmovVpp.js.map +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/client.d.ts +16 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/command/index.cjs +1 -1
- package/dist/command/index.mjs +1 -1
- package/dist/command/parser.d.ts.map +1 -1
- package/dist/command-BLe-C2L2.js.map +1 -1
- package/dist/command-DAK4pUBP.cjs.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/crypt-handshake-CQkQreLx.cjs.map +1 -1
- package/dist/crypt-handshake-DziOY4Lq.js.map +1 -1
- package/dist/{crypt-init2-D70ha4LB.js → crypt-init2-BcGT--df.js} +2 -2
- package/dist/crypt-init2-BcGT--df.js.map +1 -0
- package/dist/{crypt-init2-DparLekm.cjs → crypt-init2-Bkee1YxV.cjs} +2 -2
- package/dist/crypt-init2-Bkee1YxV.cjs.map +1 -0
- package/dist/crypto/crypt.d.ts.map +1 -1
- package/dist/crypto/eax.d.ts.map +1 -1
- package/dist/crypto/identity.d.ts +13 -1
- package/dist/crypto/identity.d.ts.map +1 -1
- package/dist/crypto/index.cjs +1 -1
- package/dist/crypto/index.d.ts +2 -1
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.mjs +3 -3
- package/dist/{crypto-CDlweUL3.cjs → crypto-BfDd9DP6.cjs} +2 -2
- package/dist/crypto-BfDd9DP6.cjs.map +1 -0
- package/dist/{crypto-Bg02m4ZE.js → crypto-DLV3oH5F.js} +12 -12
- package/dist/crypto-DLV3oH5F.js.map +1 -0
- package/dist/discovery/resolver.d.ts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/{handler-DI_abe9c.js → handler-BpdZFsKo.js} +104 -102
- package/dist/handler-BpdZFsKo.js.map +1 -0
- package/dist/handler-aywHvv7I.cjs +2 -0
- package/dist/handler-aywHvv7I.cjs.map +1 -0
- package/dist/handshake/index.cjs +1 -1
- package/dist/handshake/index.mjs +1 -1
- package/dist/handshake/license.d.ts.map +1 -1
- package/dist/handshake.d.ts +9 -0
- package/dist/handshake.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +314 -279
- package/dist/index.mjs.map +1 -1
- package/dist/{parser-DZMv3Jm-.js → parser-BX8NEiBe.js} +4 -4
- package/dist/parser-BX8NEiBe.js.map +1 -0
- package/dist/parser-BfwYH2fT.cjs +2 -0
- package/dist/parser-BfwYH2fT.cjs.map +1 -0
- package/dist/{primitives-xIr6Tjk4.js → primitives-CdX74Rgu.js} +194 -190
- package/dist/primitives-CdX74Rgu.js.map +1 -0
- package/dist/primitives-DkwW7wcP.cjs +2 -0
- package/dist/primitives-DkwW7wcP.cjs.map +1 -0
- package/dist/resolver-6B8dI9gr.js.map +1 -1
- package/dist/resolver-DCcmyWSK.cjs.map +1 -1
- package/dist/throttle.d.ts.map +1 -1
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transport/generation-window.d.ts.map +1 -1
- package/dist/transport/handler.d.ts +9 -1
- package/dist/transport/handler.d.ts.map +1 -1
- package/dist/transport/index.cjs +1 -1
- package/dist/transport/index.mjs +1 -1
- package/dist/transport/quicklz.d.ts.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/dist/address.test.d.ts +0 -2
- package/dist/address.test.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.test.d.ts +0 -2
- package/dist/command/command.test.d.ts.map +0 -1
- package/dist/crypt-init2-D70ha4LB.js.map +0 -1
- 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-Bg02m4ZE.js.map +0 -1
- package/dist/crypto-CDlweUL3.cjs.map +0 -1
- 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.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/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.map +0 -1
- package/dist/primitives-cNNAeFCo.cjs +0 -2
- package/dist/primitives-cNNAeFCo.cjs.map +0 -1
- package/dist/primitives-xIr6Tjk4.js.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/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/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { a as e, i as t, o as n } from "./address-BfmovVpp.js";
|
|
2
|
-
import { C as r, S as i,
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { a as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import { createHash as
|
|
11
|
-
import { createConnection as
|
|
2
|
+
import { C as r, S as i, T as a, _ as o, b as s, d as c, g as l, h as u, l as d, o as f, p, r as m, u as h, v as g, w as _, x as v, y } from "./primitives-CdX74Rgu.js";
|
|
3
|
+
import { t as b } from "./crypto-DLV3oH5F.js";
|
|
4
|
+
import { t as x } from "./resolver-6B8dI9gr.js";
|
|
5
|
+
import { a as S, t as C } from "./handler-BpdZFsKo.js";
|
|
6
|
+
import { i as w, n as T, t as E } from "./command-BLe-C2L2.js";
|
|
7
|
+
import { n as ee } from "./crypt-handshake-DziOY4Lq.js";
|
|
8
|
+
import { t as te } from "./crypt-init2-BcGT--df.js";
|
|
9
|
+
import { t as D } from "./parser-BX8NEiBe.js";
|
|
10
|
+
import { createHash as O } from "node:crypto";
|
|
11
|
+
import { createConnection as k } from "node:net";
|
|
12
12
|
//#region src/commands.ts
|
|
13
|
-
var
|
|
13
|
+
var A = class {
|
|
14
14
|
#e = /* @__PURE__ */ new Map();
|
|
15
15
|
#t = 0;
|
|
16
16
|
#n = [];
|
|
@@ -50,25 +50,84 @@ var O = class {
|
|
|
50
50
|
this.#e.clear(), this.#n = [], this.#r = !1, this.#t = 0;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
function
|
|
54
|
-
let t = e.id ?? "0", n = e.msg ?? "",
|
|
55
|
-
t !== "0" && (
|
|
56
|
-
let
|
|
57
|
-
if (
|
|
58
|
-
let e = parseInt(
|
|
59
|
-
isNaN(e) || (
|
|
53
|
+
function j(e) {
|
|
54
|
+
let t = e.id ?? "0", n = e.msg ?? "", r = e.return_code, i = null;
|
|
55
|
+
t !== "0" && (i = new _(t, n));
|
|
56
|
+
let a = null;
|
|
57
|
+
if (r !== void 0 && r !== "") {
|
|
58
|
+
let e = parseInt(r, 10);
|
|
59
|
+
isNaN(e) || (a = e);
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
|
-
err:
|
|
63
|
-
rc:
|
|
62
|
+
err: i,
|
|
63
|
+
rc: a
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function M(e, t) {
|
|
67
67
|
return e.includes("return_code=") ? e : `${e} return_code=${t}`;
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
|
+
//#region src/handshake.ts
|
|
71
|
+
function N(e, t) {
|
|
72
|
+
let n = t.alpha ?? "", r = t.beta ?? "", i = t.omega ?? "";
|
|
73
|
+
e.crypt.initCrypto(n, r, i), e.logger.info("crypto initialized (P-256 path), sending clientinit"), z(e);
|
|
74
|
+
}
|
|
75
|
+
function P(e, t) {
|
|
76
|
+
e.logger.info("received initivexpand2"), e.handler.receivedFinalInitAck();
|
|
77
|
+
let n = t.l ?? "", r = t.omega ?? "", i = t.proof ?? "", a = t.beta ?? "", o = I(e, a);
|
|
78
|
+
te(e.crypt, n, r, i, a, o), z(e);
|
|
79
|
+
}
|
|
80
|
+
function F(e, t) {
|
|
81
|
+
let n = t.aclid ?? t.clid ?? "", r = n ? parseInt(n, 10) : 0;
|
|
82
|
+
r > 0 && (e.clid = r, e.handler.setClientID(r));
|
|
83
|
+
let i = t.virtualserver_version;
|
|
84
|
+
i && (e.uidAlgorithm = u(i)), e.logger.info("connected to server", { selfId: e.clid }), e._markConnected(), setImmediate(() => {
|
|
85
|
+
let t = E("clientupdate", {
|
|
86
|
+
client_input_muted: "0",
|
|
87
|
+
client_output_muted: "0"
|
|
88
|
+
});
|
|
89
|
+
e.sendCommandNoWait(t).catch(() => {});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function I(e, t) {
|
|
93
|
+
let [n, r] = m(), i = Buffer.from(n).toString("base64"), a = L(e, n, t), o = T("clientek", [["ek", i], ["proof", a]]);
|
|
94
|
+
return e.handler.sendPacket(S.Command, Buffer.from(o), 0), r;
|
|
95
|
+
}
|
|
96
|
+
function L(e, t, n) {
|
|
97
|
+
let r = Buffer.from(n, "base64"), i = /* @__PURE__ */ new Uint8Array(86);
|
|
98
|
+
i.set(t.slice(0, 32)), i.set(r.slice(0, Math.min(54, r.length)), 32);
|
|
99
|
+
let a = f(e.crypt.identity.privateKey, i);
|
|
100
|
+
return Buffer.from(a).toString("base64");
|
|
101
|
+
}
|
|
102
|
+
function R(e) {
|
|
103
|
+
return e === "" ? "" : O("sha1").update(e).digest().toString("base64");
|
|
104
|
+
}
|
|
105
|
+
function z(e) {
|
|
106
|
+
let t = B(e);
|
|
107
|
+
e.handler.sendPacket(S.Command, Buffer.from(t), 0);
|
|
108
|
+
}
|
|
109
|
+
function B(e) {
|
|
110
|
+
let t = e.crypt.identity.publicKeyBase64(), n = e.getClientInitOptions(), r = R(n.defaultChannelPassword), i = R(n.serverPassword), a = O("sha1").update(t).digest().toString("base64");
|
|
111
|
+
return T("clientinit", [
|
|
112
|
+
["client_nickname", e.nickname],
|
|
113
|
+
["client_version", "3.?.? [Build: 5680278000]"],
|
|
114
|
+
["client_platform", "Windows"],
|
|
115
|
+
["client_input_hardware", "1"],
|
|
116
|
+
["client_output_hardware", "1"],
|
|
117
|
+
["client_default_channel", n.defaultChannel],
|
|
118
|
+
["client_default_channel_password", r],
|
|
119
|
+
["client_server_password", i],
|
|
120
|
+
["client_meta_data", ""],
|
|
121
|
+
["client_version_sign", "DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg=="],
|
|
122
|
+
["client_key_offset", String(e.crypt.identity.offset)],
|
|
123
|
+
["client_nickname_phonetic", ""],
|
|
124
|
+
["client_default_token", ""],
|
|
125
|
+
["hwid", a]
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
70
129
|
//#region src/transfer.ts
|
|
71
|
-
var
|
|
130
|
+
var V = class {
|
|
72
131
|
#e = /* @__PURE__ */ new Map();
|
|
73
132
|
#t = 0;
|
|
74
133
|
register() {
|
|
@@ -89,127 +148,70 @@ var j = class {
|
|
|
89
148
|
this.#e.clear(), this.#t = 0;
|
|
90
149
|
}
|
|
91
150
|
};
|
|
92
|
-
function
|
|
151
|
+
function H(e, t, n) {
|
|
93
152
|
return new Promise((r, i) => {
|
|
94
|
-
let a =
|
|
153
|
+
let a = k({
|
|
95
154
|
host: e,
|
|
96
155
|
port: t
|
|
97
156
|
}, () => {
|
|
98
157
|
a.write(n, (e) => {
|
|
99
|
-
e ? (a.destroy(), i(new
|
|
158
|
+
e ? (a.destroy(), i(new v(`failed to send transfer key: ${e.message}`))) : r(a);
|
|
100
159
|
});
|
|
101
160
|
});
|
|
102
161
|
a.setTimeout(1e4), a.once("error", i), a.once("timeout", () => {
|
|
103
|
-
a.destroy(), i(new
|
|
162
|
+
a.destroy(), i(new v("connection timeout"));
|
|
104
163
|
});
|
|
105
164
|
});
|
|
106
165
|
}
|
|
107
|
-
async function
|
|
108
|
-
let r = await
|
|
166
|
+
async function U(e, t, n) {
|
|
167
|
+
let r = await H(e, t.port, t.fileTransferKey);
|
|
109
168
|
await new Promise((e, t) => {
|
|
110
169
|
n.pipe(r), r.on("finish", e), r.on("error", t);
|
|
111
170
|
});
|
|
112
171
|
}
|
|
113
|
-
async function
|
|
114
|
-
let r = await
|
|
172
|
+
async function W(e, t, n) {
|
|
173
|
+
let r = await H(e, t.port, t.fileTransferKey);
|
|
115
174
|
await new Promise((e, t) => {
|
|
116
175
|
r.pipe(n), n.on("finish", e), r.on("error", t), n.on("error", t);
|
|
117
176
|
});
|
|
118
177
|
}
|
|
119
|
-
function
|
|
178
|
+
function G(e, t, n, r, i, a) {
|
|
120
179
|
let o = t.startsWith("/") ? t : `/${t}`;
|
|
121
|
-
return
|
|
180
|
+
return E("ftinitupload", {
|
|
122
181
|
cid: String(e),
|
|
123
182
|
name: o,
|
|
124
|
-
cpw: n,
|
|
183
|
+
cpw: R(n),
|
|
125
184
|
size: String(r),
|
|
126
185
|
clientftfid: String(i),
|
|
127
186
|
overwrite: a ? "1" : "0",
|
|
128
187
|
resume: "0"
|
|
129
188
|
});
|
|
130
189
|
}
|
|
131
|
-
function
|
|
190
|
+
function K(e, t, n, r) {
|
|
132
191
|
let i = t.startsWith("/") ? t : `/${t}`;
|
|
133
|
-
return
|
|
192
|
+
return E("ftinitdownload", {
|
|
134
193
|
cid: String(e),
|
|
135
194
|
name: i,
|
|
136
|
-
cpw: n,
|
|
195
|
+
cpw: R(n),
|
|
137
196
|
clientftfid: String(r),
|
|
138
197
|
seekpos: "0"
|
|
139
198
|
});
|
|
140
199
|
}
|
|
141
200
|
//#endregion
|
|
142
201
|
//#region src/events.ts
|
|
143
|
-
function
|
|
202
|
+
function ne(e, t) {
|
|
144
203
|
let n = t;
|
|
145
204
|
for (let t = e.length - 1; t >= 0; t--) n = e[t](n);
|
|
146
205
|
return n;
|
|
147
206
|
}
|
|
148
|
-
function
|
|
207
|
+
function q(e, t) {
|
|
149
208
|
let n = t;
|
|
150
209
|
for (let t = e.length - 1; t >= 0; t--) n = e[t](n);
|
|
151
210
|
return n;
|
|
152
211
|
}
|
|
153
212
|
//#endregion
|
|
154
|
-
//#region src/handshake.ts
|
|
155
|
-
function z(e, t) {
|
|
156
|
-
let n = t.alpha ?? "", r = t.beta ?? "", i = t.omega ?? "";
|
|
157
|
-
e.crypt.initCrypto(n, r, i), e.logger.info("crypto initialized (P-256 path), sending clientinit"), G(e);
|
|
158
|
-
}
|
|
159
|
-
function B(e, t) {
|
|
160
|
-
e.logger.info("received initivexpand2"), e.handler.receivedFinalInitAck();
|
|
161
|
-
let n = t.l ?? "", r = t.omega ?? "", i = t.proof ?? "", a = t.beta ?? "", o = H(e, a);
|
|
162
|
-
ne(e.crypt, n, r, i, a, o), G(e);
|
|
163
|
-
}
|
|
164
|
-
function V(e, t) {
|
|
165
|
-
let n = t.aclid ?? t.clid ?? "", r = n ? parseInt(n, 10) : 0;
|
|
166
|
-
r > 0 && (e.clid = r, e.handler.setClientID(r)), e.logger.info("connected to server", { selfId: e.clid }), e._markConnected(), setImmediate(() => {
|
|
167
|
-
let t = w("clientupdate", {
|
|
168
|
-
client_input_muted: "0",
|
|
169
|
-
client_output_muted: "0"
|
|
170
|
-
});
|
|
171
|
-
e.sendCommandNoWait(t).catch(() => {});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function H(e, t) {
|
|
175
|
-
let [n, r] = p(), i = Buffer.from(n).toString("base64"), a = U(e, n, t), o = C("clientek", [["ek", i], ["proof", a]]);
|
|
176
|
-
return e.handler.sendPacket(b.Command, Buffer.from(o), 0), r;
|
|
177
|
-
}
|
|
178
|
-
function U(e, t, n) {
|
|
179
|
-
let r = Buffer.from(n, "base64"), i = /* @__PURE__ */ new Uint8Array(86);
|
|
180
|
-
i.set(t.slice(0, 32)), i.set(r.slice(0, Math.min(54, r.length)), 32);
|
|
181
|
-
let a = d(e.crypt.identity.privateKey, i);
|
|
182
|
-
return Buffer.from(a).toString("base64");
|
|
183
|
-
}
|
|
184
|
-
function W(e) {
|
|
185
|
-
return e === "" ? "" : E("sha1").update(e).digest().toString("base64");
|
|
186
|
-
}
|
|
187
|
-
function G(e) {
|
|
188
|
-
let t = K(e);
|
|
189
|
-
e.handler.sendPacket(b.Command, Buffer.from(t), 0);
|
|
190
|
-
}
|
|
191
|
-
function K(e) {
|
|
192
|
-
let t = e.crypt.identity.publicKeyBase64(), n = e.getClientInitOptions(), r = W(n.defaultChannelPassword), i = W(n.serverPassword), a = E("sha1").update(t).digest().toString("base64");
|
|
193
|
-
return C("clientinit", [
|
|
194
|
-
["client_nickname", e.nickname],
|
|
195
|
-
["client_version", "3.?.? [Build: 5680278000]"],
|
|
196
|
-
["client_platform", "Windows"],
|
|
197
|
-
["client_input_hardware", "1"],
|
|
198
|
-
["client_output_hardware", "1"],
|
|
199
|
-
["client_default_channel", n.defaultChannel],
|
|
200
|
-
["client_default_channel_password", r],
|
|
201
|
-
["client_server_password", i],
|
|
202
|
-
["client_meta_data", ""],
|
|
203
|
-
["client_version_sign", "DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg=="],
|
|
204
|
-
["client_key_offset", String(e.crypt.identity.offset)],
|
|
205
|
-
["client_nickname_phonetic", ""],
|
|
206
|
-
["client_default_token", ""],
|
|
207
|
-
["hwid", a]
|
|
208
|
-
]);
|
|
209
|
-
}
|
|
210
|
-
//#endregion
|
|
211
213
|
//#region src/helpers.ts
|
|
212
|
-
function
|
|
214
|
+
function J(e) {
|
|
213
215
|
if (e === "" || e === void 0) return 0n;
|
|
214
216
|
try {
|
|
215
217
|
return BigInt(e);
|
|
@@ -217,21 +219,21 @@ function q(e) {
|
|
|
217
219
|
return 0n;
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
|
-
function
|
|
222
|
+
function Y(e) {
|
|
221
223
|
let t = parseInt(e, 10);
|
|
222
224
|
return isNaN(t) || t < 0 || t > 65535 ? 0 : t;
|
|
223
225
|
}
|
|
224
|
-
function
|
|
226
|
+
function X(e) {
|
|
225
227
|
let t = parseInt(e, 10);
|
|
226
228
|
return isNaN(t) ? 0 : t;
|
|
227
229
|
}
|
|
228
|
-
function
|
|
230
|
+
function Z(e, t) {
|
|
229
231
|
if (t === e) return !0;
|
|
230
232
|
if (!t.startsWith(e)) return !1;
|
|
231
233
|
let n = t.slice(e.length);
|
|
232
234
|
return /^\d+$/.test(n);
|
|
233
235
|
}
|
|
234
|
-
function
|
|
236
|
+
function re(e) {
|
|
235
237
|
let t = e.indexOf(" ");
|
|
236
238
|
if (t < 0) return [e];
|
|
237
239
|
let n = e.slice(0, t), r = e.slice(t + 1);
|
|
@@ -255,30 +257,30 @@ function Q(e) {
|
|
|
255
257
|
}
|
|
256
258
|
//#endregion
|
|
257
259
|
//#region src/notifications.ts
|
|
258
|
-
function
|
|
260
|
+
function ie(e, t, n, r) {
|
|
259
261
|
switch (e.name) {
|
|
260
|
-
case "notifycliententerview": return
|
|
261
|
-
case "notifyclientleftview": return
|
|
262
|
-
case "notifyclientmoved": return
|
|
263
|
-
case "notifytextmessage": return
|
|
264
|
-
case "notifyclientpoke": return
|
|
262
|
+
case "notifycliententerview": return ae(e, n, r);
|
|
263
|
+
case "notifyclientleftview": return oe(e, t, n);
|
|
264
|
+
case "notifyclientmoved": return se(e, n);
|
|
265
|
+
case "notifytextmessage": return ce(e, n);
|
|
266
|
+
case "notifyclientpoke": return fe(e);
|
|
265
267
|
case "notifystartupload": return {
|
|
266
268
|
kind: "startUpload",
|
|
267
|
-
info:
|
|
269
|
+
info: le(e)
|
|
268
270
|
};
|
|
269
271
|
case "notifystartdownload": return {
|
|
270
272
|
kind: "startDownload",
|
|
271
|
-
info:
|
|
273
|
+
info: ue(e)
|
|
272
274
|
};
|
|
273
275
|
case "notifystatusfiletransfer": return {
|
|
274
276
|
kind: "fileTransferStatus",
|
|
275
|
-
info:
|
|
277
|
+
info: de(e)
|
|
276
278
|
};
|
|
277
279
|
default: return { kind: "unknown" };
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
|
-
function
|
|
281
|
-
let r =
|
|
282
|
+
function ae(e, t, n) {
|
|
283
|
+
let r = Y(e.params.clid ?? ""), i = J(e.params.ctid ?? ""), a = X(e.params.client_type ?? ""), o = e.params.client_servergroups ?? "", s = {
|
|
282
284
|
id: r,
|
|
283
285
|
nickname: e.params.client_nickname ?? "",
|
|
284
286
|
uid: e.params.client_unique_identifier ?? "",
|
|
@@ -291,21 +293,21 @@ function ie(e, t, n) {
|
|
|
291
293
|
info: s
|
|
292
294
|
};
|
|
293
295
|
}
|
|
294
|
-
function
|
|
295
|
-
let r =
|
|
296
|
+
function oe(e, t, n) {
|
|
297
|
+
let r = Y(e.params.clid ?? ""), i = X(e.params.reasonid ?? ""), a = r === t;
|
|
296
298
|
return r !== 0 && n.delete(r), {
|
|
297
299
|
kind: "clientLeave",
|
|
298
300
|
event: {
|
|
299
301
|
id: r,
|
|
300
302
|
reasonID: i,
|
|
301
303
|
reasonMsg: e.params.reasonmsg ?? "",
|
|
302
|
-
targetID:
|
|
304
|
+
targetID: Y(e.params.targetid ?? "")
|
|
303
305
|
},
|
|
304
306
|
isSelf: a
|
|
305
307
|
};
|
|
306
308
|
}
|
|
307
|
-
function
|
|
308
|
-
let n =
|
|
309
|
+
function se(e, t) {
|
|
310
|
+
let n = Y(e.params.clid ?? ""), r = J(e.params.ctid ?? "");
|
|
309
311
|
if (n !== 0) {
|
|
310
312
|
let e = t.get(n);
|
|
311
313
|
e && t.set(n, {
|
|
@@ -318,67 +320,67 @@ function oe(e, t) {
|
|
|
318
320
|
event: {
|
|
319
321
|
id: n,
|
|
320
322
|
targetChannelID: r,
|
|
321
|
-
reasonID:
|
|
322
|
-
invokerID:
|
|
323
|
+
reasonID: X(e.params.reasonid ?? ""),
|
|
324
|
+
invokerID: Y(e.params.invokerid ?? ""),
|
|
323
325
|
invokerName: e.params.invokername ?? "",
|
|
324
326
|
invokerUID: e.params.invokeruid ?? ""
|
|
325
327
|
}
|
|
326
328
|
};
|
|
327
329
|
}
|
|
328
|
-
function
|
|
329
|
-
let n =
|
|
330
|
+
function ce(e, t) {
|
|
331
|
+
let n = Y(e.params.invokerid ?? ""), r = t.get(n);
|
|
330
332
|
return {
|
|
331
333
|
kind: "textMessage",
|
|
332
334
|
message: {
|
|
333
|
-
targetMode:
|
|
334
|
-
targetID:
|
|
335
|
+
targetMode: X(e.params.targetmode ?? ""),
|
|
336
|
+
targetID: J(e.params.target ?? ""),
|
|
335
337
|
invokerID: n,
|
|
336
338
|
invokerName: e.params.invokername ?? "",
|
|
337
339
|
invokerUID: e.params.invokeruid ?? r?.uid ?? "",
|
|
338
|
-
message:
|
|
340
|
+
message: w(e.params.msg ?? ""),
|
|
339
341
|
invokerGroups: r?.serverGroups ?? []
|
|
340
342
|
}
|
|
341
343
|
};
|
|
342
344
|
}
|
|
343
|
-
function
|
|
345
|
+
function le(e) {
|
|
344
346
|
return {
|
|
345
|
-
clientFileTransferID:
|
|
346
|
-
serverFileTransferID:
|
|
347
|
+
clientFileTransferID: Y(e.params.clientftfid ?? ""),
|
|
348
|
+
serverFileTransferID: Y(e.params.serverftfid ?? ""),
|
|
347
349
|
fileTransferKey: e.params.ftkey ?? "",
|
|
348
|
-
port:
|
|
349
|
-
seekPosition:
|
|
350
|
+
port: Y(e.params.port ?? ""),
|
|
351
|
+
seekPosition: J(e.params.seekpos ?? "")
|
|
350
352
|
};
|
|
351
353
|
}
|
|
352
|
-
function
|
|
354
|
+
function ue(e) {
|
|
353
355
|
return {
|
|
354
|
-
clientFileTransferID:
|
|
355
|
-
serverFileTransferID:
|
|
356
|
+
clientFileTransferID: Y(e.params.clientftfid ?? ""),
|
|
357
|
+
serverFileTransferID: Y(e.params.serverftfid ?? ""),
|
|
356
358
|
fileTransferKey: e.params.ftkey ?? "",
|
|
357
|
-
port:
|
|
358
|
-
size:
|
|
359
|
+
port: Y(e.params.port ?? ""),
|
|
360
|
+
size: J(e.params.size ?? "")
|
|
359
361
|
};
|
|
360
362
|
}
|
|
361
|
-
function
|
|
363
|
+
function de(e) {
|
|
362
364
|
return {
|
|
363
|
-
clientFileTransferID:
|
|
364
|
-
status:
|
|
365
|
+
clientFileTransferID: Y(e.params.clientftfid ?? ""),
|
|
366
|
+
status: X(e.params.status ?? ""),
|
|
365
367
|
message: e.params.msg ?? ""
|
|
366
368
|
};
|
|
367
369
|
}
|
|
368
|
-
function
|
|
370
|
+
function fe(e) {
|
|
369
371
|
return {
|
|
370
372
|
kind: "poked",
|
|
371
373
|
event: {
|
|
372
|
-
invokerID:
|
|
373
|
-
invokerName:
|
|
374
|
+
invokerID: Y(e.params.invokerid ?? ""),
|
|
375
|
+
invokerName: w(e.params.invokername ?? ""),
|
|
374
376
|
invokerUID: e.params.invokeruid ?? "",
|
|
375
|
-
message:
|
|
377
|
+
message: w(e.params.msg ?? "")
|
|
376
378
|
}
|
|
377
379
|
};
|
|
378
380
|
}
|
|
379
381
|
//#endregion
|
|
380
382
|
//#region src/throttle.ts
|
|
381
|
-
var
|
|
383
|
+
var pe = class e {
|
|
382
384
|
static TOKEN_RATE = 4;
|
|
383
385
|
static TOKEN_MAX = 8;
|
|
384
386
|
#e = 5;
|
|
@@ -403,31 +405,32 @@ var fe = class e {
|
|
|
403
405
|
};
|
|
404
406
|
//#endregion
|
|
405
407
|
//#region src/client.ts
|
|
406
|
-
function
|
|
408
|
+
function $(e) {
|
|
407
409
|
return {
|
|
408
410
|
serverPassword: e.serverPassword ?? "",
|
|
409
411
|
defaultChannel: e.defaultChannel ?? "",
|
|
410
412
|
defaultChannelPassword: e.defaultChannelPassword ?? ""
|
|
411
413
|
};
|
|
412
414
|
}
|
|
413
|
-
var
|
|
415
|
+
var me = class {
|
|
414
416
|
crypt;
|
|
415
417
|
handler;
|
|
416
418
|
logger;
|
|
417
419
|
nickname;
|
|
418
420
|
clid = 0;
|
|
421
|
+
uidAlgorithm = "sha1";
|
|
419
422
|
#e;
|
|
420
423
|
#t;
|
|
421
424
|
#n;
|
|
422
425
|
#r;
|
|
423
|
-
#i
|
|
424
|
-
#a =
|
|
425
|
-
#o = new
|
|
426
|
-
#s = new
|
|
427
|
-
#c =
|
|
428
|
-
#l =
|
|
426
|
+
#i;
|
|
427
|
+
#a = t.Disconnected;
|
|
428
|
+
#o = new pe();
|
|
429
|
+
#s = new A();
|
|
430
|
+
#c = new V();
|
|
431
|
+
#l = /* @__PURE__ */ new Map();
|
|
429
432
|
#u = [];
|
|
430
|
-
#d =
|
|
433
|
+
#d = null;
|
|
431
434
|
#f = [];
|
|
432
435
|
#p = [];
|
|
433
436
|
#m = [];
|
|
@@ -437,96 +440,114 @@ var $ = class {
|
|
|
437
440
|
#v = [];
|
|
438
441
|
#y = [];
|
|
439
442
|
#b = [];
|
|
440
|
-
#x;
|
|
441
|
-
#S;
|
|
443
|
+
#x = [];
|
|
444
|
+
#S = [];
|
|
445
|
+
#C;
|
|
446
|
+
#w;
|
|
442
447
|
constructor(t, n, r, i = {}) {
|
|
443
|
-
this.#e = t, this.#t = n, this.nickname = r, this.logger = i.logger ?? e, this.#n = i.resolver ?? new
|
|
448
|
+
this.#e = t, this.#t = n, this.nickname = r, this.logger = i.logger ?? e, this.#n = i.resolver ?? new x(this.logger), this.#r = $(i), this.#i = i.socketFactory, this.crypt = new b(t), this.handler = new C(this.crypt, this.logger, this.#i), this.handler.onPacket = (e) => this.#D(e), this.handler.onClosed = (e) => this.#I(e), i.commandMiddleware && this.#x.push(...i.commandMiddleware), i.eventMiddleware && this.#S.push(...i.eventMiddleware), this.#C = this.#R(), this.#w = this.#z();
|
|
444
449
|
}
|
|
445
450
|
get status() {
|
|
446
|
-
return this.#
|
|
451
|
+
return this.#a;
|
|
447
452
|
}
|
|
448
453
|
getClientInitOptions() {
|
|
449
454
|
return this.#r;
|
|
450
455
|
}
|
|
451
456
|
async connect() {
|
|
452
|
-
if (this.#
|
|
453
|
-
this.#
|
|
454
|
-
let e = await this.#
|
|
457
|
+
if (this.#a !== t.Disconnected) throw new l();
|
|
458
|
+
this.#T(), this.#a = t.Connecting;
|
|
459
|
+
let e = await this.#E();
|
|
455
460
|
this.logger.info("connecting to server", { address: e }), await this.handler.connect(e);
|
|
456
461
|
}
|
|
457
462
|
async disconnect() {
|
|
458
|
-
if (this.#
|
|
459
|
-
let e = this.#
|
|
460
|
-
if (this.#
|
|
463
|
+
if (this.#a === t.Disconnected) return;
|
|
464
|
+
let e = this.#a === t.Connected;
|
|
465
|
+
if (this.#a = t.Disconnected, this.logger.info("disconnecting from server"), e) try {
|
|
461
466
|
await this.execCommand("clientdisconnect reasonmsg=Shutdown", 1e3);
|
|
462
467
|
} catch {}
|
|
463
468
|
this.handler.close();
|
|
464
|
-
let n = this.#
|
|
469
|
+
let n = this.#y.slice();
|
|
465
470
|
for (let e of n) setImmediate(() => e(void 0));
|
|
466
471
|
}
|
|
467
472
|
waitConnected(e) {
|
|
468
|
-
return this.#
|
|
469
|
-
|
|
473
|
+
return this.#a === t.Connected ? Promise.resolve() : this.#d ? Promise.reject(this.#d) : new Promise((t, n) => {
|
|
474
|
+
let r = {
|
|
475
|
+
resolve: () => {
|
|
476
|
+
e?.removeEventListener("abort", i), t();
|
|
477
|
+
},
|
|
478
|
+
reject: (t) => {
|
|
479
|
+
e?.removeEventListener("abort", i), n(t);
|
|
480
|
+
}
|
|
481
|
+
}, i = () => {
|
|
482
|
+
let t = this.#u.indexOf(r);
|
|
483
|
+
t >= 0 && this.#u.splice(t, 1);
|
|
484
|
+
let n = e?.reason;
|
|
485
|
+
r.reject(n instanceof Error ? n : Error(String(n ?? "Connection wait aborted")));
|
|
486
|
+
};
|
|
487
|
+
this.#u.push(r), e?.aborted ? i() : e?.addEventListener("abort", i, { once: !0 });
|
|
470
488
|
});
|
|
471
489
|
}
|
|
472
490
|
async sendCommandNoWait(e) {
|
|
473
|
-
await this.#
|
|
491
|
+
await this.#o.wait(), await this.#C(e);
|
|
474
492
|
}
|
|
475
493
|
async execCommand(e, t = 1e4) {
|
|
476
494
|
await this.execCommandWithResponse(e, t);
|
|
477
495
|
}
|
|
478
496
|
async execCommandWithResponse(e, t = 1e4) {
|
|
479
|
-
let [n, r] = this.#
|
|
497
|
+
let [n, r] = this.#s.register(), i = M(e, n);
|
|
480
498
|
try {
|
|
481
|
-
await this.#
|
|
499
|
+
await this.#o.wait(), await this.#C(i);
|
|
482
500
|
} catch (e) {
|
|
483
|
-
throw this.#
|
|
501
|
+
throw this.#s.unregister(n), e;
|
|
484
502
|
}
|
|
485
|
-
let a = await Promise.race([r, new Promise((n, r) => setTimeout(() => r(new
|
|
486
|
-
if (this.#
|
|
503
|
+
let a = await Promise.race([r, new Promise((n, r) => setTimeout(() => r(new o(e)), t))]);
|
|
504
|
+
if (this.#s.unregister(n), a.err) throw a.err;
|
|
487
505
|
return a.data;
|
|
488
506
|
}
|
|
489
507
|
on(e, t) {
|
|
490
508
|
switch (e) {
|
|
491
509
|
case "textMessage":
|
|
492
|
-
this.#
|
|
510
|
+
this.#f.push(t);
|
|
493
511
|
break;
|
|
494
512
|
case "clientEnter":
|
|
495
|
-
this.#
|
|
513
|
+
this.#p.push(t);
|
|
496
514
|
break;
|
|
497
515
|
case "clientLeave":
|
|
498
|
-
this.#
|
|
516
|
+
this.#m.push(t);
|
|
499
517
|
break;
|
|
500
518
|
case "clientMoved":
|
|
501
|
-
this.#
|
|
519
|
+
this.#h.push(t);
|
|
502
520
|
break;
|
|
503
521
|
case "poked":
|
|
504
|
-
this.#
|
|
522
|
+
this.#g.push(t);
|
|
505
523
|
break;
|
|
506
524
|
case "voiceData":
|
|
507
|
-
this.#
|
|
525
|
+
this.#_.push(t);
|
|
508
526
|
break;
|
|
509
527
|
case "connected":
|
|
510
|
-
this.#
|
|
528
|
+
this.#v.push(t);
|
|
511
529
|
break;
|
|
512
530
|
case "disconnected":
|
|
513
|
-
this.#
|
|
531
|
+
this.#y.push(t);
|
|
514
532
|
break;
|
|
515
|
-
case "kicked": this.#
|
|
533
|
+
case "kicked": this.#b.push(t);
|
|
516
534
|
}
|
|
517
535
|
return this;
|
|
518
536
|
}
|
|
519
537
|
useCommandMiddleware(...e) {
|
|
520
|
-
return this.#
|
|
538
|
+
return this.#x.push(...e), this.#C = this.#R(), this;
|
|
521
539
|
}
|
|
522
540
|
useEventMiddleware(...e) {
|
|
523
|
-
return this.#
|
|
541
|
+
return this.#S.push(...e), this.#w = this.#z(), this;
|
|
524
542
|
}
|
|
525
543
|
clientID() {
|
|
526
544
|
return this.clid;
|
|
527
545
|
}
|
|
546
|
+
uniqueIdentifier() {
|
|
547
|
+
return c(this.#e.publicKeyBase64(), this.uidAlgorithm);
|
|
548
|
+
}
|
|
528
549
|
channelID() {
|
|
529
|
-
return this.#
|
|
550
|
+
return this.#l.get(this.clid)?.channelID ?? 0n;
|
|
530
551
|
}
|
|
531
552
|
sendWhisper(e, t, n) {
|
|
532
553
|
this.handler.sendWhisperPacket(e, t, n);
|
|
@@ -534,53 +555,53 @@ var $ = class {
|
|
|
534
555
|
sendVoice(e, t) {
|
|
535
556
|
this.handler.sendVoicePacket(e, t);
|
|
536
557
|
}
|
|
537
|
-
async fileTransferInitUpload(e, t, n, r,
|
|
538
|
-
let [
|
|
558
|
+
async fileTransferInitUpload(e, t, n, r, a = !1) {
|
|
559
|
+
let [o, s] = this.#c.register(), c = G(e, t, n, r, o, a);
|
|
539
560
|
try {
|
|
540
561
|
await this.execCommand(c, 1e4);
|
|
541
562
|
} catch (e) {
|
|
542
|
-
throw this.#
|
|
563
|
+
throw this.#c.unregister(o), e;
|
|
543
564
|
}
|
|
544
|
-
let l = await Promise.race([s, new Promise((e, t) => setTimeout(() => t(new
|
|
545
|
-
if (this.#
|
|
565
|
+
let l = await Promise.race([s, new Promise((e, t) => setTimeout(() => t(new i()), 1e4))]);
|
|
566
|
+
if (this.#c.unregister(o), "size" in l) throw new v("unexpected download response");
|
|
546
567
|
if ("status" in l) {
|
|
547
568
|
let e = l;
|
|
548
|
-
throw new
|
|
569
|
+
throw new v(`${e.message} (status=${e.status})`);
|
|
549
570
|
}
|
|
550
571
|
return l;
|
|
551
572
|
}
|
|
552
573
|
async fileTransferInitDownload(e, t, n) {
|
|
553
|
-
let [r,
|
|
574
|
+
let [r, a] = this.#c.register(), o = K(e, t, n, r);
|
|
554
575
|
try {
|
|
555
|
-
await this.execCommand(
|
|
576
|
+
await this.execCommand(o, 1e4);
|
|
556
577
|
} catch (e) {
|
|
557
|
-
throw this.#
|
|
578
|
+
throw this.#c.unregister(r), e;
|
|
558
579
|
}
|
|
559
|
-
let s = await Promise.race([
|
|
560
|
-
if (this.#
|
|
580
|
+
let s = await Promise.race([a, new Promise((e, t) => setTimeout(() => t(new i()), 1e4))]);
|
|
581
|
+
if (this.#c.unregister(r), "seekPosition" in s) throw new v("unexpected upload response");
|
|
561
582
|
if ("status" in s) {
|
|
562
583
|
let e = s;
|
|
563
|
-
throw new
|
|
584
|
+
throw new v(`${e.message} (status=${e.status})`);
|
|
564
585
|
}
|
|
565
586
|
return s;
|
|
566
587
|
}
|
|
567
588
|
uploadFileData(e, t, n) {
|
|
568
|
-
return
|
|
589
|
+
return U(e, t, n);
|
|
569
590
|
}
|
|
570
591
|
downloadFileData(e, t, n) {
|
|
571
|
-
return
|
|
592
|
+
return W(e, t, n);
|
|
572
593
|
}
|
|
573
594
|
_markConnected() {
|
|
574
|
-
this.#
|
|
575
|
-
for (let e of this.#
|
|
576
|
-
this.#
|
|
577
|
-
let e = this.#
|
|
595
|
+
this.#a = t.Connected, this.#d = null;
|
|
596
|
+
for (let e of this.#u) e.resolve();
|
|
597
|
+
this.#u = [];
|
|
598
|
+
let e = this.#v.slice();
|
|
578
599
|
for (let t of e) setImmediate(() => t());
|
|
579
600
|
}
|
|
580
|
-
#
|
|
581
|
-
this.handler.close(), this.crypt = new
|
|
601
|
+
#T() {
|
|
602
|
+
this.#d = null, this.handler.close(), this.crypt = new b(this.#e), this.handler = new C(this.crypt, this.logger, this.#i), this.handler.onPacket = (e) => this.#D(e), this.handler.onClosed = (e) => this.#I(e), this.#s.reset(), this.#c.reset(), this.#l.clear(), this.clid = 0, this.#C = this.#R();
|
|
582
603
|
}
|
|
583
|
-
async #
|
|
604
|
+
async #E() {
|
|
584
605
|
let e = this.#t.includes(":") ? this.#t : `${this.#t}:9987`;
|
|
585
606
|
try {
|
|
586
607
|
return (await this.#n.resolve(this.#t))[0]?.addr ?? e;
|
|
@@ -588,24 +609,27 @@ var $ = class {
|
|
|
588
609
|
return e;
|
|
589
610
|
}
|
|
590
611
|
}
|
|
591
|
-
#
|
|
592
|
-
this.#
|
|
612
|
+
#D(e) {
|
|
613
|
+
this.#O(e);
|
|
593
614
|
}
|
|
594
|
-
#
|
|
615
|
+
#O(e) {
|
|
595
616
|
let t = e.typeFlagged & 15;
|
|
596
617
|
if (t === 8) {
|
|
597
|
-
let t =
|
|
598
|
-
t && this.handler.sendPacket(
|
|
618
|
+
let t = ee(this.crypt, e.data);
|
|
619
|
+
t && this.handler.sendPacket(S.Init1, t, 0);
|
|
599
620
|
return;
|
|
600
621
|
}
|
|
601
622
|
if ((t === 0 || t === 1) && e.data.length > 5) {
|
|
602
|
-
this.#
|
|
623
|
+
this.#k(e.data);
|
|
603
624
|
return;
|
|
604
625
|
}
|
|
605
|
-
(t === 2 || t === 3) && e.data.length > 0
|
|
626
|
+
if ((t === 2 || t === 3) && e.data.length > 0) {
|
|
627
|
+
let t = Buffer.from(e.data).toString("utf8");
|
|
628
|
+
process.env.TEAMSPEAK_TRACE_RAW && process.stderr.write(`S2C ${JSON.stringify(t)}\n`), this.#A(t);
|
|
629
|
+
}
|
|
606
630
|
}
|
|
607
|
-
#
|
|
608
|
-
if (this.#
|
|
631
|
+
#k(e) {
|
|
632
|
+
if (this.#_.length === 0) return;
|
|
609
633
|
let t = new DataView(e.buffer, e.byteOffset, e.byteLength).getUint16(2, !1);
|
|
610
634
|
if (t === this.clid) return;
|
|
611
635
|
let n = {
|
|
@@ -613,145 +637,156 @@ var $ = class {
|
|
|
613
637
|
codec: e[4],
|
|
614
638
|
data: e.subarray(5)
|
|
615
639
|
};
|
|
616
|
-
for (let e of this.#
|
|
640
|
+
for (let e of this.#_) setImmediate(() => e(n));
|
|
617
641
|
}
|
|
618
|
-
#
|
|
642
|
+
#A(e) {
|
|
619
643
|
if (!e) return;
|
|
620
644
|
let t = e.split("\0").join("\n").split("\n");
|
|
621
645
|
for (let e of t) {
|
|
622
646
|
let t = e.replace(/\r$/, "");
|
|
623
|
-
if (t) for (let e of
|
|
647
|
+
if (t) for (let e of re(t)) this.#j(e);
|
|
624
648
|
}
|
|
625
649
|
}
|
|
626
|
-
#
|
|
627
|
-
let t =
|
|
628
|
-
if (t
|
|
650
|
+
#j(e) {
|
|
651
|
+
let t = D(e);
|
|
652
|
+
if (t) {
|
|
653
|
+
if (t.name === "") {
|
|
654
|
+
Object.keys(t.params).length > 0 && this.#s.buffer(t.params);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (t.name === "channellistfinished") {
|
|
658
|
+
this.#s.signalWelcomeComplete();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
629
661
|
if (t.name.startsWith("notify")) {
|
|
630
|
-
let e =
|
|
631
|
-
this.#
|
|
662
|
+
let e = ie(t, this.clid, this.#l, this.nickname);
|
|
663
|
+
this.#N(e, t.params);
|
|
632
664
|
return;
|
|
633
665
|
}
|
|
634
666
|
switch (t.name) {
|
|
635
667
|
case "clientinitiv":
|
|
636
|
-
|
|
668
|
+
N(this, t.params);
|
|
637
669
|
break;
|
|
638
670
|
case "initivexpand2":
|
|
639
|
-
|
|
671
|
+
P(this, t.params);
|
|
640
672
|
break;
|
|
641
673
|
case "initserver":
|
|
642
|
-
|
|
674
|
+
F(this, t.params);
|
|
643
675
|
break;
|
|
644
676
|
case "error":
|
|
645
|
-
this.#
|
|
677
|
+
this.#M(t.params);
|
|
646
678
|
break;
|
|
647
|
-
default:
|
|
648
|
-
let e = t.params;
|
|
649
|
-
if (t.name.includes("=")) {
|
|
650
|
-
let n = t.name.indexOf("="), r = t.name.slice(0, n), i = t.name.slice(n + 1);
|
|
651
|
-
e = {
|
|
652
|
-
[r]: i,
|
|
653
|
-
...t.params
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
this.#o.buffer(e);
|
|
657
|
-
break;
|
|
658
|
-
}
|
|
679
|
+
default: this.#s.buffer(t.params);
|
|
659
680
|
}
|
|
660
681
|
}
|
|
661
682
|
}
|
|
662
|
-
#
|
|
663
|
-
let { err:
|
|
664
|
-
|
|
683
|
+
#M(e) {
|
|
684
|
+
let { err: n, rc: r } = j(e);
|
|
685
|
+
if (r === null ? this.#s.discardBuffer() : this.#s.resolve(r, n), n && this.#a !== t.Connected) {
|
|
686
|
+
this.#L(n);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
(e.id ?? "0") === "3329" && setImmediate(() => this.disconnect().catch(() => {}));
|
|
665
690
|
}
|
|
666
|
-
#
|
|
691
|
+
#N(e, t) {
|
|
667
692
|
switch (e.kind) {
|
|
668
693
|
case "clientEnter": {
|
|
669
694
|
let t = e.info;
|
|
670
|
-
t.id !== 0 &&
|
|
695
|
+
t.id !== 0 && t.id === this.clid ? this.nickname = t.nickname : t.id !== 0 && this.clid === 0 && Z(this.nickname, t.nickname) && (this.clid = t.id, this.handler.setClientID(t.id), this.nickname = t.nickname), this.#P("clientEnter", t);
|
|
671
696
|
break;
|
|
672
697
|
}
|
|
673
698
|
case "clientLeave":
|
|
674
|
-
if (this.#
|
|
699
|
+
if (this.#P("clientLeave", e.event), e.isSelf && (e.event.reasonID === 4 || e.event.reasonID === 5)) {
|
|
675
700
|
let t = e.event.reasonMsg;
|
|
676
|
-
for (let e of this.#
|
|
701
|
+
for (let e of this.#b) setImmediate(() => e(t));
|
|
677
702
|
}
|
|
678
703
|
break;
|
|
679
704
|
case "clientMoved":
|
|
680
|
-
this.#
|
|
705
|
+
this.#P("clientMoved", e.event);
|
|
681
706
|
break;
|
|
682
707
|
case "textMessage":
|
|
683
|
-
this.#
|
|
708
|
+
this.#P("textMessage", e.message);
|
|
684
709
|
break;
|
|
685
710
|
case "poked":
|
|
686
|
-
this.#
|
|
711
|
+
this.#P("poked", e.event);
|
|
687
712
|
break;
|
|
688
713
|
case "startUpload":
|
|
689
|
-
this.#
|
|
714
|
+
this.#c.notify(e.info.clientFileTransferID, e.info);
|
|
690
715
|
break;
|
|
691
716
|
case "startDownload":
|
|
692
|
-
this.#
|
|
717
|
+
this.#c.notify(e.info.clientFileTransferID, e.info);
|
|
693
718
|
break;
|
|
694
|
-
case "fileTransferStatus": this.#
|
|
719
|
+
case "fileTransferStatus": this.#c.notify(e.info.clientFileTransferID, e.info);
|
|
695
720
|
}
|
|
696
721
|
}
|
|
697
|
-
#
|
|
698
|
-
this.#
|
|
722
|
+
#P(e, t) {
|
|
723
|
+
this.#w(t);
|
|
699
724
|
}
|
|
700
|
-
#
|
|
725
|
+
#F(e, t) {
|
|
701
726
|
switch (e) {
|
|
702
727
|
case "textMessage":
|
|
703
|
-
for (let e of this.#
|
|
728
|
+
for (let e of this.#f) setImmediate(() => e(t));
|
|
704
729
|
break;
|
|
705
730
|
case "clientEnter":
|
|
706
|
-
for (let e of this.#
|
|
731
|
+
for (let e of this.#p) setImmediate(() => e(t));
|
|
707
732
|
break;
|
|
708
733
|
case "clientLeave":
|
|
709
|
-
for (let e of this.#
|
|
734
|
+
for (let e of this.#m) setImmediate(() => e(t));
|
|
710
735
|
break;
|
|
711
736
|
case "clientMoved":
|
|
712
|
-
for (let e of this.#
|
|
737
|
+
for (let e of this.#h) setImmediate(() => e(t));
|
|
713
738
|
break;
|
|
714
|
-
case "poked": for (let e of this.#
|
|
739
|
+
case "poked": for (let e of this.#g) setImmediate(() => e(t));
|
|
715
740
|
}
|
|
716
741
|
}
|
|
717
|
-
#
|
|
718
|
-
if (this.#
|
|
719
|
-
this.#
|
|
720
|
-
|
|
742
|
+
#I(e) {
|
|
743
|
+
if (this.#a === t.Disconnected) return;
|
|
744
|
+
if (this.#a !== t.Connected) {
|
|
745
|
+
this.#L(e ?? /* @__PURE__ */ Error("Connection closed before the TeamSpeak handshake completed"));
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
this.#a = t.Disconnected;
|
|
749
|
+
let n = this.#y.slice();
|
|
721
750
|
for (let t of n) setImmediate(() => t(e ?? void 0));
|
|
722
751
|
}
|
|
723
|
-
#
|
|
724
|
-
|
|
725
|
-
|
|
752
|
+
#L(e) {
|
|
753
|
+
this.#d = e;
|
|
754
|
+
let n = this.#u.splice(0);
|
|
755
|
+
for (let t of n) t.reject(e);
|
|
756
|
+
if (this.#a === t.Disconnected) return;
|
|
757
|
+
this.#a = t.Disconnected, this.handler.close();
|
|
758
|
+
let r = this.#y.slice();
|
|
759
|
+
for (let t of r) setImmediate(() => t(e));
|
|
760
|
+
}
|
|
761
|
+
#R() {
|
|
762
|
+
return ne(this.#x, async (e) => {
|
|
763
|
+
this.handler.sendPacket(S.Command, Buffer.from(e), 0);
|
|
726
764
|
});
|
|
727
765
|
}
|
|
728
|
-
#
|
|
729
|
-
return
|
|
730
|
-
typeof e == "object" && e && "invokerName" in e && "message" in e && "targetMode" in e ? this.#
|
|
766
|
+
#z() {
|
|
767
|
+
return q(this.#S, (e) => {
|
|
768
|
+
typeof e == "object" && e && "invokerName" in e && "message" in e && "targetMode" in e ? this.#F("textMessage", e) : typeof e == "object" && e && "invokerName" in e && "message" in e && !("targetMode" in e) ? this.#F("poked", e) : typeof e == "object" && e && "id" in e && "uid" in e ? this.#F("clientEnter", e) : typeof e == "object" && e && "id" in e && "reasonID" in e && "targetChannelID" in e ? this.#F("clientMoved", e) : typeof e == "object" && e && "id" in e && "reasonID" in e && this.#F("clientLeave", e);
|
|
731
769
|
});
|
|
732
770
|
}
|
|
733
771
|
};
|
|
734
772
|
//#endregion
|
|
735
773
|
//#region src/api.ts
|
|
736
|
-
async function
|
|
737
|
-
let i =
|
|
774
|
+
async function he(e, t, n, r) {
|
|
775
|
+
let i = T("sendtextmessage", [
|
|
738
776
|
["targetmode", String(t)],
|
|
739
777
|
["target", String(n)],
|
|
740
778
|
["msg", r]
|
|
741
779
|
]);
|
|
742
780
|
await e.sendCommandNoWait(i);
|
|
743
781
|
}
|
|
744
|
-
async function
|
|
782
|
+
async function ge(e, t, n, r = "") {
|
|
745
783
|
let i = [["clid", String(t)], ["cid", String(n)]];
|
|
746
|
-
r && i.push(["cpw",
|
|
747
|
-
let a =
|
|
784
|
+
r && i.push(["cpw", R(r)]);
|
|
785
|
+
let a = T("clientmove", i);
|
|
748
786
|
await e.execCommand(a, 1e4);
|
|
749
787
|
}
|
|
750
|
-
function ge(e) {
|
|
751
|
-
return E("sha1").update(e).digest("base64");
|
|
752
|
-
}
|
|
753
788
|
async function _e(e, t, n) {
|
|
754
|
-
let r =
|
|
789
|
+
let r = T("clientpoke", [["clid", String(t)], ["msg", n]]);
|
|
755
790
|
await e.execCommand(r, 1e4);
|
|
756
791
|
}
|
|
757
792
|
async function ve(e, t) {
|
|
@@ -764,7 +799,7 @@ async function ye(e) {
|
|
|
764
799
|
id: BigInt(e.cid ?? "0"),
|
|
765
800
|
parentID: BigInt(e.pid ?? e.cpid ?? "0"),
|
|
766
801
|
order: BigInt(e.channel_order ?? "0"),
|
|
767
|
-
name:
|
|
802
|
+
name: w(e.channel_name ?? ""),
|
|
768
803
|
description: ""
|
|
769
804
|
}));
|
|
770
805
|
}
|
|
@@ -773,7 +808,7 @@ async function be(e) {
|
|
|
773
808
|
let t = e.client_servergroups ?? "";
|
|
774
809
|
return {
|
|
775
810
|
id: parseInt(e.clid ?? "0", 10),
|
|
776
|
-
nickname:
|
|
811
|
+
nickname: w(e.client_nickname ?? ""),
|
|
777
812
|
uid: e.client_unique_identifier ?? "",
|
|
778
813
|
channelID: BigInt(e.cid ?? "0"),
|
|
779
814
|
type: parseInt(e.client_type ?? "0", 10),
|
|
@@ -783,7 +818,7 @@ async function be(e) {
|
|
|
783
818
|
}
|
|
784
819
|
async function xe(e, t, n) {
|
|
785
820
|
if (n.length === 0) return;
|
|
786
|
-
let r = n.join("|"), i =
|
|
821
|
+
let r = n.join("|"), i = E("ftdeletefile", {
|
|
787
822
|
cid: String(t),
|
|
788
823
|
cpw: "",
|
|
789
824
|
name: r
|
|
@@ -791,6 +826,6 @@ async function xe(e, t, n) {
|
|
|
791
826
|
await e.execCommand(i, 1e4);
|
|
792
827
|
}
|
|
793
828
|
//#endregion
|
|
794
|
-
export { l as AlreadyConnectedError,
|
|
829
|
+
export { l as AlreadyConnectedError, me as Client, t as ClientStatus, o as CommandTimeoutError, g as CryptoInitError, y as EAXTagMismatchError, s as FakeSignatureMismatchError, v as FileTransferError, i as FileTransferTimeoutError, d as Identity, r as InvalidIdentityError, _ as ServerError, a as TeamspeakError, ge as clientMove, e as consoleLogger, H as dialFileTransfer, W as downloadFileData, xe as fileTransferDeleteFile, h as generateIdentity, ve as getClientInfo, c as getUidFromPublicKey, p as identityFromString, ye as listChannels, be as listClients, n as noopLogger, _e as poke, he as sendTextMessage, U as uploadFileData };
|
|
795
830
|
|
|
796
831
|
//# sourceMappingURL=index.mjs.map
|