@fer2809fl/baileys 7.0.1 → 7.0.4
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/README.md +322 -578
- package/WAProto/WAProto.proto +916 -360
- package/WAProto/fix-imports.js +18 -22
- package/WAProto/index.d.ts +15471 -8638
- package/WAProto/index.js +80576 -45941
- package/lib/Defaults/index.d.ts +14 -18
- package/lib/Defaults/index.js +111 -115
- package/lib/Signal/libsignal.js +22 -31
- package/lib/Signal/lid-mapping.d.ts +0 -4
- package/lib/Signal/lid-mapping.js +0 -6
- package/lib/Socket/business.d.ts +8 -75
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +0 -6
- package/lib/Socket/chats.js +3 -67
- package/lib/Socket/communities.d.ts +641 -336
- package/lib/Socket/communities.js +3 -6
- package/lib/Socket/dugong.d.ts +130 -0
- package/lib/Socket/dugong.js +772 -0
- package/lib/Socket/groups.d.ts +18 -23
- package/lib/Socket/groups.js +88 -168
- package/lib/Socket/index.d.ts +631 -322
- package/lib/Socket/index.js +12 -9
- package/lib/Socket/messages-recv.d.ts +52 -84
- package/lib/Socket/messages-recv.js +193 -677
- package/lib/Socket/messages-send.d.ts +643 -262
- package/lib/Socket/messages-send.js +1559 -1359
- package/lib/Socket/mex.d.ts +0 -1
- package/lib/Socket/mex.js +8 -22
- package/lib/Socket/native-buttons.js +231 -0
- package/lib/Socket/newsletter.d.ts +27 -42
- package/lib/Socket/newsletter.js +439 -402
- package/lib/Socket/socket.d.ts +2 -6
- package/lib/Socket/socket.js +47 -39
- package/lib/Types/Auth.d.ts +0 -1
- package/lib/Types/Bussines.d.ts +34 -22
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +0 -1
- package/lib/Types/Contact.d.ts +0 -2
- package/lib/Types/Events.d.ts +1 -20
- package/lib/Types/GroupMetadata.d.ts +1 -4
- package/lib/Types/Message.d.ts +348 -354
- package/lib/Types/Message.js +0 -4
- package/lib/Types/{Mex.d.ts → Newsletter.d.ts} +7 -17
- package/lib/Types/{Mex.js → Newsletter.js} +5 -3
- package/lib/Types/Signal.d.ts +1 -12
- package/lib/Types/Socket.d.ts +148 -135
- package/lib/Types/State.d.ts +0 -65
- package/lib/Types/State.js +0 -43
- package/lib/Types/index.d.ts +52 -52
- package/lib/Types/index.js +30 -23
- package/lib/Utils/auth-utils.d.ts +0 -5
- package/lib/Utils/auth-utils.js +0 -12
- package/lib/Utils/browser-utils.js +0 -1
- package/lib/Utils/crypto.d.ts +12 -12
- package/lib/Utils/decode-wa-message.d.ts +0 -18
- package/lib/Utils/decode-wa-message.js +0 -34
- package/lib/Utils/event-buffer.d.ts +0 -2
- package/lib/Utils/generics.d.ts +2 -3
- package/lib/Utils/generics.js +1 -10
- package/lib/Utils/history.d.ts +0 -2
- package/lib/Utils/history.js +9 -12
- package/lib/Utils/identity-change-handler.d.ts +0 -7
- package/lib/Utils/identity-change-handler.js +0 -1
- package/lib/Utils/index.d.ts +23 -30
- package/lib/Utils/index.js +3 -9
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/message-retry-manager.d.ts +0 -5
- package/lib/Utils/message-retry-manager.js +11 -11
- package/lib/Utils/messages-media.d.ts +13 -45
- package/lib/Utils/messages-media.js +98 -293
- package/lib/Utils/messages.d.ts +3 -16
- package/lib/Utils/messages.js +1123 -1219
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.js +1 -103
- package/lib/Utils/rich-messages.d.ts +277 -0
- package/lib/Utils/rich-messages.js +1144 -0
- package/lib/Utils/signal.d.ts +0 -13
- package/lib/Utils/signal.js +0 -42
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.js +0 -1
- package/lib/Utils/tc-token-utils.d.ts +1 -26
- package/lib/Utils/tc-token-utils.js +5 -151
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +3 -13
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.js +78 -0
- package/lib/WABinary/jid-utils.d.ts +0 -11
- package/lib/WABinary/jid-utils.js +0 -33
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -26
- package/lib/WAUSync/Protocols/index.d.ts +0 -1
- package/lib/WAUSync/USyncQuery.d.ts +0 -1
- package/lib/WAUSync/USyncQuery.js +1 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -4
- package/lib/WAUSync/USyncUser.js +0 -8
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -4
- package/package.json +27 -31
- package/LICENSE +0 -21
- package/engine-requirements.js +0 -10
- 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/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/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.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.map +0 -1
- 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/smgss.d.ts +0 -119
- package/lib/Socket/smgss.d.ts.map +0 -1
- package/lib/Socket/smgss.js +0 -453
- package/lib/Socket/smgss.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.d.ts.map +0 -1
- package/lib/Store/index.js +0 -4
- package/lib/Store/index.js.map +0 -1
- package/lib/Store/make-in-memory-store.d.ts +0 -132
- package/lib/Store/make-in-memory-store.d.ts.map +0 -1
- package/lib/Store/make-in-memory-store.js +0 -450
- package/lib/Store/make-in-memory-store.js.map +0 -1
- package/lib/Store/make-ordered-dictionary.d.ts +0 -14
- package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
- package/lib/Store/make-ordered-dictionary.js +0 -80
- package/lib/Store/make-ordered-dictionary.js.map +0 -1
- package/lib/Store/object-repository.d.ts +0 -13
- package/lib/Store/object-repository.d.ts.map +0 -1
- package/lib/Store/object-repository.js +0 -24
- package/lib/Store/object-repository.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.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/Mex.d.ts.map +0 -1
- package/lib/Types/Mex.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/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/button-handler.d.ts +0 -28
- package/lib/Utils/button-handler.d.ts.map +0 -1
- package/lib/Utils/button-handler.js +0 -140
- package/lib/Utils/button-handler.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/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-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/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/interactive.d.ts +0 -60
- package/lib/Utils/interactive.d.ts.map +0 -1
- package/lib/Utils/interactive.js +0 -224
- package/lib/Utils/interactive.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/message-composer.d.ts +0 -93
- package/lib/Utils/message-composer.d.ts.map +0 -1
- package/lib/Utils/message-composer.js +0 -311
- package/lib/Utils/message-composer.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages-newsletter.d.ts +0 -74
- package/lib/Utils/messages-newsletter.d.ts.map +0 -1
- package/lib/Utils/messages-newsletter.js +0 -128
- package/lib/Utils/messages-newsletter.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/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.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/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/shortcake-crypto.d.ts +0 -36
- package/lib/Utils/shortcake-crypto.d.ts.map +0 -1
- package/lib/Utils/shortcake-crypto.js +0 -71
- package/lib/Utils/shortcake-crypto.js.map +0 -1
- package/lib/Utils/shortcake.d.ts +0 -36
- package/lib/Utils/shortcake.d.ts.map +0 -1
- package/lib/Utils/shortcake.js +0 -162
- package/lib/Utils/shortcake.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.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/use-single-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-single-file-auth-state.js +0 -111
- package/lib/Utils/use-single-file-auth-state.js.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +0 -14
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.js +0 -107
- package/lib/Utils/use-sqlite-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/USyncUsernameProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.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
|
@@ -14,7 +14,7 @@ export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public
|
|
|
14
14
|
mixIntoKey: (data: Uint8Array) => void;
|
|
15
15
|
finishInit: () => Promise<void>;
|
|
16
16
|
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Uint8Array<ArrayBufferLike>;
|
|
17
|
-
encodeFrame: (data: Buffer | Uint8Array) => Buffer
|
|
17
|
+
encodeFrame: (data: Buffer | Uint8Array) => Buffer;
|
|
18
18
|
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>;
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=noise-handler.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Boom } from '@hapi/boom';
|
|
2
1
|
import { proto } from '../../WAProto/index.js';
|
|
3
2
|
import { WAMessageStubType } from '../Types/index.js';
|
|
4
3
|
import { getContentType, normalizeMessageContent } from '../Utils/messages.js';
|
|
@@ -6,7 +5,6 @@ import { areJidsSameUser, isHostedLidUser, isHostedPnUser, isJidBroadcast, isJid
|
|
|
6
5
|
import { aesDecryptGCM, hmacSign } from './crypto.js';
|
|
7
6
|
import { getKeyAuthor, toNumber } from './generics.js';
|
|
8
7
|
import { downloadAndProcessHistorySyncNotification } from './history.js';
|
|
9
|
-
import { buildMergedTcTokenIndexWrite, resolveTcTokenJid } from './tc-token-utils.js';
|
|
10
8
|
const REAL_MSG_STUB_TYPES = new Set([
|
|
11
9
|
WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
12
10
|
WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
@@ -14,53 +12,6 @@ const REAL_MSG_STUB_TYPES = new Set([
|
|
|
14
12
|
WAMessageStubType.CALL_MISSED_VOICE
|
|
15
13
|
]);
|
|
16
14
|
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
|
|
17
|
-
async function storeTcTokensFromHistorySync(chats, signalRepository, keyStore, logger) {
|
|
18
|
-
const getLIDForPN = signalRepository.lidMapping.getLIDForPN.bind(signalRepository.lidMapping);
|
|
19
|
-
const candidates = [];
|
|
20
|
-
for (const chat of chats) {
|
|
21
|
-
const ts = chat.tcTokenTimestamp ? toNumber(chat.tcTokenTimestamp) : 0;
|
|
22
|
-
if (chat.tcToken?.length && ts > 0) {
|
|
23
|
-
const jid = jidNormalizedUser(chat.id);
|
|
24
|
-
const storageJid = await resolveTcTokenJid(jid, getLIDForPN);
|
|
25
|
-
candidates.push({
|
|
26
|
-
storageJid,
|
|
27
|
-
token: Buffer.from(chat.tcToken),
|
|
28
|
-
ts,
|
|
29
|
-
senderTs: chat.tcTokenSenderTimestamp ? toNumber(chat.tcTokenSenderTimestamp) : undefined
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!candidates.length) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const jids = candidates.map(c => c.storageJid);
|
|
37
|
-
const existing = await keyStore.get('tctoken', jids);
|
|
38
|
-
const entries = {};
|
|
39
|
-
for (const c of candidates) {
|
|
40
|
-
const existingEntry = existing[c.storageJid];
|
|
41
|
-
const existingTs = existingEntry?.timestamp ? Number(existingEntry.timestamp) : 0;
|
|
42
|
-
if (existingTs > 0 && existingTs >= c.ts) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
entries[c.storageJid] = {
|
|
46
|
-
...existingEntry,
|
|
47
|
-
token: c.token,
|
|
48
|
-
timestamp: String(c.ts),
|
|
49
|
-
...(c.senderTs !== undefined ? { senderTimestamp: c.senderTs } : {})
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (Object.keys(entries).length) {
|
|
53
|
-
logger?.debug({ count: Object.keys(entries).length }, 'storing tctokens from history sync');
|
|
54
|
-
try {
|
|
55
|
-
// Include updated __index so cross-session pruning picks these JIDs up.
|
|
56
|
-
const indexWrite = await buildMergedTcTokenIndexWrite(keyStore, Object.keys(entries));
|
|
57
|
-
await keyStore.set({ tctoken: { ...entries, ...indexWrite } });
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
logger?.warn({ err }, 'failed to store tctokens from history sync');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
15
|
/** Cleans a received message to further processing */
|
|
65
16
|
export const cleanMessage = (message, meId, meLid) => {
|
|
66
17
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
@@ -122,17 +73,7 @@ export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !me
|
|
|
122
73
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
123
74
|
*/
|
|
124
75
|
export const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
125
|
-
if (!remoteJid) {
|
|
126
|
-
throw new Boom('Cannot derive chat id: message key is missing remoteJid', {
|
|
127
|
-
data: { remoteJid, participant, fromMe }
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
76
|
if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
|
|
131
|
-
if (!participant) {
|
|
132
|
-
throw new Boom('Cannot derive chat id: broadcast message key is missing participant', {
|
|
133
|
-
data: { remoteJid, fromMe }
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
77
|
return participant;
|
|
137
78
|
}
|
|
138
79
|
return remoteJid;
|
|
@@ -205,39 +146,6 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
205
146
|
}
|
|
206
147
|
const protocolMsg = content?.protocolMessage;
|
|
207
148
|
if (protocolMsg) {
|
|
208
|
-
// Mirror whatsmeow's `handleProtocolMessage` guard, but applied only to
|
|
209
|
-
// the protocol message types that originate from our own device — an
|
|
210
|
-
// attacker could otherwise spoof any of these to manipulate local state.
|
|
211
|
-
//
|
|
212
|
-
// Self-only types (drop if `!fromMe`):
|
|
213
|
-
// - HISTORY_SYNC_NOTIFICATION (our phone driving history sync)
|
|
214
|
-
// - APP_STATE_SYNC_KEY_SHARE (key share between our devices)
|
|
215
|
-
// - LID_MIGRATION_MAPPING_SYNC (server-initiated via our phone)
|
|
216
|
-
// - PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE (response from our phone to our PDO request)
|
|
217
|
-
//
|
|
218
|
-
// Cross-user types (must NOT be dropped — legitimately arrive from others):
|
|
219
|
-
// - REVOKE
|
|
220
|
-
// - MESSAGE_EDIT
|
|
221
|
-
// - EPHEMERAL_SETTING
|
|
222
|
-
// - GROUP_MEMBER_LABEL_CHANGE
|
|
223
|
-
//
|
|
224
|
-
// See https://github.com/tulir/whatsmeow/blob/8d3700152a/message.go#L842-L845
|
|
225
|
-
// for the reference architecture — whatsmeow's `handleProtocolMessage`
|
|
226
|
-
// only contains self-only types because edits are unwrapped from
|
|
227
|
-
// `EditedMessage` BEFORE this dispatch and revokes aren't routed here.
|
|
228
|
-
const SELF_ONLY_TYPES = new Set([
|
|
229
|
-
proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION,
|
|
230
|
-
proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE,
|
|
231
|
-
proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC,
|
|
232
|
-
proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE
|
|
233
|
-
]);
|
|
234
|
-
if (protocolMsg.type !== null &&
|
|
235
|
-
protocolMsg.type !== undefined &&
|
|
236
|
-
SELF_ONLY_TYPES.has(protocolMsg.type) &&
|
|
237
|
-
!message.key.fromMe) {
|
|
238
|
-
logger?.warn({ msgId: message.key.id, type: protocolMsg.type, from: message.key.participant || message.key.remoteJid }, 'dropping spoofed self-only protocolMessage from non-self origin');
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
149
|
switch (protocolMsg.type) {
|
|
242
150
|
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
243
151
|
const histNotification = protocolMsg.historySyncNotification;
|
|
@@ -266,11 +174,9 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
266
174
|
.storeLIDPNMappings(data.lidPnMappings)
|
|
267
175
|
.catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'));
|
|
268
176
|
}
|
|
269
|
-
await storeTcTokensFromHistorySync(data.chats, signalRepository, keyStore, logger);
|
|
270
177
|
ev.emit('messaging-history.set', {
|
|
271
178
|
...data,
|
|
272
179
|
isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
|
|
273
|
-
chunkOrder: histNotification.chunkOrder,
|
|
274
180
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
275
181
|
});
|
|
276
182
|
}
|
|
@@ -477,19 +383,12 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
477
383
|
id: jid,
|
|
478
384
|
author: message.key.participant,
|
|
479
385
|
authorPn: message.key.participantAlt,
|
|
480
|
-
authorUsername: message.key.participantUsername,
|
|
481
386
|
participants,
|
|
482
387
|
action
|
|
483
388
|
});
|
|
484
389
|
const emitGroupUpdate = (update) => {
|
|
485
390
|
ev.emit('groups.update', [
|
|
486
|
-
{
|
|
487
|
-
id: jid,
|
|
488
|
-
...update,
|
|
489
|
-
author: message.key.participant ?? undefined,
|
|
490
|
-
authorPn: message.key.participantAlt,
|
|
491
|
-
authorUsername: message.key.participantUsername
|
|
492
|
-
}
|
|
391
|
+
{ id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
|
|
493
392
|
]);
|
|
494
393
|
};
|
|
495
394
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
@@ -497,7 +396,6 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
497
396
|
id: jid,
|
|
498
397
|
author: message.key.participant,
|
|
499
398
|
authorPn: message.key.participantAlt,
|
|
500
|
-
authorUsername: message.key.participantUsername,
|
|
501
399
|
participant: participant.lid,
|
|
502
400
|
participantPn: participant.pn,
|
|
503
401
|
action,
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { proto } from "../../WAProto/index.js";
|
|
2
|
+
export declare const JS_KEYWORDS: Set<string>;
|
|
3
|
+
export declare const PYTHON_KEYWORDS: Set<string>;
|
|
4
|
+
export declare const GO_KEYWORDS: Set<string>;
|
|
5
|
+
export declare const LUA_KEYWORDS: Set<string>;
|
|
6
|
+
export declare const BASH_KEYWORDS: Set<string>;
|
|
7
|
+
export declare const LANGUAGE_KEYWORDS: Record<string, Set<string>>;
|
|
8
|
+
export declare enum CodeHighlightType {
|
|
9
|
+
DEFAULT = 0,
|
|
10
|
+
KEYWORD = 1,
|
|
11
|
+
METHOD = 2,
|
|
12
|
+
STRING = 3,
|
|
13
|
+
NUMBER = 4,
|
|
14
|
+
COMMENT = 5,
|
|
15
|
+
}
|
|
16
|
+
export declare enum RichSubMessageType {
|
|
17
|
+
UNKNOWN = 0,
|
|
18
|
+
GRID_IMAGE = 1,
|
|
19
|
+
TEXT = 2,
|
|
20
|
+
INLINE_IMAGE = 3,
|
|
21
|
+
TABLE = 4,
|
|
22
|
+
CODE = 5,
|
|
23
|
+
DYNAMIC = 6,
|
|
24
|
+
MAP = 7,
|
|
25
|
+
LATEX = 8,
|
|
26
|
+
CONTENT_ITEMS = 9,
|
|
27
|
+
}
|
|
28
|
+
export interface RichMessageOptions {
|
|
29
|
+
headerText?: string;
|
|
30
|
+
footer?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
language?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CodeBlockOptions extends RichMessageOptions {
|
|
35
|
+
language?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface LatexExpression {
|
|
38
|
+
latexExpression: string;
|
|
39
|
+
url: string;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
fontHeight?: number;
|
|
43
|
+
imageTopPadding?: number;
|
|
44
|
+
imageLeadingPadding?: number;
|
|
45
|
+
imageBottomPadding?: number;
|
|
46
|
+
imageTrailingPadding?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface LatexOptions extends RichMessageOptions {
|
|
49
|
+
text?: string;
|
|
50
|
+
expressions: LatexExpression[];
|
|
51
|
+
}
|
|
52
|
+
export interface LatexImageOptions extends RichMessageOptions {
|
|
53
|
+
text?: string;
|
|
54
|
+
expressions: {
|
|
55
|
+
latexExpression: string;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
export type LatexRenderFn = (latex: string) => Promise<{
|
|
59
|
+
buffer: Buffer;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}>;
|
|
63
|
+
export type MediaUploadFn = (
|
|
64
|
+
imageBuffer: Buffer,
|
|
65
|
+
mediaType: string,
|
|
66
|
+
) => Promise<{
|
|
67
|
+
url: string;
|
|
68
|
+
directPath: string;
|
|
69
|
+
}>;
|
|
70
|
+
export interface UnifiedResponseOptions {
|
|
71
|
+
data: Buffer | Uint8Array;
|
|
72
|
+
headerText?: string;
|
|
73
|
+
footer?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface CapturedUnifiedResponse {
|
|
76
|
+
unifiedResponse: {
|
|
77
|
+
data: Uint8Array;
|
|
78
|
+
};
|
|
79
|
+
submessages: any[];
|
|
80
|
+
contextInfo: any;
|
|
81
|
+
}
|
|
82
|
+
export interface QuotedMessage {
|
|
83
|
+
key: {
|
|
84
|
+
id?: string | null;
|
|
85
|
+
participant?: string | null;
|
|
86
|
+
remoteJid?: string | null;
|
|
87
|
+
fromMe?: boolean | null;
|
|
88
|
+
};
|
|
89
|
+
sender?: string;
|
|
90
|
+
message?: proto.IMessage | null;
|
|
91
|
+
}
|
|
92
|
+
interface CodeToken {
|
|
93
|
+
highlightType: number;
|
|
94
|
+
codeContent: string;
|
|
95
|
+
}
|
|
96
|
+
export declare const tokenizeCode: (
|
|
97
|
+
codeStr: string,
|
|
98
|
+
language?: string,
|
|
99
|
+
) => CodeToken[];
|
|
100
|
+
export declare const buildRichContextInfo: (
|
|
101
|
+
quoted?: QuotedMessage | null,
|
|
102
|
+
) => Record<string, any>;
|
|
103
|
+
export declare const buildBotForwardedMessage: (
|
|
104
|
+
submessages: any[],
|
|
105
|
+
contextInfo: Record<string, any>,
|
|
106
|
+
unifiedResponse?: {
|
|
107
|
+
data: Buffer | Uint8Array;
|
|
108
|
+
} | null,
|
|
109
|
+
) => any;
|
|
110
|
+
export declare const generateTableContent: (
|
|
111
|
+
title: string,
|
|
112
|
+
headers: string[],
|
|
113
|
+
rows: string[][],
|
|
114
|
+
quoted?: QuotedMessage | null,
|
|
115
|
+
options?: RichMessageOptions,
|
|
116
|
+
) => {
|
|
117
|
+
message: any;
|
|
118
|
+
messageId: string;
|
|
119
|
+
};
|
|
120
|
+
export declare const generateListContent: (
|
|
121
|
+
title: string,
|
|
122
|
+
items: (string | string[])[],
|
|
123
|
+
quoted?: QuotedMessage | null,
|
|
124
|
+
options?: RichMessageOptions,
|
|
125
|
+
) => {
|
|
126
|
+
message: any;
|
|
127
|
+
messageId: string;
|
|
128
|
+
};
|
|
129
|
+
export declare const generateCodeBlockContent: (
|
|
130
|
+
code: string,
|
|
131
|
+
quoted?: QuotedMessage | null,
|
|
132
|
+
options?: CodeBlockOptions,
|
|
133
|
+
) => {
|
|
134
|
+
message: any;
|
|
135
|
+
messageId: string;
|
|
136
|
+
};
|
|
137
|
+
export declare const generateLatexContent: (
|
|
138
|
+
quoted: QuotedMessage | null | undefined,
|
|
139
|
+
options: LatexOptions,
|
|
140
|
+
) => {
|
|
141
|
+
message: any;
|
|
142
|
+
messageId: string;
|
|
143
|
+
};
|
|
144
|
+
export declare const generateLatexImageContent: (
|
|
145
|
+
quoted: QuotedMessage | null | undefined,
|
|
146
|
+
options: LatexImageOptions,
|
|
147
|
+
uploadFn: MediaUploadFn,
|
|
148
|
+
renderLatexToPng: LatexRenderFn,
|
|
149
|
+
) => Promise<{
|
|
150
|
+
message: any;
|
|
151
|
+
messageId: string;
|
|
152
|
+
}>;
|
|
153
|
+
export declare const generateLatexInlineImageContent: (
|
|
154
|
+
quoted: QuotedMessage | null | undefined,
|
|
155
|
+
options: LatexImageOptions,
|
|
156
|
+
uploadFn: MediaUploadFn,
|
|
157
|
+
renderLatexToPng: LatexRenderFn,
|
|
158
|
+
) => Promise<{
|
|
159
|
+
message: any;
|
|
160
|
+
messageId: string;
|
|
161
|
+
}>;
|
|
162
|
+
export declare const captureUnifiedResponse: (
|
|
163
|
+
msg: proto.IMessage,
|
|
164
|
+
) => CapturedUnifiedResponse | null;
|
|
165
|
+
export declare const generateUnifiedResponseContent: (
|
|
166
|
+
quoted: QuotedMessage | null | undefined,
|
|
167
|
+
captured: CapturedUnifiedResponse,
|
|
168
|
+
) => {
|
|
169
|
+
message: any;
|
|
170
|
+
messageId: string;
|
|
171
|
+
};
|
|
172
|
+
export declare const generateRichMessageContent: (
|
|
173
|
+
submessages: any[],
|
|
174
|
+
quoted?: QuotedMessage | null,
|
|
175
|
+
) => {
|
|
176
|
+
message: any;
|
|
177
|
+
messageId: string;
|
|
178
|
+
};
|
|
179
|
+
export interface CodeBlockV2Options extends RichMessageOptions {
|
|
180
|
+
language?: string;
|
|
181
|
+
text?: string;
|
|
182
|
+
}
|
|
183
|
+
interface UnifiedCodeToken {
|
|
184
|
+
content: string;
|
|
185
|
+
type: "DEFAULT" | "KEYWORD" | "METHOD" | "STR" | "NUMBER" | "COMMENT";
|
|
186
|
+
}
|
|
187
|
+
interface TokenizeCodeV2Result {
|
|
188
|
+
codeBlock: CodeToken[];
|
|
189
|
+
unified_codeBlock: UnifiedCodeToken[];
|
|
190
|
+
}
|
|
191
|
+
export declare const tokenizeCodeV2: (
|
|
192
|
+
code: string,
|
|
193
|
+
language?: string,
|
|
194
|
+
) => TokenizeCodeV2Result;
|
|
195
|
+
interface UnifiedTableRow {
|
|
196
|
+
is_header: boolean;
|
|
197
|
+
cells: string[];
|
|
198
|
+
}
|
|
199
|
+
interface TableMetadataV2Result {
|
|
200
|
+
title: string;
|
|
201
|
+
rows: {
|
|
202
|
+
items: string[];
|
|
203
|
+
isHeading?: boolean;
|
|
204
|
+
}[];
|
|
205
|
+
unified_rows: UnifiedTableRow[];
|
|
206
|
+
}
|
|
207
|
+
export declare const toTableMetadataV2: (
|
|
208
|
+
arr: string[],
|
|
209
|
+
) => TableMetadataV2Result;
|
|
210
|
+
export interface TableV2Options extends RichMessageOptions {
|
|
211
|
+
text?: string;
|
|
212
|
+
}
|
|
213
|
+
export declare const generateTableContentV2: (
|
|
214
|
+
table: string[],
|
|
215
|
+
quoted?: QuotedMessage | null,
|
|
216
|
+
options?: TableV2Options,
|
|
217
|
+
) => {
|
|
218
|
+
message: any;
|
|
219
|
+
messageId: string;
|
|
220
|
+
};
|
|
221
|
+
export declare const generateCodeBlockContentV2: (
|
|
222
|
+
code: string,
|
|
223
|
+
quoted?: QuotedMessage | null,
|
|
224
|
+
options?: CodeBlockV2Options,
|
|
225
|
+
) => {
|
|
226
|
+
message: any;
|
|
227
|
+
messageId: string;
|
|
228
|
+
};
|
|
229
|
+
export interface Citation {
|
|
230
|
+
sourceQuery?: string;
|
|
231
|
+
faviconCdnUrl?: string;
|
|
232
|
+
citationNumber?: number;
|
|
233
|
+
sourceTitle?: string;
|
|
234
|
+
}
|
|
235
|
+
export interface Proof {
|
|
236
|
+
version?: number;
|
|
237
|
+
useCase?: number;
|
|
238
|
+
signature?: string;
|
|
239
|
+
certificateChain?: string[];
|
|
240
|
+
}
|
|
241
|
+
export interface LinkMessageOptions extends RichMessageOptions {
|
|
242
|
+
botJid?: string;
|
|
243
|
+
forwardingScore?: number;
|
|
244
|
+
citations?: Citation[];
|
|
245
|
+
proofs?: Proof[];
|
|
246
|
+
}
|
|
247
|
+
export interface LinkV2MessageOptions extends RichMessageOptions {
|
|
248
|
+
searchEngine?: string;
|
|
249
|
+
}
|
|
250
|
+
export declare const generateLinkContent: (
|
|
251
|
+
text: string,
|
|
252
|
+
links: (string | { url: string; displayName?: string })[],
|
|
253
|
+
quoted?: QuotedMessage | null,
|
|
254
|
+
options?: LinkMessageOptions,
|
|
255
|
+
) => {
|
|
256
|
+
message: any;
|
|
257
|
+
messageId: string;
|
|
258
|
+
};
|
|
259
|
+
export declare const generateLinkContentV2: (
|
|
260
|
+
text: string,
|
|
261
|
+
links: (
|
|
262
|
+
| string
|
|
263
|
+
| {
|
|
264
|
+
url: string;
|
|
265
|
+
displayName?: string;
|
|
266
|
+
sourceDisplayName?: string;
|
|
267
|
+
sourceSubtitle?: string;
|
|
268
|
+
}
|
|
269
|
+
)[],
|
|
270
|
+
quoted?: QuotedMessage | null,
|
|
271
|
+
options?: LinkV2MessageOptions,
|
|
272
|
+
) => {
|
|
273
|
+
message: any;
|
|
274
|
+
messageId: string;
|
|
275
|
+
};
|
|
276
|
+
export {};
|
|
277
|
+
//# sourceMappingURL=rich-messages.d.ts.map
|