@genuxofficial/baileys 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WAProto/WAProto.proto +24 -206
- package/WAProto/index.d.ts +219 -2233
- package/WAProto/index.js +525 -6773
- package/WAProto/shizo.x +1 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +231 -0
- package/lib/Defaults/index.js +17 -1
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
- package/lib/Socket/business.d.ts +7 -9
- package/lib/Socket/chats.d.ts +5 -8
- package/lib/Socket/chats.js +8 -38
- package/lib/Socket/groups.d.ts +5 -7
- package/lib/Socket/groups.js +2 -14
- package/lib/Socket/index.d.ts +9 -9
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +8 -10
- package/lib/Socket/messages-recv.js +11 -18
- package/lib/Socket/messages-send.d.ts +7 -14
- package/lib/Socket/messages-send.js +13 -36
- package/lib/Socket/newsletter.d.ts +7 -9
- package/lib/Socket/newsletter.js +3 -11
- package/lib/Socket/registration.d.ts +271 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +4 -5
- package/lib/Socket/socket.js +18 -15
- package/lib/Socket/usync.d.ts +4 -4
- package/lib/Store/index.d.ts +2 -1
- package/lib/Store/index.js +3 -1
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.js +10 -8
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +6 -0
- package/lib/Types/Chat.d.ts +0 -4
- package/lib/Types/Contact.d.ts +1 -1
- package/lib/Types/GroupMetadata.d.ts +0 -6
- package/lib/Types/Message.d.ts +5 -29
- package/lib/Types/Message.js +2 -0
- package/lib/Types/Socket.d.ts +4 -7
- package/lib/Utils/auth-utils.d.ts +1 -1
- package/lib/Utils/auth-utils.js +9 -2
- package/lib/Utils/business.js +3 -15
- package/lib/Utils/chat-utils.d.ts +4 -4
- package/lib/Utils/chat-utils.js +2 -1
- package/lib/Utils/decode-wa-message.d.ts +2 -4
- package/lib/Utils/decode-wa-message.js +24 -145
- package/lib/Utils/event-buffer.js +6 -4
- package/lib/Utils/generics.d.ts +4 -7
- package/lib/Utils/generics.js +17 -9
- package/lib/Utils/lt-hash.d.ts +3 -3
- package/lib/Utils/lt-hash.js +45 -11
- package/lib/Utils/messages-media.d.ts +4 -4
- package/lib/Utils/messages-media.js +57 -69
- package/lib/Utils/messages.js +39 -33
- package/lib/Utils/noise-handler.d.ts +2 -1
- package/lib/Utils/noise-handler.js +10 -5
- package/lib/Utils/use-multi-file-auth-state.js +11 -48
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +44 -10
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/encode.js +10 -23
- package/lib/WABinary/generic-utils.d.ts +5 -3
- package/lib/WABinary/generic-utils.js +19 -34
- package/lib/WABinary/jid-utils.d.ts +2 -11
- package/lib/WABinary/jid-utils.js +2 -27
- package/lib/WAM/BinaryInfo.d.ts +2 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +12 -21
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncQuery.d.ts +0 -2
- package/lib/WAUSync/USyncQuery.js +0 -10
- package/lib/WAUSync/USyncUser.d.ts +0 -2
- package/lib/WAUSync/USyncUser.js +0 -4
- package/package.json +5 -6
- package/LICENSE +0 -21
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
- /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -6,7 +6,7 @@ import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptio
|
|
6
6
|
import { BinaryNode, JidWithDevice } from '../WABinary';
|
7
7
|
import { USyncQuery } from '../WAUSync';
|
8
8
|
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
9
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
9
|
+
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
10
10
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
11
11
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
12
12
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
@@ -38,7 +38,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
38
38
|
newsletterFollow: (jid: string) => Promise<void>;
|
39
39
|
newsletterUnmute: (jid: string) => Promise<void>;
|
40
40
|
newsletterMute: (jid: string) => Promise<void>;
|
41
|
-
newsletterCreate: (name: string, description
|
41
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
42
42
|
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
43
43
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
44
44
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
@@ -51,16 +51,11 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
51
51
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
52
52
|
groupLeave: (id: string) => Promise<void>;
|
53
53
|
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
54
|
-
/**
|
55
|
-
* generic send receipt function
|
56
|
-
* used for receipts of phone call, read, delivery etc.
|
57
|
-
* */
|
58
54
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
59
55
|
[key: string]: string;
|
60
56
|
}[]>;
|
61
57
|
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
62
58
|
status: string;
|
63
|
-
/** Correctly bulk send receipts to multiple chats, participants */
|
64
59
|
jid: string;
|
65
60
|
}[]>;
|
66
61
|
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
@@ -73,7 +68,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
73
68
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
74
69
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
75
70
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
76
|
-
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<
|
71
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
77
72
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
78
73
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
79
74
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
@@ -82,7 +77,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
82
77
|
groupFetchAllParticipating: () => Promise<{
|
83
78
|
[_: string]: import("../Types").GroupMetadata;
|
84
79
|
}>;
|
85
|
-
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
86
80
|
processingMutex: {
|
87
81
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
88
82
|
};
|
@@ -94,7 +88,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
94
88
|
onWhatsApp: (...jids: string[]) => Promise<{
|
95
89
|
jid: string;
|
96
90
|
exists: unknown;
|
97
|
-
lid: unknown;
|
98
91
|
}[] | undefined>;
|
99
92
|
fetchBlocklist: () => Promise<string[]>;
|
100
93
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
@@ -127,7 +120,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
127
120
|
}[], star: boolean) => Promise<void>;
|
128
121
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
129
122
|
type: "md";
|
130
|
-
ws:
|
123
|
+
ws: any;
|
131
124
|
ev: import("../Types").BaileysEventEmitter & {
|
132
125
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
133
126
|
buffer(): void;
|
@@ -142,8 +135,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
142
135
|
signalRepository: import("../Types").SignalRepository;
|
143
136
|
user: import("../Types").Contact | undefined;
|
144
137
|
generateMessageTag: () => string;
|
145
|
-
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<
|
146
|
-
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
138
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
|
139
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
147
140
|
waitForSocketOpen: () => Promise<void>;
|
148
141
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
149
142
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
@@ -154,5 +147,5 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
154
147
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
155
148
|
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
156
149
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
|
157
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
150
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
158
151
|
};
|
@@ -226,17 +226,10 @@ const makeMessagesSocket = (config) => {
|
|
226
226
|
return msgId;
|
227
227
|
};
|
228
228
|
const createParticipantNodes = async (jids, message, extraAttrs) => {
|
229
|
-
|
230
|
-
|
231
|
-
patched = jids ? jids.map(jid => ({ recipientJid: jid, ...patched })) : [patched];
|
232
|
-
}
|
229
|
+
const patched = await patchMessageBeforeSending(message, jids);
|
230
|
+
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
233
231
|
let shouldIncludeDeviceIdentity = false;
|
234
|
-
const nodes = await Promise.all(
|
235
|
-
const { recipientJid: jid, ...patchedMessage } = patchedMessageWithJid;
|
236
|
-
if (!jid) {
|
237
|
-
return {};
|
238
|
-
}
|
239
|
-
const bytes = (0, Utils_1.encodeWAMessage)(patchedMessage);
|
232
|
+
const nodes = await Promise.all(jids.map(async (jid) => {
|
240
233
|
const { type, ciphertext } = await signalRepository
|
241
234
|
.encryptMessage({ jid, data: bytes });
|
242
235
|
if (type === 'pkmsg') {
|
@@ -327,20 +320,10 @@ const makeMessagesSocket = (config) => {
|
|
327
320
|
if (isStatus && statusJidList) {
|
328
321
|
participantsList.push(...statusJidList);
|
329
322
|
}
|
330
|
-
if (!isStatus) {
|
331
|
-
additionalAttributes = {
|
332
|
-
...additionalAttributes,
|
333
|
-
// eslint-disable-next-line camelcase
|
334
|
-
addressing_mode: (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) || 'pn'
|
335
|
-
};
|
336
|
-
}
|
337
323
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
338
324
|
devices.push(...additionalDevices);
|
339
325
|
}
|
340
|
-
const patched = await patchMessageBeforeSending(message);
|
341
|
-
if (Array.isArray(patched)) {
|
342
|
-
throw new boom_1.Boom('Per-jid patching is not supported in groups');
|
343
|
-
}
|
326
|
+
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)));
|
344
327
|
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
345
328
|
const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
|
346
329
|
group: destinationJid,
|
@@ -350,7 +333,7 @@ const makeMessagesSocket = (config) => {
|
|
350
333
|
const senderKeyJids = [];
|
351
334
|
// ensure a connection is established with every device
|
352
335
|
for (const { user, device } of devices) {
|
353
|
-
const jid = (0, WABinary_1.jidEncode)(user,
|
336
|
+
const jid = (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : 's.whatsapp.net', device);
|
354
337
|
if (!senderKeyMap[jid] || !!participant) {
|
355
338
|
senderKeyJids.push(jid);
|
356
339
|
// store that this person has had the sender keys sent to them
|
@@ -391,9 +374,6 @@ const makeMessagesSocket = (config) => {
|
|
391
374
|
message = {};
|
392
375
|
}
|
393
376
|
const patched = await patchMessageBeforeSending(message, []);
|
394
|
-
if (Array.isArray(patched)) {
|
395
|
-
throw new boom_1.Boom('Per-jid patching is not supported in channel');
|
396
|
-
}
|
397
377
|
const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
|
398
378
|
binaryNodeContent.push({
|
399
379
|
tag: 'plaintext',
|
@@ -402,13 +382,14 @@ const makeMessagesSocket = (config) => {
|
|
402
382
|
});
|
403
383
|
}
|
404
384
|
else {
|
405
|
-
const { user: meUser } = (0, WABinary_1.jidDecode)(meId);
|
385
|
+
const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
|
406
386
|
if (!participant) {
|
407
387
|
devices.push({ user });
|
408
|
-
if
|
409
|
-
|
410
|
-
|
411
|
-
|
388
|
+
// do not send message to self if the device is 0 (mobile)
|
389
|
+
if (!((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer' && user === meUser)) {
|
390
|
+
if (meDevice !== undefined && meDevice !== 0) {
|
391
|
+
devices.push({ user: meUser });
|
392
|
+
}
|
412
393
|
const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
|
413
394
|
devices.push(...additionalDevices);
|
414
395
|
}
|
@@ -739,9 +720,6 @@ const makeMessagesSocket = (config) => {
|
|
739
720
|
(disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
|
740
721
|
disappearingMessagesInChat;
|
741
722
|
await groupToggleEphemeral(jid, value);
|
742
|
-
if (jid.endsWith('@bot')) {
|
743
|
-
jid = (0, WABinary_1.getBotJid)(jid);
|
744
|
-
}
|
745
723
|
}
|
746
724
|
else {
|
747
725
|
let mediaHandle;
|
@@ -760,9 +738,8 @@ const makeMessagesSocket = (config) => {
|
|
760
738
|
: undefined
|
761
739
|
}),
|
762
740
|
getProfilePicUrl: sock.profilePictureUrl,
|
763
|
-
|
764
|
-
|
765
|
-
const up = await waUploadToServer(encFilePath, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
|
741
|
+
upload: async (readStream, opts) => {
|
742
|
+
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
|
766
743
|
mediaHandle = up.handle;
|
767
744
|
return up;
|
768
745
|
},
|
@@ -15,7 +15,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
15
15
|
newsletterFollow: (jid: string) => Promise<void>;
|
16
16
|
newsletterUnmute: (jid: string) => Promise<void>;
|
17
17
|
newsletterMute: (jid: string) => Promise<void>;
|
18
|
-
newsletterCreate: (name: string, description
|
18
|
+
newsletterCreate: (name: string, description: string) => Promise<NewsletterMetadata>;
|
19
19
|
newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
|
20
20
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
21
21
|
/**user is Lid, not Jid */
|
@@ -48,8 +48,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
48
48
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
49
49
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
50
50
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
51
|
-
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<
|
52
|
-
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
51
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
52
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
53
53
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
54
54
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
55
55
|
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
@@ -57,7 +57,6 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
57
57
|
groupFetchAllParticipating: () => Promise<{
|
58
58
|
[_: string]: import("../Types").GroupMetadata;
|
59
59
|
}>;
|
60
|
-
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
61
60
|
processingMutex: {
|
62
61
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
63
62
|
};
|
@@ -72,7 +71,6 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
72
71
|
onWhatsApp: (...jids: string[]) => Promise<{
|
73
72
|
jid: string;
|
74
73
|
exists: unknown;
|
75
|
-
lid: unknown;
|
76
74
|
}[] | undefined>;
|
77
75
|
fetchBlocklist: () => Promise<string[]>;
|
78
76
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
@@ -105,7 +103,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
105
103
|
}[], star: boolean) => Promise<void>;
|
106
104
|
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
107
105
|
type: "md";
|
108
|
-
ws:
|
106
|
+
ws: any;
|
109
107
|
ev: import("../Types").BaileysEventEmitter & {
|
110
108
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
111
109
|
buffer(): void;
|
@@ -120,8 +118,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
120
118
|
signalRepository: import("../Types").SignalRepository;
|
121
119
|
user: import("../Types").Contact | undefined;
|
122
120
|
generateMessageTag: () => string;
|
123
|
-
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<
|
124
|
-
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
121
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
|
122
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
125
123
|
waitForSocketOpen: () => Promise<void>;
|
126
124
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
127
125
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
@@ -132,6 +130,6 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
132
130
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
133
131
|
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
134
132
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
|
135
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
133
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
136
134
|
};
|
137
135
|
export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
|
package/lib/Socket/newsletter.js
CHANGED
@@ -20,7 +20,6 @@ var QueryIds;
|
|
20
20
|
QueryIds["DEMOTE"] = "6551828931592903";
|
21
21
|
})(QueryIds || (QueryIds = {}));
|
22
22
|
const makeNewsletterSocket = (config) => {
|
23
|
-
const { getMessage } = config;
|
24
23
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
25
24
|
const { authState, signalRepository, query, generateMessageTag } = sock;
|
26
25
|
const encoder = new TextEncoder();
|
@@ -67,7 +66,7 @@ const makeNewsletterSocket = (config) => {
|
|
67
66
|
.map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
|
68
67
|
let data;
|
69
68
|
if (type === 'messages') {
|
70
|
-
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger
|
69
|
+
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
71
70
|
await decrypt();
|
72
71
|
data = {
|
73
72
|
server_id: messageNode.attrs.server_id,
|
@@ -132,7 +131,7 @@ const makeNewsletterSocket = (config) => {
|
|
132
131
|
newsletterMute: async (jid) => {
|
133
132
|
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
134
133
|
},
|
135
|
-
newsletterCreate: async (name, description
|
134
|
+
newsletterCreate: async (name, description) => {
|
136
135
|
await query({
|
137
136
|
tag: 'iq',
|
138
137
|
attrs: {
|
@@ -153,14 +152,7 @@ const makeNewsletterSocket = (config) => {
|
|
153
152
|
]
|
154
153
|
});
|
155
154
|
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
156
|
-
input: {
|
157
|
-
name,
|
158
|
-
description: description !== null && description !== void 0 ? description : null,
|
159
|
-
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
160
|
-
settings: {
|
161
|
-
reaction_codes: { value: 'ALL' }
|
162
|
-
}
|
163
|
-
}
|
155
|
+
input: { name, description }
|
164
156
|
});
|
165
157
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
166
158
|
},
|
@@ -0,0 +1,271 @@
|
|
1
|
+
/// <reference types="long" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
4
|
+
import { AxiosRequestConfig } from 'axios';
|
5
|
+
import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
|
6
|
+
export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
7
|
+
register: (code: string) => Promise<ExistsResponse>;
|
8
|
+
requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
|
9
|
+
logger: import("../Utils/logger").ILogger;
|
10
|
+
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
11
|
+
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
12
|
+
products: import("../Types").Product[];
|
13
|
+
nextPageCursor: string | undefined;
|
14
|
+
}>;
|
15
|
+
getCollections: (jid?: string | undefined, limit?: number) => Promise<{
|
16
|
+
collections: import("../Types").CatalogCollection[];
|
17
|
+
}>;
|
18
|
+
productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
|
19
|
+
productDelete: (productIds: string[]) => Promise<{
|
20
|
+
deleted: number;
|
21
|
+
}>;
|
22
|
+
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
23
|
+
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode, errorCode?: number | undefined) => Promise<void>;
|
24
|
+
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
25
|
+
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
26
|
+
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
27
|
+
callId: string;
|
28
|
+
toJid: string;
|
29
|
+
isVideo: boolean;
|
30
|
+
}>;
|
31
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
32
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
33
|
+
getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
|
34
|
+
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
35
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
36
|
+
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
37
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
38
|
+
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
39
|
+
[key: string]: string;
|
40
|
+
};
|
41
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
42
|
+
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
43
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
44
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
45
|
+
[_: string]: string;
|
46
|
+
}>;
|
47
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
48
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
49
|
+
[key: string]: string;
|
50
|
+
} | undefined) => Promise<{
|
51
|
+
nodes: import("../WABinary").BinaryNode[];
|
52
|
+
shouldIncludeDeviceIdentity: boolean;
|
53
|
+
}>;
|
54
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
55
|
+
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
56
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
57
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
58
|
+
duration: string;
|
59
|
+
}>;
|
60
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
61
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
62
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
63
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
64
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
65
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
66
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
67
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
68
|
+
newsletterMute: (jid: string) => Promise<void>;
|
69
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
70
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
71
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
72
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
73
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
74
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
75
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
76
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
77
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
78
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
79
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
80
|
+
groupLeave: (id: string) => Promise<void>;
|
81
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
82
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
83
|
+
[key: string]: string;
|
84
|
+
}[]>;
|
85
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
86
|
+
status: string;
|
87
|
+
jid: string;
|
88
|
+
}[]>;
|
89
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
90
|
+
status: string;
|
91
|
+
jid: string;
|
92
|
+
content: import("../WABinary").BinaryNode;
|
93
|
+
}[]>;
|
94
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
95
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
96
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
97
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
98
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
99
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
100
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
101
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
102
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
103
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
104
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
105
|
+
groupFetchAllParticipating: () => Promise<{
|
106
|
+
[_: string]: import("../Types").GroupMetadata;
|
107
|
+
}>;
|
108
|
+
processingMutex: {
|
109
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
110
|
+
};
|
111
|
+
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
112
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
113
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
114
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
115
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
116
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
117
|
+
jid: string;
|
118
|
+
exists: unknown;
|
119
|
+
}[] | undefined>;
|
120
|
+
fetchBlocklist: () => Promise<string[]>;
|
121
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
122
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
123
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
124
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
125
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
126
|
+
updateProfileName: (name: string) => Promise<void>;
|
127
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
128
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
129
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
130
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
131
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
132
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
133
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
134
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
135
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
136
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
137
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
138
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
139
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
140
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
141
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
142
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
143
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
144
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
145
|
+
star: (jid: string, messages: {
|
146
|
+
id: string;
|
147
|
+
fromMe?: boolean | undefined;
|
148
|
+
}[], star: boolean) => Promise<void>;
|
149
|
+
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
150
|
+
type: "md";
|
151
|
+
ws: any;
|
152
|
+
ev: import("../Types").BaileysEventEmitter & {
|
153
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
154
|
+
buffer(): void;
|
155
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
156
|
+
flush(force?: boolean | undefined): boolean;
|
157
|
+
isBuffering(): boolean;
|
158
|
+
};
|
159
|
+
authState: {
|
160
|
+
creds: import("../Types").AuthenticationCreds;
|
161
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
162
|
+
};
|
163
|
+
signalRepository: import("../Types").SignalRepository;
|
164
|
+
user: import("../Types").Contact | undefined;
|
165
|
+
generateMessageTag: () => string;
|
166
|
+
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../WABinary").BinaryNode>;
|
167
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
168
|
+
waitForSocketOpen: () => Promise<void>;
|
169
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
170
|
+
sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
|
171
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
172
|
+
end: (error: Error | undefined) => void;
|
173
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
174
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
175
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
176
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
177
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
|
178
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
|
179
|
+
};
|
180
|
+
export interface RegistrationData {
|
181
|
+
registrationId: number;
|
182
|
+
signedPreKey: SignedKeyPair;
|
183
|
+
noiseKey: KeyPair;
|
184
|
+
signedIdentityKey: KeyPair;
|
185
|
+
identityId: Buffer;
|
186
|
+
phoneId: string;
|
187
|
+
deviceId: string;
|
188
|
+
backupToken: Buffer;
|
189
|
+
}
|
190
|
+
export interface RegistrationOptions {
|
191
|
+
/** your phone number */
|
192
|
+
phoneNumber?: string;
|
193
|
+
/** the country code of your phone number */
|
194
|
+
phoneNumberCountryCode: string;
|
195
|
+
/** your phone number without country code */
|
196
|
+
phoneNumberNationalNumber: string;
|
197
|
+
/** the country code of your mobile network
|
198
|
+
* @see {@link https://de.wikipedia.org/wiki/Mobile_Country_Code}
|
199
|
+
*/
|
200
|
+
phoneNumberMobileCountryCode: string;
|
201
|
+
/** the network code of your mobile network
|
202
|
+
* @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
|
203
|
+
*/
|
204
|
+
phoneNumberMobileNetworkCode: string;
|
205
|
+
/**
|
206
|
+
* How to send the one time code
|
207
|
+
*/
|
208
|
+
method?: 'sms' | 'voice' | 'captcha';
|
209
|
+
/**
|
210
|
+
* The captcha code if it was requested
|
211
|
+
*/
|
212
|
+
captcha?: string;
|
213
|
+
}
|
214
|
+
export type RegistrationParams = RegistrationData & RegistrationOptions;
|
215
|
+
export declare function registrationParams(params: RegistrationParams): {
|
216
|
+
cc: string;
|
217
|
+
in: string;
|
218
|
+
Rc: string;
|
219
|
+
lg: string;
|
220
|
+
lc: string;
|
221
|
+
mistyped: string;
|
222
|
+
authkey: string;
|
223
|
+
e_regid: string;
|
224
|
+
e_keytype: string;
|
225
|
+
e_ident: string;
|
226
|
+
e_skey_id: string;
|
227
|
+
e_skey_val: string;
|
228
|
+
e_skey_sig: string;
|
229
|
+
fdid: string;
|
230
|
+
network_ratio_type: string;
|
231
|
+
expid: string;
|
232
|
+
simnum: string;
|
233
|
+
hasinrc: string;
|
234
|
+
pid: string;
|
235
|
+
id: string;
|
236
|
+
backup_token: string;
|
237
|
+
token: string;
|
238
|
+
fraud_checkpoint_code: string | undefined;
|
239
|
+
};
|
240
|
+
/**
|
241
|
+
* Requests a registration code for the given phone number.
|
242
|
+
*/
|
243
|
+
export declare function mobileRegisterCode(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
244
|
+
export declare function mobileRegisterExists(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
245
|
+
/**
|
246
|
+
* Registers the phone number on whatsapp with the received OTP code.
|
247
|
+
*/
|
248
|
+
export declare function mobileRegister(params: RegistrationParams & {
|
249
|
+
code: string;
|
250
|
+
}, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
251
|
+
/**
|
252
|
+
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
253
|
+
*/
|
254
|
+
export declare function mobileRegisterEncrypt(data: string): string;
|
255
|
+
export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
|
256
|
+
export interface ExistsResponse {
|
257
|
+
status: 'fail' | 'sent';
|
258
|
+
voice_length?: number;
|
259
|
+
voice_wait?: number;
|
260
|
+
sms_length?: number;
|
261
|
+
sms_wait?: number;
|
262
|
+
reason?: 'incorrect' | 'missing_param' | 'code_checkpoint';
|
263
|
+
login?: string;
|
264
|
+
flash_type?: number;
|
265
|
+
ab_hash?: string;
|
266
|
+
ab_key?: string;
|
267
|
+
exp_cfg?: string;
|
268
|
+
lid?: string;
|
269
|
+
image_blob?: string;
|
270
|
+
audio_blob?: string;
|
271
|
+
}
|