whalibmob 5.5.32 → 5.5.33

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.
Files changed (2) hide show
  1. package/lib/Registration.js +12 -117
  2. package/package.json +1 -1
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const { dbg: _whaDbg } = require('./logger');
4
-
5
3
  const crypto = require('crypto');
6
4
  const https = require('https');
7
5
  const tls = require('tls');
@@ -11,11 +9,9 @@ const { getDeviceConfig } = require('./DeviceConfig');
11
9
  // ---------- SOCKS5 / Tor support ----------
12
10
  // Set TOR_PROXY=socks5://127.0.0.1:9050 (or any socks5 host) to route all
13
11
  // WhatsApp registration traffic through Tor / a residential proxy.
14
- let SOCKS_LIB;
15
- try { SOCKS_LIB = require.resolve('socks'); }
16
- catch (_) { SOCKS_LIB = '/home/runner/workspace/.config/npm/node_global/lib/node_modules/socks/build/index.js'; }
12
+ const SOCKS_LIB = '/home/runner/workspace/.config/npm/node_global/lib/node_modules/socks/build/index.js';
17
13
 
18
- async function httpPostViaSocks(path, body, waVersion, proxyUrl, locale) {
14
+ async function httpPostViaSocks(path, body, waVersion, proxyUrl) {
19
15
  const url = new URL(proxyUrl);
20
16
  const pHost = url.hostname;
21
17
  const pPort = parseInt(url.port) || 1080;
@@ -45,14 +41,10 @@ async function httpPostViaSocks(path, body, waVersion, proxyUrl, locale) {
45
41
  const userAgent = _dev.os === 'android'
46
42
  ? `WhatsApp/${waVersion} A`
47
43
  : `WhatsApp/${waVersion} iOS/${_dev.osVersion} Device/${_dev.model}`;
48
- const _acceptLang = locale || 'en-US;q=1';
49
44
  const req = [
50
45
  `POST /v2${path} HTTP/1.1`,
51
46
  `Host: ${dHost}`,
52
47
  `User-Agent: ${userAgent}`,
53
- `Accept: */*`,
54
- `Accept-Language: ${_acceptLang}`,
55
- `Accept-Encoding: gzip, deflate, br`,
56
48
  `Content-Type: application/x-www-form-urlencoded`,
57
49
  `Content-Length: ${Buffer.byteLength(body)}`,
58
50
  `Connection: keep-alive`,
@@ -222,80 +214,6 @@ const TWO_DIGIT_CCS = new Set([
222
214
  '95','98'
223
215
  ]);
224
216
 
225
-
226
- // ---------- Timezone offset per country code (UTC seconds) ----------
227
- // Used to populate time_zone_offset in /code requests — real iPhones
228
- // always send this field with their local offset.
229
- const CC_TZ_OFFSET = {
230
- '1': -18000, // US Eastern
231
- '7': 10800, // Russia Moscow
232
- '20': 7200, // Egypt
233
- '27': 7200, // South Africa
234
- '30': 7200, // Greece
235
- '31': 3600, // Netherlands
236
- '32': 3600, // Belgium
237
- '33': 3600, // France
238
- '34': 3600, // Spain
239
- '36': 3600, // Hungary
240
- '39': 3600, // Italy
241
- '40': 7200, // Romania
242
- '41': 3600, // Switzerland
243
- '43': 3600, // Austria
244
- '44': 0, // UK
245
- '45': 3600, // Denmark
246
- '46': 3600, // Sweden
247
- '47': 3600, // Norway
248
- '48': 3600, // Poland
249
- '49': 3600, // Germany
250
- '51': -18000, // Peru
251
- '52': -21600, // Mexico
252
- '54': -10800, // Argentina
253
- '55': -10800, // Brazil
254
- '56': -14400, // Chile
255
- '57': -18000, // Colombia
256
- '58': -14400, // Venezuela
257
- '60': 28800, // Malaysia
258
- '61': 36000, // Australia
259
- '62': 25200, // Indonesia
260
- '63': 28800, // Philippines
261
- '64': 43200, // New Zealand
262
- '65': 28800, // Singapore
263
- '66': 25200, // Thailand
264
- '81': 32400, // Japan
265
- '82': 32400, // South Korea
266
- '84': 25200, // Vietnam
267
- '86': 28800, // China
268
- '90': 10800, // Turkey
269
- '91': 19800, // India (IST = UTC+5:30)
270
- '92': 18000, // Pakistan
271
- '93': 16200, // Afghanistan (UTC+4:30)
272
- '94': 19800, // Sri Lanka
273
- '95': 23400, // Myanmar (UTC+6:30)
274
- '98': 12600, // Iran (UTC+3:30)
275
- '212': 3600, // Morocco
276
- '213': 3600, // Algeria
277
- '216': 3600, // Tunisia
278
- '218': 7200, // Libya
279
- '234': 3600, // Nigeria
280
- '254': 10800, // Kenya
281
- '255': 10800, // Tanzania
282
- '256': 10800, // Uganda
283
- '351': 0, // Portugal
284
- '353': 0, // Ireland
285
- '358': 7200, // Finland
286
- '380': 7200, // Ukraine
287
- '420': 3600, // Czech Republic
288
- '966': 10800, // Saudi Arabia
289
- '971': 14400, // UAE
290
- '972': 7200, // Israel
291
- '880': 21600, // Bangladesh
292
- };
293
-
294
- function getTzOffset(cc) {
295
- const v = CC_TZ_OFFSET[String(cc)];
296
- return (v !== undefined) ? v : 0;
297
- }
298
-
299
217
  function parsePhone(phoneNumber) {
300
218
  const str = String(phoneNumber).replace(/\D/g, '');
301
219
 
@@ -493,9 +411,9 @@ function encryptPayload(plaintext) {
493
411
 
494
412
  // ---------- HTTP ----------
495
413
 
496
- function httpPost(path, body, waVersion, locale) {
414
+ function httpPost(path, body, waVersion) {
497
415
  const proxy = process.env.TOR_PROXY || process.env.SOCKS_PROXY || '';
498
- if (proxy) return httpPostViaSocks(path, body, waVersion, proxy, locale);
416
+ if (proxy) return httpPostViaSocks(path, body, waVersion, proxy);
499
417
 
500
418
  return new Promise((resolve, reject) => {
501
419
  const _httpDev = getDeviceConfig();
@@ -503,7 +421,6 @@ function httpPost(path, body, waVersion, locale) {
503
421
  ? `WhatsApp/${waVersion} A`
504
422
  : `WhatsApp/${waVersion} iOS/${_httpDev.osVersion} Device/${_httpDev.model}`;
505
423
  const bodyBuf = Buffer.from(body, 'utf8');
506
- const acceptLang = locale || 'en-US;q=1';
507
424
  const opts = {
508
425
  hostname: 'v.whatsapp.net',
509
426
  port: 443,
@@ -511,13 +428,9 @@ function httpPost(path, body, waVersion, locale) {
511
428
  method: 'POST',
512
429
  timeout: 20000,
513
430
  headers: {
514
- 'User-Agent': userAgent,
515
- 'Accept': '*/*',
516
- 'Accept-Language': acceptLang,
517
- 'Accept-Encoding': 'gzip, deflate, br',
518
- 'Content-Type': 'application/x-www-form-urlencoded',
519
- 'Content-Length': bodyBuf.length,
520
- 'Connection': 'keep-alive'
431
+ 'User-Agent': userAgent,
432
+ 'Content-Type': 'application/x-www-form-urlencoded',
433
+ 'Content-Length': bodyBuf.length
521
434
  }
522
435
  };
523
436
  const req = https.request(opts, (res) => {
@@ -543,12 +456,7 @@ async function sendRequest(path, store, waVersion, useToken, extraPairs) {
543
456
  const plaintext = buildPayload(store, waVersion, useToken, extraPairs);
544
457
  const enc = encryptPayload(plaintext);
545
458
  const body = 'ENC=' + enc;
546
- const { cc: _srCc } = parsePhone(store.phoneNumber);
547
- const _srMeta = getCountryMeta(_srCc);
548
- const locale = _srMeta.lg === 'en'
549
- ? `en-${_srMeta.lc};q=1`
550
- : `${_srMeta.lg}-${_srMeta.lc};q=1, en-${_srMeta.lc};q=0.9`;
551
- return httpPost(path, body, waVersion, locale);
459
+ return httpPost(path, body, waVersion);
552
460
  }
553
461
 
554
462
  // ---------- Public API ----------
@@ -591,10 +499,7 @@ async function checkNumberStatus(phoneNumber) {
591
499
  'sim_mcc', meta.mcc,
592
500
  'sim_mnc', meta.mnc,
593
501
  'reason', '',
594
- 'cellular_strength', '3',
595
- 'network_radio_type','1',
596
- 'mistyped', '0',
597
- 'time_zone_offset', String(getTzOffset(cc))
502
+ 'cellular_strength', '1'
598
503
  ];
599
504
 
600
505
  function hasBlock(r) {
@@ -701,18 +606,13 @@ async function requestSmsCode(store, method, opts) {
701
606
  if (!emailAddr) throw new Error('requestSmsCode: email method requires opts.email address');
702
607
  const { cc: _regCc } = parsePhone(store.phoneNumber);
703
608
  const _regMeta = getCountryMeta(_regCc);
704
- const _emailTz = String(getTzOffset(parsePhone(store.phoneNumber).cc));
705
609
  const extra = [
706
610
  'method', 'email',
707
611
  'email', emailAddr,
708
612
  'sim_mcc', _regMeta.mcc,
709
613
  'sim_mnc', _regMeta.mnc,
710
614
  'reason', '',
711
- 'cellular_strength', '3',
712
- 'network_radio_type','1',
713
- 'hasinrc', _device.os === 'ios' ? '1' : null,
714
- 'mistyped', '0',
715
- 'time_zone_offset', _emailTz
615
+ 'cellular_strength', '1'
716
616
  ];
717
617
  const result = await sendRequest('/code', store, waVersion, true, extra);
718
618
  const status = result.status;
@@ -730,18 +630,13 @@ async function requestSmsCode(store, method, opts) {
730
630
  const { cc: _regCc } = parsePhone(store.phoneNumber);
731
631
  const _regMeta = getCountryMeta(_regCc);
732
632
 
733
- const _regTz = String(getTzOffset(_regCc));
734
633
  async function _tryMethod(m) {
735
634
  const extra = [
736
635
  'method', m,
737
636
  'sim_mcc', _regMeta.mcc,
738
637
  'sim_mnc', _regMeta.mnc,
739
638
  'reason', '',
740
- 'cellular_strength', '3',
741
- 'network_radio_type','1',
742
- 'hasinrc', _device.os === 'ios' ? '1' : null,
743
- 'mistyped', '0',
744
- 'time_zone_offset', _regTz
639
+ 'cellular_strength', '1'
745
640
  ];
746
641
 
747
642
  // Retry loop:
@@ -796,7 +691,7 @@ async function requestSmsCode(store, method, opts) {
796
691
  // Auto-fallback on no_routes
797
692
  if (result && result._noRoutes && !autoFallbackDone) {
798
693
  autoFallbackDone = true;
799
- _whaDbg(`[REG] ${method} returned no_routes — auto-trying ${fallbackMethod}`);
694
+ process.stderr.write(`[REG] ${method} returned no_routes — auto-trying ${fallbackMethod}\n`);
800
695
  result = await _tryMethod(fallbackMethod);
801
696
  }
802
697
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.5.32",
3
+ "version": "5.5.33",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto20",
6
6
  "main": "index.js",