@vinzsocket/baileys 2.8.20 → 2.8.35
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/lib/Defaults/index.js +38 -31
- package/lib/Signal/Group/ciphertext-message.js +9 -2
- package/lib/Signal/Group/group-session-builder.js +15 -7
- package/lib/Signal/Group/group_cipher.js +21 -13
- package/lib/Signal/Group/index.js +79 -12
- package/lib/Signal/Group/keyhelper.js +16 -6
- package/lib/Signal/Group/queue-job.js +9 -2
- package/lib/Signal/Group/sender-chain-key.js +14 -6
- package/lib/Signal/Group/sender-key-distribution-message.js +13 -6
- package/lib/Signal/Group/sender-key-message.js +17 -9
- package/lib/Signal/Group/sender-key-name.js +9 -2
- package/lib/Signal/Group/sender-key-record.js +16 -9
- package/lib/Signal/Group/sender-key-state.js +13 -6
- package/lib/Signal/Group/sender-message-key.js +12 -4
- package/lib/Signal/libsignal.js +35 -26
- package/lib/Signal/lid-mapping.js +27 -19
- package/lib/Socket/Client/index.js +27 -3
- package/lib/Socket/Client/types.js +11 -4
- package/lib/Socket/Client/websocket.js +19 -11
- package/lib/Socket/business.js +41 -34
- package/lib/Socket/chats.js +103 -95
- package/lib/Socket/communities.js +58 -49
- package/lib/Socket/groups.js +59 -51
- package/lib/Socket/index.js +11 -6
- package/lib/Socket/messages-recv.js +153 -145
- package/lib/Socket/messages-send.js +112 -104
- package/lib/Socket/mex.js +15 -8
- package/lib/Socket/newsletter.js +30 -23
- package/lib/Socket/socket.js +112 -105
- package/lib/Store/index.js +49 -4
- package/lib/Store/make-cache-manager-store.js +19 -11
- package/lib/Store/make-in-memory-store.js +38 -29
- package/lib/Store/make-ordered-dictionary.js +9 -2
- package/lib/Store/object-repository.js +9 -2
- package/lib/Types/Auth.js +5 -2
- package/lib/Types/Bussines.js +5 -2
- package/lib/Types/Call.js +5 -2
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.js +5 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +5 -2
- package/lib/Types/Label.js +8 -2
- package/lib/Types/LabelAssociation.js +8 -2
- package/lib/Types/Message.js +18 -6
- package/lib/Types/Newsletter.js +10 -4
- package/lib/Types/Product.js +5 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -3
- package/lib/Types/State.js +9 -3
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +155 -14
- package/lib/Utils/auth-utils.js +35 -25
- package/lib/Utils/baileys-event-stream.js +24 -15
- package/lib/Utils/business.js +72 -59
- package/lib/Utils/chat-utils.js +94 -77
- package/lib/Utils/crypto.js +55 -30
- package/lib/Utils/decode-wa-message.js +47 -37
- package/lib/Utils/event-buffer.js +25 -17
- package/lib/Utils/extended-messages.js +16 -9
- package/lib/Utils/generics.js +101 -62
- package/lib/Utils/history.js +33 -23
- package/lib/Utils/index.js +236 -22
- package/lib/Utils/lid-resolver.js +14 -5
- package/lib/Utils/link-preview.js +14 -7
- package/lib/Utils/logger.js +10 -4
- package/lib/Utils/lt-hash.js +10 -4
- package/lib/Utils/make-mutex.js +11 -3
- package/lib/Utils/mention.js +14 -4
- package/lib/Utils/message-retry-manager.js +13 -6
- package/lib/Utils/messages-media.js +128 -93
- package/lib/Utils/messages.js +125 -98
- package/lib/Utils/noise-handler.js +28 -21
- package/lib/Utils/process-message.js +74 -63
- package/lib/Utils/signal.js +48 -33
- package/lib/Utils/use-multi-file-auth-state.js +27 -20
- package/lib/Utils/validate-connection.js +57 -47
- package/lib/WABinary/constants.js +10 -4
- package/lib/WABinary/decode.js +20 -10
- package/lib/WABinary/encode.js +12 -4
- package/lib/WABinary/generic-utils.js +32 -15
- package/lib/WABinary/index.js +60 -6
- package/lib/WABinary/jid-utils.js +39 -20
- package/lib/WABinary/types.js +4 -2
- package/lib/WAM/BinaryInfo.js +9 -2
- package/lib/WAM/constants.js +13001 -1
- package/lib/WAM/encode.js +17 -10
- package/lib/WAM/index.js +38 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +12 -5
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -6
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +11 -4
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -4
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +11 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +26 -19
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +9 -2
- package/lib/WAUSync/Protocols/index.js +60 -6
- package/lib/WAUSync/USyncQuery.js +24 -17
- package/lib/WAUSync/USyncUser.js +9 -2
- package/lib/WAUSync/index.js +38 -4
- package/lib/index.js +114 -12
- package/package.json +2 -1
- package/lib/Defaults/index.d.ts +0 -58
- 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 +0 -10
- 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 +0 -15
- 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 +0 -18
- 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 +0 -12
- 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 +0 -11
- 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 +0 -2
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- 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 +0 -17
- 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 +0 -19
- 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 +0 -18
- 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 +0 -31
- 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 +0 -39
- 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 +0 -12
- 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 +0 -8
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -30
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts +0 -3
- 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 +0 -16
- 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 +0 -13
- 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 +0 -188
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts +0 -98
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts +0 -233
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts +0 -137
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts +0 -220
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts +0 -173
- 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 +0 -169
- 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 +0 -3
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts +0 -147
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts +0 -50
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/make-cache-manager-store.d.ts +0 -17
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -14
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -105
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts +0 -14
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts +0 -123
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts +0 -24
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts +0 -199
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts +0 -66
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts +0 -47
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts +0 -30
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts +0 -300
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Newsletter.d.ts +0 -135
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Types/Product.d.ts +0 -79
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts +0 -82
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts +0 -130
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts +0 -39
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts +0 -65
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts +0 -19
- 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 +0 -17
- 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 +0 -23
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts +0 -71
- 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 +0 -41
- 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 +0 -46
- 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 +0 -34
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/extended-messages.d.ts +0 -73
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts +0 -20
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/index.d.ts +0 -22
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/lid-resolver.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -22
- 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 +0 -12
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts +0 -13
- 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 +0 -8
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/mention.d.ts +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -82
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts +0 -113
- 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 +0 -76
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts +0 -20
- 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 +0 -43
- 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 +0 -34
- 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 +0 -13
- 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 +0 -11
- 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 +0 -28
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts +0 -15
- 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 +0 -6
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts +0 -37
- 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 +0 -19
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts +0 -9
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts +0 -40
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts +0 -4
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- 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 +0 -23
- 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 +0 -13
- 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 +0 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
- 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 +0 -9
- 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 +0 -6
- 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 +0 -30
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -13
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts +0 -4
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SenderMessageKey = void 0;
|
|
7
|
+
var _crypto = require("libsignal/src/crypto.js");
|
|
1
8
|
/* @ts-ignore */
|
|
2
|
-
|
|
3
|
-
|
|
9
|
+
|
|
10
|
+
class SenderMessageKey {
|
|
4
11
|
constructor(iteration, seed) {
|
|
5
|
-
const derivative = deriveSecrets(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'));
|
|
12
|
+
const derivative = (0, _crypto.deriveSecrets)(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'));
|
|
6
13
|
const keys = new Uint8Array(32);
|
|
7
14
|
keys.set(new Uint8Array(derivative[0].slice(16)));
|
|
8
15
|
keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16);
|
|
@@ -24,4 +31,5 @@ export class SenderMessageKey {
|
|
|
24
31
|
return this.seed;
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
|
-
//# sourceMappingURL=sender-message-key.js.map
|
|
34
|
+
//# sourceMappingURL=sender-message-key.js.map
|
|
35
|
+
exports.SenderMessageKey = SenderMessageKey;
|
package/lib/Signal/libsignal.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeLibSignalRepository = makeLibSignalRepository;
|
|
7
|
+
var libsignal = _interopRequireWildcard(require("libsignal"));
|
|
8
|
+
var _lruCache = require("lru-cache");
|
|
9
|
+
var _index = require("../Utils/index.js");
|
|
10
|
+
var _index2 = require("../WABinary/index.js");
|
|
11
|
+
var _senderKeyName = require("./Group/sender-key-name.js");
|
|
12
|
+
var _senderKeyRecord = require("./Group/sender-key-record.js");
|
|
13
|
+
var _index3 = require("./Group/index.js");
|
|
14
|
+
var _lidMapping = require("./lid-mapping.js");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
1
16
|
/* @ts-ignore */
|
|
2
|
-
|
|
17
|
+
|
|
3
18
|
/* @ts-ignore */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { SenderKeyName } from './Group/sender-key-name.js';
|
|
8
|
-
import { SenderKeyRecord } from './Group/sender-key-record.js';
|
|
9
|
-
import { GroupCipher, GroupSessionBuilder, SenderKeyDistributionMessage } from './Group/index.js';
|
|
10
|
-
import { LIDMappingStore } from './lid-mapping.js';
|
|
11
|
-
export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
12
|
-
const lidMapping = new LIDMappingStore(auth.keys, onWhatsAppFunc);
|
|
19
|
+
|
|
20
|
+
function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
21
|
+
const lidMapping = new _lidMapping.LIDMappingStore(auth.keys, onWhatsAppFunc);
|
|
13
22
|
const storage = signalStorage(auth, lidMapping);
|
|
14
23
|
const parsedKeys = auth.keys;
|
|
15
24
|
function isLikelySyncMessage(addr) {
|
|
@@ -23,7 +32,7 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
23
32
|
key.includes('@newsletter');
|
|
24
33
|
}
|
|
25
34
|
// Simple operation-level deduplication (5 minutes)
|
|
26
|
-
const recentMigrations = new LRUCache({
|
|
35
|
+
const recentMigrations = new _lruCache.LRUCache({
|
|
27
36
|
max: 500,
|
|
28
37
|
ttl: 5 * 60 * 1000
|
|
29
38
|
});
|
|
@@ -34,7 +43,7 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
34
43
|
msg
|
|
35
44
|
}) {
|
|
36
45
|
const senderName = jidToSignalSenderKeyName(group, authorJid);
|
|
37
|
-
const cipher = new GroupCipher(storage, senderName);
|
|
46
|
+
const cipher = new _index3.GroupCipher(storage, senderName);
|
|
38
47
|
// Use transaction to ensure atomicity
|
|
39
48
|
return parsedKeys.transaction(async () => {
|
|
40
49
|
return cipher.decrypt(msg);
|
|
@@ -44,25 +53,25 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
44
53
|
item,
|
|
45
54
|
authorJid
|
|
46
55
|
}) {
|
|
47
|
-
const builder = new GroupSessionBuilder(storage);
|
|
56
|
+
const builder = new _index3.GroupSessionBuilder(storage);
|
|
48
57
|
if (!item.groupId) {
|
|
49
58
|
throw new Error('Group ID is required for sender key distribution message');
|
|
50
59
|
}
|
|
51
60
|
const senderName = jidToSignalSenderKeyName(item.groupId, authorJid);
|
|
52
|
-
const senderMsg = new SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
|
|
61
|
+
const senderMsg = new _index3.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
|
|
53
62
|
const senderNameStr = senderName.toString();
|
|
54
63
|
const {
|
|
55
64
|
[senderNameStr]: senderKey
|
|
56
65
|
} = await auth.keys.get('sender-key', [senderNameStr]);
|
|
57
66
|
if (!senderKey) {
|
|
58
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
67
|
+
await storage.storeSenderKey(senderName, new _senderKeyRecord.SenderKeyRecord());
|
|
59
68
|
}
|
|
60
69
|
return parsedKeys.transaction(async () => {
|
|
61
70
|
const {
|
|
62
71
|
[senderNameStr]: senderKey
|
|
63
72
|
} = await auth.keys.get('sender-key', [senderNameStr]);
|
|
64
73
|
if (!senderKey) {
|
|
65
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
74
|
+
await storage.storeSenderKey(senderName, new _senderKeyRecord.SenderKeyRecord());
|
|
66
75
|
}
|
|
67
76
|
await builder.process(senderName, senderMsg);
|
|
68
77
|
}, item.groupId);
|
|
@@ -149,17 +158,17 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
149
158
|
data
|
|
150
159
|
}) {
|
|
151
160
|
const senderName = jidToSignalSenderKeyName(group, meId);
|
|
152
|
-
const builder = new GroupSessionBuilder(storage);
|
|
161
|
+
const builder = new _index3.GroupSessionBuilder(storage);
|
|
153
162
|
const senderNameStr = senderName.toString();
|
|
154
163
|
return parsedKeys.transaction(async () => {
|
|
155
164
|
const {
|
|
156
165
|
[senderNameStr]: senderKey
|
|
157
166
|
} = await auth.keys.get('sender-key', [senderNameStr]);
|
|
158
167
|
if (!senderKey) {
|
|
159
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
168
|
+
await storage.storeSenderKey(senderName, new _senderKeyRecord.SenderKeyRecord());
|
|
160
169
|
}
|
|
161
170
|
const senderKeyDistributionMessage = await builder.create(senderName);
|
|
162
|
-
const session = new GroupCipher(storage, senderName);
|
|
171
|
+
const session = new _index3.GroupCipher(storage, senderName);
|
|
163
172
|
const ciphertext = await session.encrypt(data);
|
|
164
173
|
return {
|
|
165
174
|
ciphertext,
|
|
@@ -226,8 +235,8 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
226
235
|
if (!fromJid.includes('@s.whatsapp.net') || !toJid.includes('@lid')) {
|
|
227
236
|
return;
|
|
228
237
|
}
|
|
229
|
-
const fromDecoded = jidDecode(fromJid);
|
|
230
|
-
const toDecoded = jidDecode(toJid);
|
|
238
|
+
const fromDecoded = (0, _index2.jidDecode)(fromJid);
|
|
239
|
+
const toDecoded = (0, _index2.jidDecode)(toJid);
|
|
231
240
|
if (!fromDecoded || !toDecoded) return;
|
|
232
241
|
const deviceId = fromDecoded.device || 0;
|
|
233
242
|
const migrationKey = `${fromDecoded.user}.${deviceId}→${toDecoded.user}.${deviceId}`;
|
|
@@ -287,7 +296,7 @@ export function makeLibSignalRepository(auth, onWhatsAppFunc) {
|
|
|
287
296
|
return repository;
|
|
288
297
|
}
|
|
289
298
|
const jidToSignalProtocolAddress = jid => {
|
|
290
|
-
const decoded = jidDecode(jid);
|
|
299
|
+
const decoded = (0, _index2.jidDecode)(jid);
|
|
291
300
|
const {
|
|
292
301
|
user,
|
|
293
302
|
device,
|
|
@@ -299,7 +308,7 @@ const jidToSignalProtocolAddress = jid => {
|
|
|
299
308
|
return new libsignal.ProtocolAddress(signalUser, finalDevice);
|
|
300
309
|
};
|
|
301
310
|
const jidToSignalSenderKeyName = (group, user) => {
|
|
302
|
-
return new SenderKeyName(group, jidToSignalProtocolAddress(user));
|
|
311
|
+
return new _senderKeyName.SenderKeyName(group, jidToSignalProtocolAddress(user));
|
|
303
312
|
};
|
|
304
313
|
function signalStorage({
|
|
305
314
|
creds,
|
|
@@ -381,9 +390,9 @@ function signalStorage({
|
|
|
381
390
|
[keyId]: key
|
|
382
391
|
} = await keys.get('sender-key', [keyId]);
|
|
383
392
|
if (key) {
|
|
384
|
-
return SenderKeyRecord.deserialize(key);
|
|
393
|
+
return _senderKeyRecord.SenderKeyRecord.deserialize(key);
|
|
385
394
|
}
|
|
386
|
-
return new SenderKeyRecord();
|
|
395
|
+
return new _senderKeyRecord.SenderKeyRecord();
|
|
387
396
|
},
|
|
388
397
|
storeSenderKey: async (senderKeyName, key) => {
|
|
389
398
|
const keyId = senderKeyName.toString();
|
|
@@ -401,7 +410,7 @@ function signalStorage({
|
|
|
401
410
|
} = creds;
|
|
402
411
|
return {
|
|
403
412
|
privKey: Buffer.from(signedIdentityKey.private),
|
|
404
|
-
pubKey: generateSignalPubKey(signedIdentityKey.public)
|
|
413
|
+
pubKey: (0, _index.generateSignalPubKey)(signedIdentityKey.public)
|
|
405
414
|
};
|
|
406
415
|
}
|
|
407
416
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LIDMappingStore = void 0;
|
|
7
|
+
var _logger = _interopRequireDefault(require("../Utils/logger.js"));
|
|
8
|
+
var _index = require("../WABinary/index.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
3
10
|
//TODO: Caching
|
|
4
|
-
|
|
11
|
+
class LIDMappingStore {
|
|
5
12
|
constructor(keys, onWhatsAppFunc) {
|
|
6
13
|
this.keys = keys;
|
|
7
14
|
this.onWhatsAppFunc = onWhatsAppFunc; // needed to get LID from PN if not found
|
|
@@ -25,19 +32,19 @@ export class LIDMappingStore {
|
|
|
25
32
|
lid,
|
|
26
33
|
pn
|
|
27
34
|
} of pairs) {
|
|
28
|
-
if (!(isLidUser(lid) && isPnUser(pn) || isPnUser(lid) && isLidUser(pn))) {
|
|
29
|
-
|
|
35
|
+
if (!((0, _index.isLidUser)(lid) && (0, _index.isPnUser)(pn) || (0, _index.isPnUser)(lid) && (0, _index.isLidUser)(pn))) {
|
|
36
|
+
_logger.default.warn(`Invalid LID-PN mapping: ${lid}, ${pn}`);
|
|
30
37
|
continue;
|
|
31
38
|
}
|
|
32
|
-
const [lidJid, pnJid] = isLidUser(lid) ? [lid, pn] : [pn, lid];
|
|
33
|
-
const lidDecoded = jidDecode(lidJid);
|
|
34
|
-
const pnDecoded = jidDecode(pnJid);
|
|
39
|
+
const [lidJid, pnJid] = (0, _index.isLidUser)(lid) ? [lid, pn] : [pn, lid];
|
|
40
|
+
const lidDecoded = (0, _index.jidDecode)(lidJid);
|
|
41
|
+
const pnDecoded = (0, _index.jidDecode)(pnJid);
|
|
35
42
|
if (!lidDecoded || !pnDecoded) return;
|
|
36
43
|
const pnUser = pnDecoded.user;
|
|
37
44
|
const lidUser = lidDecoded.user;
|
|
38
45
|
pairMap[pnUser] = lidUser;
|
|
39
46
|
}
|
|
40
|
-
|
|
47
|
+
_logger.default.trace({
|
|
41
48
|
pairMap
|
|
42
49
|
}, `Storing ${Object.keys(pairMap).length} pn mappings`);
|
|
43
50
|
await this.keys.transaction(async () => {
|
|
@@ -56,21 +63,21 @@ export class LIDMappingStore {
|
|
|
56
63
|
* Get LID for PN - Returns device-specific LID based on user mapping
|
|
57
64
|
*/
|
|
58
65
|
async getLIDForPN(pn) {
|
|
59
|
-
if (!isPnUser(pn)) return null;
|
|
60
|
-
const decoded = jidDecode(pn);
|
|
66
|
+
if (!(0, _index.isPnUser)(pn)) return null;
|
|
67
|
+
const decoded = (0, _index.jidDecode)(pn);
|
|
61
68
|
if (!decoded) return null;
|
|
62
69
|
// Look up user-level mapping (whatsmeow approach)
|
|
63
70
|
const pnUser = decoded.user;
|
|
64
71
|
const stored = await this.keys.get('lid-mapping', [pnUser]);
|
|
65
72
|
let lidUser = stored[pnUser];
|
|
66
73
|
if (!lidUser) {
|
|
67
|
-
|
|
74
|
+
_logger.default.trace(`No LID mapping found for PN user ${pnUser}; getting from USync`);
|
|
68
75
|
const {
|
|
69
76
|
exists,
|
|
70
77
|
lid
|
|
71
78
|
} = (await this.onWhatsAppFunc?.(pn))?.[0];
|
|
72
79
|
if (exists) {
|
|
73
|
-
lidUser = jidDecode(lid)?.user;
|
|
80
|
+
lidUser = (0, _index.jidDecode)(lid)?.user;
|
|
74
81
|
} else {
|
|
75
82
|
return null;
|
|
76
83
|
}
|
|
@@ -79,29 +86,30 @@ export class LIDMappingStore {
|
|
|
79
86
|
// Push the PN device ID to the LID to maintain device separation
|
|
80
87
|
const pnDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
81
88
|
const deviceSpecificLid = `${lidUser}:${pnDevice}@lid`;
|
|
82
|
-
|
|
89
|
+
_logger.default.trace(`getLIDForPN: ${pn} → ${deviceSpecificLid} (user mapping with device ${pnDevice})`);
|
|
83
90
|
return deviceSpecificLid;
|
|
84
91
|
}
|
|
85
92
|
/**
|
|
86
93
|
* Get PN for LID - USER LEVEL with device construction
|
|
87
94
|
*/
|
|
88
95
|
async getPNForLID(lid) {
|
|
89
|
-
if (!isLidUser(lid)) return null;
|
|
90
|
-
const decoded = jidDecode(lid);
|
|
96
|
+
if (!(0, _index.isLidUser)(lid)) return null;
|
|
97
|
+
const decoded = (0, _index.jidDecode)(lid);
|
|
91
98
|
if (!decoded) return null;
|
|
92
99
|
// Look up reverse user mapping
|
|
93
100
|
const lidUser = decoded.user;
|
|
94
101
|
const stored = await this.keys.get('lid-mapping', [`${lidUser}_reverse`]);
|
|
95
102
|
const pnUser = stored[`${lidUser}_reverse`];
|
|
96
103
|
if (!pnUser || typeof pnUser !== 'string') {
|
|
97
|
-
|
|
104
|
+
_logger.default.trace(`No reverse mapping found for LID user: ${lidUser}`);
|
|
98
105
|
return null;
|
|
99
106
|
}
|
|
100
107
|
// Construct device-specific PN JID
|
|
101
108
|
const lidDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
102
109
|
const pnJid = `${pnUser}:${lidDevice}@s.whatsapp.net`;
|
|
103
|
-
|
|
110
|
+
_logger.default.trace(`Found reverse mapping: ${lid} → ${pnJid}`);
|
|
104
111
|
return pnJid;
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
|
-
//# sourceMappingURL=lid-mapping.js.map
|
|
114
|
+
//# sourceMappingURL=lid-mapping.js.map
|
|
115
|
+
exports.LIDMappingStore = LIDMappingStore;
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _types = require("./types.js");
|
|
7
|
+
Object.keys(_types).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _types[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _websocket = require("./websocket.js");
|
|
18
|
+
Object.keys(_websocket).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _websocket[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _websocket[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AbstractSocketClient = void 0;
|
|
7
|
+
var _events = require("events");
|
|
8
|
+
var _url = require("url");
|
|
9
|
+
class AbstractSocketClient extends _events.EventEmitter {
|
|
4
10
|
constructor(url, config) {
|
|
5
11
|
super();
|
|
6
12
|
this.url = url;
|
|
@@ -8,4 +14,5 @@ export class AbstractSocketClient extends EventEmitter {
|
|
|
8
14
|
this.setMaxListeners(0);
|
|
9
15
|
}
|
|
10
16
|
}
|
|
11
|
-
//# sourceMappingURL=types.js.map
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
18
|
+
exports.AbstractSocketClient = AbstractSocketClient;
|
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WebSocketClient = void 0;
|
|
7
|
+
var _ws = _interopRequireDefault(require("ws"));
|
|
8
|
+
var _index = require("../../Defaults/index.js");
|
|
9
|
+
var _types = require("./types.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
class WebSocketClient extends _types.AbstractSocketClient {
|
|
5
12
|
constructor() {
|
|
6
13
|
super(...arguments);
|
|
7
14
|
this.socket = null;
|
|
8
15
|
}
|
|
9
16
|
get isOpen() {
|
|
10
|
-
return this.socket?.readyState ===
|
|
17
|
+
return this.socket?.readyState === _ws.default.OPEN;
|
|
11
18
|
}
|
|
12
19
|
get isClosed() {
|
|
13
|
-
return this.socket === null || this.socket?.readyState ===
|
|
20
|
+
return this.socket === null || this.socket?.readyState === _ws.default.CLOSED;
|
|
14
21
|
}
|
|
15
22
|
get isClosing() {
|
|
16
|
-
return this.socket === null || this.socket?.readyState ===
|
|
23
|
+
return this.socket === null || this.socket?.readyState === _ws.default.CLOSING;
|
|
17
24
|
}
|
|
18
25
|
get isConnecting() {
|
|
19
|
-
return this.socket?.readyState ===
|
|
26
|
+
return this.socket?.readyState === _ws.default.CONNECTING;
|
|
20
27
|
}
|
|
21
28
|
async connect() {
|
|
22
29
|
if (this.socket) {
|
|
23
30
|
return;
|
|
24
31
|
}
|
|
25
|
-
this.socket = new
|
|
26
|
-
origin: DEFAULT_ORIGIN,
|
|
32
|
+
this.socket = new _ws.default(this.url, {
|
|
33
|
+
origin: _index.DEFAULT_ORIGIN,
|
|
27
34
|
headers: this.config.options?.headers,
|
|
28
35
|
handshakeTimeout: this.config.connectTimeoutMs,
|
|
29
36
|
timeout: this.config.connectTimeoutMs,
|
|
@@ -47,4 +54,5 @@ export class WebSocketClient extends AbstractSocketClient {
|
|
|
47
54
|
return Boolean(this.socket);
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
|
-
//# sourceMappingURL=websocket.js.map
|
|
57
|
+
//# sourceMappingURL=websocket.js.map
|
|
58
|
+
exports.WebSocketClient = WebSocketClient;
|
package/lib/Socket/business.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeBusinessSocket = void 0;
|
|
7
|
+
var _index = require("../Utils/index.js");
|
|
8
|
+
var _business = require("../Utils/business.js");
|
|
9
|
+
var _index2 = require("../WABinary/index.js");
|
|
10
|
+
var _genericUtils = require("../WABinary/generic-utils.js");
|
|
11
|
+
var _messagesRecv = require("./messages-recv.js");
|
|
12
|
+
const makeBusinessSocket = config => {
|
|
13
|
+
const sock = (0, _messagesRecv.makeMessagesRecvSocket)(config);
|
|
8
14
|
const {
|
|
9
15
|
authState,
|
|
10
16
|
query,
|
|
@@ -56,7 +62,7 @@ export const makeBusinessSocket = config => {
|
|
|
56
62
|
const result = await query({
|
|
57
63
|
tag: 'iq',
|
|
58
64
|
attrs: {
|
|
59
|
-
to: S_WHATSAPP_NET,
|
|
65
|
+
to: _index2.S_WHATSAPP_NET,
|
|
60
66
|
type: 'set',
|
|
61
67
|
xmlns: 'w:biz'
|
|
62
68
|
},
|
|
@@ -75,7 +81,7 @@ export const makeBusinessSocket = config => {
|
|
|
75
81
|
const {
|
|
76
82
|
fileSha256,
|
|
77
83
|
filePath
|
|
78
|
-
} = await getRawMediaUploadData(photo, 'biz-cover-photo');
|
|
84
|
+
} = await (0, _index.getRawMediaUploadData)(photo, 'biz-cover-photo');
|
|
79
85
|
const fileSha256B64 = fileSha256.toString('base64');
|
|
80
86
|
const {
|
|
81
87
|
meta_hmac,
|
|
@@ -88,7 +94,7 @@ export const makeBusinessSocket = config => {
|
|
|
88
94
|
await query({
|
|
89
95
|
tag: 'iq',
|
|
90
96
|
attrs: {
|
|
91
|
-
to: S_WHATSAPP_NET,
|
|
97
|
+
to: _index2.S_WHATSAPP_NET,
|
|
92
98
|
type: 'set',
|
|
93
99
|
xmlns: 'w:biz'
|
|
94
100
|
},
|
|
@@ -115,7 +121,7 @@ export const makeBusinessSocket = config => {
|
|
|
115
121
|
return await query({
|
|
116
122
|
tag: 'iq',
|
|
117
123
|
attrs: {
|
|
118
|
-
to: S_WHATSAPP_NET,
|
|
124
|
+
to: _index2.S_WHATSAPP_NET,
|
|
119
125
|
type: 'set',
|
|
120
126
|
xmlns: 'w:biz'
|
|
121
127
|
},
|
|
@@ -141,7 +147,7 @@ export const makeBusinessSocket = config => {
|
|
|
141
147
|
cursor
|
|
142
148
|
}) => {
|
|
143
149
|
jid = jid || authState.creds.me?.id;
|
|
144
|
-
jid = jidNormalizedUser(jid);
|
|
150
|
+
jid = (0, _index2.jidNormalizedUser)(jid);
|
|
145
151
|
const queryParamNodes = [{
|
|
146
152
|
tag: 'limit',
|
|
147
153
|
attrs: {},
|
|
@@ -165,7 +171,7 @@ export const makeBusinessSocket = config => {
|
|
|
165
171
|
const result = await query({
|
|
166
172
|
tag: 'iq',
|
|
167
173
|
attrs: {
|
|
168
|
-
to: S_WHATSAPP_NET,
|
|
174
|
+
to: _index2.S_WHATSAPP_NET,
|
|
169
175
|
type: 'get',
|
|
170
176
|
xmlns: 'w:biz:catalog'
|
|
171
177
|
},
|
|
@@ -178,15 +184,15 @@ export const makeBusinessSocket = config => {
|
|
|
178
184
|
content: queryParamNodes
|
|
179
185
|
}]
|
|
180
186
|
});
|
|
181
|
-
return parseCatalogNode(result);
|
|
187
|
+
return (0, _business.parseCatalogNode)(result);
|
|
182
188
|
};
|
|
183
189
|
const getCollections = async (jid, limit = 51) => {
|
|
184
190
|
jid = jid || authState.creds.me?.id;
|
|
185
|
-
jid = jidNormalizedUser(jid);
|
|
191
|
+
jid = (0, _index2.jidNormalizedUser)(jid);
|
|
186
192
|
const result = await query({
|
|
187
193
|
tag: 'iq',
|
|
188
194
|
attrs: {
|
|
189
|
-
to: S_WHATSAPP_NET,
|
|
195
|
+
to: _index2.S_WHATSAPP_NET,
|
|
190
196
|
type: 'get',
|
|
191
197
|
xmlns: 'w:biz:catalog',
|
|
192
198
|
smax_id: '35'
|
|
@@ -215,13 +221,13 @@ export const makeBusinessSocket = config => {
|
|
|
215
221
|
}]
|
|
216
222
|
}]
|
|
217
223
|
});
|
|
218
|
-
return parseCollectionsNode(result);
|
|
224
|
+
return (0, _business.parseCollectionsNode)(result);
|
|
219
225
|
};
|
|
220
226
|
const getOrderDetails = async (orderId, tokenBase64) => {
|
|
221
227
|
const result = await query({
|
|
222
228
|
tag: 'iq',
|
|
223
229
|
attrs: {
|
|
224
|
-
to: S_WHATSAPP_NET,
|
|
230
|
+
to: _index2.S_WHATSAPP_NET,
|
|
225
231
|
type: 'get',
|
|
226
232
|
xmlns: 'fb:thrift_iq',
|
|
227
233
|
smax_id: '5'
|
|
@@ -251,15 +257,15 @@ export const makeBusinessSocket = config => {
|
|
|
251
257
|
}]
|
|
252
258
|
}]
|
|
253
259
|
});
|
|
254
|
-
return parseOrderDetailsNode(result);
|
|
260
|
+
return (0, _business.parseOrderDetailsNode)(result);
|
|
255
261
|
};
|
|
256
262
|
const productUpdate = async (productId, update) => {
|
|
257
|
-
update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
|
|
258
|
-
const editNode = toProductNode(productId, update);
|
|
263
|
+
update = await (0, _business.uploadingNecessaryImagesOfProduct)(update, waUploadToServer);
|
|
264
|
+
const editNode = (0, _business.toProductNode)(productId, update);
|
|
259
265
|
const result = await query({
|
|
260
266
|
tag: 'iq',
|
|
261
267
|
attrs: {
|
|
262
|
-
to: S_WHATSAPP_NET,
|
|
268
|
+
to: _index2.S_WHATSAPP_NET,
|
|
263
269
|
type: 'set',
|
|
264
270
|
xmlns: 'w:biz:catalog'
|
|
265
271
|
},
|
|
@@ -279,19 +285,19 @@ export const makeBusinessSocket = config => {
|
|
|
279
285
|
}]
|
|
280
286
|
}]
|
|
281
287
|
});
|
|
282
|
-
const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
|
|
283
|
-
const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
|
|
284
|
-
return parseProductNode(productNode);
|
|
288
|
+
const productCatalogEditNode = (0, _genericUtils.getBinaryNodeChild)(result, 'product_catalog_edit');
|
|
289
|
+
const productNode = (0, _genericUtils.getBinaryNodeChild)(productCatalogEditNode, 'product');
|
|
290
|
+
return (0, _business.parseProductNode)(productNode);
|
|
285
291
|
};
|
|
286
292
|
const productCreate = async create => {
|
|
287
293
|
// ensure isHidden is defined
|
|
288
294
|
create.isHidden = !!create.isHidden;
|
|
289
|
-
create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
|
|
290
|
-
const createNode = toProductNode(undefined, create);
|
|
295
|
+
create = await (0, _business.uploadingNecessaryImagesOfProduct)(create, waUploadToServer);
|
|
296
|
+
const createNode = (0, _business.toProductNode)(undefined, create);
|
|
291
297
|
const result = await query({
|
|
292
298
|
tag: 'iq',
|
|
293
299
|
attrs: {
|
|
294
|
-
to: S_WHATSAPP_NET,
|
|
300
|
+
to: _index2.S_WHATSAPP_NET,
|
|
295
301
|
type: 'set',
|
|
296
302
|
xmlns: 'w:biz:catalog'
|
|
297
303
|
},
|
|
@@ -311,15 +317,15 @@ export const makeBusinessSocket = config => {
|
|
|
311
317
|
}]
|
|
312
318
|
}]
|
|
313
319
|
});
|
|
314
|
-
const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
|
|
315
|
-
const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
|
|
316
|
-
return parseProductNode(productNode);
|
|
320
|
+
const productCatalogAddNode = (0, _genericUtils.getBinaryNodeChild)(result, 'product_catalog_add');
|
|
321
|
+
const productNode = (0, _genericUtils.getBinaryNodeChild)(productCatalogAddNode, 'product');
|
|
322
|
+
return (0, _business.parseProductNode)(productNode);
|
|
317
323
|
};
|
|
318
324
|
const productDelete = async productIds => {
|
|
319
325
|
const result = await query({
|
|
320
326
|
tag: 'iq',
|
|
321
327
|
attrs: {
|
|
322
|
-
to: S_WHATSAPP_NET,
|
|
328
|
+
to: _index2.S_WHATSAPP_NET,
|
|
323
329
|
type: 'set',
|
|
324
330
|
xmlns: 'w:biz:catalog'
|
|
325
331
|
},
|
|
@@ -339,7 +345,7 @@ export const makeBusinessSocket = config => {
|
|
|
339
345
|
}))
|
|
340
346
|
}]
|
|
341
347
|
});
|
|
342
|
-
const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
|
|
348
|
+
const productCatalogDelNode = (0, _genericUtils.getBinaryNodeChild)(result, 'product_catalog_delete');
|
|
343
349
|
return {
|
|
344
350
|
deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
|
|
345
351
|
};
|
|
@@ -358,4 +364,5 @@ export const makeBusinessSocket = config => {
|
|
|
358
364
|
removeCoverPhoto
|
|
359
365
|
};
|
|
360
366
|
};
|
|
361
|
-
//# sourceMappingURL=business.js.map
|
|
367
|
+
//# sourceMappingURL=business.js.map
|
|
368
|
+
exports.makeBusinessSocket = makeBusinessSocket;
|