@queenanya/baileys 7.1.6 → 7.1.7

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.
package/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Baileys - Typescript/Javascript WhatsApp Web API
1
+ # Note:
2
+ **QueenAnya/Baileys is another version of Baileys that was originally created by Adhiraj Singh. ShizoWeb is Maintained and Up-to-dated with all lestest feature [Thanks for Visiting Here]**
3
+
4
+ ## Maintainer Of QueenAnya/Baileys
5
+ ** • Team PikaBotz. **
6
+
7
+ # QueenAnya/Baileys - Typescript/Javascript WhatsApp Web API
2
8
 
3
9
  ### Important Note
4
10
 
@@ -802,6 +808,42 @@ Of course, replace ``` xyz ``` with an actual ID.
802
808
  console.log(response)
803
809
  ```
804
810
 
811
+
812
+ ## Channel
813
+ - To get newsletter info from code
814
+ ```ts
815
+ // https://whatsapp.com/channel/key
816
+ const key = '123wedss972279'
817
+ const result = await sock.getNewsletterInfo(key)
818
+ console.log(result)
819
+ ```
820
+ - To create newsletter
821
+ ```ts
822
+ const result = await sock.createNewsLetter('Name newsletter', 'Description news letter', { url: 'url profile pictur' })
823
+ console.log(result)
824
+ ```
825
+ - To get subscribed newsletters
826
+ ```ts
827
+
828
+ const result = await sock.getSubscribedNewsletters()
829
+ console.log(result)
830
+ ```
831
+ - To toggle mute newsletters
832
+ ```ts
833
+ const result = await sock.toggleMuteNewsletter(jid, true) // true to mute, false to unmute
834
+ console.log(result)
835
+ ```
836
+ - To follow newsletter
837
+ ```ts
838
+ const result = await sock.followNewsletter(jid)
839
+ console.log(result)
840
+ ```
841
+ - To unfollow newsletter
842
+ ```ts
843
+ const result = await sock.unFollowNewsletter(jid)
844
+ console.log(result)
845
+ ```
846
+
805
847
  ## Privacy
806
848
  - To get the privacy settings
807
849
  ``` ts
@@ -60,6 +60,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
60
60
  retryRequestDelayMs: 250,
61
61
  maxMsgRetryCount: 5,
62
62
  fireInitQueries: true,
63
+ ignoreMsgLoading: false,
63
64
  auth: undefined,
64
65
  markOnlineOnConnect: true,
65
66
  syncFullHistory: false,
@@ -76,6 +76,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
76
76
  groupInviteCode: (jid: string) => Promise<string | undefined>;
77
77
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
78
78
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
79
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
79
80
  groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
80
81
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
81
82
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -124,6 +125,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
124
125
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
125
126
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
126
127
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
128
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
127
129
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
128
130
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
129
131
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -3,6 +3,7 @@ import { Boom } from '@hapi/boom';
3
3
  import { proto } from '../../WAProto';
4
4
  import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
5
5
  import { BinaryNode } from '../WABinary';
6
+ import { LabelActionBody } from '../Types/Label';
6
7
  export declare const makeChatsSocket: (config: SocketConfig) => {
7
8
  processingMutex: {
8
9
  mutex<T>(code: () => T | Promise<T>): Promise<T>;
@@ -46,6 +47,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
46
47
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
47
48
  chatModify: (mod: ChatModification, jid: string) => Promise<void>;
48
49
  cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
50
+ addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
49
51
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
50
52
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
51
53
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -661,6 +661,16 @@ const makeChatsSocket = (config) => {
661
661
  }
662
662
  }, jid);
663
663
  };
664
+ /**
665
+ * Adds label
666
+ */
667
+ const addLabel = (jid, labels) => {
668
+ return chatModify({
669
+ addLabel: {
670
+ ...labels
671
+ }
672
+ }, jid);
673
+ };
664
674
  /**
665
675
  * Adds label for the chats
666
676
  */
@@ -847,6 +857,7 @@ const makeChatsSocket = (config) => {
847
857
  resyncAppState,
848
858
  chatModify,
849
859
  cleanDirtyBits,
860
+ addLabel,
850
861
  addChatLabel,
851
862
  removeChatLabel,
852
863
  addMessageLabel,
@@ -23,6 +23,13 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
23
23
  groupInviteCode: (jid: string) => Promise<string | undefined>;
24
24
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
25
25
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
26
+ /**
27
+ * revoke a v4 invite for someone
28
+ * @param groupJid group jid
29
+ * @param invitedJid jid of person you invited
30
+ * @returns true if successful
31
+ */
32
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
26
33
  /**
27
34
  * accept a GroupInviteMessage
28
35
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
@@ -79,6 +86,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
79
86
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
80
87
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
81
88
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
89
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
82
90
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
83
91
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
84
92
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -187,6 +187,16 @@ const makeGroupsSocket = (config) => {
187
187
  const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
188
188
  return result === null || result === void 0 ? void 0 : result.attrs.jid;
189
189
  },
190
+ /**
191
+ * revoke a v4 invite for someone
192
+ * @param groupJid group jid
193
+ * @param invitedJid jid of person you invited
194
+ * @returns true if successful
195
+ */
196
+ groupRevokeInviteV4: async (groupJid, invitedJid) => {
197
+ const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
198
+ return !!result;
199
+ },
190
200
  /**
191
201
  * accept a GroupInviteMessage
192
202
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
@@ -225,7 +235,7 @@ const makeGroupsSocket = (config) => {
225
235
  await upsertMessage({
226
236
  key: {
227
237
  remoteJid: inviteMessage.groupJid,
228
- id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
238
+ id: (0, Utils_1.generateMessageIDV3)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
229
239
  fromMe: false,
230
240
  participant: key.remoteJid,
231
241
  },
@@ -77,6 +77,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
77
77
  groupInviteCode: (jid: string) => Promise<string | undefined>;
78
78
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
79
79
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
80
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
80
81
  groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
81
82
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
82
83
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -125,6 +126,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
125
126
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
126
127
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
127
128
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
129
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
128
130
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
129
131
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
130
132
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -64,6 +64,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
64
64
  groupInviteCode: (jid: string) => Promise<string | undefined>;
65
65
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
66
66
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
67
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
67
68
  groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
68
69
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
69
70
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -112,6 +113,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
112
113
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
113
114
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
114
115
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
116
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
115
117
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
116
118
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
117
119
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -17,7 +17,7 @@ const WABinary_1 = require("../WABinary");
17
17
  const groups_1 = require("./groups");
18
18
  const messages_send_1 = require("./messages-send");
19
19
  const makeMessagesRecvSocket = (config) => {
20
- const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
20
+ const { logger, retryRequestDelayMs, maxMsgRetryCount, ignoreMsgLoading, getMessage, shouldIgnoreJid } = config;
21
21
  const sock = (0, messages_send_1.makeMessagesSocket)(config);
22
22
  const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, } = sock;
23
23
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
@@ -164,7 +164,7 @@ const makeMessagesRecvSocket = (config) => {
164
164
  }
165
165
  };
166
166
  const handleGroupNotification = (participant, child, msg) => {
167
- var _a, _b;
167
+ var _a, _b, _c, _d;
168
168
  const participantJid = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(child, 'participant')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.jid) || participant;
169
169
  switch (child === null || child === void 0 ? void 0 : child.tag) {
170
170
  case 'create':
@@ -217,6 +217,11 @@ const makeMessagesRecvSocket = (config) => {
217
217
  msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
218
218
  msg.messageStubParameters = [child.attrs.subject];
219
219
  break;
220
+ case 'description':
221
+ const description = (_d = (_c = (0, WABinary_1.getBinaryNodeChild)(child, 'body')) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.toString();
222
+ msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION;
223
+ msg.messageStubParameters = description ? [description] : undefined;
224
+ break;
220
225
  case 'announcement':
221
226
  case 'not_announcement':
222
227
  msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;
@@ -626,6 +631,11 @@ const makeMessagesRecvSocket = (config) => {
626
631
  };
627
632
  const handleMessage = async (node) => {
628
633
  var _a, _b;
634
+ if (ignoreMsgLoading && node.attrs.offline) {
635
+ logger.debug({ key: node.attrs.key }, 'ignored offline message');
636
+ await sendMessageAck(node);
637
+ return;
638
+ }
629
639
  if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
630
640
  logger.debug({ key: node.attrs.key }, 'ignored message');
631
641
  await sendMessageAck(node);
@@ -59,6 +59,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
59
59
  groupInviteCode: (jid: string) => Promise<string | undefined>;
60
60
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
61
61
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
62
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
62
63
  groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
63
64
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
64
65
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -107,6 +108,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
107
108
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
108
109
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
109
110
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
111
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
110
112
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
111
113
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
112
114
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -259,7 +259,7 @@ const makeMessagesSocket = (config) => {
259
259
  const isNewsletter = server == 'newsletter';
260
260
  const isStatus = jid === statusJid;
261
261
  const isLid = server === 'lid';
262
- msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
262
+ msgId = msgId || (0, Utils_1.generateMessageIDV3)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
263
263
  useUserDevicesCache = useUserDevicesCache !== false;
264
264
  const participants = [];
265
265
  const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
@@ -528,6 +528,9 @@ const makeMessagesSocket = (config) => {
528
528
  else if (message.interactiveResponseMessage) {
529
529
  return 'native_flow_response';
530
530
  }
531
+ else if (message.groupInviteMessage) {
532
+ return 'url';
533
+ }
531
534
  };
532
535
  const getButtonType = (message) => {
533
536
  if (message.buttonsMessage) {
@@ -677,9 +680,11 @@ const makeMessagesSocket = (config) => {
677
680
  mediaHandle = up.handle;
678
681
  return up;
679
682
  },
683
+ //TODO: CACHE
684
+ getProfilePicUrl: sock.profilePictureUrl,
680
685
  mediaCache: config.mediaCache,
681
686
  options: config.options,
682
- messageId: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
687
+ messageId: (0, Utils_1.generateMessageIDV3)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
683
688
  ...options,
684
689
  });
685
690
  const isDeleteMsg = 'delete' in content && !!content.delete;
@@ -46,8 +46,9 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
46
46
  groupInviteCode: (jid: string) => Promise<string | undefined>;
47
47
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
48
48
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
49
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
49
50
  groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
50
- groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>; /**user is Lid, not Jid */
51
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
51
52
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
52
53
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
53
54
  groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
@@ -97,6 +98,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
97
98
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
98
99
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
99
100
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
101
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
100
102
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
101
103
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
102
104
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -78,6 +78,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
78
78
  groupInviteCode: (jid: string) => Promise<string | undefined>;
79
79
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
80
80
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
81
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
81
82
  groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
82
83
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
83
84
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -126,6 +127,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
126
127
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
127
128
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
128
129
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
130
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
129
131
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
130
132
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
131
133
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -4,6 +4,7 @@ import type { BufferedEventData } from './Events';
4
4
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
5
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
6
  import type { MinimalMessage } from './Message';
7
+ import type { LabelActionBody } from './Label';
7
8
  /** privacy settings in WhatsApp Web */
8
9
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
10
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
@@ -81,6 +82,8 @@ export type ChatModification = {
81
82
  } | {
82
83
  delete: true;
83
84
  lastMessages: LastMessageList;
85
+ } | {
86
+ addLabel: LabelActionBody;
84
87
  } | {
85
88
  addChatLabel: ChatLabelAssociationActionBody;
86
89
  } | {
@@ -10,6 +10,17 @@ export interface Label {
10
10
  /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
11
  predefinedId?: string;
12
12
  }
13
+ export interface LabelActionBody {
14
+ id: string;
15
+ /** Label name */
16
+ name?: string;
17
+ /** Label color ID */
18
+ color?: number;
19
+ /** Is label has been deleted */
20
+ deleted?: boolean;
21
+ /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
22
+ predefinedId?: number;
23
+ }
13
24
  /** WhatsApp has 20 predefined colors */
14
25
  export declare enum LabelColor {
15
26
  Color1 = 0,
@@ -136,6 +136,13 @@ export type ButtonReplyInfo = {
136
136
  id: string;
137
137
  index: number;
138
138
  };
139
+ export type GroupInviteInfo = {
140
+ inviteCode: string;
141
+ inviteExpiration: number;
142
+ text: string;
143
+ jid: string;
144
+ subject: string;
145
+ };
139
146
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
140
147
  productImage: WAMediaUpload;
141
148
  };
@@ -156,6 +163,8 @@ export type AnyRegularMessageContent = (({
156
163
  } | {
157
164
  buttonReply: ButtonReplyInfo;
158
165
  type: 'template' | 'plain';
166
+ } | {
167
+ groupInvite: GroupInviteInfo;
159
168
  } | {
160
169
  listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
161
170
  } | {
@@ -247,6 +256,7 @@ export type MediaGenerationOptions = {
247
256
  };
248
257
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
249
258
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
259
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
250
260
  };
251
261
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
252
262
  /**
@@ -75,6 +75,8 @@ export type SocketConfig = {
75
75
  linkPreviewImageThumbnailWidth: number;
76
76
  /** Should Baileys ask the phone for full history, will be received async */
77
77
  syncFullHistory: boolean;
78
+ /** Ignore Message when offline, default is false */
79
+ ignoreMsgLoading: boolean;
78
80
  /** Should baileys fire init queries automatically, default true */
79
81
  fireInitQueries: boolean;
80
82
  /**
@@ -491,6 +491,22 @@ const chatModificationToAppPatch = (mod, jid) => {
491
491
  operation: OP.SET,
492
492
  };
493
493
  }
494
+ else if ('addLabel' in mod) {
495
+ patch = {
496
+ syncAction: {
497
+ labelEditAction: {
498
+ name: mod.addLabel.name,
499
+ color: mod.addLabel.color,
500
+ predefinedId: mod.addLabel.predefinedId,
501
+ deleted: mod.addLabel.deleted
502
+ }
503
+ },
504
+ index: ['label_edit', mod.addLabel.id],
505
+ type: 'regular',
506
+ apiVersion: 3,
507
+ operation: OP.SET,
508
+ };
509
+ }
494
510
  else if ('addChatLabel' in mod) {
495
511
  patch = {
496
512
  syncAction: {
@@ -44,6 +44,7 @@ export declare const delayCancellable: (ms: number) => {
44
44
  };
45
45
  export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
46
46
  export declare const generateMessageIDV2: (userId?: string) => string;
47
+ export declare const generateMessageIDV3: (userId?: string) => string;
47
48
  export declare const generateMessageID: () => string;
48
49
  export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
49
50
  export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
6
+ exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV3 = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const crypto_1 = require("crypto");
@@ -168,6 +168,7 @@ async function promiseTimeout(ms, promise) {
168
168
  return p;
169
169
  }
170
170
  exports.promiseTimeout = promiseTimeout;
171
+ //Useless but still keep this to avoid unexpected errors and bugs
171
172
  const generateMessageIDV2 = (userId) => {
172
173
  const data = Buffer.alloc(8 + 20 + 16);
173
174
  data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
@@ -181,11 +182,19 @@ const generateMessageIDV2 = (userId) => {
181
182
  const random = (0, crypto_1.randomBytes)(16);
182
183
  random.copy(data, 28);
183
184
  const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
184
- return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 16);
185
+ return 'ANYAWEB' + hash.toString('hex').toUpperCase().substring(0, 18);
185
186
  };
186
187
  exports.generateMessageIDV2 = generateMessageIDV2;
188
+ //Message ID function for ShizoWeb
189
+ //This V3 is RollBack Update to old Message ID
190
+ const generateMessageIDV3 = (userId) => {
191
+ let swebfix = 'ANYAWEB';
192
+ let swebRandom = (0, crypto_1.randomBytes)(5).toString('hex').toUpperCase().substring(0, 10);
193
+ return swebfix + swebRandom;
194
+ };
195
+ exports.generateMessageIDV3 = generateMessageIDV3;
187
196
  // generate a random ID to attach to a message
188
- const generateMessageID = () => '3EB0' + (0, crypto_1.randomBytes)(12).toString('hex').toUpperCase();
197
+ const generateMessageID = () => 'ANYAWEB' + (0, crypto_1.randomBytes)(10).toString('hex').toUpperCase();
189
198
  exports.generateMessageID = generateMessageID;
190
199
  function bindWaitForEvent(ev, event) {
191
200
  return async (check, timeoutMs) => {
@@ -310,6 +310,25 @@ const generateWAMessageContent = async (message, options) => {
310
310
  message.disappearingMessagesInChat;
311
311
  m = (0, exports.prepareDisappearingMessageSettingContent)(exp);
312
312
  }
313
+ else if ('groupInvite' in message) {
314
+ m.groupInviteMessage = {};
315
+ m.groupInviteMessage.inviteCode = message.groupInvite.inviteCode;
316
+ m.groupInviteMessage.inviteExpiration = message.groupInvite.inviteExpiration;
317
+ m.groupInviteMessage.caption = message.groupInvite.text;
318
+ m.groupInviteMessage.groupJid = message.groupInvite.jid;
319
+ m.groupInviteMessage.groupName = message.groupInvite.subject;
320
+ //TODO: use built-in interface and get disappearing mode info etc.
321
+ //TODO: cache / use store!?
322
+ if (options.getProfilePicUrl) {
323
+ const pfpUrl = await options.getProfilePicUrl(message.groupInvite.jid, 'preview');
324
+ if (pfpUrl) {
325
+ const resp = await axios_1.default.get(pfpUrl, { responseType: 'arraybuffer' });
326
+ if (resp.status === 200) {
327
+ m.groupInviteMessage.jpegThumbnail = resp.data;
328
+ }
329
+ }
330
+ }
331
+ }
313
332
  else if ('pin' in message) {
314
333
  m.pinInChatMessage = {};
315
334
  m.messageContextInfo = {};
@@ -103,7 +103,7 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
103
103
  }
104
104
  exports.decryptPollVote = decryptPollVote;
105
105
  const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }) => {
106
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
107
107
  const meId = creds.me.id;
108
108
  const { accountSettings } = creds;
109
109
  const chat = { id: (0, WABinary_1.jidNormalizedUser)((0, exports.getChatId)(message.key)) };
@@ -268,22 +268,27 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
268
268
  chat.name = name;
269
269
  emitGroupUpdate({ subject: name });
270
270
  break;
271
+ case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
272
+ const description = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
273
+ chat.description = description;
274
+ emitGroupUpdate({ desc: description });
275
+ break;
271
276
  case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
272
- const code = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
277
+ const code = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
273
278
  emitGroupUpdate({ inviteCode: code });
274
279
  break;
275
280
  case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
276
- const memberAddValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
281
+ const memberAddValue = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
277
282
  emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
278
283
  break;
279
284
  case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
280
- const approvalMode = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
285
+ const approvalMode = (_k = message.messageStubParameters) === null || _k === void 0 ? void 0 : _k[0];
281
286
  emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
282
287
  break;
283
288
  case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
284
- const participant = (_k = message.messageStubParameters) === null || _k === void 0 ? void 0 : _k[0];
285
- const action = (_l = message.messageStubParameters) === null || _l === void 0 ? void 0 : _l[1];
286
- const method = (_m = message.messageStubParameters) === null || _m === void 0 ? void 0 : _m[2];
289
+ const participant = (_l = message.messageStubParameters) === null || _l === void 0 ? void 0 : _l[0];
290
+ const action = (_m = message.messageStubParameters) === null || _m === void 0 ? void 0 : _m[1];
291
+ const method = (_o = message.messageStubParameters) === null || _o === void 0 ? void 0 : _o[2];
287
292
  emitGroupRequestJoin(participant, action, method);
288
293
  break;
289
294
  }
@@ -296,7 +301,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
296
301
  const meIdNormalised = (0, WABinary_1.jidNormalizedUser)(meId);
297
302
  const pollCreatorJid = (0, generics_1.getKeyAuthor)(creationMsgKey, meIdNormalised);
298
303
  const voterJid = (0, generics_1.getKeyAuthor)(message.key, meIdNormalised);
299
- const pollEncKey = (_o = pollMsg.messageContextInfo) === null || _o === void 0 ? void 0 : _o.messageSecret;
304
+ const pollEncKey = (_p = pollMsg.messageContextInfo) === null || _p === void 0 ? void 0 : _p.messageSecret;
300
305
  try {
301
306
  const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {
302
307
  pollEncKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "7.1.6",
3
+ "version": "7.1.7",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
6
  "whatsapp",