@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/signal.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return chunks;
|
|
11
|
-
}
|
|
12
|
-
export const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNextPreKeysNode = exports.getNextPreKeys = exports.extractDeviceJids = exports.parseAndInjectE2ESessions = exports.xmppPreKey = exports.xmppSignedPreKey = exports.generateOrGetPreKeys = exports.getPreKeys = exports.createSignalIdentity = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const Defaults_1 = require("../Defaults");
|
|
6
|
+
const WABinary_1 = require("../WABinary");
|
|
7
|
+
const crypto_1 = require("./crypto");
|
|
8
|
+
const generics_1 = require("./generics");
|
|
9
|
+
const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
13
10
|
return {
|
|
14
11
|
identifier: { name: wid, deviceId: 0 },
|
|
15
|
-
identifierKey: generateSignalPubKey(accountSignatureKey)
|
|
12
|
+
identifierKey: (0, crypto_1.generateSignalPubKey)(accountSignatureKey)
|
|
16
13
|
};
|
|
17
14
|
};
|
|
18
|
-
|
|
15
|
+
exports.createSignalIdentity = createSignalIdentity;
|
|
16
|
+
const getPreKeys = async ({ get }, min, limit) => {
|
|
19
17
|
const idList = [];
|
|
20
18
|
for (let id = min; id < limit; id++) {
|
|
21
19
|
idList.push(id.toString());
|
|
22
20
|
}
|
|
23
21
|
return get('pre-key', idList);
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
exports.getPreKeys = getPreKeys;
|
|
24
|
+
const generateOrGetPreKeys = (creds, range) => {
|
|
26
25
|
const avaliable = creds.nextPreKeyId - creds.firstUnuploadedPreKeyId;
|
|
27
26
|
const remaining = range - avaliable;
|
|
28
27
|
const lastPreKeyId = creds.nextPreKeyId + remaining - 1;
|
|
29
28
|
const newPreKeys = {};
|
|
30
29
|
if (remaining > 0) {
|
|
31
30
|
for (let i = creds.nextPreKeyId; i <= lastPreKeyId; i++) {
|
|
32
|
-
newPreKeys[i] = Curve.generateKeyPair();
|
|
31
|
+
newPreKeys[i] = crypto_1.Curve.generateKeyPair();
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
return {
|
|
@@ -38,34 +37,37 @@ export const generateOrGetPreKeys = (creds, range) => {
|
|
|
38
37
|
preKeysRange: [creds.firstUnuploadedPreKeyId, range]
|
|
39
38
|
};
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
exports.generateOrGetPreKeys = generateOrGetPreKeys;
|
|
41
|
+
const xmppSignedPreKey = (key) => ({
|
|
42
42
|
tag: 'skey',
|
|
43
43
|
attrs: {},
|
|
44
44
|
content: [
|
|
45
|
-
{ tag: 'id', attrs: {}, content: encodeBigEndian(key.keyId, 3) },
|
|
45
|
+
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(key.keyId, 3) },
|
|
46
46
|
{ tag: 'value', attrs: {}, content: key.keyPair.public },
|
|
47
47
|
{ tag: 'signature', attrs: {}, content: key.signature }
|
|
48
48
|
]
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
exports.xmppSignedPreKey = xmppSignedPreKey;
|
|
51
|
+
const xmppPreKey = (pair, id) => ({
|
|
51
52
|
tag: 'key',
|
|
52
53
|
attrs: {},
|
|
53
54
|
content: [
|
|
54
|
-
{ tag: 'id', attrs: {}, content: encodeBigEndian(id, 3) },
|
|
55
|
+
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(id, 3) },
|
|
55
56
|
{ tag: 'value', attrs: {}, content: pair.public }
|
|
56
57
|
]
|
|
57
58
|
});
|
|
58
|
-
|
|
59
|
+
exports.xmppPreKey = xmppPreKey;
|
|
60
|
+
const parseAndInjectE2ESessions = async (node, repository) => {
|
|
59
61
|
const extractKey = (key) => key
|
|
60
62
|
? {
|
|
61
|
-
keyId: getBinaryNodeChildUInt(key, 'id', 3),
|
|
62
|
-
publicKey: generateSignalPubKey(getBinaryNodeChildBuffer(key, 'value')),
|
|
63
|
-
signature: getBinaryNodeChildBuffer(key, 'signature')
|
|
63
|
+
keyId: (0, WABinary_1.getBinaryNodeChildUInt)(key, 'id', 3),
|
|
64
|
+
publicKey: (0, crypto_1.generateSignalPubKey)((0, WABinary_1.getBinaryNodeChildBuffer)(key, 'value')),
|
|
65
|
+
signature: (0, WABinary_1.getBinaryNodeChildBuffer)(key, 'signature')
|
|
64
66
|
}
|
|
65
67
|
: undefined;
|
|
66
|
-
const nodes = getBinaryNodeChildren(getBinaryNodeChild(node, 'list'), 'user');
|
|
68
|
+
const nodes = (0, WABinary_1.getBinaryNodeChildren)((0, WABinary_1.getBinaryNodeChild)(node, 'list'), 'user');
|
|
67
69
|
for (const node of nodes) {
|
|
68
|
-
assertNodeErrorFree(node);
|
|
70
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
69
71
|
}
|
|
70
72
|
// Most of the work in repository.injectE2ESession is CPU intensive, not IO
|
|
71
73
|
// So Promise.all doesn't really help here,
|
|
@@ -73,19 +75,19 @@ export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
|
73
75
|
// This way we chunk it in smaller parts and between those parts we can yield to the event loop
|
|
74
76
|
// It's rare case when you need to E2E sessions for so many users, but it's possible
|
|
75
77
|
const chunkSize = 100;
|
|
76
|
-
const chunks = chunk(nodes, chunkSize);
|
|
78
|
+
const chunks = (0, lodash_1.chunk)(nodes, chunkSize);
|
|
77
79
|
for (const nodesChunk of chunks) {
|
|
78
80
|
await Promise.all(nodesChunk.map(async (node) => {
|
|
79
|
-
const signedKey = getBinaryNodeChild(node, 'skey');
|
|
80
|
-
const key = getBinaryNodeChild(node, 'key');
|
|
81
|
-
const identity = getBinaryNodeChildBuffer(node, 'identity');
|
|
81
|
+
const signedKey = (0, WABinary_1.getBinaryNodeChild)(node, 'skey');
|
|
82
|
+
const key = (0, WABinary_1.getBinaryNodeChild)(node, 'key');
|
|
83
|
+
const identity = (0, WABinary_1.getBinaryNodeChildBuffer)(node, 'identity');
|
|
82
84
|
const jid = node.attrs.jid;
|
|
83
|
-
const registrationId = getBinaryNodeChildUInt(node, 'registration', 4);
|
|
85
|
+
const registrationId = (0, WABinary_1.getBinaryNodeChildUInt)(node, 'registration', 4);
|
|
84
86
|
await repository.injectE2ESession({
|
|
85
87
|
jid,
|
|
86
88
|
session: {
|
|
87
89
|
registrationId: registrationId,
|
|
88
|
-
identityKey: generateSignalPubKey(identity),
|
|
90
|
+
identityKey: (0, crypto_1.generateSignalPubKey)(identity),
|
|
89
91
|
signedPreKey: extractKey(signedKey),
|
|
90
92
|
preKey: extractKey(key)
|
|
91
93
|
}
|
|
@@ -93,13 +95,14 @@ export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
|
93
95
|
}));
|
|
94
96
|
}
|
|
95
97
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
exports.parseAndInjectE2ESessions = parseAndInjectE2ESessions;
|
|
99
|
+
const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
|
|
100
|
+
const { user: myUser, device: myDevice } = (0, WABinary_1.jidDecode)(myJid);
|
|
98
101
|
const extracted = [];
|
|
99
102
|
for (const userResult of result) {
|
|
100
103
|
const { devices, id } = userResult;
|
|
101
|
-
const { user } = jidDecode(id);
|
|
102
|
-
const deviceList = devices
|
|
104
|
+
const { user } = (0, WABinary_1.jidDecode)(id);
|
|
105
|
+
const deviceList = devices === null || devices === void 0 ? void 0 : devices.deviceList;
|
|
103
106
|
if (Array.isArray(deviceList)) {
|
|
104
107
|
for (const { id: device, keyIndex } of deviceList) {
|
|
105
108
|
if ((!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
|
@@ -113,38 +116,40 @@ export const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
|
|
|
113
116
|
}
|
|
114
117
|
return extracted;
|
|
115
118
|
};
|
|
119
|
+
exports.extractDeviceJids = extractDeviceJids;
|
|
116
120
|
/**
|
|
117
121
|
* get the next N keys for upload or processing
|
|
118
122
|
* @param count number of pre-keys to get or generate
|
|
119
123
|
*/
|
|
120
|
-
|
|
121
|
-
const { newPreKeys, lastPreKeyId, preKeysRange } = generateOrGetPreKeys(creds, count);
|
|
124
|
+
const getNextPreKeys = async ({ creds, keys }, count) => {
|
|
125
|
+
const { newPreKeys, lastPreKeyId, preKeysRange } = (0, exports.generateOrGetPreKeys)(creds, count);
|
|
122
126
|
const update = {
|
|
123
127
|
nextPreKeyId: Math.max(lastPreKeyId + 1, creds.nextPreKeyId),
|
|
124
128
|
firstUnuploadedPreKeyId: Math.max(creds.firstUnuploadedPreKeyId, lastPreKeyId + 1)
|
|
125
129
|
};
|
|
126
130
|
await keys.set({ 'pre-key': newPreKeys });
|
|
127
|
-
const preKeys = await getPreKeys(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
|
|
131
|
+
const preKeys = await (0, exports.getPreKeys)(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
|
|
128
132
|
return { update, preKeys };
|
|
129
133
|
};
|
|
130
|
-
|
|
134
|
+
exports.getNextPreKeys = getNextPreKeys;
|
|
135
|
+
const getNextPreKeysNode = async (state, count) => {
|
|
131
136
|
const { creds } = state;
|
|
132
|
-
const { update, preKeys } = await getNextPreKeys(state, count);
|
|
137
|
+
const { update, preKeys } = await (0, exports.getNextPreKeys)(state, count);
|
|
133
138
|
const node = {
|
|
134
139
|
tag: 'iq',
|
|
135
140
|
attrs: {
|
|
136
141
|
xmlns: 'encrypt',
|
|
137
142
|
type: 'set',
|
|
138
|
-
to: S_WHATSAPP_NET
|
|
143
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
139
144
|
},
|
|
140
145
|
content: [
|
|
141
|
-
{ tag: 'registration', attrs: {}, content: encodeBigEndian(creds.registrationId) },
|
|
142
|
-
{ tag: 'type', attrs: {}, content: KEY_BUNDLE_TYPE },
|
|
146
|
+
{ tag: 'registration', attrs: {}, content: (0, generics_1.encodeBigEndian)(creds.registrationId) },
|
|
147
|
+
{ tag: 'type', attrs: {}, content: Defaults_1.KEY_BUNDLE_TYPE },
|
|
143
148
|
{ tag: 'identity', attrs: {}, content: creds.signedIdentityKey.public },
|
|
144
|
-
{ tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => xmppPreKey(preKeys[+k], +k)) },
|
|
145
|
-
xmppSignedPreKey(creds.signedPreKey)
|
|
149
|
+
{ tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => (0, exports.xmppPreKey)(preKeys[+k], +k)) },
|
|
150
|
+
(0, exports.xmppSignedPreKey)(creds.signedPreKey)
|
|
146
151
|
]
|
|
147
152
|
};
|
|
148
153
|
return { update, node };
|
|
149
154
|
};
|
|
150
|
-
|
|
155
|
+
exports.getNextPreKeysNode = getNextPreKeysNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AuthenticationState } from '../Types';
|
|
2
2
|
/**
|
|
3
3
|
* stores the full authentication state in a single folder.
|
|
4
4
|
* Far more efficient than singlefileauthstate
|
|
@@ -10,4 +10,3 @@ export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
|
|
10
10
|
state: AuthenticationState;
|
|
11
11
|
saveCreds: () => Promise<void>;
|
|
12
12
|
}>;
|
|
13
|
-
//# sourceMappingURL=use-multi-file-auth-state.d.ts.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMultiFileAuthState = void 0;
|
|
4
|
+
const async_mutex_1 = require("async-mutex");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const WAProto_1 = require("../../WAProto");
|
|
8
|
+
const auth_utils_1 = require("./auth-utils");
|
|
9
|
+
const generics_1 = require("./generics");
|
|
7
10
|
// We need to lock files due to the fact that we are using async functions to read and write files
|
|
8
11
|
// https://github.com/WhiskeySockets/Baileys/issues/794
|
|
9
12
|
// https://github.com/nodejs/node/issues/26338
|
|
@@ -13,7 +16,7 @@ const fileLocks = new Map();
|
|
|
13
16
|
const getFileLock = (path) => {
|
|
14
17
|
let mutex = fileLocks.get(path);
|
|
15
18
|
if (!mutex) {
|
|
16
|
-
mutex = new Mutex();
|
|
19
|
+
mutex = new async_mutex_1.Mutex();
|
|
17
20
|
fileLocks.set(path, mutex);
|
|
18
21
|
}
|
|
19
22
|
return mutex;
|
|
@@ -25,14 +28,14 @@ const getFileLock = (path) => {
|
|
|
25
28
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
26
29
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
27
30
|
* */
|
|
28
|
-
|
|
31
|
+
const useMultiFileAuthState = async (folder) => {
|
|
29
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
33
|
const writeData = async (data, file) => {
|
|
31
|
-
const filePath = join(folder, fixFileName(file));
|
|
34
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
32
35
|
const mutex = getFileLock(filePath);
|
|
33
36
|
return mutex.acquire().then(async (release) => {
|
|
34
37
|
try {
|
|
35
|
-
await writeFile(filePath, JSON.stringify(data, BufferJSON.replacer));
|
|
38
|
+
await (0, promises_1.writeFile)(filePath, JSON.stringify(data, generics_1.BufferJSON.replacer));
|
|
36
39
|
}
|
|
37
40
|
finally {
|
|
38
41
|
release();
|
|
@@ -41,12 +44,12 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
41
44
|
};
|
|
42
45
|
const readData = async (file) => {
|
|
43
46
|
try {
|
|
44
|
-
const filePath = join(folder, fixFileName(file));
|
|
47
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
45
48
|
const mutex = getFileLock(filePath);
|
|
46
49
|
return await mutex.acquire().then(async (release) => {
|
|
47
50
|
try {
|
|
48
|
-
const data = await readFile(filePath, { encoding: 'utf-8' });
|
|
49
|
-
return JSON.parse(data, BufferJSON.reviver);
|
|
51
|
+
const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
|
|
52
|
+
return JSON.parse(data, generics_1.BufferJSON.reviver);
|
|
50
53
|
}
|
|
51
54
|
finally {
|
|
52
55
|
release();
|
|
@@ -59,32 +62,32 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
59
62
|
};
|
|
60
63
|
const removeData = async (file) => {
|
|
61
64
|
try {
|
|
62
|
-
const filePath = join(folder, fixFileName(file));
|
|
65
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
63
66
|
const mutex = getFileLock(filePath);
|
|
64
67
|
return mutex.acquire().then(async (release) => {
|
|
65
68
|
try {
|
|
66
|
-
await unlink(filePath);
|
|
69
|
+
await (0, promises_1.unlink)(filePath);
|
|
67
70
|
}
|
|
68
|
-
catch {
|
|
71
|
+
catch (_a) {
|
|
69
72
|
}
|
|
70
73
|
finally {
|
|
71
74
|
release();
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
|
-
catch { }
|
|
78
|
+
catch (_a) { }
|
|
76
79
|
};
|
|
77
|
-
const folderInfo = await stat(folder).catch(() => { });
|
|
80
|
+
const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
|
|
78
81
|
if (folderInfo) {
|
|
79
82
|
if (!folderInfo.isDirectory()) {
|
|
80
83
|
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
|
-
await mkdir(folder, { recursive: true });
|
|
87
|
+
await (0, promises_1.mkdir)(folder, { recursive: true });
|
|
85
88
|
}
|
|
86
|
-
const fixFileName = (file) => file
|
|
87
|
-
const creds = (await readData('creds.json')) || initAuthCreds();
|
|
89
|
+
const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
|
|
90
|
+
const creds = (await readData('creds.json')) || (0, auth_utils_1.initAuthCreds)();
|
|
88
91
|
return {
|
|
89
92
|
state: {
|
|
90
93
|
creds,
|
|
@@ -94,7 +97,7 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
94
97
|
await Promise.all(ids.map(async (id) => {
|
|
95
98
|
let value = await readData(`${type}-${id}.json`);
|
|
96
99
|
if (type === 'app-state-sync-key' && value) {
|
|
97
|
-
value = proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
100
|
+
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
98
101
|
}
|
|
99
102
|
data[id] = value;
|
|
100
103
|
}));
|
|
@@ -118,4 +121,4 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
118
121
|
}
|
|
119
122
|
};
|
|
120
123
|
};
|
|
121
|
-
|
|
124
|
+
exports.useMultiFileAuthState = useMultiFileAuthState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { proto } from '../../WAProto
|
|
2
|
-
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types
|
|
3
|
-
import {
|
|
1
|
+
import { proto } from '../../WAProto';
|
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
4
|
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
5
5
|
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
6
6
|
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, "advSecretKey" | "signedIdentityKey" | "signalIdentities">) => {
|
|
@@ -8,4 +8,3 @@ export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecre
|
|
|
8
8
|
reply: BinaryNode;
|
|
9
9
|
};
|
|
10
10
|
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array<ArrayBufferLike>;
|
|
11
|
-
//# sourceMappingURL=validate-connection.d.ts.map
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const WAProto_1 = require("../../WAProto");
|
|
7
|
+
const Defaults_1 = require("../Defaults");
|
|
8
|
+
const WABinary_1 = require("../WABinary");
|
|
9
|
+
const crypto_2 = require("./crypto");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const signal_1 = require("./signal");
|
|
9
12
|
const getUserAgent = (config) => {
|
|
10
13
|
return {
|
|
11
14
|
appVersion: {
|
|
@@ -13,8 +16,8 @@ const getUserAgent = (config) => {
|
|
|
13
16
|
secondary: config.version[1],
|
|
14
17
|
tertiary: config.version[2]
|
|
15
18
|
},
|
|
16
|
-
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
|
-
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
19
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
20
|
+
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
18
21
|
osVersion: '0.1',
|
|
19
22
|
device: 'Desktop',
|
|
20
23
|
osBuildNumber: '0.1',
|
|
@@ -25,11 +28,11 @@ const getUserAgent = (config) => {
|
|
|
25
28
|
};
|
|
26
29
|
};
|
|
27
30
|
const PLATFORM_MAP = {
|
|
28
|
-
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
29
|
-
Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
31
|
+
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
32
|
+
Windows: WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
30
33
|
};
|
|
31
34
|
const getWebInfo = (config) => {
|
|
32
|
-
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
35
|
+
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
33
36
|
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
34
37
|
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
35
38
|
}
|
|
@@ -37,15 +40,15 @@ const getWebInfo = (config) => {
|
|
|
37
40
|
};
|
|
38
41
|
const getClientPayload = (config) => {
|
|
39
42
|
const payload = {
|
|
40
|
-
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
41
|
-
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
43
|
+
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
44
|
+
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
42
45
|
userAgent: getUserAgent(config)
|
|
43
46
|
};
|
|
44
47
|
payload.webInfo = getWebInfo(config);
|
|
45
48
|
return payload;
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
const { user, device } = jidDecode(userJid);
|
|
50
|
+
const generateLoginNode = (userJid, config) => {
|
|
51
|
+
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
49
52
|
const payload = {
|
|
50
53
|
...getClientPayload(config),
|
|
51
54
|
passive: false,
|
|
@@ -53,17 +56,17 @@ export const generateLoginNode = (userJid, config) => {
|
|
|
53
56
|
username: +user,
|
|
54
57
|
device: device
|
|
55
58
|
};
|
|
56
|
-
return proto.ClientPayload.fromObject(payload);
|
|
59
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
57
60
|
};
|
|
61
|
+
exports.generateLoginNode = generateLoginNode;
|
|
58
62
|
const getPlatformType = (platform) => {
|
|
59
63
|
const platformType = platform.toUpperCase();
|
|
60
|
-
return
|
|
61
|
-
proto.DeviceProps.PlatformType.DESKTOP);
|
|
64
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.DESKTOP;
|
|
62
65
|
};
|
|
63
|
-
|
|
66
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
64
67
|
// the app version needs to be md5 hashed
|
|
65
68
|
// and passed in
|
|
66
|
-
const appVersionBuf = createHash('md5')
|
|
69
|
+
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
67
70
|
.update(config.version.join('.')) // join as string
|
|
68
71
|
.digest();
|
|
69
72
|
const companion = {
|
|
@@ -71,7 +74,7 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
|
|
|
71
74
|
platformType: getPlatformType(config.browser[1]),
|
|
72
75
|
requireFullSync: config.syncFullHistory
|
|
73
76
|
};
|
|
74
|
-
const companionProto = proto.DeviceProps.encode(companion).finish();
|
|
77
|
+
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
75
78
|
const registerPayload = {
|
|
76
79
|
...getClientPayload(config),
|
|
77
80
|
passive: false,
|
|
@@ -79,51 +82,52 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
|
|
|
79
82
|
devicePairingData: {
|
|
80
83
|
buildHash: appVersionBuf,
|
|
81
84
|
deviceProps: companionProto,
|
|
82
|
-
eRegid: encodeBigEndian(registrationId),
|
|
83
|
-
eKeytype: KEY_BUNDLE_TYPE,
|
|
85
|
+
eRegid: (0, generics_1.encodeBigEndian)(registrationId),
|
|
86
|
+
eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
|
|
84
87
|
eIdent: signedIdentityKey.public,
|
|
85
|
-
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
|
88
|
+
eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
86
89
|
eSkeyVal: signedPreKey.keyPair.public,
|
|
87
90
|
eSkeySig: signedPreKey.signature
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
|
-
return proto.ClientPayload.fromObject(registerPayload);
|
|
93
|
+
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
91
94
|
};
|
|
92
|
-
|
|
95
|
+
exports.generateRegistrationNode = generateRegistrationNode;
|
|
96
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
93
97
|
const msgId = stanza.attrs.id;
|
|
94
|
-
const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
|
|
95
|
-
const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
|
|
96
|
-
const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
|
|
97
|
-
const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
|
|
98
|
-
const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
|
|
98
|
+
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
99
|
+
const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
|
|
100
|
+
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
101
|
+
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
102
|
+
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
99
103
|
if (!deviceIdentityNode || !deviceNode) {
|
|
100
|
-
throw new Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
104
|
+
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
101
105
|
}
|
|
102
|
-
const bizName = businessNode
|
|
106
|
+
const bizName = businessNode === null || businessNode === void 0 ? void 0 : businessNode.attrs.name;
|
|
103
107
|
const jid = deviceNode.attrs.jid;
|
|
104
|
-
const { details, hmac, accountType } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
105
|
-
const isHostedAccount = accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED;
|
|
108
|
+
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
109
|
+
const isHostedAccount = accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED;
|
|
106
110
|
const hmacPrefix = isHostedAccount ? Buffer.from([6, 5]) : Buffer.alloc(0);
|
|
107
|
-
const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
111
|
+
const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
108
112
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
109
|
-
throw new Boom('Invalid account signature');
|
|
113
|
+
throw new boom_1.Boom('Invalid account signature');
|
|
110
114
|
}
|
|
111
|
-
const account = proto.ADVSignedDeviceIdentity.decode(details);
|
|
115
|
+
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
112
116
|
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
113
117
|
const accountMsg = Buffer.concat([Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public]);
|
|
114
|
-
if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
115
|
-
throw new Boom('Failed to verify account signature');
|
|
118
|
+
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
119
|
+
throw new boom_1.Boom('Failed to verify account signature');
|
|
116
120
|
}
|
|
117
121
|
const devicePrefix = isHostedAccount ? Buffer.from([6, 6]) : Buffer.from([6, 1]);
|
|
118
122
|
const deviceMsg = Buffer.concat([devicePrefix, deviceDetails, signedIdentityKey.public, accountSignatureKey]);
|
|
119
|
-
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
120
|
-
const identity = createSignalIdentity(jid, accountSignatureKey);
|
|
121
|
-
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
122
|
-
const deviceIdentity = proto.ADVDeviceIdentity.decode(account.details);
|
|
123
|
+
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
124
|
+
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
125
|
+
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
126
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(account.details);
|
|
123
127
|
const reply = {
|
|
124
128
|
tag: 'iq',
|
|
125
129
|
attrs: {
|
|
126
|
-
to: S_WHATSAPP_NET,
|
|
130
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
127
131
|
type: 'result',
|
|
128
132
|
id: msgId
|
|
129
133
|
},
|
|
@@ -145,20 +149,22 @@ export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentit
|
|
|
145
149
|
account,
|
|
146
150
|
me: { id: jid, name: bizName },
|
|
147
151
|
signalIdentities: [...(signalIdentities || []), identity],
|
|
148
|
-
platform: platformNode
|
|
152
|
+
platform: platformNode === null || platformNode === void 0 ? void 0 : platformNode.attrs.name
|
|
149
153
|
};
|
|
150
154
|
return {
|
|
151
155
|
creds: authUpdate,
|
|
152
156
|
reply
|
|
153
157
|
};
|
|
154
158
|
};
|
|
155
|
-
|
|
159
|
+
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
160
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
161
|
+
var _a;
|
|
156
162
|
account = { ...account };
|
|
157
163
|
// set to null if we are not to include the signature key
|
|
158
164
|
// or if we are including the signature key but it is empty
|
|
159
|
-
if (!includeSignatureKey || !account.accountSignatureKey
|
|
165
|
+
if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
160
166
|
account.accountSignatureKey = null;
|
|
161
167
|
}
|
|
162
|
-
return proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
168
|
+
return WAProto_1.proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
163
169
|
};
|
|
164
|
-
|
|
170
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOKEN_MAP = exports.SINGLE_BYTE_TOKENS = exports.DOUBLE_BYTE_TOKENS = exports.TAGS = void 0;
|
|
4
|
+
exports.TAGS = {
|
|
2
5
|
LIST_EMPTY: 0,
|
|
3
6
|
DICTIONARY_0: 236,
|
|
4
7
|
DICTIONARY_1: 237,
|
|
@@ -17,7 +20,7 @@ export const TAGS = {
|
|
|
17
20
|
NIBBLE_8: 255,
|
|
18
21
|
PACKED_MAX: 127
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
exports.DOUBLE_BYTE_TOKENS = [
|
|
21
24
|
[
|
|
22
25
|
'read-self',
|
|
23
26
|
'active',
|
|
@@ -1051,7 +1054,7 @@ export const DOUBLE_BYTE_TOKENS = [
|
|
|
1051
1054
|
'1961'
|
|
1052
1055
|
]
|
|
1053
1056
|
];
|
|
1054
|
-
|
|
1057
|
+
exports.SINGLE_BYTE_TOKENS = [
|
|
1055
1058
|
'',
|
|
1056
1059
|
'xmlstreamstart',
|
|
1057
1060
|
'xmlstreamend',
|
|
@@ -1289,13 +1292,12 @@ export const SINGLE_BYTE_TOKENS = [
|
|
|
1289
1292
|
'03',
|
|
1290
1293
|
'screen_height'
|
|
1291
1294
|
];
|
|
1292
|
-
|
|
1293
|
-
for (const [i, SINGLE_BYTE_TOKEN] of SINGLE_BYTE_TOKENS.entries()) {
|
|
1294
|
-
TOKEN_MAP[SINGLE_BYTE_TOKEN] = { index: i };
|
|
1295
|
+
exports.TOKEN_MAP = {};
|
|
1296
|
+
for (const [i, SINGLE_BYTE_TOKEN] of exports.SINGLE_BYTE_TOKENS.entries()) {
|
|
1297
|
+
exports.TOKEN_MAP[SINGLE_BYTE_TOKEN] = { index: i };
|
|
1295
1298
|
}
|
|
1296
|
-
for (const [i, DOUBLE_BYTE_TOKEN] of DOUBLE_BYTE_TOKENS.entries()) {
|
|
1299
|
+
for (const [i, DOUBLE_BYTE_TOKEN] of exports.DOUBLE_BYTE_TOKENS.entries()) {
|
|
1297
1300
|
for (const [j, element] of DOUBLE_BYTE_TOKEN.entries()) {
|
|
1298
|
-
TOKEN_MAP[element] = { dict: i, index: j };
|
|
1301
|
+
exports.TOKEN_MAP[element] = { dict: i, index: j };
|
|
1299
1302
|
}
|
|
1300
1303
|
}
|
|
1301
|
-
//# sourceMappingURL=constants.js.map
|
package/lib/WABinary/decode.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { BinaryNode, BinaryNodeCodingOptions } from './types
|
|
1
|
+
import type { BinaryNode, BinaryNodeCodingOptions } from './types';
|
|
2
2
|
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer<ArrayBufferLike>>;
|
|
3
3
|
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
|
|
4
4
|
index: number;
|
|
5
5
|
}) => BinaryNode;
|
|
6
6
|
export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>;
|
|
7
|
-
//# sourceMappingURL=decode.d.ts.map
|