mod-baileys 1.0.2 → 2.0.0

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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -61
  3. package/lib/Defaults/constants.js +74 -0
  4. package/lib/Defaults/index.d.ts +53 -0
  5. package/lib/Defaults/index.js +6 -6
  6. package/lib/Defaults/media.js +48 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  9. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  10. package/lib/Signal/Group/index.d.ts +11 -0
  11. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  12. package/lib/Signal/Group/queue-job.d.ts +1 -0
  13. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  14. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  15. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  16. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  17. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  18. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  19. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  20. package/lib/Signal/libsignal.d.ts +3 -0
  21. package/lib/Signal/libsignal.js +5 -5
  22. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  23. package/lib/Socket/Client/index.d.ts +3 -0
  24. package/lib/Socket/Client/index.js +3 -3
  25. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  26. package/lib/Socket/Client/mobile-socket-client.js +1 -1
  27. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  28. package/lib/Socket/Client/web-socket-client.js +2 -2
  29. package/lib/Socket/business.d.ts +171 -0
  30. package/lib/Socket/chats.d.ts +267 -0
  31. package/lib/Socket/groups.d.ts +115 -0
  32. package/lib/Socket/groups.js +6 -6
  33. package/lib/Socket/index.d.ts +173 -0
  34. package/lib/Socket/index.js +2 -2
  35. package/lib/Socket/luxu.d.ts +268 -0
  36. package/lib/Socket/{dew.js → luxu.js} +11 -11
  37. package/lib/Socket/messages-recv.d.ts +161 -0
  38. package/lib/Socket/messages-send.d.ts +149 -0
  39. package/lib/Socket/messages-send.js +10 -10
  40. package/lib/Socket/newsletter.d.ts +134 -0
  41. package/lib/Socket/newsletter.js +5 -8
  42. package/lib/Socket/registration.d.ts +267 -0
  43. package/lib/Socket/registration.js +4 -4
  44. package/lib/Socket/socket.d.ts +43 -0
  45. package/lib/Socket/socket.js +10 -9
  46. package/lib/Socket/usync.d.ts +36 -0
  47. package/lib/Store/index.d.ts +3 -0
  48. package/lib/Store/index.js +2 -2
  49. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  50. package/lib/Store/make-cache-manager-store.js +3 -3
  51. package/lib/Store/make-in-memory-store.d.ts +118 -0
  52. package/lib/Store/make-in-memory-store.js +7 -7
  53. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  54. package/lib/Store/object-repository.d.ts +10 -0
  55. package/lib/Types/Auth.d.ts +110 -0
  56. package/lib/Types/Call.d.ts +13 -0
  57. package/lib/Types/Chat.d.ts +102 -0
  58. package/lib/Types/Contact.d.ts +19 -0
  59. package/lib/Types/Events.d.ts +157 -0
  60. package/lib/Types/GroupMetadata.d.ts +55 -0
  61. package/lib/Types/Label.d.ts +35 -0
  62. package/lib/Types/LabelAssociation.d.ts +29 -0
  63. package/lib/Types/Message.d.ts +273 -0
  64. package/lib/Types/Message.js +1 -1
  65. package/lib/Types/Newsletter.d.ts +103 -0
  66. package/lib/Types/Product.d.ts +78 -0
  67. package/lib/Types/Signal.d.ts +57 -0
  68. package/lib/Types/Socket.d.ts +111 -0
  69. package/lib/Types/State.d.ts +27 -0
  70. package/lib/Types/USync.d.ts +25 -0
  71. package/lib/Types/index.d.ts +57 -0
  72. package/lib/Types/index.js +12 -12
  73. package/lib/Utils/auth-utils.d.ts +18 -0
  74. package/lib/Utils/auth-utils.js +3 -3
  75. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  76. package/lib/Utils/baileys-event-stream.js +2 -2
  77. package/lib/Utils/business.d.ts +22 -0
  78. package/lib/Utils/chat-utils.d.ts +71 -0
  79. package/lib/Utils/chat-utils.js +7 -7
  80. package/lib/Utils/crypto.d.ts +41 -0
  81. package/lib/Utils/crypto.js +1 -1
  82. package/lib/Utils/decode-wa-message.d.ts +19 -0
  83. package/lib/Utils/decode-wa-message.js +3 -3
  84. package/lib/Utils/event-buffer.d.ts +35 -0
  85. package/lib/Utils/event-buffer.js +4 -4
  86. package/lib/Utils/generics.d.ts +92 -0
  87. package/lib/Utils/generics.js +5 -5
  88. package/lib/Utils/history.d.ts +15 -0
  89. package/lib/Utils/history.js +6 -6
  90. package/lib/Utils/index.d.ts +17 -0
  91. package/lib/Utils/index.js +17 -17
  92. package/lib/Utils/link-preview.d.ts +21 -0
  93. package/lib/Utils/link-preview.js +2 -2
  94. package/lib/Utils/logger.d.ts +4 -0
  95. package/lib/Utils/lt-hash.d.ts +12 -0
  96. package/lib/Utils/lt-hash.js +1 -1
  97. package/lib/Utils/make-mutex.d.ts +7 -0
  98. package/lib/Utils/messages-media.d.ts +116 -0
  99. package/lib/Utils/messages-media.js +837 -548
  100. package/lib/Utils/messages.d.ts +77 -0
  101. package/lib/Utils/messages.js +1539 -497
  102. package/lib/Utils/noise-handler.d.ts +21 -0
  103. package/lib/Utils/noise-handler.js +4 -4
  104. package/lib/Utils/process-message.d.ts +41 -0
  105. package/lib/Utils/process-message.js +7 -7
  106. package/lib/Utils/signal.d.ts +32 -0
  107. package/lib/Utils/signal.js +4 -4
  108. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  109. package/lib/Utils/use-multi-file-auth-state.js +3 -3
  110. package/lib/Utils/validate-connection.d.ts +11 -0
  111. package/lib/Utils/validate-connection.js +6 -6
  112. package/lib/WABinary/constants.d.ts +30 -0
  113. package/lib/WABinary/decode.d.ts +7 -0
  114. package/lib/WABinary/decode.js +2 -2
  115. package/lib/WABinary/encode.d.ts +3 -0
  116. package/lib/WABinary/encode.js +2 -2
  117. package/lib/WABinary/generic-utils.d.ts +17 -0
  118. package/lib/WABinary/generic-utils.js +2 -2
  119. package/lib/WABinary/index.d.ts +5 -0
  120. package/lib/WABinary/index.js +5 -5
  121. package/lib/WABinary/jid-utils.d.ts +31 -0
  122. package/lib/WABinary/jid-utils.js +3 -0
  123. package/lib/WABinary/types.d.ts +18 -0
  124. package/lib/WAM/BinaryInfo.d.ts +17 -0
  125. package/lib/WAM/constants.d.ts +38 -0
  126. package/lib/WAM/encode.d.ts +3 -0
  127. package/lib/WAM/encode.js +1 -1
  128. package/lib/WAM/index.d.ts +3 -0
  129. package/lib/WAM/index.js +3 -3
  130. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
  131. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  132. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -2
  136. package/lib/WAUSync/Protocols/index.d.ts +4 -4
  137. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  138. package/lib/WAUSync/USyncQuery.js +4 -4
  139. package/lib/WAUSync/USyncUser.d.ts +12 -0
  140. package/lib/WAUSync/index.js +3 -3
  141. package/lib/index.d.ts +12 -0
  142. package/lib/index.js +10 -18
  143. package/lib/temp +1 -0
  144. package/package.json +5 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dew-Coders
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
+ <div align="center">
2
+
1
3
  <div align="center">
2
4
  <img src="https://capsule-render.vercel.app/api?type=speech&height=300&color=gradient&text=MOD%20BAIYLES&animation=blinking" width="100%">
3
5
  </div>
4
6
  <br>
5
- <div align="center">
7
+
6
8
  <div style="background: linear-gradient(90deg, #6366F1, #3B82F6, #2DD4BF); padding: 8px; border-radius: 10px; margin: 15px 0;">
7
9
  <span style="font-size: 18px; font-weight: bold; color: white;"><b>🔥Ultimate WhatsApp Web API<b></span>
8
10
  </div>
@@ -11,71 +13,22 @@
11
13
  ![JavaScript](https://img.shields.io/badge/-%F0%9F%94%B8%20JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=F7DF1E&labelColor=0D1117)
12
14
  ![WhatsApp](https://img.shields.io/badge/-%F0%9F%92%AC%20WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white&labelColor=0D1117)
13
15
  ![NPM](https://img.shields.io/badge/-%F0%9F%93%A6%20npm-CB3837?style=for-the-badge&logo=npm&logoColor=white&labelColor=0D1117)
14
-
15
- <p>
16
- <!-- NPM Version -->
17
- <a href="https://www.npmjs.com/package/mod-baileys">
18
- <img src="https://img.shields.io/npm/v/mod-baileys?color=blueviolet&label=version&logo=npm" alt="npm version" />
19
- </a>
20
-
21
- <!-- NPM Downloads -->
22
- <a href="https://www.npmjs.com/package/mod-baileys">
23
- <img src="https://img.shields.io/npm/dt/mod-baileys?color=blueviolet&label=downloads&logo=npm" alt="npm downloads" />
24
- </a>
25
-
26
- <!-- License -->
27
- <a href="https://www.npmjs.com/package/mod-baileys">
28
- <img src="https://img.shields.io/npm/l/mod-baileys?color=success&label=license" alt="license" />
29
- </a>
30
-
31
- <!-- Bundle Size -->
32
- <a href="https://bundlephobia.com/package/mod-baileys">
33
- <img src="https://img.shields.io/bundlephobia/min/mod-baileys?label=minified%20size&color=orange" alt="bundle size" />
34
- </a>
35
-
36
- <!-- Gzip Bundle Size -->
37
- <a href="https://bundlephobia.com/package/mod-baileys">
38
- <img src="https://img.shields.io/bundlephobia/minzip/mod-baileys?label=minzip%20size&color=orange" alt="gzip bundle size" />
39
- </a>
40
-
41
- <!-- PackagePhobia Install Size -->
42
- <a href="https://packagephobia.com/result?p=mod-baileys">
43
- <img src="https://packagephobia.com/badge?p=mod-baileys" alt="install size" />
44
- </a>
45
-
46
- <!-- Code Quality (Codacy) -->
47
- <a href="https://app.codacy.com">
48
- <img src="https://img.shields.io/badge/Codacy-Quality%20Check-blue?logo=codacy" alt="Codacy quality" />
49
- </a>
50
-
51
- <!-- Security Scan (Snyk) -->
52
- <a href="https://snyk.io">
53
- <img src="https://img.shields.io/badge/Snyk-Security%20Scan-purple?logo=snyk" alt="Snyk security" />
54
- </a>
55
-
56
- <!-- Node Engine Support -->
57
- <img src="https://img.shields.io/node/v/mod-baileys?label=node%21engine" alt="node engine" />
58
-
59
- <!-- Types -->
60
- <img src="https://img.shields.io/npm/types/mod-baileys?label=types" alt="types" />
61
- </p>
62
-
63
16
  </div>
64
17
 
18
+ <br>
65
19
 
66
20
  <div align="center">
67
21
  <img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=60&section=header" width="100%">
68
22
  </div>
69
- <div align="center">
23
+
70
24
  <div style="border-left: 4px solid #3B82F6; padding-left: 15px; margin: 25px 0;">
71
- <h2>2026 BEST BAILEYS RELEASE</h2>
25
+ <h2>⚡️ Supercharged WhatsApp API 🌟</h2>
72
26
  <p><i>Elevate your messaging experience with the most advanced WhatsApp Web API solution available</i></p>
73
- </div></div></div>
74
-
27
+ </div>
75
28
 
76
29
  ---
77
30
 
78
- ## ❓️ | WHY USE MOD-BAILEYS?
31
+ ## ❓️ | WHY MOD-BAILEYS?
79
32
 
80
33
  <div style="display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin: 20px 0;">
81
34
  <div style="background: rgba(45, 212, 191, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
@@ -105,21 +58,21 @@
105
58
  ### 📂 In package.json:
106
59
  ```json
107
60
  "dependencies": {
108
- "mod-baileys": "*"
61
+ "dew-baileys": "*"
109
62
  }
110
63
  ```
111
64
  or option2
112
65
  ### 📂 In package.json:
113
66
  ```json
114
67
  "dependencies": {
115
- "@whiskeysockets/baileys": "github:dew-coders/mod-baileys"
68
+ "@whiskeysockets/baileys": "github:dew-coders/Dew-Baileys"
116
69
  }
117
70
  ```
118
71
 
119
72
 
120
73
  ### ⚙️ Terminal Installation:
121
74
  ```bash
122
- npm install mod-baileys
75
+ npm install dew-baileys
123
76
  ```
124
77
 
125
78
  ### 🔌 Import:
@@ -128,14 +81,14 @@ npm install mod-baileys
128
81
 
129
82
  ```typescript
130
83
  // ESM
131
- import makeWASocket from 'dew-baileys'
84
+ import makeWASocket from 'mod-baileys'
132
85
  ```
133
86
  </div>
134
87
  <div style="background: rgba(234, 179, 8, 0.1); border-radius: 5px; padding: 10px; flex: 1;">
135
88
 
136
89
  ```javascript
137
90
  // CommonJS
138
- const { default: makeWASocket } = require("dew-baileys")
91
+ const { default: makeWASocket } = require("mod-baileys")
139
92
  ```
140
93
  </div>
141
94
  </div>
@@ -190,6 +143,7 @@ console.log("Ur pairing code : " + code)
190
143
  | 🔐 **Custom Pairing** | Personalized device pairing codes | ✅ |
191
144
  | 🔧 **Performance Optimizations** | Cleaner logs & improved signal handling | ✅ |
192
145
  | 📱 **Cross-Platform** | Works on all NodeJS supported platforms | ✅ |
146
+ | ⤴️ **2GB UPLOAD** | Works on all Up To 1GB Files Fast | ✅ |
193
147
 
194
148
  </div>
195
149
 
@@ -510,4 +464,4 @@ if(usePairingCode && !sock.authState.creds.registered) {
510
464
  </div>
511
465
  <div align="center">
512
466
  <img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=100&section=footer" width="100%">
513
- </div>
467
+ </div>
@@ -0,0 +1,74 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const UNAUTHORIZED_CODES = [401, 403, 419]
6
+
7
+ const PHONENUMBER_MCC = require("./phonenumber-mcc.json")
8
+
9
+ const DEFAULT_ORIGIN = 'https://web.whatsapp.com'
10
+
11
+ const PHONE_CONNECTION_CB = 'CB:Pong'
12
+
13
+ const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0])
14
+
15
+ const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1])
16
+
17
+ const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5])
18
+
19
+ const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6])
20
+
21
+ const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
22
+
23
+ const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
24
+
25
+ const DICT_VERSION = 3
26
+
27
+ const KEY_BUNDLE_TYPE = Buffer.from([5])
28
+
29
+ const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]) // last is "DICT_VERSION"
30
+
31
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
32
+ const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
33
+
34
+ const MIN_PREKEY_COUNT = 5
35
+
36
+ const INITIAL_PREKEY_COUNT = 812
37
+
38
+ const UPLOAD_TIMEOUT = 30000 // 30 seconds
39
+
40
+ const MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
41
+
42
+ const WA_CERT_DETAILS = {
43
+ SERIAL: 0
44
+ }
45
+
46
+ const DEFAULT_CACHE_TTLS = {
47
+ SIGNAL_STORE: 5 * 60,
48
+ MSG_RETRY: 60 * 60,
49
+ CALL_OFFER: 5 * 60,
50
+ USER_DEVICES: 5 * 60, // 5 minutes
51
+ }
52
+
53
+ module.exports = {
54
+ UNAUTHORIZED_CODES,
55
+ PHONENUMBER_MCC,
56
+ DEFAULT_ORIGIN,
57
+ PHONE_CONNECTION_CB,
58
+ WA_ADV_ACCOUNT_SIG_PREFIX,
59
+ WA_ADV_DEVICE_SIG_PREFIX,
60
+ WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX,
61
+ WA_ADV_HOSTED_DEVICE_SIG_PREFIX,
62
+ WA_DEFAULT_EPHEMERAL,
63
+ NOISE_MODE,
64
+ DICT_VERSION,
65
+ KEY_BUNDLE_TYPE,
66
+ NOISE_WA_HEADER,
67
+ URL_REGEX,
68
+ MIN_PREKEY_COUNT,
69
+ MIN_UPLOAD_INTERVAL,
70
+ INITIAL_PREKEY_COUNT,
71
+ UPLOAD_TIMEOUT,
72
+ WA_CERT_DETAILS,
73
+ DEFAULT_CACHE_TTLS
74
+ }
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { proto } from '../../WAProto';
4
+ import type { MediaType, SocketConfig } from '../Types';
5
+ export declare const UNAUTHORIZED_CODES: number[];
6
+ export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
7
+ export declare const DEF_CALLBACK_PREFIX = "CB:";
8
+ export declare const DEF_TAG_PREFIX = "TAG:";
9
+ export declare const PHONE_CONNECTION_CB = "CB:Pong";
10
+ export declare const WA_DEFAULT_EPHEMERAL: number;
11
+ export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
12
+ export declare const DICT_VERSION = 2;
13
+ export declare const KEY_BUNDLE_TYPE: Buffer;
14
+ export declare const NOISE_WA_HEADER: Buffer;
15
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
16
+ export declare const URL_REGEX: RegExp;
17
+ export declare const WA_CERT_DETAILS: {
18
+ SERIAL: number;
19
+ };
20
+ export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
21
+ export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
22
+ export declare const MEDIA_PATH_MAP: {
23
+ [T in MediaType]?: string;
24
+ };
25
+ export declare const MEDIA_HKDF_KEY_MAPPING: {
26
+ audio: string;
27
+ document: string;
28
+ gif: string;
29
+ image: string;
30
+ ppic: string;
31
+ product: string;
32
+ ptt: string;
33
+ sticker: string;
34
+ video: string;
35
+ 'thumbnail-document': string;
36
+ 'thumbnail-image': string;
37
+ 'thumbnail-video': string;
38
+ 'thumbnail-link': string;
39
+ 'md-msg-hist': string;
40
+ 'md-app-state': string;
41
+ 'product-catalog-image': string;
42
+ 'payment-bg-image': string;
43
+ ptv: string;
44
+ };
45
+ export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
46
+ export declare const MIN_PREKEY_COUNT = 5;
47
+ export declare const INITIAL_PREKEY_COUNT = 30;
48
+ export declare const DEFAULT_CACHE_TTLS: {
49
+ SIGNAL_STORE: number;
50
+ MSG_RETRY: number;
51
+ CALL_OFFER: number;
52
+ USER_DEVICES: number;
53
+ };
@@ -27,12 +27,12 @@ exports.DEFAULT_CACHE_TTLS =
27
27
  void 0;
28
28
 
29
29
  const crypto_1 = require("crypto");
30
- const WAProto_1 = require("mod-baileys/WAProto"),
31
- libsignal_1 = require("mod-baileys/lib/Signal/libsignal"),
32
- Utils_1 = require("mod-baileys/lib/Utils"),
33
- logger_1 = __importDefault(require("mod-baileys/lib/Utils/logger")),
34
- baileys_version_json_1 = require("mod-baileys/lib/Defaults/baileys-version.json"),
35
- phonenumber_mcc_json_1 = __importDefault(require("mod-baileys/lib/Defaults/phonenumber-mcc.json"));
30
+ const WAProto_1 = require("../../WAProto"),
31
+ libsignal_1 = require("../Signal/libsignal"),
32
+ Utils_1 = require("../Utils"),
33
+ logger_1 = __importDefault(require("../Utils/logger")),
34
+ baileys_version_json_1 = require("./baileys-version.json"),
35
+ phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
36
36
 
37
37
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
38
38
  exports.version = [2, 3000, 1027934701];
@@ -0,0 +1,48 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const MEDIA_PATH_MAP = {
6
+ image: '/mms/image',
7
+ video: '/mms/video',
8
+ document: '/mms/document',
9
+ audio: '/mms/audio',
10
+ sticker: '/mms/image',
11
+ 'sticker-pack': '/mms/sticker',
12
+ 'thumbnail-link': '/mms/image',
13
+ 'product-catalog-image': '/product/image',
14
+ 'md-app-state': '',
15
+ 'md-msg-hist': '/mms/md-app-state',
16
+ 'biz-cover-photo': '/pps/biz-cover-photo'
17
+ }
18
+
19
+ const MEDIA_HKDF_KEY_MAPPING = {
20
+ 'audio': 'Audio',
21
+ 'document': 'Document',
22
+ 'gif': 'Video',
23
+ 'image': 'Image',
24
+ 'ppic': '',
25
+ 'product': 'Image',
26
+ 'ptt': 'Audio',
27
+ 'video': 'Video',
28
+ 'sticker': 'Image',
29
+ 'sticker-pack': 'Sticker Pack',
30
+ 'thumbnail-document': 'Document Thumbnail',
31
+ 'thumbnail-image': 'Image Thumbnail',
32
+ 'thumbnail-video': 'Video Thumbnail',
33
+ 'thumbnail-link': 'Link Thumbnail',
34
+ 'md-msg-hist': 'History',
35
+ 'md-app-state': 'App State',
36
+ 'product-catalog-image': '',
37
+ 'payment-bg-image': 'Payment Background',
38
+ 'ptv': 'Video',
39
+ 'biz-cover-photo': 'Image'
40
+ }
41
+
42
+ const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP)
43
+
44
+ module.exports = {
45
+ MEDIA_KEYS,
46
+ MEDIA_PATH_MAP,
47
+ MEDIA_HKDF_KEY_MAPPING
48
+ }
@@ -0,0 +1,9 @@
1
+ export declare class CiphertextMessage {
2
+ readonly UNSUPPORTED_VERSION: number;
3
+ readonly CURRENT_VERSION: number;
4
+ readonly WHISPER_TYPE: number;
5
+ readonly PREKEY_TYPE: number;
6
+ readonly SENDERKEY_TYPE: number;
7
+ readonly SENDERKEY_DISTRIBUTION_TYPE: number;
8
+ readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
9
+ }
@@ -0,0 +1,14 @@
1
+ import { SenderKeyDistributionMessage } from './sender-key-distribution-message';
2
+ import { SenderKeyName } from './sender-key-name';
3
+ import { SenderKeyRecord } from './sender-key-record';
4
+ interface SenderKeyStore {
5
+ loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
6
+ storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
7
+ }
8
+ export declare class GroupSessionBuilder {
9
+ private readonly senderKeyStore;
10
+ constructor(senderKeyStore: SenderKeyStore);
11
+ process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
12
+ create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
13
+ }
14
+ export {};
@@ -0,0 +1,17 @@
1
+ import { SenderKeyName } from './sender-key-name';
2
+ import { SenderKeyRecord } from './sender-key-record';
3
+ export interface SenderKeyStore {
4
+ loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
5
+ storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
6
+ }
7
+ export declare class GroupCipher {
8
+ private readonly senderKeyStore;
9
+ private readonly senderKeyName;
10
+ constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
11
+ private queueJob;
12
+ encrypt(paddedPlaintext: Uint8Array | string): Promise<Uint8Array>;
13
+ decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
14
+ private getSenderKey;
15
+ private getPlainText;
16
+ private getCipherText;
17
+ }
@@ -0,0 +1,11 @@
1
+ export { GroupSessionBuilder } from './group-session-builder';
2
+ export { SenderKeyDistributionMessage } from './sender-key-distribution-message';
3
+ export { SenderKeyRecord } from './sender-key-record';
4
+ export { SenderKeyName } from './sender-key-name';
5
+ export { GroupCipher } from './group_cipher';
6
+ export { SenderKeyState } from './sender-key-state';
7
+ export { SenderKeyMessage } from './sender-key-message';
8
+ export { SenderMessageKey } from './sender-message-key';
9
+ export { SenderChainKey } from './sender-chain-key';
10
+ export { CiphertextMessage } from './ciphertext-message';
11
+ export * as keyhelper from './keyhelper';
@@ -0,0 +1,10 @@
1
+ import { generateKeyPair } from 'libsignal/src/curve';
2
+ type KeyPairType = ReturnType<typeof generateKeyPair>;
3
+ export declare function generateSenderKey(): Buffer;
4
+ export declare function generateSenderKeyId(): number;
5
+ export interface SigningKeyPair {
6
+ public: Buffer;
7
+ private: Buffer;
8
+ }
9
+ export declare function generateSenderSigningKey(key?: KeyPairType): SigningKeyPair;
10
+ export {};
@@ -0,0 +1 @@
1
+ export default function queueJob<T>(bucket: string | number, awaitable: () => Promise<T>): Promise<T>;
@@ -0,0 +1,13 @@
1
+ import { SenderMessageKey } from './sender-message-key';
2
+ export declare class SenderChainKey {
3
+ private readonly MESSAGE_KEY_SEED;
4
+ private readonly CHAIN_KEY_SEED;
5
+ private readonly iteration;
6
+ private readonly chainKey;
7
+ constructor(iteration: number, chainKey: any);
8
+ getIteration(): number;
9
+ getSenderMessageKey(): SenderMessageKey;
10
+ getNext(): SenderChainKey;
11
+ getSeed(): Uint8Array;
12
+ private getDerivative;
13
+ }
@@ -0,0 +1,16 @@
1
+ import { CiphertextMessage } from './ciphertext-message';
2
+ export declare class SenderKeyDistributionMessage extends CiphertextMessage {
3
+ private readonly id;
4
+ private readonly iteration;
5
+ private readonly chainKey;
6
+ private readonly signatureKey;
7
+ private readonly serialized;
8
+ constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
9
+ private intsToByteHighAndLow;
10
+ serialize(): Uint8Array;
11
+ getType(): number;
12
+ getIteration(): number;
13
+ getChainKey(): Uint8Array;
14
+ getSignatureKey(): Uint8Array;
15
+ getId(): number;
16
+ }
@@ -0,0 +1,18 @@
1
+ import { CiphertextMessage } from './ciphertext-message';
2
+ export declare class SenderKeyMessage extends CiphertextMessage {
3
+ private readonly SIGNATURE_LENGTH;
4
+ private readonly messageVersion;
5
+ private readonly keyId;
6
+ private readonly iteration;
7
+ private readonly ciphertext;
8
+ private readonly signature;
9
+ private readonly serialized;
10
+ constructor(keyId?: number | null, iteration?: number | null, ciphertext?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
11
+ getKeyId(): number;
12
+ getIteration(): number;
13
+ getCipherText(): Uint8Array;
14
+ verifySignature(signatureKey: Uint8Array): void;
15
+ private getSignature;
16
+ serialize(): Uint8Array;
17
+ getType(): number;
18
+ }
@@ -0,0 +1,17 @@
1
+ interface Sender {
2
+ id: string;
3
+ deviceId: number;
4
+ toString(): string;
5
+ }
6
+ export declare class SenderKeyName {
7
+ private readonly groupId;
8
+ private readonly sender;
9
+ constructor(groupId: string, sender: Sender);
10
+ getGroupId(): string;
11
+ getSender(): Sender;
12
+ serialize(): string;
13
+ toString(): string;
14
+ equals(other: SenderKeyName | null): boolean;
15
+ hashCode(): number;
16
+ }
17
+ export {};
@@ -0,0 +1,30 @@
1
+ import { SenderKeyState } from './sender-key-state';
2
+ export interface SenderKeyStateStructure {
3
+ senderKeyId: number;
4
+ senderChainKey: {
5
+ iteration: number;
6
+ seed: Uint8Array;
7
+ };
8
+ senderSigningKey: {
9
+ public: Uint8Array;
10
+ private?: Uint8Array;
11
+ };
12
+ senderMessageKeys: Array<{
13
+ iteration: number;
14
+ seed: Uint8Array;
15
+ }>;
16
+ }
17
+ export declare class SenderKeyRecord {
18
+ private readonly MAX_STATES;
19
+ private readonly senderKeyStates;
20
+ constructor(serialized?: SenderKeyStateStructure[]);
21
+ isEmpty(): boolean;
22
+ getSenderKeyState(keyId?: number): SenderKeyState | undefined;
23
+ addSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, signatureKey: Uint8Array): void;
24
+ setSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, keyPair: {
25
+ public: Uint8Array;
26
+ private: Uint8Array;
27
+ }): void;
28
+ serialize(): SenderKeyStateStructure[];
29
+ static deserialize(data: Uint8Array | string | SenderKeyStateStructure[]): SenderKeyRecord;
30
+ }
@@ -0,0 +1,38 @@
1
+ import { SenderChainKey } from './sender-chain-key';
2
+ import { SenderMessageKey } from './sender-message-key';
3
+ interface SenderChainKeyStructure {
4
+ iteration: number;
5
+ seed: Uint8Array;
6
+ }
7
+ interface SenderSigningKeyStructure {
8
+ public: Uint8Array;
9
+ private?: Uint8Array;
10
+ }
11
+ interface SenderMessageKeyStructure {
12
+ iteration: number;
13
+ seed: Uint8Array;
14
+ }
15
+ interface SenderKeyStateStructure {
16
+ senderKeyId: number;
17
+ senderChainKey: SenderChainKeyStructure;
18
+ senderSigningKey: SenderSigningKeyStructure;
19
+ senderMessageKeys: SenderMessageKeyStructure[];
20
+ }
21
+ export declare class SenderKeyState {
22
+ private readonly MAX_MESSAGE_KEYS;
23
+ private readonly senderKeyStateStructure;
24
+ constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKeyPair?: {
25
+ public: Uint8Array;
26
+ private: Uint8Array;
27
+ } | null, signatureKeyPublic?: Uint8Array | null, signatureKeyPrivate?: Uint8Array | null, senderKeyStateStructure?: SenderKeyStateStructure | null);
28
+ getKeyId(): number;
29
+ getSenderChainKey(): SenderChainKey;
30
+ setSenderChainKey(chainKey: SenderChainKey): void;
31
+ getSigningKeyPublic(): Buffer;
32
+ getSigningKeyPrivate(): Buffer | undefined;
33
+ hasSenderMessageKey(iteration: number): boolean;
34
+ addSenderMessageKey(senderMessageKey: SenderMessageKey): void;
35
+ removeSenderMessageKey(iteration: number): SenderMessageKey | null;
36
+ getStructure(): SenderKeyStateStructure;
37
+ }
38
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare class SenderMessageKey {
2
+ private readonly iteration;
3
+ private readonly iv;
4
+ private readonly cipherKey;
5
+ private readonly seed;
6
+ constructor(iteration: number, seed: Uint8Array);
7
+ getIteration(): number;
8
+ getIv(): Uint8Array;
9
+ getCipherKey(): Uint8Array;
10
+ getSeed(): Uint8Array;
11
+ }
@@ -0,0 +1,3 @@
1
+ import { SignalAuthState } from '../Types';
2
+ import { SignalRepository } from '../Types/Signal';
3
+ export declare function makeLibSignalRepository(auth: SignalAuthState): SignalRepository;
@@ -35,11 +35,11 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.makeLibSignalRepository = makeLibSignalRepository;
37
37
  const libsignal = __importStar(require("libsignal"));
38
- const Utils_1 = require("mod-baileys/lib/Utils");
39
- const WABinary_1 = require("mod-baileys/lib/WABinary");
40
- const sender_key_name_1 = require("mod-baileys/lib/Signal/Group/sender-key-name");
41
- const sender_key_record_1 = require("mod-baileys/lib/Signal/Group/sender-key-record");
42
- const Group_1 = require("mod-baileys/lib/Signal/Group");
38
+ const Utils_1 = require("../Utils");
39
+ const WABinary_1 = require("../WABinary");
40
+ const sender_key_name_1 = require("./Group/sender-key-name");
41
+ const sender_key_record_1 = require("./Group/sender-key-record");
42
+ const Group_1 = require("./Group");
43
43
  function makeLibSignalRepository(auth) {
44
44
  const storage = signalStorage(auth);
45
45
  return {
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { EventEmitter } from 'events';
4
+ import { URL } from 'url';
5
+ import { SocketConfig } from '../../Types';
6
+ export declare abstract class AbstractSocketClient extends EventEmitter {
7
+ url: URL;
8
+ config: SocketConfig;
9
+ abstract get isOpen(): boolean;
10
+ abstract get isClosed(): boolean;
11
+ abstract get isClosing(): boolean;
12
+ abstract get isConnecting(): boolean;
13
+ constructor(url: URL, config: SocketConfig);
14
+ abstract connect(): Promise<void>;
15
+ abstract close(): Promise<void>;
16
+ abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
17
+ }
@@ -0,0 +1,3 @@
1
+ export * from './abstract-socket-client';
2
+ export * from './mobile-socket-client';
3
+ export * from './web-socket-client';
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("mod-baileys/lib/Socket/Client/abstract-socket-client"), exports);
18
- __exportStar(require("mod-baileys/lib/Socket/Client/mobile-socket-client"), exports);
19
- __exportStar(require("mod-baileys/lib/Socket/Client/web-socket-client"), exports);
17
+ __exportStar(require("./abstract-socket-client"), exports);
18
+ __exportStar(require("./mobile-socket-client"), exports);
19
+ __exportStar(require("./web-socket-client"), exports);
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { Socket } from 'net';
3
+ import { AbstractSocketClient } from './abstract-socket-client';
4
+ export declare class MobileSocketClient extends AbstractSocketClient {
5
+ protected socket: Socket | null;
6
+ get isOpen(): boolean;
7
+ get isClosed(): boolean;
8
+ get isClosing(): boolean;
9
+ get isConnecting(): boolean;
10
+ connect(): Promise<void>;
11
+ close(): Promise<void>;
12
+ send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
13
+ }