@badzz88/baileys 8.4.6 → 8.4.9

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 (250) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1055 -337
  3. package/WAProto/WAProto.proto +850 -32
  4. package/WAProto/index.d.ts +4913 -25
  5. package/WAProto/index.js +14074 -98
  6. package/package.json +96 -131
  7. package/src/Defaults/index.js +201 -0
  8. package/src/Defaults/phonenumber-mcc.json +223 -0
  9. package/src/Signal/Group/ciphertext-message.js +15 -0
  10. package/src/Signal/Group/group-session-builder.js +92 -0
  11. package/src/Signal/Group/group_cipher.js +89 -0
  12. package/src/Signal/Group/index.js +136 -0
  13. package/src/Signal/Group/keyhelper.js +73 -0
  14. package/src/Signal/Group/sender-chain-key.js +32 -0
  15. package/src/Signal/Group/sender-key-distribution-message.js +66 -0
  16. package/src/Signal/Group/sender-key-message.js +69 -0
  17. package/src/Signal/Group/sender-key-name.js +50 -0
  18. package/src/Signal/Group/sender-key-record.js +44 -0
  19. package/src/Signal/Group/sender-key-state.js +97 -0
  20. package/src/Signal/Group/sender-message-key.js +30 -0
  21. package/src/Signal/libsignal.js +470 -0
  22. package/src/Signal/lid-mapping.js +262 -0
  23. package/src/Socket/Client/index.js +30 -0
  24. package/src/Socket/Client/types.js +13 -0
  25. package/src/Socket/Client/websocket.js +62 -0
  26. package/src/Socket/aigroups.js +240 -0
  27. package/src/Socket/business.js +422 -0
  28. package/src/Socket/chats.js +2374 -0
  29. package/src/Socket/communities.js +580 -0
  30. package/src/Socket/graphql.js +915 -0
  31. package/src/Socket/groups.js +812 -0
  32. package/src/Socket/index.js +37 -0
  33. package/src/Socket/interactive-handler.js +579 -0
  34. package/src/Socket/interop.js +566 -0
  35. package/src/Socket/managed-account.js +214 -0
  36. package/src/Socket/messages-recv.js +3012 -0
  37. package/src/Socket/messages-send.js +2163 -0
  38. package/{lib → src}/Socket/mex.js +11 -5
  39. package/src/Socket/newsletter.js +1057 -0
  40. package/src/Socket/privacy.js +452 -0
  41. package/src/Socket/registration.js +434 -0
  42. package/src/Socket/socket.js +1079 -0
  43. package/src/Socket/text-router.js +67 -0
  44. package/src/Socket/username.js +234 -0
  45. package/src/Store/index.js +36 -0
  46. package/src/Store/make-cache-manager-store.js +90 -0
  47. package/src/Store/make-in-memory-store.js +506 -0
  48. package/src/Store/make-ordered-dictionary.js +81 -0
  49. package/src/Store/object-repository.js +29 -0
  50. package/src/Types/Auth.js +38 -0
  51. package/src/Types/Bussines.js +2 -0
  52. package/src/Types/Call.js +2 -0
  53. package/src/Types/Chat.js +4 -0
  54. package/src/Types/Contact.js +2 -0
  55. package/src/Types/Events.js +2 -0
  56. package/src/Types/GroupMetadata.js +2 -0
  57. package/src/Types/Label.js +27 -0
  58. package/src/Types/LabelAssociation.js +9 -0
  59. package/src/Types/Message.js +95 -0
  60. package/src/Types/Newsletter.js +152 -0
  61. package/src/Types/Product.js +2 -0
  62. package/src/Types/Signal.js +2 -0
  63. package/src/Types/Socket.js +2 -0
  64. package/src/Types/State.js +70 -0
  65. package/src/Types/USync.js +2 -0
  66. package/src/Types/index.js +54 -0
  67. package/src/Utils/auth-utils.js +306 -0
  68. package/src/Utils/browser-utils.js +114 -0
  69. package/src/Utils/business.js +247 -0
  70. package/src/Utils/chat-utils.js +1272 -0
  71. package/src/Utils/consumer-application.js +107 -0
  72. package/src/Utils/crypto.js +125 -0
  73. package/src/Utils/decode-wa-message.js +808 -0
  74. package/src/Utils/event-buffer.js +586 -0
  75. package/src/Utils/generics.js +640 -0
  76. package/src/Utils/group-history.js +60 -0
  77. package/src/Utils/history.js +244 -0
  78. package/src/Utils/identity-change-handler.js +52 -0
  79. package/src/Utils/index.js +53 -0
  80. package/src/Utils/jid-display-normalization.js +218 -0
  81. package/src/Utils/link-preview.js +143 -0
  82. package/src/Utils/logger.js +9 -0
  83. package/src/Utils/lt-hash.js +10 -0
  84. package/src/Utils/make-mutex.js +36 -0
  85. package/src/Utils/message-composer.js +479 -0
  86. package/src/Utils/message-inspect.js +400 -0
  87. package/src/Utils/message-retry-manager.js +231 -0
  88. package/src/Utils/messages-media.js +943 -0
  89. package/src/Utils/messages.js +2490 -0
  90. package/src/Utils/meta-ai-msmsg.js +133 -0
  91. package/src/Utils/noise-handler.js +194 -0
  92. package/src/Utils/offline-node-processor.js +42 -0
  93. package/src/Utils/pre-key-manager.js +107 -0
  94. package/src/Utils/process-message.js +1047 -0
  95. package/src/Utils/reporting-utils.js +262 -0
  96. package/src/Utils/signal.js +192 -0
  97. package/src/Utils/stanza-ack.js +74 -0
  98. package/src/Utils/sync-action-utils.js +54 -0
  99. package/src/Utils/tc-token-utils.js +161 -0
  100. package/src/Utils/use-multi-file-auth-state.js +121 -0
  101. package/src/Utils/validate-connection.js +248 -0
  102. package/src/Utils/voip-rekey.js +22 -0
  103. package/src/WABinary/constants.js +1304 -0
  104. package/src/WABinary/decode.js +377 -0
  105. package/src/WABinary/encode.js +58 -0
  106. package/src/WABinary/generic-utils.js +148 -0
  107. package/src/WABinary/index.js +33 -0
  108. package/src/WABinary/jid-utils.js +374 -0
  109. package/src/WABinary/types.js +2 -0
  110. package/src/WAM/BinaryInfo.js +13 -0
  111. package/src/WAM/constants.js +39486 -0
  112. package/src/WAM/encode.js +142 -0
  113. package/src/WAM/index.js +31 -0
  114. package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
  115. package/src/WAUSync/Protocols/USyncBusinessProtocol.js +100 -0
  116. package/src/WAUSync/Protocols/USyncContactProtocol.js +60 -0
  117. package/src/WAUSync/Protocols/USyncDeviceProtocol.js +65 -0
  118. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  119. package/src/WAUSync/Protocols/USyncFeatureProtocol.js +74 -0
  120. package/src/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
  121. package/src/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
  122. package/src/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
  123. package/src/WAUSync/Protocols/USyncStatusProtocol.js +44 -0
  124. package/src/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
  125. package/src/WAUSync/Protocols/USyncUsernameProtocol.js +28 -0
  126. package/src/WAUSync/Protocols/index.js +40 -0
  127. package/src/WAUSync/USyncBackoff.js +31 -0
  128. package/src/WAUSync/USyncQuery.js +204 -0
  129. package/src/WAUSync/USyncUser.js +58 -0
  130. package/src/WAUSync/index.js +32 -0
  131. package/src/antiban.js +4726 -0
  132. package/{lib → src}/index.js +48 -16
  133. package/lib/Defaults/baileys-version.json +0 -3
  134. package/lib/Defaults/index.js +0 -137
  135. package/lib/Defaults/phonenumber-mcc.json +0 -223
  136. package/lib/Signal/Group/Protocols.js +0 -269
  137. package/lib/Signal/Group/ciphertext-message.js +0 -12
  138. package/lib/Signal/Group/group-session-builder.js +0 -30
  139. package/lib/Signal/Group/group_cipher.js +0 -82
  140. package/lib/Signal/Group/index.js +0 -12
  141. package/lib/Signal/Group/keyhelper.js +0 -18
  142. package/lib/Signal/Group/queue-job.js +0 -57
  143. package/lib/Signal/Group/sender-chain-key.js +0 -26
  144. package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
  145. package/lib/Signal/Group/sender-key-message.js +0 -66
  146. package/lib/Signal/Group/sender-key-name.js +0 -48
  147. package/lib/Signal/Group/sender-key-record.js +0 -41
  148. package/lib/Signal/Group/sender-key-state.js +0 -84
  149. package/lib/Signal/Group/sender-message-key.js +0 -26
  150. package/lib/Signal/libsignal.js +0 -432
  151. package/lib/Signal/lid-mapping.js +0 -277
  152. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  153. package/lib/Socket/Client/index.js +0 -3
  154. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  155. package/lib/Socket/Client/types.js +0 -11
  156. package/lib/Socket/Client/web-socket-client.js +0 -62
  157. package/lib/Socket/Client/websocket.js +0 -54
  158. package/lib/Socket/business.js +0 -379
  159. package/lib/Socket/chats.js +0 -1193
  160. package/lib/Socket/communities.js +0 -431
  161. package/lib/Socket/community.js +0 -392
  162. package/lib/Socket/dugong.js +0 -637
  163. package/lib/Socket/groups.js +0 -374
  164. package/lib/Socket/index.js +0 -12
  165. package/lib/Socket/luxu.js +0 -387
  166. package/lib/Socket/messages-recv.js +0 -1916
  167. package/lib/Socket/messages-send.js +0 -1459
  168. package/lib/Socket/newsletter.js +0 -253
  169. package/lib/Socket/registration.js +0 -167
  170. package/lib/Socket/socket.js +0 -950
  171. package/lib/Socket/username.js +0 -146
  172. package/lib/Socket/usync.js +0 -69
  173. package/lib/Store/index.js +0 -10
  174. package/lib/Store/keyed-db.js +0 -108
  175. package/lib/Store/make-cache-manager-store.js +0 -85
  176. package/lib/Store/make-in-memory-store.js +0 -198
  177. package/lib/Store/make-ordered-dictionary.js +0 -75
  178. package/lib/Store/object-repository.js +0 -32
  179. package/lib/Types/Auth.js +0 -2
  180. package/lib/Types/Bussines.js +0 -2
  181. package/lib/Types/Call.js +0 -2
  182. package/lib/Types/Chat.js +0 -8
  183. package/lib/Types/Contact.js +0 -2
  184. package/lib/Types/Events.js +0 -2
  185. package/lib/Types/GroupMetadata.js +0 -2
  186. package/lib/Types/Label.js +0 -25
  187. package/lib/Types/LabelAssociation.js +0 -7
  188. package/lib/Types/Message.js +0 -11
  189. package/lib/Types/Mex.js +0 -37
  190. package/lib/Types/Newsletter.js +0 -38
  191. package/lib/Types/Product.js +0 -2
  192. package/lib/Types/Signal.js +0 -2
  193. package/lib/Types/Socket.js +0 -3
  194. package/lib/Types/State.js +0 -56
  195. package/lib/Types/USync.js +0 -2
  196. package/lib/Types/index.js +0 -26
  197. package/lib/Utils/auth-utils.js +0 -302
  198. package/lib/Utils/baileys-event-stream.js +0 -63
  199. package/lib/Utils/browser-utils.js +0 -48
  200. package/lib/Utils/business.js +0 -231
  201. package/lib/Utils/chat-utils.js +0 -873
  202. package/lib/Utils/companion-reg-client-utils.js +0 -35
  203. package/lib/Utils/crypto.js +0 -118
  204. package/lib/Utils/decode-wa-message.js +0 -350
  205. package/lib/Utils/event-buffer.js +0 -622
  206. package/lib/Utils/generics.js +0 -399
  207. package/lib/Utils/history.js +0 -134
  208. package/lib/Utils/identity-change-handler.js +0 -50
  209. package/lib/Utils/index.js +0 -23
  210. package/lib/Utils/link-preview.js +0 -85
  211. package/lib/Utils/logger.js +0 -3
  212. package/lib/Utils/lt-hash.js +0 -8
  213. package/lib/Utils/make-mutex.js +0 -33
  214. package/lib/Utils/message-composer.js +0 -273
  215. package/lib/Utils/message-retry-manager.js +0 -265
  216. package/lib/Utils/messages-media.js +0 -788
  217. package/lib/Utils/messages.js +0 -1260
  218. package/lib/Utils/noise-handler.js +0 -201
  219. package/lib/Utils/offline-node-processor.js +0 -40
  220. package/lib/Utils/pre-key-manager.js +0 -106
  221. package/lib/Utils/process-message.js +0 -630
  222. package/lib/Utils/reporting-utils.js +0 -258
  223. package/lib/Utils/signal.js +0 -202
  224. package/lib/Utils/stanza-ack.js +0 -38
  225. package/lib/Utils/sync-action-utils.js +0 -49
  226. package/lib/Utils/tc-token-utils.js +0 -163
  227. package/lib/Utils/use-multi-file-auth-state.js +0 -121
  228. package/lib/Utils/validate-connection.js +0 -204
  229. package/lib/WABinary/constants.js +0 -1301
  230. package/lib/WABinary/decode.js +0 -262
  231. package/lib/WABinary/encode.js +0 -220
  232. package/lib/WABinary/generic-utils.js +0 -204
  233. package/lib/WABinary/index.js +0 -6
  234. package/lib/WABinary/jid-utils.js +0 -98
  235. package/lib/WABinary/types.js +0 -2
  236. package/lib/WAM/BinaryInfo.js +0 -10
  237. package/lib/WAM/constants.js +0 -22853
  238. package/lib/WAM/encode.js +0 -150
  239. package/lib/WAM/index.js +0 -4
  240. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -52
  241. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -54
  242. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -27
  243. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -38
  244. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
  245. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
  246. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
  247. package/lib/WAUSync/Protocols/index.js +0 -6
  248. package/lib/WAUSync/USyncQuery.js +0 -98
  249. package/lib/WAUSync/USyncUser.js +0 -31
  250. package/lib/WAUSync/index.js +0 -4
@@ -1,32 +0,0 @@
1
- export class ObjectRepository {
2
- constructor(entities = {}) {
3
- this.entityMap = new Map(Object.entries(entities));
4
- }
5
-
6
- findById(id) {
7
- return this.entityMap.get(id);
8
- }
9
-
10
- findAll() {
11
- return Array.from(this.entityMap.values());
12
- }
13
-
14
- upsertById(id, entity) {
15
- this.entityMap.set(id, { ...entity });
16
- return this;
17
- }
18
-
19
- deleteById(id) {
20
- return this.entityMap.delete(id);
21
- }
22
-
23
- count() {
24
- return this.entityMap.size;
25
- }
26
-
27
- toJSON() {
28
- return this.findAll();
29
- }
30
- }
31
-
32
- export default ObjectRepository;
package/lib/Types/Auth.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Auth.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Bussines.js.map
package/lib/Types/Call.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Call.js.map
package/lib/Types/Chat.js DELETED
@@ -1,8 +0,0 @@
1
- export const ALL_WA_PATCH_NAMES = [
2
- 'critical_block',
3
- 'critical_unblock_low',
4
- 'regular_high',
5
- 'regular_low',
6
- 'regular'
7
- ];
8
- //# sourceMappingURL=Chat.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Contact.js.map
@@ -1,2 +0,0 @@
1
- import { proto } from '../../WAProto/index.js';
2
- //# sourceMappingURL=Events.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=GroupMetadata.js.map
@@ -1,25 +0,0 @@
1
- /** WhatsApp has 20 predefined colors */
2
- export var LabelColor;
3
- (function (LabelColor) {
4
- LabelColor[LabelColor["Color1"] = 0] = "Color1";
5
- LabelColor[LabelColor["Color2"] = 1] = "Color2";
6
- LabelColor[LabelColor["Color3"] = 2] = "Color3";
7
- LabelColor[LabelColor["Color4"] = 3] = "Color4";
8
- LabelColor[LabelColor["Color5"] = 4] = "Color5";
9
- LabelColor[LabelColor["Color6"] = 5] = "Color6";
10
- LabelColor[LabelColor["Color7"] = 6] = "Color7";
11
- LabelColor[LabelColor["Color8"] = 7] = "Color8";
12
- LabelColor[LabelColor["Color9"] = 8] = "Color9";
13
- LabelColor[LabelColor["Color10"] = 9] = "Color10";
14
- LabelColor[LabelColor["Color11"] = 10] = "Color11";
15
- LabelColor[LabelColor["Color12"] = 11] = "Color12";
16
- LabelColor[LabelColor["Color13"] = 12] = "Color13";
17
- LabelColor[LabelColor["Color14"] = 13] = "Color14";
18
- LabelColor[LabelColor["Color15"] = 14] = "Color15";
19
- LabelColor[LabelColor["Color16"] = 15] = "Color16";
20
- LabelColor[LabelColor["Color17"] = 16] = "Color17";
21
- LabelColor[LabelColor["Color18"] = 17] = "Color18";
22
- LabelColor[LabelColor["Color19"] = 18] = "Color19";
23
- LabelColor[LabelColor["Color20"] = 19] = "Color20";
24
- })(LabelColor || (LabelColor = {}));
25
- //# sourceMappingURL=Label.js.map
@@ -1,7 +0,0 @@
1
- /** Association type */
2
- export var LabelAssociationType;
3
- (function (LabelAssociationType) {
4
- LabelAssociationType["Chat"] = "label_jid";
5
- LabelAssociationType["Message"] = "label_message";
6
- })(LabelAssociationType || (LabelAssociationType = {}));
7
- //# sourceMappingURL=LabelAssociation.js.map
@@ -1,11 +0,0 @@
1
- import { proto } from '../../WAProto/index.js';
2
- // export the WAMessage Prototypes
3
- export { proto as WAProto };
4
- export const WAMessageStubType = proto.WebMessageInfo.StubType;
5
- export const WAMessageStatus = proto.WebMessageInfo.Status;
6
- export var WAMessageAddressingMode;
7
- (function (WAMessageAddressingMode) {
8
- WAMessageAddressingMode["PN"] = "pn";
9
- WAMessageAddressingMode["LID"] = "lid";
10
- })(WAMessageAddressingMode || (WAMessageAddressingMode = {}));
11
- //# sourceMappingURL=Message.js.map
package/lib/Types/Mex.js DELETED
@@ -1,37 +0,0 @@
1
- export var XWAPaths;
2
- (function (XWAPaths) {
3
- XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
4
- XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
5
- XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
6
- XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
7
- XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
8
- XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
9
- XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
10
- XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
11
- XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
12
- XWAPaths["xwa2_newsletter_join_v2"] = "xwa2_newsletter_join_v2";
13
- XWAPaths["xwa2_newsletter_leave_v2"] = "xwa2_newsletter_leave_v2";
14
- XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
15
- XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
16
- XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
17
- XWAPaths["xwa2_fetch_account_reachout_timelock"] = "xwa2_fetch_account_reachout_timelock";
18
- XWAPaths["xwa2_message_capping_info"] = "xwa2_message_capping_info";
19
- })(XWAPaths || (XWAPaths = {}));
20
- export var QueryIds;
21
- (function (QueryIds) {
22
- QueryIds["CREATE"] = "8823471724422422";
23
- QueryIds["UPDATE_METADATA"] = "24250201037901610";
24
- QueryIds["METADATA"] = "6563316087068696";
25
- QueryIds["SUBSCRIBERS"] = "9783111038412085";
26
- QueryIds["FOLLOW"] = "24404358912487870";
27
- QueryIds["UNFOLLOW"] = "9767147403369991";
28
- QueryIds["MUTE"] = "29766401636284406";
29
- QueryIds["UNMUTE"] = "9864994326891137";
30
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
31
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
32
- QueryIds["DEMOTE"] = "6551828931592903";
33
- QueryIds["DELETE"] = "30062808666639665";
34
- QueryIds["REACHOUT_TIMELOCK"] = "23983697327930364";
35
- QueryIds["MESSAGE_CAPPING_INFO"] = "24503548349331633";
36
- })(QueryIds || (QueryIds = {}));
37
- //# sourceMappingURL=Mex.js.map
@@ -1,38 +0,0 @@
1
- "use strict"
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true })
4
-
5
- const MexOperations = {
6
- PROMOTE: "NotificationNewsletterAdminPromote",
7
- DEMOTE: "NotificationNewsletterAdminDemote",
8
- UPDATE: "NotificationNewsletterUpdate"
9
- }
10
-
11
- const XWAPaths = {
12
- PROMOTE: "xwa2_notify_newsletter_admin_promote",
13
- DEMOTE: "xwa2_notify_newsletter_admin_demote",
14
- ADMIN_COUNT: "xwa2_newsletter_admin",
15
- CREATE: "xwa2_newsletter_create",
16
- NEWSLETTER: "xwa2_newsletter",
17
- SUBSCRIBED: "xwa2_newsletter_subscribed",
18
- METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
19
- }
20
-
21
- const QueryIds = {
22
- JOB_MUTATION: "7150902998257522",
23
- METADATA: "6620195908089573",
24
- UNFOLLOW: "7238632346214362",
25
- FOLLOW: "7871414976211147",
26
- UNMUTE: "7337137176362961",
27
- MUTE: "25151904754424642",
28
- CREATE: "6996806640408138",
29
- ADMIN_COUNT: "7130823597031706",
30
- CHANGE_OWNER: "7341777602580933",
31
- DELETE: "8316537688363079",
32
- DEMOTE: "6551828931592903",
33
- SUBSCRIBED: "6388546374527196"
34
- }
35
-
36
- exports.MexOperations = MexOperations
37
- exports.XWAPaths = XWAPaths
38
- exports.QueryIds = QueryIds
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Product.js.map
@@ -1,2 +0,0 @@
1
- import { proto } from '../../WAProto/index.js';
2
- //# sourceMappingURL=Signal.js.map
@@ -1,3 +0,0 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import {} from './Message.js';
3
- //# sourceMappingURL=Socket.js.map
@@ -1,56 +0,0 @@
1
- import { Boom } from '@hapi/boom';
2
- export var SyncState;
3
- (function (SyncState) {
4
- /** The socket is connecting, but we haven't received pending notifications yet. */
5
- SyncState[SyncState["Connecting"] = 0] = "Connecting";
6
- /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
- SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
8
- /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
- SyncState[SyncState["Syncing"] = 2] = "Syncing";
10
- /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
- SyncState[SyncState["Online"] = 3] = "Online";
12
- })(SyncState || (SyncState = {}));
13
- export var ReachoutTimelockEnforcementType;
14
- (function (ReachoutTimelockEnforcementType) {
15
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ALCOHOL"] = "BIZ_COMMERCE_VIOLATION_ALCOHOL";
16
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ADULT"] = "BIZ_COMMERCE_VIOLATION_ADULT";
17
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ANIMALS"] = "BIZ_COMMERCE_VIOLATION_ANIMALS";
18
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS"] = "BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS";
19
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DATING"] = "BIZ_COMMERCE_VIOLATION_DATING";
20
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS"] = "BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS";
21
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS"] = "BIZ_COMMERCE_VIOLATION_DRUGS";
22
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC"] = "BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC";
23
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_GAMBLING"] = "BIZ_COMMERCE_VIOLATION_GAMBLING";
24
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_HEALTHCARE"] = "BIZ_COMMERCE_VIOLATION_HEALTHCARE";
25
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY"] = "BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY";
26
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_SUPPLEMENTS"] = "BIZ_COMMERCE_VIOLATION_SUPPLEMENTS";
27
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_TOBACCO"] = "BIZ_COMMERCE_VIOLATION_TOBACCO";
28
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT"] = "BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT";
29
- ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_WEAPONS"] = "BIZ_COMMERCE_VIOLATION_WEAPONS";
30
- ReachoutTimelockEnforcementType["BIZ_QUALITY"] = "BIZ_QUALITY";
31
- /** This means there is no restriction */
32
- ReachoutTimelockEnforcementType["DEFAULT"] = "DEFAULT";
33
- ReachoutTimelockEnforcementType["WEB_COMPANION_ONLY"] = "WEB_COMPANION_ONLY";
34
- })(ReachoutTimelockEnforcementType || (ReachoutTimelockEnforcementType = {}));
35
- export var NewChatMessageCappingStatusType;
36
- (function (NewChatMessageCappingStatusType) {
37
- NewChatMessageCappingStatusType["NONE"] = "NONE";
38
- NewChatMessageCappingStatusType["FIRST_WARNING"] = "FIRST_WARNING";
39
- NewChatMessageCappingStatusType["SECOND_WARNING"] = "SECOND_WARNING";
40
- NewChatMessageCappingStatusType["CAPPED"] = "CAPPED";
41
- })(NewChatMessageCappingStatusType || (NewChatMessageCappingStatusType = {}));
42
- export var NewChatMessageCappingMVStatusType;
43
- (function (NewChatMessageCappingMVStatusType) {
44
- NewChatMessageCappingMVStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
45
- NewChatMessageCappingMVStatusType["NOT_ACTIVE"] = "NOT_ACTIVE";
46
- NewChatMessageCappingMVStatusType["ACTIVE"] = "ACTIVE";
47
- NewChatMessageCappingMVStatusType["ACTIVE_UPGRADE_AVAILABLE"] = "ACTIVE_UPGRADE_AVAILABLE";
48
- })(NewChatMessageCappingMVStatusType || (NewChatMessageCappingMVStatusType = {}));
49
- export var NewChatMessageCappingOTEStatusType;
50
- (function (NewChatMessageCappingOTEStatusType) {
51
- NewChatMessageCappingOTEStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
52
- NewChatMessageCappingOTEStatusType["ELIGIBLE"] = "ELIGIBLE";
53
- NewChatMessageCappingOTEStatusType["ACTIVE_IN_CURRENT_CYCLE"] = "ACTIVE_IN_CURRENT_CYCLE";
54
- NewChatMessageCappingOTEStatusType["EXHAUSTED"] = "EXHAUSTED";
55
- })(NewChatMessageCappingOTEStatusType || (NewChatMessageCappingOTEStatusType = {}));
56
- //# sourceMappingURL=State.js.map
@@ -1,2 +0,0 @@
1
- import { USyncUser } from '../WAUSync/index.js';
2
- //# sourceMappingURL=USync.js.map
@@ -1,26 +0,0 @@
1
- export * from './Auth.js';
2
- export * from './GroupMetadata.js';
3
- export * from './Chat.js';
4
- export * from './Contact.js';
5
- export * from './State.js';
6
- export * from './Message.js';
7
- export * from './Socket.js';
8
- export * from './Events.js';
9
- export * from './Product.js';
10
- export * from './Call.js';
11
- export * from './Signal.js';
12
- export * from './Mex.js';
13
- export var DisconnectReason;
14
- (function (DisconnectReason) {
15
- DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
16
- DisconnectReason[DisconnectReason["connectionLost"] = 408] = "connectionLost";
17
- DisconnectReason[DisconnectReason["connectionReplaced"] = 440] = "connectionReplaced";
18
- DisconnectReason[DisconnectReason["timedOut"] = 408] = "timedOut";
19
- DisconnectReason[DisconnectReason["loggedOut"] = 401] = "loggedOut";
20
- DisconnectReason[DisconnectReason["badSession"] = 500] = "badSession";
21
- DisconnectReason[DisconnectReason["restartRequired"] = 515] = "restartRequired";
22
- DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
23
- DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
24
- DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
25
- })(DisconnectReason || (DisconnectReason = {}));
26
- //# sourceMappingURL=index.js.map
@@ -1,302 +0,0 @@
1
- import NodeCache from '@cacheable/node-cache';
2
- import { Boom } from '@hapi/boom';
3
- import { AsyncLocalStorage } from 'async_hooks';
4
- import { Mutex } from 'async-mutex';
5
- import { randomBytes } from 'crypto';
6
- import PQueue from 'p-queue';
7
- import { DEFAULT_CACHE_TTLS } from '../Defaults/index.js';
8
- import { Curve, signedKeyPair } from './crypto.js';
9
- import { delay, generateRegistrationId } from './generics.js';
10
- import { PreKeyManager } from './pre-key-manager.js';
11
- /**
12
- * Adds caching capability to a SignalKeyStore
13
- * @param store the store to add caching to
14
- * @param logger to log trace events
15
- * @param _cache cache store to use
16
- */
17
- export function makeCacheableSignalKeyStore(store, logger, _cache) {
18
- const cache = _cache ||
19
- new NodeCache({
20
- stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
21
- useClones: false,
22
- deleteOnExpire: true
23
- });
24
- // Mutex for protecting cache operations
25
- const cacheMutex = new Mutex();
26
- function getUniqueId(type, id) {
27
- return `${type}.${id}`;
28
- }
29
- return {
30
- async get(type, ids) {
31
- return cacheMutex.runExclusive(async () => {
32
- const data = {};
33
- const idsToFetch = [];
34
- for (const id of ids) {
35
- const item = (await cache.get(getUniqueId(type, id)));
36
- if (typeof item !== 'undefined') {
37
- data[id] = item;
38
- }
39
- else {
40
- idsToFetch.push(id);
41
- }
42
- }
43
- if (idsToFetch.length) {
44
- logger?.trace({ items: idsToFetch.length }, 'loading from store');
45
- const fetched = await store.get(type, idsToFetch);
46
- for (const id of idsToFetch) {
47
- const item = fetched[id];
48
- if (item) {
49
- data[id] = item;
50
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
51
- await cache.set(getUniqueId(type, id), item);
52
- }
53
- }
54
- }
55
- return data;
56
- });
57
- },
58
- async set(data) {
59
- return cacheMutex.runExclusive(async () => {
60
- let keys = 0;
61
- for (const type in data) {
62
- for (const id in data[type]) {
63
- await cache.set(getUniqueId(type, id), data[type][id]);
64
- keys += 1;
65
- }
66
- }
67
- logger?.trace({ keys }, 'updated cache');
68
- await store.set(data);
69
- });
70
- },
71
- async clear() {
72
- await cache.flushAll();
73
- await store.clear?.();
74
- }
75
- };
76
- }
77
- /**
78
- * Adds DB-like transaction capability to the SignalKeyStore
79
- * Uses AsyncLocalStorage for automatic context management
80
- * @param state the key store to apply this capability to
81
- * @param logger logger to log events
82
- * @returns SignalKeyStore with transaction capability
83
- */
84
- export const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
85
- const txStorage = new AsyncLocalStorage();
86
- // Queues for concurrency control (keyed by signal data type - bounded set)
87
- const keyQueues = new Map();
88
- // Transaction mutexes with reference counting for cleanup
89
- const txMutexes = new Map();
90
- const txMutexRefCounts = new Map();
91
- // Pre-key manager for specialized operations
92
- const preKeyManager = new PreKeyManager(state, logger);
93
- /**
94
- * Get or create a queue for a specific key type
95
- */
96
- function getQueue(key) {
97
- if (!keyQueues.has(key)) {
98
- keyQueues.set(key, new PQueue({ concurrency: 1 }));
99
- }
100
- return keyQueues.get(key);
101
- }
102
- /**
103
- * Get or create a transaction mutex
104
- */
105
- function getTxMutex(key) {
106
- if (!txMutexes.has(key)) {
107
- txMutexes.set(key, new Mutex());
108
- txMutexRefCounts.set(key, 0);
109
- }
110
- return txMutexes.get(key);
111
- }
112
- /**
113
- * Acquire a reference to a transaction mutex
114
- */
115
- function acquireTxMutexRef(key) {
116
- const count = txMutexRefCounts.get(key) ?? 0;
117
- txMutexRefCounts.set(key, count + 1);
118
- }
119
- /**
120
- * Release a reference to a transaction mutex and cleanup if no longer needed
121
- */
122
- function releaseTxMutexRef(key) {
123
- const count = (txMutexRefCounts.get(key) ?? 1) - 1;
124
- txMutexRefCounts.set(key, count);
125
- // Cleanup if no more references and mutex is not locked
126
- if (count <= 0) {
127
- const mutex = txMutexes.get(key);
128
- if (mutex && !mutex.isLocked()) {
129
- txMutexes.delete(key);
130
- txMutexRefCounts.delete(key);
131
- }
132
- }
133
- }
134
- /**
135
- * Check if currently in a transaction
136
- */
137
- function isInTransaction() {
138
- return !!txStorage.getStore();
139
- }
140
- /**
141
- * Commit transaction with retries
142
- */
143
- async function commitWithRetry(mutations) {
144
- if (Object.keys(mutations).length === 0) {
145
- logger.trace('no mutations in transaction');
146
- return;
147
- }
148
- logger.trace('committing transaction');
149
- for (let attempt = 0; attempt < maxCommitRetries; attempt++) {
150
- try {
151
- await state.set(mutations);
152
- logger.trace({ mutationCount: Object.keys(mutations).length }, 'committed transaction');
153
- return;
154
- }
155
- catch (error) {
156
- const retriesLeft = maxCommitRetries - attempt - 1;
157
- logger.warn(`failed to commit mutations, retries left=${retriesLeft}`);
158
- if (retriesLeft === 0) {
159
- throw error;
160
- }
161
- await delay(delayBetweenTriesMs);
162
- }
163
- }
164
- }
165
- return {
166
- get: async (type, ids) => {
167
- const ctx = txStorage.getStore();
168
- if (!ctx) {
169
- // No transaction - direct read without exclusive lock for concurrency
170
- return state.get(type, ids);
171
- }
172
- // In transaction - check cache first
173
- const cached = ctx.cache[type] || {};
174
- const missing = ids.filter(id => !(id in cached));
175
- if (missing.length > 0) {
176
- ctx.dbQueries++;
177
- logger.trace({ type, count: missing.length }, 'fetching missing keys in transaction');
178
- const fetched = await getTxMutex(type).runExclusive(() => state.get(type, missing));
179
- // Update cache
180
- ctx.cache[type] = ctx.cache[type] || {};
181
- Object.assign(ctx.cache[type], fetched);
182
- }
183
- // Return requested ids from cache
184
- const result = {};
185
- for (const id of ids) {
186
- const value = ctx.cache[type]?.[id];
187
- if (value !== undefined && value !== null) {
188
- result[id] = value;
189
- }
190
- }
191
- return result;
192
- },
193
- set: async (data) => {
194
- const ctx = txStorage.getStore();
195
- if (!ctx) {
196
- // No transaction - direct write with queue protection
197
- const types = Object.keys(data);
198
- // Process pre-keys with validation
199
- for (const type_ of types) {
200
- const type = type_;
201
- if (type === 'pre-key') {
202
- await preKeyManager.validateDeletions(data, type);
203
- }
204
- }
205
- // Write all data in parallel
206
- await Promise.all(types.map(type => getQueue(type).add(async () => {
207
- const typeData = { [type]: data[type] };
208
- await state.set(typeData);
209
- })));
210
- return;
211
- }
212
- // In transaction - update cache and mutations
213
- logger.trace({ types: Object.keys(data) }, 'caching in transaction');
214
- for (const key_ in data) {
215
- const key = key_;
216
- // Ensure structures exist
217
- ctx.cache[key] = ctx.cache[key] || {};
218
- ctx.mutations[key] = ctx.mutations[key] || {};
219
- // Special handling for pre-keys
220
- if (key === 'pre-key') {
221
- await preKeyManager.processOperations(data, key, ctx.cache, ctx.mutations, true);
222
- }
223
- else {
224
- // Normal key types
225
- Object.assign(ctx.cache[key], data[key]);
226
- Object.assign(ctx.mutations[key], data[key]);
227
- }
228
- }
229
- },
230
- isInTransaction,
231
- transaction: async (work, key) => {
232
- const existing = txStorage.getStore();
233
- // Nested transaction - reuse existing context
234
- if (existing) {
235
- logger.trace('reusing existing transaction context');
236
- return work();
237
- }
238
- // New transaction - acquire mutex and create context
239
- const mutex = getTxMutex(key);
240
- acquireTxMutexRef(key);
241
- try {
242
- return await mutex.runExclusive(async () => {
243
- const ctx = {
244
- cache: {},
245
- mutations: {},
246
- dbQueries: 0
247
- };
248
- logger.trace('entering transaction');
249
- try {
250
- const result = await txStorage.run(ctx, work);
251
- // Commit mutations
252
- await commitWithRetry(ctx.mutations);
253
- logger.trace({ dbQueries: ctx.dbQueries }, 'transaction completed');
254
- return result;
255
- }
256
- catch (error) {
257
- logger.error({ error }, 'transaction failed, rolling back');
258
- throw error;
259
- }
260
- });
261
- }
262
- finally {
263
- releaseTxMutexRef(key);
264
- }
265
- }
266
- };
267
- };
268
- /**
269
- * Returns the authenticated user's JID, or throws a Boom-401 if creds are not yet authenticated.
270
- * Use this anywhere we'd otherwise reach for `creds.me!.id` to fail fast with a descriptive error.
271
- */
272
- export const assertMeId = (creds) => {
273
- const id = creds.me?.id;
274
- if (!id) {
275
- throw new Boom('Cannot proceed: socket is not authenticated yet (creds.me.id is missing)', { statusCode: 401 });
276
- }
277
- return id;
278
- };
279
- export const initAuthCreds = () => {
280
- const identityKey = Curve.generateKeyPair();
281
- return {
282
- noiseKey: Curve.generateKeyPair(),
283
- pairingEphemeralKeyPair: Curve.generateKeyPair(),
284
- signedIdentityKey: identityKey,
285
- signedPreKey: signedKeyPair(identityKey, 1),
286
- registrationId: generateRegistrationId(),
287
- advSecretKey: randomBytes(32).toString('base64'),
288
- processedHistoryMessages: [],
289
- nextPreKeyId: 1,
290
- firstUnuploadedPreKeyId: 1,
291
- accountSyncCounter: 0,
292
- accountSettings: {
293
- unarchiveChats: false
294
- },
295
- registered: false,
296
- pairingCode: undefined,
297
- lastPropHash: undefined,
298
- routingInfo: undefined,
299
- additionalData: undefined
300
- };
301
- };
302
- //# sourceMappingURL=auth-utils.js.map
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readAndEmitEventStream = exports.captureEventStream = void 0;
7
- const events_1 = __importDefault(require("events"));
8
- const fs_1 = require("fs");
9
- const promises_1 = require("fs/promises");
10
- const readline_1 = require("readline");
11
- const generics_1 = require("./generics");
12
- const make_mutex_1 = require("./make-mutex");
13
- /**
14
- * Captures events from a baileys event emitter & stores them in a file
15
- * @param ev The event emitter to read events from
16
- * @param filename File to save to
17
- */
18
- const captureEventStream = (ev, filename) => {
19
- const oldEmit = ev.emit;
20
- // write mutex so data is appended in order
21
- const writeMutex = (0, make_mutex_1.makeMutex)();
22
- // monkey patch eventemitter to capture all events
23
- ev.emit = function (...args) {
24
- const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
25
- const result = oldEmit.apply(ev, args);
26
- writeMutex.mutex(async () => {
27
- await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
28
- });
29
- return result;
30
- };
31
- };
32
- exports.captureEventStream = captureEventStream;
33
- /**
34
- * Read event file and emit events from there
35
- * @param filename filename containing event data
36
- * @param delayIntervalMs delay between each event emit
37
- */
38
- const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
39
- const ev = new events_1.default();
40
- const fireEvents = async () => {
41
- // from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
42
- const fileStream = (0, fs_1.createReadStream)(filename);
43
- const rl = (0, readline_1.createInterface)({
44
- input: fileStream,
45
- crlfDelay: Infinity
46
- });
47
- // Note: we use the crlfDelay option to recognize all instances of CR LF
48
- // ('\r\n') in input.txt as a single line break.
49
- for await (const line of rl) {
50
- if (line) {
51
- const { event, data } = JSON.parse(line);
52
- ev.emit(event, data);
53
- delayIntervalMs && await (0, generics_1.delay)(delayIntervalMs);
54
- }
55
- }
56
- fileStream.close();
57
- };
58
- return {
59
- ev,
60
- task: fireEvents()
61
- };
62
- };
63
- exports.readAndEmitEventStream = readAndEmitEventStream;