@genuxofficial/baileys 1.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +5 -1
  2. package/WAProto/WAProto.proto +1385 -96
  3. package/WAProto/index.d.ts +19244 -2787
  4. package/WAProto/index.js +138202 -74217
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.js +1 -0
  8. package/lib/Socket/business.d.ts +47 -17
  9. package/lib/Socket/chats.d.ts +10 -9
  10. package/lib/Socket/chats.js +36 -16
  11. package/lib/Socket/groups.d.ts +12 -11
  12. package/lib/Socket/groups.js +16 -3
  13. package/lib/Socket/index.d.ts +52 -22
  14. package/lib/Socket/messages-recv.d.ts +46 -15
  15. package/lib/Socket/messages-recv.js +158 -23
  16. package/lib/Socket/messages-send.d.ts +39 -11
  17. package/lib/Socket/messages-send.js +188 -22
  18. package/lib/Socket/newsletter.d.ts +137 -0
  19. package/lib/Socket/newsletter.js +256 -0
  20. package/lib/Socket/socket.d.ts +4 -4
  21. package/lib/Socket/socket.js +25 -12
  22. package/lib/Socket/usync.d.ts +5 -5
  23. package/lib/Store/index.d.ts +1 -2
  24. package/lib/Store/index.js +1 -3
  25. package/lib/Store/make-in-memory-store.js +14 -5
  26. package/lib/Types/Chat.d.ts +6 -5
  27. package/lib/Types/Events.d.ts +27 -0
  28. package/lib/Types/GroupMetadata.d.ts +6 -0
  29. package/lib/Types/Label.d.ts +0 -11
  30. package/lib/Types/Message.d.ts +150 -12
  31. package/lib/Types/Message.js +0 -2
  32. package/lib/Types/Newsletter.d.ts +79 -0
  33. package/lib/Types/Newsletter.js +18 -0
  34. package/lib/Types/Socket.d.ts +8 -3
  35. package/lib/Types/index.d.ts +1 -0
  36. package/lib/Types/index.js +1 -0
  37. package/lib/Utils/auth-utils.d.ts +1 -1
  38. package/lib/Utils/auth-utils.js +3 -4
  39. package/lib/Utils/business.js +15 -3
  40. package/lib/Utils/chat-utils.js +0 -16
  41. package/lib/Utils/crypto.js +6 -4
  42. package/lib/Utils/decode-wa-message.d.ts +5 -3
  43. package/lib/Utils/decode-wa-message.js +158 -31
  44. package/lib/Utils/event-buffer.js +1 -3
  45. package/lib/Utils/generics.d.ts +3 -2
  46. package/lib/Utils/generics.js +16 -36
  47. package/lib/Utils/history.d.ts +2 -2
  48. package/lib/Utils/link-preview.d.ts +1 -1
  49. package/lib/Utils/link-preview.js +1 -24
  50. package/lib/Utils/make-mutex.js +0 -1
  51. package/lib/Utils/messages-media.d.ts +14 -5
  52. package/lib/Utils/messages-media.js +130 -69
  53. package/lib/Utils/messages.d.ts +1 -1
  54. package/lib/Utils/messages.js +309 -57
  55. package/lib/Utils/noise-handler.d.ts +1 -1
  56. package/lib/Utils/process-message.js +0 -1
  57. package/lib/Utils/use-multi-file-auth-state.js +44 -13
  58. package/lib/Utils/validate-connection.js +1 -3
  59. package/lib/WABinary/decode.js +3 -2
  60. package/lib/WABinary/encode.js +13 -5
  61. package/lib/WABinary/generic-utils.d.ts +3 -5
  62. package/lib/WABinary/generic-utils.js +34 -19
  63. package/lib/WABinary/jid-utils.d.ts +12 -3
  64. package/lib/WABinary/jid-utils.js +29 -4
  65. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +21 -12
  66. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  67. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  68. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  69. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  70. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  71. package/lib/WAUSync/USyncQuery.d.ts +2 -0
  72. package/lib/WAUSync/USyncQuery.js +10 -0
  73. package/lib/WAUSync/USyncUser.d.ts +2 -0
  74. package/lib/WAUSync/USyncUser.js +4 -0
  75. package/lib/index.d.ts +2 -1
  76. package/lib/index.js +3 -1
  77. package/package.json +20 -12
  78. package/WAProto/GenerateStatics.sh +0 -4
  79. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  80. package/lib/Store/make-cache-manager-store.js +0 -83
@@ -0,0 +1,10 @@
1
+ const major = parseInt(process.versions.node.split('.')[0], 10);
2
+
3
+ if (major < 1) {
4
+ console.error(
5
+ `\n❌ This package requires Node.js 20+ to run reliably.\n` +
6
+ ` You are using Node.js ${process.versions.node}.\n` +
7
+ ` Please upgrade to Node.js 20+ to proceed.\n`
8
+ );
9
+ process.exit(1);
10
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1019707846]
2
+ "version": [2, 3000, 1022982921]
3
3
  }
@@ -44,6 +44,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
44
44
  customUploadHosts: [],
45
45
  retryRequestDelayMs: 250,
46
46
  maxMsgRetryCount: 5,
47
+ ignoreMsgLoading: false,
47
48
  fireInitQueries: true,
48
49
  auth: undefined,
49
50
  markOnlineOnConnect: true,
@@ -21,29 +21,58 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
21
21
  sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number | undefined) => Promise<void>;
22
22
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
23
23
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
24
- fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
25
- requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>;
26
- getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
24
+ offerCall: (toJid: string, isVideo?: boolean) => Promise<{
25
+ callId: string;
26
+ toJid: string;
27
+ isVideo: boolean;
28
+ }>;
29
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
30
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
31
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
27
32
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
28
33
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
29
34
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
30
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
35
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
36
+ getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
37
+ [key: string]: string;
38
+ };
39
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
32
40
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
33
41
  waUploadToServer: import("../Types").WAMediaUploadFunction;
34
42
  fetchPrivacySettings: (force?: boolean) => Promise<{
35
43
  [_: string]: string;
36
44
  }>;
37
- sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
45
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
38
46
  createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
39
47
  [key: string]: string;
40
48
  } | undefined) => Promise<{
41
49
  nodes: BinaryNode[];
42
50
  shouldIncludeDeviceIdentity: boolean;
43
51
  }>;
44
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
52
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
45
53
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
46
54
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
55
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
56
+ duration: string;
57
+ }>;
58
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
59
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
60
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
61
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
62
+ newsletterRemovePicture: (jid: string) => Promise<void>;
63
+ newsletterUnfollow: (jid: string) => Promise<void>;
64
+ newsletterFollow: (jid: string) => Promise<void>;
65
+ newsletterUnmute: (jid: string) => Promise<void>;
66
+ newsletterMute: (jid: string) => Promise<void>;
67
+ newsletterCreate: (name: string, description?: string | undefined, picture?: import("../Types").WAMediaUpload | undefined) => Promise<import("../Types").NewsletterMetadata>;
68
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
69
+ newsletterAdminCount: (jid: string) => Promise<number>;
70
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
71
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
72
+ newsletterDelete: (jid: string) => Promise<void>;
73
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
74
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
75
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
76
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
48
77
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
49
78
  groupLeave: (id: string) => Promise<void>;
@@ -65,7 +94,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
65
94
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
66
95
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
67
96
  groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
68
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
97
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
69
98
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
70
99
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
71
100
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -74,6 +103,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
74
103
  groupFetchAllParticipating: () => Promise<{
75
104
  [_: string]: import("../Types").GroupMetadata;
76
105
  }>;
106
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
77
107
  processingMutex: {
78
108
  mutex<T>(code: () => T | Promise<T>): Promise<T>;
79
109
  };
@@ -85,10 +115,11 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
85
115
  onWhatsApp: (...jids: string[]) => Promise<{
86
116
  jid: string;
87
117
  exists: unknown;
118
+ lid: unknown;
88
119
  }[] | undefined>;
89
120
  fetchBlocklist: () => Promise<string[]>;
90
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
91
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
121
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
122
+ fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
92
123
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
93
124
  removeProfilePicture: (jid: string) => Promise<void>;
94
125
  updateProfileStatus: (status: string) => Promise<void>;
@@ -107,7 +138,6 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
107
138
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
108
139
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
109
140
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
110
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
111
141
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
112
142
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
113
143
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -116,9 +146,9 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
116
146
  id: string;
117
147
  fromMe?: boolean | undefined;
118
148
  }[], star: boolean) => Promise<void>;
119
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
149
+ executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
120
150
  type: "md";
121
- ws: import("./Client").WebSocketClient;
151
+ ws: import("./Client/websocket").WebSocketClient;
122
152
  ev: import("../Types").BaileysEventEmitter & {
123
153
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
124
154
  buffer(): void;
@@ -133,8 +163,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
133
163
  signalRepository: import("../Types").SignalRepository;
134
164
  user: import("../Types").Contact | undefined;
135
165
  generateMessageTag: () => string;
136
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
137
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
166
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
167
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
138
168
  waitForSocketOpen: () => Promise<void>;
139
169
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
140
170
  sendNode: (frame: BinaryNode) => Promise<void>;
@@ -143,7 +173,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
143
173
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
144
174
  uploadPreKeys: (count?: number) => Promise<void>;
145
175
  uploadPreKeysToServerIfRequired: () => Promise<void>;
146
- requestPairingCode: (phoneNumber: string) => Promise<string>;
176
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
147
177
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
148
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
178
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
149
179
  };
@@ -2,11 +2,11 @@
2
2
  /// <reference types="node" />
3
3
  import { Boom } from '@hapi/boom';
4
4
  import { proto } from '../../WAProto';
5
- import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
6
- import { LabelActionBody } from '../Types/Label';
5
+ import { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
7
6
  import { BinaryNode } from '../WABinary';
8
7
  import { USyncQuery } from '../WAUSync';
9
8
  export declare const makeChatsSocket: (config: SocketConfig) => {
9
+ getBotListV2: () => Promise<BotListInfo[]>;
10
10
  processingMutex: {
11
11
  mutex<T>(code: () => T | Promise<T>): Promise<T>;
12
12
  };
@@ -21,10 +21,11 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
21
21
  onWhatsApp: (...jids: string[]) => Promise<{
22
22
  jid: string;
23
23
  exists: unknown;
24
+ lid: unknown;
24
25
  }[] | undefined>;
25
26
  fetchBlocklist: () => Promise<string[]>;
26
- fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
27
27
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
28
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
28
29
  updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
29
30
  removeProfilePicture: (jid: string) => Promise<void>;
30
31
  updateProfileStatus: (status: string) => Promise<void>;
@@ -43,7 +44,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
43
44
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
44
45
  chatModify: (mod: ChatModification, jid: string) => Promise<void>;
45
46
  cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
46
- addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
47
47
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
48
48
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
49
49
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -54,7 +54,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
54
54
  }[], star: boolean) => Promise<void>;
55
55
  executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
56
56
  type: "md";
57
- ws: import("./Client").WebSocketClient;
57
+ ws: import("./Client/websocket").WebSocketClient;
58
58
  ev: import("../Types").BaileysEventEmitter & {
59
59
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
60
60
  buffer(): void;
@@ -69,17 +69,18 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
69
69
  signalRepository: import("../Types").SignalRepository;
70
70
  user: import("../Types").Contact | undefined;
71
71
  generateMessageTag: () => string;
72
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
73
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
72
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
73
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
74
74
  waitForSocketOpen: () => Promise<void>;
75
75
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
76
+ /** sending non-abt props may fix QR scan fail if server expects */
76
77
  sendNode: (frame: BinaryNode) => Promise<void>;
77
78
  logout: (msg?: string | undefined) => Promise<void>;
78
79
  end: (error: Error | undefined) => void;
79
80
  onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
80
81
  uploadPreKeys: (count?: number) => Promise<void>;
81
82
  uploadPreKeysToServerIfRequired: () => Promise<void>;
82
- requestPairingCode: (phoneNumber: string) => Promise<string>;
83
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
83
84
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
84
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
85
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
85
86
  };
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeChatsSocket = void 0;
7
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
8
7
  const boom_1 = require("@hapi/boom");
8
+ const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
9
  const WAProto_1 = require("../../WAProto");
10
10
  const Defaults_1 = require("../Defaults");
11
11
  const Types_1 = require("../Types");
@@ -115,16 +115,46 @@ const makeChatsSocket = (config) => {
115
115
  }]
116
116
  });
117
117
  };
118
+ const getBotListV2 = async () => {
119
+ const resp = await query({
120
+ tag: 'iq',
121
+ attrs: {
122
+ xmlns: 'bot',
123
+ to: WABinary_1.S_WHATSAPP_NET,
124
+ type: 'get'
125
+ },
126
+ content: [{
127
+ tag: 'bot',
128
+ attrs: {
129
+ v: '2'
130
+ }
131
+ }]
132
+ });
133
+ const botNode = (0, WABinary_1.getBinaryNodeChild)(resp, 'bot');
134
+ const botList = [];
135
+ for (const section of (0, WABinary_1.getBinaryNodeChildren)(botNode, 'section')) {
136
+ if (section.attrs.type === 'all') {
137
+ for (const bot of (0, WABinary_1.getBinaryNodeChildren)(section, 'bot')) {
138
+ botList.push({
139
+ jid: bot.attrs.jid,
140
+ personaId: bot.attrs['persona_id']
141
+ });
142
+ }
143
+ }
144
+ }
145
+ return botList;
146
+ };
118
147
  const onWhatsApp = async (...jids) => {
119
148
  const usyncQuery = new WAUSync_1.USyncQuery()
120
- .withContactProtocol();
149
+ .withContactProtocol()
150
+ .withLIDProtocol();
121
151
  for (const jid of jids) {
122
152
  const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
123
153
  usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
124
154
  }
125
155
  const results = await sock.executeUSyncQuery(usyncQuery);
126
156
  if (results) {
127
- return results.list.filter((a) => !!a.contact).map(({ contact, id }) => ({ jid: id, exists: contact }));
157
+ return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
128
158
  }
129
159
  };
130
160
  const fetchStatus = async (...jids) => {
@@ -507,7 +537,7 @@ const makeChatsSocket = (config) => {
507
537
  let presence;
508
538
  const jid = attrs.from;
509
539
  const participant = attrs.participant || attrs.from;
510
- if (shouldIgnoreJid(jid) && jid !== '@s.whatsapp.net') {
540
+ if (shouldIgnoreJid(jid) && jid != '@s.whatsapp.net') {
511
541
  return;
512
542
  }
513
543
  if (tag === 'presence') {
@@ -642,16 +672,6 @@ const makeChatsSocket = (config) => {
642
672
  }
643
673
  }, jid);
644
674
  };
645
- /**
646
- * Adds label
647
- */
648
- const addLabel = (jid, labels) => {
649
- return chatModify({
650
- addLabel: {
651
- ...labels
652
- }
653
- }, jid);
654
- };
655
675
  /**
656
676
  * Adds label for the chats
657
677
  */
@@ -810,6 +830,7 @@ const makeChatsSocket = (config) => {
810
830
  });
811
831
  return {
812
832
  ...sock,
833
+ getBotListV2,
813
834
  processingMutex,
814
835
  fetchPrivacySettings,
815
836
  upsertMessage,
@@ -819,8 +840,8 @@ const makeChatsSocket = (config) => {
819
840
  profilePictureUrl,
820
841
  onWhatsApp,
821
842
  fetchBlocklist,
822
- fetchStatus,
823
843
  fetchDisappearingDuration,
844
+ fetchStatus,
824
845
  updateProfilePicture,
825
846
  removeProfilePicture,
826
847
  updateProfileStatus,
@@ -839,7 +860,6 @@ const makeChatsSocket = (config) => {
839
860
  resyncAppState,
840
861
  chatModify,
841
862
  cleanDirtyBits,
842
- addLabel,
843
863
  addChatLabel,
844
864
  removeChatLabel,
845
865
  addMessageLabel,
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { proto } from '../../WAProto';
4
- import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
4
+ import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
5
5
  import { BinaryNode } from '../WABinary';
6
6
  export declare const makeGroupsSocket: (config: SocketConfig) => {
7
7
  groupMetadata: (jid: string) => Promise<GroupMetadata>;
@@ -36,7 +36,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
36
36
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
37
37
  * @param inviteMessage the message to accept
38
38
  */
39
- groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
39
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
40
40
  groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
41
41
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
42
42
  groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
@@ -45,6 +45,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
45
45
  groupFetchAllParticipating: () => Promise<{
46
46
  [_: string]: GroupMetadata;
47
47
  }>;
48
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
48
49
  processingMutex: {
49
50
  mutex<T>(code: () => T | Promise<T>): Promise<T>;
50
51
  };
@@ -59,10 +60,11 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
59
60
  onWhatsApp: (...jids: string[]) => Promise<{
60
61
  jid: string;
61
62
  exists: unknown;
63
+ lid: unknown;
62
64
  }[] | undefined>;
63
65
  fetchBlocklist: () => Promise<string[]>;
64
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
65
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
66
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
67
+ fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
66
68
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
67
69
  removeProfilePicture: (jid: string) => Promise<void>;
68
70
  updateProfileStatus: (status: string) => Promise<void>;
@@ -81,7 +83,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
81
83
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
82
84
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
83
85
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
84
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
85
86
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
86
87
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
87
88
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -90,9 +91,9 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
90
91
  id: string;
91
92
  fromMe?: boolean | undefined;
92
93
  }[], star: boolean) => Promise<void>;
93
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
94
+ executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
94
95
  type: "md";
95
- ws: import("./Client").WebSocketClient;
96
+ ws: import("./Client/websocket").WebSocketClient;
96
97
  ev: import("../Types").BaileysEventEmitter & {
97
98
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
98
99
  buffer(): void;
@@ -107,8 +108,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
107
108
  signalRepository: import("../Types").SignalRepository;
108
109
  user: import("../Types").Contact | undefined;
109
110
  generateMessageTag: () => string;
110
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
111
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
111
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
112
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
112
113
  waitForSocketOpen: () => Promise<void>;
113
114
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
114
115
  sendNode: (frame: BinaryNode) => Promise<void>;
@@ -117,8 +118,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
117
118
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
118
119
  uploadPreKeys: (count?: number) => Promise<void>;
119
120
  uploadPreKeysToServerIfRequired: () => Promise<void>;
120
- requestPairingCode: (phoneNumber: string) => Promise<string>;
121
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
121
122
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
122
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
123
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
123
124
  };
124
125
  export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;
@@ -69,7 +69,7 @@ const makeGroupsSocket = (config) => {
69
69
  ...sock,
70
70
  groupMetadata,
71
71
  groupCreate: async (subject, participants) => {
72
- const key = (0, Utils_1.generateMessageID)();
72
+ const key = (0, Utils_1.generateMessageIDV2)();
73
73
  const result = await groupQuery('@g.us', 'set', [
74
74
  {
75
75
  tag: 'create',
@@ -163,7 +163,7 @@ const makeGroupsSocket = (config) => {
163
163
  {
164
164
  tag: 'description',
165
165
  attrs: {
166
- ...(description ? { id: (0, Utils_1.generateMessageID)() } : { delete: 'true' }),
166
+ ...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
167
167
  ...(prev ? { prev } : {})
168
168
  },
169
169
  content: description ? [
@@ -277,23 +277,35 @@ const extractGroupMetadata = (result) => {
277
277
  const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
278
278
  let desc;
279
279
  let descId;
280
+ let descOwner;
281
+ let descOwnerPhoneNumber;
282
+ let descTime;
280
283
  if (descChild) {
281
284
  desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
285
+ descOwner = descChild.attrs.participant;
286
+ descOwnerPhoneNumber = descChild.attrs.participant_pn;
282
287
  descId = descChild.attrs.id;
288
+ descTime = +descChild.attrs.t;
283
289
  }
290
+ const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
284
291
  const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
285
292
  const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
286
293
  const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
287
294
  const metadata = {
288
295
  id: groupId,
296
+ addressingMode: group.attrs.addressing_mode,
289
297
  subject: group.attrs.subject,
290
298
  subjectOwner: group.attrs.s_o,
299
+ subjectOwnerPhoneNumber: group.attrs.s_o_pn,
291
300
  subjectTime: +group.attrs.s_t,
292
- size: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
301
+ size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
293
302
  creation: +group.attrs.creation,
294
303
  owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
295
304
  desc,
296
305
  descId,
306
+ descOwner,
307
+ descOwnerPhoneNumber,
308
+ descTime,
297
309
  linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
298
310
  restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
299
311
  announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
@@ -304,6 +316,7 @@ const extractGroupMetadata = (result) => {
304
316
  participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
305
317
  return {
306
318
  id: attrs.jid,
319
+ phoneNumber: attrs.phone_number || attrs.jid,
307
320
  admin: (attrs.type || null),
308
321
  };
309
322
  }),