@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
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.initAuthCreds = exports.addTransactionCapability = void 0;
|
|
7
|
+
exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
|
|
8
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
10
|
+
const Defaults_1 = require("../Defaults");
|
|
11
|
+
const crypto_2 = require("./crypto");
|
|
12
|
+
const generics_1 = require("./generics");
|
|
6
13
|
/**
|
|
7
14
|
* Adds caching capability to a SignalKeyStore
|
|
8
15
|
* @param store the store to add caching to
|
|
9
16
|
* @param logger to log trace events
|
|
10
17
|
* @param _cache cache store to use
|
|
11
18
|
*/
|
|
12
|
-
|
|
19
|
+
function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
13
20
|
const cache = _cache ||
|
|
14
|
-
new
|
|
15
|
-
stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
|
|
21
|
+
new node_cache_1.default({
|
|
22
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
|
|
16
23
|
useClones: false,
|
|
17
24
|
deleteOnExpire: true
|
|
18
25
|
});
|
|
@@ -25,7 +32,7 @@ export function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
25
32
|
const idsToFetch = [];
|
|
26
33
|
for (const id of ids) {
|
|
27
34
|
const item = cache.get(getUniqueId(type, id));
|
|
28
|
-
if (typeof item !== 'undefined') {
|
|
35
|
+
if (typeof item !== 'undefined' && item !== null) {
|
|
29
36
|
data[id] = item;
|
|
30
37
|
}
|
|
31
38
|
else {
|
|
@@ -33,7 +40,7 @@ export function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
if (idsToFetch.length) {
|
|
36
|
-
logger
|
|
43
|
+
logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
|
|
37
44
|
const fetched = await store.get(type, idsToFetch);
|
|
38
45
|
for (const id of idsToFetch) {
|
|
39
46
|
const item = fetched[id];
|
|
@@ -53,12 +60,13 @@ export function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
53
60
|
keys += 1;
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
|
-
logger
|
|
63
|
+
logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
|
|
57
64
|
await store.set(data);
|
|
58
65
|
},
|
|
59
66
|
async clear() {
|
|
67
|
+
var _a;
|
|
60
68
|
cache.flushAll();
|
|
61
|
-
await store.clear
|
|
69
|
+
await ((_a = store.clear) === null || _a === void 0 ? void 0 : _a.call(store));
|
|
62
70
|
}
|
|
63
71
|
};
|
|
64
72
|
}
|
|
@@ -69,7 +77,7 @@ export function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
69
77
|
* @param logger logger to log events
|
|
70
78
|
* @returns SignalKeyStore with transaction capability
|
|
71
79
|
*/
|
|
72
|
-
|
|
80
|
+
const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
|
|
73
81
|
// number of queries made to the DB during the transaction
|
|
74
82
|
// only there for logging purposes
|
|
75
83
|
let dbQueriesInTransaction = 0;
|
|
@@ -89,7 +97,8 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
|
|
|
89
97
|
Object.assign(transactionCache[type], result);
|
|
90
98
|
}
|
|
91
99
|
return ids.reduce((dict, id) => {
|
|
92
|
-
|
|
100
|
+
var _a;
|
|
101
|
+
const value = (_a = transactionCache[type]) === null || _a === void 0 ? void 0 : _a[id];
|
|
93
102
|
if (value) {
|
|
94
103
|
dict[id] = value;
|
|
95
104
|
}
|
|
@@ -103,8 +112,7 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
|
|
|
103
112
|
set: data => {
|
|
104
113
|
if (isInTransaction()) {
|
|
105
114
|
logger.trace({ types: Object.keys(data) }, 'caching in transaction');
|
|
106
|
-
for (const
|
|
107
|
-
const key = key_;
|
|
115
|
+
for (const key in data) {
|
|
108
116
|
transactionCache[key] = transactionCache[key] || {};
|
|
109
117
|
Object.assign(transactionCache[key], data[key]);
|
|
110
118
|
mutations[key] = mutations[key] || {};
|
|
@@ -141,7 +149,7 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
|
|
|
141
149
|
}
|
|
142
150
|
catch (error) {
|
|
143
151
|
logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`);
|
|
144
|
-
await delay(delayBetweenTriesMs);
|
|
152
|
+
await (0, generics_1.delay)(delayBetweenTriesMs);
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
155
|
}
|
|
@@ -165,15 +173,16 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
|
|
|
165
173
|
return transactionsInProgress > 0;
|
|
166
174
|
}
|
|
167
175
|
};
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
exports.addTransactionCapability = addTransactionCapability;
|
|
177
|
+
const initAuthCreds = () => {
|
|
178
|
+
const identityKey = crypto_2.Curve.generateKeyPair();
|
|
170
179
|
return {
|
|
171
|
-
noiseKey: Curve.generateKeyPair(),
|
|
172
|
-
pairingEphemeralKeyPair: Curve.generateKeyPair(),
|
|
180
|
+
noiseKey: crypto_2.Curve.generateKeyPair(),
|
|
181
|
+
pairingEphemeralKeyPair: crypto_2.Curve.generateKeyPair(),
|
|
173
182
|
signedIdentityKey: identityKey,
|
|
174
|
-
signedPreKey: signedKeyPair(identityKey, 1),
|
|
175
|
-
registrationId: generateRegistrationId(),
|
|
176
|
-
advSecretKey: randomBytes(32).toString('base64'),
|
|
183
|
+
signedPreKey: (0, crypto_2.signedKeyPair)(identityKey, 1),
|
|
184
|
+
registrationId: (0, generics_1.generateRegistrationId)(),
|
|
185
|
+
advSecretKey: (0, crypto_1.randomBytes)(32).toString('base64'),
|
|
177
186
|
processedHistoryMessages: [],
|
|
178
187
|
nextPreKeyId: 1,
|
|
179
188
|
firstUnuploadedPreKeyId: 1,
|
|
@@ -187,4 +196,4 @@ export const initAuthCreds = () => {
|
|
|
187
196
|
routingInfo: undefined
|
|
188
197
|
};
|
|
189
198
|
};
|
|
190
|
-
|
|
199
|
+
exports.initAuthCreds = initAuthCreds;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaileysEventEmitter } from '../Types
|
|
1
|
+
import type { BaileysEventEmitter } from '../Types';
|
|
2
2
|
/**
|
|
3
3
|
* Captures events from a baileys event emitter & stores them in a file
|
|
4
4
|
* @param ev The event emitter to read events from
|
|
@@ -14,4 +14,3 @@ export declare const readAndEmitEventStream: (filename: string, delayIntervalMs?
|
|
|
14
14
|
ev: BaileysEventEmitter;
|
|
15
15
|
task: Promise<void>;
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=baileys-event-stream.d.ts.map
|
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.readAndEmitEventStream = exports.captureEventStream = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const promises_1 = require("fs/promises");
|
|
10
|
+
const readline_1 = require("readline");
|
|
11
|
+
const generics_1 = require("./generics");
|
|
12
|
+
const make_mutex_1 = require("./make-mutex");
|
|
7
13
|
/**
|
|
8
14
|
* Captures events from a baileys event emitter & stores them in a file
|
|
9
15
|
* @param ev The event emitter to read events from
|
|
10
16
|
* @param filename File to save to
|
|
11
17
|
*/
|
|
12
|
-
|
|
18
|
+
const captureEventStream = (ev, filename) => {
|
|
13
19
|
const oldEmit = ev.emit;
|
|
14
20
|
// write mutex so data is appended in order
|
|
15
|
-
const writeMutex = makeMutex();
|
|
21
|
+
const writeMutex = (0, make_mutex_1.makeMutex)();
|
|
16
22
|
// monkey patch eventemitter to capture all events
|
|
17
23
|
ev.emit = function (...args) {
|
|
18
24
|
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
|
|
19
25
|
const result = oldEmit.apply(ev, args);
|
|
20
26
|
writeMutex.mutex(async () => {
|
|
21
|
-
await writeFile(filename, content, { flag: 'a' });
|
|
27
|
+
await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
|
|
22
28
|
});
|
|
23
29
|
return result;
|
|
24
30
|
};
|
|
25
31
|
};
|
|
32
|
+
exports.captureEventStream = captureEventStream;
|
|
26
33
|
/**
|
|
27
34
|
* Read event file and emit events from there
|
|
28
35
|
* @param filename filename containing event data
|
|
29
36
|
* @param delayIntervalMs delay between each event emit
|
|
30
37
|
*/
|
|
31
|
-
|
|
32
|
-
const ev = new
|
|
38
|
+
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
39
|
+
const ev = new events_1.default();
|
|
33
40
|
const fireEvents = async () => {
|
|
34
41
|
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
35
|
-
const fileStream = createReadStream(filename);
|
|
36
|
-
const rl = createInterface({
|
|
42
|
+
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
43
|
+
const rl = (0, readline_1.createInterface)({
|
|
37
44
|
input: fileStream,
|
|
38
45
|
crlfDelay: Infinity
|
|
39
46
|
});
|
|
@@ -43,7 +50,7 @@ export const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
|
43
50
|
if (line) {
|
|
44
51
|
const { event, data } = JSON.parse(line);
|
|
45
52
|
ev.emit(event, data);
|
|
46
|
-
delayIntervalMs && (await delay(delayIntervalMs));
|
|
53
|
+
delayIntervalMs && (await (0, generics_1.delay)(delayIntervalMs));
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
fileStream.close();
|
|
@@ -53,4 +60,4 @@ export const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
|
53
60
|
task: fireEvents()
|
|
54
61
|
};
|
|
55
62
|
};
|
|
56
|
-
|
|
63
|
+
exports.readAndEmitEventStream = readAndEmitEventStream;
|
package/lib/Utils/business.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types';
|
|
2
|
+
import { BinaryNode } from '../WABinary';
|
|
3
3
|
export declare const parseCatalogNode: (node: BinaryNode) => {
|
|
4
4
|
products: Product[];
|
|
5
5
|
nextPageCursor: string | undefined;
|
|
@@ -20,4 +20,3 @@ export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdat
|
|
|
20
20
|
export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
|
|
21
21
|
url: string;
|
|
22
22
|
}[]>;
|
|
23
|
-
//# sourceMappingURL=business.d.ts.map
|
package/lib/Utils/business.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadingNecessaryImages = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
|
4
|
+
exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
|
|
5
|
+
const boom_1 = require("@hapi/boom");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const os_1 = require("os");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const WABinary_1 = require("../WABinary");
|
|
11
|
+
const generics_1 = require("./generics");
|
|
12
|
+
const messages_media_1 = require("./messages-media");
|
|
13
|
+
const parseCatalogNode = (node) => {
|
|
14
|
+
const catalogNode = (0, WABinary_1.getBinaryNodeChild)(node, 'product_catalog');
|
|
15
|
+
const products = (0, WABinary_1.getBinaryNodeChildren)(catalogNode, 'product').map(exports.parseProductNode);
|
|
16
|
+
const paging = (0, WABinary_1.getBinaryNodeChild)(catalogNode, 'paging');
|
|
13
17
|
return {
|
|
14
18
|
products,
|
|
15
|
-
nextPageCursor: paging ? getBinaryNodeChildString(paging, 'after') : undefined
|
|
19
|
+
nextPageCursor: paging ? (0, WABinary_1.getBinaryNodeChildString)(paging, 'after') : undefined
|
|
16
20
|
};
|
|
17
21
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
exports.parseCatalogNode = parseCatalogNode;
|
|
23
|
+
const parseCollectionsNode = (node) => {
|
|
24
|
+
const collectionsNode = (0, WABinary_1.getBinaryNodeChild)(node, 'collections');
|
|
25
|
+
const collections = (0, WABinary_1.getBinaryNodeChildren)(collectionsNode, 'collection').map(collectionNode => {
|
|
26
|
+
const id = (0, WABinary_1.getBinaryNodeChildString)(collectionNode, 'id');
|
|
27
|
+
const name = (0, WABinary_1.getBinaryNodeChildString)(collectionNode, 'name');
|
|
28
|
+
const products = (0, WABinary_1.getBinaryNodeChildren)(collectionNode, 'product').map(exports.parseProductNode);
|
|
24
29
|
return {
|
|
25
30
|
id,
|
|
26
31
|
name,
|
|
@@ -32,30 +37,32 @@ export const parseCollectionsNode = (node) => {
|
|
|
32
37
|
collections
|
|
33
38
|
};
|
|
34
39
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
40
|
+
exports.parseCollectionsNode = parseCollectionsNode;
|
|
41
|
+
const parseOrderDetailsNode = (node) => {
|
|
42
|
+
const orderNode = (0, WABinary_1.getBinaryNodeChild)(node, 'order');
|
|
43
|
+
const products = (0, WABinary_1.getBinaryNodeChildren)(orderNode, 'product').map(productNode => {
|
|
44
|
+
const imageNode = (0, WABinary_1.getBinaryNodeChild)(productNode, 'image');
|
|
39
45
|
return {
|
|
40
|
-
id: getBinaryNodeChildString(productNode, 'id'),
|
|
41
|
-
name: getBinaryNodeChildString(productNode, 'name'),
|
|
42
|
-
imageUrl: getBinaryNodeChildString(imageNode, 'url'),
|
|
43
|
-
price: +getBinaryNodeChildString(productNode, 'price'),
|
|
44
|
-
currency: getBinaryNodeChildString(productNode, 'currency'),
|
|
45
|
-
quantity: +getBinaryNodeChildString(productNode, 'quantity')
|
|
46
|
+
id: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'id'),
|
|
47
|
+
name: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'name'),
|
|
48
|
+
imageUrl: (0, WABinary_1.getBinaryNodeChildString)(imageNode, 'url'),
|
|
49
|
+
price: +(0, WABinary_1.getBinaryNodeChildString)(productNode, 'price'),
|
|
50
|
+
currency: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'currency'),
|
|
51
|
+
quantity: +(0, WABinary_1.getBinaryNodeChildString)(productNode, 'quantity')
|
|
46
52
|
};
|
|
47
53
|
});
|
|
48
|
-
const priceNode = getBinaryNodeChild(orderNode, 'price');
|
|
54
|
+
const priceNode = (0, WABinary_1.getBinaryNodeChild)(orderNode, 'price');
|
|
49
55
|
const orderDetails = {
|
|
50
56
|
price: {
|
|
51
|
-
total: +getBinaryNodeChildString(priceNode, 'total'),
|
|
52
|
-
currency: getBinaryNodeChildString(priceNode, 'currency')
|
|
57
|
+
total: +(0, WABinary_1.getBinaryNodeChildString)(priceNode, 'total'),
|
|
58
|
+
currency: (0, WABinary_1.getBinaryNodeChildString)(priceNode, 'currency')
|
|
53
59
|
},
|
|
54
60
|
products
|
|
55
61
|
};
|
|
56
62
|
return orderDetails;
|
|
57
63
|
};
|
|
58
|
-
|
|
64
|
+
exports.parseOrderDetailsNode = parseOrderDetailsNode;
|
|
65
|
+
const toProductNode = (productId, product) => {
|
|
59
66
|
const attrs = {};
|
|
60
67
|
const content = [];
|
|
61
68
|
if (typeof productId !== 'undefined') {
|
|
@@ -92,7 +99,7 @@ export const toProductNode = (productId, product) => {
|
|
|
92
99
|
attrs: {},
|
|
93
100
|
content: product.images.map(img => {
|
|
94
101
|
if (!('url' in img)) {
|
|
95
|
-
throw new Boom('Expected img for product to already be uploaded', { statusCode: 400 });
|
|
102
|
+
throw new boom_1.Boom('Expected img for product to already be uploaded', { statusCode: 400 });
|
|
96
103
|
}
|
|
97
104
|
return {
|
|
98
105
|
tag: 'image',
|
|
@@ -150,36 +157,38 @@ export const toProductNode = (productId, product) => {
|
|
|
150
157
|
};
|
|
151
158
|
return node;
|
|
152
159
|
};
|
|
153
|
-
|
|
160
|
+
exports.toProductNode = toProductNode;
|
|
161
|
+
const parseProductNode = (productNode) => {
|
|
154
162
|
const isHidden = productNode.attrs.is_hidden === 'true';
|
|
155
|
-
const id = getBinaryNodeChildString(productNode, 'id');
|
|
156
|
-
const mediaNode = getBinaryNodeChild(productNode, 'media');
|
|
157
|
-
const statusInfoNode = getBinaryNodeChild(productNode, 'status_info');
|
|
163
|
+
const id = (0, WABinary_1.getBinaryNodeChildString)(productNode, 'id');
|
|
164
|
+
const mediaNode = (0, WABinary_1.getBinaryNodeChild)(productNode, 'media');
|
|
165
|
+
const statusInfoNode = (0, WABinary_1.getBinaryNodeChild)(productNode, 'status_info');
|
|
158
166
|
const product = {
|
|
159
167
|
id,
|
|
160
168
|
imageUrls: parseImageUrls(mediaNode),
|
|
161
169
|
reviewStatus: {
|
|
162
|
-
whatsapp: getBinaryNodeChildString(statusInfoNode, 'status')
|
|
170
|
+
whatsapp: (0, WABinary_1.getBinaryNodeChildString)(statusInfoNode, 'status')
|
|
163
171
|
},
|
|
164
172
|
availability: 'in stock',
|
|
165
|
-
name: getBinaryNodeChildString(productNode, 'name'),
|
|
166
|
-
retailerId: getBinaryNodeChildString(productNode, 'retailer_id'),
|
|
167
|
-
url: getBinaryNodeChildString(productNode, 'url'),
|
|
168
|
-
description: getBinaryNodeChildString(productNode, 'description'),
|
|
169
|
-
price: +getBinaryNodeChildString(productNode, 'price'),
|
|
170
|
-
currency: getBinaryNodeChildString(productNode, 'currency'),
|
|
173
|
+
name: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'name'),
|
|
174
|
+
retailerId: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'retailer_id'),
|
|
175
|
+
url: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'url'),
|
|
176
|
+
description: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'description'),
|
|
177
|
+
price: +(0, WABinary_1.getBinaryNodeChildString)(productNode, 'price'),
|
|
178
|
+
currency: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'currency'),
|
|
171
179
|
isHidden
|
|
172
180
|
};
|
|
173
181
|
return product;
|
|
174
182
|
};
|
|
183
|
+
exports.parseProductNode = parseProductNode;
|
|
175
184
|
/**
|
|
176
185
|
* Uploads images not already uploaded to WA's servers
|
|
177
186
|
*/
|
|
178
|
-
|
|
187
|
+
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
|
|
179
188
|
product = {
|
|
180
189
|
...product,
|
|
181
190
|
images: product.images
|
|
182
|
-
? await uploadingNecessaryImages(product.images, waUploadToServer, timeoutMs)
|
|
191
|
+
? await (0, exports.uploadingNecessaryImages)(product.images, waUploadToServer, timeoutMs)
|
|
183
192
|
: product.images
|
|
184
193
|
};
|
|
185
194
|
return product;
|
|
@@ -187,7 +196,7 @@ export async function uploadingNecessaryImagesOfProduct(product, waUploadToServe
|
|
|
187
196
|
/**
|
|
188
197
|
* Uploads images not already uploaded to WA's servers
|
|
189
198
|
*/
|
|
190
|
-
|
|
199
|
+
const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30000) => {
|
|
191
200
|
const results = await Promise.all(images.map(async (img) => {
|
|
192
201
|
if ('url' in img) {
|
|
193
202
|
const url = img.url.toString();
|
|
@@ -195,10 +204,10 @@ export const uploadingNecessaryImages = async (images, waUploadToServer, timeout
|
|
|
195
204
|
return { url };
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
|
-
const { stream } = await getStream(img);
|
|
199
|
-
const hasher = createHash('sha256');
|
|
200
|
-
const filePath = join(tmpdir(), 'img' + generateMessageIDV2());
|
|
201
|
-
const encFileWriteStream = createWriteStream(filePath);
|
|
207
|
+
const { stream } = await (0, messages_media_1.getStream)(img);
|
|
208
|
+
const hasher = (0, crypto_1.createHash)('sha256');
|
|
209
|
+
const filePath = (0, path_1.join)((0, os_1.tmpdir)(), 'img' + (0, generics_1.generateMessageIDV2)());
|
|
210
|
+
const encFileWriteStream = (0, fs_1.createWriteStream)(filePath);
|
|
202
211
|
for await (const block of stream) {
|
|
203
212
|
hasher.update(block);
|
|
204
213
|
encFileWriteStream.write(block);
|
|
@@ -209,23 +218,23 @@ export const uploadingNecessaryImages = async (images, waUploadToServer, timeout
|
|
|
209
218
|
fileEncSha256B64: sha,
|
|
210
219
|
timeoutMs
|
|
211
220
|
});
|
|
212
|
-
await
|
|
213
|
-
return { url: getUrlFromDirectPath(directPath) };
|
|
221
|
+
await fs_1.promises.unlink(filePath).catch(err => console.log('Error deleting temp file ', err));
|
|
222
|
+
return { url: (0, messages_media_1.getUrlFromDirectPath)(directPath) };
|
|
214
223
|
}));
|
|
215
224
|
return results;
|
|
216
225
|
};
|
|
226
|
+
exports.uploadingNecessaryImages = uploadingNecessaryImages;
|
|
217
227
|
const parseImageUrls = (mediaNode) => {
|
|
218
|
-
const imgNode = getBinaryNodeChild(mediaNode, 'image');
|
|
228
|
+
const imgNode = (0, WABinary_1.getBinaryNodeChild)(mediaNode, 'image');
|
|
219
229
|
return {
|
|
220
|
-
requested: getBinaryNodeChildString(imgNode, 'request_image_url'),
|
|
221
|
-
original: getBinaryNodeChildString(imgNode, 'original_image_url')
|
|
230
|
+
requested: (0, WABinary_1.getBinaryNodeChildString)(imgNode, 'request_image_url'),
|
|
231
|
+
original: (0, WABinary_1.getBinaryNodeChildString)(imgNode, 'original_image_url')
|
|
222
232
|
};
|
|
223
233
|
};
|
|
224
234
|
const parseStatusInfo = (mediaNode) => {
|
|
225
|
-
const node = getBinaryNodeChild(mediaNode, 'status_info');
|
|
235
|
+
const node = (0, WABinary_1.getBinaryNodeChild)(mediaNode, 'status_info');
|
|
226
236
|
return {
|
|
227
|
-
status: getBinaryNodeChildString(node, 'status'),
|
|
228
|
-
canAppeal: getBinaryNodeChildString(node, 'can_appeal') === 'true'
|
|
237
|
+
status: (0, WABinary_1.getBinaryNodeChildString)(node, 'status'),
|
|
238
|
+
canAppeal: (0, WABinary_1.getBinaryNodeChildString)(node, 'can_appeal') === 'true'
|
|
229
239
|
};
|
|
230
240
|
};
|
|
231
|
-
//# sourceMappingURL=business.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { proto } from '../../WAProto
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { proto } from '../../WAProto';
|
|
3
|
+
import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
|
4
|
+
import { BinaryNode } from '../WABinary';
|
|
5
|
+
import { ILogger } from './logger';
|
|
6
6
|
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
|
7
7
|
export type ChatMutationMap = {
|
|
8
8
|
[index: string]: ChatMutation;
|
|
@@ -13,7 +13,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
|
|
|
13
13
|
state: LTHashState;
|
|
14
14
|
}>;
|
|
15
15
|
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
16
|
-
hash: Buffer<
|
|
16
|
+
hash: Buffer<any>;
|
|
17
17
|
indexValueMap: {
|
|
18
18
|
[indexMacBase64: string]: {
|
|
19
19
|
valueMac: Uint8Array | Buffer;
|
|
@@ -21,7 +21,7 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
|
|
|
21
21
|
};
|
|
22
22
|
}>;
|
|
23
23
|
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
24
|
-
hash: Buffer<
|
|
24
|
+
hash: Buffer<any>;
|
|
25
25
|
indexValueMap: {
|
|
26
26
|
[indexMacBase64: string]: {
|
|
27
27
|
valueMac: Uint8Array | Buffer;
|
|
@@ -68,4 +68,3 @@ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatc
|
|
|
68
68
|
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
|
69
69
|
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
|
|
70
70
|
export {};
|
|
71
|
-
//# sourceMappingURL=chat-utils.d.ts.map
|