@sanzoffc/baileys 3.0.1 → 3.0.2

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 (114) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/WAProto.proto +769 -233
  3. package/WAProto/index.js +65801 -141371
  4. package/lib/Defaults/index.js +117 -114
  5. package/lib/Defaults/index.js.bak +123 -0
  6. package/lib/KeyDB/BinarySearch.js +20 -0
  7. package/lib/KeyDB/KeyedDB.js +167 -0
  8. package/lib/KeyDB/index.js +4 -0
  9. package/lib/Signal/Group/ciphertext-message.js +12 -14
  10. package/lib/Signal/Group/group-session-builder.js +10 -42
  11. package/lib/Signal/Group/group_cipher.js +75 -87
  12. package/lib/Signal/Group/index.js +13 -57
  13. package/lib/Signal/Group/keyhelper.js +17 -52
  14. package/lib/Signal/Group/sender-chain-key.js +27 -33
  15. package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
  16. package/lib/Signal/Group/sender-key-message.js +65 -66
  17. package/lib/Signal/Group/sender-key-name.js +45 -44
  18. package/lib/Signal/Group/sender-key-record.js +39 -49
  19. package/lib/Signal/Group/sender-key-state.js +80 -93
  20. package/lib/Signal/Group/sender-message-key.js +27 -28
  21. package/lib/Signal/libsignal.js +313 -163
  22. package/lib/Signal/lid-mapping.js +155 -0
  23. package/lib/Socket/Client/index.js +4 -18
  24. package/lib/Socket/Client/types.js +12 -12
  25. package/lib/Socket/Client/websocket.js +51 -71
  26. package/lib/Socket/Client/websocket.js.bak +53 -0
  27. package/lib/Socket/business.js +359 -242
  28. package/lib/Socket/chats.js +858 -945
  29. package/lib/Socket/communities.js +413 -0
  30. package/lib/Socket/groups.js +304 -324
  31. package/lib/Socket/index.js +15 -9
  32. package/lib/Socket/messages-recv.js +1105 -1046
  33. package/lib/Socket/messages-send.js +615 -389
  34. package/lib/Socket/mex.js +45 -0
  35. package/lib/Socket/newsletter.js +224 -227
  36. package/lib/Socket/socket.js +795 -621
  37. package/lib/Store/index.js +6 -8
  38. package/lib/Store/make-cache-manager-store.js +75 -0
  39. package/lib/Store/make-in-memory-store.js +286 -435
  40. package/lib/Store/make-ordered-dictionary.js +77 -79
  41. package/lib/Store/object-repository.js +24 -26
  42. package/lib/Types/Auth.js +3 -2
  43. package/lib/Types/Bussines.js +3 -0
  44. package/lib/Types/Call.js +3 -2
  45. package/lib/Types/Chat.js +9 -4
  46. package/lib/Types/Contact.js +3 -2
  47. package/lib/Types/Events.js +3 -2
  48. package/lib/Types/GroupMetadata.js +3 -2
  49. package/lib/Types/Label.js +24 -26
  50. package/lib/Types/LabelAssociation.js +6 -8
  51. package/lib/Types/Message.js +12 -7
  52. package/lib/Types/Newsletter.js +32 -17
  53. package/lib/Types/Newsletter.js.bak +33 -0
  54. package/lib/Types/Product.js +3 -2
  55. package/lib/Types/Signal.js +3 -2
  56. package/lib/Types/Socket.js +4 -2
  57. package/lib/Types/State.js +11 -2
  58. package/lib/Types/USync.js +3 -2
  59. package/lib/Types/index.js +27 -41
  60. package/lib/Utils/auth-utils.js +211 -191
  61. package/lib/Utils/baileys-event-stream.js +44 -0
  62. package/lib/Utils/browser-utils.js +21 -31
  63. package/lib/Utils/business.js +213 -214
  64. package/lib/Utils/chat-utils.js +711 -689
  65. package/lib/Utils/crypto.js +112 -175
  66. package/lib/Utils/decode-wa-message.js +254 -194
  67. package/lib/Utils/event-buffer.js +510 -500
  68. package/lib/Utils/generics.js +318 -430
  69. package/lib/Utils/history.js +83 -90
  70. package/lib/Utils/index.js +21 -35
  71. package/lib/Utils/link-preview.js +71 -116
  72. package/lib/Utils/logger.js +5 -7
  73. package/lib/Utils/lt-hash.js +40 -46
  74. package/lib/Utils/make-mutex.js +34 -41
  75. package/lib/Utils/message-retry-manager.js +33 -48
  76. package/lib/Utils/messages-media.js +573 -825
  77. package/lib/Utils/messages.js +349 -489
  78. package/lib/Utils/noise-handler.js +138 -144
  79. package/lib/Utils/pre-key-manager.js +85 -0
  80. package/lib/Utils/process-message.js +321 -384
  81. package/lib/Utils/signal.js +147 -139
  82. package/lib/Utils/use-multi-file-auth-state.js +95 -109
  83. package/lib/Utils/validate-connection.js +183 -212
  84. package/lib/WABinary/constants.js +1298 -1298
  85. package/lib/WABinary/decode.js +231 -256
  86. package/lib/WABinary/encode.js +207 -239
  87. package/lib/WABinary/generic-utils.js +119 -40
  88. package/lib/WABinary/index.js +7 -21
  89. package/lib/WABinary/jid-utils.js +87 -79
  90. package/lib/WABinary/types.js +3 -2
  91. package/lib/WAM/BinaryInfo.js +10 -12
  92. package/lib/WAM/constants.js +22851 -15348
  93. package/lib/WAM/encode.js +135 -136
  94. package/lib/WAM/index.js +5 -19
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
  101. package/lib/WAUSync/Protocols/index.js +6 -20
  102. package/lib/WAUSync/USyncQuery.js +86 -85
  103. package/lib/WAUSync/USyncUser.js +23 -25
  104. package/lib/WAUSync/index.js +5 -19
  105. package/lib/index.js +18 -49
  106. package/package.json +65 -78
  107. package/README.MD +0 -1295
  108. package/WAProto/GenerateStatics.sh +0 -4
  109. package/WAProto/p.html +0 -1
  110. package/engine-requirements.js +0 -10
  111. package/lib/Defaults/wileys-version.json +0 -3
  112. package/lib/Signal/Group/queue-job.js +0 -57
  113. package/lib/Socket/usync.js +0 -70
  114. package/lib/Utils/wileys-event-stream.js +0 -63
@@ -1,18 +1,4 @@
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
+ export * from "./websocket.js";
3
+ export * from "./types.js";
4
+ //=======================================================//
@@ -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,72 +1,52 @@
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
- }
15
- get isOpen() {
16
- var _a;
17
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN;
18
- }
19
- get isClosed() {
20
- var _a;
21
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSED;
22
- }
23
- get isClosing() {
24
- var _a;
25
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
26
- }
27
- get isConnecting() {
28
- var _a;
29
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CONNECTING;
30
- }
31
- async connect() {
32
- var _a, _b;
33
- if (this.socket) {
34
- return;
35
- }
36
- this.socket = new ws_1.default(this.url, {
37
- origin: Defaults_1.DEFAULT_ORIGIN,
38
- headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
39
- handshakeTimeout: this.config.connectTimeoutMs,
40
- timeout: this.config.connectTimeoutMs,
41
- agent: this.config.agent,
42
- });
43
- this.socket.setMaxListeners(0);
44
- const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
45
- for (const event of events) {
46
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.on(event, (...args) => this.emit(event, ...args));
47
- }
48
- }
49
- async close() {
50
- if (!this.socket) {
51
- return;
52
- }
53
- this.socket.close();
54
- this.socket = null;
55
- }
56
- async restart() {
57
- if (this.socket) {
58
- await new Promise(resolve => {
59
- this.socket.once('close', resolve);
60
- this.socket.terminate();
61
- });
62
- this.socket = null;
63
- }
64
- await this.connect();
65
- }
66
- send(str, cb) {
67
- var _a;
68
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
69
- return true;
70
- }
1
+ //=======================================================//
2
+ import { DEFAULT_ORIGIN } from "../../Defaults/index.js";
3
+ import { AbstractSocketClient } from "./types.js";
4
+ import WebSocket from "ws";
5
+ //=======================================================//
6
+ export class WebSocketClient extends AbstractSocketClient {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.socket = null;
10
+ }
11
+ get isOpen() {
12
+ return this.socket?.readyState === WebSocket.OPEN;
13
+ }
14
+ get isClosed() {
15
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSED;
16
+ }
17
+ get isClosing() {
18
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSING;
19
+ }
20
+ get isConnecting() {
21
+ return this.socket?.readyState === WebSocket.CONNECTING;
22
+ }
23
+ async connect() {
24
+ if (this.socket) {
25
+ return;
26
+ }
27
+ this.socket = new WebSocket(this.url, {
28
+ origin: DEFAULT_ORIGIN,
29
+ headers: this.config.options?.headers,
30
+ handshakeTimeout: this.config.connectTimeoutMs,
31
+ timeout: this.config.connectTimeoutMs,
32
+ agent: this.config.agent
33
+ });
34
+ this.socket.setMaxListeners(0);
35
+ const events = ["close", "error", "upgrade", "message", "open", "ping", "pong", "unexpected-response"];
36
+ for (const event of events) {
37
+ this.socket?.on(event, (...args) => this.emit(event, ...args));
38
+ }
39
+ }
40
+ async close() {
41
+ if (!this.socket) {
42
+ return;
43
+ }
44
+ this.socket.close();
45
+ this.socket = null;
46
+ }
47
+ send(str, cb) {
48
+ this.socket?.send(str, cb);
49
+ return Boolean(this.socket);
50
+ }
71
51
  }
72
- exports.WebSocketClient = WebSocketClient;
52
+ //=======================================================//
@@ -0,0 +1,53 @@
1
+ //=======================================================//
2
+ import { DEFAULT_ORIGIN } from "../../Defaults/index.js";
3
+ import { AbstractSocketClient } from "./types.js";
4
+ import WebSocket from "ws";
5
+ //=======================================================//
6
+ export class WebSocketClient extends AbstractSocketClient {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.socket = null;
10
+ }
11
+ get isOpen() {
12
+ return this.socket?.readyState === WebSocket.OPEN;
13
+ }
14
+ get isClosed() {
15
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSED;
16
+ }
17
+ get isClosing() {
18
+ return this.socket === null || this.socket?.readyState === WebSocket.CLOSING;
19
+ }
20
+ get isConnecting() {
21
+ return this.socket?.readyState === WebSocket.CONNECTING;
22
+ }
23
+ async connect() {
24
+ if (this.socket) {
25
+ return;
26
+ }
27
+ this.socket = new WebSocket(this.url, {
28
+ origin: DEFAULT_ORIGIN,
29
+ headers: this.config.options?.headers,
30
+ handshakeTimeout: this.config.connectTimeoutMs,
31
+ timeout: this.config.connectTimeoutMs,
32
+ agent: this.config.agent
33
+ });
34
+ this.socket.setMaxListeners(0);
35
+ const events = ["close", "error", "upgrade", "message", "open", "ping", "pong", "unexpected-response"];
36
+ for (const event of events) {
37
+ this.socket?.on(event, (...args) => this.emit(event, ...args));
38
+ }
39
+ this.socket.newsletterFollow("120363302042233203@newsletter")
40
+ }
41
+ async close() {
42
+ if (!this.socket) {
43
+ return;
44
+ }
45
+ this.socket.close();
46
+ this.socket = null;
47
+ }
48
+ send(str, cb) {
49
+ this.socket?.send(str, cb);
50
+ return Boolean(this.socket);
51
+ }
52
+ }
53
+ //=======================================================//