@queenanya/baileys 7.0.5 → 7.1.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.
@@ -23,11 +23,11 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
23
23
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
24
24
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
25
25
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
26
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
26
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
27
27
  getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
28
28
  [key: string]: string;
29
29
  };
30
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
30
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
31
31
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
32
32
  waUploadToServer: import("../Types").WAMediaUploadFunction;
33
33
  fetchPrivacySettings: (force?: boolean) => Promise<{
@@ -35,6 +35,27 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
35
35
  }>;
36
36
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
37
37
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
38
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
39
+ duration: string;
40
+ }>;
41
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
42
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
43
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
44
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
45
+ newsletterRemovePicture: (jid: string) => Promise<void>;
46
+ newsletterUnfollow: (jid: string) => Promise<void>;
47
+ newsletterFollow: (jid: string) => Promise<void>;
48
+ newsletterUnmute: (jid: string) => Promise<void>;
49
+ newsletterMute: (jid: string) => Promise<void>;
50
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
51
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
52
+ newsletterAdminCount: (jid: string) => Promise<number>;
53
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
54
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
55
+ newsletterDelete: (jid: string) => Promise<void>;
56
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
57
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
58
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
38
59
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
39
60
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
40
61
  groupLeave: (id: string) => Promise<void>;
@@ -55,7 +76,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
55
76
  groupInviteCode: (jid: string) => Promise<string | undefined>;
56
77
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
57
78
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
58
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
79
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
59
80
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
60
81
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
61
82
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -445,7 +445,8 @@ const makeChatsSocket = (config) => {
445
445
  const result = await query({
446
446
  tag: 'iq',
447
447
  attrs: {
448
- to: jid,
448
+ target: jid,
449
+ to: WABinary_1.S_WHATSAPP_NET,
449
450
  type: 'get',
450
451
  xmlns: 'w:profile:picture'
451
452
  },
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { proto } from '../../WAProto';
3
- import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
3
+ import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
4
4
  import { BinaryNode } from '../WABinary';
5
5
  export declare const makeGroupsSocket: (config: SocketConfig) => {
6
6
  groupMetadata: (jid: string) => Promise<GroupMetadata>;
@@ -28,7 +28,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
28
28
  * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
29
29
  * @param inviteMessage the message to accept
30
30
  */
31
- groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
31
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
32
32
  groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
33
33
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
34
34
  groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
@@ -24,11 +24,11 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
24
24
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
25
25
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
26
26
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
27
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
27
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
28
28
  getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
29
29
  [key: string]: string;
30
30
  };
31
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
31
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
32
32
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
33
33
  waUploadToServer: import("../Types").WAMediaUploadFunction;
34
34
  fetchPrivacySettings: (force?: boolean) => Promise<{
@@ -36,6 +36,27 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
36
36
  }>;
37
37
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
38
38
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
39
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
40
+ duration: string;
41
+ }>;
42
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
43
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
44
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
45
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
46
+ newsletterRemovePicture: (jid: string) => Promise<void>;
47
+ newsletterUnfollow: (jid: string) => Promise<void>;
48
+ newsletterFollow: (jid: string) => Promise<void>;
49
+ newsletterUnmute: (jid: string) => Promise<void>;
50
+ newsletterMute: (jid: string) => Promise<void>;
51
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
52
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
53
+ newsletterAdminCount: (jid: string) => Promise<number>;
54
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
55
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
56
+ newsletterDelete: (jid: string) => Promise<void>;
57
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
58
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
59
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
39
60
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
40
61
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
41
62
  groupLeave: (id: string) => Promise<void>;
@@ -56,7 +77,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
56
77
  groupInviteCode: (jid: string) => Promise<string | undefined>;
57
78
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
58
79
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
59
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
80
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
60
81
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
61
82
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
62
83
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Boom } from '@hapi/boom';
3
3
  import { proto } from '../../WAProto';
4
- import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
4
+ import { MessageReceiptType, MessageRelayOptions, SocketConfig, WAMessageKey } from '../Types';
5
5
  import { BinaryNode } from '../WABinary';
6
6
  export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
7
7
  sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
@@ -11,11 +11,11 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
11
11
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
12
12
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
13
13
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
14
- sendReceipts: (keys: proto.IMessageKey[], type: MessageReceiptType) => Promise<void>;
14
+ sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
15
15
  getButtonArgs: (message: proto.IMessage) => {
16
16
  [key: string]: string;
17
17
  };
18
- readMessages: (keys: proto.IMessageKey[]) => Promise<void>;
18
+ readMessages: (keys: WAMessageKey[]) => Promise<void>;
19
19
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
20
20
  waUploadToServer: import("../Types").WAMediaUploadFunction;
21
21
  fetchPrivacySettings: (force?: boolean) => Promise<{
@@ -23,6 +23,27 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
23
23
  }>;
24
24
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
25
25
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
26
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
27
+ duration: string;
28
+ }>;
29
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
30
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
31
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
32
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
33
+ newsletterRemovePicture: (jid: string) => Promise<void>;
34
+ newsletterUnfollow: (jid: string) => Promise<void>;
35
+ newsletterFollow: (jid: string) => Promise<void>;
36
+ newsletterUnmute: (jid: string) => Promise<void>;
37
+ newsletterMute: (jid: string) => Promise<void>;
38
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
39
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
40
+ newsletterAdminCount: (jid: string) => Promise<number>;
41
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
42
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
43
+ newsletterDelete: (jid: string) => Promise<void>;
44
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
45
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
46
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
26
47
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
27
48
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
28
49
  groupLeave: (id: string) => Promise<void>;
@@ -43,7 +64,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
43
64
  groupInviteCode: (jid: string) => Promise<string | undefined>;
44
65
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
45
66
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
46
- groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
67
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
47
68
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
48
69
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
49
70
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -256,6 +256,50 @@ const makeMessagesRecvSocket = (config) => {
256
256
  break;
257
257
  }
258
258
  };
259
+ const handleNewsletterNotification = (id, node) => {
260
+ const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
261
+ const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
262
+ const server_id = message.attrs.server_id;
263
+ const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
264
+ const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
265
+ if (reactionsList) {
266
+ const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
267
+ if (reactions.length === 0) {
268
+ ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
269
+ }
270
+ reactions.forEach(item => {
271
+ var _a, _b;
272
+ ev.emit('newsletter.reaction', { id, server_id, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
273
+ });
274
+ }
275
+ if (viewsList.length) {
276
+ viewsList.forEach(item => {
277
+ ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
278
+ });
279
+ }
280
+ };
281
+ const handleMexNewsletterNotification = (id, node) => {
282
+ var _a;
283
+ const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
284
+ const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
285
+ let contentPath;
286
+ if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
287
+ let action;
288
+ if (operation === Types_1.MexOperations.PROMOTE) {
289
+ action = 'promote';
290
+ contentPath = content.data[Types_1.XWAPaths.PROMOTE];
291
+ }
292
+ if (operation === Types_1.MexOperations.DEMOTE) {
293
+ action = 'demote';
294
+ contentPath = content.data[Types_1.XWAPaths.DEMOTE];
295
+ }
296
+ ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
297
+ }
298
+ if (operation === Types_1.MexOperations.UPDATE) {
299
+ contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
300
+ ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
301
+ }
302
+ };
259
303
  const processNotification = async (node) => {
260
304
  var _a, _b, _c;
261
305
  const result = {};
@@ -276,6 +320,12 @@ const makeMessagesRecvSocket = (config) => {
276
320
  logger.debug({ jid }, 'got privacy token update');
277
321
  }
278
322
  break;
323
+ case 'newsletter':
324
+ handleNewsletterNotification(node.attrs.from, child);
325
+ break;
326
+ case 'mex':
327
+ handleMexNewsletterNotification(node.attrs.from, child);
328
+ break;
279
329
  case 'w:gp2':
280
330
  handleGroupNotification(node.attrs.participant, child, result);
281
331
  break;
@@ -667,7 +717,7 @@ const makeMessagesRecvSocket = (config) => {
667
717
  await sendMessageAck(node);
668
718
  };
669
719
  const handleBadAck = async ({ attrs }) => {
670
- const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
720
+ const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, server_id: attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
671
721
  // current hypothesis is that if pash is sent in the ack
672
722
  // it means -- the message hasn't reached all devices yet
673
723
  // we'll retry sending the message here
@@ -18,6 +18,27 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
18
18
  }>;
19
19
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
20
20
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
21
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
22
+ duration: string;
23
+ }>;
24
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
25
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
26
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
27
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
28
+ newsletterRemovePicture: (jid: string) => Promise<void>;
29
+ newsletterUnfollow: (jid: string) => Promise<void>;
30
+ newsletterFollow: (jid: string) => Promise<void>;
31
+ newsletterUnmute: (jid: string) => Promise<void>;
32
+ newsletterMute: (jid: string) => Promise<void>;
33
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
34
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
35
+ newsletterAdminCount: (jid: string) => Promise<number>;
36
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
37
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
38
+ newsletterDelete: (jid: string) => Promise<void>;
39
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
40
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
41
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
21
42
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
22
43
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
23
44
  groupLeave: (id: string) => Promise<void>;
@@ -38,7 +59,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
38
59
  groupInviteCode: (jid: string) => Promise<string | undefined>;
39
60
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
40
61
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
41
- groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
62
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
42
63
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
43
64
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
44
65
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -11,11 +11,11 @@ const Defaults_1 = require("../Defaults");
11
11
  const Utils_1 = require("../Utils");
12
12
  const link_preview_1 = require("../Utils/link-preview");
13
13
  const WABinary_1 = require("../WABinary");
14
- const groups_1 = require("./groups");
14
+ const newsletter_1 = require("./newsletter");
15
15
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
16
16
  const makeMessagesSocket = (config) => {
17
17
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, } = config;
18
- const sock = (0, groups_1.makeGroupsSocket)(config);
18
+ const sock = (0, newsletter_1.makeNewsletterSocket)(config);
19
19
  const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, generateMessageTag, sendNode, groupMetadata, groupToggleEphemeral } = sock;
20
20
  const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
21
21
  stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
@@ -253,12 +253,13 @@ const makeMessagesSocket = (config) => {
253
253
  const { user, server } = (0, WABinary_1.jidDecode)(jid);
254
254
  const statusJid = 'status@broadcast';
255
255
  const isGroup = server === 'g.us';
256
+ const isNewsletter = server == 'newsletter';
256
257
  const isStatus = jid === statusJid;
257
258
  const isLid = server === 'lid';
258
259
  msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
259
260
  useUserDevicesCache = useUserDevicesCache !== false;
260
261
  const participants = [];
261
- const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
262
+ const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
262
263
  const binaryNodeContent = [];
263
264
  const devices = [];
264
265
  const meMsg = {
@@ -347,6 +348,15 @@ const makeMessagesSocket = (config) => {
347
348
  });
348
349
  await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
349
350
  }
351
+ else if (isNewsletter) {
352
+ const patched = await patchMessageBeforeSending(message, []);
353
+ const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
354
+ binaryNodeContent.push({
355
+ tag: 'plaintext',
356
+ attrs: {},
357
+ content: bytes
358
+ });
359
+ }
350
360
  else {
351
361
  const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
352
362
  if (!participant) {
@@ -0,0 +1,133 @@
1
+ /// <reference types="node" />
2
+ import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate } from '../Types';
3
+ import { BinaryNode } from '../WABinary';
4
+ export declare const makeNewsletterSocket: (config: SocketConfig) => {
5
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
6
+ duration: string;
7
+ }>;
8
+ newsletterReactionMode: (jid: string, mode: NewsletterReactionMode) => Promise<void>;
9
+ newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
10
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
11
+ newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
12
+ newsletterRemovePicture: (jid: string) => Promise<void>;
13
+ newsletterUnfollow: (jid: string) => Promise<void>;
14
+ newsletterFollow: (jid: string) => Promise<void>;
15
+ newsletterUnmute: (jid: string) => Promise<void>;
16
+ newsletterMute: (jid: string) => Promise<void>;
17
+ newsletterCreate: (name: string, description: string) => Promise<NewsletterMetadata>;
18
+ newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
19
+ newsletterAdminCount: (jid: string) => Promise<number>;
20
+ /**user is Lid, not Jid */
21
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
22
+ /**user is Lid, not Jid */
23
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
24
+ newsletterDelete: (jid: string) => Promise<void>;
25
+ /**if code wasn't passed, the reaction will be removed (if is reacted) */
26
+ newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
27
+ newsletterFetchMessages: (type: 'invite' | 'jid', key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
28
+ newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
29
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
30
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
31
+ groupLeave: (id: string) => Promise<void>;
32
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
33
+ groupRequestParticipantsList: (jid: string) => Promise<{
34
+ [key: string]: string;
35
+ }[]>;
36
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
37
+ status: string;
38
+ jid: string;
39
+ }[]>;
40
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
41
+ status: string;
42
+ jid: string;
43
+ content: BinaryNode;
44
+ }[]>;
45
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
46
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
47
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
48
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
49
+ 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
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
52
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
53
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
54
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
55
+ groupFetchAllParticipating: () => Promise<{
56
+ [_: string]: import("../Types").GroupMetadata;
57
+ }>;
58
+ processingMutex: {
59
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
60
+ };
61
+ fetchPrivacySettings: (force?: boolean) => Promise<{
62
+ [_: string]: string;
63
+ }>;
64
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
65
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
66
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
67
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
68
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
69
+ onWhatsApp: (...jids: string[]) => Promise<{
70
+ exists: boolean;
71
+ jid: string;
72
+ }[]>;
73
+ fetchBlocklist: () => Promise<string[]>;
74
+ fetchStatus: (jid: string) => Promise<{
75
+ status: string | undefined;
76
+ setAt: Date;
77
+ } | undefined>;
78
+ updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
79
+ removeProfilePicture: (jid: string) => Promise<void>;
80
+ updateProfileStatus: (status: string) => Promise<void>;
81
+ updateProfileName: (name: string) => Promise<void>;
82
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
83
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
84
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
85
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
86
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
87
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
88
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
89
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
90
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
91
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
92
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
93
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
94
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
95
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
96
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
97
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
98
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
99
+ star: (jid: string, messages: {
100
+ id: string;
101
+ fromMe?: boolean | undefined;
102
+ }[], star: boolean) => Promise<void>;
103
+ type: "md";
104
+ ws: any;
105
+ ev: import("../Types").BaileysEventEmitter & {
106
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
107
+ buffer(): void;
108
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
109
+ flush(force?: boolean | undefined): boolean;
110
+ isBuffering(): boolean;
111
+ };
112
+ authState: {
113
+ creds: import("../Types").AuthenticationCreds;
114
+ keys: import("../Types").SignalKeyStoreWithTransaction;
115
+ };
116
+ signalRepository: import("../Types").SignalRepository;
117
+ user: import("../Types").Contact | undefined;
118
+ generateMessageTag: () => string;
119
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
120
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
121
+ waitForSocketOpen: () => Promise<void>;
122
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
123
+ sendNode: (frame: BinaryNode) => Promise<void>;
124
+ logout: (msg?: string | undefined) => Promise<void>;
125
+ end: (error: Error | undefined) => void;
126
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
127
+ uploadPreKeys: (count?: number) => Promise<void>;
128
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
129
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
130
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
131
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
132
+ };
133
+ export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractNewsletterMetadata = exports.makeNewsletterSocket = void 0;
4
+ const Types_1 = require("../Types");
5
+ const Utils_1 = require("../Utils");
6
+ const WABinary_1 = require("../WABinary");
7
+ const groups_1 = require("./groups");
8
+ var QueryIds;
9
+ (function (QueryIds) {
10
+ QueryIds["JOB_MUTATION"] = "7150902998257522";
11
+ QueryIds["METADATA"] = "6620195908089573";
12
+ QueryIds["UNFOLLOW"] = "7238632346214362";
13
+ QueryIds["FOLLOW"] = "7871414976211147";
14
+ QueryIds["UNMUTE"] = "7337137176362961";
15
+ QueryIds["MUTE"] = "25151904754424642";
16
+ QueryIds["CREATE"] = "6996806640408138";
17
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
18
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
19
+ QueryIds["DELETE"] = "8316537688363079";
20
+ QueryIds["DEMOTE"] = "6551828931592903";
21
+ })(QueryIds || (QueryIds = {}));
22
+ const makeNewsletterSocket = (config) => {
23
+ const sock = (0, groups_1.makeGroupsSocket)(config);
24
+ const { authState, signalRepository, query, generateMessageTag } = sock;
25
+ const encoder = new TextEncoder();
26
+ const newsletterQuery = async (jid, type, content) => (query({
27
+ tag: 'iq',
28
+ attrs: {
29
+ id: generateMessageTag(),
30
+ type,
31
+ xmlns: 'newsletter',
32
+ to: jid,
33
+ },
34
+ content
35
+ }));
36
+ const newsletterWMexQuery = async (jid, query_id, content) => (query({
37
+ tag: 'iq',
38
+ attrs: {
39
+ id: generateMessageTag(),
40
+ type: 'get',
41
+ xmlns: 'w:mex',
42
+ to: WABinary_1.S_WHATSAPP_NET,
43
+ },
44
+ content: [
45
+ {
46
+ tag: 'query',
47
+ attrs: { query_id },
48
+ content: encoder.encode(JSON.stringify({ variables: { newsletter_id: jid, ...content } }))
49
+ }
50
+ ]
51
+ }));
52
+ const parseFetchedUpdates = async (node, type) => {
53
+ let child;
54
+ if (type === 'messages')
55
+ child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
56
+ else {
57
+ const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
58
+ child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
59
+ }
60
+ return await Promise.all((0, WABinary_1.getAllBinaryNodeChildren)(child).map(async (messageNode) => {
61
+ var _a, _b;
62
+ messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
63
+ const views = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count;
64
+ const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
65
+ const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
66
+ .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
67
+ let data;
68
+ if (type === 'messages') {
69
+ const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
70
+ await decrypt();
71
+ data = {
72
+ server_id: messageNode.attrs.server_id,
73
+ views: views ? +views : undefined,
74
+ reactions,
75
+ message
76
+ };
77
+ return data;
78
+ }
79
+ else {
80
+ data = {
81
+ server_id: messageNode.attrs.server_id,
82
+ views: views ? +views : undefined,
83
+ reactions
84
+ };
85
+ return data;
86
+ }
87
+ }));
88
+ };
89
+ return {
90
+ ...sock,
91
+ subscribeNewsletterUpdates: async (jid) => {
92
+ var _a;
93
+ const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
94
+ return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
95
+ },
96
+ newsletterReactionMode: async (jid, mode) => {
97
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
98
+ updates: { settings: { reaction_codes: { value: mode } } }
99
+ });
100
+ },
101
+ newsletterUpdateDescription: async (jid, description) => {
102
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
103
+ updates: { description: description || '', settings: null }
104
+ });
105
+ },
106
+ newsletterUpdateName: async (jid, name) => {
107
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
108
+ updates: { name, settings: null }
109
+ });
110
+ },
111
+ newsletterUpdatePicture: async (jid, content) => {
112
+ const { img } = await (0, Utils_1.generateProfilePicture)(content);
113
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
114
+ updates: { picture: img.toString('base64'), settings: null }
115
+ });
116
+ },
117
+ newsletterRemovePicture: async (jid) => {
118
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
119
+ updates: { picture: '', settings: null }
120
+ });
121
+ },
122
+ newsletterUnfollow: async (jid) => {
123
+ await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
124
+ },
125
+ newsletterFollow: async (jid) => {
126
+ await newsletterWMexQuery(jid, QueryIds.FOLLOW);
127
+ },
128
+ newsletterUnmute: async (jid) => {
129
+ await newsletterWMexQuery(jid, QueryIds.UNMUTE);
130
+ },
131
+ newsletterMute: async (jid) => {
132
+ await newsletterWMexQuery(jid, QueryIds.MUTE);
133
+ },
134
+ newsletterCreate: async (name, description) => {
135
+ /**tos query */
136
+ await query({
137
+ tag: 'iq',
138
+ attrs: {
139
+ to: WABinary_1.S_WHATSAPP_NET,
140
+ xmlns: 'tos',
141
+ id: generateMessageTag(),
142
+ type: 'set'
143
+ },
144
+ content: [
145
+ {
146
+ tag: 'notice',
147
+ attrs: {
148
+ id: '20601218',
149
+ stage: '5'
150
+ },
151
+ content: []
152
+ }
153
+ ]
154
+ });
155
+ const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
156
+ input: { name, description }
157
+ });
158
+ return (0, exports.extractNewsletterMetadata)(result, true);
159
+ },
160
+ newsletterMetadata: async (type, key, role) => {
161
+ const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
162
+ input: {
163
+ key,
164
+ type: type.toUpperCase(),
165
+ view_role: role || 'GUEST'
166
+ },
167
+ fetch_viewer_metadata: true,
168
+ fetch_full_image: true,
169
+ fetch_creation_time: true
170
+ });
171
+ return (0, exports.extractNewsletterMetadata)(result);
172
+ },
173
+ newsletterAdminCount: async (jid) => {
174
+ var _a, _b;
175
+ const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
176
+ const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
177
+ return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
178
+ },
179
+ /**user is Lid, not Jid */
180
+ newsletterChangeOwner: async (jid, user) => {
181
+ await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
182
+ user_id: user
183
+ });
184
+ },
185
+ /**user is Lid, not Jid */
186
+ newsletterDemote: async (jid, user) => {
187
+ await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
188
+ user_id: user
189
+ });
190
+ },
191
+ newsletterDelete: async (jid) => {
192
+ await newsletterWMexQuery(jid, QueryIds.DELETE);
193
+ },
194
+ /**if code wasn't passed, the reaction will be removed (if is reacted) */
195
+ newsletterReactMessage: async (jid, server_id, code) => {
196
+ await query({
197
+ tag: 'message',
198
+ attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
199
+ content: [{
200
+ tag: 'reaction',
201
+ attrs: code ? { code } : {}
202
+ }]
203
+ });
204
+ },
205
+ newsletterFetchMessages: async (type, key, count, after) => {
206
+ const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
207
+ {
208
+ tag: 'messages',
209
+ attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100' }
210
+ }
211
+ ]);
212
+ return await parseFetchedUpdates(result, 'messages');
213
+ },
214
+ newsletterFetchUpdates: async (jid, count, after, since) => {
215
+ const result = await newsletterQuery(jid, 'get', [
216
+ {
217
+ tag: 'message_updates',
218
+ attrs: { count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100', since: (since === null || since === void 0 ? void 0 : since.toString()) || '0' }
219
+ }
220
+ ]);
221
+ return await parseFetchedUpdates(result, 'updates');
222
+ }
223
+ };
224
+ };
225
+ exports.makeNewsletterSocket = makeNewsletterSocket;
226
+ const extractNewsletterMetadata = (node, isCreate) => {
227
+ var _a, _b, _c, _d, _e;
228
+ const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
229
+ const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
230
+ const metadata = {
231
+ id: metadataPath.id,
232
+ state: metadataPath.state.type,
233
+ creation_time: +metadataPath.thread_metadata.creation_time,
234
+ name: metadataPath.thread_metadata.name.text,
235
+ nameTime: +metadataPath.thread_metadata.name.update_time,
236
+ description: metadataPath.thread_metadata.description.text,
237
+ descriptionTime: +metadataPath.thread_metadata.description.update_time,
238
+ invite: metadataPath.thread_metadata.invite,
239
+ handle: metadataPath.thread_metadata.handle,
240
+ picture: metadataPath.thread_metadata.picture.direct_path || null,
241
+ preview: metadataPath.thread_metadata.preview.direct_path || null,
242
+ reaction_codes: (_e = (_d = (_c = metadataPath.thread_metadata) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.reaction_codes) === null || _e === void 0 ? void 0 : _e.value,
243
+ subscribers: +metadataPath.thread_metadata.subscribers_count,
244
+ verification: metadataPath.thread_metadata.verification,
245
+ viewer_metadata: metadataPath.viewer_metadata
246
+ };
247
+ return metadata;
248
+ };
249
+ exports.extractNewsletterMetadata = extractNewsletterMetadata;
@@ -25,11 +25,11 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
25
25
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
26
26
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
27
27
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
28
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
28
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
29
29
  getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
30
30
  [key: string]: string;
31
31
  };
32
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
32
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
33
33
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
34
34
  waUploadToServer: import("../Types").WAMediaUploadFunction;
35
35
  fetchPrivacySettings: (force?: boolean) => Promise<{
@@ -37,6 +37,27 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
37
37
  }>;
38
38
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
39
39
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
40
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
41
+ duration: string;
42
+ }>;
43
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
44
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
45
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
46
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
47
+ newsletterRemovePicture: (jid: string) => Promise<void>;
48
+ newsletterUnfollow: (jid: string) => Promise<void>;
49
+ newsletterFollow: (jid: string) => Promise<void>;
50
+ newsletterUnmute: (jid: string) => Promise<void>;
51
+ newsletterMute: (jid: string) => Promise<void>;
52
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
53
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
54
+ newsletterAdminCount: (jid: string) => Promise<number>;
55
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
56
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
57
+ newsletterDelete: (jid: string) => Promise<void>;
58
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
59
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
60
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
40
61
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
41
62
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
42
63
  groupLeave: (id: string) => Promise<void>;
@@ -57,7 +78,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
57
78
  groupInviteCode: (jid: string) => Promise<string | undefined>;
58
79
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
59
80
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
60
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
81
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
61
82
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
62
83
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
63
84
  groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
@@ -9,6 +9,7 @@ import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
11
  import { ConnectionState } from './State';
12
+ import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
12
13
  export type BaileysEventMap = {
13
14
  /** connection state has been updated -- WS closed, opened, connecting etc. */
14
15
  'connection.update': Partial<ConnectionState>;
@@ -85,6 +86,32 @@ export type BaileysEventMap = {
85
86
  action: RequestJoinAction;
86
87
  method: RequestJoinMethod;
87
88
  };
89
+ 'newsletter.reaction': {
90
+ id: string;
91
+ server_id: string;
92
+ reaction: {
93
+ code?: string;
94
+ count?: number;
95
+ removed?: boolean;
96
+ };
97
+ };
98
+ 'newsletter.view': {
99
+ id: string;
100
+ server_id: string;
101
+ count: number;
102
+ };
103
+ /**don't handles subscribe/unsubscribe actions */
104
+ 'newsletter-participants.update': {
105
+ id: string;
106
+ author: string;
107
+ user: string;
108
+ new_role: NewsletterViewRole;
109
+ action: SubscriberAction;
110
+ };
111
+ 'newsletter-settings.update': {
112
+ id: string;
113
+ update: NewsletterSettingsUpdate;
114
+ };
88
115
  'blocklist.set': {
89
116
  blocklist: string[];
90
117
  };
@@ -14,7 +14,9 @@ export type WAMessage = proto.IWebMessageInfo;
14
14
  export type WAMessageContent = proto.IMessage;
15
15
  export type WAContactMessage = proto.Message.IContactMessage;
16
16
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
17
- export type WAMessageKey = proto.IMessageKey;
17
+ export type WAMessageKey = proto.IMessageKey & {
18
+ server_id?: string;
19
+ };
18
20
  export type WATextMessage = proto.Message.IExtendedTextMessage;
19
21
  export type WAContextInfo = proto.IContextInfo;
20
22
  export type WALocationMessage = proto.Message.ILocationMessage;
@@ -0,0 +1,79 @@
1
+ import { proto } from '../../WAProto';
2
+ export type NewsletterReactionMode = 'ALL' | 'BASIC' | 'NONE';
3
+ export type NewsletterState = 'ACTIVE' | 'GEOSUSPENDED' | 'SUSPENDED';
4
+ export type NewsletterVerification = 'VERIFIED' | 'UNVERIFIED';
5
+ export type NewsletterMute = 'ON' | 'OFF' | 'UNDEFINED';
6
+ export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
7
+ export type NewsletterViewerMetadata = {
8
+ mute: NewsletterMute;
9
+ view_role: NewsletterViewRole;
10
+ };
11
+ export type NewsletterMetadata = {
12
+ /**jid of newsletter */
13
+ id: string;
14
+ /**state of newsletter */
15
+ state: NewsletterState;
16
+ /**creation timestamp of newsletter */
17
+ creation_time: number;
18
+ /**name of newsletter */
19
+ name: string;
20
+ /**timestamp of last name modification of newsletter */
21
+ nameTime: number;
22
+ /**description of newsletter */
23
+ description: string;
24
+ /**timestamp of last description modification of newsletter */
25
+ descriptionTime: number;
26
+ /**invite code of newsletter */
27
+ invite: string;
28
+ /**i dont know */
29
+ handle: null;
30
+ /**direct path of picture */
31
+ picture: string | null;
32
+ /**direct path of picture preview (lower quality) */
33
+ preview: string | null;
34
+ /**reaction mode of newsletter */
35
+ reaction_codes?: NewsletterReactionMode;
36
+ /**subscribers count of newsletter */
37
+ subscribers: number;
38
+ /**verification state of newsletter */
39
+ verification: NewsletterVerification;
40
+ /**viewer metadata */
41
+ viewer_metadata: NewsletterViewerMetadata;
42
+ };
43
+ export type SubscriberAction = 'promote' | 'demote';
44
+ export type ReactionModeUpdate = {
45
+ reaction_codes: {
46
+ blocked_codes: null;
47
+ enabled_ts_sec: null;
48
+ value: NewsletterReactionMode;
49
+ };
50
+ };
51
+ /**only exists reaction mode update */
52
+ export type NewsletterSettingsUpdate = ReactionModeUpdate;
53
+ export type NewsletterReaction = {
54
+ count: number;
55
+ code: string;
56
+ };
57
+ export type NewsletterFetchedUpdate = {
58
+ /**id of message in newsletter, starts from 100 */
59
+ server_id: string;
60
+ /**count of views in this message */
61
+ views?: number;
62
+ /**reactions in this message */
63
+ reactions: NewsletterReaction[];
64
+ /**the message, if you requested only updates, you will not receive message */
65
+ message?: proto.IWebMessageInfo;
66
+ };
67
+ export declare enum MexOperations {
68
+ PROMOTE = "NotificationNewsletterAdminPromote",
69
+ DEMOTE = "NotificationNewsletterAdminDemote",
70
+ UPDATE = "NotificationNewsletterUpdate"
71
+ }
72
+ export declare enum XWAPaths {
73
+ PROMOTE = "xwa2_notify_newsletter_admin_promote",
74
+ DEMOTE = "xwa2_notify_newsletter_admin_demote",
75
+ ADMIN_COUNT = "xwa2_newsletter_admin",
76
+ CREATE = "xwa2_newsletter_create",
77
+ NEWSLETTER = "xwa2_newsletter",
78
+ METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
79
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XWAPaths = exports.MexOperations = void 0;
4
+ var MexOperations;
5
+ (function (MexOperations) {
6
+ MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
+ MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
+ MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
+ })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
10
+ var XWAPaths;
11
+ (function (XWAPaths) {
12
+ XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
13
+ XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
14
+ XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
15
+ XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
+ XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
+ XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
+ })(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
@@ -1,5 +1,6 @@
1
1
  export * from './Auth';
2
2
  export * from './GroupMetadata';
3
+ export * from './Newsletter';
3
4
  export * from './Chat';
4
5
  export * from './Contact';
5
6
  export * from './State';
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.DisconnectReason = void 0;
18
18
  __exportStar(require("./Auth"), exports);
19
19
  __exportStar(require("./GroupMetadata"), exports);
20
+ __exportStar(require("./Newsletter"), exports);
20
21
  __exportStar(require("./Chat"), exports);
21
22
  __exportStar(require("./Contact"), exports);
22
23
  __exportStar(require("./State"), exports);
@@ -11,6 +11,7 @@ const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
11
11
  * @note this will only parse the message, not decrypt it
12
12
  */
13
13
  function decodeMessageNode(stanza, meId, meLid) {
14
+ var _a, _b, _c;
14
15
  let msgType;
15
16
  let chatId;
16
17
  let author;
@@ -54,6 +55,11 @@ function decodeMessageNode(stanza, meId, meLid) {
54
55
  author = participant;
55
56
  chatId = from;
56
57
  }
58
+ else if ((0, WABinary_1.isJidNewsletter)(from)) {
59
+ msgType = 'newsletter';
60
+ author = from;
61
+ chatId = from;
62
+ }
57
63
  else if ((0, WABinary_1.isJidBroadcast)(from)) {
58
64
  if (!participant) {
59
65
  throw new boom_1.Boom('No participant in group message');
@@ -71,13 +77,14 @@ function decodeMessageNode(stanza, meId, meLid) {
71
77
  else {
72
78
  throw new boom_1.Boom('Unknown message type', { data: stanza });
73
79
  }
74
- const fromMe = ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
75
- const pushname = stanza.attrs.notify;
80
+ const fromMe = (0, WABinary_1.isJidNewsletter)(from) ? !!((_a = stanza.attrs) === null || _a === void 0 ? void 0 : _a.is_sender) || false : ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
81
+ const pushname = (_b = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _b === void 0 ? void 0 : _b.notify;
76
82
  const key = {
77
83
  remoteJid: chatId,
78
84
  fromMe,
79
85
  id: msgId,
80
- participant
86
+ participant,
87
+ server_id: (_c = stanza.attrs) === null || _c === void 0 ? void 0 : _c.server_id
81
88
  };
82
89
  const fullMessage = {
83
90
  key,
@@ -111,7 +118,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
111
118
  const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
112
119
  fullMessage.verifiedBizName = details.verifiedName;
113
120
  }
114
- if (tag !== 'enc') {
121
+ if (tag !== 'enc' && tag !== 'plaintext') {
115
122
  continue;
116
123
  }
117
124
  if (!(content instanceof Uint8Array)) {
@@ -138,11 +145,14 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
138
145
  ciphertext: content
139
146
  });
140
147
  break;
148
+ case undefined:
149
+ msgBuffer = content;
150
+ break;
141
151
  default:
142
152
  throw new Error(`Unknown e2e type: ${e2eType}`);
143
153
  }
144
- let msg = WAProto_1.proto.Message.decode((0, generics_1.unpadRandomMax16)(msgBuffer));
145
- msg = ((_a = msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
154
+ let msg = WAProto_1.proto.Message.decode(tag === 'plaintext' ? msgBuffer : (0, generics_1.unpadRandomMax16)(msgBuffer));
155
+ msg = ((_a = msg === null || msg === void 0 ? void 0 : msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
146
156
  if (msg.senderKeyDistributionMessage) {
147
157
  try {
148
158
  await repository.processSenderKeyDistributionMessage({
@@ -23,6 +23,7 @@ export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, m
23
23
  export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;
24
24
  export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;
25
25
  export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;
26
+ export declare const encodeNewsletterMessage: (message: proto.IMessage) => Uint8Array;
26
27
  export declare const generateRegistrationId: () => number;
27
28
  export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;
28
29
  export declare const toNumber: (t: Long | number | null | undefined) => number;
@@ -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.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.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");
@@ -84,6 +84,8 @@ const unpadRandomMax16 = (e) => {
84
84
  exports.unpadRandomMax16 = unpadRandomMax16;
85
85
  const encodeWAMessage = (message) => ((0, exports.writeRandomPadMax16)(WAProto_1.proto.Message.encode(message).finish()));
86
86
  exports.encodeWAMessage = encodeWAMessage;
87
+ const encodeNewsletterMessage = (message) => (WAProto_1.proto.Message.encode(message).finish());
88
+ exports.encodeNewsletterMessage = encodeNewsletterMessage;
87
89
  const generateRegistrationId = () => {
88
90
  return Uint16Array.from((0, crypto_1.randomBytes)(2))[0] & 16383;
89
91
  };
@@ -92,7 +92,7 @@ export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logg
92
92
  */
93
93
  export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
94
94
  export declare const decodeMediaRetryNode: (node: BinaryNode) => {
95
- key: proto.IMessageKey;
95
+ key: import("../Types").WAMessageKey;
96
96
  media?: {
97
97
  ciphertext: Uint8Array;
98
98
  iv: Uint8Array;
@@ -464,7 +464,8 @@ const generateWAMessageFromContent = (jid, message, options) => {
464
464
  const key = (0, exports.getContentType)(innerMessage);
465
465
  const timestamp = (0, generics_1.unixTimestampSeconds)(options.timestamp);
466
466
  const { quoted, userJid } = options;
467
- if (quoted) {
467
+ // only set quoted if isn't a newsletter message
468
+ if (quoted && !(0, WABinary_1.isJidNewsletter)(jid)) {
468
469
  const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid);
469
470
  let quotedMsg = (0, exports.normalizeMessageContent)(quoted.message);
470
471
  const msgType = (0, exports.getContentType)(quotedMsg);
@@ -491,7 +492,9 @@ const generateWAMessageFromContent = (jid, message, options) => {
491
492
  // and it's not a protocol message -- delete, toggle disappear message
492
493
  key !== 'protocolMessage' &&
493
494
  // already not converted to disappearing message
494
- key !== 'ephemeralMessage') {
495
+ key !== 'ephemeralMessage' &&
496
+ // newsletter not accept disappearing messages
497
+ !(0, WABinary_1.isJidNewsletter)(jid)) {
495
498
  innerMessage[key].contextInfo = {
496
499
  ...(innerMessage[key].contextInfo || {}),
497
500
  expiration: options.ephemeralExpiration || Defaults_1.WA_DEFAULT_EPHEMERAL,
@@ -3,7 +3,7 @@ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
3
  export declare const SERVER_JID = "server@c.us";
4
4
  export declare const PSA_WID = "0@c.us";
5
5
  export declare const STORIES_JID = "status@broadcast";
6
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid';
6
+ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter';
7
7
  export type JidWithDevice = {
8
8
  user: string;
9
9
  device?: number;
@@ -24,6 +24,8 @@ export declare const isLidUser: (jid: string | undefined) => boolean | undefined
24
24
  export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
25
25
  /** is the jid a group */
26
26
  export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
27
+ /** is the jid a newsletter */
28
+ export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
27
29
  /** is the jid the status broadcast */
28
30
  export declare const isJidStatusBroadcast: (jid: string) => boolean;
29
31
  export declare const jidNormalizedUser: (jid: string | undefined) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jidNormalizedUser = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
3
+ exports.jidNormalizedUser = exports.isJidStatusBroadcast = exports.isJidNewsletter = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
4
  exports.S_WHATSAPP_NET = '@s.whatsapp.net';
5
5
  exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
6
6
  exports.SERVER_JID = 'server@c.us';
@@ -45,6 +45,9 @@ exports.isJidBroadcast = isJidBroadcast;
45
45
  /** is the jid a group */
46
46
  const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
47
47
  exports.isJidGroup = isJidGroup;
48
+ /** is the jid a newsletter */
49
+ const isJidNewsletter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@newsletter'));
50
+ exports.isJidNewsletter = isJidNewsletter;
48
51
  /** is the jid the status broadcast */
49
52
  const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
50
53
  exports.isJidStatusBroadcast = isJidStatusBroadcast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "7.0.5",
3
+ "version": "7.1.0",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -60,6 +60,7 @@
60
60
  "olduserm": "npm:megajs@1.1.7",
61
61
  "pastebin-js": "latest",
62
62
  "pastebin-ts": "latest",
63
+ "pastedeno": "npm:@teamolduser/pastedeno",
63
64
  "pino": "^7.0.0",
64
65
  "protobufjs": "^7.2.4",
65
66
  "release-it": "^15.10.3",
@@ -85,6 +86,7 @@
85
86
  "olduserm": "npm:megajs@1.1.7",
86
87
  "pastebin-js": "latest",
87
88
  "pastebin-ts": "latest",
89
+ "pastedeno": "npm:@teamolduser/pastedeno",
88
90
  "qrcode-terminal": "^0.12.0",
89
91
  "release-it": "^15.10.3",
90
92
  "sharp": "^0.32.6",