@hbmodsofc/baileys 1.7.8 → 2.2.0
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/LICENSE +1 -1
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +8 -12
- package/lib/Defaults/index.js +124 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +39 -28
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +2 -9
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +16 -47
- package/lib/Signal/libsignal.d.ts +3 -7
- package/lib/Signal/libsignal.js +39 -224
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
- package/lib/Socket/business.d.ts +78 -94
- package/lib/Socket/business.js +11 -130
- package/lib/Socket/chats.d.ts +233 -63
- package/lib/Socket/chats.js +184 -234
- package/lib/Socket/groups.d.ts +41 -62
- package/lib/Socket/groups.js +64 -76
- package/lib/Socket/hbmods.d.ts +253 -0
- package/lib/Socket/hbmods.js +1 -0
- package/lib/Socket/index.d.ts +83 -129
- package/lib/Socket/index.js +6 -13
- package/lib/Socket/messages-recv.d.ts +48 -59
- package/lib/Socket/messages-recv.js +371 -516
- package/lib/Socket/messages-send.d.ts +67 -86
- package/lib/Socket/messages-send.js +1 -1091
- package/lib/Socket/newsletter.d.ts +64 -76
- package/lib/Socket/newsletter.js +1 -184
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +13 -19
- package/lib/Socket/socket.js +1 -805
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Auth.d.ts +10 -4
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +9 -29
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +14 -55
- package/lib/Types/GroupMetadata.d.ts +5 -15
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +49 -75
- package/lib/Types/Message.js +7 -10
- package/lib/Types/Newsletter.d.ts +98 -129
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -29
- package/lib/Types/Socket.d.ts +22 -48
- package/lib/Types/State.d.ts +2 -13
- package/lib/Types/State.js +0 -12
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +3 -10
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +102 -378
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +13 -19
- package/lib/Utils/chat-utils.d.ts +22 -21
- package/lib/Utils/chat-utils.js +154 -201
- package/lib/Utils/crypto.d.ts +19 -18
- package/lib/Utils/crypto.js +37 -78
- package/lib/Utils/decode-wa-message.d.ts +7 -34
- package/lib/Utils/decode-wa-message.js +66 -138
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +43 -81
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +133 -128
- package/lib/Utils/history.d.ts +5 -9
- package/lib/Utils/history.js +23 -17
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +12 -40
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +24 -23
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +2 -3
- package/lib/Utils/messages-media.d.ts +41 -37
- package/lib/Utils/messages-media.js +368 -252
- package/lib/Utils/messages.d.ts +15 -13
- package/lib/Utils/messages.js +261 -274
- package/lib/Utils/noise-handler.d.ts +15 -13
- package/lib/Utils/noise-handler.js +26 -20
- package/lib/Utils/process-message.d.ts +8 -9
- package/lib/Utils/process-message.js +93 -157
- package/lib/Utils/signal.d.ts +5 -6
- package/lib/Utils/signal.js +29 -37
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.js +7 -12
- package/lib/Utils/validate-connection.d.ts +6 -5
- package/lib/Utils/validate-connection.js +97 -39
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +14 -28
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +7 -4
- package/lib/WABinary/generic-utils.js +125 -40
- package/lib/WABinary/jid-utils.d.ts +8 -13
- package/lib/WABinary/jid-utils.js +16 -27
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/constants.js +2359 -2252
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAM/encode.js +11 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +15 -19
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -104
- package/WAProto/index.js +0 -37306
- package/lib/Signal/lid-mapping.d.ts +0 -26
- package/lib/Signal/lid-mapping.js +0 -146
- package/lib/Socket/communities.d.ts +0 -232
- package/lib/Socket/communities.js +0 -402
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.d.ts +0 -24
- package/lib/Types/Bussines.js +0 -2
- package/lib/Utils/lidToJid-test.d.ts +0 -11
- package/lib/Utils/lidToJid-test.js +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -81
- package/lib/Utils/message-retry-manager.js +0 -152
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import { KeyPair } from '../Types';
|
|
5
|
+
import { BinaryNode } from '../WABinary';
|
|
6
|
+
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, mobile, logger, routingInfo }: {
|
|
6
7
|
keyPair: KeyPair;
|
|
7
8
|
NOISE_HEADER: Uint8Array;
|
|
8
|
-
|
|
9
|
+
mobile: boolean;
|
|
10
|
+
logger: Logger;
|
|
9
11
|
routingInfo?: Buffer | undefined;
|
|
10
12
|
}) => {
|
|
11
|
-
encrypt: (plaintext: Uint8Array) => Buffer
|
|
12
|
-
decrypt: (ciphertext: Uint8Array) => Buffer
|
|
13
|
+
encrypt: (plaintext: Uint8Array) => Buffer;
|
|
14
|
+
decrypt: (ciphertext: Uint8Array) => Buffer;
|
|
13
15
|
authenticate: (data: Uint8Array) => void;
|
|
14
|
-
mixIntoKey: (data: Uint8Array) =>
|
|
15
|
-
finishInit: () =>
|
|
16
|
-
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) =>
|
|
17
|
-
encodeFrame: (data: Buffer | Uint8Array) => Buffer
|
|
18
|
-
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) =>
|
|
16
|
+
mixIntoKey: (data: Uint8Array) => void;
|
|
17
|
+
finishInit: () => void;
|
|
18
|
+
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Buffer;
|
|
19
|
+
encodeFrame: (data: Buffer | Uint8Array) => Buffer;
|
|
20
|
+
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => void;
|
|
19
21
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeNoiseHandler = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
|
-
const
|
|
5
|
+
const WAProto_1 = require("../../WAProto");
|
|
6
6
|
const Defaults_1 = require("../Defaults");
|
|
7
7
|
const WABinary_1 = require("../WABinary");
|
|
8
8
|
const crypto_1 = require("./crypto");
|
|
@@ -11,7 +11,7 @@ const generateIV = (counter) => {
|
|
|
11
11
|
new DataView(iv).setUint32(8, counter);
|
|
12
12
|
return new Uint8Array(iv);
|
|
13
13
|
};
|
|
14
|
-
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
|
|
14
|
+
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, mobile, logger, routingInfo }) => {
|
|
15
15
|
logger = logger.child({ class: 'ns' });
|
|
16
16
|
const authenticate = (data) => {
|
|
17
17
|
if (!isFinished) {
|
|
@@ -38,20 +38,20 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
38
38
|
authenticate(ciphertext);
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
|
-
const localHKDF =
|
|
42
|
-
const key =
|
|
41
|
+
const localHKDF = (data) => {
|
|
42
|
+
const key = (0, crypto_1.hkdf)(Buffer.from(data), 64, { salt, info: '' });
|
|
43
43
|
return [key.slice(0, 32), key.slice(32)];
|
|
44
44
|
};
|
|
45
|
-
const mixIntoKey =
|
|
46
|
-
const [write, read] =
|
|
45
|
+
const mixIntoKey = (data) => {
|
|
46
|
+
const [write, read] = localHKDF(data);
|
|
47
47
|
salt = write;
|
|
48
48
|
encKey = read;
|
|
49
49
|
decKey = read;
|
|
50
50
|
readCounter = 0;
|
|
51
51
|
writeCounter = 0;
|
|
52
52
|
};
|
|
53
|
-
const finishInit =
|
|
54
|
-
const [write, read] =
|
|
53
|
+
const finishInit = () => {
|
|
54
|
+
const [write, read] = localHKDF(new Uint8Array(0));
|
|
55
55
|
encKey = write;
|
|
56
56
|
decKey = read;
|
|
57
57
|
hash = Buffer.from([]);
|
|
@@ -60,7 +60,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
60
60
|
isFinished = true;
|
|
61
61
|
};
|
|
62
62
|
const data = Buffer.from(Defaults_1.NOISE_MODE);
|
|
63
|
-
let hash = data.byteLength === 32 ? data : (0, crypto_1.sha256)(data);
|
|
63
|
+
let hash = Buffer.from(data.byteLength === 32 ? data : (0, crypto_1.sha256)(data));
|
|
64
64
|
let salt = hash;
|
|
65
65
|
let encKey = hash;
|
|
66
66
|
let decKey = hash;
|
|
@@ -77,19 +77,24 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
77
77
|
authenticate,
|
|
78
78
|
mixIntoKey,
|
|
79
79
|
finishInit,
|
|
80
|
-
processHandshake:
|
|
80
|
+
processHandshake: ({ serverHello }, noiseKey) => {
|
|
81
81
|
authenticate(serverHello.ephemeral);
|
|
82
|
-
|
|
82
|
+
mixIntoKey(crypto_1.Curve.sharedKey(privateKey, serverHello.ephemeral));
|
|
83
83
|
const decStaticContent = decrypt(serverHello.static);
|
|
84
|
-
|
|
84
|
+
mixIntoKey(crypto_1.Curve.sharedKey(privateKey, decStaticContent));
|
|
85
85
|
const certDecoded = decrypt(serverHello.payload);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
if (mobile) {
|
|
87
|
+
WAProto_1.proto.CertChain.NoiseCertificate.decode(certDecoded);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded);
|
|
91
|
+
const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
92
|
+
if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
|
|
93
|
+
throw new boom_1.Boom('certification match failed', { statusCode: 400 });
|
|
94
|
+
}
|
|
90
95
|
}
|
|
91
96
|
const keyEnc = encrypt(noiseKey.public);
|
|
92
|
-
|
|
97
|
+
mixIntoKey(crypto_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
|
|
93
98
|
return keyEnc;
|
|
94
99
|
},
|
|
95
100
|
encodeFrame: (data) => {
|
|
@@ -120,7 +125,8 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
120
125
|
frame.set(data, introSize + 3);
|
|
121
126
|
return frame;
|
|
122
127
|
},
|
|
123
|
-
decodeFrame:
|
|
128
|
+
decodeFrame: (newData, onFrame) => {
|
|
129
|
+
var _a;
|
|
124
130
|
// the binary protocol uses its own framing mechanism
|
|
125
131
|
// on top of the WS frames
|
|
126
132
|
// so we get this data and separate out the frames
|
|
@@ -137,9 +143,9 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
137
143
|
inBytes = inBytes.slice(size + 3);
|
|
138
144
|
if (isFinished) {
|
|
139
145
|
const result = decrypt(frame);
|
|
140
|
-
frame =
|
|
146
|
+
frame = (0, WABinary_1.decodeBinaryNode)(result);
|
|
141
147
|
}
|
|
142
|
-
logger.trace({ msg: frame
|
|
148
|
+
logger.trace({ msg: (_a = frame === null || frame === void 0 ? void 0 : frame.attrs) === null || _a === void 0 ? void 0 : _a.id }, 'recv frame');
|
|
143
149
|
onFrame(frame);
|
|
144
150
|
size = getBytesSize();
|
|
145
151
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { Logger } from 'pino';
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import { AuthenticationCreds, BaileysEventEmitter, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
|
|
5
5
|
type ProcessMessageContext = {
|
|
6
6
|
shouldProcessHistoryMsg: boolean;
|
|
7
|
-
placeholderResendCache?: CacheStore;
|
|
8
7
|
creds: AuthenticationCreds;
|
|
9
8
|
keyStore: SignalKeyStoreWithTransaction;
|
|
10
9
|
ev: BaileysEventEmitter;
|
|
11
|
-
|
|
10
|
+
getMessage: SocketConfig['getMessage'];
|
|
11
|
+
logger?: Logger;
|
|
12
12
|
options: AxiosRequestConfig<{}>;
|
|
13
|
-
signalRepository: SignalRepositoryWithLIDStore;
|
|
14
13
|
};
|
|
15
14
|
/** Cleans a received message to further processing */
|
|
16
15
|
export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void;
|
|
@@ -37,6 +36,6 @@ type PollContext = {
|
|
|
37
36
|
* @param ctx additional info about the poll required for decryption
|
|
38
37
|
* @returns list of SHA256 options
|
|
39
38
|
*/
|
|
40
|
-
export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }: PollContext): proto.Message.PollVoteMessage;
|
|
41
|
-
declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg,
|
|
39
|
+
export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage;
|
|
40
|
+
declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>;
|
|
42
41
|
export default processMessage;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChatId = exports.shouldIncrementChatUnread = exports.isRealMessage = exports.cleanMessage = void 0;
|
|
4
|
-
|
|
5
|
-
const index_js_1 = require("../../WAProto/index.js");
|
|
3
|
+
exports.decryptPollVote = exports.getChatId = exports.shouldIncrementChatUnread = exports.isRealMessage = exports.cleanMessage = void 0;
|
|
4
|
+
const WAProto_1 = require("../../WAProto");
|
|
6
5
|
const Types_1 = require("../Types");
|
|
7
6
|
const messages_1 = require("../Utils/messages");
|
|
8
7
|
const WABinary_1 = require("../WABinary");
|
|
@@ -15,7 +14,9 @@ const REAL_MSG_STUB_TYPES = new Set([
|
|
|
15
14
|
Types_1.WAMessageStubType.CALL_MISSED_VIDEO,
|
|
16
15
|
Types_1.WAMessageStubType.CALL_MISSED_VOICE
|
|
17
16
|
]);
|
|
18
|
-
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
|
|
17
|
+
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
|
|
18
|
+
Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD
|
|
19
|
+
]);
|
|
19
20
|
/** Cleans a received message to further processing */
|
|
20
21
|
const cleanMessage = (message, meId) => {
|
|
21
22
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
@@ -23,10 +24,10 @@ const cleanMessage = (message, meId) => {
|
|
|
23
24
|
message.key.participant = message.key.participant ? (0, WABinary_1.jidNormalizedUser)(message.key.participant) : undefined;
|
|
24
25
|
const content = (0, messages_1.normalizeMessageContent)(message.message);
|
|
25
26
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
|
26
|
-
if (content
|
|
27
|
+
if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
|
|
27
28
|
normaliseKey(content.reactionMessage.key);
|
|
28
29
|
}
|
|
29
|
-
if (content
|
|
30
|
+
if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
|
|
30
31
|
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
|
|
31
32
|
}
|
|
32
33
|
function normaliseKey(msgKey) {
|
|
@@ -37,9 +38,9 @@ const cleanMessage = (message, meId) => {
|
|
|
37
38
|
// we've to correct the key to be from them, or some other participant
|
|
38
39
|
msgKey.fromMe = !msgKey.fromMe
|
|
39
40
|
? (0, WABinary_1.areJidsSameUser)(msgKey.participant || msgKey.remoteJid, meId)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// if the message being reacted to, was from them
|
|
42
|
+
// fromMe automatically becomes false
|
|
43
|
+
: false;
|
|
43
44
|
// set the remoteJid to being the same as the chat the message came from
|
|
44
45
|
msgKey.remoteJid = message.key.remoteJid;
|
|
45
46
|
// set participant of the message
|
|
@@ -49,26 +50,29 @@ const cleanMessage = (message, meId) => {
|
|
|
49
50
|
};
|
|
50
51
|
exports.cleanMessage = cleanMessage;
|
|
51
52
|
const isRealMessage = (message, meId) => {
|
|
53
|
+
var _a;
|
|
52
54
|
const normalizedContent = (0, messages_1.normalizeMessageContent)(message.message);
|
|
53
55
|
const hasSomeContent = !!(0, messages_1.getContentType)(normalizedContent);
|
|
54
|
-
return (
|
|
55
|
-
REAL_MSG_STUB_TYPES.has(message.messageStubType)
|
|
56
|
-
(REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType)
|
|
57
|
-
message.messageStubParameters
|
|
58
|
-
hasSomeContent
|
|
59
|
-
!normalizedContent
|
|
60
|
-
!normalizedContent
|
|
61
|
-
!normalizedContent
|
|
56
|
+
return (!!normalizedContent
|
|
57
|
+
|| REAL_MSG_STUB_TYPES.has(message.messageStubType)
|
|
58
|
+
|| (REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType)
|
|
59
|
+
&& ((_a = message.messageStubParameters) === null || _a === void 0 ? void 0 : _a.some(p => (0, WABinary_1.areJidsSameUser)(meId, p)))))
|
|
60
|
+
&& hasSomeContent
|
|
61
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.protocolMessage)
|
|
62
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.reactionMessage)
|
|
63
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.pollUpdateMessage);
|
|
62
64
|
};
|
|
63
65
|
exports.isRealMessage = isRealMessage;
|
|
64
|
-
const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
|
|
66
|
+
const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.messageStubType);
|
|
65
67
|
exports.shouldIncrementChatUnread = shouldIncrementChatUnread;
|
|
66
68
|
/**
|
|
67
69
|
* Get the ID of the chat from the given key.
|
|
68
70
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
69
71
|
*/
|
|
70
72
|
const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
71
|
-
if ((0, WABinary_1.isJidBroadcast)(remoteJid)
|
|
73
|
+
if ((0, WABinary_1.isJidBroadcast)(remoteJid)
|
|
74
|
+
&& !(0, WABinary_1.isJidStatusBroadcast)(remoteJid)
|
|
75
|
+
&& !fromMe) {
|
|
72
76
|
return participant;
|
|
73
77
|
}
|
|
74
78
|
return remoteJid;
|
|
@@ -80,7 +84,7 @@ exports.getChatId = getChatId;
|
|
|
80
84
|
* @param ctx additional info about the poll required for decryption
|
|
81
85
|
* @returns list of SHA256 options
|
|
82
86
|
*/
|
|
83
|
-
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
|
|
87
|
+
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }) {
|
|
84
88
|
const sign = Buffer.concat([
|
|
85
89
|
toBinary(pollMsgId),
|
|
86
90
|
toBinary(pollCreatorJid),
|
|
@@ -92,18 +96,19 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
92
96
|
const decKey = (0, crypto_1.hmacSign)(sign, key0, 'sha256');
|
|
93
97
|
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`);
|
|
94
98
|
const decrypted = (0, crypto_1.aesDecryptGCM)(encPayload, decKey, encIv, aad);
|
|
95
|
-
return
|
|
99
|
+
return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted);
|
|
96
100
|
function toBinary(txt) {
|
|
97
101
|
return Buffer.from(txt);
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
|
-
|
|
104
|
+
exports.decryptPollVote = decryptPollVote;
|
|
105
|
+
const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }) => {
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
101
107
|
const meId = creds.me.id;
|
|
102
108
|
const { accountSettings } = creds;
|
|
103
109
|
const chat = { id: (0, WABinary_1.jidNormalizedUser)((0, exports.getChatId)(message.key)) };
|
|
104
110
|
const isRealMsg = (0, exports.isRealMessage)(message, meId);
|
|
105
111
|
if (isRealMsg) {
|
|
106
|
-
chat.messages = [{ message }];
|
|
107
112
|
chat.conversationTimestamp = (0, generics_1.toNumber)(message.messageTimestamp);
|
|
108
113
|
// only increment unread count if not CIPHERTEXT and from another person
|
|
109
114
|
if ((0, exports.shouldIncrementChatUnread)(message)) {
|
|
@@ -113,43 +118,38 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
113
118
|
const content = (0, messages_1.normalizeMessageContent)(message.message);
|
|
114
119
|
// unarchive chat if it's a real message, or someone reacted to our message
|
|
115
120
|
// and we've the unarchive chats setting on
|
|
116
|
-
if ((isRealMsg || content
|
|
121
|
+
if ((isRealMsg || ((_b = (_a = content === null || content === void 0 ? void 0 : content.reactionMessage) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.fromMe))
|
|
122
|
+
&& (accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.unarchiveChats)) {
|
|
117
123
|
chat.archived = false;
|
|
118
124
|
chat.readOnly = false;
|
|
119
125
|
}
|
|
120
|
-
const protocolMsg = content
|
|
126
|
+
const protocolMsg = content === null || content === void 0 ? void 0 : content.protocolMessage;
|
|
121
127
|
if (protocolMsg) {
|
|
122
128
|
switch (protocolMsg.type) {
|
|
123
|
-
case
|
|
129
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
124
130
|
const histNotification = protocolMsg.historySyncNotification;
|
|
125
131
|
const process = shouldProcessHistoryMsg;
|
|
126
|
-
const isLatest = !creds.processedHistoryMessages
|
|
127
|
-
logger
|
|
132
|
+
const isLatest = !((_c = creds.processedHistoryMessages) === null || _c === void 0 ? void 0 : _c.length);
|
|
133
|
+
logger === null || logger === void 0 ? void 0 : logger.info({
|
|
128
134
|
histNotification,
|
|
129
135
|
process,
|
|
130
136
|
id: message.key.id,
|
|
131
|
-
isLatest
|
|
137
|
+
isLatest,
|
|
132
138
|
}, 'got history notification');
|
|
133
139
|
if (process) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
processedHistoryMessages
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
const data = await (0, history_1.downloadAndProcessHistorySyncNotification)(histNotification, options);
|
|
143
|
-
ev.emit('messaging-history.set', {
|
|
144
|
-
...data,
|
|
145
|
-
isLatest: histNotification.syncType !== index_js_1.proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
|
|
146
|
-
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
140
|
+
ev.emit('creds.update', {
|
|
141
|
+
processedHistoryMessages: [
|
|
142
|
+
...(creds.processedHistoryMessages || []),
|
|
143
|
+
{ key: message.key, messageTimestamp: message.messageTimestamp }
|
|
144
|
+
]
|
|
147
145
|
});
|
|
146
|
+
const data = await (0, history_1.downloadAndProcessHistorySyncNotification)(histNotification, options);
|
|
147
|
+
ev.emit('messaging-history.set', { ...data, isLatest });
|
|
148
148
|
}
|
|
149
149
|
break;
|
|
150
|
-
case
|
|
150
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
151
151
|
const keys = protocolMsg.appStateSyncKeyShare.keys;
|
|
152
|
-
if (keys
|
|
152
|
+
if (keys === null || keys === void 0 ? void 0 : keys.length) {
|
|
153
153
|
let newAppStateSyncKeyId = '';
|
|
154
154
|
await keyStore.transaction(async () => {
|
|
155
155
|
const newKeys = [];
|
|
@@ -159,15 +159,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
159
159
|
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } });
|
|
160
160
|
newAppStateSyncKeyId = strKeyId;
|
|
161
161
|
}
|
|
162
|
-
logger
|
|
163
|
-
}
|
|
162
|
+
logger === null || logger === void 0 ? void 0 : logger.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
|
|
163
|
+
});
|
|
164
164
|
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId });
|
|
165
165
|
}
|
|
166
166
|
else {
|
|
167
|
-
logger
|
|
167
|
+
logger === null || logger === void 0 ? void 0 : logger.info({ protocolMsg }, 'recv app state sync with 0 keys');
|
|
168
168
|
}
|
|
169
169
|
break;
|
|
170
|
-
case
|
|
170
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE:
|
|
171
171
|
ev.emit('messages.update', [
|
|
172
172
|
{
|
|
173
173
|
key: {
|
|
@@ -178,94 +178,50 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
178
178
|
}
|
|
179
179
|
]);
|
|
180
180
|
break;
|
|
181
|
-
case
|
|
181
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
182
182
|
Object.assign(chat, {
|
|
183
183
|
ephemeralSettingTimestamp: (0, generics_1.toNumber)(message.messageTimestamp),
|
|
184
184
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
|
185
185
|
});
|
|
186
186
|
break;
|
|
187
|
-
case
|
|
187
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
188
188
|
const response = protocolMsg.peerDataOperationRequestResponseMessage;
|
|
189
189
|
if (response) {
|
|
190
|
-
await placeholderResendCache?.del(response.stanzaId);
|
|
191
|
-
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
192
190
|
const { peerDataOperationResult } = response;
|
|
193
191
|
for (const result of peerDataOperationResult) {
|
|
194
192
|
const { placeholderMessageResendResponse: retryResponse } = result;
|
|
195
|
-
//eslint-disable-next-line max-depth
|
|
196
193
|
if (retryResponse) {
|
|
197
|
-
const webMessageInfo =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
messages: [webMessageInfo],
|
|
202
|
-
type: 'notify',
|
|
203
|
-
requestId: response.stanzaId
|
|
204
|
-
});
|
|
205
|
-
}, 500);
|
|
194
|
+
const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
|
|
195
|
+
ev.emit('messages.update', [
|
|
196
|
+
{ key: webMessageInfo.key, update: { message: webMessageInfo.message } }
|
|
197
|
+
]);
|
|
206
198
|
}
|
|
207
199
|
}
|
|
208
200
|
}
|
|
209
201
|
break;
|
|
210
|
-
case index_js_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
211
|
-
ev.emit('messages.update', [
|
|
212
|
-
{
|
|
213
|
-
// flip the sender / fromMe properties because they're in the perspective of the sender
|
|
214
|
-
key: { ...message.key, id: protocolMsg.key?.id },
|
|
215
|
-
update: {
|
|
216
|
-
message: {
|
|
217
|
-
editedMessage: {
|
|
218
|
-
message: protocolMsg.editedMessage
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
messageTimestamp: protocolMsg.timestampMs
|
|
222
|
-
? Math.floor((0, generics_1.toNumber)(protocolMsg.timestampMs) / 1000)
|
|
223
|
-
: message.messageTimestamp
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
]);
|
|
227
|
-
break;
|
|
228
|
-
case index_js_1.proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
|
|
229
|
-
const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload;
|
|
230
|
-
const { pnToLidMappings, chatDbMigrationTimestamp } = index_js_1.proto.LIDMigrationMappingSyncPayload.decode(encodedPayload);
|
|
231
|
-
logger?.debug({ pnToLidMappings, chatDbMigrationTimestamp }, 'got lid mappings and chat db migration timestamp');
|
|
232
|
-
const pairs = [];
|
|
233
|
-
for (const { pn, latestLid, assignedLid } of pnToLidMappings) {
|
|
234
|
-
const lid = latestLid || assignedLid;
|
|
235
|
-
pairs.push({ lid: `${lid}@lid`, pn: `${pn}@s.whatsapp.net` });
|
|
236
|
-
}
|
|
237
|
-
await signalRepository.lidMapping.storeLIDPNMappings(pairs);
|
|
238
202
|
}
|
|
239
203
|
}
|
|
240
|
-
else if (content
|
|
204
|
+
else if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
|
|
241
205
|
const reaction = {
|
|
242
206
|
...content.reactionMessage,
|
|
243
|
-
key: message.key
|
|
207
|
+
key: message.key,
|
|
244
208
|
};
|
|
245
|
-
ev.emit('messages.reaction', [
|
|
246
|
-
{
|
|
209
|
+
ev.emit('messages.reaction', [{
|
|
247
210
|
reaction,
|
|
248
|
-
key: content.reactionMessage
|
|
249
|
-
}
|
|
250
|
-
]);
|
|
211
|
+
key: content.reactionMessage.key,
|
|
212
|
+
}]);
|
|
251
213
|
}
|
|
252
214
|
else if (message.messageStubType) {
|
|
253
|
-
const jid = message.key
|
|
215
|
+
const jid = message.key.remoteJid;
|
|
254
216
|
//let actor = whatsappID (message.participant)
|
|
255
217
|
let participants;
|
|
256
|
-
const emitParticipantsUpdate = (action) => ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action });
|
|
218
|
+
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action }));
|
|
257
219
|
const emitGroupUpdate = (update) => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const emitGroupRequestJoin = (participant, action, method) => {
|
|
261
|
-
ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method });
|
|
220
|
+
var _a;
|
|
221
|
+
ev.emit('groups.update', [{ id: jid, ...update, author: (_a = message.participant) !== null && _a !== void 0 ? _a : undefined }]);
|
|
262
222
|
};
|
|
263
223
|
const participantsIncludesMe = () => participants.find(jid => (0, WABinary_1.areJidsSameUser)(meId, jid));
|
|
264
224
|
switch (message.messageStubType) {
|
|
265
|
-
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
266
|
-
participants = message.messageStubParameters || [];
|
|
267
|
-
emitParticipantsUpdate('modify');
|
|
268
|
-
break;
|
|
269
225
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
270
226
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
271
227
|
participants = message.messageStubParameters || [];
|
|
@@ -293,64 +249,48 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
293
249
|
emitParticipantsUpdate('promote');
|
|
294
250
|
break;
|
|
295
251
|
case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
296
|
-
const announceValue = message.messageStubParameters
|
|
252
|
+
const announceValue = (_d = message.messageStubParameters) === null || _d === void 0 ? void 0 : _d[0];
|
|
297
253
|
emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' });
|
|
298
254
|
break;
|
|
299
255
|
case Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
300
|
-
const restrictValue = message.messageStubParameters
|
|
256
|
+
const restrictValue = (_e = message.messageStubParameters) === null || _e === void 0 ? void 0 : _e[0];
|
|
301
257
|
emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' });
|
|
302
258
|
break;
|
|
303
259
|
case Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
304
|
-
const name = message.messageStubParameters
|
|
260
|
+
const name = (_f = message.messageStubParameters) === null || _f === void 0 ? void 0 : _f[0];
|
|
305
261
|
chat.name = name;
|
|
306
262
|
emitGroupUpdate({ subject: name });
|
|
307
263
|
break;
|
|
308
|
-
case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
309
|
-
const description = message.messageStubParameters?.[0];
|
|
310
|
-
chat.description = description;
|
|
311
|
-
emitGroupUpdate({ desc: description });
|
|
312
|
-
break;
|
|
313
264
|
case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
314
|
-
const code = message.messageStubParameters
|
|
265
|
+
const code = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
|
|
315
266
|
emitGroupUpdate({ inviteCode: code });
|
|
316
267
|
break;
|
|
317
268
|
case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
318
|
-
const memberAddValue = message.messageStubParameters
|
|
269
|
+
const memberAddValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
|
|
319
270
|
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
|
|
320
271
|
break;
|
|
321
272
|
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
322
|
-
const approvalMode = message.messageStubParameters
|
|
273
|
+
const approvalMode = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
|
|
323
274
|
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
|
|
324
275
|
break;
|
|
325
|
-
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
|
|
326
|
-
const participant = message.messageStubParameters?.[0];
|
|
327
|
-
const action = message.messageStubParameters?.[1];
|
|
328
|
-
const method = message.messageStubParameters?.[2];
|
|
329
|
-
emitGroupRequestJoin(participant, action, method);
|
|
330
|
-
break;
|
|
331
276
|
}
|
|
332
|
-
}
|
|
333
|
-
|
|
277
|
+
}
|
|
278
|
+
else if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
|
|
279
|
+
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey;
|
|
334
280
|
// we need to fetch the poll creation message to get the poll enc key
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
const voterJid = getKeyAuthor(message.key, meIdNormalised)
|
|
342
|
-
const pollEncKey = pollMsg.messageContextInfo?.messageSecret!
|
|
343
|
-
|
|
281
|
+
const pollMsg = await getMessage(creationMsgKey);
|
|
282
|
+
if (pollMsg) {
|
|
283
|
+
const meIdNormalised = (0, WABinary_1.jidNormalizedUser)(meId);
|
|
284
|
+
const pollCreatorJid = (0, generics_1.getKeyAuthor)(creationMsgKey, meIdNormalised);
|
|
285
|
+
const voterJid = (0, generics_1.getKeyAuthor)(message.key, meIdNormalised);
|
|
286
|
+
const pollEncKey = (_k = pollMsg.messageContextInfo) === null || _k === void 0 ? void 0 : _k.messageSecret;
|
|
344
287
|
try {
|
|
345
|
-
const voteMsg = decryptPollVote(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
voterJid,
|
|
352
|
-
}
|
|
353
|
-
)
|
|
288
|
+
const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {
|
|
289
|
+
pollEncKey,
|
|
290
|
+
pollCreatorJid,
|
|
291
|
+
pollMsgId: creationMsgKey.id,
|
|
292
|
+
voterJid,
|
|
293
|
+
});
|
|
354
294
|
ev.emit('messages.update', [
|
|
355
295
|
{
|
|
356
296
|
key: creationMsgKey,
|
|
@@ -359,25 +299,21 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
359
299
|
{
|
|
360
300
|
pollUpdateMessageKey: message.key,
|
|
361
301
|
vote: voteMsg,
|
|
362
|
-
senderTimestampMs:
|
|
302
|
+
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
363
303
|
}
|
|
364
304
|
]
|
|
365
305
|
}
|
|
366
306
|
}
|
|
367
|
-
])
|
|
368
|
-
} catch(err) {
|
|
369
|
-
logger?.warn(
|
|
370
|
-
{ err, creationMsgKey },
|
|
371
|
-
'failed to decrypt poll vote'
|
|
372
|
-
)
|
|
307
|
+
]);
|
|
373
308
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
309
|
+
catch (err) {
|
|
310
|
+
logger === null || logger === void 0 ? void 0 : logger.warn({ err, creationMsgKey }, 'failed to decrypt poll vote');
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
logger === null || logger === void 0 ? void 0 : logger.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update');
|
|
379
315
|
}
|
|
380
|
-
|
|
316
|
+
}
|
|
381
317
|
if (Object.keys(chat).length > 1) {
|
|
382
318
|
ev.emit('chats.update', [chat]);
|
|
383
319
|
}
|
package/lib/Utils/signal.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import type { USyncQueryResultList } from '../WAUSync';
|
|
1
|
+
import { SignalRepository } from '../Types';
|
|
2
|
+
import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
|
|
3
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
5
4
|
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
|
|
6
5
|
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
|
7
6
|
[id: string]: KeyPair;
|
|
@@ -15,8 +14,8 @@ export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: n
|
|
|
15
14
|
};
|
|
16
15
|
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
|
17
16
|
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
|
|
18
|
-
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository:
|
|
19
|
-
export declare const extractDeviceJids: (result:
|
|
17
|
+
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
|
|
18
|
+
export declare const extractDeviceJids: (result: BinaryNode, myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
|
|
20
19
|
/**
|
|
21
20
|
* get the next N keys for upload or processing
|
|
22
21
|
* @param count number of pre-keys to get or generate
|