@violetix/baileys 0.5.5 → 0.6.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/README.md +1530 -2009
- package/WAProto/index.d.ts +14030 -14586
- package/WAProto/index.js +58426 -88874
- package/lib/Defaults/index.d.ts +2 -7
- package/lib/Defaults/index.js +5 -20
- package/lib/Signal/Group/sender-key-message.js +19 -1
- package/lib/Signal/libsignal.js +82 -29
- package/lib/Signal/xeddsa-fast.js +114 -0
- package/lib/Socket/Client/types.js +6 -8
- package/lib/Socket/Client/websocket.js +3 -38
- package/lib/Socket/business.d.ts +0 -3
- package/lib/Socket/chats.d.ts +0 -3
- package/lib/Socket/chats.js +18 -45
- package/lib/Socket/communities.d.ts +0 -3
- package/lib/Socket/graphql.js +3 -7
- package/lib/Socket/groups.d.ts +0 -3
- package/lib/Socket/groups.js +3 -8
- package/lib/Socket/index.d.ts +15 -17
- package/lib/Socket/messages-recv.d.ts +0 -3
- package/lib/Socket/messages-recv.js +43 -127
- package/lib/Socket/messages-send.d.ts +0 -4
- package/lib/Socket/messages-send.js +63 -191
- package/lib/Socket/newsletter.d.ts +0 -3
- package/lib/Socket/newsletter.js +1 -2
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +0 -9
- package/lib/Socket/socket.js +53 -341
- package/lib/Store/make-in-memory-store.js +30 -41
- package/lib/Types/Auth.d.ts +2 -60
- package/lib/Types/Bussines.d.ts +2 -9
- package/lib/Types/Call.d.ts +2 -22
- package/lib/Types/Chat.d.ts +1 -2
- package/lib/Types/Contact.d.ts +2 -11
- package/lib/Types/Events.d.ts +2 -41
- package/lib/Types/GroupMetadata.d.ts +2 -36
- package/lib/Types/Message.d.ts +1 -11
- package/lib/Types/Product.d.ts +2 -5
- package/lib/Types/Signal.d.ts +2 -10
- package/lib/Types/Socket.d.ts +2 -33
- package/lib/Types/USync.d.ts +2 -9
- package/lib/Types/index.d.ts +1 -3
- package/lib/Utils/auth-utils.d.ts +2 -3
- package/lib/Utils/auth-utils.js +53 -37
- package/lib/Utils/business.js +11 -25
- package/lib/Utils/chat-utils.js +4 -6
- package/lib/Utils/decode-wa-message.js +2 -2
- package/lib/Utils/event-buffer.js +12 -21
- package/lib/Utils/generics.d.ts +5 -5
- package/lib/Utils/generics.js +7 -25
- package/lib/Utils/history.d.ts +1 -2
- package/lib/Utils/history.js +83 -137
- package/lib/Utils/index.d.ts +0 -4
- package/lib/Utils/index.js +0 -4
- package/lib/Utils/listener-guard.js +0 -2
- package/lib/Utils/message-retry-manager.js +0 -20
- package/lib/Utils/messages-media.d.ts +8 -39
- package/lib/Utils/messages-media.js +89 -218
- package/lib/Utils/messages.d.ts +0 -1
- package/lib/Utils/messages.js +36 -122
- package/lib/Utils/process-message.d.ts +0 -18
- package/lib/Utils/process-message.js +47 -99
- package/lib/Utils/rich-message-utils.js +4 -3
- package/lib/Utils/use-multi-file-auth-state.d.ts +3 -5
- package/lib/Utils/use-multi-file-auth-state.js +6 -27
- package/lib/Utils/use-single-file-auth-state.d.ts +1 -1
- package/lib/Utils/use-single-file-auth-state.js +3 -12
- package/lib/WABinary/types.d.ts +2 -6
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +3 -6
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -3
- package/lib/WAUSync/USyncQuery.d.ts +1 -1
- package/lib/WAUSync/USyncQuery.js +4 -7
- package/package.json +107 -123
- package/lib/Utils/a2ui.d.ts +0 -50
- package/lib/Utils/a2ui.js +0 -168
- package/lib/Utils/anchor-guard.d.ts +0 -71
- package/lib/Utils/anchor-guard.js +0 -404
- package/lib/Utils/connection-manager.d.ts +0 -44
- package/lib/Utils/connection-manager.js +0 -258
- package/lib/Utils/ignore-key.d.ts +0 -51
- package/lib/Utils/ignore-key.js +0 -176
package/lib/Utils/history.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { pipeline } from 'stream/promises';
|
|
2
2
|
import { promisify } from 'util';
|
|
3
3
|
import { createInflate, inflate } from 'zlib';
|
|
4
|
-
import $protobuf from 'protobufjs/minimal.js';
|
|
5
4
|
import { proto } from '../../WAProto/index.js';
|
|
6
5
|
import { WAMessageStubType } from '../Types/index.js';
|
|
7
6
|
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser } from '../WABinary/index.js';
|
|
@@ -24,31 +23,7 @@ const extractPnFromMessages = (messages) => {
|
|
|
24
23
|
}
|
|
25
24
|
return undefined;
|
|
26
25
|
};
|
|
27
|
-
const
|
|
28
|
-
const WIRE_TYPE_LENGTH_DELIMITED = 2;
|
|
29
|
-
/**
|
|
30
|
-
* Decodes a HistorySync one conversation at a time. `proto.HistorySync.decode` materializes
|
|
31
|
-
* the whole tree, so for a large chunk every message of every chat is alive at once; walking
|
|
32
|
-
* the top-level fields instead lets each conversation be reduced and dropped before the next
|
|
33
|
-
* one is decoded. Non-conversation fields are copied raw and decoded together at the end.
|
|
34
|
-
*/
|
|
35
|
-
export const decodeHistorySyncStreaming = (buffer, onConversation) => {
|
|
36
|
-
const reader = $protobuf.Reader.create(buffer);
|
|
37
|
-
const rest = [];
|
|
38
|
-
while (reader.pos < reader.len) {
|
|
39
|
-
const start = reader.pos;
|
|
40
|
-
const tag = reader.uint32();
|
|
41
|
-
if (tag >>> 3 === HISTORY_SYNC_CONVERSATIONS_FIELD && (tag & 7) === WIRE_TYPE_LENGTH_DELIMITED) {
|
|
42
|
-
onConversation(proto.Conversation.decode(reader, reader.uint32()));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
reader.skipType(tag & 7);
|
|
46
|
-
rest.push(buffer.subarray(start, reader.pos));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return proto.HistorySync.decode(rest.length === 1 ? rest[0] : Buffer.concat(rest));
|
|
50
|
-
};
|
|
51
|
-
const inflateHistoryStream = async (msg, options) => {
|
|
26
|
+
export const downloadHistory = async (msg, options) => {
|
|
52
27
|
const stream = await downloadContentFromMessage(msg, 'md-msg-hist', { options });
|
|
53
28
|
// Pipe decrypted stream directly through zlib inflate
|
|
54
29
|
// This avoids allocating an intermediate buffer for the compressed data
|
|
@@ -56,129 +31,100 @@ const inflateHistoryStream = async (msg, options) => {
|
|
|
56
31
|
const chunks = [];
|
|
57
32
|
inflater.on('data', (chunk) => chunks.push(chunk));
|
|
58
33
|
await pipeline(stream, inflater);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return proto.HistorySync.decode(await inflateHistoryStream(msg, options));
|
|
34
|
+
const buffer = Buffer.concat(chunks);
|
|
35
|
+
const syncData = proto.HistorySync.decode(buffer);
|
|
36
|
+
return syncData;
|
|
63
37
|
};
|
|
64
|
-
const
|
|
38
|
+
export const processHistoryMessage = (item, logger) => {
|
|
65
39
|
const messages = [];
|
|
66
40
|
const contacts = [];
|
|
67
41
|
const chats = [];
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
lid: chat.lidJid || chat.accountLid || undefined,
|
|
75
|
-
phoneNumber: chat.pnJid || undefined
|
|
76
|
-
});
|
|
77
|
-
const chatId = chat.id;
|
|
78
|
-
const isLid = isLidUser(chatId) || isHostedLidUser(chatId);
|
|
79
|
-
const isPn = isPnUser(chatId) || isHostedPnUser(chatId);
|
|
80
|
-
if (isLid && chat.pnJid) {
|
|
81
|
-
convLidPnMappings.push({ lid: chatId, pn: chat.pnJid });
|
|
82
|
-
}
|
|
83
|
-
else if (isPn && chat.lidJid) {
|
|
84
|
-
convLidPnMappings.push({ lid: chat.lidJid, pn: chatId });
|
|
42
|
+
const lidPnMappings = [];
|
|
43
|
+
logger?.trace({ progress: item.progress }, 'processing history of type ' + item.syncType?.toString());
|
|
44
|
+
// Extract LID-PN mappings for all sync types
|
|
45
|
+
for (const m of item.phoneNumberToLidMappings || []) {
|
|
46
|
+
if (m.lidJid && m.pnJid) {
|
|
47
|
+
lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid });
|
|
85
48
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const msgs = chat.messages || [];
|
|
94
|
-
delete chat.messages;
|
|
95
|
-
for (const item of msgs) {
|
|
96
|
-
const message = item.message;
|
|
97
|
-
messages.push(message);
|
|
98
|
-
if (!chat.messages?.length) {
|
|
99
|
-
// keep only the most recent message in the chat array
|
|
100
|
-
chat.messages = [{ message }];
|
|
101
|
-
}
|
|
102
|
-
if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
103
|
-
chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp);
|
|
104
|
-
}
|
|
105
|
-
if ((message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP ||
|
|
106
|
-
message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB) &&
|
|
107
|
-
message.messageStubParameters?.[0]) {
|
|
49
|
+
}
|
|
50
|
+
switch (item.syncType) {
|
|
51
|
+
case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
52
|
+
case proto.HistorySync.HistorySyncType.RECENT:
|
|
53
|
+
case proto.HistorySync.HistorySyncType.FULL:
|
|
54
|
+
case proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
55
|
+
for (const chat of item.conversations) {
|
|
108
56
|
contacts.push({
|
|
109
|
-
id:
|
|
110
|
-
|
|
57
|
+
id: chat.id,
|
|
58
|
+
name: chat.displayName || chat.name || chat.username || undefined,
|
|
59
|
+
username: chat.username || undefined,
|
|
60
|
+
lid: chat.lidJid || chat.accountLid || undefined,
|
|
61
|
+
phoneNumber: chat.pnJid || undefined
|
|
111
62
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
logger?.trace({ progress: item.progress }, 'processing history of type ' + item.syncType?.toString());
|
|
118
|
-
// Extract LID-PN mappings for all sync types
|
|
119
|
-
const lidPnMappings = [];
|
|
120
|
-
for (const m of item.phoneNumberToLidMappings || []) {
|
|
121
|
-
if (m.lidJid && m.pnJid) {
|
|
122
|
-
lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
switch (item.syncType) {
|
|
126
|
-
case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
127
|
-
case proto.HistorySync.HistorySyncType.RECENT:
|
|
128
|
-
case proto.HistorySync.HistorySyncType.FULL:
|
|
129
|
-
case proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
130
|
-
for (const chat of item.conversations || []) {
|
|
131
|
-
addConversation(chat);
|
|
63
|
+
const chatId = chat.id;
|
|
64
|
+
const isLid = isLidUser(chatId) || isHostedLidUser(chatId);
|
|
65
|
+
const isPn = isPnUser(chatId) || isHostedPnUser(chatId);
|
|
66
|
+
if (isLid && chat.pnJid) {
|
|
67
|
+
lidPnMappings.push({ lid: chatId, pn: chat.pnJid });
|
|
132
68
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
for (const c of item.pushnames || []) {
|
|
136
|
-
contacts.push({ id: c.id, notify: c.pushname });
|
|
69
|
+
else if (isPn && chat.lidJid) {
|
|
70
|
+
lidPnMappings.push({ lid: chat.lidJid, pn: chatId });
|
|
137
71
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
])
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
72
|
+
else if (isLid && !chat.pnJid) {
|
|
73
|
+
// Fallback: extract PN from userReceipt in messages when pnJid is missing
|
|
74
|
+
const pnFromReceipt = extractPnFromMessages(chat.messages || []);
|
|
75
|
+
if (pnFromReceipt) {
|
|
76
|
+
lidPnMappings.push({ lid: chatId, pn: pnFromReceipt });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const msgs = chat.messages || [];
|
|
80
|
+
delete chat.messages;
|
|
81
|
+
for (const item of msgs) {
|
|
82
|
+
const message = item.message;
|
|
83
|
+
messages.push(message);
|
|
84
|
+
if (!chat.messages?.length) {
|
|
85
|
+
// keep only the most recent message in the chat array
|
|
86
|
+
chat.messages = [{ message }];
|
|
87
|
+
}
|
|
88
|
+
if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
89
|
+
chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp);
|
|
90
|
+
}
|
|
91
|
+
if ((message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP ||
|
|
92
|
+
message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB) &&
|
|
93
|
+
message.messageStubParameters?.[0]) {
|
|
94
|
+
contacts.push({
|
|
95
|
+
id: message.key.participant || message.key.remoteJid,
|
|
96
|
+
verifiedName: message.messageStubParameters?.[0]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
chats.push(chat);
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
104
|
+
for (const c of item.pushnames) {
|
|
105
|
+
contacts.push({ id: c.id, notify: c.pushname });
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
169
108
|
}
|
|
170
|
-
return
|
|
109
|
+
return {
|
|
110
|
+
chats,
|
|
111
|
+
contacts,
|
|
112
|
+
messages,
|
|
113
|
+
lidPnMappings,
|
|
114
|
+
pastParticipants: item.pastParticipants,
|
|
115
|
+
syncType: item.syncType,
|
|
116
|
+
progress: item.progress
|
|
117
|
+
};
|
|
171
118
|
};
|
|
172
119
|
export const downloadAndProcessHistorySyncNotification = async (msg, options, logger) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return acc.finish(rest);
|
|
120
|
+
let historyMsg;
|
|
121
|
+
if (msg.initialHistBootstrapInlinePayload) {
|
|
122
|
+
historyMsg = proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
historyMsg = await downloadHistory(msg, options);
|
|
126
|
+
}
|
|
127
|
+
return processHistoryMessage(historyMsg, logger);
|
|
182
128
|
};
|
|
183
129
|
export const getHistoryMsg = (message) => {
|
|
184
130
|
const normalizedContent = !!message ? normalizeMessageContent(message) : undefined;
|
package/lib/Utils/index.d.ts
CHANGED
|
@@ -22,9 +22,5 @@ export * from "./browser-utils.js";
|
|
|
22
22
|
export * from "./companion-reg-client-utils.js";
|
|
23
23
|
export * from "./identity-change-handler.js";
|
|
24
24
|
export * from "./stanza-ack.js";
|
|
25
|
-
export * from "./ignore-key.js";
|
|
26
|
-
export * from "./anchor-guard.js";
|
|
27
|
-
export * from "./connection-manager.js";
|
|
28
|
-
export * from "./a2ui.js";
|
|
29
25
|
export * from "./meta-ai-msmsg.js";
|
|
30
26
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/Utils/index.js
CHANGED
|
@@ -18,13 +18,9 @@ export * from './event-buffer.js';
|
|
|
18
18
|
export * from './process-message.js';
|
|
19
19
|
export * from './rich-message-utils.js';
|
|
20
20
|
export * from './message-retry-manager.js';
|
|
21
|
-
export * from './connection-manager.js';
|
|
22
21
|
export * from './browser-utils.js';
|
|
23
22
|
export * from './companion-reg-client-utils.js';
|
|
24
23
|
export * from './identity-change-handler.js';
|
|
25
24
|
export * from './stanza-ack.js';
|
|
26
|
-
export * from './ignore-key.js';
|
|
27
|
-
export * from './anchor-guard.js';
|
|
28
|
-
export * from './a2ui.js';
|
|
29
25
|
export * from './meta-ai-msmsg.js';
|
|
30
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -34,8 +34,6 @@ export const makeListenerGuard = (onError) => {
|
|
|
34
34
|
if (result && typeof result.catch === 'function') result.catch(onError)
|
|
35
35
|
return result
|
|
36
36
|
}
|
|
37
|
-
// Preserve the identity EventEmitter uses to remove once wrappers and list callbacks.
|
|
38
|
-
wrapper.listener = listener.listener || listener
|
|
39
37
|
wrappers.set(listener, wrapper)
|
|
40
38
|
return wrapper
|
|
41
39
|
},
|
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import { LRUCache } from 'lru-cache';
|
|
2
2
|
/** Number of sent messages to cache in memory for handling retry receipts */
|
|
3
3
|
const RECENT_MESSAGES_SIZE = 1024;
|
|
4
|
-
/**
|
|
5
|
-
* Entry caps for the two caches below that only had a `ttl`.
|
|
6
|
-
*
|
|
7
|
-
* lru-cache's own docs: "Even if ttl tracking is enabled, it is strongly recommended to set a `max` to
|
|
8
|
-
* prevent unbounded growth of the cache." `recentMessagesMap` and `baseKeys` were capped at
|
|
9
|
-
* RECENT_MESSAGES_SIZE; `sessionRecreateHistory` and `retryCounters` were not, so their only bound was
|
|
10
|
-
* expiry — and one MessageRetryManager exists PER SOCKET (messages-send.js:87, on by default via
|
|
11
|
-
* `enableRecentMessageCache`). A host running a bot fleet holds one per bot.
|
|
12
|
-
*
|
|
13
|
-
* `retryCounters` is the worse of the two: it is keyed per message and sets `updateAgeOnGet`, so
|
|
14
|
-
* `hasExceededMaxRetries()` — which reads it — refreshes the TTL on every check. A message stuck in a
|
|
15
|
-
* retry loop therefore kept its entry alive indefinitely, which is the opposite of what a TTL backstop
|
|
16
|
-
* is for. The age semantics are left alone (dropping them would hand a long retry a fresh count and
|
|
17
|
-
* extra attempts past maxMsgRetryCount); the cap is what makes the growth bounded either way, and LRU
|
|
18
|
-
* eviction of the oldest counter has the same effect the TTL already intended.
|
|
19
|
-
*/
|
|
20
|
-
const SESSION_HISTORY_SIZE = 1024;
|
|
21
|
-
const RETRY_COUNTER_SIZE = 4096;
|
|
22
4
|
const MESSAGE_KEY_SEPARATOR = '\u0000';
|
|
23
5
|
/** Timeout for session recreation - 1 hour */
|
|
24
6
|
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000; // 1 hour in milliseconds
|
|
@@ -62,12 +44,10 @@ export class MessageRetryManager {
|
|
|
62
44
|
});
|
|
63
45
|
this.messageKeyIndex = new Map();
|
|
64
46
|
this.sessionRecreateHistory = new LRUCache({
|
|
65
|
-
max: SESSION_HISTORY_SIZE,
|
|
66
47
|
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
67
48
|
ttlAutopurge: true
|
|
68
49
|
});
|
|
69
50
|
this.retryCounters = new LRUCache({
|
|
70
|
-
max: RETRY_COUNTER_SIZE,
|
|
71
51
|
ttl: 15 * 60 * 1000,
|
|
72
52
|
ttlAutopurge: true,
|
|
73
53
|
updateAgeOnGet: true
|
|
@@ -44,31 +44,8 @@ export function getStream(item: any, opts: any): Promise<{
|
|
|
44
44
|
stream: any;
|
|
45
45
|
type: string;
|
|
46
46
|
}>;
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
signal?: AbortSignal;
|
|
50
|
-
dispatcher?: unknown;
|
|
51
|
-
maxContentLength?: number;
|
|
52
|
-
}
|
|
53
|
-
export interface MediaEncryptionOptions {
|
|
54
|
-
logger?: {
|
|
55
|
-
debug?: (...args: any[]) => void;
|
|
56
|
-
error?: (...args: any[]) => void;
|
|
57
|
-
};
|
|
58
|
-
saveOriginalFileIfRequired?: boolean;
|
|
59
|
-
opts?: MediaFetchOptions;
|
|
60
|
-
/** Reuse an existing 32-byte media key instead of generating one (e.g. sticker-pack thumbnails). */
|
|
61
|
-
mediaKey?: Uint8Array;
|
|
62
|
-
}
|
|
63
|
-
export interface MediaDownloadOptions {
|
|
64
|
-
startByte?: number;
|
|
65
|
-
/** Exclusive end offset. Ranges still download and authenticate the complete media. */
|
|
66
|
-
endByte?: number;
|
|
67
|
-
options?: MediaFetchOptions;
|
|
68
|
-
host?: string;
|
|
69
|
-
}
|
|
70
|
-
export function getHttpStream(url: any, options?: MediaFetchOptions): Promise<any>;
|
|
71
|
-
export function encryptedStream(media: any, mediaType: any, { logger, saveOriginalFileIfRequired, opts }?: MediaEncryptionOptions): Promise<{
|
|
47
|
+
export function getHttpStream(url: any, options?: {}): Promise<any>;
|
|
48
|
+
export function encryptedStream(media: any, mediaType: any, { logger, saveOriginalFileIfRequired, opts }?: {}): Promise<{
|
|
72
49
|
mediaKey: any;
|
|
73
50
|
originalFilePath: any;
|
|
74
51
|
encFilePath: any;
|
|
@@ -76,26 +53,18 @@ export function encryptedStream(media: any, mediaType: any, { logger, saveOrigin
|
|
|
76
53
|
fileEncSha256: any;
|
|
77
54
|
fileSha256: any;
|
|
78
55
|
fileLength: number;
|
|
79
|
-
streamingSidecar: Buffer | undefined;
|
|
80
56
|
}>;
|
|
81
|
-
export function scanStreamable(head: Uint8Array): boolean | null;
|
|
82
57
|
export const DEF_MEDIA_HOST: "mmg.whatsapp.net";
|
|
83
58
|
export function getUrlFromDirectPath(directPath: any, host?: string): string;
|
|
84
59
|
export function downloadContentFromMessage({ mediaKey, directPath, url }: {
|
|
85
60
|
mediaKey: any;
|
|
86
|
-
directPath
|
|
87
|
-
url
|
|
88
|
-
}, type: any, opts?:
|
|
89
|
-
|
|
90
|
-
* Verifies the complete media HMAC before returning a temporary-file-backed stream.
|
|
91
|
-
* Byte ranges are sliced after full download/authentication (endByte is exclusive).
|
|
92
|
-
* Consume or destroy the stream to release its temporary file.
|
|
93
|
-
*/
|
|
94
|
-
export function downloadEncryptedContent(downloadUrl: any, { cipherKey, iv, macKey }: {
|
|
61
|
+
directPath: any;
|
|
62
|
+
url: any;
|
|
63
|
+
}, type: any, opts?: {}): Promise<any>;
|
|
64
|
+
export function downloadEncryptedContent(downloadUrl: any, { cipherKey, iv }: {
|
|
95
65
|
cipherKey: any;
|
|
96
66
|
iv: any;
|
|
97
|
-
|
|
98
|
-
}, { startByte, endByte, options }?: MediaDownloadOptions): Promise<any>;
|
|
67
|
+
}, { startByte, endByte, options }?: {}): Promise<any>;
|
|
99
68
|
export function uploadWithNodeHttp({ url, filePath, headers, timeoutMs, agent }: {
|
|
100
69
|
url: any;
|
|
101
70
|
filePath: any;
|
|
@@ -165,4 +134,4 @@ export function decryptMediaRetryData({ ciphertext, iv }: {
|
|
|
165
134
|
}, mediaKey: any, msgId: any): proto.MediaRetryNotification;
|
|
166
135
|
export function getStatusCodeForMediaRetry(code: any): any;
|
|
167
136
|
import { proto } from '../../WAProto/index.js';
|
|
168
|
-
//# sourceMappingURL=messages-media.d.ts.map
|
|
137
|
+
//# sourceMappingURL=messages-media.d.ts.map
|