oicq-icalingua-plus-plus 1.24.76 → 1.25.0
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/lib/client-ext.js +22 -13
- package/lib/message/builder.js +5 -3
- package/lib/message/face.js +4 -0
- package/lib/oicq.js +9 -5
- package/lib/ref.d.ts +7 -1
- package/lib/wtlogin/wt.js +6 -5
- package/package.json +3 -3
package/lib/client-ext.js
CHANGED
|
@@ -71,9 +71,9 @@ Client.prototype.send = function (packet, timeout = 5, seq_id = this.seq_id) {
|
|
|
71
71
|
* 除login包之外都是uni包,以0x0b开头
|
|
72
72
|
* login包以0x0a开头
|
|
73
73
|
*/
|
|
74
|
-
Client.prototype.writeUni = async function (cmd, body, seq = 0) {
|
|
74
|
+
Client.prototype.writeUni = async function (cmd, body, seq = 0, options = {}) {
|
|
75
75
|
++this.stat.sent_pkt_cnt;
|
|
76
|
-
const packet = await this._buildUniPacket(cmd, body, seq);
|
|
76
|
+
const packet = await this._buildUniPacket(cmd, body, seq, options);
|
|
77
77
|
this._socket.write(packet);
|
|
78
78
|
};
|
|
79
79
|
|
|
@@ -122,7 +122,7 @@ Client.prototype.sendOidbSvcTrpcTcp = async function (cmd, body, useUid = false)
|
|
|
122
122
|
4: body,
|
|
123
123
|
12: 0,
|
|
124
124
|
});
|
|
125
|
-
const options = useUid ?
|
|
125
|
+
const options = useUid ? { trace_parent: true, nt_core: true } : { };
|
|
126
126
|
const seq = this.nextSeq();
|
|
127
127
|
const packet = await this._buildUniPacket(cmd, body, seq, options);
|
|
128
128
|
const payload = await this.send(packet, 5, seq);
|
|
@@ -136,9 +136,9 @@ Client.prototype.sendOidbSvcTrpcTcp = async function (cmd, body, useUid = false)
|
|
|
136
136
|
* @param {string} cmd
|
|
137
137
|
* @param {Buffer} body
|
|
138
138
|
* @param {number} seq
|
|
139
|
-
* @param {
|
|
139
|
+
* @param {import("./ref").SsoOptions} options
|
|
140
140
|
*/
|
|
141
|
-
Client.prototype._buildUniPacket = async function (cmd, body, seq = 0, options =
|
|
141
|
+
Client.prototype._buildUniPacket = async function (cmd, body, seq = 0, options = {}) {
|
|
142
142
|
seq = seq ? seq : this.nextSeq();
|
|
143
143
|
const startTime = Date.now();
|
|
144
144
|
const reserveFields = await this.buildSSOReserveField(cmd, Buffer.from(body), seq, options);
|
|
@@ -243,8 +243,12 @@ Client.prototype.buildSyncCookie = function () {
|
|
|
243
243
|
/**
|
|
244
244
|
* 消息同步
|
|
245
245
|
*/
|
|
246
|
-
Client.prototype.pbGetMsg = async function (force = false, flag = 0) {
|
|
246
|
+
Client.prototype.pbGetMsg = async function (force = false, flag = 0, count = 10) {
|
|
247
247
|
if (this.config.useNT && !force) return true;
|
|
248
|
+
if (count <= 0) {
|
|
249
|
+
this.sync_cookie = null;
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
248
252
|
if (!this.sync_cookie)
|
|
249
253
|
this.sync_cookie = this.buildSyncCookie();
|
|
250
254
|
let body = pb.encode({
|
|
@@ -361,12 +365,10 @@ Client.prototype.pbGetMsg = async function (force = false, flag = 0) {
|
|
|
361
365
|
if (items.length) {
|
|
362
366
|
this.writeUni("MessageSvc.PbDeleteMsg", pb.encode({ 1: items }));
|
|
363
367
|
}
|
|
364
|
-
/*
|
|
365
368
|
if (rsp[4] !== undefined && rsp[4] !== 2) {
|
|
366
369
|
this.logger.debug("消息同步未完成,继续同步中,sync flag: " + rsp[4]);
|
|
367
|
-
return await this.pbGetMsg(force, rsp[4]);
|
|
370
|
+
return await this.pbGetMsg(force, rsp[4], count - 1);
|
|
368
371
|
}
|
|
369
|
-
*/
|
|
370
372
|
return true;
|
|
371
373
|
} catch (e) {
|
|
372
374
|
this.logger.debug("getMsg发生错误。");
|
|
@@ -563,9 +565,9 @@ Client.prototype.refreshQSignToken = async function(retry = 0) {
|
|
|
563
565
|
* @param {string} cmd
|
|
564
566
|
* @param {Buffer} body
|
|
565
567
|
* @param {number} seq_id
|
|
566
|
-
* @param {
|
|
568
|
+
* @param {import("./ref").SsoOptions} options
|
|
567
569
|
*/
|
|
568
|
-
Client.prototype.buildSSOReserveField = async function(cmd, body, seq_id = this.seq_id, options =
|
|
570
|
+
Client.prototype.buildSSOReserveField = async function(cmd, body, seq_id = this.seq_id, options = {}) {
|
|
569
571
|
const qimei = this.device.qimei36 || this.device.qimei16 || "";
|
|
570
572
|
const reserveFields = {
|
|
571
573
|
9: 1, //flag (uint32) 0b1: wifi 0b0: mobile 0b10: weak network
|
|
@@ -578,6 +580,7 @@ Client.prototype.buildSSOReserveField = async function(cmd, body, seq_id = this.
|
|
|
578
580
|
19: 1, //network_type (uint32)
|
|
579
581
|
20: 1, //ip_stack_type (uint32)
|
|
580
582
|
21: 0, //message_type (uint32)
|
|
583
|
+
23: null, //trans_info (bytes)
|
|
581
584
|
24: null, //sec_info (bytes)
|
|
582
585
|
26: null, //nt_core_version (uint32)
|
|
583
586
|
28: 3, //sso_ip_origin (uint32)
|
|
@@ -585,15 +588,21 @@ Client.prototype.buildSSOReserveField = async function(cmd, body, seq_id = this.
|
|
|
585
588
|
if (this.needSignCmd.includes(cmd)) {
|
|
586
589
|
reserveFields[24] = await this.getSign(cmd, body, seq_id);
|
|
587
590
|
}
|
|
588
|
-
if (options.
|
|
591
|
+
if (options.trace_parent) {
|
|
589
592
|
reserveFields[15] = "00-00000000000000000000000000000000-0000000000000000-00";
|
|
590
593
|
reserveFields[21] = 2;
|
|
594
|
+
if (typeof options.trace_parent === "string") {
|
|
595
|
+
reserveFields[15] = options.trace_parent;
|
|
596
|
+
}
|
|
591
597
|
}
|
|
592
|
-
if (options.
|
|
598
|
+
if (options.nt_core) { //此时数据包内需用uid取代uin
|
|
593
599
|
reserveFields[16] = String(this.uid);
|
|
594
600
|
reserveFields[21] |= 32;
|
|
595
601
|
reserveFields[26] = 100;
|
|
596
602
|
}
|
|
603
|
+
if (options.trans_info) {
|
|
604
|
+
reserveFields[23] = options.trans_info;
|
|
605
|
+
}
|
|
597
606
|
return Buffer.from(pb.encode(reserveFields));
|
|
598
607
|
}
|
|
599
608
|
|
package/lib/message/builder.js
CHANGED
|
@@ -278,6 +278,7 @@ class Builder {
|
|
|
278
278
|
text: text,
|
|
279
279
|
surpriseId: "",
|
|
280
280
|
ramdomType: 1,
|
|
281
|
+
chainCount: null,
|
|
281
282
|
businessType: 1,
|
|
282
283
|
};
|
|
283
284
|
if (cq.extra) {
|
|
@@ -295,13 +296,14 @@ class Builder {
|
|
|
295
296
|
2: lottieElem.lottieId, //QQ只靠小表情的faceId来展示对应lottie表情
|
|
296
297
|
3: lottieElem.faceId,
|
|
297
298
|
4: lottieElem.sourceType,
|
|
298
|
-
5: lottieElem.lottieType, //展示形式,1:普通 2:有结果 3
|
|
299
|
+
5: lottieElem.lottieType, //展示形式,1:普通 2:有结果 3:接龙lottie表情
|
|
299
300
|
6: lottieElem.resultId, //有结果时的展示的结果动画id
|
|
300
301
|
7: lottieElem.text,
|
|
301
|
-
8: lottieElem.surpriseId,
|
|
302
|
+
8: lottieElem.surpriseId, //全屏动画id
|
|
302
303
|
9: lottieElem.ramdomType,
|
|
304
|
+
10: lottieElem.chainCount, //接龙次数
|
|
303
305
|
},
|
|
304
|
-
3: lottieElem.businessType //1:普通 2:服务器随机resultId 3
|
|
306
|
+
3: lottieElem.businessType //1:普通 2:服务器随机resultId 3:接龙lottie表情
|
|
305
307
|
}
|
|
306
308
|
},
|
|
307
309
|
{
|
package/lib/message/face.js
CHANGED
package/lib/oicq.js
CHANGED
|
@@ -233,8 +233,9 @@ Client.prototype._nt_hb_var = 0;
|
|
|
233
233
|
Client.prototype._runCircleTask = async function () {
|
|
234
234
|
if (this._var4++ > 10) {
|
|
235
235
|
await this._wt.refreshD2();
|
|
236
|
-
if (this.
|
|
237
|
-
this.
|
|
236
|
+
if (!this.config.useNT) {
|
|
237
|
+
this.writeUni('StatSvc.SimpleGet', BUF0);
|
|
238
|
+
}
|
|
238
239
|
this._var4 = 0;
|
|
239
240
|
}
|
|
240
241
|
for (let time of this.seq_cache.keys()) {
|
|
@@ -383,7 +384,7 @@ async function parseSSO(buf) {
|
|
|
383
384
|
const seq = buf.readInt32BE(4);
|
|
384
385
|
const retcode = buf.readInt32BE(8);
|
|
385
386
|
if (retcode !== 0) {
|
|
386
|
-
const retmsg_len = buf.
|
|
387
|
+
const retmsg_len = buf.readUInt32BE(12);
|
|
387
388
|
const retmsg = String(buf.slice(16, 16 + retmsg_len - 4));
|
|
388
389
|
const error = new Error("unsuccessful retcode: " + retcode + " retmsg: " + retmsg + " seq: " + seq);
|
|
389
390
|
if (this.handlers.has(seq))
|
|
@@ -396,7 +397,7 @@ async function parseSSO(buf) {
|
|
|
396
397
|
|
|
397
398
|
if (cmd === "Heartbeat.Alive") {
|
|
398
399
|
return {
|
|
399
|
-
seq, cmd, payload: BUF0
|
|
400
|
+
seq, cmd, payload: BUF0, reserved: BUF0
|
|
400
401
|
};
|
|
401
402
|
}
|
|
402
403
|
|
|
@@ -404,6 +405,9 @@ async function parseSSO(buf) {
|
|
|
404
405
|
len = buf.readUInt32BE(offset); // length of session_id
|
|
405
406
|
offset += len;
|
|
406
407
|
const flag = buf.readInt32BE(offset);
|
|
408
|
+
offset += 4;
|
|
409
|
+
len = buf.readUInt32BE(offset); // length of reserved
|
|
410
|
+
const reserved = buf.slice(offset + 4, offset + len);
|
|
407
411
|
let payload;
|
|
408
412
|
if (flag === 0) {
|
|
409
413
|
payload = buf.slice(headlen + 4);
|
|
@@ -418,7 +422,7 @@ async function parseSSO(buf) {
|
|
|
418
422
|
throw error;
|
|
419
423
|
}
|
|
420
424
|
return {
|
|
421
|
-
seq, cmd, payload
|
|
425
|
+
seq, cmd, payload, reserved
|
|
422
426
|
};
|
|
423
427
|
}
|
|
424
428
|
|
package/lib/ref.d.ts
CHANGED
|
@@ -151,6 +151,12 @@ export interface Storage {
|
|
|
151
151
|
port: number,
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
export interface SsoOptions {
|
|
155
|
+
trace_parent?: boolean | string;
|
|
156
|
+
nt_core?: boolean;
|
|
157
|
+
trans_info?: Buffer;
|
|
158
|
+
}
|
|
159
|
+
|
|
154
160
|
//////////
|
|
155
161
|
|
|
156
162
|
export class Client extends oicq.Client {
|
|
@@ -188,7 +194,7 @@ export class Client extends oicq.Client {
|
|
|
188
194
|
handleSsoCallback(callbackList: Array<any>): Promise<void>;
|
|
189
195
|
submitSsoCallback(cmd: string, callbackId: number, body: Buffer): Promise<void>;
|
|
190
196
|
refreshQSignToken(): Promise<void>;
|
|
191
|
-
buildSSOReserveField(cmd: string, body: Buffer, seq?: number, options?:
|
|
197
|
+
buildSSOReserveField(cmd: string, body: Buffer, seq?: number, options?: SsoOptions): Promise<Buffer>;
|
|
192
198
|
}
|
|
193
199
|
|
|
194
200
|
export * from '../index';
|
package/lib/wtlogin/wt.js
CHANGED
|
@@ -417,9 +417,11 @@ class WtLogin {
|
|
|
417
417
|
try {
|
|
418
418
|
const blob = await this.c.send(pkt, undefined, seq);
|
|
419
419
|
const rsp = jce.decode(blob);
|
|
420
|
-
const result = rsp[
|
|
421
|
-
if (!result && !logout)
|
|
420
|
+
const result = !rsp[2];
|
|
421
|
+
if (!result && !logout) {
|
|
422
|
+
this.logger.error(`上线失败:${rsp[3]}(${rsp[2]})`);
|
|
422
423
|
await this.deleteToken();
|
|
424
|
+
}
|
|
423
425
|
return result;
|
|
424
426
|
} catch {
|
|
425
427
|
return false;
|
|
@@ -573,10 +575,9 @@ class WtLogin {
|
|
|
573
575
|
"trpc.msg.register_proxy.RegisterProxy.SsoInfoSync",
|
|
574
576
|
"trpc.qq_new_tech.status_svc.StatusService.UnRegister"
|
|
575
577
|
];
|
|
576
|
-
|
|
578
|
+
let options = { };
|
|
577
579
|
if (ntRegCmds.includes(cmd)) {
|
|
578
|
-
options
|
|
579
|
-
options.push("trace_parent");
|
|
580
|
+
options = { nt_core: true, trace_parent: true };
|
|
580
581
|
}
|
|
581
582
|
const startTime = Date.now();
|
|
582
583
|
let reserveFields = await this.c.buildSSOReserveField(cmd, Buffer.from(body), seq, options);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oicq-icalingua-plus-plus",
|
|
3
3
|
"app_name": "oicq-icalingua-plus-plus",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"app_version": "1.
|
|
6
|
-
"upday": "
|
|
4
|
+
"version": "1.25.0",
|
|
5
|
+
"app_version": "1.25.0",
|
|
6
|
+
"upday": "2025/01/21",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|
|
9
9
|
"main": "index.js",
|