@hbmodsofc/baileys 1.7.8 → 2.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 (155) hide show
  1. package/LICENSE +1 -1
  2. package/lib/Defaults/baileys-version.json +3 -0
  3. package/lib/Defaults/index.d.ts +8 -12
  4. package/lib/Defaults/index.js +124 -90
  5. package/lib/Defaults/phonenumber-mcc.json +223 -0
  6. package/lib/Signal/Group/group_cipher.d.ts +1 -0
  7. package/lib/Signal/Group/group_cipher.js +39 -28
  8. package/lib/Signal/Group/queue-job.d.ts +1 -0
  9. package/lib/Signal/Group/queue-job.js +57 -0
  10. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  11. package/lib/Signal/Group/sender-chain-key.js +2 -9
  12. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  13. package/lib/Signal/Group/sender-key-message.js +3 -3
  14. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  15. package/lib/Signal/Group/sender-key-state.js +16 -47
  16. package/lib/Signal/libsignal.d.ts +3 -7
  17. package/lib/Signal/libsignal.js +39 -224
  18. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
  19. package/lib/Socket/Client/index.d.ts +3 -2
  20. package/lib/Socket/Client/index.js +3 -2
  21. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  22. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  23. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  24. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
  25. package/lib/Socket/business.d.ts +78 -94
  26. package/lib/Socket/business.js +11 -130
  27. package/lib/Socket/chats.d.ts +233 -63
  28. package/lib/Socket/chats.js +184 -234
  29. package/lib/Socket/groups.d.ts +41 -62
  30. package/lib/Socket/groups.js +64 -76
  31. package/lib/Socket/hbmods.d.ts +253 -0
  32. package/lib/Socket/hbmods.js +1 -0
  33. package/lib/Socket/index.d.ts +83 -129
  34. package/lib/Socket/index.js +6 -13
  35. package/lib/Socket/messages-recv.d.ts +48 -59
  36. package/lib/Socket/messages-recv.js +371 -516
  37. package/lib/Socket/messages-send.d.ts +67 -86
  38. package/lib/Socket/messages-send.js +1 -1091
  39. package/lib/Socket/newsletter.d.ts +64 -76
  40. package/lib/Socket/newsletter.js +1 -184
  41. package/lib/Socket/registration.d.ts +267 -0
  42. package/lib/Socket/registration.js +166 -0
  43. package/lib/Socket/socket.d.ts +13 -19
  44. package/lib/Socket/socket.js +1 -805
  45. package/lib/Socket/usync.d.ts +36 -0
  46. package/lib/Socket/usync.js +70 -0
  47. package/lib/Types/Auth.d.ts +10 -4
  48. package/lib/Types/Call.d.ts +1 -1
  49. package/lib/Types/Chat.d.ts +9 -29
  50. package/lib/Types/Chat.js +1 -7
  51. package/lib/Types/Contact.d.ts +1 -5
  52. package/lib/Types/Events.d.ts +14 -55
  53. package/lib/Types/GroupMetadata.d.ts +5 -15
  54. package/lib/Types/Label.d.ts +0 -11
  55. package/lib/Types/Label.js +1 -1
  56. package/lib/Types/LabelAssociation.js +1 -1
  57. package/lib/Types/Message.d.ts +49 -75
  58. package/lib/Types/Message.js +7 -10
  59. package/lib/Types/Newsletter.d.ts +98 -129
  60. package/lib/Types/Newsletter.js +38 -33
  61. package/lib/Types/Product.d.ts +1 -1
  62. package/lib/Types/Signal.d.ts +1 -29
  63. package/lib/Types/Socket.d.ts +22 -48
  64. package/lib/Types/State.d.ts +2 -13
  65. package/lib/Types/State.js +0 -12
  66. package/lib/Types/USync.d.ts +1 -1
  67. package/lib/Types/index.d.ts +3 -10
  68. package/lib/Types/index.js +2 -2
  69. package/lib/Utils/auth-utils.d.ts +3 -3
  70. package/lib/Utils/auth-utils.js +102 -378
  71. package/lib/Utils/baileys-event-stream.js +1 -1
  72. package/lib/Utils/business.d.ts +2 -2
  73. package/lib/Utils/business.js +13 -19
  74. package/lib/Utils/chat-utils.d.ts +22 -21
  75. package/lib/Utils/chat-utils.js +154 -201
  76. package/lib/Utils/crypto.d.ts +19 -18
  77. package/lib/Utils/crypto.js +37 -78
  78. package/lib/Utils/decode-wa-message.d.ts +7 -34
  79. package/lib/Utils/decode-wa-message.js +66 -138
  80. package/lib/Utils/event-buffer.d.ts +8 -6
  81. package/lib/Utils/event-buffer.js +43 -81
  82. package/lib/Utils/generics.d.ts +27 -27
  83. package/lib/Utils/generics.js +133 -128
  84. package/lib/Utils/history.d.ts +5 -9
  85. package/lib/Utils/history.js +23 -17
  86. package/lib/Utils/index.d.ts +0 -2
  87. package/lib/Utils/index.js +0 -2
  88. package/lib/Utils/link-preview.d.ts +4 -4
  89. package/lib/Utils/link-preview.js +12 -40
  90. package/lib/Utils/logger.d.ts +3 -11
  91. package/lib/Utils/lt-hash.d.ts +8 -8
  92. package/lib/Utils/lt-hash.js +24 -23
  93. package/lib/Utils/make-mutex.d.ts +2 -2
  94. package/lib/Utils/make-mutex.js +2 -3
  95. package/lib/Utils/messages-media.d.ts +41 -37
  96. package/lib/Utils/messages-media.js +368 -252
  97. package/lib/Utils/messages.d.ts +15 -13
  98. package/lib/Utils/messages.js +261 -274
  99. package/lib/Utils/noise-handler.d.ts +15 -13
  100. package/lib/Utils/noise-handler.js +26 -20
  101. package/lib/Utils/process-message.d.ts +8 -9
  102. package/lib/Utils/process-message.js +93 -157
  103. package/lib/Utils/signal.d.ts +5 -6
  104. package/lib/Utils/signal.js +29 -37
  105. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
  106. package/lib/Utils/use-multi-file-auth-state.js +7 -12
  107. package/lib/Utils/validate-connection.d.ts +6 -5
  108. package/lib/Utils/validate-connection.js +97 -39
  109. package/lib/WABinary/constants.d.ts +27 -24
  110. package/lib/WABinary/constants.js +13 -1276
  111. package/lib/WABinary/decode.d.ts +4 -3
  112. package/lib/WABinary/decode.js +14 -28
  113. package/lib/WABinary/encode.d.ts +2 -1
  114. package/lib/WABinary/encode.js +147 -134
  115. package/lib/WABinary/generic-utils.d.ts +7 -4
  116. package/lib/WABinary/generic-utils.js +125 -40
  117. package/lib/WABinary/jid-utils.d.ts +8 -13
  118. package/lib/WABinary/jid-utils.js +16 -27
  119. package/lib/WAM/BinaryInfo.d.ts +11 -2
  120. package/lib/WAM/constants.d.ts +2 -3
  121. package/lib/WAM/constants.js +2359 -2252
  122. package/lib/WAM/encode.d.ts +2 -1
  123. package/lib/WAM/encode.js +11 -8
  124. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
  126. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  127. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  128. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  129. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  130. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  131. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
  132. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  134. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
  136. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  137. package/lib/WAUSync/USyncQuery.js +15 -19
  138. package/lib/WAUSync/USyncUser.d.ts +5 -5
  139. package/lib/WAUSync/index.d.ts +1 -1
  140. package/lib/WAUSync/index.js +1 -1
  141. package/package.json +102 -104
  142. package/WAProto/index.js +0 -37306
  143. package/lib/Signal/lid-mapping.d.ts +0 -26
  144. package/lib/Signal/lid-mapping.js +0 -146
  145. package/lib/Socket/communities.d.ts +0 -232
  146. package/lib/Socket/communities.js +0 -402
  147. package/lib/Socket/mex.d.ts +0 -2
  148. package/lib/Socket/mex.js +0 -45
  149. package/lib/Types/Bussines.d.ts +0 -24
  150. package/lib/Types/Bussines.js +0 -2
  151. package/lib/Utils/lidToJid-test.d.ts +0 -11
  152. package/lib/Utils/lidToJid-test.js +0 -27
  153. package/lib/Utils/message-retry-manager.d.ts +0 -81
  154. package/lib/Utils/message-retry-manager.js +0 -152
  155. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MobileSocketClient = void 0;
4
+ const net_1 = require("net");
5
+ const abstract_socket_client_1 = require("./abstract-socket-client");
6
+ class MobileSocketClient extends abstract_socket_client_1.AbstractSocketClient {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.socket = null;
10
+ }
11
+ get isOpen() {
12
+ var _a;
13
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'open';
14
+ }
15
+ get isClosed() {
16
+ var _a;
17
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
18
+ }
19
+ get isClosing() {
20
+ var _a;
21
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
22
+ }
23
+ get isConnecting() {
24
+ var _a;
25
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'opening';
26
+ }
27
+ async connect() {
28
+ var _a;
29
+ if (this.socket) {
30
+ return;
31
+ }
32
+ if (this.config.agent) {
33
+ throw new Error('There are not support for proxy agent for mobile connection');
34
+ }
35
+ else {
36
+ this.socket = (0, net_1.connect)({
37
+ host: this.url.hostname,
38
+ port: Number(this.url.port) || 443
39
+ });
40
+ }
41
+ this.socket.setMaxListeners(0);
42
+ const events = ['close', 'connect', 'data', 'drain', 'end', 'error', 'lookup', 'ready', 'timeout'];
43
+ for (const event of events) {
44
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.on(event, (...args) => this.emit(event, ...args));
45
+ }
46
+ this.socket.on('data', (...args) => this.emit('message', ...args));
47
+ this.socket.on('ready', (...args) => this.emit('open', ...args));
48
+ }
49
+ async close() {
50
+ if (!this.socket) {
51
+ return;
52
+ }
53
+ return new Promise(resolve => {
54
+ this.socket.end(resolve);
55
+ this.socket = null;
56
+ });
57
+ }
58
+ send(str, cb) {
59
+ if (this.socket === null) {
60
+ return false;
61
+ }
62
+ return this.socket.write(str, undefined, cb);
63
+ }
64
+ }
65
+ exports.MobileSocketClient = MobileSocketClient;
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'ws';
2
- import { AbstractSocketClient } from './types';
2
+ import { AbstractSocketClient } from './abstract-socket-client';
3
3
  export declare class WebSocketClient extends AbstractSocketClient {
4
4
  protected socket: WebSocket | null;
5
5
  get isOpen(): boolean;
@@ -6,39 +6,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WebSocketClient = void 0;
7
7
  const ws_1 = __importDefault(require("ws"));
8
8
  const Defaults_1 = require("../../Defaults");
9
- const types_1 = require("./types");
10
- class WebSocketClient extends types_1.AbstractSocketClient {
9
+ const abstract_socket_client_1 = require("./abstract-socket-client");
10
+ class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
11
11
  constructor() {
12
12
  super(...arguments);
13
13
  this.socket = null;
14
14
  }
15
15
  get isOpen() {
16
- return this.socket?.readyState === ws_1.default.OPEN;
16
+ var _a;
17
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN;
17
18
  }
18
19
  get isClosed() {
19
- return this.socket === null || this.socket?.readyState === ws_1.default.CLOSED;
20
+ var _a;
21
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSED;
20
22
  }
21
23
  get isClosing() {
22
- return this.socket === null || this.socket?.readyState === ws_1.default.CLOSING;
24
+ var _a;
25
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
23
26
  }
24
27
  get isConnecting() {
25
- return this.socket?.readyState === ws_1.default.CONNECTING;
28
+ var _a;
29
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CONNECTING;
26
30
  }
27
31
  async connect() {
32
+ var _a, _b;
28
33
  if (this.socket) {
29
34
  return;
30
35
  }
31
36
  this.socket = new ws_1.default(this.url, {
32
37
  origin: Defaults_1.DEFAULT_ORIGIN,
33
- headers: this.config.options?.headers,
38
+ headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
34
39
  handshakeTimeout: this.config.connectTimeoutMs,
35
40
  timeout: this.config.connectTimeoutMs,
36
- agent: this.config.agent
41
+ agent: this.config.agent,
37
42
  });
38
43
  this.socket.setMaxListeners(0);
39
44
  const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
40
45
  for (const event of events) {
41
- this.socket?.on(event, (...args) => this.emit(event, ...args));
46
+ (_b = this.socket) === null || _b === void 0 ? void 0 : _b.on(event, (...args) => this.emit(event, ...args));
42
47
  }
43
48
  }
44
49
  async close() {
@@ -49,7 +54,8 @@ class WebSocketClient extends types_1.AbstractSocketClient {
49
54
  this.socket = null;
50
55
  }
51
56
  send(str, cb) {
52
- this.socket?.send(str, cb);
57
+ var _a;
58
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
53
59
  return Boolean(this.socket);
54
60
  }
55
61
  }
@@ -1,8 +1,8 @@
1
- import type { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig, WAMediaUpload } from '../Types';
2
- import type { UpdateBussinesProfileProps } from '../Types/Bussines';
3
- import { type BinaryNode } from '../WABinary';
1
+ /// <reference types="node" />
2
+ import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
3
+ import { BinaryNode } from '../WABinary';
4
4
  export declare const makeBusinessSocket: (config: SocketConfig) => {
5
- logger: import("../Utils/logger").ILogger;
5
+ logger: import("pino").Logger<import("pino").LoggerOptions>;
6
6
  getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
7
7
  getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
8
8
  products: import("../Types").Product[];
@@ -16,59 +16,58 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
16
16
  deleted: number;
17
17
  }>;
18
18
  productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
19
- updateBussinesProfile: (args: UpdateBussinesProfileProps) => Promise<any>;
20
- updateCoverPhoto: (photo: WAMediaUpload) => Promise<number>;
21
- removeCoverPhoto: (id: string) => Promise<any>;
22
- sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
19
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
23
20
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
21
+ offerCall: (toJid: string, isVideo?: boolean) => Promise<{
22
+ id: string;
23
+ to: string;
24
+ }>;
24
25
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
25
- fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
26
- requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
27
- messageRetryManager: import("../Utils").MessageRetryManager | null;
28
- getPrivacyTokens: (jids: string[]) => Promise<any>;
26
+ getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
29
27
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
30
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
28
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
31
29
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
32
- sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
33
- readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
30
+ sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
+ getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
32
+ [key: string]: string;
33
+ };
34
+ readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
34
35
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
36
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
37
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
38
+ [key: string]: string;
39
+ } | undefined) => Promise<{
40
+ nodes: BinaryNode[];
41
+ shouldIncludeDeviceIdentity: boolean;
42
+ }>;
35
43
  waUploadToServer: import("../Types").WAMediaUploadFunction;
36
44
  fetchPrivacySettings: (force?: boolean) => Promise<{
37
45
  [_: string]: string;
38
46
  }>;
39
- sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
40
- createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: BinaryNode["attrs"], dsmMessage?: import("../Types").WAProto.IMessage) => Promise<{
41
- nodes: BinaryNode[];
42
- shouldIncludeDeviceIdentity: boolean;
43
- }>;
44
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<(import("../WABinary").JidWithDevice & {
45
- wireJid: string;
46
- })[]>;
47
47
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
48
48
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
49
- newsletterCreate: (name: string, description?: string) => Promise<import("../Types").NewsletterMetadata>;
50
- newsletterUpdate: (jid: string, updates: import("../Types").NewsletterUpdate) => Promise<unknown>;
51
- newsletterSubscribers: (jid: string) => Promise<{
52
- subscribers: number;
53
- }>;
54
- newsletterMetadata: (type: "invite" | "jid", key: string) => Promise<import("../Types").NewsletterMetadata | null>;
55
- newsletterFollow: (jid: string) => Promise<unknown>;
56
- newsletterUnfollow: (jid: string) => Promise<unknown>;
57
- newsletterMute: (jid: string) => Promise<unknown>;
58
- newsletterUnmute: (jid: string) => Promise<unknown>;
59
- newsletterUpdateName: (jid: string, name: string) => Promise<unknown>;
60
- newsletterUpdateDescription: (jid: string, description: string) => Promise<unknown>;
61
- newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<unknown>;
62
- newsletterRemovePicture: (jid: string) => Promise<unknown>;
63
- newsletterReactMessage: (jid: string, serverId: string, reaction?: string) => Promise<void>;
64
- newsletterFetchMessages: (jid: string, count: number, since: number, after: number) => Promise<any>;
65
49
  subscribeNewsletterUpdates: (jid: string) => Promise<{
66
50
  duration: string;
67
- } | null>;
51
+ }>;
52
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
53
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
54
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
55
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
56
+ newsletterRemovePicture: (jid: string) => Promise<void>;
57
+ newsletterUnfollow: (jid: string) => Promise<void>;
58
+ newsletterFollow: (jid: string) => Promise<void>;
59
+ newsletterUnmute: (jid: string) => Promise<void>;
60
+ newsletterMute: (jid: string) => Promise<void>;
61
+ newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
62
+ newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
63
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
68
64
  newsletterAdminCount: (jid: string) => Promise<number>;
69
- newsletterChangeOwner: (jid: string, newOwnerJid: string) => Promise<void>;
70
- newsletterDemote: (jid: string, userJid: string) => Promise<void>;
65
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
66
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
71
67
  newsletterDelete: (jid: string) => Promise<void>;
68
+ newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
69
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
70
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
72
71
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
73
72
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
74
73
  groupLeave: (id: string) => Promise<void>;
@@ -76,7 +75,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
76
75
  groupRequestParticipantsList: (jid: string) => Promise<{
77
76
  [key: string]: string;
78
77
  }[]>;
79
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
78
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
80
79
  status: string;
81
80
  jid: string;
82
81
  }[]>;
@@ -85,103 +84,88 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
85
84
  jid: string;
86
85
  content: BinaryNode;
87
86
  }[]>;
88
- groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
87
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
89
88
  groupInviteCode: (jid: string) => Promise<string | undefined>;
90
89
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
91
90
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
92
- groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
93
- groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
91
+ groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
94
92
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
95
93
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
96
- groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
97
- groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
94
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
95
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
98
96
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
99
97
  groupFetchAllParticipating: () => Promise<{
100
98
  [_: string]: import("../Types").GroupMetadata;
101
99
  }>;
102
- createCallLink: (type: "audio" | "video", event?: {
103
- startTime: number;
104
- }, timeoutMs?: number) => Promise<string | undefined>;
105
- getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
106
100
  processingMutex: {
107
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
101
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
108
102
  };
109
- upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
103
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
110
104
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
111
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
112
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
113
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
105
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
106
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
107
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
108
+ onWhatsApp: (...jids: string[]) => Promise<{
109
+ jid: string;
110
+ exists: unknown;
111
+ lid: unknown;
112
+ }[] | undefined>;
114
113
  fetchBlocklist: () => Promise<string[]>;
115
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
116
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
117
- updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
118
- width: number;
119
- height: number;
120
- }) => Promise<void>;
114
+ fetchStatus: (jid: string) => Promise<{
115
+ status: string | undefined;
116
+ setAt: Date;
117
+ } | undefined>;
118
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
121
119
  removeProfilePicture: (jid: string) => Promise<void>;
122
120
  updateProfileStatus: (status: string) => Promise<void>;
123
121
  updateProfileName: (name: string) => Promise<void>;
124
122
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
125
- updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
126
- updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
127
- updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
128
123
  updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
129
124
  updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
130
125
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
131
126
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
132
127
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
133
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
128
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
134
129
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
135
- getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
136
- resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
130
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
131
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
137
132
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
138
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
139
- addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
140
- removeContact: (jid: string) => Promise<void>;
141
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
133
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
142
134
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
143
135
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
144
136
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
145
137
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
146
138
  star: (jid: string, messages: {
147
139
  id: string;
148
- fromMe?: boolean;
140
+ fromMe?: boolean | undefined;
149
141
  }[], star: boolean) => Promise<void>;
150
- addOrEditQuickReply: (quickReply: import("../Types/Bussines").QuickReplyAction) => Promise<void>;
151
- removeQuickReply: (timestamp: string) => Promise<void>;
152
142
  type: "md";
153
- ws: import("./Client").WebSocketClient;
143
+ ws: any;
154
144
  ev: import("../Types").BaileysEventEmitter & {
155
145
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
156
146
  buffer(): void;
157
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
158
- flush(): boolean;
147
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
148
+ flush(force?: boolean | undefined): boolean;
159
149
  isBuffering(): boolean;
160
150
  };
161
151
  authState: {
162
152
  creds: import("../Types").AuthenticationCreds;
163
153
  keys: import("../Types").SignalKeyStoreWithTransaction;
164
154
  };
165
- signalRepository: import("../Types").SignalRepositoryWithLIDStore;
155
+ signalRepository: import("../Types").SignalRepository;
166
156
  user: import("../Types").Contact | undefined;
167
157
  generateMessageTag: () => string;
168
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
169
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
158
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
159
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
170
160
  waitForSocketOpen: () => Promise<void>;
171
161
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
172
162
  sendNode: (frame: BinaryNode) => Promise<void>;
173
- logout: (msg?: string) => Promise<void>;
163
+ logout: (msg?: string | undefined) => Promise<void>;
174
164
  end: (error: Error | undefined) => void;
175
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
176
- uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
165
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
166
+ uploadPreKeys: (count?: number) => Promise<void>;
177
167
  uploadPreKeysToServerIfRequired: () => Promise<void>;
178
- requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
179
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
180
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
181
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
182
- onWhatsApp: (...jids: string[]) => Promise<{
183
- jid: string;
184
- exists: boolean;
185
- lid: string;
186
- }[] | undefined>;
168
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
169
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
170
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
187
171
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeBusinessSocket = void 0;
4
- const Utils_1 = require("../Utils");
5
4
  const business_1 = require("../Utils/business");
6
5
  const WABinary_1 = require("../WABinary");
7
6
  const generic_utils_1 = require("../WABinary/generic-utils");
@@ -9,125 +8,9 @@ const messages_recv_1 = require("./messages-recv");
9
8
  const makeBusinessSocket = (config) => {
10
9
  const sock = (0, messages_recv_1.makeMessagesRecvSocket)(config);
11
10
  const { authState, query, waUploadToServer } = sock;
12
- const updateBussinesProfile = async (args) => {
13
- const node = [];
14
- const simpleFields = ['address', 'email', 'description'];
15
- node.push(...simpleFields
16
- .filter(key => args[key])
17
- .map(key => ({
18
- tag: key,
19
- attrs: {},
20
- content: args[key]
21
- })));
22
- if (args.websites) {
23
- node.push(...args.websites.map(website => ({
24
- tag: 'website',
25
- attrs: {},
26
- content: website
27
- })));
28
- }
29
- if (args.hours) {
30
- node.push({
31
- tag: 'business_hours',
32
- attrs: { timezone: args.hours.timezone },
33
- content: args.hours.days.map(config => {
34
- const base = {
35
- tag: 'business_hours_config',
36
- attrs: { day_of_week: config.day, mode: config.mode }
37
- };
38
- if (config.mode === 'specific_hours') {
39
- return {
40
- ...base,
41
- attrs: {
42
- ...base.attrs,
43
- open_time: config.openTimeInMinutes,
44
- close_time: config.closeTimeInMinutes
45
- }
46
- };
47
- }
48
- return base;
49
- })
50
- });
51
- }
52
- const result = await query({
53
- tag: 'iq',
54
- attrs: {
55
- to: WABinary_1.S_WHATSAPP_NET,
56
- type: 'set',
57
- xmlns: 'w:biz'
58
- },
59
- content: [
60
- {
61
- tag: 'business_profile',
62
- attrs: {
63
- v: '3',
64
- mutation_type: 'delta'
65
- },
66
- content: node
67
- }
68
- ]
69
- });
70
- return result;
71
- };
72
- const updateCoverPhoto = async (photo) => {
73
- const { fileSha256, filePath } = await (0, Utils_1.getRawMediaUploadData)(photo, 'biz-cover-photo');
74
- const fileSha256B64 = fileSha256.toString('base64');
75
- const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
76
- fileEncSha256B64: fileSha256B64,
77
- mediaType: 'biz-cover-photo'
78
- });
79
- await query({
80
- tag: 'iq',
81
- attrs: {
82
- to: WABinary_1.S_WHATSAPP_NET,
83
- type: 'set',
84
- xmlns: 'w:biz'
85
- },
86
- content: [
87
- {
88
- tag: 'business_profile',
89
- attrs: {
90
- v: '3',
91
- mutation_type: 'delta'
92
- },
93
- content: [
94
- {
95
- tag: 'cover_photo',
96
- attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
97
- }
98
- ]
99
- }
100
- ]
101
- });
102
- return fbid;
103
- };
104
- const removeCoverPhoto = async (id) => {
105
- return await query({
106
- tag: 'iq',
107
- attrs: {
108
- to: WABinary_1.S_WHATSAPP_NET,
109
- type: 'set',
110
- xmlns: 'w:biz'
111
- },
112
- content: [
113
- {
114
- tag: 'business_profile',
115
- attrs: {
116
- v: '3',
117
- mutation_type: 'delta'
118
- },
119
- content: [
120
- {
121
- tag: 'cover_photo',
122
- attrs: { op: 'delete', id }
123
- }
124
- ]
125
- }
126
- ]
127
- });
128
- };
129
11
  const getCatalog = async ({ jid, limit, cursor }) => {
130
- jid = jid || authState.creds.me?.id;
12
+ var _a;
13
+ jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
131
14
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
132
15
  const queryParamNodes = [
133
16
  {
@@ -144,7 +27,7 @@ const makeBusinessSocket = (config) => {
144
27
  tag: 'height',
145
28
  attrs: {},
146
29
  content: Buffer.from('100')
147
- }
30
+ },
148
31
  ];
149
32
  if (cursor) {
150
33
  queryParamNodes.push({
@@ -165,7 +48,7 @@ const makeBusinessSocket = (config) => {
165
48
  tag: 'product_catalog',
166
49
  attrs: {
167
50
  jid,
168
- allow_shop_source: 'true'
51
+ 'allow_shop_source': 'true'
169
52
  },
170
53
  content: queryParamNodes
171
54
  }
@@ -174,7 +57,8 @@ const makeBusinessSocket = (config) => {
174
57
  return (0, business_1.parseCatalogNode)(result);
175
58
  };
176
59
  const getCollections = async (jid, limit = 51) => {
177
- jid = jid || authState.creds.me?.id;
60
+ var _a;
61
+ jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
178
62
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
179
63
  const result = await query({
180
64
  tag: 'iq',
@@ -182,13 +66,13 @@ const makeBusinessSocket = (config) => {
182
66
  to: WABinary_1.S_WHATSAPP_NET,
183
67
  type: 'get',
184
68
  xmlns: 'w:biz:catalog',
185
- smax_id: '35'
69
+ 'smax_id': '35'
186
70
  },
187
71
  content: [
188
72
  {
189
73
  tag: 'collections',
190
74
  attrs: {
191
- biz_jid: jid
75
+ 'biz_jid': jid,
192
76
  },
193
77
  content: [
194
78
  {
@@ -224,7 +108,7 @@ const makeBusinessSocket = (config) => {
224
108
  to: WABinary_1.S_WHATSAPP_NET,
225
109
  type: 'get',
226
110
  xmlns: 'fb:thrift_iq',
227
- smax_id: '5'
111
+ 'smax_id': '5'
228
112
  },
229
113
  content: [
230
114
  {
@@ -359,7 +243,7 @@ const makeBusinessSocket = (config) => {
359
243
  });
360
244
  const productCatalogDelNode = (0, generic_utils_1.getBinaryNodeChild)(result, 'product_catalog_delete');
361
245
  return {
362
- deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
246
+ deleted: +((productCatalogDelNode === null || productCatalogDelNode === void 0 ? void 0 : productCatalogDelNode.attrs.deleted_count) || 0)
363
247
  };
364
248
  };
365
249
  return {
@@ -370,10 +254,7 @@ const makeBusinessSocket = (config) => {
370
254
  getCollections,
371
255
  productCreate,
372
256
  productDelete,
373
- productUpdate,
374
- updateBussinesProfile,
375
- updateCoverPhoto,
376
- removeCoverPhoto
257
+ productUpdate
377
258
  };
378
259
  };
379
260
  exports.makeBusinessSocket = makeBusinessSocket;