riftcore 1.4.5 → 1.4.7

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 (115) hide show
  1. package/README.md +422 -0
  2. package/WAProto/index.js +79296 -118676
  3. package/example.js +13 -0
  4. package/lib/Defaults/baileys-version.json +2 -2
  5. package/lib/Defaults/index.d.ts +7 -16
  6. package/lib/Defaults/index.js +103 -90
  7. package/lib/Defaults/phonenumber-mcc.json +223 -0
  8. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -1
  9. package/lib/Socket/Client/index.d.ts +3 -2
  10. package/lib/Socket/Client/index.js +3 -2
  11. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  12. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  13. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  14. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +5 -54
  15. package/lib/Socket/business.d.ts +58 -59
  16. package/lib/Socket/chats.d.ts +27 -29
  17. package/lib/Socket/chats.js +90 -97
  18. package/lib/Socket/erlanggaofficial.d.ts +219 -0
  19. package/lib/Socket/erlanggaofficial.js +439 -0
  20. package/lib/Socket/groups.d.ts +32 -41
  21. package/lib/Socket/groups.js +5 -20
  22. package/lib/Socket/index.d.ts +64 -63
  23. package/lib/Socket/index.js +2 -2
  24. package/lib/Socket/messages-recv.js +65 -9
  25. package/lib/Socket/messages-send.d.ts +47 -49
  26. package/lib/Socket/messages-send.js +377 -541
  27. package/lib/Socket/newsletter.d.ts +37 -39
  28. package/lib/Socket/newsletter.js +41 -73
  29. package/lib/Socket/registration.d.ts +267 -0
  30. package/lib/Socket/registration.js +166 -0
  31. package/lib/Socket/socket.d.ts +43 -270
  32. package/lib/Socket/socket.js +38 -62
  33. package/lib/Socket/usync.d.ts +3 -3
  34. package/lib/Store/index.d.ts +2 -1
  35. package/lib/Store/index.js +3 -1
  36. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  37. package/lib/Store/make-cache-manager-store.js +83 -0
  38. package/lib/Store/make-in-memory-store.d.ts +24 -24
  39. package/lib/Store/make-in-memory-store.js +15 -27
  40. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  41. package/lib/Store/make-ordered-dictionary.js +2 -2
  42. package/lib/Types/Auth.d.ts +7 -0
  43. package/lib/Types/Call.d.ts +1 -1
  44. package/lib/Types/Chat.d.ts +7 -14
  45. package/lib/Types/Contact.d.ts +1 -5
  46. package/lib/Types/Events.d.ts +2 -44
  47. package/lib/Types/GroupMetadata.d.ts +2 -11
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +21 -148
  51. package/lib/Types/Message.js +2 -0
  52. package/lib/Types/Newsletter.d.ts +13 -0
  53. package/lib/Types/Newsletter.js +17 -3
  54. package/lib/Types/Socket.d.ts +9 -17
  55. package/lib/Types/index.d.ts +1 -8
  56. package/lib/Types/index.js +2 -2
  57. package/lib/Utils/auth-utils.d.ts +3 -3
  58. package/lib/Utils/auth-utils.js +13 -6
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +16 -15
  61. package/lib/Utils/chat-utils.js +35 -36
  62. package/lib/Utils/crypto.d.ts +16 -15
  63. package/lib/Utils/crypto.js +29 -71
  64. package/lib/Utils/decode-wa-message.d.ts +6 -22
  65. package/lib/Utils/decode-wa-message.js +56 -65
  66. package/lib/Utils/event-buffer.d.ts +2 -2
  67. package/lib/Utils/event-buffer.js +7 -11
  68. package/lib/Utils/generics.d.ts +20 -17
  69. package/lib/Utils/generics.js +23 -73
  70. package/lib/Utils/history.d.ts +0 -4
  71. package/lib/Utils/history.js +6 -4
  72. package/lib/Utils/link-preview.d.ts +2 -2
  73. package/lib/Utils/link-preview.js +1 -34
  74. package/lib/Utils/logger.d.ts +3 -10
  75. package/lib/Utils/lt-hash.d.ts +2 -2
  76. package/lib/Utils/lt-hash.js +6 -6
  77. package/lib/Utils/make-mutex.d.ts +2 -2
  78. package/lib/Utils/messages-media.d.ts +24 -28
  79. package/lib/Utils/messages-media.js +157 -406
  80. package/lib/Utils/messages.d.ts +10 -13
  81. package/lib/Utils/messages.js +48 -345
  82. package/lib/Utils/noise-handler.d.ts +12 -10
  83. package/lib/Utils/noise-handler.js +23 -18
  84. package/lib/Utils/process-message.d.ts +4 -5
  85. package/lib/Utils/process-message.js +25 -108
  86. package/lib/Utils/signal.d.ts +1 -2
  87. package/lib/Utils/signal.js +35 -37
  88. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  89. package/lib/Utils/use-multi-file-auth-state.js +6 -51
  90. package/lib/Utils/validate-connection.d.ts +4 -3
  91. package/lib/Utils/validate-connection.js +66 -90
  92. package/lib/WABinary/constants.d.ts +4 -4
  93. package/lib/WABinary/constants.js +13 -1276
  94. package/lib/WABinary/decode.d.ts +4 -3
  95. package/lib/WABinary/decode.js +13 -26
  96. package/lib/WABinary/encode.d.ts +2 -1
  97. package/lib/WABinary/encode.js +17 -39
  98. package/lib/WABinary/generic-utils.d.ts +3 -1
  99. package/lib/WABinary/generic-utils.js +10 -2
  100. package/lib/WABinary/jid-utils.d.ts +5 -11
  101. package/lib/WABinary/jid-utils.js +5 -28
  102. package/lib/WAM/BinaryInfo.d.ts +11 -2
  103. package/lib/WAM/encode.d.ts +2 -1
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  105. package/lib/index.d.ts +2 -6
  106. package/lib/index.js +15 -31
  107. package/package.json +51 -39
  108. package/WAProto/GenerateStatics.sh +0 -4
  109. package/WAProto/WAProto.proto +0 -4775
  110. package/WAProto/index.d.ts +0 -55057
  111. package/WAProto/index.ts.ts +0 -53473
  112. package/lib/Socket/setup.js +0 -481
  113. package/lib/Socket/setup.ts +0 -623
  114. package/lib/WABinary/jid-utils.js.bak +0 -83
  115. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/README.md ADDED
@@ -0,0 +1,422 @@
1
+
2
+ # <div align='center'>Baileys Modification</div>
3
+
4
+ <div align="center">
5
+
6
+ <img src="https://files.catbox.moe/qhl7st.png" />
7
+
8
+ <a href="https://www.npmjs.com/package/riftcore">
9
+ <img src="https://img.shields.io/npm/v/riftcore?color=red&label=Version&logo=npm" alt="npm version" />
10
+ </a>
11
+
12
+ <a href="https://www.npmjs.com/package/riftcore">
13
+ <img src="https://img.shields.io/npm/dt/riftcore?color=red&label=Downloads&logo=npm" alt="npm downloads" />
14
+ </a>
15
+
16
+ <a href="https://whatsapp.com/channel/0029Vb73EYZFXUujAoHFor1i">
17
+ <img src="https://img.shields.io/badge/WhatsApp-Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
18
+ </a>
19
+
20
+ </div>
21
+
22
+ ## 📖 Table of Contents
23
+
24
+ - [Important Note](#important-note)
25
+ - [Install](#install)
26
+ - [Added Features and Improvements](#-added-features-and-improvements)
27
+ - [Feature Examples](#feature-examples)
28
+ - [Newsletter Management](#newsletter-management)
29
+ - [Button and Interactive Message Management](#button-and-interactive-message-management)
30
+ - [Send Album Message](#send-album-message)
31
+ - [AI Message Icon Customization](#ai-message-icon-customization)
32
+ - [Custom Pairing Code Generation](#custom-pairing-code-generation)
33
+ - [Reporting Issues](#reporting-issues)
34
+ - [Notes](#notes)
35
+ ---
36
+
37
+ ## Important Note
38
+
39
+ The original repository was initially removed by its creator and subsequently taken over by [WhiskeySockets](https://github.com/WhiskeySockets). Building upon this foundation, I have implemented several enhancements and introduced new features that were not present in the original repository. These improvements aim to elevate functionality and provide a more robust and versatile experience.
40
+
41
+ ## Install
42
+
43
+ Install in package.json:
44
+ ```json
45
+ "dependencies": {
46
+ "@whiskeysockets/baileys": "npm:riftcore"
47
+ }
48
+ ````
49
+ or install in terminal:
50
+ ```
51
+ npm install i riftcore
52
+ ```
53
+
54
+ Then import the default function in your code:
55
+ ```ts
56
+ // type esm
57
+ import makeWASocket from ' WhiskeySockets/baileys'
58
+ ```
59
+
60
+ ```js
61
+ // type cjs
62
+ const { default: makeWASocket } = require(" WhiskeySockets/baileys")
63
+ ```
64
+
65
+ ## Added Features and Improvements
66
+
67
+ | Feature | Description |
68
+ | :------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------- |
69
+ | 💬 **Send Messages to Channels** | Supports sending text and media messages to channels. |
70
+ | 🔘 **Button & Interactive Messages** | Supports sending button messages and interactive messages on WhatsApp Messenger and WhatsApp Business. |
71
+ | 🖼️ **Send Album Messages** | Supports sending multiple images as an album (grouped media message), enabling richer and more organized media sharing. |
72
+ | 👥 **Group with LID Support** | Full support for group using `@lid`, ensuring compatibility with the latest WhatsApp group addressing format. |
73
+ | 🤖 **AI Message Icon** | Customize message appearances with an optional AI icon, adding a modern touch. |
74
+ | 🖼️ **Full-Size Profile Pictures** | Allows users to upload profile pictures in their original size without cropping, ensuring better quality and visual presentation. |
75
+ | 🔑 **Custom Pairing Codes** | Users can now create and customize pairing codes as they wish, enhancing convenience and security when connecting devices. |
76
+ | 🛠️ **Libsignal Fixes** | Enjoy a cleaner development experience with refined logs, providing more informative and less cluttered output from the libsignal library.|
77
+
78
+ More features and improvements will be added in the future.
79
+
80
+ ## Feature Examples
81
+
82
+ Here are some examples of features that have been added:
83
+
84
+ ### Newsletter Management
85
+
86
+ <details>
87
+ <summary style="font-weight: bold; cursor: pointer; padding: 8px; border-bottom: 1px solid #eee; margin-bottom: 5px;">Show Examples</summary>
88
+ <div style="padding: 10px 15px; background: #f9f9f9; border: 1px solid #eee; border-top: none; border-radius: 0 0 5px 5px;">
89
+
90
+ - **To get info newsletter**
91
+ ```ts
92
+ const metadata = await sock.newsletterMetadata("invite", "xxxxx")
93
+ // or
94
+ const metadata = await sock.newsletterMetadata("jid", "abcd@newsletter")
95
+ console.log(metadata)
96
+ ```
97
+ - **To update the description of a newsletter**
98
+ ```ts
99
+ await sock.newsletterUpdateDescription("abcd@newsletter", "New Description")
100
+ ```
101
+ - **To update the name of a newsletter**
102
+ ```ts
103
+ await sock.newsletterUpdateName("abcd@newsletter", "New Name")
104
+ ```
105
+ - **To update the profile picture of a newsletter**
106
+ ```ts
107
+ await sock.newsletterUpdatePicture("abcd@newsletter", buffer)
108
+ ```
109
+ - **To remove the profile picture of a newsletter**
110
+ ```ts
111
+ await sock.newsletterRemovePicture("abcd@newsletter")
112
+ ```
113
+ - **To mute notifications for a newsletter**
114
+ ```ts
115
+ await sock.newsletterUnmute("abcd@newsletter")
116
+ ```
117
+ - **To mute notifications for a newsletter**
118
+ ```ts
119
+ await sock.newsletterMute("abcd@newsletter")
120
+ ```
121
+ - **To create a newsletter**
122
+ ```ts
123
+ const metadata = await sock.newsletterCreate("Newsletter Name")
124
+ console.log(metadata)
125
+ ```
126
+ - **To delete a newsletter**
127
+ ```ts
128
+ await sock.newsletterDelete("abcd@newsletter")
129
+ ```
130
+ - **To follow a newsletter**
131
+ ```ts
132
+ await sock.newsletterFollow("abcd@newsletter")
133
+ ```
134
+ - **To unfollow a newsletter**
135
+ ```ts
136
+ await sock.newsletterUnfollow("abcd@newsletter")
137
+ ```
138
+ - **To send reaction**
139
+ ```ts
140
+ // jid, id message & emoticon
141
+ // way to get the ID is to copy the message url from channel
142
+ // Example: [ https://whatsapp.com/channel/xxxxx/175 ]
143
+ // The last number of the URL is the ID
144
+ const id = "175"
145
+ await sock.newsletterReactMessage("abcd@newsletter", id, "🥳")
146
+ ```
147
+ </div>
148
+ </details>
149
+
150
+ ### Button and Interactive Message Management
151
+
152
+ <details>
153
+ <summary style="font-weight: bold; cursor: pointer; padding: 8px; border-bottom: 1px solid #eee; margin-bottom: 5px;">Show Examples</summary>
154
+ <div style="padding: 10px 15px; background: #f9f9f9; border: 1px solid #eee; border-top: none; border-radius: 0 0 5px 5px;">
155
+
156
+ - **To send button with text**
157
+ ```ts
158
+ const buttons = [
159
+ { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
160
+ { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
161
+ ]
162
+
163
+ const buttonMessage = {
164
+ text: "Hi it's button message",
165
+ footer: 'Hello World',
166
+ buttons,
167
+ headerType: 1
168
+ }
169
+
170
+ await sock.sendMessage(id, buttonMessage, { quoted: null })
171
+ ```
172
+ - **To send button with image**
173
+ ```ts
174
+ const buttons = [
175
+ { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
176
+ { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
177
+ ]
178
+
179
+ const buttonMessage = {
180
+ image: { url: "https://example.com/abcd.jpg" }, // image: buffer or path
181
+ caption: "Hi it's button message with image",
182
+ footer: 'Hello World',
183
+ buttons,
184
+ headerType: 1
185
+ }
186
+
187
+ await sock.sendMessage(id, buttonMessage, { quoted: null })
188
+
189
+ ```
190
+ - **To send button with video**
191
+ ```ts
192
+ const buttons = [
193
+ { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
194
+ { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
195
+ ]
196
+
197
+ const buttonMessage = {
198
+ video: { url: "https://example.com/abcd.mp4" }, // video: buffer or path
199
+ caption: "Hi it's button message with video",
200
+ footer: 'Hello World',
201
+ buttons,
202
+ headerType: 1
203
+ }
204
+
205
+ await sock.sendMessage(id, buttonMessage, { quoted: null })
206
+ ```
207
+
208
+ - **To send interactive message**
209
+ ```ts
210
+ const interactiveButtons = [
211
+ {
212
+ name: "quick_reply",
213
+ buttonParamsJson: JSON.stringify({
214
+ display_text: "Quick Reply",
215
+ id: "ID"
216
+ })
217
+ },
218
+ {
219
+ name: "cta_url",
220
+ buttonParamsJson: JSON.stringify({
221
+ display_text: "Tap Here!",
222
+ url: "https://www.example.com/"
223
+ })
224
+ },
225
+ {
226
+ name: "cta_copy",
227
+ buttonParamsJson: JSON.stringify({
228
+ display_text: "Copy Code",
229
+ id: "12345",
230
+ copy_code: "12345"
231
+ })
232
+ }
233
+ ]
234
+
235
+ const interactiveMessage = {
236
+ text: "Hello World!",
237
+ title: "this is the title",
238
+ footer: "this is the footer",
239
+ interactiveButtons
240
+ }
241
+
242
+ await sock.sendMessage(id, interactiveMessage, { quoted: null })
243
+ ```
244
+ - **To send interactive message with image**
245
+ ```ts
246
+ const interactiveButtons = [
247
+ {
248
+ name: "quick_reply",
249
+ buttonParamsJson: JSON.stringify({
250
+ display_text: "Quick Reply",
251
+ id: "ID"
252
+ })
253
+ },
254
+ {
255
+ name: "cta_url",
256
+ buttonParamsJson: JSON.stringify({
257
+ display_text: "Tap Here!",
258
+ url: "https://www.example.com/"
259
+ })
260
+ },
261
+ {
262
+ name: "cta_copy",
263
+ buttonParamsJson: JSON.stringify({
264
+ display_text: "Copy Code",
265
+ id: "12345",
266
+ copy_code: "12345"
267
+ })
268
+ }
269
+ ]
270
+
271
+ const interactiveMessage = {
272
+ image: { url: "https://example.com/abcd.jpg" }, // image: buffer or path
273
+ caption: "this is the caption",
274
+ title: "this is the title",
275
+ footer: "this is the footer",
276
+ interactiveButtons
277
+ }
278
+
279
+ await sock.sendMessage(id, interactiveMessage, { quoted: null })
280
+ ```
281
+ - **To send interactive message with video**
282
+ ```ts
283
+ const interactiveButtons = [
284
+ {
285
+ name: "quick_reply",
286
+ buttonParamsJson: JSON.stringify({
287
+ display_text: "Quick Reply",
288
+ id: "ID"
289
+ })
290
+ },
291
+ {
292
+ name: "cta_url",
293
+ buttonParamsJson: JSON.stringify({
294
+ display_text: "Tap Here!",
295
+ url: "https://www.example.com/"
296
+ })
297
+ },
298
+ {
299
+ name: "cta_copy",
300
+ buttonParamsJson: JSON.stringify({
301
+ display_text: "Copy Code",
302
+ id: "12345",
303
+ copy_code: "12345"
304
+ })
305
+ }
306
+ ]
307
+
308
+ const interactiveMessage = {
309
+ video: { url: "https://example.com/abcd.mp4" }, // video: buffer or path
310
+ caption: "this is the caption",
311
+ title: "this is the title",
312
+ footer: "this is the footer",
313
+ interactiveButtons
314
+ }
315
+
316
+ await sock.sendMessage(id, interactiveMessage, { quoted: null })
317
+ ```
318
+ - **To send list interactive**
319
+ ```ts
320
+ const interactiveButtons = [
321
+ {
322
+ name: "single_select",
323
+ buttonParamsJson: JSON.stringify({
324
+ title: "message",
325
+ sections: [
326
+ {
327
+ title: "title",
328
+ highlight_label: "label",
329
+ rows: [
330
+ {
331
+ header: "HEADER",
332
+ title: "TITLE",
333
+ description: "DESCRIPTION",
334
+ id: "YOUR ID"
335
+ },
336
+ {
337
+ header: "HEADER",
338
+ title: "TITLE",
339
+ description: "DESCRIPTION",
340
+ id: "YOUR ID"
341
+ }
342
+ ]
343
+ }
344
+ ]
345
+ })
346
+ }
347
+ ];
348
+
349
+ const interactiveMessage = {
350
+ text: "Hello World!",
351
+ title: "this is the title",
352
+ footer: "this is the footer",
353
+ interactiveButtons
354
+ };
355
+
356
+ await sock.sendMessage(id, interactiveMessage, { quoted: null });
357
+ ```
358
+
359
+ </div>
360
+ </details>
361
+
362
+ ### Send Album Message
363
+
364
+ <details>
365
+ <summary style="font-weight: bold; cursor: pointer; padding: 8px; border-bottom: 1px solid #eee; margin-bottom: 5px;">Show Example</summary>
366
+ <div style="padding: 10px 15px; background: #f9f9f9; border: 1px solid #eee; border-top: none; border-radius: 0 0 5px 5px;">
367
+
368
+ ```ts
369
+ // Media can be a URL, buffer, or path.
370
+ const media = [
371
+ {
372
+ image: { url: "https://example.com/image.jpg" }
373
+ },
374
+ {
375
+ image: await getBuffer("https://example.com/image.jpg")
376
+ },
377
+ {
378
+ video: { url: "https://example.com/video.mp4" }
379
+ }
380
+ ]
381
+
382
+ await sock.sendMessage(id, { album: media, caption: "testing send album" }, { quoted: null })
383
+ ```
384
+
385
+ </div>
386
+ </details>
387
+
388
+ ### AI Message Icon Customization
389
+
390
+ <details>
391
+ <summary style="font-weight: bold; cursor: pointer; padding: 8px; border-bottom: 1px solid #eee; margin-bottom: 5px;">Show Example</summary>
392
+ <div style="padding: 10px 15px; background: #f9f9f9; border: 1px solid #eee; border-top: none; border-radius: 0 0 5px 5px;">
393
+
394
+ ```ts
395
+ // To enable the AI icon for a message, simply add the "ai: true" parameter:
396
+ await sock.sendMessage(id, { text: "Hello World", ai: true });
397
+ ```
398
+
399
+ </div>
400
+ </details>
401
+
402
+ ### Custom Pairing Code Generation
403
+
404
+ <details>
405
+ <summary style="font-weight: bold; cursor: pointer; padding: 8px; border-bottom: 1px solid #eee; margin-bottom: 5px;">Show Example</summary>
406
+ <div style="padding: 10px 15px; background: #f9f9f9; border: 1px solid #eee; border-top: none; border-radius: 0 0 5px 5px;">
407
+
408
+ ```ts
409
+ if(usePairingCode && !sock.authState.creds.registered) {
410
+ const phoneNumber = await question('Please enter your mobile phone number:\n');
411
+ // Define your custom 8-digit code (alphanumeric)
412
+ const customPairingCode = "RIFTCORE";
413
+ const code = await sock.requestPairingCode(phoneNumber, customPairingCode);
414
+ console.log(`Your Pairing Code: ${code?.match(/.{1,4}/g)?.join('-') || code}`);
415
+ }
416
+ ```
417
+ *Note: The `question` function is a placeholder for your method of obtaining user input.*
418
+ </div>
419
+ </details>
420
+
421
+ ## Notes
422
+ Everything other than the modifications mentioned above remains the same as the original repository. You can check out the original repository at [WhiskeySockets](https://github.com/WhiskeySockets/Baileys)