@d0v3riz/baileys 6.7.20 → 6.7.22

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.
@@ -0,0 +1,141 @@
1
+ import type { WAMediaUpload } from '../Types';
2
+ import { NewsletterMetadata, NewsletterUpdate } from '../Types';
3
+ import { GroupsSocket } from './groups';
4
+ export declare const makeNewsletterSocket: (sock: GroupsSocket) => {
5
+ newsletterCreate: (name: string, description?: string) => Promise<NewsletterMetadata>;
6
+ newsletterUpdate: (jid: string, updates: NewsletterUpdate) => Promise<unknown>;
7
+ newsletterSubscribers: (jid: string) => Promise<{
8
+ subscribers: number;
9
+ }>;
10
+ newsletterMetadata: (type: "invite" | "jid", key: string) => Promise<NewsletterMetadata | null>;
11
+ newsletterFollow: (jid: string) => Promise<unknown>;
12
+ newsletterUnfollow: (jid: string) => Promise<unknown>;
13
+ newsletterMute: (jid: string) => Promise<unknown>;
14
+ newsletterUnmute: (jid: string) => Promise<unknown>;
15
+ newsletterUpdateName: (jid: string, name: string) => Promise<unknown>;
16
+ newsletterUpdateDescription: (jid: string, description: string) => Promise<unknown>;
17
+ newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<unknown>;
18
+ newsletterRemovePicture: (jid: string) => Promise<unknown>;
19
+ newsletterReactMessage: (jid: string, serverId: string, reaction?: string) => Promise<void>;
20
+ newsletterFetchMessages: (jid: string, count: number, since: number, after: number) => Promise<any>;
21
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
22
+ duration: string;
23
+ } | null>;
24
+ newsletterAdminCount: (jid: string) => Promise<number>;
25
+ newsletterChangeOwner: (jid: string, newOwnerJid: string) => Promise<void>;
26
+ newsletterDemote: (jid: string, userJid: string) => Promise<void>;
27
+ newsletterDelete: (jid: string) => Promise<void>;
28
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
29
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
30
+ groupLeave: (id: string) => Promise<void>;
31
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
32
+ groupRequestParticipantsList: (jid: string) => Promise<{
33
+ [key: string]: string;
34
+ }[]>;
35
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
36
+ status: string;
37
+ jid: string;
38
+ }[]>;
39
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
40
+ status: string;
41
+ jid: string;
42
+ content: import("../WABinary").BinaryNode;
43
+ }[]>;
44
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
45
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
46
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
47
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
48
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
49
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
50
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
51
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
52
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
53
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
54
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
55
+ groupFetchAllParticipating: () => Promise<{
56
+ [_: string]: import("../Types").GroupMetadata;
57
+ }>;
58
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
59
+ processingMutex: {
60
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
61
+ };
62
+ fetchPrivacySettings: (force?: boolean) => Promise<{
63
+ [_: string]: string;
64
+ }>;
65
+ upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
66
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
67
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
68
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
69
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
70
+ onWhatsApp: (...jids: string[]) => Promise<{
71
+ jid: string;
72
+ exists: unknown;
73
+ lid: unknown;
74
+ }[] | undefined>;
75
+ fetchBlocklist: () => Promise<string[]>;
76
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
77
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
78
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
79
+ width: number;
80
+ height: number;
81
+ }) => Promise<void>;
82
+ removeProfilePicture: (jid: string) => Promise<void>;
83
+ updateProfileStatus: (status: string) => Promise<void>;
84
+ updateProfileName: (name: string) => Promise<void>;
85
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
86
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
87
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
88
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
89
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
90
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
91
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
92
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
93
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
94
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
95
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
96
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
97
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
98
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
99
+ addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
100
+ removeContact: (jid: string) => Promise<void>;
101
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
102
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
103
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
104
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
105
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
106
+ star: (jid: string, messages: {
107
+ id: string;
108
+ fromMe?: boolean;
109
+ }[], star: boolean) => Promise<void>;
110
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
111
+ type: "md";
112
+ ws: import("./Client").WebSocketClient;
113
+ ev: import("../Types").BaileysEventEmitter & {
114
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
115
+ buffer(): void;
116
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
117
+ flush(force?: boolean): boolean;
118
+ isBuffering(): boolean;
119
+ };
120
+ authState: {
121
+ creds: import("../Types").AuthenticationCreds;
122
+ keys: import("../Types").SignalKeyStoreWithTransaction;
123
+ };
124
+ signalRepository: import("../Types").SignalRepository;
125
+ user: import("../Types").Contact | undefined;
126
+ generateMessageTag: () => string;
127
+ query: (node: import("../WABinary").BinaryNode, timeoutMs?: number) => Promise<any>;
128
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
129
+ waitForSocketOpen: () => Promise<void>;
130
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
131
+ sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
132
+ logout: (msg?: string) => Promise<void>;
133
+ end: (error: Error | undefined) => void;
134
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
135
+ uploadPreKeys: (count?: number) => Promise<void>;
136
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
137
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
138
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
139
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
140
+ };
141
+ export type NewsletterSocket = ReturnType<typeof makeNewsletterSocket>;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeNewsletterSocket = void 0;
4
+ const Types_1 = require("../Types");
5
+ const messages_media_1 = require("../Utils/messages-media");
6
+ const WABinary_1 = require("../WABinary");
7
+ const mex_1 = require("./mex");
8
+ const parseNewsletterCreateResponse = (response) => {
9
+ const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
10
+ return {
11
+ id: id,
12
+ owner: undefined,
13
+ name: thread.name.text,
14
+ creation_time: parseInt(thread.creation_time, 10),
15
+ description: thread.description.text,
16
+ invite: thread.invite,
17
+ subscribers: parseInt(thread.subscribers_count, 10),
18
+ verification: thread.verification,
19
+ picture: {
20
+ id: thread.picture.id,
21
+ directPath: thread.picture.direct_path
22
+ },
23
+ mute_state: viewer.mute
24
+ };
25
+ };
26
+ const parseNewsletterMetadata = (result) => {
27
+ if (typeof result !== 'object' || result === null) {
28
+ return null;
29
+ }
30
+ if ('id' in result && typeof result.id === 'string') {
31
+ return result;
32
+ }
33
+ if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
34
+ return result.result;
35
+ }
36
+ return null;
37
+ };
38
+ const makeNewsletterSocket = (sock) => {
39
+ const { query, generateMessageTag } = sock;
40
+ const executeWMexQuery = (variables, queryId, dataPath) => {
41
+ return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag);
42
+ };
43
+ const newsletterUpdate = async (jid, updates) => {
44
+ const variables = {
45
+ newsletter_id: jid,
46
+ updates: {
47
+ ...updates,
48
+ settings: null
49
+ }
50
+ };
51
+ return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
52
+ };
53
+ return {
54
+ ...sock,
55
+ newsletterCreate: async (name, description) => {
56
+ const variables = {
57
+ input: {
58
+ name,
59
+ description: description !== null && description !== void 0 ? description : null
60
+ }
61
+ };
62
+ const rawResponse = await executeWMexQuery(variables, Types_1.QueryIds.CREATE, Types_1.XWAPaths.xwa2_newsletter_create);
63
+ return parseNewsletterCreateResponse(rawResponse);
64
+ },
65
+ newsletterUpdate,
66
+ newsletterSubscribers: async (jid) => {
67
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.SUBSCRIBERS, Types_1.XWAPaths.xwa2_newsletter_subscribers);
68
+ },
69
+ newsletterMetadata: async (type, key) => {
70
+ const variables = {
71
+ fetch_creation_time: true,
72
+ fetch_full_image: true,
73
+ fetch_viewer_metadata: true,
74
+ input: {
75
+ key,
76
+ type: type.toUpperCase()
77
+ }
78
+ };
79
+ const result = await executeWMexQuery(variables, Types_1.QueryIds.METADATA, Types_1.XWAPaths.xwa2_newsletter_metadata);
80
+ return parseNewsletterMetadata(result);
81
+ },
82
+ newsletterFollow: (jid) => {
83
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow);
84
+ },
85
+ newsletterUnfollow: (jid) => {
86
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNFOLLOW, Types_1.XWAPaths.xwa2_newsletter_unfollow);
87
+ },
88
+ newsletterMute: (jid) => {
89
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2);
90
+ },
91
+ newsletterUnmute: (jid) => {
92
+ return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNMUTE, Types_1.XWAPaths.xwa2_newsletter_unmute_v2);
93
+ },
94
+ newsletterUpdateName: async (jid, name) => {
95
+ return await newsletterUpdate(jid, { name });
96
+ },
97
+ newsletterUpdateDescription: async (jid, description) => {
98
+ return await newsletterUpdate(jid, { description });
99
+ },
100
+ newsletterUpdatePicture: async (jid, content) => {
101
+ const { img } = await (0, messages_media_1.generateProfilePicture)(content);
102
+ return await newsletterUpdate(jid, { picture: img.toString('base64') });
103
+ },
104
+ newsletterRemovePicture: async (jid) => {
105
+ return await newsletterUpdate(jid, { picture: '' });
106
+ },
107
+ newsletterReactMessage: async (jid, serverId, reaction) => {
108
+ await query({
109
+ tag: 'message',
110
+ attrs: {
111
+ to: jid,
112
+ ...(reaction ? {} : { edit: '7' }),
113
+ type: 'reaction',
114
+ server_id: serverId,
115
+ id: generateMessageTag()
116
+ },
117
+ content: [
118
+ {
119
+ tag: 'reaction',
120
+ attrs: reaction ? { code: reaction } : {}
121
+ }
122
+ ]
123
+ });
124
+ },
125
+ newsletterFetchMessages: async (jid, count, since, after) => {
126
+ const messageUpdateAttrs = {
127
+ count: count.toString()
128
+ };
129
+ if (typeof since === 'number') {
130
+ messageUpdateAttrs.since = since.toString();
131
+ }
132
+ if (after) {
133
+ messageUpdateAttrs.after = after.toString();
134
+ }
135
+ const result = await query({
136
+ tag: 'iq',
137
+ attrs: {
138
+ id: generateMessageTag(),
139
+ type: 'get',
140
+ xmlns: 'newsletter',
141
+ to: jid
142
+ },
143
+ content: [
144
+ {
145
+ tag: 'message_updates',
146
+ attrs: messageUpdateAttrs
147
+ }
148
+ ]
149
+ });
150
+ return result;
151
+ },
152
+ subscribeNewsletterUpdates: async (jid) => {
153
+ var _a;
154
+ const result = await query({
155
+ tag: 'iq',
156
+ attrs: {
157
+ id: generateMessageTag(),
158
+ type: 'set',
159
+ xmlns: 'newsletter',
160
+ to: jid
161
+ },
162
+ content: [{ tag: 'live_updates', attrs: {}, content: [] }]
163
+ });
164
+ const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates');
165
+ const duration = (_a = liveUpdatesNode === null || liveUpdatesNode === void 0 ? void 0 : liveUpdatesNode.attrs) === null || _a === void 0 ? void 0 : _a.duration;
166
+ return duration ? { duration: duration } : null;
167
+ },
168
+ newsletterAdminCount: async (jid) => {
169
+ const response = await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_COUNT, Types_1.XWAPaths.xwa2_newsletter_admin_count);
170
+ return response.admin_count;
171
+ },
172
+ newsletterChangeOwner: async (jid, newOwnerJid) => {
173
+ await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, Types_1.QueryIds.CHANGE_OWNER, Types_1.XWAPaths.xwa2_newsletter_change_owner);
174
+ },
175
+ newsletterDemote: async (jid, userJid) => {
176
+ await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.DEMOTE, Types_1.XWAPaths.xwa2_newsletter_demote);
177
+ },
178
+ newsletterDelete: async (jid) => {
179
+ await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.DELETE, Types_1.XWAPaths.xwa2_newsletter_delete_v2);
180
+ }
181
+ };
182
+ };
183
+ exports.makeNewsletterSocket = makeNewsletterSocket;
@@ -249,7 +249,6 @@ const makeSocket = (config) => {
249
249
  clearInterval(keepAliveReq);
250
250
  clearTimeout(qrTimer);
251
251
  ws.removeAllListeners('close');
252
- ws.removeAllListeners('error');
253
252
  ws.removeAllListeners('open');
254
253
  ws.removeAllListeners('message');
255
254
  if (!ws.isClosed && !ws.isClosing) {
@@ -68,6 +68,7 @@ export type ChatModification = {
68
68
  mute: number | null;
69
69
  } | {
70
70
  clear: boolean;
71
+ lastMessages: LastMessageList;
71
72
  } | {
72
73
  deleteForMe: {
73
74
  deleteMedia: boolean;
@@ -88,6 +89,8 @@ export type ChatModification = {
88
89
  } | {
89
90
  delete: true;
90
91
  lastMessages: LastMessageList;
92
+ } | {
93
+ contact: proto.SyncActionValue.IContactAction | null;
91
94
  } | {
92
95
  addLabel: LabelActionBody;
93
96
  } | {
@@ -104,6 +104,32 @@ export type BaileysEventMap = {
104
104
  association: LabelAssociation;
105
105
  type: 'add' | 'remove';
106
106
  };
107
+ /** Newsletter-related events */
108
+ 'newsletter.reaction': {
109
+ id: string;
110
+ server_id: string;
111
+ reaction: {
112
+ code?: string;
113
+ count?: number;
114
+ removed?: boolean;
115
+ };
116
+ };
117
+ 'newsletter.view': {
118
+ id: string;
119
+ server_id: string;
120
+ count: number;
121
+ };
122
+ 'newsletter-participants.update': {
123
+ id: string;
124
+ author: string;
125
+ user: string;
126
+ new_role: string;
127
+ action: string;
128
+ };
129
+ 'newsletter-settings.update': {
130
+ id: string;
131
+ update: any;
132
+ };
107
133
  };
108
134
  export type BufferedEventData = {
109
135
  historySets: {
@@ -13,6 +13,7 @@ export interface GroupMetadata {
13
13
  addressingMode: 'pn' | 'lid';
14
14
  owner: string | undefined;
15
15
  ownerJid?: string | undefined;
16
+ owner_country_code: string;
16
17
  subject: string;
17
18
  /** group subject owner */
18
19
  subjectOwner?: string;
@@ -7,15 +7,19 @@ import { BinaryNode } from '../WABinary';
7
7
  import type { GroupMetadata } from './GroupMetadata';
8
8
  import { CacheStore } from './Socket';
9
9
  export { proto as WAProto };
10
- export type WAMessage = proto.IWebMessageInfo;
10
+ export type WAMessage = proto.IWebMessageInfo & {
11
+ key: WAMessageKey;
12
+ };
11
13
  export type WAMessageContent = proto.IMessage;
12
14
  export type WAContactMessage = proto.Message.IContactMessage;
13
15
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
14
16
  export type WAMessageKey = proto.IMessageKey & {
15
17
  senderLid?: string;
18
+ server_id?: string;
16
19
  senderPn?: string;
17
20
  participantLid?: string;
18
21
  participantPn?: string;
22
+ isViewOnce?: boolean;
19
23
  };
20
24
  export type WATextMessage = proto.Message.IExtendedTextMessage;
21
25
  export type WAContextInfo = proto.IContextInfo;
@@ -244,6 +248,7 @@ export type MediaGenerationOptions = {
244
248
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
245
249
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
246
250
  getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
251
+ jid?: string;
247
252
  };
248
253
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
249
254
  /**
@@ -0,0 +1,134 @@
1
+ export declare enum XWAPaths {
2
+ xwa2_newsletter_create = "xwa2_newsletter_create",
3
+ xwa2_newsletter_subscribers = "xwa2_newsletter_subscribers",
4
+ xwa2_newsletter_view = "xwa2_newsletter_view",
5
+ xwa2_newsletter_metadata = "xwa2_newsletter",
6
+ xwa2_newsletter_admin_count = "xwa2_newsletter_admin",
7
+ xwa2_newsletter_mute_v2 = "xwa2_newsletter_mute_v2",
8
+ xwa2_newsletter_unmute_v2 = "xwa2_newsletter_unmute_v2",
9
+ xwa2_newsletter_follow = "xwa2_newsletter_follow",
10
+ xwa2_newsletter_unfollow = "xwa2_newsletter_unfollow",
11
+ xwa2_newsletter_change_owner = "xwa2_newsletter_change_owner",
12
+ xwa2_newsletter_demote = "xwa2_newsletter_demote",
13
+ xwa2_newsletter_delete_v2 = "xwa2_newsletter_delete_v2"
14
+ }
15
+ export declare enum QueryIds {
16
+ CREATE = "8823471724422422",
17
+ UPDATE_METADATA = "24250201037901610",
18
+ METADATA = "6563316087068696",
19
+ SUBSCRIBERS = "9783111038412085",
20
+ FOLLOW = "7871414976211147",
21
+ UNFOLLOW = "7238632346214362",
22
+ MUTE = "29766401636284406",
23
+ UNMUTE = "9864994326891137",
24
+ ADMIN_COUNT = "7130823597031706",
25
+ CHANGE_OWNER = "7341777602580933",
26
+ DEMOTE = "6551828931592903",
27
+ DELETE = "30062808666639665"
28
+ }
29
+ export type NewsletterUpdate = {
30
+ name?: string;
31
+ description?: string;
32
+ picture?: string;
33
+ };
34
+ export interface NewsletterCreateResponse {
35
+ id: string;
36
+ state: {
37
+ type: string;
38
+ };
39
+ thread_metadata: {
40
+ creation_time: string;
41
+ description: {
42
+ id: string;
43
+ text: string;
44
+ update_time: string;
45
+ };
46
+ handle: string | null;
47
+ invite: string;
48
+ name: {
49
+ id: string;
50
+ text: string;
51
+ update_time: string;
52
+ };
53
+ picture: {
54
+ direct_path: string;
55
+ id: string;
56
+ type: string;
57
+ };
58
+ preview: {
59
+ direct_path: string;
60
+ id: string;
61
+ type: string;
62
+ };
63
+ subscribers_count: string;
64
+ verification: 'VERIFIED' | 'UNVERIFIED';
65
+ };
66
+ viewer_metadata: {
67
+ mute: 'ON' | 'OFF';
68
+ role: NewsletterViewRole;
69
+ };
70
+ }
71
+ export interface NewsletterCreateResponse {
72
+ id: string;
73
+ state: {
74
+ type: string;
75
+ };
76
+ thread_metadata: {
77
+ creation_time: string;
78
+ description: {
79
+ id: string;
80
+ text: string;
81
+ update_time: string;
82
+ };
83
+ handle: string | null;
84
+ invite: string;
85
+ name: {
86
+ id: string;
87
+ text: string;
88
+ update_time: string;
89
+ };
90
+ picture: {
91
+ direct_path: string;
92
+ id: string;
93
+ type: string;
94
+ };
95
+ preview: {
96
+ direct_path: string;
97
+ id: string;
98
+ type: string;
99
+ };
100
+ subscribers_count: string;
101
+ verification: 'VERIFIED' | 'UNVERIFIED';
102
+ };
103
+ viewer_metadata: {
104
+ mute: 'ON' | 'OFF';
105
+ role: NewsletterViewRole;
106
+ };
107
+ }
108
+ export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
109
+ export interface NewsletterMetadata {
110
+ id: string;
111
+ owner?: string;
112
+ name: string;
113
+ description?: string;
114
+ invite?: string;
115
+ creation_time?: number;
116
+ subscribers?: number;
117
+ picture?: {
118
+ url?: string;
119
+ directPath?: string;
120
+ mediaKey?: string;
121
+ id?: string;
122
+ };
123
+ verification?: 'VERIFIED' | 'UNVERIFIED';
124
+ reaction_codes?: {
125
+ code: string;
126
+ count: number;
127
+ }[];
128
+ mute_state?: 'ON' | 'OFF';
129
+ thread_metadata?: {
130
+ creation_time?: number;
131
+ name?: string;
132
+ description?: string;
133
+ };
134
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryIds = exports.XWAPaths = void 0;
4
+ var XWAPaths;
5
+ (function (XWAPaths) {
6
+ XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
7
+ XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
8
+ XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
9
+ XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
10
+ XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
11
+ XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
12
+ XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
13
+ XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
14
+ XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
15
+ XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
16
+ XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
17
+ XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
18
+ })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
+ var QueryIds;
20
+ (function (QueryIds) {
21
+ QueryIds["CREATE"] = "8823471724422422";
22
+ QueryIds["UPDATE_METADATA"] = "24250201037901610";
23
+ QueryIds["METADATA"] = "6563316087068696";
24
+ QueryIds["SUBSCRIBERS"] = "9783111038412085";
25
+ QueryIds["FOLLOW"] = "7871414976211147";
26
+ QueryIds["UNFOLLOW"] = "7238632346214362";
27
+ QueryIds["MUTE"] = "29766401636284406";
28
+ QueryIds["UNMUTE"] = "9864994326891137";
29
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
30
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
31
+ QueryIds["DEMOTE"] = "6551828931592903";
32
+ QueryIds["DELETE"] = "30062808666639665";
33
+ })(QueryIds || (exports.QueryIds = QueryIds = {}));
@@ -9,6 +9,7 @@ export * from './Events';
9
9
  export * from './Product';
10
10
  export * from './Call';
11
11
  export * from './Signal';
12
+ export * from './Newsletter';
12
13
  import { AuthenticationState } from './Auth';
13
14
  import { SocketConfig } from './Socket';
14
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
@@ -26,6 +26,7 @@ __exportStar(require("./Events"), exports);
26
26
  __exportStar(require("./Product"), exports);
27
27
  __exportStar(require("./Call"), exports);
28
28
  __exportStar(require("./Signal"), exports);
29
+ __exportStar(require("./Newsletter"), exports);
29
30
  var DisconnectReason;
30
31
  (function (DisconnectReason) {
31
32
  DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
@@ -32,7 +32,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
32
32
  const idsToFetch = [];
33
33
  for (const id of ids) {
34
34
  const item = cache.get(getUniqueId(type, id));
35
- if (typeof item !== 'undefined') {
35
+ if (typeof item !== 'undefined' && item !== null) {
36
36
  data[id] = item;
37
37
  }
38
38
  else {
@@ -430,7 +430,9 @@ const chatModificationToAppPatch = (mod, jid) => {
430
430
  else if ('clear' in mod) {
431
431
  patch = {
432
432
  syncAction: {
433
- clearChatAction: {} // add message range later
433
+ clearChatAction: {
434
+ messageRange: getMessageRange(mod.lastMessages)
435
+ }
434
436
  },
435
437
  index: ['clearChat', jid, '1' /*the option here is 0 when keep starred messages is enabled*/, '0'],
436
438
  type: 'regular_high',
@@ -451,6 +453,17 @@ const chatModificationToAppPatch = (mod, jid) => {
451
453
  operation: OP.SET
452
454
  };
453
455
  }
456
+ else if ('contact' in mod) {
457
+ patch = {
458
+ syncAction: {
459
+ contactAction: mod.contact || {}
460
+ },
461
+ index: ['contact', jid],
462
+ type: 'critical_unblock_low',
463
+ apiVersion: 2,
464
+ operation: mod.contact ? OP.SET : OP.REMOVE
465
+ };
466
+ }
454
467
  else if ('star' in mod) {
455
468
  const key = mod.star.messages[0];
456
469
  patch = {
@@ -1,5 +1,4 @@
1
- import { proto } from '../../WAProto';
2
- import { SignalRepository } from '../Types';
1
+ import { SignalRepository, WAMessage } from '../Types';
3
2
  import { BinaryNode } from '../WABinary';
4
3
  import { ILogger } from './logger';
5
4
  export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
@@ -24,12 +23,12 @@ export declare const NACK_REASONS: {
24
23
  * @note this will only parse the message, not decrypt it
25
24
  */
26
25
  export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
27
- fullMessage: proto.IWebMessageInfo;
26
+ fullMessage: WAMessage;
28
27
  author: string;
29
28
  sender: string;
30
29
  };
31
30
  export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: ILogger) => {
32
- fullMessage: proto.IWebMessageInfo;
31
+ fullMessage: WAMessage;
33
32
  category: string;
34
33
  author: string;
35
34
  decrypt(): Promise<void>;