@nexustechpro/baileys 2.0.5 → 2.1.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/README.md CHANGED
@@ -38,6 +38,7 @@
38
38
  - [Media Download](#-media-download)
39
39
  - [Group Management](#-group-management)
40
40
  - [User Operations](#-user-operations)
41
+ - [Check Number Status](#ban-checker)
41
42
  - [Privacy Controls](#-privacy-controls)
42
43
  - [Chat Operations](#-chat-operations)
43
44
  - [Newsletter / Channels](#-newsletter--channels)
@@ -940,6 +941,24 @@ await sock.sendMessage('status@broadcast', {
940
941
  })
941
942
  ```
942
943
 
944
+ #### React to a Status
945
+ ```javascript
946
+ // Method 1 — via sendMessage
947
+ await sock.sendMessage('status@broadcast', {
948
+ react: {
949
+ text: '❤️',
950
+ key: message.key // the key of the status message
951
+ }
952
+ }, {
953
+ statusJidList: [message.key.participant] // the person who posted the status
954
+ })
955
+
956
+ // Method 2 — via sendReaction shorthand
957
+ await sock.sendReaction('status@broadcast', message.key, '❤️', {
958
+ statusJidList: [message.key.participant]
959
+ })
960
+ ```
961
+
943
962
  #### Status Mention (tag someone in your story)
944
963
 
945
964
  Mention specific users or groups in a story. They get a private notification.
@@ -1152,6 +1171,58 @@ const blocked = await sock.fetchBlocklist()
1152
1171
 
1153
1172
  ---
1154
1173
 
1174
+ ## 💬 Check Number Status
1175
+
1176
+ ```javascript
1177
+ // Via socket instance
1178
+ const result = await sock.checkStatusWA('1234567890')
1179
+
1180
+ // Or direct import (no socket needed)
1181
+ import { checkStatusWA } from '@nexustechpro/baileys'
1182
+ const result = await checkStatusWA('1234567890')
1183
+
1184
+ // Response examples:
1185
+ // Active number
1186
+ { number: '+1234567890', status: 'active', isBanned: false, isNeedOfficialWa: false, banInfo: null }
1187
+
1188
+ // Banned number
1189
+ {
1190
+ number: '+1234567890',
1191
+ status: 'banned',
1192
+ isBanned: true,
1193
+ isNeedOfficialWa: false,
1194
+ banInfo: {
1195
+ banType: 'temporary', // 'temporary' | 'permanent'
1196
+ violationType: '2',
1197
+ violationReason: 'Type 2',
1198
+ canAppeal: true, // false if permanent
1199
+ appealToken: 'xxxxx',
1200
+ banTime: 1716840000,
1201
+ banDate: '2024-05-28T00:00:00.000Z',
1202
+ appealStatus: 'PENDING',
1203
+ appealCreatedAt: '2024-05-27T00:00:00.000Z'
1204
+ }
1205
+ }
1206
+
1207
+ // Blocked by custom screen (needs official WhatsApp)
1208
+ { number: '+1234567890', status: 'blocked', isBanned: false, isNeedOfficialWa: true, banInfo: null }
1209
+
1210
+ // Rate limited
1211
+ { number: '+1234567890', status: 'rate_limited', isBanned: false, isNeedOfficialWa: false, banInfo: null }
1212
+
1213
+ // Usage example
1214
+ import { checkStatusWA } from '@nexustechpro/baileys'
1215
+ const check = await checkStatusWA('1234567890')
1216
+ if (check.isBanned) {
1217
+ console.log(`Banned: ${check.banInfo.banType}`)
1218
+ if (check.banInfo.canAppeal) console.log(`Appeal token: ${check.banInfo.appealToken}`)
1219
+ } else {
1220
+ console.log(`Status: ${check.status}`)
1221
+ }
1222
+ ```
1223
+
1224
+ ---
1225
+
1155
1226
  ## 🔒 Privacy Controls
1156
1227
 
1157
1228
  ```javascript
package/WAProto/index.js CHANGED
@@ -12,14 +12,18 @@ function longToString(value, unsigned) {
12
12
  if (typeof value === "number") {
13
13
  return String(value);
14
14
  }
15
- if (!$util.Long) {
16
- return String(value);
15
+ // Fast path: convert Long {low, high} directly via native BigInt
16
+ // BigInt.toString() is a native C++ operation, much faster than Long's pure JS division loops
17
+ if (value && typeof value.low === "number" && typeof value.high === "number") {
18
+ const lo = BigInt(value.low >>> 0);
19
+ const hi = BigInt(value.high >>> 0);
20
+ const combined = (hi << 32n) | lo;
21
+ if (!unsigned && value.high < 0) {
22
+ return (combined - (1n << 64n)).toString();
23
+ }
24
+ return combined.toString();
17
25
  }
18
- const normalized = $util.Long.fromValue(value);
19
- const prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"
20
- ? normalized.toUnsigned()
21
- : normalized;
22
- return prepared.toString();
26
+ return String(value);
23
27
  }
24
28
 
25
29
  function longToNumber(value, unsigned) {
@@ -27,19 +31,19 @@ function longToNumber(value, unsigned) {
27
31
  return value;
28
32
  }
29
33
  if (typeof value === "string") {
30
- const numeric = Number(value);
31
- return numeric;
32
- }
33
- if (!$util.Long) {
34
34
  return Number(value);
35
35
  }
36
- const normalized = $util.Long.fromValue(value);
37
- const prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"
38
- ? normalized.toUnsigned()
39
- : typeof normalized.toSigned === "function"
40
- ? normalized.toSigned()
41
- : normalized;
42
- return prepared.toNumber();
36
+ // Fast path: convert Long {low, high} directly via native BigInt
37
+ if (value && typeof value.low === "number" && typeof value.high === "number") {
38
+ const lo = BigInt(value.low >>> 0);
39
+ const hi = BigInt(value.high >>> 0);
40
+ const combined = (hi << 32n) | lo;
41
+ if (!unsigned && value.high < 0) {
42
+ return Number(combined - (1n << 64n));
43
+ }
44
+ return Number(combined);
45
+ }
46
+ return Number(value);
43
47
  }
44
48
 
45
49
  export const proto = $root.proto = (() => {
@@ -2,6 +2,6 @@
2
2
  "version": [
3
3
  2,
4
4
  3000,
5
- 1036200034
5
+ 1040069233
6
6
  ]
7
7
  }
@@ -4,10 +4,11 @@ import { proto } from '../../WAProto/index.js';
4
4
  import { makeLibSignalRepository } from '../Signal/libsignal.js';
5
5
  import { Browsers } from '../Utils/browser-utils.js';
6
6
  import logger from '../Utils/logger.js';
7
+ import urlRegexSafe from 'url-regex-safe';
7
8
  const require = createRequire(import.meta.url);
8
9
  const PHONENUMBER_MCC = require('./phonenumber-mcc.json');
9
10
  export { PHONENUMBER_MCC };
10
- const version = [2, 3000, 1036200034];
11
+ const version = [2, 3000, 1040069233];
11
12
 
12
13
  export const UNAUTHORIZED_CODES = [401, 403, 419];
13
14
 
@@ -36,8 +37,7 @@ export const DICT_VERSION = 3;
36
37
  export const KEY_BUNDLE_TYPE = Buffer.from([5]);
37
38
  export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
38
39
 
39
- export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
40
-
40
+ export const URL_REGEX = urlRegexSafe({ strict: true, re2: false });
41
41
  export const WA_CERT_DETAILS = {
42
42
  SERIAL: 0,
43
43
  ISSUER: 'WhatsAppLongTerm1',
@@ -55,19 +55,20 @@ export const PROCESSABLE_HISTORY_TYPES = [
55
55
  ];
56
56
  export const MOBILE_ENDPOINT = 'g.whatsapp.net';
57
57
  export const MOBILE_PORT = 443;
58
-
59
- const WA_VERSION = '2.25.23.24';
60
- const WA_VERSION_HASH = createHash('md5').update(WA_VERSION).digest('hex');
61
-
58
+ export const WA_VERSION = '2.2413.51'
59
+ export const WA_VERSION_HASH = createHash('md5').update(WA_VERSION).digest('hex');
62
60
  export const MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
63
61
  export const MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
64
62
  export const MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
65
-
63
+ export const GRAPHQL_ENDPOINT = 'https://graph.whatsapp.com/graphql'
64
+ export const GRAPHQL_ACCESS_TOKEN = 'WA|1015890928915437|3201f239340c1c8ec6262a6dad04200e'
65
+ export const GRAPHQL_BAN_STATUS_DOC_ID = '25573756098908502'
66
66
  export const REGISTRATION_PUBLIC_KEY = Buffer.from([
67
67
  5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
68
68
  34, 251, 111, 18, 37, 18, 48, 45,
69
69
  ]);
70
70
 
71
+
71
72
  export const PROTOCOL_VERSION = [5, 2];
72
73
  export const MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(PROTOCOL_VERSION)]);
73
74