@dhilzzkz/baileys 0.0.0-stage → 0.1.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 +23 -0
- package/NOTICE.md +37 -0
- package/README.md +2083 -2
- package/WAProto/index.d.ts +22220 -0
- package/WAProto/index.js +5 -0
- package/lib/Addon/http-error.d.ts +18 -0
- package/lib/Addon/http-error.js +40 -0
- package/lib/Addon/index.d.ts +3 -0
- package/lib/Addon/index.js +4 -0
- package/lib/Addon/keyed-db.d.ts +14 -0
- package/lib/Addon/keyed-db.js +241 -0
- package/lib/Addon/link-preview.d.ts +15 -0
- package/lib/Addon/link-preview.js +79 -0
- package/lib/Defaults/index.d.ts +188 -0
- package/lib/Defaults/index.js +185 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-cipher.d.ts +10 -0
- package/lib/Signal/Group/group-cipher.js +81 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/Protocol/crypto.d.ts +6 -0
- package/lib/Signal/Protocol/crypto.js +61 -0
- package/lib/Signal/Protocol/curve.d.ts +8 -0
- package/lib/Signal/Protocol/curve.js +61 -0
- package/lib/Signal/Protocol/index.d.ts +16 -0
- package/lib/Signal/Protocol/index.js +9 -0
- package/lib/Signal/Protocol/internals.d.ts +57 -0
- package/lib/Signal/Protocol/internals.js +155 -0
- package/lib/Signal/Protocol/session-builder.d.ts +40 -0
- package/lib/Signal/Protocol/session-builder.js +143 -0
- package/lib/Signal/Protocol/session-cipher.d.ts +26 -0
- package/lib/Signal/Protocol/session-cipher.js +301 -0
- package/lib/Signal/Protocol/session-record.d.ts +55 -0
- package/lib/Signal/Protocol/session-record.js +272 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/libsignal.js +426 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +274 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +119 -0
- package/lib/Socket/business.d.ts +387 -0
- package/lib/Socket/business.js +380 -0
- package/lib/Socket/chats.d.ts +144 -0
- package/lib/Socket/chats.js +1216 -0
- package/lib/Socket/communities.d.ts +554 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/groups.d.ts +286 -0
- package/lib/Socket/groups.js +347 -0
- package/lib/Socket/index.d.ts +522 -0
- package/lib/Socket/index.js +11 -0
- package/lib/Socket/messages-recv.d.ts +326 -0
- package/lib/Socket/messages-recv.js +1822 -0
- package/lib/Socket/messages-send.d.ts +321 -0
- package/lib/Socket/messages-send.js +1378 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +283 -0
- package/lib/Socket/newsletter.js +225 -0
- package/lib/Socket/socket.d.ts +61 -0
- package/lib/Socket/socket.js +992 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +418 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Business.d.ts +1 -0
- package/lib/Types/Business.js +1 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +1 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/State.js +54 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +13 -0
- package/lib/Types/index.js +25 -0
- package/lib/Utils/Auth/auth-utils.d.ts +58 -0
- package/lib/Utils/Auth/auth-utils.js +316 -0
- package/lib/Utils/Auth/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/Auth/companion-reg-client-utils.js +39 -0
- package/lib/Utils/Auth/pre-key-manager.d.ts +25 -0
- package/lib/Utils/Auth/pre-key-manager.js +105 -0
- package/lib/Utils/Auth/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/Auth/use-multi-file-auth-state.js +116 -0
- package/lib/Utils/Auth/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/Auth/use-single-file-auth-state.js +94 -0
- package/lib/Utils/Auth/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/Auth/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/Auth/validate-connection.d.ts +44 -0
- package/lib/Utils/Auth/validate-connection.js +210 -0
- package/lib/Utils/Common/browser-utils.d.ts +9 -0
- package/lib/Utils/Common/browser-utils.js +28 -0
- package/lib/Utils/Common/generics.d.ts +63 -0
- package/lib/Utils/Common/generics.js +392 -0
- package/lib/Utils/Common/logger.d.ts +12 -0
- package/lib/Utils/Common/logger.js +12 -0
- package/lib/Utils/Common/make-mutex.d.ts +6 -0
- package/lib/Utils/Common/make-mutex.js +32 -0
- package/lib/Utils/Crypto/crypto.d.ts +39 -0
- package/lib/Utils/Crypto/crypto.js +117 -0
- package/lib/Utils/Crypto/lt-hash.d.ts +6 -0
- package/lib/Utils/Crypto/lt-hash.js +7 -0
- package/lib/Utils/Crypto/noise-handler.d.ts +20 -0
- package/lib/Utils/Crypto/noise-handler.js +200 -0
- package/lib/Utils/Crypto/signal.d.ts +82 -0
- package/lib/Utils/Crypto/signal.js +200 -0
- package/lib/Utils/Message/business.d.ts +49 -0
- package/lib/Utils/Message/business.js +230 -0
- package/lib/Utils/Message/decode-wa-message.d.ts +83 -0
- package/lib/Utils/Message/decode-wa-message.js +316 -0
- package/lib/Utils/Message/history.d.ts +75 -0
- package/lib/Utils/Message/history.js +133 -0
- package/lib/Utils/Message/link-preview.d.ts +13 -0
- package/lib/Utils/Message/link-preview.js +73 -0
- package/lib/Utils/Message/message-retry-manager.d.ts +79 -0
- package/lib/Utils/Message/message-retry-manager.js +259 -0
- package/lib/Utils/Message/messages-media.d.ts +134 -0
- package/lib/Utils/Message/messages-media.js +802 -0
- package/lib/Utils/Message/messages.d.ts +47 -0
- package/lib/Utils/Message/messages.js +1907 -0
- package/lib/Utils/Message/offline-node-processor.d.ts +10 -0
- package/lib/Utils/Message/offline-node-processor.js +40 -0
- package/lib/Utils/Message/process-message.d.ts +83 -0
- package/lib/Utils/Message/process-message.js +748 -0
- package/lib/Utils/Message/reporting-utils.d.ts +12 -0
- package/lib/Utils/Message/reporting-utils.js +257 -0
- package/lib/Utils/Message/rich-message-utils.d.ts +48 -0
- package/lib/Utils/Message/rich-message-utils.js +366 -0
- package/lib/Utils/Message/stanza-ack.d.ts +16 -0
- package/lib/Utils/Message/stanza-ack.js +37 -0
- package/lib/Utils/State/chat-utils.d.ts +408 -0
- package/lib/Utils/State/chat-utils.js +871 -0
- package/lib/Utils/State/event-buffer.d.ts +12 -0
- package/lib/Utils/State/event-buffer.js +621 -0
- package/lib/Utils/State/identity-change-handler.d.ts +13 -0
- package/lib/Utils/State/identity-change-handler.js +48 -0
- package/lib/Utils/State/sync-action-utils.d.ts +2 -0
- package/lib/Utils/State/sync-action-utils.js +48 -0
- package/lib/Utils/State/tc-token-utils.d.ts +29 -0
- package/lib/Utils/State/tc-token-utils.js +163 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +24 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +79 -0
- package/lib/WABinary/generic-utils.js +226 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.js +5 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +97 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/package.json +120 -5
- package/scripts/engine-requirements.js +16 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a processor for offline stanza nodes that:
|
|
3
|
+
* - Queues nodes for sequential processing
|
|
4
|
+
* - Yields to the event loop periodically to avoid blocking
|
|
5
|
+
* - Catches handler errors to prevent the processing loop from crashing
|
|
6
|
+
*/
|
|
7
|
+
export function makeOfflineNodeProcessor(nodeProcessorMap: any, deps: any, batchSize?: number): {
|
|
8
|
+
enqueue: (type: any, node: any) => void;
|
|
9
|
+
};
|
|
10
|
+
export function isOfflineNode(node: any): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const isOfflineNode = (node) => node?.attrs?.offline === '1';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a processor for offline stanza nodes that:
|
|
4
|
+
* - Queues nodes for sequential processing
|
|
5
|
+
* - Yields to the event loop periodically to avoid blocking
|
|
6
|
+
* - Catches handler errors to prevent the processing loop from crashing
|
|
7
|
+
*/
|
|
8
|
+
export function makeOfflineNodeProcessor(nodeProcessorMap, deps, batchSize = 10) {
|
|
9
|
+
const nodes = [];
|
|
10
|
+
let isProcessing = false;
|
|
11
|
+
const enqueue = (type, node) => {
|
|
12
|
+
nodes.push({ type, node });
|
|
13
|
+
if (isProcessing) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
isProcessing = true;
|
|
17
|
+
const promise = async () => {
|
|
18
|
+
let processedInBatch = 0;
|
|
19
|
+
while (nodes.length && deps.isWsOpen()) {
|
|
20
|
+
const { type, node } = nodes.shift();
|
|
21
|
+
const nodeProcessor = nodeProcessorMap.get(type);
|
|
22
|
+
if (!nodeProcessor) {
|
|
23
|
+
deps.onUnexpectedError(new Error(`unknown offline node type: ${type}`), 'processing offline node');
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
await nodeProcessor(node).catch(err => deps.onUnexpectedError(err, `processing offline ${type}`));
|
|
27
|
+
processedInBatch++;
|
|
28
|
+
// Yield to event loop after processing a batch
|
|
29
|
+
// This prevents blocking the event loop for too long when there are many offline nodes
|
|
30
|
+
if (processedInBatch >= batchSize) {
|
|
31
|
+
processedInBatch = 0;
|
|
32
|
+
await deps.yieldToEventLoop();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
isProcessing = false;
|
|
36
|
+
};
|
|
37
|
+
promise().catch(error => deps.onUnexpectedError(error, 'processing offline nodes'));
|
|
38
|
+
};
|
|
39
|
+
return { enqueue };
|
|
40
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decrypt a poll vote
|
|
3
|
+
* @param vote encrypted vote
|
|
4
|
+
* @param ctx additional info about the poll required for decryption
|
|
5
|
+
* @returns list of SHA256 options
|
|
6
|
+
*/
|
|
7
|
+
export function decryptPollVote({ encPayload, encIv }: {
|
|
8
|
+
encPayload: any;
|
|
9
|
+
encIv: any;
|
|
10
|
+
}, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }: {
|
|
11
|
+
pollCreatorJid: any;
|
|
12
|
+
pollMsgId: any;
|
|
13
|
+
pollEncKey: any;
|
|
14
|
+
voterJid: any;
|
|
15
|
+
}): proto.Message.PollVoteMessage & proto.Message.PollVoteMessage.$Properties;
|
|
16
|
+
/**
|
|
17
|
+
* Decrypt an event response
|
|
18
|
+
* @param response encrypted event response
|
|
19
|
+
* @param ctx additional info about the event required for decryption
|
|
20
|
+
* @returns event response message
|
|
21
|
+
*/
|
|
22
|
+
export function decryptEventResponse({ encPayload, encIv }: {
|
|
23
|
+
encPayload: any;
|
|
24
|
+
encIv: any;
|
|
25
|
+
}, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }: {
|
|
26
|
+
eventCreatorJid: any;
|
|
27
|
+
eventMsgId: any;
|
|
28
|
+
eventEncKey: any;
|
|
29
|
+
responderJid: any;
|
|
30
|
+
}): proto.Message.EventResponseMessage & proto.Message.EventResponseMessage.$Properties;
|
|
31
|
+
/**
|
|
32
|
+
* Decrypt a `secretEncryptedMessage` carrying a `MESSAGE_EDIT` payload.
|
|
33
|
+
*
|
|
34
|
+
* WhatsApp started wrapping message edits in an E2EE envelope (May 2026).
|
|
35
|
+
* The new content is encrypted with a key derived from the original
|
|
36
|
+
* message's `messageContextInfo.messageSecret` using HKDF-SHA256
|
|
37
|
+
* + AES-256-GCM, same family as polls and event responses but with
|
|
38
|
+
* different constants (validated against live WhatsApp Android traffic):
|
|
39
|
+
*
|
|
40
|
+
* info = msgId || origSenderJid || editorJid || "Message Edit"
|
|
41
|
+
* aad = (empty) <-- differs from Poll Vote / Event Response
|
|
42
|
+
* key = HKDF-SHA256(salt=zeros, ikm=messageSecret, info, L=32)
|
|
43
|
+
*
|
|
44
|
+
* The decrypted plaintext is a regular `proto.Message` whose
|
|
45
|
+
* `protocolMessage.editedMessage` field holds the new content — same
|
|
46
|
+
* shape as the legacy `protocolMessage.editedMessage` edit path, so
|
|
47
|
+
* consumers can treat the result identically.
|
|
48
|
+
*
|
|
49
|
+
* @param edit encrypted edit payload (encPayload + encIv from SecretEncryptedMessage)
|
|
50
|
+
* @param ctx info about the original message required for decryption
|
|
51
|
+
* @returns decoded outer `Message` whose `protocolMessage.editedMessage`
|
|
52
|
+
* carries the new content (extendedTextMessage / conversation / etc.)
|
|
53
|
+
*/
|
|
54
|
+
export function decryptMessageEdit({ encPayload, encIv }: {
|
|
55
|
+
encPayload: any;
|
|
56
|
+
encIv: any;
|
|
57
|
+
}, { originalSenderJid, originalMsgId, editEncKey, editorJid }: {
|
|
58
|
+
originalSenderJid: any;
|
|
59
|
+
originalMsgId: any;
|
|
60
|
+
editEncKey: any;
|
|
61
|
+
editorJid: any;
|
|
62
|
+
}): proto.Message & proto.Message.$Shape;
|
|
63
|
+
export function cleanMessage(message: any, meId: any, meLid: any): void;
|
|
64
|
+
export function isRealMessage(message: any): boolean;
|
|
65
|
+
export function shouldIncrementChatUnread(message: any): boolean;
|
|
66
|
+
export function getChatId({ remoteJid, participant, fromMe }: {
|
|
67
|
+
remoteJid: any;
|
|
68
|
+
participant: any;
|
|
69
|
+
fromMe: any;
|
|
70
|
+
}): any;
|
|
71
|
+
export default processMessage;
|
|
72
|
+
import { proto } from '../../../WAProto/index.js';
|
|
73
|
+
declare function processMessage(message: any, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }: {
|
|
74
|
+
shouldProcessHistoryMsg: any;
|
|
75
|
+
placeholderResendCache: any;
|
|
76
|
+
ev: any;
|
|
77
|
+
creds: any;
|
|
78
|
+
signalRepository: any;
|
|
79
|
+
keyStore: any;
|
|
80
|
+
logger: any;
|
|
81
|
+
options: any;
|
|
82
|
+
getMessage: any;
|
|
83
|
+
}): Promise<void>;
|