@vanzxy/baileys 1.3.7 → 1.3.9
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.
Potentially problematic release.
This version of @vanzxy/baileys might be problematic. Click here for more details.
- package/NOTICE.md +41 -0
- package/README.md +1 -1
- package/WAProto/index.d.ts +9 -0
- package/lib/Defaults/index.d.ts +147 -0
- package/lib/Defaults/index.js +2 -2
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/chats.d.ts +136 -0
- package/lib/Socket/communities.d.ts +561 -0
- package/lib/Socket/communities.js +4 -2
- package/lib/Socket/dugong.d.ts +117 -0
- package/lib/Socket/dugong.js +26 -1
- package/lib/Socket/groups.d.ts +285 -0
- package/lib/Socket/index.d.ts +531 -0
- package/lib/Socket/messages-recv.d.ts +333 -0
- package/lib/Socket/messages-send.d.ts +329 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/newsletter.d.ts +281 -0
- package/lib/Socket/newsletter.js +19 -19
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Socket.d.ts +136 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/MessageBuilder.js +2297 -0
- package/lib/Utils/auth-utils.d.ts +57 -0
- package/lib/Utils/browser-utils.d.ts +8 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +2 -1
- package/lib/Utils/chat-utils.d.ts +407 -0
- package/lib/Utils/chat-utils.js +15 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +1 -3
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/generics.d.ts +63 -0
- package/lib/Utils/generics.js +2 -4
- package/lib/Utils/history.d.ts +90 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +21 -2
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/messages-media.d.ts +135 -0
- package/lib/Utils/messages.d.ts +44 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/process-message.d.ts +82 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +32 -7
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +6 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +12 -0
- package/lib/Utils/validate-connection.d.ts +42 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts +74 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/index.d.ts +7 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.d.ts +12 -0
- package/package.json +17 -7
- package/postinstall-banner.js +23 -0
- package/LICENSE +0 -23
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}): any;
|
|
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
|
+
}): any;
|
|
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
|
+
}): any;
|
|
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
|
+
declare function processMessage(message: any, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }: {
|
|
73
|
+
shouldProcessHistoryMsg: any;
|
|
74
|
+
placeholderResendCache: any;
|
|
75
|
+
ev: any;
|
|
76
|
+
creds: any;
|
|
77
|
+
signalRepository: any;
|
|
78
|
+
keyStore: any;
|
|
79
|
+
logger: any;
|
|
80
|
+
options: any;
|
|
81
|
+
getMessage: any;
|
|
82
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function shouldIncludeReportingToken(message: any): boolean;
|
|
2
|
+
export function getMessageReportingToken(msgProtobuf: any, message: any, key: any): Promise<{
|
|
3
|
+
tag: string;
|
|
4
|
+
attrs: {};
|
|
5
|
+
content: {
|
|
6
|
+
tag: string;
|
|
7
|
+
attrs: {
|
|
8
|
+
v: string;
|
|
9
|
+
};
|
|
10
|
+
content: any;
|
|
11
|
+
}[];
|
|
12
|
+
} | null>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function tokenizeCode(code: any, language?: string): {
|
|
2
|
+
highlightType: any;
|
|
3
|
+
codeContent: string;
|
|
4
|
+
}[];
|
|
5
|
+
export function toUnified(submessages: any, uuid: any): {
|
|
6
|
+
response_id: any;
|
|
7
|
+
sections: any;
|
|
8
|
+
};
|
|
9
|
+
export function prepareRichResponseMessage(content: any): {
|
|
10
|
+
messageContextInfo: {
|
|
11
|
+
botMetadata: {
|
|
12
|
+
verificationMetadata: {
|
|
13
|
+
proofs: {
|
|
14
|
+
certificateChain: Uint8Array<ArrayBuffer>[];
|
|
15
|
+
version: number;
|
|
16
|
+
useCase: number;
|
|
17
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
botForwardedMessage: {
|
|
23
|
+
message: {
|
|
24
|
+
richResponseMessage: any;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export function botMetadataSignature(): Uint8Array<ArrayBuffer>;
|
|
29
|
+
export function botMetadataCertificate(length?: number): Uint8Array<ArrayBuffer>;
|
|
30
|
+
export function wrapToBotForwardedMessage(richResponseMessage: any): {
|
|
31
|
+
messageContextInfo: {
|
|
32
|
+
botMetadata: {
|
|
33
|
+
verificationMetadata: {
|
|
34
|
+
proofs: {
|
|
35
|
+
certificateChain: Uint8Array<ArrayBuffer>[];
|
|
36
|
+
version: number;
|
|
37
|
+
useCase: number;
|
|
38
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
botForwardedMessage: {
|
|
44
|
+
message: {
|
|
45
|
+
richResponseMessage: any;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -11,6 +11,23 @@ import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
|
|
|
11
11
|
import { proto } from '../../WAProto/index.js';
|
|
12
12
|
import { unixTimestampSeconds } from './generics.js';
|
|
13
13
|
const NOOP = new Set([]);
|
|
14
|
+
// Vanz@Fix (bug 40 / inline image): AIRichResponseInlineImageMetadata.imageUrl is a nested
|
|
15
|
+
// AIRichResponseImageURL message (imagePreviewUrl/imageHighResUrl/sourceUrl), NOT a plain string.
|
|
16
|
+
// Passing a raw string made protobufjs silently encode an empty embedded message (no throw),
|
|
17
|
+
// so the image URL data was dropped on the wire and the image never rendered.
|
|
18
|
+
const toImageUrlObject = (url) => {
|
|
19
|
+
if (!url)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (typeof url === 'object')
|
|
22
|
+
return { imagePreviewUrl: url.imagePreviewUrl || url.url, imageHighResUrl: url.imageHighResUrl || url.url, sourceUrl: url.sourceUrl || url.url };
|
|
23
|
+
return { imagePreviewUrl: url, imageHighResUrl: url, sourceUrl: url };
|
|
24
|
+
};
|
|
25
|
+
const IMAGE_ALIGNMENT = { leading: 0, trailing: 1, center: 2 };
|
|
26
|
+
const toImageAlignment = (alignment) => {
|
|
27
|
+
if (typeof alignment === 'number')
|
|
28
|
+
return alignment;
|
|
29
|
+
return IMAGE_ALIGNMENT[String(alignment || 'center').toLowerCase()] ?? IMAGE_ALIGNMENT.center;
|
|
30
|
+
};
|
|
14
31
|
export const tokenizeCode = (code, language = 'javascript') => {
|
|
15
32
|
const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
|
|
16
33
|
const blocks = [];
|
|
@@ -75,14 +92,22 @@ export const toUnified = (submessages, uuid) => ({
|
|
|
75
92
|
}
|
|
76
93
|
};
|
|
77
94
|
case RichSubMessageType.INLINE_IMAGE:
|
|
78
|
-
// Vanz@Fix (bug 40):
|
|
95
|
+
// Vanz@Fix (bug 40, round 2): imageUrl is now a real AIRichResponseImageURL
|
|
96
|
+
// object (imagePreviewUrl/imageHighResUrl/sourceUrl) instead of a bare string
|
|
97
|
+
// that protobufjs silently dropped on encode. alignment is mapped back to its
|
|
98
|
+
// enum name (matches how the compiled proto's toObject() renders other enums).
|
|
79
99
|
const imgMeta = submessage.imageMetadata;
|
|
100
|
+
const ALIGNMENT_NAME = ['AI_RICH_RESPONSE_IMAGE_LAYOUT_LEADING_ALIGNED', 'AI_RICH_RESPONSE_IMAGE_LAYOUT_TRAILING_ALIGNED', 'AI_RICH_RESPONSE_IMAGE_LAYOUT_CENTER_ALIGNED'];
|
|
80
101
|
return {
|
|
81
102
|
view_model: {
|
|
82
103
|
primitive: {
|
|
83
|
-
image_url:
|
|
104
|
+
image_url: {
|
|
105
|
+
image_preview_url: imgMeta?.imageUrl?.imagePreviewUrl || '',
|
|
106
|
+
image_high_res_url: imgMeta?.imageUrl?.imageHighResUrl || '',
|
|
107
|
+
source_url: imgMeta?.imageUrl?.sourceUrl || ''
|
|
108
|
+
},
|
|
84
109
|
image_text: imgMeta?.imageText || '',
|
|
85
|
-
alignment: imgMeta?.alignment
|
|
110
|
+
alignment: ALIGNMENT_NAME[imgMeta?.alignment ?? 2],
|
|
86
111
|
tap_link_url: imgMeta?.tapLinkUrl || '',
|
|
87
112
|
__typename: 'GenAIInlineImageUXPrimitive'
|
|
88
113
|
},
|
|
@@ -167,9 +192,9 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
167
192
|
return {
|
|
168
193
|
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
169
194
|
imageMetadata: {
|
|
170
|
-
imageUrl: submessage.inlineImage,
|
|
195
|
+
imageUrl: toImageUrlObject(submessage.inlineImage),
|
|
171
196
|
imageText: submessage.imageText,
|
|
172
|
-
alignment: submessage.alignment,
|
|
197
|
+
alignment: toImageAlignment(submessage.alignment),
|
|
173
198
|
tapLinkUrl: submessage.tapLinkUrl
|
|
174
199
|
}
|
|
175
200
|
};
|
|
@@ -255,9 +280,9 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
255
280
|
submessages.push({
|
|
256
281
|
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
257
282
|
imageMetadata: {
|
|
258
|
-
imageUrl: inlineImage,
|
|
283
|
+
imageUrl: toImageUrlObject(inlineImage),
|
|
259
284
|
imageText,
|
|
260
|
-
alignment,
|
|
285
|
+
alignment: toImageAlignment(alignment),
|
|
261
286
|
tapLinkUrl
|
|
262
287
|
}
|
|
263
288
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export function createSignalIdentity(wid: any, accountSignatureKey: any): {
|
|
2
|
+
identifier: {
|
|
3
|
+
name: any;
|
|
4
|
+
deviceId: number;
|
|
5
|
+
};
|
|
6
|
+
identifierKey: any;
|
|
7
|
+
};
|
|
8
|
+
export function getPreKeys({ get }: {
|
|
9
|
+
get: any;
|
|
10
|
+
}, min: any, limit: any): Promise<any>;
|
|
11
|
+
export function generateOrGetPreKeys(creds: any, range: any): {
|
|
12
|
+
newPreKeys: {};
|
|
13
|
+
lastPreKeyId: number;
|
|
14
|
+
preKeysRange: any[];
|
|
15
|
+
};
|
|
16
|
+
export function xmppSignedPreKey(key: any): {
|
|
17
|
+
tag: string;
|
|
18
|
+
attrs: {};
|
|
19
|
+
content: {
|
|
20
|
+
tag: string;
|
|
21
|
+
attrs: {};
|
|
22
|
+
content: any;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export function xmppPreKey(pair: any, id: any): {
|
|
26
|
+
tag: string;
|
|
27
|
+
attrs: {};
|
|
28
|
+
content: {
|
|
29
|
+
tag: string;
|
|
30
|
+
attrs: {};
|
|
31
|
+
content: any;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
export function extractE2ESessionFromRetryReceipt(receipt: any): {
|
|
35
|
+
registrationId: number | undefined;
|
|
36
|
+
identityKey: any;
|
|
37
|
+
signedPreKey: {
|
|
38
|
+
keyId: number | undefined;
|
|
39
|
+
publicKey: any;
|
|
40
|
+
signature: any;
|
|
41
|
+
};
|
|
42
|
+
preKey: {
|
|
43
|
+
keyId: number | undefined;
|
|
44
|
+
publicKey: any;
|
|
45
|
+
} | undefined;
|
|
46
|
+
} | null;
|
|
47
|
+
export function parseAndInjectE2ESessions(node: any, repository: any): Promise<void>;
|
|
48
|
+
export function extractDeviceJids(result: any, myJid: any, myLid: any, excludeZeroDevices: any): {
|
|
49
|
+
user: any;
|
|
50
|
+
device: any;
|
|
51
|
+
domainType: any;
|
|
52
|
+
server: any;
|
|
53
|
+
}[];
|
|
54
|
+
export function getNextPreKeys({ creds, keys }: {
|
|
55
|
+
creds: any;
|
|
56
|
+
keys: any;
|
|
57
|
+
}, count: any): Promise<{
|
|
58
|
+
update: {
|
|
59
|
+
nextPreKeyId: number;
|
|
60
|
+
firstUnuploadedPreKeyId: number;
|
|
61
|
+
};
|
|
62
|
+
preKeys: any;
|
|
63
|
+
}>;
|
|
64
|
+
export function getNextPreKeysNode(state: any, count: any): Promise<{
|
|
65
|
+
update: {
|
|
66
|
+
nextPreKeyId: number;
|
|
67
|
+
firstUnuploadedPreKeyId: number;
|
|
68
|
+
};
|
|
69
|
+
node: {
|
|
70
|
+
tag: string;
|
|
71
|
+
attrs: {
|
|
72
|
+
xmlns: string;
|
|
73
|
+
type: string;
|
|
74
|
+
to: string;
|
|
75
|
+
};
|
|
76
|
+
content: {
|
|
77
|
+
tag: string;
|
|
78
|
+
attrs: {};
|
|
79
|
+
content: any;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an ACK stanza for a received node.
|
|
3
|
+
* Pure function -- no I/O, no side effects.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors WhatsApp Web's ACK construction:
|
|
6
|
+
* - WAWebHandleMsgSendAck.sendAck / sendNack
|
|
7
|
+
* - WAWebCreateNackFromStanza.createNackFromStanza
|
|
8
|
+
*/
|
|
9
|
+
export function buildAckStanza(node: any, errorCode: any, meId: any): {
|
|
10
|
+
tag: string;
|
|
11
|
+
attrs: {
|
|
12
|
+
id: any;
|
|
13
|
+
to: any;
|
|
14
|
+
class: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Read the persisted tctoken JID index and return its entries (never contains the sentinel key itself). */
|
|
2
|
+
export function readTcTokenIndex(keys: any): Promise<any[]>;
|
|
3
|
+
/** Build a SignalDataSet fragment that writes the merged index (persisted ∪ added) under the sentinel key. */
|
|
4
|
+
export function buildMergedTcTokenIndexWrite(keys: any, addedJids: any): Promise<{
|
|
5
|
+
__index: {
|
|
6
|
+
token: any;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
9
|
+
export function isTcTokenExpired(timestamp: any): boolean;
|
|
10
|
+
export function shouldSendNewTcToken(senderTimestamp: any): boolean;
|
|
11
|
+
/** Resolve JID to LID for tctoken storage (WA Web stores under LID) */
|
|
12
|
+
export function resolveTcTokenJid(jid: any, getLIDForPN: any): Promise<any>;
|
|
13
|
+
/** Resolve target JID for issuing privacy token based on AB prop 14303 */
|
|
14
|
+
export function resolveIssuanceJid(jid: any, issueToLid: any, getLIDForPN: any, getPNForLID: any): Promise<any>;
|
|
15
|
+
export function buildTcTokenFromJid({ authState, jid, baseContent, getLIDForPN }: {
|
|
16
|
+
authState: any;
|
|
17
|
+
jid: any;
|
|
18
|
+
baseContent?: never[] | undefined;
|
|
19
|
+
getLIDForPN: any;
|
|
20
|
+
}): Promise<any[] | undefined>;
|
|
21
|
+
export function storeTcTokensFromIqResult({ result, fallbackJid, keys, getLIDForPN, onNewJidStored }: {
|
|
22
|
+
result: any;
|
|
23
|
+
fallbackJid: any;
|
|
24
|
+
keys: any;
|
|
25
|
+
getLIDForPN: any;
|
|
26
|
+
onNewJidStored: any;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/** Sentinel key under `tctoken` store holding a JSON array of tracked storage JIDs for cross-session pruning. */
|
|
29
|
+
export const TC_TOKEN_INDEX_KEY: "__index";
|
|
@@ -5,6 +5,7 @@ import { initAuthCreds } from './auth-utils.js';
|
|
|
5
5
|
import { BufferJSON } from './generics.js';
|
|
6
6
|
import { LRUCache } from 'lru-cache';
|
|
7
7
|
import { Mutex } from 'async-mutex';
|
|
8
|
+
import defaultLogger from './logger.js';
|
|
8
9
|
// Lia@Changes 25-03-26 --- Add useSingleFileAuthState with integrated cache
|
|
9
10
|
const FLUSH_TIMEOUT_MS = 3000;
|
|
10
11
|
// Lia@Changes 22-04-26 --- Enhanced useSingleFileAuthState with LRUCache
|
|
@@ -49,7 +50,11 @@ export const useSingleFileAuthState = async (fileName) => {
|
|
|
49
50
|
await writeFile(tempFile, JSON.stringify(fileData, BufferJSON.replacer));
|
|
50
51
|
await rename(tempFile, fileName);
|
|
51
52
|
}
|
|
52
|
-
catch {
|
|
53
|
+
catch (err) {
|
|
54
|
+
// Vanz@Fix (bug 58): was silently swallowed — auth session could fail
|
|
55
|
+
// to persist (disk full, permission error, etc.) with zero trace.
|
|
56
|
+
defaultLogger.error({ err, fileName }, 'failed to flush auth state to disk');
|
|
57
|
+
}
|
|
53
58
|
});
|
|
54
59
|
}, FLUSH_TIMEOUT_MS);
|
|
55
60
|
};
|
|
@@ -125,6 +125,18 @@ export async function useSqliteAuthState(opts) {
|
|
|
125
125
|
},
|
|
126
126
|
saveCreds: async () => {
|
|
127
127
|
persistCreds(creds);
|
|
128
|
+
},
|
|
129
|
+
// Vanz@Fix: release the WAL cleanup interval and (if we opened it ourselves)
|
|
130
|
+
// the underlying db handle. Without this, every useSqliteAuthState() call
|
|
131
|
+
// (e.g. re-pairing / rotating sessions) leaked a timer + open sqlite fd forever.
|
|
132
|
+
close: async () => {
|
|
133
|
+
clearInterval(_walCleanupInterval);
|
|
134
|
+
if (!opts.database) {
|
|
135
|
+
try {
|
|
136
|
+
db.close();
|
|
137
|
+
}
|
|
138
|
+
catch { /* already closed */ }
|
|
139
|
+
}
|
|
128
140
|
}
|
|
129
141
|
};
|
|
130
142
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function generateLoginNode(userJid: any, config: any): any;
|
|
2
|
+
export function generateRegistrationNode({ registrationId, signedPreKey, signedIdentityKey }: {
|
|
3
|
+
registrationId: any;
|
|
4
|
+
signedPreKey: any;
|
|
5
|
+
signedIdentityKey: any;
|
|
6
|
+
}, config: any): any;
|
|
7
|
+
export function configureSuccessfulPairing(stanza: any, { advSecretKey, signedIdentityKey, signalIdentities }: {
|
|
8
|
+
advSecretKey: any;
|
|
9
|
+
signedIdentityKey: any;
|
|
10
|
+
signalIdentities: any;
|
|
11
|
+
}): {
|
|
12
|
+
creds: {
|
|
13
|
+
account: any;
|
|
14
|
+
me: {
|
|
15
|
+
id: any;
|
|
16
|
+
name: any;
|
|
17
|
+
lid: any;
|
|
18
|
+
};
|
|
19
|
+
signalIdentities: any[];
|
|
20
|
+
platform: any;
|
|
21
|
+
};
|
|
22
|
+
reply: {
|
|
23
|
+
tag: string;
|
|
24
|
+
attrs: {
|
|
25
|
+
to: string;
|
|
26
|
+
type: string;
|
|
27
|
+
id: any;
|
|
28
|
+
};
|
|
29
|
+
content: {
|
|
30
|
+
tag: string;
|
|
31
|
+
attrs: {};
|
|
32
|
+
content: {
|
|
33
|
+
tag: string;
|
|
34
|
+
attrs: {
|
|
35
|
+
'key-index': any;
|
|
36
|
+
};
|
|
37
|
+
content: any;
|
|
38
|
+
}[];
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export function encodeSignedDeviceIdentity(account: any, includeSignatureKey: any): any;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export namespace TAGS {
|
|
2
|
+
let LIST_EMPTY: number;
|
|
3
|
+
let DICTIONARY_0: number;
|
|
4
|
+
let DICTIONARY_1: number;
|
|
5
|
+
let DICTIONARY_2: number;
|
|
6
|
+
let DICTIONARY_3: number;
|
|
7
|
+
let INTEROP_JID: number;
|
|
8
|
+
let FB_JID: number;
|
|
9
|
+
let AD_JID: number;
|
|
10
|
+
let LIST_8: number;
|
|
11
|
+
let LIST_16: number;
|
|
12
|
+
let JID_PAIR: number;
|
|
13
|
+
let HEX_8: number;
|
|
14
|
+
let BINARY_8: number;
|
|
15
|
+
let BINARY_20: number;
|
|
16
|
+
let BINARY_32: number;
|
|
17
|
+
let NIBBLE_8: number;
|
|
18
|
+
let PACKED_MAX: number;
|
|
19
|
+
}
|
|
20
|
+
export const DOUBLE_BYTE_TOKENS: string[][];
|
|
21
|
+
export const SINGLE_BYTE_TOKENS: string[];
|
|
22
|
+
export const TOKEN_MAP: {};
|
|
23
|
+
export const CPP_KEYWORDS: Set<string>;
|
|
24
|
+
export const CSS_KEYWORDS: Set<string>;
|
|
25
|
+
export const GO_KEYWORDS: Set<string>;
|
|
26
|
+
export const HTML_KEYWORDS: Set<string>;
|
|
27
|
+
export const JS_KEYWORDS: Set<string>;
|
|
28
|
+
export const PYTHON_KEYWORDS: Set<string>;
|
|
29
|
+
export const RUST_KEYWORDS: Set<string>;
|
|
30
|
+
export const C_KEYWORDS: Set<string>;
|
|
31
|
+
export const CSHARP_KEYWORDS: Set<string>;
|
|
32
|
+
export const BASH_KEYWORDS: Set<string>;
|
|
33
|
+
export const CMD_KEYWORDS: Set<string>;
|
|
34
|
+
export const POWERSHELL_KEYWORDS: Set<string>;
|
|
35
|
+
export const LANGUAGE_KEYWORDS: {
|
|
36
|
+
css: Set<string>;
|
|
37
|
+
html: Set<string>;
|
|
38
|
+
javascript: Set<string>;
|
|
39
|
+
typescript: Set<string>;
|
|
40
|
+
js: Set<string>;
|
|
41
|
+
ts: Set<string>;
|
|
42
|
+
python: Set<string>;
|
|
43
|
+
py: Set<string>;
|
|
44
|
+
go: Set<string>;
|
|
45
|
+
golang: Set<string>;
|
|
46
|
+
cpp: Set<string>;
|
|
47
|
+
'c++': Set<string>;
|
|
48
|
+
rust: Set<string>;
|
|
49
|
+
rs: Set<string>;
|
|
50
|
+
c: Set<string>;
|
|
51
|
+
h: Set<string>;
|
|
52
|
+
csharp: Set<string>;
|
|
53
|
+
cs: Set<string>;
|
|
54
|
+
bash: Set<string>;
|
|
55
|
+
sh: Set<string>;
|
|
56
|
+
zsh: Set<string>;
|
|
57
|
+
cmd: Set<string>;
|
|
58
|
+
bat: Set<string>;
|
|
59
|
+
powershell: Set<string>;
|
|
60
|
+
ps1: Set<string>;
|
|
61
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function decompressingIfRequired(buffer: any): Promise<any>;
|
|
2
|
+
export function decodeDecompressedBinaryNode(buffer: any, opts: any, indexRef?: {
|
|
3
|
+
index: number;
|
|
4
|
+
}): {
|
|
5
|
+
tag: any;
|
|
6
|
+
attrs: {};
|
|
7
|
+
content: any;
|
|
8
|
+
};
|
|
9
|
+
export function decodeBinaryNode(buff: any): Promise<any>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function binaryNodeToString(node: any, i?: number): any;
|
|
2
|
+
export function getBinaryNodeChildren(node: any, childTag: any): any;
|
|
3
|
+
export function getBinaryNodeChild(node: any, childTag: any): any;
|
|
4
|
+
export function getAllBinaryNodeChildren({ content }: {
|
|
5
|
+
content: any;
|
|
6
|
+
}): any[];
|
|
7
|
+
export function getBinaryNodeChildBuffer(node: any, childTag: any): any;
|
|
8
|
+
export function getBinaryNodeChildString(node: any, childTag: any): any;
|
|
9
|
+
export function getBinaryNodeChildUInt(node: any, childTag: any, length: any): number | undefined;
|
|
10
|
+
export function assertNodeErrorFree(node: any): void;
|
|
11
|
+
export function reduceBinaryNodeToDictionary(node: any, tag: any): any;
|
|
12
|
+
export function getBinaryNodeMessages({ content }: {
|
|
13
|
+
content: any;
|
|
14
|
+
}): any[];
|
|
15
|
+
export function getBizBinaryNode(message: any): {
|
|
16
|
+
tag: string;
|
|
17
|
+
attrs: {
|
|
18
|
+
actual_actors: string;
|
|
19
|
+
host_storage: string;
|
|
20
|
+
privacy_mode_ts: string;
|
|
21
|
+
};
|
|
22
|
+
content: ({
|
|
23
|
+
tag: string;
|
|
24
|
+
attrs: {
|
|
25
|
+
decision_id: any;
|
|
26
|
+
source_type: string;
|
|
27
|
+
};
|
|
28
|
+
content: {
|
|
29
|
+
tag: string;
|
|
30
|
+
attrs: {
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
}[];
|
|
34
|
+
} | {
|
|
35
|
+
tag: string;
|
|
36
|
+
attrs: {
|
|
37
|
+
type: string;
|
|
38
|
+
v: string;
|
|
39
|
+
};
|
|
40
|
+
content: {
|
|
41
|
+
tag: string;
|
|
42
|
+
attrs: {
|
|
43
|
+
v: string;
|
|
44
|
+
name: any;
|
|
45
|
+
};
|
|
46
|
+
}[];
|
|
47
|
+
})[];
|
|
48
|
+
} | {
|
|
49
|
+
tag: string;
|
|
50
|
+
attrs: {
|
|
51
|
+
actual_actors: string;
|
|
52
|
+
host_storage: string;
|
|
53
|
+
privacy_mode_ts: string;
|
|
54
|
+
};
|
|
55
|
+
content: ({
|
|
56
|
+
tag: string;
|
|
57
|
+
attrs: {
|
|
58
|
+
decision_id: any;
|
|
59
|
+
source_type: string;
|
|
60
|
+
};
|
|
61
|
+
content: {
|
|
62
|
+
tag: string;
|
|
63
|
+
attrs: {
|
|
64
|
+
value: string;
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|
67
|
+
} | {
|
|
68
|
+
tag: string;
|
|
69
|
+
attrs: {
|
|
70
|
+
v: string;
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
})[];
|
|
74
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const S_WHATSAPP_NET: "@s.whatsapp.net";
|
|
2
|
+
export const OFFICIAL_BIZ_JID: "16505361212@c.us";
|
|
3
|
+
export const SERVER_JID: "server@c.us";
|
|
4
|
+
export const PSA_WID: "0@c.us";
|
|
5
|
+
export const STORIES_JID: "status@broadcast";
|
|
6
|
+
export const META_AI_JID: "13135550002@c.us";
|
|
7
|
+
export const WAJIDDomains: any;
|
|
8
|
+
export function getServerFromDomainType(initialServer: any, domainType: any): any;
|
|
9
|
+
export function jidEncode(user: any, server: any, device: any, agent: any): string;
|
|
10
|
+
export function jidDecode(jid: any): {
|
|
11
|
+
server: any;
|
|
12
|
+
user: any;
|
|
13
|
+
domainType: any;
|
|
14
|
+
device: number | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
export function areJidsSameUser(jid1: any, jid2: any): boolean;
|
|
17
|
+
export function isJidMetaAI(jid: any): any;
|
|
18
|
+
export function isPnUser(jid: any): any;
|
|
19
|
+
export function isLidUser(jid: any): any;
|
|
20
|
+
export function isJidBroadcast(jid: any): any;
|
|
21
|
+
export function isJidGroup(jid: any): any;
|
|
22
|
+
export function isJidStatusBroadcast(jid: any): boolean;
|
|
23
|
+
export function isJidNewsletter(jid: any): any;
|
|
24
|
+
export function isHostedPnUser(jid: any): any;
|
|
25
|
+
export function isHostedLidUser(jid: any): any;
|
|
26
|
+
export function isJidBot(jid: any): any;
|
|
27
|
+
export function jidNormalizedUser(jid: any): string;
|
|
28
|
+
export function transferDevice(fromJid: any, toJid: any): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as constants from './constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* the binary node WA uses internally for communication
|
|
4
|
+
*
|
|
5
|
+
* this is manipulated soley as an object and it does not have any functions.
|
|
6
|
+
* This is done for easy serialization, to prevent running into issues with prototypes &
|
|
7
|
+
* to maintain functional code structure
|
|
8
|
+
* */
|
|
9
|
+
export type BinaryNode = {
|
|
10
|
+
tag: string;
|
|
11
|
+
attrs: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
content?: BinaryNode[] | string | Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
export type BinaryNodeAttributes = BinaryNode['attrs'];
|
|
17
|
+
export type BinaryNodeData = BinaryNode['content'];
|
|
18
|
+
export type BinaryNodeCodingOptions = typeof constants;
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|