@badzz88/baileys 8.5.4 → 8.5.5

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 (107) hide show
  1. package/README.md +1 -1
  2. package/WAProto/WAProto.proto +75 -1256
  3. package/WAProto/index.d.ts +19729 -36122
  4. package/WAProto/index.js +132193 -178538
  5. package/engine-requirements.js +15 -7
  6. package/lib/Defaults/index.js +14 -22
  7. package/lib/Signal/Group/group_cipher.js +5 -5
  8. package/lib/Signal/Group/keyhelper.js +4 -4
  9. package/lib/Signal/Group/sender-chain-key.js +2 -2
  10. package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
  11. package/lib/Signal/Group/sender-key-message.js +3 -3
  12. package/lib/Signal/Group/sender-key-record.js +1 -1
  13. package/lib/Signal/Group/sender-message-key.js +5 -5
  14. package/lib/Signal/libsignal.js +28 -39
  15. package/lib/Signal/lid-mapping.js +8 -28
  16. package/lib/Socket/aigroups.js +5 -5
  17. package/lib/Socket/business.js +11 -3
  18. package/lib/Socket/chats.js +319 -668
  19. package/lib/Socket/communities.js +89 -85
  20. package/lib/Socket/graphql.js +228 -435
  21. package/lib/Socket/groups.js +211 -132
  22. package/lib/Socket/index.js +7 -9
  23. package/lib/Socket/interactive-handler.js +60 -117
  24. package/lib/Socket/interop.js +175 -56
  25. package/lib/Socket/luxu.js +387 -0
  26. package/lib/Socket/managed-account.js +48 -79
  27. package/lib/Socket/messages-recv.js +340 -898
  28. package/lib/Socket/messages-send.js +160 -462
  29. package/lib/Socket/mex.js +53 -40
  30. package/lib/Socket/newsletter.js +295 -291
  31. package/lib/Socket/privacy.js +265 -77
  32. package/lib/Socket/registration.js +157 -164
  33. package/lib/Socket/socket.js +199 -181
  34. package/lib/Socket/text-router.js +83 -0
  35. package/lib/Socket/username.js +227 -144
  36. package/lib/Store/keyed-db.js +108 -0
  37. package/lib/Store/make-cache-manager-store.js +2 -2
  38. package/lib/Store/make-in-memory-store.js +141 -25
  39. package/lib/Types/Auth.js +3 -3
  40. package/lib/Types/Label.js +1 -1
  41. package/lib/Types/LabelAssociation.js +1 -1
  42. package/lib/Types/Mex.js +112 -0
  43. package/lib/Types/Newsletter.js +65 -96
  44. package/lib/Types/State.js +4 -4
  45. package/lib/Types/index.js +1 -1
  46. package/lib/Utils/auth-utils.js +57 -52
  47. package/lib/Utils/browser-utils.js +1 -1
  48. package/lib/Utils/business.js +6 -2
  49. package/lib/Utils/chat-utils.js +38 -102
  50. package/lib/Utils/command-loader.d.ts +31 -0
  51. package/lib/Utils/command-loader.js +100 -0
  52. package/lib/Utils/companion-reg-client-utils.js +42 -0
  53. package/lib/Utils/crypto.js +84 -54
  54. package/lib/Utils/curve25519-js.js +275 -0
  55. package/lib/Utils/decode-wa-message.js +83 -316
  56. package/lib/Utils/event-buffer.js +61 -37
  57. package/lib/Utils/generics.js +103 -157
  58. package/lib/Utils/group-history.js +12 -3
  59. package/lib/Utils/history.js +15 -15
  60. package/lib/Utils/index.js +5 -1
  61. package/lib/Utils/link-preview.js +8 -3
  62. package/lib/Utils/lt-hash.js +35 -2
  63. package/lib/Utils/make-mutex.js +1 -1
  64. package/lib/Utils/message-retry-manager.js +92 -27
  65. package/lib/Utils/messages-media.js +130 -159
  66. package/lib/Utils/messages.js +566 -144
  67. package/lib/Utils/meta-ai-msmsg.js +202 -62
  68. package/lib/Utils/native-bridge.js +82 -0
  69. package/lib/Utils/noise-handler.js +21 -19
  70. package/lib/Utils/offline-node-processor.js +8 -3
  71. package/lib/Utils/pre-key-manager.js +23 -13
  72. package/lib/Utils/process-message.js +106 -197
  73. package/lib/Utils/reporting-utils.js +2 -2
  74. package/lib/Utils/session-pool.d.ts +16 -0
  75. package/lib/Utils/session-pool.js +94 -0
  76. package/lib/Utils/signal.js +63 -28
  77. package/lib/Utils/stanza-ack.js +12 -39
  78. package/lib/Utils/sticker.d.ts +17 -0
  79. package/lib/Utils/sticker.js +145 -0
  80. package/lib/Utils/sync-action-utils.js +7 -4
  81. package/lib/Utils/tc-token-utils.js +25 -20
  82. package/lib/Utils/use-multi-file-auth-state.js +14 -30
  83. package/lib/Utils/validate-connection.js +19 -59
  84. package/lib/Utils/view-once-cache.d.ts +9 -0
  85. package/lib/Utils/view-once-cache.js +79 -0
  86. package/lib/WABinary/decode.js +16 -50
  87. package/lib/WABinary/encode.js +224 -54
  88. package/lib/WABinary/generic-utils.js +97 -7
  89. package/lib/WABinary/jid-utils.js +14 -27
  90. package/lib/WAM/encode.js +7 -7
  91. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +1 -58
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -7
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
  95. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +7 -20
  96. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
  97. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
  99. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
  100. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
  101. package/lib/WAUSync/Protocols/index.js +0 -1
  102. package/lib/WAUSync/USyncQuery.js +6 -77
  103. package/lib/WAUSync/USyncUser.js +8 -16
  104. package/lib/WAUSync/index.js +0 -1
  105. package/lib/antiban.js +854 -608
  106. package/lib/index.js +1 -1
  107. package/package.json +20 -16
package/lib/Socket/mex.js CHANGED
@@ -1,47 +1,60 @@
1
1
  'use strict'
2
2
  Object.defineProperty(exports, '__esModule', { value: true })
3
3
  exports.executeWMexQuery = void 0
4
- const boom_1 = require('@hapi/boom')
5
- const WABinary_1 = require('../WABinary')
4
+ exports.wMexQuery = void 0
5
+ const { Boom } = require('@hapi/boom')
6
+ const WeaBineri = require('../WABinary')
7
+
6
8
  const wMexQuery = (variables, queryId, query, generateMessageTag) => {
7
- return query({
8
- tag: 'iq',
9
- attrs: {
10
- id: generateMessageTag(),
11
- type: 'get',
12
- to: WABinary_1.S_WHATSAPP_NET,
13
- xmlns: 'w:mex'
14
- },
15
- content: [
16
- {
17
- tag: 'query',
18
- attrs: { query_id: queryId },
19
- content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
20
- }
21
- ]
22
- })
9
+ return query({
10
+ tag: 'iq',
11
+ attrs: {
12
+ id: generateMessageTag(),
13
+ type: 'get',
14
+ to: WeaBineri.S_WHATSAPP_NET,
15
+ xmlns: 'w:mex'
16
+ },
17
+ content: [
18
+ {
19
+ tag: 'query',
20
+ attrs: { query_id: queryId },
21
+ content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
22
+ }
23
+ ]
24
+ })
23
25
  }
26
+ exports.wMexQuery = wMexQuery
27
+
24
28
  const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
25
- const result = await wMexQuery(variables, queryId, query, generateMessageTag)
26
- const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
27
- if (child?.content) {
28
- const data = JSON.parse(child.content.toString())
29
- if (data.errors && data.errors.length > 0) {
30
- const errorMessages = data.errors.map(err => err.message || 'Unknown error').join(', ')
31
- const firstError = data.errors[0]
32
- const errorCode = firstError.extensions?.error_code || 400
33
-
34
- console.error('[mex error] query_id=%s code=%s errors=%s', queryId, errorCode, JSON.stringify(data.errors))
35
- throw new boom_1.Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
36
- }
37
- const response = dataPath ? data?.data?.[dataPath] : data?.data
38
- if (typeof response !== 'undefined') {
39
- return response
40
- }
41
- }
42
- const action = (dataPath || '').startsWith('xwa2_')
43
- ? dataPath.substring(5).replace(/_/g, ' ')
44
- : dataPath?.replace(/_/g, ' ')
45
- throw new boom_1.Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
29
+ const result = await wMexQuery(variables, queryId, query, generateMessageTag)
30
+ const child = WeaBineri.getBinaryNodeChild(result, 'result')
31
+ if (child?.content) {
32
+ const str = child.content.toString('utf-8').replace(/^\x00+/, '').trim()
33
+ let data
34
+ try {
35
+ data = JSON.parse(str)
36
+ } catch {
37
+ data = str
38
+ }
39
+ if (typeof data === 'string') {
40
+ return data
41
+ }
42
+ if (data.errors && data.errors.length > 0) {
43
+ const errorMessages = data.errors.map(err => err.message || 'Unknown error').join(', ')
44
+ const firstError = data.errors[0]
45
+ const errorCode = firstError.extensions?.error_code || 400
46
+ throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
47
+ }
48
+
49
+ const response = dataPath? data?.data?.[dataPath] : data?.data
50
+ if (typeof response!== 'undefined') {
51
+ return response
52
+ }
53
+ }
54
+
55
+ const action = (dataPath || '').startsWith('xwa2_')
56
+ ? dataPath.substring(5).replace(/_/g, '')
57
+ : dataPath?.replace(/_/g, '')
58
+ throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
46
59
  }
47
- exports.executeWMexQuery = executeWMexQuery
60
+ exports.executeWMexQuery = executeWMexQuery