@d0v3riz/baileys 6.7.21 → 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.
- package/WAProto/GenerateStatics.sh +2 -3
- package/WAProto/index.js +4138 -4136
- package/lib/Defaults/index.d.ts +2 -3
- package/lib/Defaults/index.js +40 -36
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
- package/lib/Signal/Group/ciphertext-message.js +5 -2
- package/lib/Signal/Group/group-session-builder.d.ts +3 -4
- package/lib/Signal/Group/group-session-builder.js +41 -7
- package/lib/Signal/Group/group_cipher.d.ts +2 -3
- package/lib/Signal/Group/group_cipher.js +16 -14
- package/lib/Signal/Group/index.d.ts +11 -12
- package/lib/Signal/Group/index.js +57 -12
- package/lib/Signal/Group/keyhelper.d.ts +1 -2
- package/lib/Signal/Group/keyhelper.js +44 -8
- package/lib/Signal/Group/queue-job.d.ts +0 -2
- package/lib/Signal/Group/queue-job.js +5 -5
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -2
- package/lib/Signal/Group/sender-chain-key.js +9 -7
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +9 -6
- package/lib/Signal/Group/sender-key-message.d.ts +1 -2
- package/lib/Signal/Group/sender-key-message.js +12 -10
- package/lib/Signal/Group/sender-key-name.d.ts +0 -1
- package/lib/Signal/Group/sender-key-name.js +5 -2
- package/lib/Signal/Group/sender-key-record.d.ts +1 -2
- package/lib/Signal/Group/sender-key-record.js +12 -9
- package/lib/Signal/Group/sender-key-state.d.ts +2 -3
- package/lib/Signal/Group/sender-key-state.js +9 -6
- package/lib/Signal/Group/sender-message-key.d.ts +0 -1
- package/lib/Signal/Group/sender-message-key.js +7 -5
- package/lib/Signal/libsignal.d.ts +2 -3
- package/lib/Signal/libsignal.js +55 -22
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +18 -3
- package/lib/Socket/Client/types.d.ts +1 -2
- package/lib/Socket/Client/types.js +6 -4
- package/lib/Socket/Client/websocket.d.ts +1 -2
- package/lib/Socket/Client/websocket.js +26 -14
- package/lib/Socket/business.d.ts +64 -66
- package/lib/Socket/business.js +37 -32
- package/lib/Socket/chats.d.ts +19 -21
- package/lib/Socket/chats.js +141 -176
- package/lib/Socket/groups.d.ts +35 -37
- package/lib/Socket/groups.js +63 -56
- package/lib/Socket/index.d.ts +70 -102
- package/lib/Socket/index.js +9 -16
- package/lib/Socket/messages-recv.d.ts +49 -51
- package/lib/Socket/messages-recv.js +173 -180
- package/lib/Socket/messages-send.d.ts +46 -48
- package/lib/Socket/messages-send.js +84 -75
- package/lib/Socket/mex.d.ts +1 -2
- package/lib/Socket/mex.js +16 -12
- package/lib/Socket/newsletter.d.ts +44 -46
- package/lib/Socket/newsletter.js +27 -23
- package/lib/Socket/socket.d.ts +12 -13
- package/lib/Socket/socket.js +115 -135
- package/lib/Socket/usync.d.ts +14 -15
- package/lib/Socket/usync.js +11 -9
- package/lib/Types/Auth.d.ts +3 -4
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.d.ts +0 -1
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.d.ts +7 -10
- package/lib/Types/Chat.js +4 -2
- package/lib/Types/Contact.d.ts +0 -1
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.d.ts +10 -11
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.d.ts +2 -3
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.d.ts +0 -1
- package/lib/Types/Label.js +5 -3
- package/lib/Types/LabelAssociation.d.ts +0 -1
- package/lib/Types/LabelAssociation.js +5 -3
- package/lib/Types/Message.d.ts +7 -9
- package/lib/Types/Message.js +7 -7
- package/lib/Types/Newsletter.d.ts +0 -1
- package/lib/Types/Newsletter.js +7 -5
- package/lib/Types/Product.d.ts +1 -2
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.d.ts +1 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.d.ts +7 -8
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.d.ts +2 -14
- package/lib/Types/State.js +2 -13
- package/lib/Types/USync.d.ts +2 -3
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.d.ts +14 -15
- package/lib/Types/index.js +31 -15
- package/lib/Utils/auth-utils.d.ts +2 -3
- package/lib/Utils/auth-utils.js +34 -25
- package/lib/Utils/baileys-event-stream.d.ts +1 -2
- package/lib/Utils/baileys-event-stream.js +22 -15
- package/lib/Utils/business.d.ts +2 -3
- package/lib/Utils/business.js +70 -61
- package/lib/Utils/chat-utils.d.ts +7 -8
- package/lib/Utils/chat-utils.js +137 -130
- package/lib/Utils/crypto.d.ts +1 -2
- package/lib/Utils/crypto.js +86 -37
- package/lib/Utils/decode-wa-message.d.ts +4 -5
- package/lib/Utils/decode-wa-message.js +44 -38
- package/lib/Utils/event-buffer.d.ts +4 -4
- package/lib/Utils/event-buffer.js +50 -37
- package/lib/Utils/generics.d.ts +8 -9
- package/lib/Utils/generics.js +114 -87
- package/lib/Utils/history.d.ts +3 -4
- package/lib/Utils/history.js +40 -32
- package/lib/Utils/index.d.ts +17 -18
- package/lib/Utils/index.js +33 -18
- package/lib/Utils/link-preview.d.ts +3 -4
- package/lib/Utils/link-preview.js +47 -10
- package/lib/Utils/logger.d.ts +6 -8
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +8 -9
- package/lib/Utils/lt-hash.js +26 -23
- package/lib/Utils/make-mutex.d.ts +0 -1
- package/lib/Utils/make-mutex.js +9 -5
- package/lib/Utils/messages-media.d.ts +10 -11
- package/lib/Utils/messages-media.js +203 -141
- package/lib/Utils/messages.d.ts +6 -7
- package/lib/Utils/messages.js +199 -190
- package/lib/Utils/noise-handler.d.ts +4 -5
- package/lib/Utils/noise-handler.js +26 -22
- package/lib/Utils/process-message.d.ts +4 -5
- package/lib/Utils/process-message.js +104 -95
- package/lib/Utils/signal.d.ts +4 -5
- package/lib/Utils/signal.js +52 -47
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +26 -23
- package/lib/Utils/validate-connection.d.ts +3 -4
- package/lib/Utils/validate-connection.js +58 -52
- package/lib/WABinary/constants.d.ts +0 -1
- package/lib/WABinary/constants.js +11 -9
- package/lib/WABinary/decode.d.ts +1 -2
- package/lib/WABinary/decode.js +51 -13
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +41 -5
- package/lib/WABinary/generic-utils.d.ts +3 -4
- package/lib/WABinary/generic-utils.js +38 -30
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +21 -6
- package/lib/WABinary/jid-utils.d.ts +0 -1
- package/lib/WABinary/jid-utils.js +35 -21
- package/lib/WABinary/types.d.ts +1 -2
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +1 -2
- package/lib/WAM/BinaryInfo.js +5 -2
- package/lib/WAM/constants.d.ts +0 -1
- package/lib/WAM/constants.js +6 -4
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.js +14 -12
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +19 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -6
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +12 -9
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -6
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -7
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +21 -19
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +5 -2
- package/lib/WAUSync/Protocols/index.d.ts +4 -5
- package/lib/WAUSync/Protocols/index.js +20 -5
- package/lib/WAUSync/USyncQuery.d.ts +3 -4
- package/lib/WAUSync/USyncQuery.js +20 -18
- package/lib/WAUSync/USyncUser.d.ts +5 -6
- package/lib/WAUSync/USyncUser.js +5 -2
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +19 -4
- package/lib/index.d.ts +8 -9
- package/lib/index.js +30 -11
- package/package.json +26 -26
- package/WAProto/fix-imports.js +0 -29
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/queue-job.d.ts.map +0 -1
- package/lib/Signal/Group/queue-job.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts +0 -219
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js +0 -351
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Socket/usync.d.ts.map +0 -1
- package/lib/Socket/usync.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
- package/lib/Utils/baileys-event-stream.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeMessagesSocket = void 0;
|
|
7
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
|
8
|
+
const boom_1 = require("@hapi/boom");
|
|
9
|
+
const WAProto_1 = require("../../WAProto");
|
|
10
|
+
const Defaults_1 = require("../Defaults");
|
|
11
|
+
const Utils_1 = require("../Utils");
|
|
12
|
+
const link_preview_1 = require("../Utils/link-preview");
|
|
13
|
+
const WABinary_1 = require("../WABinary");
|
|
14
|
+
const WAUSync_1 = require("../WAUSync");
|
|
15
|
+
const groups_1 = require("./groups");
|
|
16
|
+
const newsletter_1 = require("./newsletter");
|
|
17
|
+
const makeMessagesSocket = (config) => {
|
|
12
18
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata } = config;
|
|
13
|
-
const sock = makeNewsletterSocket(makeGroupsSocket(config));
|
|
19
|
+
const sock = (0, newsletter_1.makeNewsletterSocket)((0, groups_1.makeGroupsSocket)(config));
|
|
14
20
|
const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral } = sock;
|
|
15
21
|
const userDevicesCache = config.userDevicesCache ||
|
|
16
|
-
new
|
|
17
|
-
stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
|
|
22
|
+
new node_cache_1.default({
|
|
23
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
|
|
18
24
|
useClones: false
|
|
19
25
|
});
|
|
20
26
|
let mediaConn;
|
|
@@ -27,13 +33,13 @@ export const makeMessagesSocket = (config) => {
|
|
|
27
33
|
attrs: {
|
|
28
34
|
type: 'set',
|
|
29
35
|
xmlns: 'w:m',
|
|
30
|
-
to: S_WHATSAPP_NET
|
|
36
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
31
37
|
},
|
|
32
38
|
content: [{ tag: 'media_conn', attrs: {} }]
|
|
33
39
|
});
|
|
34
|
-
const mediaConnNode = getBinaryNodeChild(result, 'media_conn');
|
|
40
|
+
const mediaConnNode = (0, WABinary_1.getBinaryNodeChild)(result, 'media_conn');
|
|
35
41
|
const node = {
|
|
36
|
-
hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
|
|
42
|
+
hosts: (0, WABinary_1.getBinaryNodeChildren)(mediaConnNode, 'host').map(({ attrs }) => ({
|
|
37
43
|
hostname: attrs.hostname,
|
|
38
44
|
maxContentLengthBytes: +attrs.maxContentLengthBytes
|
|
39
45
|
})),
|
|
@@ -52,9 +58,6 @@ export const makeMessagesSocket = (config) => {
|
|
|
52
58
|
* used for receipts of phone call, read, delivery etc.
|
|
53
59
|
* */
|
|
54
60
|
const sendReceipt = async (jid, participant, messageIds, type) => {
|
|
55
|
-
if (!messageIds || messageIds.length === 0) {
|
|
56
|
-
throw new Boom('missing ids in receipt');
|
|
57
|
-
}
|
|
58
61
|
const node = {
|
|
59
62
|
tag: 'receipt',
|
|
60
63
|
attrs: {
|
|
@@ -63,9 +66,9 @@ export const makeMessagesSocket = (config) => {
|
|
|
63
66
|
};
|
|
64
67
|
const isReadReceipt = type === 'read' || type === 'read-self';
|
|
65
68
|
if (isReadReceipt) {
|
|
66
|
-
node.attrs.t = unixTimestampSeconds().toString();
|
|
69
|
+
node.attrs.t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
67
70
|
}
|
|
68
|
-
if (type === 'sender' && isJidUser(jid)) {
|
|
71
|
+
if (type === 'sender' && (0, WABinary_1.isJidUser)(jid)) {
|
|
69
72
|
node.attrs.recipient = jid;
|
|
70
73
|
node.attrs.to = participant;
|
|
71
74
|
}
|
|
@@ -96,7 +99,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
96
99
|
};
|
|
97
100
|
/** Correctly bulk send receipts to multiple chats, participants */
|
|
98
101
|
const sendReceipts = async (keys, type) => {
|
|
99
|
-
const recps = aggregateMessageKeysNotFromMe(keys);
|
|
102
|
+
const recps = (0, Utils_1.aggregateMessageKeysNotFromMe)(keys);
|
|
100
103
|
for (const { jid, participant, messageIds } of recps) {
|
|
101
104
|
await sendReceipt(jid, participant, messageIds, type);
|
|
102
105
|
}
|
|
@@ -110,6 +113,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
110
113
|
};
|
|
111
114
|
/** Fetch all the devices we've to send a message to */
|
|
112
115
|
const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
|
|
116
|
+
var _a;
|
|
113
117
|
const deviceResults = [];
|
|
114
118
|
if (!useCache) {
|
|
115
119
|
logger.debug('not using cache for devices');
|
|
@@ -117,8 +121,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
117
121
|
const toFetch = [];
|
|
118
122
|
jids = Array.from(new Set(jids));
|
|
119
123
|
for (let jid of jids) {
|
|
120
|
-
const user = jidDecode(jid)
|
|
121
|
-
jid = jidNormalizedUser(jid);
|
|
124
|
+
const user = (_a = (0, WABinary_1.jidDecode)(jid)) === null || _a === void 0 ? void 0 : _a.user;
|
|
125
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
122
126
|
if (useCache) {
|
|
123
127
|
const devices = userDevicesCache.get(user);
|
|
124
128
|
if (devices) {
|
|
@@ -136,17 +140,17 @@ export const makeMessagesSocket = (config) => {
|
|
|
136
140
|
if (!toFetch.length) {
|
|
137
141
|
return deviceResults;
|
|
138
142
|
}
|
|
139
|
-
const query = new USyncQuery().withContext('message').withDeviceProtocol();
|
|
143
|
+
const query = new WAUSync_1.USyncQuery().withContext('message').withDeviceProtocol();
|
|
140
144
|
for (const jid of toFetch) {
|
|
141
|
-
query.withUser(new USyncUser().withId(jid));
|
|
145
|
+
query.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
142
146
|
}
|
|
143
147
|
const result = await sock.executeUSyncQuery(query);
|
|
144
148
|
if (result) {
|
|
145
|
-
const extracted = extractDeviceJids(result
|
|
149
|
+
const extracted = (0, Utils_1.extractDeviceJids)(result === null || result === void 0 ? void 0 : result.list, authState.creds.me.id, ignoreZeroDevices);
|
|
146
150
|
const deviceMap = {};
|
|
147
151
|
for (const item of extracted) {
|
|
148
152
|
deviceMap[item.user] = deviceMap[item.user] || [];
|
|
149
|
-
deviceMap[item.user]
|
|
153
|
+
deviceMap[item.user].push(item);
|
|
150
154
|
deviceResults.push(item);
|
|
151
155
|
}
|
|
152
156
|
for (const key in deviceMap) {
|
|
@@ -178,7 +182,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
178
182
|
attrs: {
|
|
179
183
|
xmlns: 'encrypt',
|
|
180
184
|
type: 'get',
|
|
181
|
-
to: S_WHATSAPP_NET
|
|
185
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
182
186
|
},
|
|
183
187
|
content: [
|
|
184
188
|
{
|
|
@@ -191,26 +195,28 @@ export const makeMessagesSocket = (config) => {
|
|
|
191
195
|
}
|
|
192
196
|
]
|
|
193
197
|
});
|
|
194
|
-
await parseAndInjectE2ESessions(result, signalRepository);
|
|
198
|
+
await (0, Utils_1.parseAndInjectE2ESessions)(result, signalRepository);
|
|
195
199
|
didFetchNewSession = true;
|
|
196
200
|
}
|
|
197
201
|
return didFetchNewSession;
|
|
198
202
|
};
|
|
199
203
|
const sendPeerDataOperationMessage = async (pdoMessage) => {
|
|
204
|
+
var _a;
|
|
200
205
|
//TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
|
|
201
|
-
if (!authState.creds.me
|
|
202
|
-
throw new Boom('Not authenticated');
|
|
206
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
207
|
+
throw new boom_1.Boom('Not authenticated');
|
|
203
208
|
}
|
|
204
209
|
const protocolMessage = {
|
|
205
210
|
protocolMessage: {
|
|
206
211
|
peerDataOperationRequestMessage: pdoMessage,
|
|
207
|
-
type: proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
212
|
+
type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
208
213
|
}
|
|
209
214
|
};
|
|
210
|
-
const meJid = jidNormalizedUser(authState.creds.me.id);
|
|
215
|
+
const meJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
|
|
211
216
|
const msgId = await relayMessage(meJid, protocolMessage, {
|
|
212
217
|
additionalAttributes: {
|
|
213
218
|
category: 'peer',
|
|
219
|
+
// eslint-disable-next-line camelcase
|
|
214
220
|
push_priority: 'high_force'
|
|
215
221
|
}
|
|
216
222
|
});
|
|
@@ -227,7 +233,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
227
233
|
if (!jid) {
|
|
228
234
|
return {};
|
|
229
235
|
}
|
|
230
|
-
const bytes = encodeWAMessage(patchedMessage);
|
|
236
|
+
const bytes = (0, Utils_1.encodeWAMessage)(patchedMessage);
|
|
231
237
|
const { type, ciphertext } = await signalRepository.encryptMessage({ jid, data: bytes });
|
|
232
238
|
if (type === 'pkmsg') {
|
|
233
239
|
shouldIncludeDeviceIdentity = true;
|
|
@@ -252,19 +258,20 @@ export const makeMessagesSocket = (config) => {
|
|
|
252
258
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
253
259
|
};
|
|
254
260
|
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
|
|
261
|
+
var _a;
|
|
255
262
|
const meId = authState.creds.me.id;
|
|
256
263
|
let shouldIncludeDeviceIdentity = false;
|
|
257
|
-
const { user, server } = jidDecode(jid);
|
|
264
|
+
const { user, server } = (0, WABinary_1.jidDecode)(jid);
|
|
258
265
|
const statusJid = 'status@broadcast';
|
|
259
266
|
const isGroup = server === 'g.us';
|
|
260
267
|
const isStatus = jid === statusJid;
|
|
261
268
|
const isLid = server === 'lid';
|
|
262
269
|
const isNewsletter = server === 'newsletter';
|
|
263
|
-
msgId = msgId || generateMessageIDV2(sock.user
|
|
270
|
+
msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
|
|
264
271
|
useUserDevicesCache = useUserDevicesCache !== false;
|
|
265
272
|
useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus;
|
|
266
273
|
const participants = [];
|
|
267
|
-
const destinationJid = !isStatus ? jidEncode(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
|
|
274
|
+
const destinationJid = !isStatus ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
|
|
268
275
|
const binaryNodeContent = [];
|
|
269
276
|
const devices = [];
|
|
270
277
|
const meMsg = {
|
|
@@ -282,10 +289,11 @@ export const makeMessagesSocket = (config) => {
|
|
|
282
289
|
if (!isGroup && !isStatus) {
|
|
283
290
|
additionalAttributes = { ...additionalAttributes, device_fanout: 'false' };
|
|
284
291
|
}
|
|
285
|
-
const { user, device } = jidDecode(participant.jid);
|
|
292
|
+
const { user, device } = (0, WABinary_1.jidDecode)(participant.jid);
|
|
286
293
|
devices.push({ user, device });
|
|
287
294
|
}
|
|
288
295
|
await authState.keys.transaction(async () => {
|
|
296
|
+
var _a, _b, _c, _d, _e;
|
|
289
297
|
const mediaType = getMediaType(message);
|
|
290
298
|
if (mediaType) {
|
|
291
299
|
extraAttrs['mediatype'] = mediaType;
|
|
@@ -293,7 +301,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
293
301
|
if (isNewsletter) {
|
|
294
302
|
// Patch message if needed, then encode as plaintext
|
|
295
303
|
const patched = patchMessageBeforeSending ? await patchMessageBeforeSending(message, []) : message;
|
|
296
|
-
const bytes = encodeNewsletterMessage(patched);
|
|
304
|
+
const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
|
|
297
305
|
binaryNodeContent.push({
|
|
298
306
|
tag: 'plaintext',
|
|
299
307
|
attrs: {},
|
|
@@ -313,14 +321,14 @@ export const makeMessagesSocket = (config) => {
|
|
|
313
321
|
await sendNode(stanza);
|
|
314
322
|
return;
|
|
315
323
|
}
|
|
316
|
-
if (normalizeMessageContent(message)
|
|
324
|
+
if ((_a = (0, Utils_1.normalizeMessageContent)(message)) === null || _a === void 0 ? void 0 : _a.pinInChatMessage) {
|
|
317
325
|
extraAttrs['decrypt-fail'] = 'hide';
|
|
318
326
|
}
|
|
319
327
|
if (isGroup || isStatus) {
|
|
320
328
|
const [groupData, senderKeyMap] = await Promise.all([
|
|
321
329
|
(async () => {
|
|
322
330
|
let groupData = useCachedGroupMetadata && cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined;
|
|
323
|
-
if (groupData && Array.isArray(groupData
|
|
331
|
+
if (groupData && Array.isArray(groupData === null || groupData === void 0 ? void 0 : groupData.participants)) {
|
|
324
332
|
logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
|
|
325
333
|
}
|
|
326
334
|
else if (!isStatus) {
|
|
@@ -344,7 +352,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
344
352
|
if (!isStatus) {
|
|
345
353
|
additionalAttributes = {
|
|
346
354
|
...additionalAttributes,
|
|
347
|
-
addressing_mode: groupData
|
|
355
|
+
addressing_mode: (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) || 'pn'
|
|
348
356
|
};
|
|
349
357
|
}
|
|
350
358
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
|
@@ -352,9 +360,9 @@ export const makeMessagesSocket = (config) => {
|
|
|
352
360
|
}
|
|
353
361
|
const patched = await patchMessageBeforeSending(message);
|
|
354
362
|
if (Array.isArray(patched)) {
|
|
355
|
-
throw new Boom('Per-jid patching is not supported in groups');
|
|
363
|
+
throw new boom_1.Boom('Per-jid patching is not supported in groups');
|
|
356
364
|
}
|
|
357
|
-
const bytes = encodeWAMessage(patched);
|
|
365
|
+
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
358
366
|
const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
|
|
359
367
|
group: destinationJid,
|
|
360
368
|
data: bytes,
|
|
@@ -363,7 +371,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
363
371
|
const senderKeyJids = [];
|
|
364
372
|
// ensure a connection is established with every device
|
|
365
373
|
for (const { user, device } of devices) {
|
|
366
|
-
const jid = jidEncode(user, groupData
|
|
374
|
+
const jid = (0, WABinary_1.jidEncode)(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
|
|
367
375
|
if (!senderKeyMap[jid] || !!participant) {
|
|
368
376
|
senderKeyJids.push(jid);
|
|
369
377
|
// store that this person has had the sender keys sent to them
|
|
@@ -393,13 +401,13 @@ export const makeMessagesSocket = (config) => {
|
|
|
393
401
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
394
402
|
}
|
|
395
403
|
else {
|
|
396
|
-
const { user: meUser } = jidDecode(meId);
|
|
404
|
+
const { user: meUser } = (0, WABinary_1.jidDecode)(meId);
|
|
397
405
|
if (!participant) {
|
|
398
406
|
devices.push({ user });
|
|
399
407
|
if (user !== meUser) {
|
|
400
408
|
devices.push({ user: meUser });
|
|
401
409
|
}
|
|
402
|
-
if (additionalAttributes
|
|
410
|
+
if ((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) !== 'peer') {
|
|
403
411
|
const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
|
|
404
412
|
devices.push(...additionalDevices);
|
|
405
413
|
}
|
|
@@ -409,7 +417,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
409
417
|
const otherJids = [];
|
|
410
418
|
for (const { user, device } of devices) {
|
|
411
419
|
const isMe = user === meUser;
|
|
412
|
-
const jid = jidEncode(isMe && isLid ? authState.creds
|
|
420
|
+
const jid = (0, WABinary_1.jidEncode)(isMe && isLid ? ((_c = (_b = authState.creds) === null || _b === void 0 ? void 0 : _b.me) === null || _c === void 0 ? void 0 : _c.lid.split(':')[0]) || user : user, isLid ? 'lid' : 's.whatsapp.net', device);
|
|
413
421
|
if (isMe) {
|
|
414
422
|
meJids.push(jid);
|
|
415
423
|
}
|
|
@@ -428,8 +436,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
428
436
|
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
|
|
429
437
|
}
|
|
430
438
|
if (participants.length) {
|
|
431
|
-
if (additionalAttributes
|
|
432
|
-
const peerNode = participants[0]
|
|
439
|
+
if ((additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes['category']) === 'peer') {
|
|
440
|
+
const peerNode = (_e = (_d = participants[0]) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e[0];
|
|
433
441
|
if (peerNode) {
|
|
434
442
|
binaryNodeContent.push(peerNode); // push only enc
|
|
435
443
|
}
|
|
@@ -455,11 +463,11 @@ export const makeMessagesSocket = (config) => {
|
|
|
455
463
|
// ensure the message is only sent to that person
|
|
456
464
|
// if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
|
|
457
465
|
if (participant) {
|
|
458
|
-
if (isJidGroup(destinationJid)) {
|
|
466
|
+
if ((0, WABinary_1.isJidGroup)(destinationJid)) {
|
|
459
467
|
stanza.attrs.to = destinationJid;
|
|
460
468
|
stanza.attrs.participant = participant.jid;
|
|
461
469
|
}
|
|
462
|
-
else if (areJidsSameUser(participant.jid, meId)) {
|
|
470
|
+
else if ((0, WABinary_1.areJidsSameUser)(participant.jid, meId)) {
|
|
463
471
|
stanza.attrs.to = participant.jid;
|
|
464
472
|
stanza.attrs.recipient = destinationJid;
|
|
465
473
|
}
|
|
@@ -475,7 +483,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
475
483
|
stanza.content.push({
|
|
476
484
|
tag: 'device-identity',
|
|
477
485
|
attrs: {},
|
|
478
|
-
content: encodeSignedDeviceIdentity(authState.creds.account, true)
|
|
486
|
+
content: (0, Utils_1.encodeSignedDeviceIdentity)(authState.creds.account, true)
|
|
479
487
|
});
|
|
480
488
|
logger.debug({ jid }, 'adding device identity');
|
|
481
489
|
}
|
|
@@ -542,11 +550,11 @@ export const makeMessagesSocket = (config) => {
|
|
|
542
550
|
}
|
|
543
551
|
};
|
|
544
552
|
const getPrivacyTokens = async (jids) => {
|
|
545
|
-
const t = unixTimestampSeconds().toString();
|
|
553
|
+
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
546
554
|
const result = await query({
|
|
547
555
|
tag: 'iq',
|
|
548
556
|
attrs: {
|
|
549
|
-
to: S_WHATSAPP_NET,
|
|
557
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
550
558
|
type: 'set',
|
|
551
559
|
xmlns: 'privacy'
|
|
552
560
|
},
|
|
@@ -557,7 +565,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
557
565
|
content: jids.map(jid => ({
|
|
558
566
|
tag: 'token',
|
|
559
567
|
attrs: {
|
|
560
|
-
jid: jidNormalizedUser(jid),
|
|
568
|
+
jid: (0, WABinary_1.jidNormalizedUser)(jid),
|
|
561
569
|
t,
|
|
562
570
|
type: 'trusted_contact'
|
|
563
571
|
}
|
|
@@ -567,8 +575,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
567
575
|
});
|
|
568
576
|
return result;
|
|
569
577
|
};
|
|
570
|
-
const waUploadToServer = getWAUploadToServer(config, refreshMediaConn);
|
|
571
|
-
const waitForMsgMediaUpdate = bindWaitForEvent(ev, 'messages.media-update');
|
|
578
|
+
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
579
|
+
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
572
580
|
return {
|
|
573
581
|
...sock,
|
|
574
582
|
getPrivacyTokens,
|
|
@@ -584,10 +592,10 @@ export const makeMessagesSocket = (config) => {
|
|
|
584
592
|
createParticipantNodes,
|
|
585
593
|
getUSyncDevices,
|
|
586
594
|
updateMediaMessage: async (message) => {
|
|
587
|
-
const content = assertMediaContent(message.message);
|
|
595
|
+
const content = (0, Utils_1.assertMediaContent)(message.message);
|
|
588
596
|
const mediaKey = content.mediaKey;
|
|
589
597
|
const meId = authState.creds.me.id;
|
|
590
|
-
const node = await encryptMediaRetryRequest(message.key, mediaKey, meId);
|
|
598
|
+
const node = await (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
|
|
591
599
|
let error = undefined;
|
|
592
600
|
await Promise.all([
|
|
593
601
|
sendNode(node),
|
|
@@ -599,16 +607,16 @@ export const makeMessagesSocket = (config) => {
|
|
|
599
607
|
}
|
|
600
608
|
else {
|
|
601
609
|
try {
|
|
602
|
-
const media = await decryptMediaRetryData(result.media, mediaKey, result.key.id);
|
|
603
|
-
if (media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
604
|
-
const resultStr = proto.MediaRetryNotification.ResultType[media.result];
|
|
605
|
-
throw new Boom(`Media re-upload failed by device (${resultStr})`, {
|
|
610
|
+
const media = await (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
|
|
611
|
+
if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
612
|
+
const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result];
|
|
613
|
+
throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, {
|
|
606
614
|
data: media,
|
|
607
|
-
statusCode: getStatusCodeForMediaRetry(media.result) || 404
|
|
615
|
+
statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404
|
|
608
616
|
});
|
|
609
617
|
}
|
|
610
618
|
content.directPath = media.directPath;
|
|
611
|
-
content.url = getUrlFromDirectPath(content.directPath);
|
|
619
|
+
content.url = (0, Utils_1.getUrlFromDirectPath)(content.directPath);
|
|
612
620
|
logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful');
|
|
613
621
|
}
|
|
614
622
|
catch (err) {
|
|
@@ -626,24 +634,25 @@ export const makeMessagesSocket = (config) => {
|
|
|
626
634
|
return message;
|
|
627
635
|
},
|
|
628
636
|
sendMessage: async (jid, content, options = {}) => {
|
|
637
|
+
var _a, _b, _c;
|
|
629
638
|
const userJid = authState.creds.me.id;
|
|
630
639
|
if (typeof content === 'object' &&
|
|
631
640
|
'disappearingMessagesInChat' in content &&
|
|
632
641
|
typeof content['disappearingMessagesInChat'] !== 'undefined' &&
|
|
633
|
-
isJidGroup(jid)) {
|
|
642
|
+
(0, WABinary_1.isJidGroup)(jid)) {
|
|
634
643
|
const { disappearingMessagesInChat } = content;
|
|
635
644
|
const value = typeof disappearingMessagesInChat === 'boolean'
|
|
636
645
|
? disappearingMessagesInChat
|
|
637
|
-
? WA_DEFAULT_EPHEMERAL
|
|
646
|
+
? Defaults_1.WA_DEFAULT_EPHEMERAL
|
|
638
647
|
: 0
|
|
639
648
|
: disappearingMessagesInChat;
|
|
640
649
|
await groupToggleEphemeral(jid, value);
|
|
641
650
|
}
|
|
642
651
|
else {
|
|
643
|
-
const fullMsg = await generateWAMessage(jid, content, {
|
|
652
|
+
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
644
653
|
logger,
|
|
645
654
|
userJid,
|
|
646
|
-
getUrlInfo: text => getUrlInfo(text, {
|
|
655
|
+
getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
|
|
647
656
|
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
648
657
|
fetchOpts: {
|
|
649
658
|
timeout: 3000,
|
|
@@ -657,7 +666,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
657
666
|
upload: waUploadToServer,
|
|
658
667
|
mediaCache: config.mediaCache,
|
|
659
668
|
options: config.options,
|
|
660
|
-
messageId: generateMessageIDV2(sock.user
|
|
669
|
+
messageId: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
|
|
661
670
|
...options
|
|
662
671
|
});
|
|
663
672
|
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
@@ -669,7 +678,7 @@ export const makeMessagesSocket = (config) => {
|
|
|
669
678
|
// required for delete
|
|
670
679
|
if (isDeleteMsg) {
|
|
671
680
|
// if the chat is a group, and I am not the author, then delete the message as an admin
|
|
672
|
-
if (isJidGroup(content.delete
|
|
681
|
+
if ((0, WABinary_1.isJidGroup)((_b = content.delete) === null || _b === void 0 ? void 0 : _b.remoteJid) && !((_c = content.delete) === null || _c === void 0 ? void 0 : _c.fromMe)) {
|
|
673
682
|
additionalAttributes.edit = '8';
|
|
674
683
|
}
|
|
675
684
|
else {
|
|
@@ -710,4 +719,4 @@ export const makeMessagesSocket = (config) => {
|
|
|
710
719
|
}
|
|
711
720
|
};
|
|
712
721
|
};
|
|
713
|
-
|
|
722
|
+
exports.makeMessagesSocket = makeMessagesSocket;
|
package/lib/Socket/mex.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BinaryNode } from '../WABinary';
|
|
2
2
|
export declare const executeWMexQuery: <T>(variables: Record<string, unknown>, queryId: string, dataPath: string, query: (node: BinaryNode) => Promise<BinaryNode>, generateMessageTag: () => string) => Promise<T>;
|
|
3
|
-
//# sourceMappingURL=mex.d.ts.map
|
package/lib/Socket/mex.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeWMexQuery = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
3
6
|
const wMexQuery = (variables, queryId, query, generateMessageTag) => {
|
|
4
7
|
return query({
|
|
5
8
|
tag: 'iq',
|
|
6
9
|
attrs: {
|
|
7
10
|
id: generateMessageTag(),
|
|
8
11
|
type: 'get',
|
|
9
|
-
to: S_WHATSAPP_NET,
|
|
12
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
10
13
|
xmlns: 'w:mex'
|
|
11
14
|
},
|
|
12
15
|
content: [
|
|
@@ -18,25 +21,26 @@ const wMexQuery = (variables, queryId, query, generateMessageTag) => {
|
|
|
18
21
|
]
|
|
19
22
|
});
|
|
20
23
|
};
|
|
21
|
-
|
|
24
|
+
const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
|
|
25
|
+
var _a, _b;
|
|
22
26
|
const result = await wMexQuery(variables, queryId, query, generateMessageTag);
|
|
23
|
-
const child = getBinaryNodeChild(result, 'result');
|
|
24
|
-
if (child
|
|
27
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result');
|
|
28
|
+
if (child === null || child === void 0 ? void 0 : child.content) {
|
|
25
29
|
const data = JSON.parse(child.content.toString());
|
|
26
30
|
if (data.errors && data.errors.length > 0) {
|
|
27
31
|
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ');
|
|
28
32
|
const firstError = data.errors[0];
|
|
29
|
-
const errorCode = firstError.extensions
|
|
30
|
-
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError });
|
|
33
|
+
const errorCode = ((_a = firstError.extensions) === null || _a === void 0 ? void 0 : _a.error_code) || 400;
|
|
34
|
+
throw new boom_1.Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError });
|
|
31
35
|
}
|
|
32
|
-
const response = dataPath ? data
|
|
36
|
+
const response = dataPath ? (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b[dataPath] : data === null || data === void 0 ? void 0 : data.data;
|
|
33
37
|
if (typeof response !== 'undefined') {
|
|
34
38
|
return response;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
const action = (dataPath || '').startsWith('xwa2_')
|
|
38
42
|
? dataPath.substring(5).replace(/_/g, ' ')
|
|
39
|
-
: dataPath
|
|
40
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result });
|
|
43
|
+
: dataPath === null || dataPath === void 0 ? void 0 : dataPath.replace(/_/g, ' ');
|
|
44
|
+
throw new boom_1.Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result });
|
|
41
45
|
};
|
|
42
|
-
|
|
46
|
+
exports.executeWMexQuery = executeWMexQuery;
|