gifted-baileys 1.5.5 → 1.5.7
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 +6 -1642
- package/WAProto/WAProto.proto +969 -88
- package/WAProto/index.d.ts +13199 -1260
- package/WAProto/index.js +124901 -74525
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +284 -0
- package/{src → lib}/Defaults/index.js +7 -14
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +161 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/{src → lib}/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/business.d.ts +170 -0
- package/{src → lib}/Socket/business.js +28 -33
- package/lib/Socket/chats.d.ts +81 -0
- package/{src → lib}/Socket/chats.js +174 -176
- package/lib/Socket/groups.d.ts +115 -0
- package/{src → lib}/Socket/groups.js +80 -68
- package/lib/Socket/index.d.ts +172 -0
- package/{src → lib}/Socket/index.js +4 -1
- package/lib/Socket/messages-recv.d.ts +158 -0
- package/{src → lib}/Socket/messages-recv.js +378 -211
- package/lib/Socket/messages-send.d.ts +155 -0
- package/{src → lib}/Socket/messages-send.js +452 -177
- package/lib/Socket/newsletter.d.ts +132 -0
- package/{src → lib}/Socket/newsletter.js +107 -98
- package/lib/Socket/registration.d.ts +264 -0
- package/{src → lib}/Socket/registration.js +56 -48
- package/lib/Socket/socket.d.ts +44 -0
- package/{src → lib}/Socket/socket.js +77 -77
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/{src → lib}/Store/make-cache-manager-store.js +25 -34
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/{src → lib}/Store/make-in-memory-store.js +36 -32
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/{src → lib}/Store/object-repository.js +1 -1
- package/lib/Types/Auth.d.ts +109 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +107 -0
- package/{src/Types/Contact.ts → lib/Types/Contact.d.ts} +8 -9
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/GroupMetadata.d.ts +56 -0
- package/lib/Types/Label.d.ts +46 -0
- package/{src/Types/LabelAssociation.ts → lib/Types/LabelAssociation.d.ts} +16 -22
- package/lib/Types/Message.d.ts +433 -0
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/{src/Types/Socket.ts → lib/Types/Socket.d.ts} +61 -68
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/{src → lib}/Utils/auth-utils.js +73 -90
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/{src → lib}/Utils/business.js +15 -43
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/{src → lib}/Utils/chat-utils.js +87 -94
- package/lib/Utils/crypto.d.ts +40 -0
- package/{src → lib}/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/decode-wa-message.js +226 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/{src → lib}/Utils/event-buffer.js +4 -13
- package/lib/Utils/generics.d.ts +88 -0
- package/{src → lib}/Utils/generics.js +67 -86
- package/lib/Utils/history.d.ts +19 -0
- package/{src → lib}/Utils/history.js +13 -39
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/{src → lib}/Utils/link-preview.js +17 -54
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/{src → lib}/Utils/make-mutex.js +4 -13
- package/lib/Utils/messages-media.d.ts +113 -0
- package/{src → lib}/Utils/messages-media.js +193 -255
- package/lib/Utils/messages.d.ts +77 -0
- package/{src → lib}/Utils/messages.js +588 -118
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/{src → lib}/Utils/process-message.js +27 -30
- package/lib/Utils/signal.d.ts +33 -0
- package/{src → lib}/Utils/signal.js +25 -42
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/{src → lib}/Utils/use-multi-file-auth-state.js +27 -28
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/{src → lib}/Utils/validate-connection.js +40 -9
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/{src → lib}/WABinary/encode.js +16 -10
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/{src → lib}/index.js +1 -0
- package/package.json +26 -8
- package/LICENSE +0 -21
- package/src/Defaults/baileys-version.json +0 -3
- package/src/Defaults/index.ts +0 -131
- package/src/Signal/libsignal.js +0 -180
- package/src/Signal/libsignal.ts +0 -141
- package/src/Socket/Client/abstract-socket-client.ts +0 -19
- package/src/Socket/Client/index.ts +0 -3
- package/src/Socket/Client/mobile-socket-client.js +0 -78
- package/src/Socket/Client/mobile-socket-client.ts +0 -66
- package/src/Socket/Client/web-socket-client.js +0 -75
- package/src/Socket/Client/web-socket-client.ts +0 -57
- package/src/Socket/business.ts +0 -281
- package/src/Socket/chats.ts +0 -1030
- package/src/Socket/groups.ts +0 -356
- package/src/Socket/index.ts +0 -13
- package/src/Socket/messages-recv.ts +0 -985
- package/src/Socket/messages-send.ts +0 -871
- package/src/Socket/newsletter.ts +0 -282
- package/src/Socket/registration.ts +0 -250
- package/src/Socket/socket.ts +0 -777
- package/src/Store/index.ts +0 -3
- package/src/Store/make-cache-manager-store.ts +0 -100
- package/src/Store/make-in-memory-store.ts +0 -475
- package/src/Store/make-ordered-dictionary.ts +0 -86
- package/src/Store/object-repository.ts +0 -32
- package/src/Tests/test.app-state-sync.js +0 -204
- package/src/Tests/test.app-state-sync.ts +0 -207
- package/src/Tests/test.event-buffer.js +0 -270
- package/src/Tests/test.event-buffer.ts +0 -319
- package/src/Tests/test.key-store.js +0 -76
- package/src/Tests/test.key-store.ts +0 -92
- package/src/Tests/test.libsignal.js +0 -141
- package/src/Tests/test.libsignal.ts +0 -186
- package/src/Tests/test.media-download.js +0 -93
- package/src/Tests/test.media-download.ts +0 -76
- package/src/Tests/test.messages.js +0 -33
- package/src/Tests/test.messages.ts +0 -37
- package/src/Tests/utils.js +0 -34
- package/src/Tests/utils.ts +0 -36
- package/src/Types/Auth.ts +0 -113
- package/src/Types/Call.ts +0 -15
- package/src/Types/Chat.ts +0 -106
- package/src/Types/Events.ts +0 -93
- package/src/Types/GroupMetadata.ts +0 -53
- package/src/Types/Label.ts +0 -36
- package/src/Types/Message.ts +0 -288
- package/src/Types/Newsletter.ts +0 -98
- package/src/Types/Product.ts +0 -85
- package/src/Types/Signal.ts +0 -68
- package/src/Types/State.ts +0 -29
- package/src/Types/index.ts +0 -59
- package/src/Utils/auth-utils.ts +0 -222
- package/src/Utils/baileys-event-stream.js +0 -92
- package/src/Utils/baileys-event-stream.ts +0 -66
- package/src/Utils/business.ts +0 -275
- package/src/Utils/chat-utils.ts +0 -860
- package/src/Utils/crypto.ts +0 -131
- package/src/Utils/decode-wa-message.js +0 -211
- package/src/Utils/decode-wa-message.ts +0 -228
- package/src/Utils/event-buffer.ts +0 -613
- package/src/Utils/generics.ts +0 -434
- package/src/Utils/history.ts +0 -112
- package/src/Utils/index.ts +0 -17
- package/src/Utils/link-preview.ts +0 -122
- package/src/Utils/logger.ts +0 -3
- package/src/Utils/lt-hash.ts +0 -61
- package/src/Utils/make-mutex.ts +0 -44
- package/src/Utils/messages-media.ts +0 -847
- package/src/Utils/messages.ts +0 -956
- package/src/Utils/noise-handler.ts +0 -197
- package/src/Utils/process-message.ts +0 -414
- package/src/Utils/signal.ts +0 -177
- package/src/Utils/use-multi-file-auth-state.ts +0 -90
- package/src/Utils/validate-connection.ts +0 -238
- package/src/WABinary/constants.ts +0 -42
- package/src/WABinary/decode.ts +0 -265
- package/src/WABinary/encode.ts +0 -236
- package/src/WABinary/generic-utils.ts +0 -121
- package/src/WABinary/index.ts +0 -5
- package/src/WABinary/jid-utils.ts +0 -68
- package/src/WABinary/types.ts +0 -17
- package/src/WAM/BinaryInfo.ts +0 -12
- package/src/WAM/constants.ts +0 -15382
- package/src/WAM/encode.ts +0 -174
- package/src/WAM/index.ts +0 -3
- package/src/gifted +0 -1
- package/src/index.ts +0 -13
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
- /package/{src → lib}/Socket/Client/abstract-socket-client.js +0 -0
- /package/{src → lib}/Store/index.js +0 -0
- /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
- /package/{src → lib}/Types/Auth.js +0 -0
- /package/{src → lib}/Types/Call.js +0 -0
- /package/{src → lib}/Types/Chat.js +0 -0
- /package/{src → lib}/Types/Contact.js +0 -0
- /package/{src → lib}/Types/Events.js +0 -0
- /package/{src → lib}/Types/GroupMetadata.js +0 -0
- /package/{src → lib}/Types/Label.js +0 -0
- /package/{src → lib}/Types/LabelAssociation.js +0 -0
- /package/{src → lib}/Types/Message.js +0 -0
- /package/{src → lib}/Types/Newsletter.js +0 -0
- /package/{src → lib}/Types/Product.js +0 -0
- /package/{src → lib}/Types/Signal.js +0 -0
- /package/{src → lib}/Types/Socket.js +0 -0
- /package/{src → lib}/Types/State.js +0 -0
- /package/{src/WABinary/types.js → lib/Types/USync.js} +0 -0
- /package/{src → lib}/Types/index.js +0 -0
- /package/{src → lib}/Utils/index.js +0 -0
- /package/{src → lib}/Utils/logger.js +0 -0
- /package/{src → lib}/Utils/lt-hash.js +0 -0
- /package/{src → lib}/Utils/noise-handler.js +0 -0
- /package/{src → lib}/WABinary/constants.js +0 -0
- /package/{src → lib}/WABinary/decode.js +0 -0
- /package/{src → lib}/WABinary/generic-utils.js +0 -0
- /package/{src → lib}/WABinary/index.js +0 -0
- /package/{src → lib}/WABinary/jid-utils.js +0 -0
- /package/{src → lib}/WAM/BinaryInfo.js +0 -0
- /package/{src → lib}/WAM/constants.js +0 -0
- /package/{src → lib}/WAM/encode.js +0 -0
- /package/{src → lib}/WAM/index.js +0 -0
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
3
|
exports.getHistoryMsg = exports.downloadAndProcessHistorySyncNotification = exports.processHistoryMessage = exports.downloadHistory = void 0;
|
|
20
4
|
const util_1 = require("util");
|
|
@@ -26,31 +10,18 @@ const generics_1 = require("./generics");
|
|
|
26
10
|
const messages_1 = require("./messages");
|
|
27
11
|
const messages_media_1 = require("./messages-media");
|
|
28
12
|
const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
|
|
29
|
-
const downloadHistory = (msg, options) =>
|
|
30
|
-
|
|
31
|
-
const stream = yield (0, messages_media_1.downloadContentFromMessage)(msg, 'md-msg-hist', { options });
|
|
13
|
+
const downloadHistory = async (msg, options) => {
|
|
14
|
+
const stream = await (0, messages_media_1.downloadContentFromMessage)(msg, 'md-msg-hist', { options });
|
|
32
15
|
const bufferArray = [];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_c = stream_1_1.value;
|
|
36
|
-
_d = false;
|
|
37
|
-
const chunk = _c;
|
|
38
|
-
bufferArray.push(chunk);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
42
|
-
finally {
|
|
43
|
-
try {
|
|
44
|
-
if (!_d && !_a && (_b = stream_1.return)) yield _b.call(stream_1);
|
|
45
|
-
}
|
|
46
|
-
finally { if (e_1) throw e_1.error; }
|
|
16
|
+
for await (const chunk of stream) {
|
|
17
|
+
bufferArray.push(chunk);
|
|
47
18
|
}
|
|
48
19
|
let buffer = Buffer.concat(bufferArray);
|
|
49
20
|
// decompress buffer
|
|
50
|
-
buffer =
|
|
21
|
+
buffer = await inflatePromise(buffer);
|
|
51
22
|
const syncData = WAProto_1.proto.HistorySync.decode(buffer);
|
|
52
23
|
return syncData;
|
|
53
|
-
}
|
|
24
|
+
};
|
|
54
25
|
exports.downloadHistory = downloadHistory;
|
|
55
26
|
const processHistoryMessage = (item) => {
|
|
56
27
|
var _a, _b, _c;
|
|
@@ -61,6 +32,7 @@ const processHistoryMessage = (item) => {
|
|
|
61
32
|
case WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
62
33
|
case WAProto_1.proto.HistorySync.HistorySyncType.RECENT:
|
|
63
34
|
case WAProto_1.proto.HistorySync.HistorySyncType.FULL:
|
|
35
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
64
36
|
for (const chat of item.conversations) {
|
|
65
37
|
contacts.push({ id: chat.id, name: chat.name || undefined });
|
|
66
38
|
const msgs = chat.messages || [];
|
|
@@ -90,7 +62,7 @@ const processHistoryMessage = (item) => {
|
|
|
90
62
|
if ((0, WABinary_1.isJidUser)(chat.id) && chat.readOnly && chat.archived) {
|
|
91
63
|
delete chat.readOnly;
|
|
92
64
|
}
|
|
93
|
-
chats.push(
|
|
65
|
+
chats.push({ ...chat });
|
|
94
66
|
}
|
|
95
67
|
break;
|
|
96
68
|
case WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
@@ -103,13 +75,15 @@ const processHistoryMessage = (item) => {
|
|
|
103
75
|
chats,
|
|
104
76
|
contacts,
|
|
105
77
|
messages,
|
|
78
|
+
syncType: item.syncType,
|
|
79
|
+
progress: item.progress
|
|
106
80
|
};
|
|
107
81
|
};
|
|
108
82
|
exports.processHistoryMessage = processHistoryMessage;
|
|
109
|
-
const downloadAndProcessHistorySyncNotification = (msg, options) =>
|
|
110
|
-
const historyMsg =
|
|
83
|
+
const downloadAndProcessHistorySyncNotification = async (msg, options) => {
|
|
84
|
+
const historyMsg = await (0, exports.downloadHistory)(msg, options);
|
|
111
85
|
return (0, exports.processHistoryMessage)(historyMsg);
|
|
112
|
-
}
|
|
86
|
+
};
|
|
113
87
|
exports.downloadAndProcessHistorySyncNotification = downloadAndProcessHistorySyncNotification;
|
|
114
88
|
const getHistoryMsg = (message) => {
|
|
115
89
|
var _a;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './generics';
|
|
2
|
+
export * from './decode-wa-message';
|
|
3
|
+
export * from './messages';
|
|
4
|
+
export * from './messages-media';
|
|
5
|
+
export * from './validate-connection';
|
|
6
|
+
export * from './crypto';
|
|
7
|
+
export * from './signal';
|
|
8
|
+
export * from './noise-handler';
|
|
9
|
+
export * from './history';
|
|
10
|
+
export * from './chat-utils';
|
|
11
|
+
export * from './lt-hash';
|
|
12
|
+
export * from './auth-utils';
|
|
13
|
+
export * from './baileys-event-stream';
|
|
14
|
+
export * from './use-multi-file-auth-state';
|
|
15
|
+
export * from './link-preview';
|
|
16
|
+
export * from './event-buffer';
|
|
17
|
+
export * from './process-message';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
|
|
4
|
+
export type URLGenerationOptions = {
|
|
5
|
+
thumbnailWidth: number;
|
|
6
|
+
fetchOpts: {
|
|
7
|
+
/** Timeout in ms */
|
|
8
|
+
timeout: number;
|
|
9
|
+
proxyUrl?: string;
|
|
10
|
+
headers?: AxiosRequestConfig<{}>['headers'];
|
|
11
|
+
};
|
|
12
|
+
uploadImage?: WAMediaUploadFunction;
|
|
13
|
+
logger?: Logger;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
17
|
+
* Return undefined if the fetch failed or no URL was found
|
|
18
|
+
* @param text first matched URL in text
|
|
19
|
+
* @returns the URL info required to generate link preview
|
|
20
|
+
*/
|
|
21
|
+
export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>;
|
|
@@ -1,78 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
3
|
exports.getUrlInfo = void 0;
|
|
46
4
|
const messages_1 = require("./messages");
|
|
47
5
|
const messages_media_1 = require("./messages-media");
|
|
48
6
|
const THUMBNAIL_WIDTH_PX = 192;
|
|
49
7
|
/** Fetches an image and generates a thumbnail for it */
|
|
50
|
-
const getCompressedJpegThumbnail =
|
|
51
|
-
const stream =
|
|
52
|
-
const result =
|
|
8
|
+
const getCompressedJpegThumbnail = async (url, { thumbnailWidth, fetchOpts }) => {
|
|
9
|
+
const stream = await (0, messages_media_1.getHttpStream)(url, fetchOpts);
|
|
10
|
+
const result = await (0, messages_media_1.extractImageThumb)(stream, thumbnailWidth);
|
|
53
11
|
return result;
|
|
54
|
-
}
|
|
12
|
+
};
|
|
55
13
|
/**
|
|
56
14
|
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
57
15
|
* Return undefined if the fetch failed or no URL was found
|
|
58
16
|
* @param text first matched URL in text
|
|
59
17
|
* @returns the URL info required to generate link preview
|
|
60
18
|
*/
|
|
61
|
-
const getUrlInfo =
|
|
19
|
+
const getUrlInfo = async (text, opts = {
|
|
62
20
|
thumbnailWidth: THUMBNAIL_WIDTH_PX,
|
|
63
21
|
fetchOpts: { timeout: 3000 }
|
|
64
|
-
}) {
|
|
22
|
+
}) => {
|
|
65
23
|
var _a;
|
|
66
24
|
try {
|
|
67
25
|
// retries
|
|
68
26
|
const retries = 0;
|
|
69
27
|
const maxRetry = 5;
|
|
70
|
-
const { getLinkPreview } =
|
|
28
|
+
const { getLinkPreview } = await import('link-preview-js');
|
|
71
29
|
let previewLink = text;
|
|
72
30
|
if (!text.startsWith('https://') && !text.startsWith('http://')) {
|
|
73
31
|
previewLink = 'https://' + previewLink;
|
|
74
32
|
}
|
|
75
|
-
const info =
|
|
33
|
+
const info = await getLinkPreview(previewLink, {
|
|
34
|
+
...opts.fetchOpts,
|
|
35
|
+
followRedirects: 'follow',
|
|
36
|
+
handleRedirects: (baseURL, forwardedURL) => {
|
|
76
37
|
const urlObj = new URL(baseURL);
|
|
77
38
|
const forwardedURLObj = new URL(forwardedURL);
|
|
78
39
|
if (retries >= maxRetry) {
|
|
@@ -87,7 +48,9 @@ const getUrlInfo = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1],
|
|
|
87
48
|
else {
|
|
88
49
|
return false;
|
|
89
50
|
}
|
|
90
|
-
},
|
|
51
|
+
},
|
|
52
|
+
headers: opts.fetchOpts
|
|
53
|
+
});
|
|
91
54
|
if (info && 'title' in info && info.title) {
|
|
92
55
|
const [image] = info.images;
|
|
93
56
|
const urlInfo = {
|
|
@@ -98,7 +61,7 @@ const getUrlInfo = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1],
|
|
|
98
61
|
originalThumbnailUrl: image
|
|
99
62
|
};
|
|
100
63
|
if (opts.uploadImage) {
|
|
101
|
-
const { imageMessage } =
|
|
64
|
+
const { imageMessage } = await (0, messages_1.prepareWAMessageMedia)({ image: { url: image } }, {
|
|
102
65
|
upload: opts.uploadImage,
|
|
103
66
|
mediaTypeOverride: 'thumbnail-link',
|
|
104
67
|
options: opts.fetchOpts
|
|
@@ -111,7 +74,7 @@ const getUrlInfo = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1],
|
|
|
111
74
|
else {
|
|
112
75
|
try {
|
|
113
76
|
urlInfo.jpegThumbnail = image
|
|
114
|
-
? (
|
|
77
|
+
? (await getCompressedJpegThumbnail(image, opts)).buffer
|
|
115
78
|
: undefined;
|
|
116
79
|
}
|
|
117
80
|
catch (error) {
|
|
@@ -126,5 +89,5 @@ const getUrlInfo = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1],
|
|
|
126
89
|
throw error;
|
|
127
90
|
}
|
|
128
91
|
}
|
|
129
|
-
}
|
|
92
|
+
};
|
|
130
93
|
exports.getUrlInfo = getUrlInfo;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class d {
|
|
2
|
+
salt: string;
|
|
3
|
+
constructor(e: string);
|
|
4
|
+
add(e: any, t: any): any;
|
|
5
|
+
subtract(e: any, t: any): any;
|
|
6
|
+
subtractThenAdd(e: any, t: any, r: any): any;
|
|
7
|
+
_addSingle(e: any, t: any): ArrayBuffer;
|
|
8
|
+
_subtractSingle(e: any, t: any): ArrayBuffer;
|
|
9
|
+
performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer;
|
|
10
|
+
}
|
|
11
|
+
export declare const LT_HASH_ANTI_TAMPERING: d;
|
|
12
|
+
export {};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.makeKeyedMutex = exports.makeMutex = void 0;
|
|
13
4
|
const makeMutex = () => {
|
|
@@ -15,22 +6,22 @@ const makeMutex = () => {
|
|
|
15
6
|
let taskTimeout;
|
|
16
7
|
return {
|
|
17
8
|
mutex(code) {
|
|
18
|
-
task = (() =>
|
|
9
|
+
task = (async () => {
|
|
19
10
|
// wait for the previous task to complete
|
|
20
11
|
// if there is an error, we swallow so as to not block the queue
|
|
21
12
|
try {
|
|
22
|
-
|
|
13
|
+
await task;
|
|
23
14
|
}
|
|
24
15
|
catch (_a) { }
|
|
25
16
|
try {
|
|
26
17
|
// execute the current task
|
|
27
|
-
const result =
|
|
18
|
+
const result = await code();
|
|
28
19
|
return result;
|
|
29
20
|
}
|
|
30
21
|
finally {
|
|
31
22
|
clearTimeout(taskTimeout);
|
|
32
23
|
}
|
|
33
|
-
})
|
|
24
|
+
})();
|
|
34
25
|
// we replace the existing task, appending the new piece of execution to it
|
|
35
26
|
// so the next task will have to wait for this one to finish
|
|
36
27
|
return task;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
4
|
+
import { Readable } from 'stream';
|
|
5
|
+
import { URL } from 'url';
|
|
6
|
+
import { proto } from '../../WAProto';
|
|
7
|
+
import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
|
|
8
|
+
import { BinaryNode } from '../WABinary';
|
|
9
|
+
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
10
|
+
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
11
|
+
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
|
|
12
|
+
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
13
|
+
buffer: any;
|
|
14
|
+
original: {
|
|
15
|
+
width: any;
|
|
16
|
+
height: any;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
20
|
+
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
21
|
+
img: Buffer;
|
|
22
|
+
}>;
|
|
23
|
+
/** gets the SHA256 of the given media message */
|
|
24
|
+
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => any;
|
|
25
|
+
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
28
|
+
*/
|
|
29
|
+
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger): Promise<Uint8Array<ArrayBuffer> | undefined>;
|
|
30
|
+
export declare const toReadable: (buffer: Buffer) => any;
|
|
31
|
+
export declare const toBuffer: (stream: Readable) => Promise<any>;
|
|
32
|
+
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
|
|
33
|
+
readonly stream: any;
|
|
34
|
+
readonly type: "buffer";
|
|
35
|
+
} | {
|
|
36
|
+
readonly stream: any;
|
|
37
|
+
readonly type: "readable";
|
|
38
|
+
} | {
|
|
39
|
+
readonly stream: Readable;
|
|
40
|
+
readonly type: "remote";
|
|
41
|
+
} | {
|
|
42
|
+
readonly stream: any;
|
|
43
|
+
readonly type: "file";
|
|
44
|
+
}>;
|
|
45
|
+
/** generates a thumbnail for a given media, if required */
|
|
46
|
+
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
47
|
+
logger?: Logger;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
thumbnail: string | undefined;
|
|
50
|
+
originalImageDimensions: {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
} | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
|
|
56
|
+
isStream?: true;
|
|
57
|
+
}) => Promise<Readable>;
|
|
58
|
+
type EncryptedStreamOptions = {
|
|
59
|
+
saveOriginalFileIfRequired?: boolean;
|
|
60
|
+
logger?: Logger;
|
|
61
|
+
opts?: AxiosRequestConfig;
|
|
62
|
+
};
|
|
63
|
+
export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
64
|
+
mediaKey: undefined;
|
|
65
|
+
encWriteStream: any;
|
|
66
|
+
fileLength: any;
|
|
67
|
+
fileSha256: any;
|
|
68
|
+
fileEncSha256: undefined;
|
|
69
|
+
bodyPath: string | undefined;
|
|
70
|
+
didSaveToTmpPath: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
73
|
+
mediaKey: any;
|
|
74
|
+
encWriteStream: any;
|
|
75
|
+
bodyPath: string | undefined;
|
|
76
|
+
mac: any;
|
|
77
|
+
fileEncSha256: any;
|
|
78
|
+
fileSha256: any;
|
|
79
|
+
fileLength: number;
|
|
80
|
+
didSaveToTmpPath: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
export type MediaDownloadOptions = {
|
|
83
|
+
startByte?: number;
|
|
84
|
+
endByte?: number;
|
|
85
|
+
options?: AxiosRequestConfig<any>;
|
|
86
|
+
};
|
|
87
|
+
export declare const getUrlFromDirectPath: (directPath: string) => string;
|
|
88
|
+
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<any>;
|
|
89
|
+
/**
|
|
90
|
+
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
|
|
91
|
+
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
|
|
92
|
+
* */
|
|
93
|
+
export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<any>;
|
|
94
|
+
export declare function extensionForMediaMessage(message: WAMessageContent): string;
|
|
95
|
+
export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
|
|
96
|
+
/**
|
|
97
|
+
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
98
|
+
*/
|
|
99
|
+
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
|
|
100
|
+
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
101
|
+
key: import("../Types").WAMessageKey;
|
|
102
|
+
media?: {
|
|
103
|
+
ciphertext: Uint8Array;
|
|
104
|
+
iv: Uint8Array;
|
|
105
|
+
};
|
|
106
|
+
error?: Boom;
|
|
107
|
+
};
|
|
108
|
+
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
109
|
+
ciphertext: Uint8Array;
|
|
110
|
+
iv: Uint8Array;
|
|
111
|
+
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
|
|
112
|
+
export declare const getStatusCodeForMediaRetry: (code: number) => any;
|
|
113
|
+
export {};
|