@badzz88/baileys 8.4.9 → 8.5.1

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 (154) hide show
  1. package/README.md +1 -1
  2. package/WAProto/WAProto.proto +6 -347
  3. package/WAProto/fix-imports.js +85 -86
  4. package/WAProto/index.d.ts +25 -4913
  5. package/WAProto/index.js +93 -14069
  6. package/{src → lib}/Defaults/index.js +2 -13
  7. package/{src → lib}/Signal/Group/group_cipher.js +5 -5
  8. package/{src → lib}/Signal/Group/keyhelper.js +4 -4
  9. package/{src → lib}/Signal/Group/sender-chain-key.js +2 -2
  10. package/{src → lib}/Signal/Group/sender-key-distribution-message.js +1 -1
  11. package/{src → lib}/Signal/Group/sender-key-message.js +3 -3
  12. package/{src → lib}/Signal/Group/sender-key-record.js +1 -1
  13. package/{src → lib}/Signal/Group/sender-message-key.js +2 -2
  14. package/{src → lib}/Signal/libsignal.js +26 -6
  15. package/{src → lib}/Socket/chats.js +58 -616
  16. package/{src → lib}/Socket/communities.js +28 -59
  17. package/{src → lib}/Socket/graphql.js +103 -362
  18. package/{src → lib}/Socket/groups.js +29 -77
  19. package/{src → lib}/Socket/index.js +5 -3
  20. package/{src → lib}/Socket/interactive-handler.js +60 -117
  21. package/{src → lib}/Socket/interop.js +19 -36
  22. package/lib/Socket/luxu.js +387 -0
  23. package/{src → lib}/Socket/managed-account.js +27 -58
  24. package/{src → lib}/Socket/messages-recv.js +144 -715
  25. package/{src → lib}/Socket/messages-send.js +102 -412
  26. package/lib/Socket/mex.js +60 -0
  27. package/{src → lib}/Socket/newsletter.js +23 -266
  28. package/{src → lib}/Socket/privacy.js +38 -41
  29. package/{src → lib}/Socket/registration.js +106 -113
  30. package/{src → lib}/Socket/socket.js +101 -88
  31. package/{src → lib}/Socket/text-router.js +17 -1
  32. package/lib/Socket/username.js +243 -0
  33. package/lib/Store/keyed-db.js +108 -0
  34. package/{src → lib}/Store/make-in-memory-store.js +104 -6
  35. package/lib/Types/Mex.js +112 -0
  36. package/{src → lib}/Types/Newsletter.js +41 -72
  37. package/{src → lib}/Types/index.js +1 -0
  38. package/{src → lib}/Utils/chat-utils.js +9 -73
  39. package/lib/Utils/command-loader.d.ts +31 -0
  40. package/lib/Utils/command-loader.js +100 -0
  41. package/lib/Utils/companion-reg-client-utils.js +42 -0
  42. package/lib/Utils/crypto.js +155 -0
  43. package/lib/Utils/curve25519-js.js +275 -0
  44. package/{src → lib}/Utils/decode-wa-message.js +36 -284
  45. package/{src → lib}/Utils/event-buffer.js +27 -6
  46. package/{src → lib}/Utils/generics.js +37 -114
  47. package/{src → lib}/Utils/index.js +5 -1
  48. package/lib/Utils/lt-hash.js +39 -0
  49. package/{src → lib}/Utils/message-retry-manager.js +39 -0
  50. package/{src → lib}/Utils/messages-media.js +58 -105
  51. package/{src → lib}/Utils/messages.js +529 -115
  52. package/lib/Utils/meta-ai-msmsg.js +262 -0
  53. package/lib/Utils/native-bridge.js +82 -0
  54. package/{src → lib}/Utils/noise-handler.js +15 -13
  55. package/{src → lib}/Utils/process-message.js +55 -54
  56. package/{src → lib}/Utils/reporting-utils.js +2 -2
  57. package/lib/Utils/session-pool.d.ts +16 -0
  58. package/lib/Utils/session-pool.js +94 -0
  59. package/{src → lib}/Utils/signal.js +51 -19
  60. package/{src → lib}/Utils/stanza-ack.js +2 -36
  61. package/lib/Utils/sticker.d.ts +17 -0
  62. package/lib/Utils/sticker.js +145 -0
  63. package/{src → lib}/Utils/tc-token-utils.js +1 -1
  64. package/{src → lib}/Utils/validate-connection.js +11 -40
  65. package/lib/Utils/view-once-cache.d.ts +9 -0
  66. package/lib/Utils/view-once-cache.js +79 -0
  67. package/{src → lib}/WABinary/decode.js +4 -38
  68. package/lib/WABinary/encode.js +228 -0
  69. package/{src → lib}/WABinary/generic-utils.js +93 -1
  70. package/{src → lib}/WABinary/jid-utils.js +3 -16
  71. package/{src → lib}/WAM/encode.js +1 -1
  72. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
  73. package/{src → lib}/WAUSync/Protocols/USyncContactProtocol.js +1 -7
  74. package/{src → lib}/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
  75. package/{src → lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
  76. package/{src → lib}/WAUSync/Protocols/USyncFeatureProtocol.js +2 -17
  77. package/{src → lib}/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
  78. package/{src → lib}/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
  79. package/{src → lib}/WAUSync/Protocols/index.js +0 -1
  80. package/{src → lib}/WAUSync/USyncQuery.js +6 -77
  81. package/{src → lib}/WAUSync/USyncUser.js +8 -16
  82. package/{src → lib}/WAUSync/index.js +0 -1
  83. package/{src → lib}/antiban.js +266 -355
  84. package/{src → lib}/index.js +2 -2
  85. package/package.json +19 -16
  86. package/WAProto/fix-import.js +0 -38
  87. package/src/Socket/mex.js +0 -47
  88. package/src/Socket/username.js +0 -234
  89. package/src/Utils/crypto.js +0 -125
  90. package/src/Utils/lt-hash.js +0 -10
  91. package/src/Utils/message-inspect.js +0 -400
  92. package/src/Utils/meta-ai-msmsg.js +0 -133
  93. package/src/WABinary/encode.js +0 -58
  94. package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -100
  95. package/src/WAUSync/USyncBackoff.js +0 -31
  96. /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
  97. /package/{src → lib}/Signal/Group/ciphertext-message.js +0 -0
  98. /package/{src → lib}/Signal/Group/group-session-builder.js +0 -0
  99. /package/{src → lib}/Signal/Group/index.js +0 -0
  100. /package/{src → lib}/Signal/Group/sender-key-name.js +0 -0
  101. /package/{src → lib}/Signal/Group/sender-key-state.js +0 -0
  102. /package/{src → lib}/Signal/lid-mapping.js +0 -0
  103. /package/{src → lib}/Socket/Client/index.js +0 -0
  104. /package/{src → lib}/Socket/Client/types.js +0 -0
  105. /package/{src → lib}/Socket/Client/websocket.js +0 -0
  106. /package/{src → lib}/Socket/aigroups.js +0 -0
  107. /package/{src → lib}/Socket/business.js +0 -0
  108. /package/{src → lib}/Store/index.js +0 -0
  109. /package/{src → lib}/Store/make-cache-manager-store.js +0 -0
  110. /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
  111. /package/{src → lib}/Store/object-repository.js +0 -0
  112. /package/{src → lib}/Types/Auth.js +0 -0
  113. /package/{src → lib}/Types/Bussines.js +0 -0
  114. /package/{src → lib}/Types/Call.js +0 -0
  115. /package/{src → lib}/Types/Chat.js +0 -0
  116. /package/{src → lib}/Types/Contact.js +0 -0
  117. /package/{src → lib}/Types/Events.js +0 -0
  118. /package/{src → lib}/Types/GroupMetadata.js +0 -0
  119. /package/{src → lib}/Types/Label.js +0 -0
  120. /package/{src → lib}/Types/LabelAssociation.js +0 -0
  121. /package/{src → lib}/Types/Message.js +0 -0
  122. /package/{src → lib}/Types/Product.js +0 -0
  123. /package/{src → lib}/Types/Signal.js +0 -0
  124. /package/{src → lib}/Types/Socket.js +0 -0
  125. /package/{src → lib}/Types/State.js +0 -0
  126. /package/{src → lib}/Types/USync.js +0 -0
  127. /package/{src → lib}/Utils/auth-utils.js +0 -0
  128. /package/{src → lib}/Utils/browser-utils.js +0 -0
  129. /package/{src → lib}/Utils/business.js +0 -0
  130. /package/{src → lib}/Utils/consumer-application.js +0 -0
  131. /package/{src → lib}/Utils/group-history.js +0 -0
  132. /package/{src → lib}/Utils/history.js +0 -0
  133. /package/{src → lib}/Utils/identity-change-handler.js +0 -0
  134. /package/{src → lib}/Utils/jid-display-normalization.js +0 -0
  135. /package/{src → lib}/Utils/link-preview.js +0 -0
  136. /package/{src → lib}/Utils/logger.js +0 -0
  137. /package/{src → lib}/Utils/make-mutex.js +0 -0
  138. /package/{src → lib}/Utils/message-composer.js +0 -0
  139. /package/{src → lib}/Utils/offline-node-processor.js +0 -0
  140. /package/{src → lib}/Utils/pre-key-manager.js +0 -0
  141. /package/{src → lib}/Utils/sync-action-utils.js +0 -0
  142. /package/{src → lib}/Utils/use-multi-file-auth-state.js +0 -0
  143. /package/{src → lib}/Utils/voip-rekey.js +0 -0
  144. /package/{src → lib}/WABinary/constants.js +0 -0
  145. /package/{src → lib}/WABinary/index.js +0 -0
  146. /package/{src → lib}/WABinary/types.js +0 -0
  147. /package/{src → lib}/WAM/BinaryInfo.js +0 -0
  148. /package/{src → lib}/WAM/constants.js +0 -0
  149. /package/{src → lib}/WAM/index.js +0 -0
  150. /package/{src → lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
  151. /package/{src → lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
  152. /package/{src → lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
  153. /package/{src → lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
  154. /package/{src → lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
@@ -1,86 +1,85 @@
1
- import { readFileSync, writeFileSync } from 'fs';
2
- import { exit } from 'process';
3
-
4
- const filePath = './index.js'
5
-
6
- try {
7
- let content = readFileSync(filePath, 'utf8')
8
-
9
- content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
10
- content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
11
-
12
- const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
13
- const longToStringHelper =
14
- 'function longToString(value, unsigned) {\n' +
15
- '\tif (typeof value === "string") {\n' +
16
- '\t\treturn value;\n' +
17
- '\t}\n' +
18
- '\tif (typeof value === "number") {\n' +
19
- '\t\treturn String(value);\n' +
20
- '\t}\n' +
21
- '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
22
- '\t// BigInt.toString() is a native C++ operation, much faster than Long\'s pure JS division loops\n' +
23
- '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
24
- '\t\tconst lo = BigInt(value.low >>> 0);\n' +
25
- '\t\tconst hi = BigInt(value.high >>> 0);\n' +
26
- '\t\tconst combined = (hi << 32n) | lo;\n' +
27
- '\t\tif (!unsigned && value.high < 0) {\n' +
28
- '\t\t\treturn (combined - (1n << 64n)).toString();\n' +
29
- '\t\t}\n' +
30
- '\t\treturn combined.toString();\n' +
31
- '\t}\n' +
32
- '\treturn String(value);\n' +
33
- '}\n\n'
34
- const longToNumberHelper =
35
- 'function longToNumber(value, unsigned) {\n' +
36
- '\tif (typeof value === "number") {\n' +
37
- '\t\treturn value;\n' +
38
- '\t}\n' +
39
- '\tif (typeof value === "string") {\n' +
40
- '\t\treturn Number(value);\n' +
41
- '\t}\n' +
42
- '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
43
- '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
44
- '\t\tconst lo = BigInt(value.low >>> 0);\n' +
45
- '\t\tconst hi = BigInt(value.high >>> 0);\n' +
46
- '\t\tconst combined = (hi << 32n) | lo;\n' +
47
- '\t\tif (!unsigned && value.high < 0) {\n' +
48
- '\t\t\treturn Number(combined - (1n << 64n));\n' +
49
- '\t\t}\n' +
50
- '\t\treturn Number(combined);\n' +
51
- '\t}\n' +
52
- '\treturn Number(value);\n' +
53
- '}\n\n'
54
-
55
- if (!content.includes('function longToString(')) {
56
- const markerIndex = content.indexOf(marker)
57
- if (markerIndex === -1) {
58
- throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
59
- }
60
-
61
- content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
62
- } else {
63
- const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
64
- const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
65
-
66
- if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
67
- throw new Error('Unable to update Long helpers: existing definitions not found')
68
- }
69
-
70
- content = content.replace(longToStringRegex, longToStringHelper)
71
- content = content.replace(longToNumberRegex, longToNumberHelper)
72
- }
73
-
74
- const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
75
- content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
76
- const unsignedArg = unsignedFlag ? ', true' : ''
77
- return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
78
- })
79
-
80
- writeFileSync(filePath, content, 'utf8')
81
- console.log(`✅ Fixed imports in ${filePath}`)
82
- } catch (error) {
83
- console.error(`❌ Error fixing imports: ${error.message}`)
84
- exit(1)
85
- }
86
-
1
+ import { readFileSync, writeFileSync } from 'fs';
2
+ import { exit } from 'process';
3
+
4
+ const filePath = './index.js'
5
+
6
+ try {
7
+ let content = readFileSync(filePath, 'utf8')
8
+
9
+ content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
10
+ content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
11
+
12
+ const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
13
+ const longToStringHelper =
14
+ 'function longToString(value, unsigned) {\n' +
15
+ '\tif (typeof value === "string") {\n' +
16
+ '\t\treturn value;\n' +
17
+ '\t}\n' +
18
+ '\tif (typeof value === "number") {\n' +
19
+ '\t\treturn String(value);\n' +
20
+ '\t}\n' +
21
+ '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
22
+ '\t// BigInt.toString() is a native C++ operation, much faster than Long\'s pure JS division loops\n' +
23
+ '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
24
+ '\t\tconst lo = BigInt(value.low >>> 0);\n' +
25
+ '\t\tconst hi = BigInt(value.high >>> 0);\n' +
26
+ '\t\tconst combined = (hi << 32n) | lo;\n' +
27
+ '\t\tif (!unsigned && value.high < 0) {\n' +
28
+ '\t\t\treturn (combined - (1n << 64n)).toString();\n' +
29
+ '\t\t}\n' +
30
+ '\t\treturn combined.toString();\n' +
31
+ '\t}\n' +
32
+ '\treturn String(value);\n' +
33
+ '}\n\n'
34
+ const longToNumberHelper =
35
+ 'function longToNumber(value, unsigned) {\n' +
36
+ '\tif (typeof value === "number") {\n' +
37
+ '\t\treturn value;\n' +
38
+ '\t}\n' +
39
+ '\tif (typeof value === "string") {\n' +
40
+ '\t\treturn Number(value);\n' +
41
+ '\t}\n' +
42
+ '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
43
+ '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
44
+ '\t\tconst lo = BigInt(value.low >>> 0);\n' +
45
+ '\t\tconst hi = BigInt(value.high >>> 0);\n' +
46
+ '\t\tconst combined = (hi << 32n) | lo;\n' +
47
+ '\t\tif (!unsigned && value.high < 0) {\n' +
48
+ '\t\t\treturn Number(combined - (1n << 64n));\n' +
49
+ '\t\t}\n' +
50
+ '\t\treturn Number(combined);\n' +
51
+ '\t}\n' +
52
+ '\treturn Number(value);\n' +
53
+ '}\n\n'
54
+
55
+ if (!content.includes('function longToString(')) {
56
+ const markerIndex = content.indexOf(marker)
57
+ if (markerIndex === -1) {
58
+ throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
59
+ }
60
+
61
+ content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
62
+ } else {
63
+ const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
64
+ const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
65
+
66
+ if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
67
+ throw new Error('Unable to update Long helpers: existing definitions not found')
68
+ }
69
+
70
+ content = content.replace(longToStringRegex, longToStringHelper)
71
+ content = content.replace(longToNumberRegex, longToNumberHelper)
72
+ }
73
+
74
+ const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
75
+ content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
76
+ const unsignedArg = unsignedFlag ? ', true' : ''
77
+ return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
78
+ })
79
+
80
+ writeFileSync(filePath, content, 'utf8')
81
+ console.log(`✅ Fixed imports in ${filePath}`)
82
+ } catch (error) {
83
+ console.error(`❌ Error fixing imports: ${error.message}`)
84
+ exit(1)
85
+ }