@baileys-md/baileys 12.0.0 → 12.2.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 (109) hide show
  1. package/LICENSE +21 -13
  2. package/WAProto/WAProto.proto +769 -233
  3. package/WAProto/index.js +65813 -141372
  4. package/lib/Defaults/index.js +128 -113
  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 -18
  23. package/lib/Socket/Client/types.js +12 -12
  24. package/lib/Socket/Client/websocket.js +60 -109
  25. package/lib/Socket/business.js +359 -242
  26. package/lib/Socket/chats.js +857 -898
  27. package/lib/Socket/communities.js +413 -0
  28. package/lib/Socket/groups.js +304 -324
  29. package/lib/Socket/index.js +25 -9
  30. package/lib/Socket/messages-recv.js +1109 -1000
  31. package/lib/Socket/messages-send.js +615 -387
  32. package/lib/Socket/mex.js +45 -0
  33. package/lib/Socket/newsletter.js +231 -227
  34. package/lib/Socket/socket.js +803 -628
  35. package/lib/Store/index.js +18 -8
  36. package/lib/Store/make-cache-manager-store.js +75 -0
  37. package/lib/Store/make-in-memory-store.js +286 -435
  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/LabelAssociation.js +16 -8
  49. package/lib/Types/Message.js +22 -7
  50. package/lib/Types/Newsletter.js +42 -17
  51. package/lib/Types/Product.js +13 -2
  52. package/lib/Types/Signal.js +13 -2
  53. package/lib/Types/Socket.js +14 -2
  54. package/lib/Types/State.js +21 -2
  55. package/lib/Types/USync.js +13 -2
  56. package/lib/Types/index.js +37 -41
  57. package/lib/Utils/auth-utils.js +219 -189
  58. package/lib/Utils/baileys-event-stream.js +54 -0
  59. package/lib/Utils/browser-utils.js +21 -31
  60. package/lib/Utils/business.js +213 -214
  61. package/lib/Utils/chat-utils.js +711 -689
  62. package/lib/Utils/crypto.js +112 -175
  63. package/lib/Utils/decode-wa-message.js +254 -194
  64. package/lib/Utils/event-buffer.js +510 -500
  65. package/lib/Utils/generics.js +318 -430
  66. package/lib/Utils/history.js +83 -90
  67. package/lib/Utils/index.js +31 -35
  68. package/lib/Utils/link-preview.js +71 -116
  69. package/lib/Utils/logger.js +5 -7
  70. package/lib/Utils/lt-hash.js +40 -46
  71. package/lib/Utils/make-mutex.js +34 -41
  72. package/lib/Utils/message-retry-manager.js +33 -48
  73. package/lib/Utils/messages-media.js +516 -784
  74. package/lib/Utils/messages.js +347 -489
  75. package/lib/Utils/noise-handler.js +138 -144
  76. package/lib/Utils/pre-key-manager.js +95 -0
  77. package/lib/Utils/process-message.js +331 -384
  78. package/lib/Utils/signal.js +157 -139
  79. package/lib/Utils/use-multi-file-auth-state.js +119 -91
  80. package/lib/Utils/validate-connection.js +184 -203
  81. package/lib/WABinary/constants.js +1308 -1298
  82. package/lib/WABinary/decode.js +241 -256
  83. package/lib/WABinary/encode.js +217 -239
  84. package/lib/WABinary/generic-utils.js +131 -40
  85. package/lib/WABinary/index.js +17 -21
  86. package/lib/WABinary/jid-utils.js +97 -79
  87. package/lib/WABinary/types.js +13 -2
  88. package/lib/WAM/BinaryInfo.js +20 -12
  89. package/lib/WAM/constants.js +22863 -15348
  90. package/lib/WAM/encode.js +145 -136
  91. package/lib/WAM/index.js +15 -19
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +39 -31
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +61 -54
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +39 -29
  95. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +48 -40
  96. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -51
  97. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +38 -21
  98. package/lib/WAUSync/Protocols/index.js +17 -20
  99. package/lib/WAUSync/USyncQuery.js +98 -86
  100. package/lib/WAUSync/USyncUser.js +35 -26
  101. package/lib/WAUSync/index.js +16 -19
  102. package/lib/index.js +23 -41
  103. package/package.json +46 -56
  104. package/README.md +0 -113
  105. package/WAProto/GenerateStatics.sh +0 -4
  106. package/lib/Defaults/wileys-version.json +0 -3
  107. package/lib/Signal/Group/queue-job.js +0 -57
  108. package/lib/Socket/usync.js +0 -70
  109. package/lib/Utils/wileys-event-stream.js +0 -63
@@ -1,18 +1,14 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./websocket"), exports);
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 "./websocket.js";
14
+ export * from "./types.js";
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractSocketClient = void 0;
4
- const events_1 = require("events");
5
- class AbstractSocketClient extends events_1.EventEmitter {
6
- constructor(url, config) {
7
- super();
8
- this.url = url;
9
- this.config = config;
10
- this.setMaxListeners(0);
11
- }
1
+ //=======================================================//
2
+ import { EventEmitter } from "events";
3
+ import { URL } from "url";
4
+ //=======================================================//
5
+ export class AbstractSocketClient extends EventEmitter {
6
+ constructor(url, config) {
7
+ super();
8
+ this.url = url;
9
+ this.config = config;
10
+ this.setMaxListeners(0);
11
+ }
12
12
  }
13
- exports.AbstractSocketClient = AbstractSocketClient;
13
+ //=======================================================//
@@ -1,111 +1,62 @@
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.WebSocketClient = void 0;
7
- const ws_1 = __importDefault(require("ws"));
8
- const Defaults_1 = require("../../Defaults");
9
- const types_1 = require("./types");
10
- class WebSocketClient extends types_1.AbstractSocketClient {
11
- constructor() {
12
- super(...arguments);
13
- this.socket = null;
14
- // queue & dispatch variables for throttling outgoing messages to avoid rate limits
15
- this._queue = [];
16
- this._isDispatching = false;
17
- this._lastDispatch = 0;
18
- this._minSendIntervalMs = (Defaults_1.DEFAULT_CONNECTION_CONFIG && Defaults_1.DEFAULT_CONNECTION_CONFIG.minSendIntervalMs) || 50;
19
- }
20
- get isOpen() {
21
- var _a;
22
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN;
23
- }
24
- get isClosed() {
25
- var _a;
26
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSED;
27
- }
28
- get isClosing() {
29
- var _a;
30
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
31
- }
32
- get isConnecting() {
33
- var _a;
34
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CONNECTING;
35
- }
36
- async connect() {
37
- var _a, _b;
38
- if (this.socket) {
39
- return;
40
- }
41
- this.socket = new ws_1.default(this.url, {
42
- origin: Defaults_1.DEFAULT_ORIGIN,
43
- headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
44
- handshakeTimeout: this.config.connectTimeoutMs,
45
- timeout: this.config.connectTimeoutMs,
46
- agent: this.config.agent,
47
- });
48
- this.socket.setMaxListeners(0);
49
- const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
50
- for (const event of events) {
51
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.on(event, (...args) => this.emit(event, ...args));
52
- }
53
- }
54
- async close() {
55
- if (!this.socket) {
56
- return;
57
- }
58
- this.socket.close();
59
- this.socket = null;
60
- }
61
- async restart() {
62
- if (this.socket) {
63
- await new Promise(resolve => {
64
- this.socket.once('close', resolve);
65
- this.socket.terminate();
66
- });
67
- this.socket = null;
68
- }
69
- await this.connect();
70
- }
71
- send(str, cb) {
72
- // throttle sends to reduce rate-limit likelihood
73
- const doSend = () => {
74
- var _a;
75
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
76
- return Boolean(this.socket);
77
- };
78
- this._queue.push(doSend);
79
- this._dispatch();
80
- return true;
81
- }
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 { DEFAULT_ORIGIN } from "../../Defaults/index.js";
14
+ import { AbstractSocketClient } from "./types.js";
15
+ import WebSocket from "ws";
82
16
 
83
- _dispatch() {
84
- if (this._isDispatching) {
85
- return;
86
- }
87
- this._isDispatching = true;
88
- const tick = () => {
89
- const now = Date.now();
90
- if (this._queue.length === 0) {
91
- this._isDispatching = false;
92
- return;
93
- }
94
- const delta = now - this._lastDispatch;
95
- const wait = Math.max(0, this._minSendIntervalMs - delta);
96
- setTimeout(() => {
97
- const fn = this._queue.shift();
98
- this._lastDispatch = Date.now();
99
- try {
100
- fn && fn();
101
- }
102
- catch (_err) {
103
- // ignore send errors here; they'll surface elsewhere
104
- }
105
- tick();
106
- }, wait);
107
- };
108
- tick();
109
- }
17
+ export class WebSocketClient extends AbstractSocketClient {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.socket = null;
21
+ }
22
+ get isOpen() {
23
+ return this.socket?.readyState === WebSocket.OPEN;
24
+ }
25
+ get isClosed() {
26
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSED;
27
+ }
28
+ get isClosing() {
29
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSING;
30
+ }
31
+ get isConnecting() {
32
+ return this.socket?.readyState === WebSocket.CONNECTING;
33
+ }
34
+ async connect() {
35
+ if (this.socket) {
36
+ return;
37
+ }
38
+ this.socket = new WebSocket(this.url, {
39
+ origin: DEFAULT_ORIGIN,
40
+ headers: this.config.options?.headers,
41
+ handshakeTimeout: this.config.connectTimeoutMs,
42
+ timeout: this.config.connectTimeoutMs,
43
+ agent: this.config.agent
44
+ });
45
+ this.socket.setMaxListeners(0);
46
+ const events = ["close", "error", "upgrade", "message", "open", "ping", "pong", "unexpected-response"];
47
+ for (const event of events) {
48
+ this.socket?.on(event, (...args) => this.emit(event, ...args));
49
+ }
50
+ }
51
+ async close() {
52
+ if (!this.socket) {
53
+ return;
54
+ }
55
+ this.socket.close();
56
+ this.socket = null;
57
+ }
58
+ send(str, cb) {
59
+ this.socket?.send(str, cb);
60
+ return Boolean(this.socket);
61
+ }
110
62
  }
111
- exports.WebSocketClient = WebSocketClient;