oicq-icalingua-plus-plus 1.23.85 → 1.23.87

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/index.d.ts CHANGED
@@ -790,6 +790,7 @@ export interface Sig {
790
790
  t543: Buffer,
791
791
  t544: Object,
792
792
  t547: Buffer,
793
+ t553: Buffer,
793
794
  skey: Buffer,
794
795
  d2: Buffer,
795
796
  d2key: Buffer,
package/lib/client-ext.js CHANGED
@@ -664,7 +664,9 @@ Client.prototype.getT544 = async function(cmd, retry = 0) {
664
664
  }
665
665
  if (typeof(data.data) === 'string')
666
666
  return Buffer.from(data.data, 'hex');
667
- else if (typeof(data.data.sign) === 'string')
667
+ else if (typeof(data.data.sign) === 'string') {
668
+ if (typeof(data.data.t553) === 'string') this.sig.t553 = Buffer.from(data.data.t553, 'hex');
668
669
  return Buffer.from(data.data.sign, 'hex');
670
+ }
669
671
  else throw new Error(`[qsign][T544] server return invalid response: ${JSON.stringify(data)}`);
670
672
  };
package/lib/client.js CHANGED
@@ -165,6 +165,7 @@ class Client extends EventEmitter {
165
165
  t103: BUF0,
166
166
  t543: BUF0,
167
167
  t547: BUF0,
168
+ t553: BUF0,
168
169
  skey: BUF0,
169
170
  d2: BUF0,
170
171
  d2key: BUF0,
package/lib/oicq.js CHANGED
@@ -234,7 +234,7 @@ Client.prototype._startHeartbeat = function () {
234
234
  }
235
235
  this._wt.syncTimeDiff();
236
236
  this._wt.heartbeat();
237
- //this._wt.ssoHeartbeat();
237
+ if (this.config.useNT) this._wt.ssoHeartbeat();
238
238
  if (timestamp() - this.sig.qsign_token_time >= (60 * 60)) {
239
239
  this.sig.qsign_token_time = timestamp();
240
240
  this.refreshQSignToken();
@@ -56,7 +56,7 @@ WtLogin.prototype.passwordLogin = async function () {
56
56
  this.sig.tgt = tgt;
57
57
  this.device.tgtgt = md5(d2key);
58
58
  this.token_flag = true;
59
- return this.tokenLogin(d2);
59
+ return await this.tokenLogin(d2);
60
60
  }
61
61
  } catch {
62
62
  this.token_flag = false;
@@ -64,40 +64,36 @@ WtLogin.prototype.passwordLogin = async function () {
64
64
  if (!this.password_md5)
65
65
  return this.fetchQrcode();
66
66
  const t = this.tlvPacker;
67
- let tlv_count = this.device.qimei16 ? 25 : 26;
68
- if (this.apk.ssover <= 12) tlv_count--;
69
- let writer = new Writer()
70
- .writeU16(9)
71
- .writeU16(tlv_count)
72
- .writeBytes(t(0x18))
73
- .writeBytes(t(0x1))
74
- .writeBytes(t(0x106))
75
- .writeBytes(t(0x116))
76
- .writeBytes(t(0x100))
77
- .writeBytes(t(0x107))
78
- //.writeBytes(t(0x108))
79
- .writeBytes(t(0x142))
80
- .writeBytes(t(0x144))
81
- .writeBytes(t(0x145))
82
- .writeBytes(t(0x147))
83
- .writeBytes(t(0x154))
84
- .writeBytes(t(0x141))
85
- .writeBytes(t(0x8))
86
- .writeBytes(t(0x511))
87
- .writeBytes(t(0x187))
88
- .writeBytes(t(0x188));
67
+ const tlvs = [
68
+ t(0x18),
69
+ t(0x1),
70
+ t(0x106),
71
+ t(0x116),
72
+ t(0x100),
73
+ t(0x107),
74
+ //t(0x108)),
75
+ t(0x142),
76
+ t(0x144),
77
+ t(0x145),
78
+ t(0x147),
79
+ t(0x154),
80
+ t(0x141),
81
+ t(0x8),
82
+ t(0x511),
83
+ t(0x187),
84
+ t(0x188),
85
+ ];
89
86
  if (!this.device.qimei16){
90
- writer.writeBytes(t(0x194)); // should have been removed
87
+ tlvs.push(t(0x194)); // should have been removed
91
88
  }
92
- writer.writeBytes(t(0x191))
89
+ tlvs.push(t(0x191))
93
90
  if (!this.device.qimei16){
94
- writer.writeBytes(t(0x202)); // should have been removed
91
+ tlvs.push(t(0x202)); // should have been removed
95
92
  }
96
- writer
97
- .writeBytes(t(0x177))
98
- .writeBytes(t(0x516))
99
- .writeBytes(t(0x521))
100
- .writeBytes(t(0x525));
93
+ tlvs.push(t(0x177))
94
+ tlvs.push(t(0x516))
95
+ tlvs.push(t(0x521))
96
+ tlvs.push(t(0x525));
101
97
  if (this.apk.ssover > 12) {
102
98
  let tlv544;
103
99
  try {
@@ -108,14 +104,20 @@ WtLogin.prototype.passwordLogin = async function () {
108
104
  this.c.em("system.login.error", { code: -1, message: message });
109
105
  return;
110
106
  }
111
- writer.writeBytes(t(0x544, "810_9", tlv544));
107
+ tlvs.push(t(0x544, "810_9", tlv544));
112
108
  }
113
109
  if (this.device.qimei16) {
114
- writer.writeBytes(t(0x545, this.device.qimei16));
110
+ tlvs.push(t(0x545, this.device.qimei16));
115
111
  }
116
- writer
117
- .writeBytes(t(0x548))
118
- .writeBytes(t(0x542));
112
+ tlvs.push(t(0x548));
113
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
114
+ tlvs.push(t(0x542));
115
+
116
+ const writer = new Writer()
117
+ .writeU16(9)
118
+ .writeU16(tlvs.length);
119
+ for (const tlv of tlvs)
120
+ writer.writeBytes(tlv);
119
121
  const body = writer.read();
120
122
  this.sendLogin("wtlogin.login", body);
121
123
  }
@@ -125,16 +127,13 @@ WtLogin.prototype.sliderLogin = async function (ticket) {
125
127
  return this.logger.warn("未收到滑动验证码或已过期,你不能调用sliderLogin函数。");
126
128
  ticket = String(ticket).trim();
127
129
  const t = this.tlvPacker;
128
- let tlv_count = this.sig.t547.length ? 6 : 5;
129
- if (this.apk.ssover <= 12) tlv_count--;
130
- const writer = new Writer()
131
- .writeU16(2)
132
- .writeU16(tlv_count)
133
- .writeBytes(t(0x193, ticket))
134
- .writeBytes(t(0x8))
135
- .writeBytes(t(0x104))
136
- .writeBytes(t(0x116));
137
- if (this.sig.t547.length) writer.writeBytes(t(0x547));
130
+ const tlvs = [
131
+ t(0x193, ticket),
132
+ t(0x8),
133
+ t(0x104),
134
+ t(0x116),
135
+ ];
136
+ if (this.sig.t547.length) tlvs.push(t(0x547));
138
137
  if (this.apk.ssover > 12) {
139
138
  let tlv544;
140
139
  try {
@@ -145,22 +144,34 @@ WtLogin.prototype.sliderLogin = async function (ticket) {
145
144
  this.c.em("system.login.error", { code: -1, message: message });
146
145
  return;
147
146
  }
148
- writer.writeBytes(t(0x544, "810_2", tlv544));
147
+ tlvs.push(t(0x544, "810_2", tlv544));
148
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
149
149
  }
150
+
151
+ const writer = new Writer()
152
+ .writeU16(2)
153
+ .writeU16(tlvs.length);
154
+ for (const tlv of tlvs)
155
+ writer.writeBytes(tlv);
150
156
  const body = writer.read();
151
157
  this.sendLogin("wtlogin.login", body);
152
158
  }
153
159
 
154
160
  WtLogin.prototype.deviceLogin = function () {
155
161
  const t = this.tlvPacker;
156
- const body = new Writer()
162
+ const tlvs = [
163
+ t(0x8),
164
+ t(0x104),
165
+ t(0x116),
166
+ t(0x401),
167
+ ];
168
+
169
+ const writer = new Writer()
157
170
  .writeU16(20)
158
- .writeU16(4)
159
- .writeBytes(t(0x8))
160
- .writeBytes(t(0x104))
161
- .writeBytes(t(0x116))
162
- .writeBytes(t(0x401))
163
- .read();
171
+ .writeU16(tlvs.length);
172
+ for (const tlv of tlvs)
173
+ writer.writeBytes(tlv);
174
+ const body = writer.read();
164
175
  this.sendLogin("wtlogin.login", body);
165
176
  }
166
177
 
@@ -168,16 +179,21 @@ WtLogin.prototype.sendSMSCode = function () {
168
179
  if (!this.t104 || !this.t174)
169
180
  return this.logger.warn("未收到设备锁验证要求,你不能调用sendSMSCode函数。");
170
181
  const t = this.tlvPacker;
171
- const body = new Writer()
182
+ const tlvs = [
183
+ t(0x8),
184
+ t(0x104),
185
+ t(0x116),
186
+ t(0x174),
187
+ t(0x17a),
188
+ t(0x197),
189
+ ];
190
+
191
+ const writer = new Writer()
172
192
  .writeU16(8)
173
- .writeU16(6)
174
- .writeBytes(t(0x8))
175
- .writeBytes(t(0x104))
176
- .writeBytes(t(0x116))
177
- .writeBytes(t(0x174))
178
- .writeBytes(t(0x17a))
179
- .writeBytes(t(0x197))
180
- .read();
193
+ .writeU16(tlvs.length);
194
+ for (const tlv of tlvs)
195
+ writer.writeBytes(tlv);
196
+ const body = writer.read();
181
197
  this.logger.mark(`已向手机 ${this.phone} 发送短信验证码,请查看并输入。`);
182
198
  this.sendLogin("wtlogin.login", body);
183
199
  }
@@ -189,18 +205,15 @@ WtLogin.prototype.submitSMSCode = async function (code) {
189
205
  if (Buffer.byteLength(code) !== 6)
190
206
  code = "123456";
191
207
  const t = this.tlvPacker;
192
- let tlv_count = 8;
193
- if (this.apk.ssover <= 12) tlv_count--;
194
- let writer = new Writer()
195
- .writeU16(7)
196
- .writeU16(tlv_count)
197
- .writeBytes(t(0x8))
198
- .writeBytes(t(0x104))
199
- .writeBytes(t(0x116))
200
- .writeBytes(t(0x174))
201
- .writeBytes(t(0x17c, code))
202
- .writeBytes(t(0x401))
203
- .writeBytes(t(0x198));
208
+ const tlvs = [
209
+ t(0x8),
210
+ t(0x104),
211
+ t(0x116),
212
+ t(0x174),
213
+ t(0x17c, code),
214
+ t(0x401),
215
+ t(0x198),
216
+ ];
204
217
  if (this.apk.ssover > 12) {
205
218
  let tlv544;
206
219
  try {
@@ -211,37 +224,61 @@ WtLogin.prototype.submitSMSCode = async function (code) {
211
224
  this.c.em("system.login.error", { code: -1, message: message });
212
225
  return;
213
226
  }
214
- writer.writeBytes(t(0x544, "810_7", tlv544));
227
+ tlvs.push(t(0x544, "810_7", tlv544));
228
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
215
229
  }
230
+
231
+ let writer = new Writer()
232
+ .writeU16(7)
233
+ .writeU16(tlvs.length);
234
+ for (const tlv of tlvs)
235
+ writer.writeBytes(tlv);
216
236
  const body = writer.read();
217
237
  this.sendLogin("wtlogin.login", body);
218
238
  }
219
239
 
220
- WtLogin.prototype.tokenLogin = function (d2) {
240
+ WtLogin.prototype.tokenLogin = async function (d2) {
221
241
  const t = this.tlvPacker;
222
- const body = new Writer()
242
+ const tlvs = [
243
+ t(0x100),
244
+ t(0x10a),
245
+ t(0x116),
246
+ t(0x108),
247
+ t(0x144),
248
+ //t(0x112),
249
+ t(0x143, d2),
250
+ t(0x142),
251
+ t(0x154),
252
+ t(0x18),
253
+ t(0x141),
254
+ t(0x8),
255
+ t(0x147),
256
+ t(0x177),
257
+ t(0x187),
258
+ t(0x188),
259
+ t(0x194),
260
+ t(0x511),
261
+ t(0x202),
262
+ ];
263
+ if (this.apk.ssover > 12) {
264
+ let tlv544;
265
+ try {
266
+ tlv544 = await this.c.getT544("810_a");
267
+ } catch (e) {
268
+ const message = e.message || "[qsign][T544] 未知错误";
269
+ this.logger.error(message);
270
+ this.c.em("system.login.error", { code: -1, message: message });
271
+ return;
272
+ }
273
+ tlvs.push(t(0x544, "810_a", tlv544));
274
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
275
+ }
276
+ const writer = new Writer()
223
277
  .writeU16(11)
224
- .writeU16(18)
225
- .writeBytes(t(0x100))
226
- .writeBytes(t(0x10a))
227
- .writeBytes(t(0x116))
228
- .writeBytes(t(0x108))
229
- .writeBytes(t(0x144))
230
- //.writeBytes(t(0x112))
231
- .writeBytes(t(0x143, d2))
232
- .writeBytes(t(0x142))
233
- .writeBytes(t(0x154))
234
- .writeBytes(t(0x18))
235
- .writeBytes(t(0x141))
236
- .writeBytes(t(0x8))
237
- .writeBytes(t(0x147))
238
- .writeBytes(t(0x177))
239
- .writeBytes(t(0x187))
240
- .writeBytes(t(0x188))
241
- .writeBytes(t(0x194))
242
- .writeBytes(t(0x511))
243
- .writeBytes(t(0x202))
244
- .read();
278
+ .writeU16(tlvs.length);
279
+ for (const tlv of tlvs)
280
+ writer.writeBytes(tlv);
281
+ const body = writer.read();
245
282
  this.sendLogin("wtlogin.exchange_emp", body);
246
283
  }
247
284
 
@@ -250,26 +287,43 @@ WtLogin.prototype.refreshD2 = async function () {
250
287
  return
251
288
  this.device.tgtgt = md5(this.sig.d2key);
252
289
  const t = this.tlvPacker;
253
- const body = new Writer()
290
+ const tlvs = [
291
+ t(0x100),
292
+ t(0x10a),
293
+ t(0x116),
294
+ t(0x144),
295
+ t(0x143, this.sig.d2),
296
+ t(0x142),
297
+ t(0x154),
298
+ t(0x18),
299
+ t(0x141),
300
+ t(0x8),
301
+ t(0x147),
302
+ t(0x177),
303
+ t(0x187),
304
+ t(0x188),
305
+ t(0x202),
306
+ t(0x511),
307
+ ];
308
+ if (this.apk.ssover > 12) {
309
+ let tlv544;
310
+ try {
311
+ tlv544 = await this.c.getT544("810_a");
312
+ } catch (e) {
313
+ const message = e.message || "[qsign][T544] 未知错误";
314
+ this.logger.error(message);
315
+ this.c.em("system.login.error", { code: -1, message: message });
316
+ return;
317
+ }
318
+ tlvs.push(t(0x544, "810_a", tlv544));
319
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
320
+ }
321
+ const writer = new Writer()
254
322
  .writeU16(11)
255
- .writeU16(16)
256
- .writeBytes(t(0x100))
257
- .writeBytes(t(0x10a))
258
- .writeBytes(t(0x116))
259
- .writeBytes(t(0x144))
260
- .writeBytes(t(0x143, this.sig.d2))
261
- .writeBytes(t(0x142))
262
- .writeBytes(t(0x154))
263
- .writeBytes(t(0x18))
264
- .writeBytes(t(0x141))
265
- .writeBytes(t(0x8))
266
- .writeBytes(t(0x147))
267
- .writeBytes(t(0x177))
268
- .writeBytes(t(0x187))
269
- .writeBytes(t(0x188))
270
- .writeBytes(t(0x202))
271
- .writeBytes(t(0x511))
272
- .read();
323
+ .writeU16(tlvs.length);
324
+ for (const tlv of tlvs)
325
+ writer.writeBytes(tlv);
326
+ const body = writer.read();
273
327
  const seq = this.c.nextSeq();
274
328
  const pkt = await this._buildLoginPacket("wtlogin.exchange_emp", this._buildOICQPacket(body), 2, seq);
275
329
  try {
@@ -111,7 +111,8 @@ const tlv_map = {
111
111
  0x104: function () {
112
112
  return new Writer().writeBytes(this.t104);
113
113
  },
114
- 0x106: function () {
114
+ 0x106: function (t106 = BUF0) {
115
+ if (t106 && t106.length !== 0) return new Writer().writeBytes(t106);
115
116
  const body = new Writer()
116
117
  .writeU16(4) // tgtgt ver
117
118
  .writeBytes(crypto.randomBytes(4))
@@ -325,6 +326,7 @@ const tlv_map = {
325
326
  return new Writer().writeBytes(buf);
326
327
  },
327
328
  0x542: function () {
329
+ if (this.device.ssover >= 20) return new Writer().writeBytes(Buffer.from([0x4A, 0x04, 0x60, 0x01, 0x78, 0x01]));
328
330
  return new Writer().writeBytes(Buffer.from([0x4A, 0x02, 0x60, 0x01]));
329
331
  },
330
332
  0x544: function (code = "810_9", tlv544 = BUF0) {
@@ -379,6 +381,9 @@ const tlv_map = {
379
381
  .read();
380
382
  const t548 = this.calcPoW(t546);
381
383
  return new Writer().writeBytes(t548);
384
+ },
385
+ 0x553: function () {
386
+ return new Writer().writeBytes(this.sig.t553);
382
387
  }
383
388
  };
384
389
 
package/lib/wtlogin/wt.js CHANGED
@@ -97,6 +97,7 @@ class WtLogin {
97
97
  t103: t[0x103] ? t[0x103] : this.sig.t103,
98
98
  t543: t[0x543] ? t[0x543] : this.sig.t543,
99
99
  t547: this.sig.t547,
100
+ t553: this.sig.t553,
100
101
  skey: t[0x120] ? t[0x120] : this.sig.skey,
101
102
  d2: t[0x143] ? t[0x143] : this.sig.d2,
102
103
  d2key: t[0x305] ? t[0x305] : this.sig.d2key,
@@ -603,36 +604,55 @@ class WtLogin {
603
604
  if (!this.password_md5 || !this.c.isOnline())
604
605
  return;
605
606
  const t = this.tlvPacker;
606
- const body = new Writer()
607
+ const tlvs = [
608
+ t(0x18),
609
+ t(0x1),
610
+ t(0x106, this.t106),
611
+ t(0x116),
612
+ t(0x100, 1),
613
+ t(0x107),
614
+ t(0x108),
615
+ t(0x144),
616
+ t(0x142),
617
+ t(0x145),
618
+ t(0x16a),
619
+ t(0x154),
620
+ t(0x141),
621
+ t(0x8),
622
+ t(0x511),
623
+ t(0x147),
624
+ t(0x177),
625
+ t(0x400),
626
+ t(0x187),
627
+ t(0x188),
628
+ t(0x194),
629
+ t(0x202),
630
+ t(0x516),
631
+ t(0x521),
632
+ t(0x525),
633
+ ];
634
+ if (this.apk.ssover > 12) {
635
+ let tlv544;
636
+ try {
637
+ tlv544 = await this.c.getT544("810_f");
638
+ } catch (e) {
639
+ const message = e.message || "[qsign][T544] 未知错误";
640
+ this.logger.error(message);
641
+ this.c.em("system.login.error", { code: -1, message: message });
642
+ return;
643
+ }
644
+ tlvs.push(t(0x544, "810_f", tlv544));
645
+ if (this.sig.t553 && this.apk.buildtime >= 1691565978) tlvs.push(t(0x553));
646
+ }
647
+ if (this.device.qimei16) {
648
+ tlvs.push(t(0x545, this.device.qimei16));
649
+ }
650
+ const writer = new Writer()
607
651
  .writeU16(15)
608
- .writeU16(24)
609
- .writeBytes(t(0x18))
610
- .writeBytes(t(0x1))
611
- .writeU16(0x106)
612
- .writeU16(this.t106.length)
613
- .writeBytes(this.t106)
614
- .writeBytes(t(0x116))
615
- .writeBytes(t(0x100, 1))
616
- .writeBytes(t(0x107))
617
- .writeBytes(t(0x144))
618
- .writeBytes(t(0x142))
619
- .writeBytes(t(0x145))
620
- .writeBytes(t(0x16a))
621
- .writeBytes(t(0x154))
622
- .writeBytes(t(0x141))
623
- .writeBytes(t(0x8))
624
- .writeBytes(t(0x511))
625
- .writeBytes(t(0x147))
626
- .writeBytes(t(0x177))
627
- .writeBytes(t(0x400))
628
- .writeBytes(t(0x187))
629
- .writeBytes(t(0x188))
630
- .writeBytes(t(0x194))
631
- .writeBytes(t(0x202))
632
- .writeBytes(t(0x516))
633
- .writeBytes(t(0x521))
634
- .writeBytes(t(0x525))
635
- .read();
652
+ .writeU16(tlvs.length);
653
+ for (const tlv of tlvs)
654
+ writer.writeBytes(tlv);
655
+ const body = writer.read();
636
656
  const pkt = this._buildOICQPacket(body, true);
637
657
  try {
638
658
  let payload = await this.c.sendUni("wtlogin.exchange_emp", pkt);
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.23.85",
5
- "app_version": "1.23.85",
6
- "upday": "2023/11/11",
4
+ "version": "1.23.87",
5
+ "app_version": "1.23.87",
6
+ "upday": "2023/11/12",
7
7
  "protocol_version": "v11",
8
8
  "description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
9
9
  "main": "index.js",