@sixcore/baileys 1.0.1 → 1.1.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 (210) hide show
  1. package/LICENSE +21 -13
  2. package/WAProto/WAProto.proto +5311 -0
  3. package/WAProto/index.js +65813 -141372
  4. package/lib/Defaults/index.js +120 -133
  5. package/lib/KeyDB/BinarySearch.js +30 -0
  6. package/lib/KeyDB/KeyedDB.js +178 -0
  7. package/lib/KeyDB/index.js +14 -0
  8. package/lib/Signal/Group/ciphertext-message.js +22 -14
  9. package/lib/Signal/Group/group-session-builder.js +21 -42
  10. package/lib/Signal/Group/group_cipher.js +85 -87
  11. package/lib/Signal/Group/index.js +23 -57
  12. package/lib/Signal/Group/keyhelper.js +28 -52
  13. package/lib/Signal/Group/sender-chain-key.js +37 -33
  14. package/lib/Signal/Group/sender-key-distribution-message.js +73 -63
  15. package/lib/Signal/Group/sender-key-message.js +75 -66
  16. package/lib/Signal/Group/sender-key-name.js +55 -44
  17. package/lib/Signal/Group/sender-key-record.js +49 -49
  18. package/lib/Signal/Group/sender-key-state.js +90 -93
  19. package/lib/Signal/Group/sender-message-key.js +37 -28
  20. package/lib/Signal/libsignal.js +324 -163
  21. package/lib/Signal/lid-mapping.js +166 -0
  22. package/lib/Socket/Client/index.js +14 -19
  23. package/lib/Socket/Client/types.js +13 -0
  24. package/lib/Socket/Client/websocket.js +62 -0
  25. package/lib/Socket/business.js +359 -242
  26. package/lib/Socket/chats.js +850 -935
  27. package/lib/Socket/communities.js +413 -0
  28. package/lib/Socket/groups.js +304 -309
  29. package/lib/Socket/index.js +25 -10
  30. package/lib/Socket/messages-recv.js +1107 -1054
  31. package/lib/Socket/messages-send.js +639 -448
  32. package/lib/Socket/mex.js +45 -0
  33. package/lib/Socket/newsletter.js +226 -306
  34. package/lib/Socket/socket.js +803 -638
  35. package/lib/Store/index.js +18 -10
  36. package/lib/Store/make-cache-manager-store.js +73 -81
  37. package/lib/Store/make-in-memory-store.js +286 -423
  38. package/lib/Store/make-ordered-dictionary.js +77 -79
  39. package/lib/Store/object-repository.js +24 -26
  40. package/lib/Types/Auth.js +13 -2
  41. package/lib/Types/Bussines.js +13 -0
  42. package/lib/Types/Call.js +13 -2
  43. package/lib/Types/Chat.js +19 -4
  44. package/lib/Types/Contact.js +13 -2
  45. package/lib/Types/Events.js +13 -2
  46. package/lib/Types/GroupMetadata.js +13 -2
  47. package/lib/Types/Label.js +43 -26
  48. package/lib/Types/Label.js.bak +25 -0
  49. package/lib/Types/LabelAssociation.js +16 -8
  50. package/lib/Types/Message.js +22 -9
  51. package/lib/Types/Newsletter.js +42 -37
  52. package/lib/Types/Product.js +13 -2
  53. package/lib/Types/Signal.js +13 -2
  54. package/lib/Types/Socket.js +14 -2
  55. package/lib/Types/State.js +21 -2
  56. package/lib/Types/USync.js +13 -2
  57. package/lib/Types/index.js +37 -41
  58. package/lib/Utils/auth-utils.js +219 -196
  59. package/lib/Utils/baileys-event-stream.js +50 -59
  60. package/lib/Utils/browser-utils.js +25 -0
  61. package/lib/Utils/business.js +213 -214
  62. package/lib/Utils/chat-utils.js +710 -687
  63. package/lib/Utils/crypto.js +112 -133
  64. package/lib/Utils/decode-wa-message.js +252 -183
  65. package/lib/Utils/event-buffer.js +510 -496
  66. package/lib/Utils/generics.js +319 -387
  67. package/lib/Utils/history.js +83 -92
  68. package/lib/Utils/index.js +31 -33
  69. package/lib/Utils/link-preview.js +71 -83
  70. package/lib/Utils/logger.js +5 -7
  71. package/lib/Utils/lt-hash.js +40 -46
  72. package/lib/Utils/make-mutex.js +34 -41
  73. package/lib/Utils/message-retry-manager.js +113 -0
  74. package/lib/Utils/messages-media.js +553 -768
  75. package/lib/Utils/messages-media.js.bak2 +602 -0
  76. package/lib/Utils/messages.js +354 -263
  77. package/lib/Utils/noise-handler.js +138 -149
  78. package/lib/Utils/pre-key-manager.js +95 -0
  79. package/lib/Utils/process-message.js +333 -303
  80. package/lib/Utils/signal.js +159 -141
  81. package/lib/Utils/use-multi-file-auth-state.js +105 -103
  82. package/lib/Utils/validate-connection.js +184 -203
  83. package/lib/WABinary/constants.js +1308 -35
  84. package/lib/WABinary/decode.js +247 -249
  85. package/lib/WABinary/encode.js +221 -258
  86. package/lib/WABinary/generic-utils.js +68 -65
  87. package/lib/WABinary/index.js +17 -21
  88. package/lib/WABinary/jid-utils.js +99 -58
  89. package/lib/WABinary/types.js +13 -2
  90. package/lib/WAM/BinaryInfo.js +20 -12
  91. package/lib/WAM/constants.js +22863 -15348
  92. package/lib/WAM/encode.js +145 -136
  93. package/lib/WAM/index.js +15 -19
  94. package/lib/WAUSync/Protocols/USyncContactProtocol.js +39 -31
  95. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +61 -54
  96. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +39 -29
  97. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +48 -40
  98. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -51
  99. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +38 -21
  100. package/lib/WAUSync/Protocols/index.js +17 -20
  101. package/lib/WAUSync/USyncQuery.js +98 -86
  102. package/lib/WAUSync/USyncUser.js +35 -26
  103. package/lib/WAUSync/index.js +16 -19
  104. package/lib/index.js +26 -94
  105. package/lib/index.js.bak +23 -0
  106. package/package.json +97 -113
  107. package/jessica.js +0 -91
  108. package/lib/Defaults/baileys-version.json +0 -3
  109. package/lib/Defaults/index.d.ts +0 -53
  110. package/lib/Defaults/phonenumber-mcc.json +0 -223
  111. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  112. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  113. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  114. package/lib/Signal/Group/index.d.ts +0 -11
  115. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  116. package/lib/Signal/Group/queue-job.d.ts +0 -1
  117. package/lib/Signal/Group/queue-job.js +0 -57
  118. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  119. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  120. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  121. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  122. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  123. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  124. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  125. package/lib/Signal/libsignal.d.ts +0 -3
  126. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  127. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  128. package/lib/Socket/Client/index.d.ts +0 -3
  129. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  130. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  131. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  132. package/lib/Socket/Client/web-socket-client.js +0 -62
  133. package/lib/Socket/business.d.ts +0 -171
  134. package/lib/Socket/chats.d.ts +0 -267
  135. package/lib/Socket/dugong.d.ts +0 -254
  136. package/lib/Socket/dugong.js +0 -484
  137. package/lib/Socket/groups.d.ts +0 -115
  138. package/lib/Socket/index.d.ts +0 -173
  139. package/lib/Socket/messages-recv.d.ts +0 -161
  140. package/lib/Socket/messages-send.d.ts +0 -149
  141. package/lib/Socket/newsletter.d.ts +0 -134
  142. package/lib/Socket/registration.d.ts +0 -267
  143. package/lib/Socket/registration.js +0 -166
  144. package/lib/Socket/socket.d.ts +0 -43
  145. package/lib/Socket/usync.d.ts +0 -36
  146. package/lib/Socket/usync.js +0 -70
  147. package/lib/Store/index.d.ts +0 -3
  148. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  149. package/lib/Store/make-in-memory-store.d.ts +0 -118
  150. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  151. package/lib/Store/object-repository.d.ts +0 -10
  152. package/lib/Types/Auth.d.ts +0 -110
  153. package/lib/Types/Call.d.ts +0 -13
  154. package/lib/Types/Chat.d.ts +0 -102
  155. package/lib/Types/Contact.d.ts +0 -19
  156. package/lib/Types/Events.d.ts +0 -157
  157. package/lib/Types/GroupMetadata.d.ts +0 -55
  158. package/lib/Types/Label.d.ts +0 -35
  159. package/lib/Types/LabelAssociation.d.ts +0 -29
  160. package/lib/Types/Message.d.ts +0 -273
  161. package/lib/Types/Newsletter.d.ts +0 -103
  162. package/lib/Types/Product.d.ts +0 -78
  163. package/lib/Types/Signal.d.ts +0 -57
  164. package/lib/Types/Socket.d.ts +0 -111
  165. package/lib/Types/State.d.ts +0 -27
  166. package/lib/Types/USync.d.ts +0 -25
  167. package/lib/Types/index.d.ts +0 -57
  168. package/lib/Utils/auth-utils.d.ts +0 -18
  169. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  170. package/lib/Utils/business.d.ts +0 -22
  171. package/lib/Utils/chat-utils.d.ts +0 -71
  172. package/lib/Utils/crypto.d.ts +0 -41
  173. package/lib/Utils/decode-wa-message.d.ts +0 -19
  174. package/lib/Utils/event-buffer.d.ts +0 -35
  175. package/lib/Utils/generics.d.ts +0 -92
  176. package/lib/Utils/history.d.ts +0 -15
  177. package/lib/Utils/index.d.ts +0 -17
  178. package/lib/Utils/link-preview.d.ts +0 -21
  179. package/lib/Utils/logger.d.ts +0 -4
  180. package/lib/Utils/lt-hash.d.ts +0 -12
  181. package/lib/Utils/make-mutex.d.ts +0 -7
  182. package/lib/Utils/messages-media.d.ts +0 -116
  183. package/lib/Utils/messages.d.ts +0 -77
  184. package/lib/Utils/noise-handler.d.ts +0 -21
  185. package/lib/Utils/process-message.d.ts +0 -41
  186. package/lib/Utils/signal.d.ts +0 -32
  187. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  188. package/lib/Utils/validate-connection.d.ts +0 -11
  189. package/lib/WABinary/constants.d.ts +0 -30
  190. package/lib/WABinary/decode.d.ts +0 -7
  191. package/lib/WABinary/encode.d.ts +0 -3
  192. package/lib/WABinary/generic-utils.d.ts +0 -17
  193. package/lib/WABinary/index.d.ts +0 -5
  194. package/lib/WABinary/jid-utils.d.ts +0 -31
  195. package/lib/WABinary/types.d.ts +0 -18
  196. package/lib/WAM/BinaryInfo.d.ts +0 -17
  197. package/lib/WAM/constants.d.ts +0 -38
  198. package/lib/WAM/encode.d.ts +0 -3
  199. package/lib/WAM/index.d.ts +0 -3
  200. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  201. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  202. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  203. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  204. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  205. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  206. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  207. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  208. package/lib/WAUSync/USyncUser.d.ts +0 -12
  209. package/lib/WAUSync/index.d.ts +0 -3
  210. package/lib/index.d.ts +0 -12
@@ -1,146 +1,133 @@
1
- var __importDefault = this && this.__importDefault || function (a) {
2
- return a && a.__esModule ? a : { "default": a }
3
- };
4
-
5
- Object.defineProperty(exports, "__esModule", { value: !0 });
6
-
7
- exports.DEFAULT_CACHE_TTLS =
8
- exports.INITIAL_PREKEY_COUNT =
9
- exports.MIN_PREKEY_COUNT =
10
- exports.MEDIA_KEYS =
11
- exports.MEDIA_HKDF_KEY_MAPPING =
12
- exports.MEDIA_PATH_MAP =
13
- exports.DEFAULT_CONNECTION_CONFIG =
14
- exports.PROCESSABLE_HISTORY_TYPES =
15
- exports.WA_CERT_DETAILS =
16
- exports.URL_REGEX =
17
- exports.NOISE_WA_HEADER =
18
- exports.KEY_BUNDLE_TYPE =
19
- exports.DICT_VERSION =
20
- exports.NOISE_MODE =
21
- exports.WA_DEFAULT_EPHEMERAL =
22
- exports.PHONE_CONNECTION_CB =
23
- exports.DEF_TAG_PREFIX =
24
- exports.DEF_CALLBACK_PREFIX =
25
- exports.DEFAULT_ORIGIN =
26
- exports.UNAUTHORIZED_CODES =
27
- void 0;
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+
14
+ import { makeLibSignalRepository } from "../Signal/libsignal.js";
15
+ import { Browsers } from "../Utils/browser-utils.js";
16
+ import { proto } from "../../WAProto/index.js";
17
+ import logger from "../Utils/logger.js";
28
18
 
29
- const crypto_1 = require("crypto");
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"));
19
+ export const version = [2, 3000, 1029030078]
20
+ export const DICT_VERSION = 3;
21
+ export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
22
+ export const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
23
+ export const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
24
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
25
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
26
+ export const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
27
+ export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
28
+ export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
29
+ export const DEFAULT_ORIGIN = "https://web.whatsapp.com";
30
+ export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
31
+ export const UNAUTHORIZED_CODES = [401, 403, 419];
32
+ export const KEY_BUNDLE_TYPE = Buffer.from([5]);
33
+ export const PHONE_CONNECTION_CB = "CB:Pong";
34
+ export const DEF_CALLBACK_PREFIX = "CB:";
35
+ export const DEF_TAG_PREFIX = "TAG:";
36
36
 
37
- exports.UNAUTHORIZED_CODES = [401, 403, 419];
38
- exports.version = [2, 3000, 1027934701];
39
- exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
40
- exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
41
- exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
42
- exports.MOBILE_PORT = 443;
43
- exports.DEF_CALLBACK_PREFIX = "CB:";
44
- exports.DEF_TAG_PREFIX = "TAG:";
45
- exports.PHONE_CONNECTION_CB = "CB:Pong";
46
- exports.WA_DEFAULT_EPHEMERAL = 604800;
47
- const WA_VERSION = '2.25.23.24';
48
- const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
49
- exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
50
- exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
51
- exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
52
- exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
53
- 8, 20, 20, 16, 19, 0, 23, 8, 1, 20, 19, 1, 16, 16, 0, 3, 15, 13, 0, 3, 8, 1, 14, 14, 5, 12, 0, 22, 1, 2, 15, 12, 19, 22, 0, 20, 5, 10, 12, 14, 20, 20, 5, 0, 4,
54
- ]);
55
- exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
56
- exports.DICT_VERSION = 2;
57
- exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
58
- exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
59
- exports.PROTOCOL_VERSION = [5, 2];
60
- exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
37
+ export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
61
38
 
62
- exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
63
- exports.WA_CERT_DETAILS = { SERIAL: 0 };
39
+ export const WA_CERT_DETAILS = {
40
+ SERIAL: 0
41
+ };
64
42
 
65
- exports.PROCESSABLE_HISTORY_TYPES = [
66
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
67
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
68
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
69
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
70
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND
43
+ export const PROCESSABLE_HISTORY_TYPES = [
44
+ proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
45
+ proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
46
+ proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
47
+ proto.Message.HistorySyncNotification.HistorySyncType.FULL,
48
+ proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
49
+ proto.Message.HistorySyncNotification.HistorySyncType.NON_BLOCKING_DATA,
50
+ proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_STATUS_V3
71
51
  ];
72
52
 
73
- exports.DEFAULT_CONNECTION_CONFIG = {
74
- version: baileys_version_json_1.version,
75
- browser: Utils_1.Browsers("Chrome"),
76
- waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
77
- connectTimeoutMs: 2E4,
78
- keepAliveIntervalMs: 3E4,
79
- logger: logger_1.default.child({ class: "baileys" }),
80
- printQRInTerminal: !1,
81
- emitOwnEvents: !0,
82
- defaultQueryTimeoutMs: 6E4,
83
- customUploadHosts: [],
84
- retryRequestDelayMs: 250,
85
- maxMsgRetryCount: 5,
86
- fireInitQueries: !0,
87
- auth: void 0,
88
- markOnlineOnConnect: !0,
89
- syncFullHistory: !1,
90
- patchMessageBeforeSending: a => a,
91
- shouldSyncHistoryMessage: () => !0,
92
- shouldIgnoreJid: () => !1,
93
- linkPreviewImageThumbnailWidth: 192,
94
- transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3E3 },
95
- generateHighQualityLinkPreview: !1,
96
- options: {},
97
- appStateMacVerification: { patch: !1, snapshot: !1 },
98
- countryCode: "US",
99
- getMessage: async () => { },
100
- cachedGroupMetadata: async () => { },
101
- makeSignalRepository: libsignal_1.makeLibSignalRepository
53
+ export const DEFAULT_CONNECTION_CONFIG = {
54
+ "version": version,
55
+ "browser": Browsers.iOS("Safari"),
56
+ "waWebSocketUrl": "wss://web.whatsapp.com/ws/chat",
57
+ "connectTimeoutMs": 20000,
58
+ "keepAliveIntervalMs": 30000,
59
+ "logger": logger.child({ "class": "baileys" }),
60
+ "emitOwnEvents": true,
61
+ "defaultQueryTimeoutMs": 60000,
62
+ "customUploadHosts": [],
63
+ "retryRequestDelayMs": 250,
64
+ "maxMsgRetryCount": 5,
65
+ "fireInitQueries": true,
66
+ "auth": undefined,
67
+ "markOnlineOnConnect": true,
68
+ "syncFullHistory": true,
69
+ "patchMessageBeforeSending": msg => msg,
70
+ "shouldSyncHistoryMessage": () => true,
71
+ "shouldIgnoreJid": () => false,
72
+ "linkPreviewImageThumbnailWidth": 192,
73
+ "transactionOpts": { "maxCommitRetries": 10, "delayBetweenTriesMs": 3000 },
74
+ "generateHighQualityLinkPreview": false,
75
+ "enableAutoSessionRecreation": true,
76
+ "enableRecentMessageCache": true,
77
+ "options": {},
78
+ "appStateMacVerification": {
79
+ "patch": false,
80
+ "snapshot": false
81
+ },
82
+ "countryCode": "US",
83
+ "getMessage": async () => undefined,
84
+ "cachedGroupMetadata": async () => undefined,
85
+ "makeSignalRepository": makeLibSignalRepository
102
86
  };
103
87
 
104
- exports.MEDIA_PATH_MAP = {
105
- image: "/mms/image",
106
- video: "/mms/video",
107
- document: "/mms/document",
108
- audio: "/mms/audio",
109
- sticker: "/mms/image",
110
- "thumbnail-link": "/mms/image",
111
- "product-catalog-image": "/product/image",
112
- "md-app-state": "",
113
- "md-msg-hist": "/mms/md-app-state"
88
+ export const MEDIA_PATH_MAP = {
89
+ "image": "/mms/image",
90
+ "video": "/mms/video",
91
+ "document": "/mms/document",
92
+ "audio": "/mms/audio",
93
+ "sticker": "/mms/image",
94
+ "thumbnail-link": "/mms/image",
95
+ "product-catalog-image": "/product/image",
96
+ "md-app-state": "",
97
+ "md-msg-hist": "/mms/md-app-state",
98
+ "biz-cover-photo": "/pps/biz-cover-photo"
114
99
  };
115
100
 
116
- exports.MEDIA_HKDF_KEY_MAPPING = {
117
- audio: "Audio",
118
- document: "Document",
119
- gif: "Video",
120
- image: "Image",
121
- ppic: "",
122
- product: "Image",
123
- ptt: "Audio",
124
- sticker: "Image",
125
- video: "Video",
126
- "thumbnail-document": "Document Thumbnail",
127
- "thumbnail-image": "Image Thumbnail",
128
- "thumbnail-video": "Video Thumbnail",
129
- "thumbnail-link": "Link Thumbnail",
130
- "md-msg-hist": "History",
131
- "md-app-state": "App State",
132
- "product-catalog-image": "",
133
- "payment-bg-image": "Payment Background",
134
- ptv: "Video"
101
+ export const MEDIA_HKDF_KEY_MAPPING = {
102
+ "audio": "Audio",
103
+ "document": "Document",
104
+ "gif": "Video",
105
+ "image": "Image",
106
+ "ppic": "",
107
+ "product": "Image",
108
+ "ptt": "Audio",
109
+ "sticker": "Image",
110
+ "video": "Video",
111
+ "thumbnail-document": "Document Thumbnail",
112
+ "thumbnail-image": "Image Thumbnail",
113
+ "thumbnail-video": "Video Thumbnail",
114
+ "thumbnail-link": "Link Thumbnail",
115
+ "md-msg-hist": "History",
116
+ "md-app-state": "App State",
117
+ "product-catalog-image": "",
118
+ "payment-bg-image": "Payment Background",
119
+ "ptv": "Video",
120
+ "biz-cover-photo": "Image"
135
121
  };
136
122
 
137
- exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
138
- exports.MIN_PREKEY_COUNT = 5;
139
- exports.INITIAL_PREKEY_COUNT = 30;
140
-
141
- exports.DEFAULT_CACHE_TTLS = {
142
- SIGNAL_STORE: 300,
143
- MSG_RETRY: 3600,
144
- CALL_OFFER: 300,
145
- USER_DEVICES: 300
123
+ export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
124
+ export const MIN_PREKEY_COUNT = 5;
125
+ export const INITIAL_PREKEY_COUNT = 812;
126
+ export const UPLOAD_TIMEOUT = 30000;
127
+ export const MIN_UPLOAD_INTERVAL = 5000;
128
+ export const DEFAULT_CACHE_TTLS = {
129
+ SIGNAL_STORE: 5 * 60,
130
+ MSG_RETRY: 60 * 60,
131
+ CALL_OFFER: 5 * 60,
132
+ USER_DEVICES: 5 * 60
146
133
  };
@@ -0,0 +1,30 @@
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+
14
+ export default function binarySearch(array, predicate) {
15
+ let low = 0
16
+ let high = array.length
17
+
18
+ if (high === 0) return -1
19
+
20
+ while (low < high) {
21
+ const Mafilzin = (low + high) >> 1
22
+ const ninja = predicate(array[Mafilzin])
23
+
24
+ if (ninja === 0) return Mafilzin
25
+ if (ninja < 0) high = Mafilzin
26
+ else low = Mafilzin + 1
27
+ }
28
+
29
+ return -1
30
+ }
@@ -0,0 +1,178 @@
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+
14
+ import binarySearch from "./BinarySearch.js";
15
+
16
+ export default class KeyedDB {
17
+ constructor(key, id) {
18
+ this.key = key;
19
+ this.idGetter = id || (v => this.key.key(v).toString());
20
+ this.dict = {};
21
+ this.array = [];
22
+ }
23
+ get length() {
24
+ return this.array.length;
25
+ }
26
+ get first() {
27
+ return this.array[0];
28
+ }
29
+ get last() {
30
+ return this.array[this.array.length - 1];
31
+ }
32
+ toJSON() {
33
+ return this.array;
34
+ }
35
+ insert(...values) {
36
+ values.forEach(v => this._insertSingle(v));
37
+ }
38
+ upsert(...values) {
39
+ const updates = [];
40
+ values.forEach(v => {
41
+ if (!v) return;
42
+ const deleted = this.deleteById(this.idGetter(v), false);
43
+ this._insertSingle(v);
44
+ deleted && updates.push(v);
45
+ });
46
+ return updates;
47
+ }
48
+ insertIfAbsent(...values) {
49
+ const insertions = [];
50
+ values.forEach(v => {
51
+ if (!v) return;
52
+ const presentValue = this.get(this.idGetter(v));
53
+ if (presentValue) return;
54
+ const presentKey = this.firstIndex(v);
55
+ if (this.array[presentKey] && this.key.key(this.array[presentKey]) === this.key.key(v)) return;
56
+ this.insert(v);
57
+ insertions.push(v);
58
+ });
59
+ return insertions;
60
+ }
61
+ deleteById(id, assertPresent = true) {
62
+ const value = this.get(id);
63
+ if (!value) {
64
+ if (assertPresent) throw new Error(`Value not found`);
65
+ return;
66
+ }
67
+ return this.delete(value);
68
+ }
69
+ delete(value) {
70
+ const index = this.firstIndex(value);
71
+ if (index < 0 || index >= this.array.length || this.key.key(value) !== this.key.key(this.array[index])) {
72
+ return null;
73
+ }
74
+ delete this.dict[this.idGetter(value)];
75
+ return this.array.splice(index, 1)[0];
76
+ }
77
+ slice(start, end) {
78
+ const db = new KeyedDB(this.key, this.idGetter);
79
+ db.array = this.array.slice(start, end);
80
+ db.array.forEach(item => db.dict[this.idGetter(item)] = item);
81
+ return db;
82
+ }
83
+ clear() {
84
+ this.array = [];
85
+ this.dict = {};
86
+ }
87
+ get(id) {
88
+ return this.dict[id];
89
+ }
90
+ all() {
91
+ return this.array;
92
+ }
93
+ update(id, update) {
94
+ const value = this.get(id);
95
+ if (value) {
96
+ const idx = this.firstIndex(value);
97
+ if (idx >= 0 && idx < this.array.length && this.idGetter(this.array[idx]) === id) {
98
+ const oldKey = this.key.key(value);
99
+ update(value);
100
+ const newKey = this.key.key(value);
101
+ if (newKey !== oldKey) {
102
+ delete this.dict[id];
103
+ this.array.splice(idx, 1);
104
+ this._insertSingle(value);
105
+ return 2;
106
+ }
107
+ return 1;
108
+ }
109
+ }
110
+ }
111
+ updateKey(value, update) {
112
+ return this.update(this.idGetter(value), update);
113
+ }
114
+ filter(predicate) {
115
+ const db = new KeyedDB(this.key, this.idGetter);
116
+ db.array = this.array.filter((value, index) => {
117
+ if (predicate(value, index)) {
118
+ db.dict[this.idGetter(value)] = value;
119
+ return true;
120
+ }
121
+ });
122
+ return db;
123
+ }
124
+ paginatedByValue(value, limit, predicate, mode = "after") {
125
+ return this.paginated(value && this.key.key(value), limit, predicate, mode);
126
+ }
127
+ paginated(cursor, limit, predicate, mode = "after") {
128
+ let index = mode === "after" ? 0 : this.array.length;
129
+ if (cursor !== null && typeof cursor !== "undefined") {
130
+ index = binarySearch(this.array, v => this.key.compare(cursor, this.key.key(v)));
131
+ if (index < 0) index = 0;
132
+ if (this.key.key(this.array[index]) === cursor) index += (mode === "after" ? 1 : 0);
133
+ }
134
+ return this.filtered(index, limit, mode, predicate);
135
+ }
136
+ _insertSingle(value) {
137
+ if (!value) throw new Error("falsey value");
138
+ const valueID = this.idGetter(value);
139
+ if (this.get(valueID)) throw new Error("duplicate ID being inserted: " + valueID);
140
+
141
+ if (this.array.length > 0) {
142
+ const index = this.firstIndex(value);
143
+ if (index >= this.array.length) this.array.push(value);
144
+ else if (index < 0) this.array.unshift(value);
145
+ else if (this.key.key(value) !== this.key.key(this.array[index])) this.array.splice(index, 0, value);
146
+ else throw new Error(`duplicate key: ${this.key.key(value)}, inserting: ${valueID}, present: ${this.idGetter(this.array[index])}`);
147
+ } else {
148
+ this.array.push(value);
149
+ }
150
+ this.dict[valueID] = value;
151
+ }
152
+ filtered(start, count, mode, predicate) {
153
+ let arr;
154
+ if (mode === "after") {
155
+ if (predicate) {
156
+ arr = [];
157
+ for (let item of this.array.slice(start)) {
158
+ predicate(item, start + arr.length) && arr.push(item);
159
+ if (arr.length >= count) break;
160
+ }
161
+ } else arr = this.array.slice(start, start + count);
162
+ } else if (mode === "before") {
163
+ if (predicate) {
164
+ arr = [];
165
+ for (let i = start - 1; i >= 0; i--) {
166
+ let item = this.array[i];
167
+ predicate(item, start + arr.length) && arr.unshift(item);
168
+ if (arr.length >= count) break;
169
+ }
170
+ } else arr = this.array.slice(Math.max(start - count, 0), start);
171
+ }
172
+ return arr;
173
+ }
174
+ firstIndex(value) {
175
+ const valueKey = this.key.key(value);
176
+ return binarySearch(this.array, v => this.key.compare(valueKey, this.key.key(v)));
177
+ }
178
+ }
@@ -0,0 +1,14 @@
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+ export * from "./BinarySearch.js"
14
+ export * from "./KeyedDB.js"
@@ -1,15 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CiphertextMessage = void 0;
4
- class CiphertextMessage {
5
- constructor() {
6
- this.UNSUPPORTED_VERSION = 1;
7
- this.CURRENT_VERSION = 3;
8
- this.WHISPER_TYPE = 2;
9
- this.PREKEY_TYPE = 3;
10
- this.SENDERKEY_TYPE = 4;
11
- this.SENDERKEY_DISTRIBUTION_TYPE = 5;
12
- this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
13
- }
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+ export class CiphertextMessage {
14
+ constructor() {
15
+ this.UNSUPPORTED_VERSION = 1;
16
+ this.CURRENT_VERSION = 3;
17
+ this.WHISPER_TYPE = 2;
18
+ this.PREKEY_TYPE = 3;
19
+ this.SENDERKEY_TYPE = 4;
20
+ this.SENDERKEY_DISTRIBUTION_TYPE = 5;
21
+ this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
22
+ }
14
23
  }
15
- exports.CiphertextMessage = CiphertextMessage;
@@ -1,42 +1,21 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.GroupSessionBuilder = void 0;
37
- const keyhelper = __importStar(require("./keyhelper"));
38
- const sender_key_distribution_message_1 = require("./sender-key-distribution-message");
39
- class GroupSessionBuilder {
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+ import { SenderKeyDistributionMessage } from "./sender-key-distribution-message.js";
14
+ import { SenderKeyRecord } from "./sender-key-record.js";
15
+ import { SenderKeyName } from "./sender-key-name.js";
16
+ import * as keyhelper from "./keyhelper.js";
17
+
18
+ export class GroupSessionBuilder {
40
19
  constructor(senderKeyStore) {
41
20
  this.senderKeyStore = senderKeyStore;
42
21
  }
@@ -56,9 +35,9 @@ class GroupSessionBuilder {
56
35
  }
57
36
  const state = senderKeyRecord.getSenderKeyState();
58
37
  if (!state) {
59
- throw new Error('No session state available');
38
+ throw new Error("No session state available");
60
39
  }
61
- return new sender_key_distribution_message_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
40
+ return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
62
41
  }
63
42
  }
64
- exports.GroupSessionBuilder = GroupSessionBuilder;
43
+ //# sourceMappingURL=group-session-builder.js.map