@badzz88/baileys 8.5.3 → 8.5.4

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 (110) hide show
  1. package/README.md +1 -1
  2. package/WAProto/WAProto.proto +1256 -75
  3. package/WAProto/index.d.ts +36042 -19649
  4. package/WAProto/index.js +181990 -135645
  5. package/engine-requirements.js +7 -15
  6. package/lib/Defaults/index.js +22 -17
  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 +39 -59
  15. package/lib/Signal/lid-mapping.js +28 -10
  16. package/lib/Socket/aigroups.js +5 -5
  17. package/lib/Socket/business.js +3 -11
  18. package/lib/Socket/chats.js +668 -319
  19. package/lib/Socket/communities.js +85 -89
  20. package/lib/Socket/graphql.js +435 -228
  21. package/lib/Socket/groups.js +132 -211
  22. package/lib/Socket/index.js +9 -7
  23. package/lib/Socket/interactive-handler.js +117 -60
  24. package/lib/Socket/interop.js +56 -175
  25. package/lib/Socket/managed-account.js +79 -48
  26. package/lib/Socket/messages-recv.js +898 -340
  27. package/lib/Socket/messages-send.js +462 -160
  28. package/lib/Socket/mex.js +40 -53
  29. package/lib/Socket/newsletter.js +291 -295
  30. package/lib/Socket/privacy.js +77 -265
  31. package/lib/Socket/registration.js +164 -157
  32. package/lib/Socket/socket.js +181 -199
  33. package/lib/Socket/username.js +144 -227
  34. package/lib/Store/make-cache-manager-store.js +2 -2
  35. package/lib/Store/make-in-memory-store.js +25 -141
  36. package/lib/Types/Auth.js +3 -3
  37. package/lib/Types/Label.js +1 -1
  38. package/lib/Types/LabelAssociation.js +1 -1
  39. package/lib/Types/Newsletter.js +96 -65
  40. package/lib/Types/State.js +4 -4
  41. package/lib/Types/index.js +1 -1
  42. package/lib/Utils/auth-utils.js +52 -57
  43. package/lib/Utils/browser-utils.js +1 -1
  44. package/lib/Utils/business.js +2 -6
  45. package/lib/Utils/chat-utils.js +102 -38
  46. package/lib/Utils/crypto.js +54 -84
  47. package/lib/Utils/decode-wa-message.js +316 -83
  48. package/lib/Utils/event-buffer.js +37 -61
  49. package/lib/Utils/generics.js +157 -103
  50. package/lib/Utils/group-history.js +3 -12
  51. package/lib/Utils/history.js +15 -15
  52. package/lib/Utils/index.js +1 -5
  53. package/lib/Utils/link-preview.js +3 -8
  54. package/lib/Utils/lt-hash.js +2 -35
  55. package/lib/Utils/make-mutex.js +1 -1
  56. package/lib/Utils/message-inspect.js +393 -0
  57. package/lib/Utils/message-retry-manager.js +27 -92
  58. package/lib/Utils/messages-media.js +159 -130
  59. package/lib/Utils/messages.js +144 -566
  60. package/lib/Utils/meta-ai-msmsg.js +62 -202
  61. package/lib/Utils/noise-handler.js +19 -21
  62. package/lib/Utils/offline-node-processor.js +3 -8
  63. package/lib/Utils/pre-key-manager.js +13 -23
  64. package/lib/Utils/process-message.js +197 -106
  65. package/lib/Utils/reporting-utils.js +2 -2
  66. package/lib/Utils/signal.js +28 -63
  67. package/lib/Utils/stanza-ack.js +39 -12
  68. package/lib/Utils/sync-action-utils.js +4 -7
  69. package/lib/Utils/tc-token-utils.js +20 -25
  70. package/lib/Utils/use-multi-file-auth-state.js +30 -14
  71. package/lib/Utils/validate-connection.js +59 -19
  72. package/lib/WABinary/decode.js +50 -16
  73. package/lib/WABinary/encode.js +54 -224
  74. package/lib/WABinary/generic-utils.js +7 -97
  75. package/lib/WABinary/jid-utils.js +27 -14
  76. package/lib/WAM/encode.js +7 -7
  77. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
  78. package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
  79. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
  80. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
  81. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
  82. package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
  83. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
  84. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
  85. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
  86. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
  87. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
  88. package/lib/WAUSync/Protocols/index.js +1 -0
  89. package/lib/WAUSync/USyncBackoff.js +26 -0
  90. package/lib/WAUSync/USyncQuery.js +77 -6
  91. package/lib/WAUSync/USyncUser.js +16 -8
  92. package/lib/WAUSync/index.js +1 -0
  93. package/lib/antiban.js +608 -854
  94. package/lib/index.js +1 -1
  95. package/package.json +16 -20
  96. package/lib/Socket/luxu.js +0 -387
  97. package/lib/Socket/text-router.js +0 -83
  98. package/lib/Store/keyed-db.js +0 -108
  99. package/lib/Types/Mex.js +0 -112
  100. package/lib/Utils/command-loader.d.ts +0 -31
  101. package/lib/Utils/command-loader.js +0 -100
  102. package/lib/Utils/companion-reg-client-utils.js +0 -42
  103. package/lib/Utils/curve25519-js.js +0 -275
  104. package/lib/Utils/native-bridge.js +0 -82
  105. package/lib/Utils/session-pool.d.ts +0 -16
  106. package/lib/Utils/session-pool.js +0 -94
  107. package/lib/Utils/sticker.d.ts +0 -17
  108. package/lib/Utils/sticker.js +0 -145
  109. package/lib/Utils/view-once-cache.d.ts +0 -9
  110. package/lib/Utils/view-once-cache.js +0 -79
package/lib/Socket/mex.js CHANGED
@@ -1,60 +1,47 @@
1
1
  'use strict'
2
2
  Object.defineProperty(exports, '__esModule', { value: true })
3
3
  exports.executeWMexQuery = void 0
4
- exports.wMexQuery = void 0
5
- const { Boom } = require('@hapi/boom')
6
- const WeaBineri = require('../WABinary')
7
-
4
+ const boom_1 = require('@hapi/boom')
5
+ const WABinary_1 = require('../WABinary')
8
6
  const wMexQuery = (variables, queryId, query, generateMessageTag) => {
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
- })
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
+ })
25
23
  }
26
- exports.wMexQuery = wMexQuery
27
-
28
24
  const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
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 })
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 })
59
46
  }
60
- exports.executeWMexQuery = executeWMexQuery
47
+ exports.executeWMexQuery = executeWMexQuery