@queenanya/baileys 8.2.7 → 8.3.1
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/index.d.ts +1590 -6
- package/WAProto/index.js +4635 -3
- package/engine-requirements.js +1 -1
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +232 -1
- package/lib/Defaults/index.js +21 -6
- 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 +12 -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} +3 -3
- package/lib/Socket/business.d.ts +4 -9
- package/lib/Socket/chats.d.ts +3 -9
- package/lib/Socket/chats.js +6 -89
- package/lib/Socket/groups.d.ts +3 -7
- package/lib/Socket/groups.js +13 -9
- package/lib/Socket/index.d.ts +6 -9
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +4 -9
- package/lib/Socket/messages-recv.js +14 -27
- package/lib/Socket/messages-send.d.ts +3 -8
- package/lib/Socket/messages-send.js +55 -86
- package/lib/Socket/newsletter.d.ts +3 -7
- package/lib/Socket/newsletter.js +2 -4
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +1 -2
- package/lib/Socket/socket.js +15 -10
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Socket/usync.js +15 -10
- package/lib/Store/make-in-memory-store.js +10 -8
- package/lib/Types/Auth.d.ts +6 -0
- package/lib/Types/Chat.d.ts +2 -8
- package/lib/Types/Contact.d.ts +4 -5
- package/lib/Types/GroupMetadata.d.ts +4 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +5 -5
- package/lib/Types/Socket.d.ts +3 -5
- package/lib/Utils/auth-utils.js +7 -0
- package/lib/Utils/chat-utils.d.ts +8 -8
- package/lib/Utils/chat-utils.js +4 -30
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +1 -3
- package/lib/Utils/decode-wa-message.d.ts +2 -4
- package/lib/Utils/decode-wa-message.js +18 -161
- package/lib/Utils/event-buffer.js +6 -4
- package/lib/Utils/generics.d.ts +18 -8
- package/lib/Utils/generics.js +93 -7
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/messages-media.d.ts +9 -16
- package/lib/Utils/messages-media.js +175 -88
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.js +17 -15
- package/lib/Utils/noise-handler.d.ts +2 -1
- package/lib/Utils/noise-handler.js +10 -5
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +50 -16
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1271 -8
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/jid-utils.d.ts +4 -4
- package/lib/WABinary/jid-utils.js +19 -19
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.js +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +3 -3
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
- package/lib/WAUSync/USyncQuery.js +13 -17
- package/package.json +9 -5
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- /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
|
@@ -13,7 +13,6 @@ const link_preview_1 = require("../Utils/link-preview");
|
|
|
13
13
|
const WABinary_1 = require("../WABinary");
|
|
14
14
|
const WAUSync_1 = require("../WAUSync");
|
|
15
15
|
const newsletter_1 = require("./newsletter");
|
|
16
|
-
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
17
16
|
const makeMessagesSocket = (config) => {
|
|
18
17
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
|
|
19
18
|
const sock = (0, newsletter_1.makeNewsletterSocket)(config);
|
|
@@ -139,7 +138,9 @@ const makeMessagesSocket = (config) => {
|
|
|
139
138
|
if (!toFetch.length) {
|
|
140
139
|
return deviceResults;
|
|
141
140
|
}
|
|
142
|
-
const query = new WAUSync_1.USyncQuery()
|
|
141
|
+
const query = new WAUSync_1.USyncQuery()
|
|
142
|
+
.withContext('message')
|
|
143
|
+
.withDeviceProtocol();
|
|
143
144
|
for (const jid of toFetch) {
|
|
144
145
|
query.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
145
146
|
}
|
|
@@ -156,7 +157,6 @@ const makeMessagesSocket = (config) => {
|
|
|
156
157
|
userDevicesCache.set(key, deviceMap[key]);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
logger.debug(deviceResults);
|
|
160
160
|
return deviceResults;
|
|
161
161
|
};
|
|
162
162
|
const assertSessions = async (jids, force) => {
|
|
@@ -401,13 +401,14 @@ const makeMessagesSocket = (config) => {
|
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
else {
|
|
404
|
-
const { user: meUser } = (0, WABinary_1.jidDecode)(meId);
|
|
404
|
+
const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
|
|
405
405
|
if (!participant) {
|
|
406
406
|
devices.push({ user });
|
|
407
|
-
if
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
407
|
+
// do not send message to self if the device is 0 (mobile)
|
|
408
|
+
if (!((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer' && user === meUser)) {
|
|
409
|
+
if (meDevice !== undefined && meDevice !== 0) {
|
|
410
|
+
devices.push({ user: meUser });
|
|
411
|
+
}
|
|
411
412
|
const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
|
|
412
413
|
devices.push(...additionalDevices);
|
|
413
414
|
}
|
|
@@ -454,7 +455,7 @@ const makeMessagesSocket = (config) => {
|
|
|
454
455
|
tag: 'message',
|
|
455
456
|
attrs: {
|
|
456
457
|
id: msgId,
|
|
457
|
-
type: isNewsletter ? getTypeMessage(message) :
|
|
458
|
+
type: isNewsletter ? getTypeMessage(message) : 'text',
|
|
458
459
|
...(additionalAttributes || {})
|
|
459
460
|
},
|
|
460
461
|
content: binaryNodeContent
|
|
@@ -486,53 +487,45 @@ const makeMessagesSocket = (config) => {
|
|
|
486
487
|
});
|
|
487
488
|
logger.debug({ jid }, 'adding device identity');
|
|
488
489
|
}
|
|
489
|
-
const buttonType = getButtonType(message);
|
|
490
|
-
if (buttonType) {
|
|
491
|
-
stanza.content.push({
|
|
492
|
-
tag: 'biz',
|
|
493
|
-
attrs: {},
|
|
494
|
-
content: [
|
|
495
|
-
{
|
|
496
|
-
tag: buttonType,
|
|
497
|
-
attrs: getButtonArgs(message),
|
|
498
|
-
}
|
|
499
|
-
]
|
|
500
|
-
});
|
|
501
|
-
logger.debug({ jid }, 'adding business node');
|
|
502
|
-
}
|
|
503
490
|
if (additionalNodes && additionalNodes.length > 0) {
|
|
504
491
|
stanza.content.push(...additionalNodes);
|
|
505
492
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
493
|
+
const content = (0, Utils_1.normalizeMessageContent)(message);
|
|
494
|
+
const contentType = (0, Utils_1.getContentType)(content);
|
|
495
|
+
if (((0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidUser)(jid)) && (contentType === 'interactiveMessage' ||
|
|
496
|
+
contentType === 'buttonsMessage' ||
|
|
497
|
+
contentType === 'listMessage')) {
|
|
498
|
+
const bizNode = { tag: 'biz', attrs: {} };
|
|
499
|
+
if ((((_l = (_k = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.interactiveMessage) || ((_o = (_m = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _m === void 0 ? void 0 : _m.message) === null || _o === void 0 ? void 0 : _o.interactiveMessage) || ((_q = (_p = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _p === void 0 ? void 0 : _p.message) === null || _q === void 0 ? void 0 : _q.interactiveMessage) || (message === null || message === void 0 ? void 0 : message.interactiveMessage)) || (((_s = (_r = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _r === void 0 ? void 0 : _r.message) === null || _s === void 0 ? void 0 : _s.buttonsMessage) || ((_u = (_t = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _t === void 0 ? void 0 : _t.message) === null || _u === void 0 ? void 0 : _u.buttonsMessage) || ((_w = (_v = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _v === void 0 ? void 0 : _v.message) === null || _w === void 0 ? void 0 : _w.buttonsMessage) || (message === null || message === void 0 ? void 0 : message.buttonsMessage))) {
|
|
500
|
+
bizNode.content = [{
|
|
501
|
+
tag: 'interactive',
|
|
502
|
+
attrs: {
|
|
503
|
+
type: 'native_flow',
|
|
504
|
+
v: '1'
|
|
505
|
+
},
|
|
506
|
+
content: [{
|
|
507
|
+
tag: 'native_flow',
|
|
508
|
+
attrs: { v: '9', name: 'mixed' }
|
|
509
|
+
}]
|
|
510
|
+
}];
|
|
523
511
|
}
|
|
512
|
+
else if (message === null || message === void 0 ? void 0 : message.listMessage) {
|
|
513
|
+
// list message only support in private chat
|
|
514
|
+
bizNode.content = [{
|
|
515
|
+
tag: 'list',
|
|
516
|
+
attrs: {
|
|
517
|
+
type: 'product_list',
|
|
518
|
+
v: '2'
|
|
519
|
+
}
|
|
520
|
+
}];
|
|
521
|
+
}
|
|
522
|
+
stanza.content.push(bizNode);
|
|
524
523
|
}
|
|
525
524
|
logger.debug({ msgId }, `sending message to ${participants.length} devices`);
|
|
526
525
|
await sendNode(stanza);
|
|
527
526
|
});
|
|
528
527
|
return msgId;
|
|
529
528
|
};
|
|
530
|
-
const getMessageType = (message) => {
|
|
531
|
-
if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3 || message.pollUpdateMessage) {
|
|
532
|
-
return 'poll';
|
|
533
|
-
}
|
|
534
|
-
return 'text';
|
|
535
|
-
};
|
|
536
529
|
const getTypeMessage = (msg) => {
|
|
537
530
|
if (msg.viewOnceMessage) {
|
|
538
531
|
return getTypeMessage(msg.viewOnceMessage.message);
|
|
@@ -609,39 +602,6 @@ const makeMessagesSocket = (config) => {
|
|
|
609
602
|
return 'url';
|
|
610
603
|
}
|
|
611
604
|
};
|
|
612
|
-
const getButtonType = (message) => {
|
|
613
|
-
if (message.buttonsMessage) {
|
|
614
|
-
return 'buttons';
|
|
615
|
-
}
|
|
616
|
-
else if (message.buttonsResponseMessage) {
|
|
617
|
-
return 'buttons_response';
|
|
618
|
-
}
|
|
619
|
-
else if (message.interactiveResponseMessage) {
|
|
620
|
-
return 'interactive_response';
|
|
621
|
-
}
|
|
622
|
-
else if (message.listMessage) {
|
|
623
|
-
return 'list';
|
|
624
|
-
}
|
|
625
|
-
else if (message.listResponseMessage) {
|
|
626
|
-
return 'list_response';
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
const getButtonArgs = (message) => {
|
|
630
|
-
if (message.templateMessage) {
|
|
631
|
-
// TODO: Add attributes
|
|
632
|
-
return {};
|
|
633
|
-
}
|
|
634
|
-
else if (message.listMessage) {
|
|
635
|
-
const type = message.listMessage.listType;
|
|
636
|
-
if (!type) {
|
|
637
|
-
throw new boom_1.Boom('Expected list type inside message');
|
|
638
|
-
}
|
|
639
|
-
return { v: '2', type: ListType[type].toLowerCase() };
|
|
640
|
-
}
|
|
641
|
-
else {
|
|
642
|
-
return {};
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
605
|
const getPrivacyTokens = async (jids) => {
|
|
646
606
|
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
647
607
|
const result = await query({
|
|
@@ -677,7 +637,6 @@ const makeMessagesSocket = (config) => {
|
|
|
677
637
|
relayMessage,
|
|
678
638
|
sendReceipt,
|
|
679
639
|
sendReceipts,
|
|
680
|
-
getButtonArgs,
|
|
681
640
|
readMessages,
|
|
682
641
|
refreshMediaConn,
|
|
683
642
|
waUploadToServer,
|
|
@@ -727,8 +686,21 @@ const makeMessagesSocket = (config) => {
|
|
|
727
686
|
return message;
|
|
728
687
|
},
|
|
729
688
|
sendMessage: async (jid, content, options = {}) => {
|
|
730
|
-
var _a, _b, _c;
|
|
689
|
+
var _a, _b, _c, _d, _e;
|
|
731
690
|
const userJid = authState.creds.me.id;
|
|
691
|
+
if (!options.ephemeralExpiration) {
|
|
692
|
+
if ((0, WABinary_1.isJidGroup)(jid)) {
|
|
693
|
+
const groups = await sock.groupQuery(jid, 'get', [{
|
|
694
|
+
tag: 'query',
|
|
695
|
+
attrs: {
|
|
696
|
+
request: 'interactive'
|
|
697
|
+
}
|
|
698
|
+
}]);
|
|
699
|
+
const metadata = (0, WABinary_1.getBinaryNodeChild)(groups, 'group');
|
|
700
|
+
const expiration = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(metadata, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.expiration) || 0;
|
|
701
|
+
options.ephemeralExpiration = expiration;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
732
704
|
if (typeof content === 'object' &&
|
|
733
705
|
'disappearingMessagesInChat' in content &&
|
|
734
706
|
typeof content['disappearingMessagesInChat'] !== 'undefined' &&
|
|
@@ -740,9 +712,6 @@ const makeMessagesSocket = (config) => {
|
|
|
740
712
|
await groupToggleEphemeral(jid, value);
|
|
741
713
|
}
|
|
742
714
|
else {
|
|
743
|
-
if (jid.endsWith('@bot')) {
|
|
744
|
-
jid = (0, WABinary_1.getBotJid)(jid);
|
|
745
|
-
}
|
|
746
715
|
let mediaHandle;
|
|
747
716
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
748
717
|
logger,
|
|
@@ -766,7 +735,7 @@ const makeMessagesSocket = (config) => {
|
|
|
766
735
|
},
|
|
767
736
|
mediaCache: config.mediaCache,
|
|
768
737
|
options: config.options,
|
|
769
|
-
messageId: (0, Utils_1.generateMessageIDV2)((
|
|
738
|
+
messageId: (0, Utils_1.generateMessageIDV2)((_c = sock.user) === null || _c === void 0 ? void 0 : _c.id),
|
|
770
739
|
...options,
|
|
771
740
|
});
|
|
772
741
|
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
@@ -780,7 +749,7 @@ const makeMessagesSocket = (config) => {
|
|
|
780
749
|
// required for delete
|
|
781
750
|
if (isDeleteMsg) {
|
|
782
751
|
// if the chat is a group, and I am not the author, then delete the message as an admin
|
|
783
|
-
if (((0, WABinary_1.isJidGroup)((
|
|
752
|
+
if (((0, WABinary_1.isJidGroup)((_d = content.delete) === null || _d === void 0 ? void 0 : _d.remoteJid) && !((_e = content.delete) === null || _e === void 0 ? void 0 : _e.fromMe)) || (0, WABinary_1.isJidNewsletter)(jid)) {
|
|
784
753
|
additionalAttributes.edit = '8';
|
|
785
754
|
}
|
|
786
755
|
else {
|
|
@@ -25,6 +25,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
25
25
|
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
26
26
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
27
27
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
28
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
28
29
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
29
30
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
30
31
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -76,8 +77,6 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
76
77
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
77
78
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
78
79
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
79
|
-
updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
80
|
-
updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
81
80
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
82
81
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
83
82
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -92,12 +91,9 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
92
91
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
93
92
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
94
93
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
95
|
-
resyncAppState: (collections: readonly ("
|
|
94
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
96
95
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
97
96
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
98
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
99
|
-
removeContact: (jid: string) => Promise<void>;
|
|
100
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
101
97
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
102
98
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
103
99
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -108,7 +104,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
108
104
|
}[], star: boolean) => Promise<void>;
|
|
109
105
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
110
106
|
type: "md";
|
|
111
|
-
ws:
|
|
107
|
+
ws: any;
|
|
112
108
|
ev: import("../Types").BaileysEventEmitter & {
|
|
113
109
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
114
110
|
buffer(): void;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -75,7 +75,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
75
75
|
reactions
|
|
76
76
|
};
|
|
77
77
|
if (type === 'messages') {
|
|
78
|
-
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger
|
|
78
|
+
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
|
79
79
|
await decrypt();
|
|
80
80
|
data.message = message;
|
|
81
81
|
}
|
|
@@ -152,9 +152,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
152
152
|
name,
|
|
153
153
|
description: description !== null && description !== void 0 ? description : null,
|
|
154
154
|
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
155
|
-
settings:
|
|
156
|
-
reaction_codes: { value: 'ALL' }
|
|
157
|
-
}
|
|
155
|
+
settings: null
|
|
158
156
|
}
|
|
159
157
|
});
|
|
160
158
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
|
|
3
|
+
export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
4
|
+
register: (code: string) => Promise<ExistsResponse>;
|
|
5
|
+
requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
|
|
6
|
+
logger: import("../Utils/logger").ILogger;
|
|
7
|
+
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
8
|
+
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
9
|
+
products: import("../Types").Product[];
|
|
10
|
+
nextPageCursor: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
getCollections: (jid?: string, limit?: number) => Promise<{
|
|
13
|
+
collections: import("../Types").CatalogCollection[];
|
|
14
|
+
}>;
|
|
15
|
+
productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
|
|
16
|
+
productDelete: (productIds: string[]) => Promise<{
|
|
17
|
+
deleted: number;
|
|
18
|
+
}>;
|
|
19
|
+
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
20
|
+
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode, errorCode?: number) => Promise<void>;
|
|
21
|
+
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
22
|
+
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
23
|
+
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
24
|
+
callId: string;
|
|
25
|
+
toJid: string;
|
|
26
|
+
isVideo: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
29
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<"RESOLVED" | string | undefined>;
|
|
30
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
31
|
+
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
32
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
33
|
+
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
34
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
35
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
36
|
+
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
37
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
38
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
39
|
+
[_: string]: string;
|
|
40
|
+
}>;
|
|
41
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
42
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: import("../WABinary").BinaryNode["attrs"]) => Promise<{
|
|
43
|
+
nodes: import("../WABinary").BinaryNode[];
|
|
44
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
47
|
+
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
48
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
49
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
50
|
+
duration: string;
|
|
51
|
+
}>;
|
|
52
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
53
|
+
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
54
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
55
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
56
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
57
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
58
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
59
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
60
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
61
|
+
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
|
|
62
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
63
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
64
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
65
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
66
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
67
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
68
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
69
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
70
|
+
groupQuery: (jid: string, type: "get" | "set", content: import("../WABinary").BinaryNode[]) => Promise<any>;
|
|
71
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
72
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
73
|
+
groupLeave: (id: string) => Promise<void>;
|
|
74
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
75
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
76
|
+
[key: string]: string;
|
|
77
|
+
}[]>;
|
|
78
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
79
|
+
status: string;
|
|
80
|
+
jid: string;
|
|
81
|
+
}[]>;
|
|
82
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
83
|
+
status: string;
|
|
84
|
+
jid: string;
|
|
85
|
+
content: import("../WABinary").BinaryNode;
|
|
86
|
+
}[]>;
|
|
87
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
88
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
89
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
90
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
91
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
92
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
93
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
94
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
95
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
96
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
97
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
98
|
+
groupFetchAllParticipating: () => Promise<{
|
|
99
|
+
[_: string]: import("../Types").GroupMetadata;
|
|
100
|
+
}>;
|
|
101
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
102
|
+
processingMutex: {
|
|
103
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
104
|
+
};
|
|
105
|
+
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
106
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
107
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
108
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
109
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
110
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
111
|
+
jid: string;
|
|
112
|
+
exists: unknown;
|
|
113
|
+
lid: unknown;
|
|
114
|
+
}[] | undefined>;
|
|
115
|
+
fetchBlocklist: () => Promise<string[]>;
|
|
116
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
117
|
+
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
118
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
119
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
120
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
121
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
122
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
123
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
124
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
125
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
126
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
127
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
128
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
129
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
130
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
131
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
132
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
133
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
134
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
135
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
136
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
137
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
138
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
139
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
140
|
+
star: (jid: string, messages: {
|
|
141
|
+
id: string;
|
|
142
|
+
fromMe?: boolean;
|
|
143
|
+
}[], star: boolean) => Promise<void>;
|
|
144
|
+
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
145
|
+
type: "md";
|
|
146
|
+
ws: any;
|
|
147
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
148
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
149
|
+
buffer(): void;
|
|
150
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
151
|
+
flush(force?: boolean): boolean;
|
|
152
|
+
isBuffering(): boolean;
|
|
153
|
+
};
|
|
154
|
+
authState: {
|
|
155
|
+
creds: import("../Types").AuthenticationCreds;
|
|
156
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
157
|
+
};
|
|
158
|
+
signalRepository: import("../Types").SignalRepository;
|
|
159
|
+
user: import("../Types").Contact | undefined;
|
|
160
|
+
generateMessageTag: () => string;
|
|
161
|
+
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
162
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
163
|
+
waitForSocketOpen: () => Promise<void>;
|
|
164
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
165
|
+
sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
|
|
166
|
+
logout: (msg?: string) => Promise<void>;
|
|
167
|
+
end: (error: Error | undefined) => void;
|
|
168
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
169
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
170
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
171
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
172
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
173
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
174
|
+
};
|
|
175
|
+
export interface RegistrationData {
|
|
176
|
+
registrationId: number;
|
|
177
|
+
signedPreKey: SignedKeyPair;
|
|
178
|
+
noiseKey: KeyPair;
|
|
179
|
+
signedIdentityKey: KeyPair;
|
|
180
|
+
identityId: Buffer;
|
|
181
|
+
phoneId: string;
|
|
182
|
+
deviceId: string;
|
|
183
|
+
backupToken: Buffer;
|
|
184
|
+
}
|
|
185
|
+
export interface RegistrationOptions {
|
|
186
|
+
/** your phone number */
|
|
187
|
+
phoneNumber?: string;
|
|
188
|
+
/** the country code of your phone number */
|
|
189
|
+
phoneNumberCountryCode: string;
|
|
190
|
+
/** your phone number without country code */
|
|
191
|
+
phoneNumberNationalNumber: string;
|
|
192
|
+
/** the country code of your mobile network
|
|
193
|
+
* @see {@link https://de.wikipedia.org/wiki/Mobile_Country_Code}
|
|
194
|
+
*/
|
|
195
|
+
phoneNumberMobileCountryCode: string;
|
|
196
|
+
/** the network code of your mobile network
|
|
197
|
+
* @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
|
|
198
|
+
*/
|
|
199
|
+
phoneNumberMobileNetworkCode: string;
|
|
200
|
+
/**
|
|
201
|
+
* How to send the one time code
|
|
202
|
+
*/
|
|
203
|
+
method?: 'sms' | 'voice' | 'captcha';
|
|
204
|
+
/**
|
|
205
|
+
* The captcha code if it was requested
|
|
206
|
+
*/
|
|
207
|
+
captcha?: string;
|
|
208
|
+
}
|
|
209
|
+
export type RegistrationParams = RegistrationData & RegistrationOptions;
|
|
210
|
+
export declare function registrationParams(params: RegistrationParams): {
|
|
211
|
+
cc: string;
|
|
212
|
+
in: string;
|
|
213
|
+
Rc: string;
|
|
214
|
+
lg: string;
|
|
215
|
+
lc: string;
|
|
216
|
+
mistyped: string;
|
|
217
|
+
authkey: string;
|
|
218
|
+
e_regid: string;
|
|
219
|
+
e_keytype: string;
|
|
220
|
+
e_ident: string;
|
|
221
|
+
e_skey_id: string;
|
|
222
|
+
e_skey_val: string;
|
|
223
|
+
e_skey_sig: string;
|
|
224
|
+
fdid: string;
|
|
225
|
+
network_ratio_type: string;
|
|
226
|
+
expid: string;
|
|
227
|
+
simnum: string;
|
|
228
|
+
hasinrc: string;
|
|
229
|
+
pid: string;
|
|
230
|
+
id: string;
|
|
231
|
+
backup_token: string;
|
|
232
|
+
token: string;
|
|
233
|
+
fraud_checkpoint_code: string | undefined;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Requests a registration code for the given phone number.
|
|
237
|
+
*/
|
|
238
|
+
export declare function mobileRegisterCode(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
239
|
+
export declare function mobileRegisterExists(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
240
|
+
/**
|
|
241
|
+
* Registers the phone number on whatsapp with the received OTP code.
|
|
242
|
+
*/
|
|
243
|
+
export declare function mobileRegister(params: RegistrationParams & {
|
|
244
|
+
code: string;
|
|
245
|
+
}, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
246
|
+
/**
|
|
247
|
+
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
248
|
+
*/
|
|
249
|
+
export declare function mobileRegisterEncrypt(data: string): string;
|
|
250
|
+
export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
251
|
+
export interface ExistsResponse {
|
|
252
|
+
status: 'fail' | 'sent';
|
|
253
|
+
voice_length?: number;
|
|
254
|
+
voice_wait?: number;
|
|
255
|
+
sms_length?: number;
|
|
256
|
+
sms_wait?: number;
|
|
257
|
+
reason?: 'incorrect' | 'missing_param' | 'code_checkpoint';
|
|
258
|
+
login?: string;
|
|
259
|
+
flash_type?: number;
|
|
260
|
+
ab_hash?: string;
|
|
261
|
+
ab_key?: string;
|
|
262
|
+
exp_cfg?: string;
|
|
263
|
+
lid?: string;
|
|
264
|
+
image_blob?: string;
|
|
265
|
+
audio_blob?: string;
|
|
266
|
+
}
|