socketon 1.31.2-rc → 1.51.16
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 +313 -159
- package/WAProto/WAProto.proto +5311 -0
- package/WAProto/index.js +65801 -141371
- package/lib/Defaults/index.js +117 -141
- package/lib/KeyDB/BinarySearch.js +20 -0
- package/lib/KeyDB/KeyedDB.js +167 -0
- package/lib/KeyDB/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -14
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +75 -87
- package/lib/Signal/Group/index.js +13 -57
- package/lib/Signal/Group/keyhelper.js +17 -52
- package/lib/Signal/Group/sender-chain-key.js +27 -33
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
- package/lib/Signal/Group/sender-key-message.js +65 -66
- package/lib/Signal/Group/sender-key-name.js +45 -44
- package/lib/Signal/Group/sender-key-record.js +39 -49
- package/lib/Signal/Group/sender-key-state.js +80 -93
- package/lib/Signal/Group/sender-message-key.js +27 -28
- package/lib/Signal/libsignal.js +313 -163
- package/lib/Signal/lid-mapping.js +155 -0
- package/lib/Socket/Client/index.js +4 -19
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +52 -0
- package/lib/Socket/Client/websocket.js.bak +53 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +846 -935
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -309
- package/lib/Socket/index.js +15 -10
- package/lib/Socket/messages-recv.js +1107 -1054
- package/lib/Socket/messages-send.js +639 -448
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +240 -324
- package/lib/Socket/socket.js +794 -651
- package/lib/Socket/socketon.js +402 -0
- package/lib/Store/index.js +6 -10
- package/lib/Store/make-cache-manager-store.js +73 -81
- package/lib/Store/make-in-memory-store.js +286 -423
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +9 -4
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +12 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Newsletter.js.bak +33 -0
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -2
- package/lib/Types/State.js +11 -2
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +27 -41
- package/lib/Utils/auth-utils.js +211 -198
- package/lib/Utils/baileys-event-stream.js +42 -61
- package/lib/Utils/browser-utils.js +25 -0
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +710 -687
- package/lib/Utils/crypto.js +112 -133
- package/lib/Utils/decode-wa-message.js +252 -183
- package/lib/Utils/decode-wa-message.js.bak +267 -0
- package/lib/Utils/event-buffer.js +510 -496
- package/lib/Utils/generics.js +319 -392
- package/lib/Utils/history.js +83 -92
- package/lib/Utils/index.js +21 -33
- package/lib/Utils/link-preview.js +71 -83
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +113 -0
- package/lib/Utils/messages-media.js +550 -768
- package/lib/Utils/messages.js +354 -263
- package/lib/Utils/noise-handler.js +138 -149
- package/lib/Utils/pre-key-manager.js +85 -0
- package/lib/Utils/process-message.js +323 -303
- package/lib/Utils/signal.js +149 -141
- package/lib/Utils/use-multi-file-auth-state.js +95 -103
- package/lib/Utils/validate-connection.js +183 -214
- package/lib/WABinary/constants.js +1298 -35
- package/lib/WABinary/decode.js +237 -249
- package/lib/WABinary/encode.js +213 -260
- package/lib/WABinary/generic-utils.js +56 -65
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/jid-utils.js +89 -58
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.js +10 -12
- package/lib/WAM/constants.js +22851 -15348
- package/lib/WAM/encode.js +135 -136
- package/lib/WAM/index.js +5 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/USyncQuery.js +86 -85
- package/lib/WAUSync/USyncUser.js +23 -25
- package/lib/WAUSync/index.js +5 -19
- package/lib/index.js +27 -35
- package/package.json +85 -95
- package/engine-requirements.js +0 -10
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/dugong.d.ts +0 -254
- package/lib/Socket/dugong.js +0 -484
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/generics.js.bak +0 -433
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/validate-connection.js.bak +0 -237
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -17
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.Browsers = void 0;
|
|
7
|
-
const boom_1 = require("@hapi/boom");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const crypto_1 = require("crypto");
|
|
10
|
-
const os_1 = require("os");
|
|
11
|
-
const fetch_1 = require("node-fetch")
|
|
12
|
-
const WAProto_1 = require("../../WAProto");
|
|
13
|
-
const baileys_version_json_1 = require("../Defaults/baileys-version.json");
|
|
14
|
-
const Types_1 = require("../Types");
|
|
15
|
-
const WABinary_1 = require("../WABinary");
|
|
16
|
-
const baileysVersion = [2, 3000, 1027934701]
|
|
17
|
-
const PLATFORM_MAP = {
|
|
18
|
-
'aix': 'AIX',
|
|
19
|
-
'darwin': 'Mac OS',
|
|
20
|
-
'win32': 'Windows',
|
|
21
|
-
'android': 'Android',
|
|
22
|
-
'freebsd': 'FreeBSD',
|
|
23
|
-
'openbsd': 'OpenBSD',
|
|
24
|
-
'sunos': 'Solaris',
|
|
25
|
-
'linux': undefined,
|
|
26
|
-
'haiku': undefined,
|
|
27
|
-
'cygwin': undefined,
|
|
28
|
-
'netbsd': undefined
|
|
29
|
-
};
|
|
30
|
-
exports.Browsers = (browser) => {
|
|
31
|
-
const osName = PLATFORM_MAP[os_1.platform()] || 'Ubuntu';
|
|
32
|
-
const osRelease = os_1.release();
|
|
33
|
-
return [osName, browser, osRelease];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const Browsers = {
|
|
37
|
-
iOS: (browser) => ["ios", browser, "18.2"],
|
|
38
|
-
ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
|
|
39
|
-
macOS: (browser) => ['Mac OS', browser, '14.4.1'],
|
|
40
|
-
baileys: (browser) => ['Baileys', browser, '6.5.0'],
|
|
41
|
-
windows: (browser) => ['Windows', browser, '10.0.22631']
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
exports.Browsers = Browsers
|
|
45
|
-
|
|
46
|
-
const getPlatformId = (browser) => {
|
|
47
|
-
const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
48
|
-
return platformType ? platformType.toString() : '1'; //chrome
|
|
49
|
-
};
|
|
50
|
-
exports.getPlatformId = getPlatformId;
|
|
51
|
-
exports.BufferJSON = {
|
|
52
|
-
replacer: (k, value) => {
|
|
53
|
-
if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
|
|
54
|
-
return { type: 'Buffer', data: Buffer.from((value === null || value === void 0 ? void 0 : value.data) || value).toString('base64') };
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
},
|
|
58
|
-
reviver: (_, value) => {
|
|
59
|
-
if (typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) {
|
|
60
|
-
const val = value.data || value.value;
|
|
61
|
-
return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val || []);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const getKeyAuthor = (key, meId = 'me') => (((key === null || key === void 0 ? void 0 : key.fromMe) ? meId : (key === null || key === void 0 ? void 0 : key.participant) || (key === null || key === void 0 ? void 0 : key.remoteJid)) || '');
|
|
67
|
-
exports.getKeyAuthor = getKeyAuthor;
|
|
68
|
-
const writeRandomPadMax16 = (msg) => {
|
|
69
|
-
const pad = (0, crypto_1.randomBytes)(1);
|
|
70
|
-
pad[0] &= 0xf;
|
|
71
|
-
if (!pad[0]) {
|
|
72
|
-
pad[0] = 0xf;
|
|
73
|
-
}
|
|
74
|
-
return Buffer.concat([msg, Buffer.alloc(pad[0], pad[0])]);
|
|
75
|
-
};
|
|
76
|
-
exports.writeRandomPadMax16 = writeRandomPadMax16;
|
|
77
|
-
const unpadRandomMax16 = (e) => {
|
|
78
|
-
const t = new Uint8Array(e);
|
|
79
|
-
if (0 === t.length) {
|
|
80
|
-
throw new Error('unpadPkcs7 given empty bytes');
|
|
81
|
-
}
|
|
82
|
-
var r = t[t.length - 1];
|
|
83
|
-
if (r > t.length) {
|
|
84
|
-
throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`);
|
|
85
|
-
}
|
|
86
|
-
return new Uint8Array(t.buffer, t.byteOffset, t.length - r);
|
|
87
|
-
};
|
|
88
|
-
exports.unpadRandomMax16 = unpadRandomMax16;
|
|
89
|
-
const encodeWAMessage = (message) => ((0, exports.writeRandomPadMax16)(WAProto_1.proto.Message.encode(message).finish()));
|
|
90
|
-
exports.encodeWAMessage = encodeWAMessage;
|
|
91
|
-
const generateRegistrationId = () => {
|
|
92
|
-
return Uint16Array.from((0, crypto_1.randomBytes)(2))[0] & 16383;
|
|
93
|
-
};
|
|
94
|
-
exports.generateRegistrationId = generateRegistrationId;
|
|
95
|
-
const encodeBigEndian = (e, t = 4) => {
|
|
96
|
-
let r = e;
|
|
97
|
-
const a = new Uint8Array(t);
|
|
98
|
-
for (let i = t - 1; i >= 0; i--) {
|
|
99
|
-
a[i] = 255 & r;
|
|
100
|
-
r >>>= 8;
|
|
101
|
-
}
|
|
102
|
-
return a;
|
|
103
|
-
};
|
|
104
|
-
exports.encodeBigEndian = encodeBigEndian;
|
|
105
|
-
const toNumber = (t) => ((typeof t === 'object' && t) ? ('toNumber' in t ? t.toNumber() : t.low) : t);
|
|
106
|
-
exports.toNumber = toNumber;
|
|
107
|
-
/** unix timestamp of a date in seconds */
|
|
108
|
-
const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000);
|
|
109
|
-
exports.unixTimestampSeconds = unixTimestampSeconds;
|
|
110
|
-
const debouncedTimeout = (intervalMs = 1000, task) => {
|
|
111
|
-
let timeout;
|
|
112
|
-
return {
|
|
113
|
-
start: (newIntervalMs, newTask) => {
|
|
114
|
-
task = newTask || task;
|
|
115
|
-
intervalMs = newIntervalMs || intervalMs;
|
|
116
|
-
timeout && clearTimeout(timeout);
|
|
117
|
-
timeout = setTimeout(() => task === null || task === void 0 ? void 0 : task(), intervalMs);
|
|
118
|
-
},
|
|
119
|
-
cancel: () => {
|
|
120
|
-
timeout && clearTimeout(timeout);
|
|
121
|
-
timeout = undefined;
|
|
122
|
-
},
|
|
123
|
-
setTask: (newTask) => task = newTask,
|
|
124
|
-
setInterval: (newInterval) => intervalMs = newInterval
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
exports.debouncedTimeout = debouncedTimeout;
|
|
128
|
-
const delay = (ms) => (0, exports.delayCancellable)(ms).delay;
|
|
129
|
-
exports.delay = delay;
|
|
130
|
-
const delayCancellable = (ms) => {
|
|
131
|
-
const stack = new Error().stack;
|
|
132
|
-
let timeout;
|
|
133
|
-
let reject;
|
|
134
|
-
const delay = new Promise((resolve, _reject) => {
|
|
135
|
-
timeout = setTimeout(resolve, ms);
|
|
136
|
-
reject = _reject;
|
|
137
|
-
});
|
|
138
|
-
const cancel = () => {
|
|
139
|
-
clearTimeout(timeout);
|
|
140
|
-
reject(new boom_1.Boom('Cancelled', {
|
|
141
|
-
statusCode: 500,
|
|
142
|
-
data: {
|
|
143
|
-
stack
|
|
144
|
-
}
|
|
145
|
-
}));
|
|
146
|
-
};
|
|
147
|
-
return { delay, cancel };
|
|
148
|
-
};
|
|
149
|
-
exports.delayCancellable = delayCancellable;
|
|
150
|
-
async function promiseTimeout(ms, promise) {
|
|
151
|
-
if (!ms) {
|
|
152
|
-
return new Promise(promise);
|
|
153
|
-
}
|
|
154
|
-
const stack = new Error().stack;
|
|
155
|
-
// Create a promise that rejects in <ms> milliseconds
|
|
156
|
-
const { delay, cancel } = (0, exports.delayCancellable)(ms);
|
|
157
|
-
const p = new Promise((resolve, reject) => {
|
|
158
|
-
delay
|
|
159
|
-
.then(() => reject(new boom_1.Boom('Timed Out', {
|
|
160
|
-
statusCode: Types_1.DisconnectReason.timedOut,
|
|
161
|
-
data: {
|
|
162
|
-
stack
|
|
163
|
-
}
|
|
164
|
-
})))
|
|
165
|
-
.catch(err => reject(err));
|
|
166
|
-
promise(resolve, reject);
|
|
167
|
-
})
|
|
168
|
-
.finally(cancel);
|
|
169
|
-
return p;
|
|
170
|
-
}
|
|
171
|
-
exports.promiseTimeout = promiseTimeout;
|
|
172
|
-
const generateMessageIDV2 = (userId) => {
|
|
173
|
-
const data = Buffer.alloc(8 + 20 + 16);
|
|
174
|
-
data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
|
|
175
|
-
if (userId) {
|
|
176
|
-
const id = (0, WABinary_1.jidDecode)(userId);
|
|
177
|
-
if (id === null || id === void 0 ? void 0 : id.user) {
|
|
178
|
-
data.write(id.user, 8);
|
|
179
|
-
data.write('@c.us', 8 + id.user.length);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const random = (0, crypto_1.randomBytes)(16);
|
|
183
|
-
random.copy(data, 28);
|
|
184
|
-
const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
|
|
185
|
-
return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
|
|
186
|
-
};
|
|
187
|
-
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
188
|
-
// generate a random ID to attach to a message
|
|
189
|
-
const generateMessageID = () => 'ILSYM-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
|
|
190
|
-
exports.generateMessageID = generateMessageID;
|
|
191
|
-
function bindWaitForEvent(ev, event) {
|
|
192
|
-
return async (check, timeoutMs) => {
|
|
193
|
-
let listener;
|
|
194
|
-
let closeListener;
|
|
195
|
-
await (promiseTimeout(timeoutMs, (resolve, reject) => {
|
|
196
|
-
closeListener = ({ connection, lastDisconnect }) => {
|
|
197
|
-
if (connection === 'close') {
|
|
198
|
-
reject((lastDisconnect === null || lastDisconnect === void 0 ? void 0 : lastDisconnect.error)
|
|
199
|
-
|| new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
ev.on('connection.update', closeListener);
|
|
203
|
-
listener = (update) => {
|
|
204
|
-
if (check(update)) {
|
|
205
|
-
resolve();
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
ev.on(event, listener);
|
|
209
|
-
})
|
|
210
|
-
.finally(() => {
|
|
211
|
-
ev.off(event, listener);
|
|
212
|
-
ev.off('connection.update', closeListener);
|
|
213
|
-
}));
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
exports.bindWaitForEvent = bindWaitForEvent;
|
|
217
|
-
const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
|
|
218
|
-
exports.bindWaitForConnectionUpdate = bindWaitForConnectionUpdate;
|
|
219
|
-
const printQRIfNecessaryListener = (ev, logger) => {
|
|
220
|
-
ev.on('connection.update', async ({ qr }) => {
|
|
221
|
-
if (qr) {
|
|
222
|
-
const QR = await import('qrcode-terminal')
|
|
223
|
-
.then(m => m.default || m)
|
|
224
|
-
.catch(() => {
|
|
225
|
-
logger.error('QR code terminal not added as dependency');
|
|
226
|
-
});
|
|
227
|
-
QR === null || QR === void 0 ? void 0 : QR.generate(qr, { small: true });
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
232
|
-
/**
|
|
233
|
-
* utility that fetches latest baileys version from the master branch.
|
|
234
|
-
* Use to ensure your WA connection is always on the latest version
|
|
235
|
-
*/
|
|
236
|
-
const fetchLatestWaWebVersion = async (options = {}) => {
|
|
237
|
-
try {
|
|
238
|
-
const defaultHeaders = {
|
|
239
|
-
'User-Agent':
|
|
240
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
241
|
-
'Accept': '*/*'
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const headers = { ...defaultHeaders, ...options.headers }
|
|
245
|
-
|
|
246
|
-
const response = await fetch_1('https://web.whatsapp.com/sw.js', {
|
|
247
|
-
method: 'GET',
|
|
248
|
-
headers
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
if (!response.ok) {
|
|
252
|
-
throw new Error(`Failed to fetch sw.js: ${response.status} ${response.statusText}`)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const data = await response.text()
|
|
256
|
-
const regex = /"client_revision":\s*(\d+)/ // regex cukup begini untuk Node
|
|
257
|
-
const match = data.match(regex)
|
|
258
|
-
|
|
259
|
-
if (!match || !match[1]) {
|
|
260
|
-
return {
|
|
261
|
-
version: baileysVersion,
|
|
262
|
-
isLatest: false,
|
|
263
|
-
error: { message: 'Client revision not found' }
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const clientRevision = match[1]
|
|
268
|
-
return {
|
|
269
|
-
version: [2, 3000, +clientRevision],
|
|
270
|
-
isLatest: true
|
|
271
|
-
}
|
|
272
|
-
} catch (error) {
|
|
273
|
-
return {
|
|
274
|
-
version: baileysVersion,
|
|
275
|
-
isLatest: false,
|
|
276
|
-
error
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
|
|
281
|
-
/**
|
|
282
|
-
* utility that fetches latest baileys version from the master branch.
|
|
283
|
-
* Use to ensure your WA connection is always on the latest version
|
|
284
|
-
*/
|
|
285
|
-
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
286
|
-
const URL = 'https://raw.githubusercontent.com/kiuur/bails/master/src/Defaults/baileys-version.json';
|
|
287
|
-
try {
|
|
288
|
-
const result = await axios_1.default.get(URL, {
|
|
289
|
-
...options,
|
|
290
|
-
responseType: 'json'
|
|
291
|
-
});
|
|
292
|
-
return {
|
|
293
|
-
version: result.data.version,
|
|
294
|
-
isLatest: true
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
return {
|
|
299
|
-
version: baileys_version_json_1.version,
|
|
300
|
-
isLatest: false,
|
|
301
|
-
error
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
|
|
306
|
-
/** unique message tag prefix for MD clients */
|
|
307
|
-
const generateMdTagPrefix = () => {
|
|
308
|
-
const bytes = (0, crypto_1.randomBytes)(4);
|
|
309
|
-
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
|
|
310
|
-
};
|
|
311
|
-
exports.generateMdTagPrefix = generateMdTagPrefix;
|
|
312
|
-
const STATUS_MAP = {
|
|
313
|
-
'played': WAProto_1.proto.WebMessageInfo.Status.PLAYED,
|
|
314
|
-
'read': WAProto_1.proto.WebMessageInfo.Status.READ,
|
|
315
|
-
'read-self': WAProto_1.proto.WebMessageInfo.Status.READ
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Given a type of receipt, returns what the new status of the message should be
|
|
319
|
-
* @param type type from receipt
|
|
320
|
-
*/
|
|
321
|
-
const getStatusFromReceiptType = (type) => {
|
|
322
|
-
const status = STATUS_MAP[type];
|
|
323
|
-
if (typeof type === 'undefined') {
|
|
324
|
-
return WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK;
|
|
325
|
-
}
|
|
326
|
-
return status;
|
|
327
|
-
};
|
|
328
|
-
exports.getStatusFromReceiptType = getStatusFromReceiptType;
|
|
329
|
-
const CODE_MAP = {
|
|
330
|
-
conflict: Types_1.DisconnectReason.connectionReplaced
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* Stream errors generally provide a reason, map that to a baileys DisconnectReason
|
|
334
|
-
* @param reason the string reason given, eg. "conflict"
|
|
335
|
-
*/
|
|
336
|
-
const getErrorCodeFromStreamError = (node) => {
|
|
337
|
-
const [reasonNode] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
338
|
-
let reason = (reasonNode === null || reasonNode === void 0 ? void 0 : reasonNode.tag) || 'unknown';
|
|
339
|
-
const statusCode = +(node.attrs.code || CODE_MAP[reason] || Types_1.DisconnectReason.badSession);
|
|
340
|
-
if (statusCode === Types_1.DisconnectReason.restartRequired) {
|
|
341
|
-
reason = 'restart required';
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
reason,
|
|
345
|
-
statusCode
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
exports.getErrorCodeFromStreamError = getErrorCodeFromStreamError;
|
|
349
|
-
const getCallStatusFromNode = ({ tag, attrs }) => {
|
|
350
|
-
let status;
|
|
351
|
-
switch (tag) {
|
|
352
|
-
case 'offer':
|
|
353
|
-
case 'offer_notice':
|
|
354
|
-
status = 'offer';
|
|
355
|
-
break;
|
|
356
|
-
case 'terminate':
|
|
357
|
-
if (attrs.reason === 'timeout') {
|
|
358
|
-
status = 'timeout';
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
status = 'reject';
|
|
362
|
-
}
|
|
363
|
-
break;
|
|
364
|
-
case 'reject':
|
|
365
|
-
status = 'reject';
|
|
366
|
-
break;
|
|
367
|
-
case 'accept':
|
|
368
|
-
status = 'accept';
|
|
369
|
-
break;
|
|
370
|
-
default:
|
|
371
|
-
status = 'ringing';
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
return status;
|
|
375
|
-
};
|
|
376
|
-
exports.getCallStatusFromNode = getCallStatusFromNode;
|
|
377
|
-
const UNEXPECTED_SERVER_CODE_TEXT = 'Unexpected server response: ';
|
|
378
|
-
const getCodeFromWSError = (error) => {
|
|
379
|
-
var _a, _b, _c;
|
|
380
|
-
let statusCode = 500;
|
|
381
|
-
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes(UNEXPECTED_SERVER_CODE_TEXT)) {
|
|
382
|
-
const code = +(error === null || error === void 0 ? void 0 : error.message.slice(UNEXPECTED_SERVER_CODE_TEXT.length));
|
|
383
|
-
if (!Number.isNaN(code) && code >= 400) {
|
|
384
|
-
statusCode = code;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
else if (((_b = error === null || error === void 0 ? void 0 : error.code) === null || _b === void 0 ? void 0 : _b.startsWith('E'))
|
|
388
|
-
|| ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('timed out'))) { // handle ETIMEOUT, ENOTFOUND etc
|
|
389
|
-
statusCode = 408;
|
|
390
|
-
}
|
|
391
|
-
return statusCode;
|
|
392
|
-
};
|
|
393
|
-
exports.getCodeFromWSError = getCodeFromWSError;
|
|
394
|
-
/**
|
|
395
|
-
* Is the given platform WA business
|
|
396
|
-
* @param platform AuthenticationCreds.platform
|
|
397
|
-
*/
|
|
398
|
-
const isWABusinessPlatform = (platform) => {
|
|
399
|
-
return platform === 'smbi' || platform === 'smba';
|
|
400
|
-
};
|
|
401
|
-
exports.isWABusinessPlatform = isWABusinessPlatform;
|
|
402
|
-
function trimUndefined(obj) {
|
|
403
|
-
for (const key in obj) {
|
|
404
|
-
if (typeof obj[key] === 'undefined') {
|
|
405
|
-
delete obj[key];
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return obj;
|
|
409
|
-
}
|
|
410
|
-
exports.trimUndefined = trimUndefined;
|
|
411
|
-
const CROCKFORD_CHARACTERS = '123456789ABCDEFGHJKLMNPQRSTVWXYZ';
|
|
412
|
-
function bytesToCrockford(buffer) {
|
|
413
|
-
let value = 0;
|
|
414
|
-
let bitCount = 0;
|
|
415
|
-
const crockford = [];
|
|
416
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
417
|
-
value = (value << 8) | (buffer[i] & 0xff);
|
|
418
|
-
bitCount += 8;
|
|
419
|
-
while (bitCount >= 5) {
|
|
420
|
-
crockford.push(CROCKFORD_CHARACTERS.charAt((value >>> (bitCount - 5)) & 31));
|
|
421
|
-
bitCount -= 5;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (bitCount > 0) {
|
|
425
|
-
crockford.push(CROCKFORD_CHARACTERS.charAt((value << (5 - bitCount)) & 31));
|
|
426
|
-
}
|
|
427
|
-
return crockford.join('');
|
|
428
|
-
}
|
|
429
|
-
exports.bytesToCrockford = bytesToCrockford;
|
|
430
|
-
const encodeNewsletterMessage = (message) => {
|
|
431
|
-
return WAProto_1.proto.Message.encode(message).finish()
|
|
432
|
-
}
|
|
433
|
-
exports.encodeNewsletterMessage = encodeNewsletterMessage;
|
package/lib/Utils/history.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { proto } from '../../WAProto';
|
|
3
|
-
import { Chat, Contact } from '../Types';
|
|
4
|
-
export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<proto.HistorySync>;
|
|
5
|
-
export declare const processHistoryMessage: (item: proto.IHistorySync) => {
|
|
6
|
-
chats: Chat[];
|
|
7
|
-
contacts: Contact[];
|
|
8
|
-
messages: proto.IWebMessageInfo[];
|
|
9
|
-
};
|
|
10
|
-
export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<{
|
|
11
|
-
chats: Chat[];
|
|
12
|
-
contacts: Contact[];
|
|
13
|
-
messages: proto.IWebMessageInfo[];
|
|
14
|
-
}>;
|
|
15
|
-
export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification | null | undefined;
|
package/lib/Utils/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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';
|
|
@@ -1,21 +0,0 @@
|
|
|
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>;
|
package/lib/Utils/logger.d.ts
DELETED
package/lib/Utils/lt-hash.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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,116 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import { Boom } from '@hapi/boom';
|
|
5
|
-
import { AxiosRequestConfig } from 'axios';
|
|
6
|
-
import type { Logger } from 'pino';
|
|
7
|
-
import { Readable, Transform } from 'stream';
|
|
8
|
-
import { URL } from 'url';
|
|
9
|
-
import { proto } from '../../WAProto';
|
|
10
|
-
import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
|
|
11
|
-
import { BinaryNode } from '../WABinary';
|
|
12
|
-
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
13
|
-
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
14
|
-
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
|
|
15
|
-
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
16
|
-
buffer: Buffer;
|
|
17
|
-
original: {
|
|
18
|
-
width: number | undefined;
|
|
19
|
-
height: number | undefined;
|
|
20
|
-
};
|
|
21
|
-
}>;
|
|
22
|
-
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
23
|
-
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
24
|
-
img: Buffer;
|
|
25
|
-
}>;
|
|
26
|
-
/** gets the SHA256 of the given media message */
|
|
27
|
-
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
|
|
28
|
-
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
31
|
-
*/
|
|
32
|
-
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger): Promise<Uint8Array | undefined>;
|
|
33
|
-
export declare const toReadable: (buffer: Buffer) => Readable;
|
|
34
|
-
export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
|
|
35
|
-
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
|
|
36
|
-
readonly stream: Readable;
|
|
37
|
-
readonly type: "buffer";
|
|
38
|
-
} | {
|
|
39
|
-
readonly stream: Readable;
|
|
40
|
-
readonly type: "readable";
|
|
41
|
-
} | {
|
|
42
|
-
readonly stream: Readable;
|
|
43
|
-
readonly type: "remote";
|
|
44
|
-
} | {
|
|
45
|
-
readonly stream: import("fs").ReadStream;
|
|
46
|
-
readonly type: "file";
|
|
47
|
-
}>;
|
|
48
|
-
/** generates a thumbnail for a given media, if required */
|
|
49
|
-
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
50
|
-
logger?: Logger;
|
|
51
|
-
}): Promise<{
|
|
52
|
-
thumbnail: string | undefined;
|
|
53
|
-
originalImageDimensions: {
|
|
54
|
-
width: number;
|
|
55
|
-
height: number;
|
|
56
|
-
} | undefined;
|
|
57
|
-
}>;
|
|
58
|
-
export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
|
|
59
|
-
isStream?: true;
|
|
60
|
-
}) => Promise<Readable>;
|
|
61
|
-
type EncryptedStreamOptions = {
|
|
62
|
-
saveOriginalFileIfRequired?: boolean;
|
|
63
|
-
logger?: Logger;
|
|
64
|
-
opts?: AxiosRequestConfig;
|
|
65
|
-
};
|
|
66
|
-
export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
67
|
-
mediaKey: undefined;
|
|
68
|
-
encWriteStream: Buffer;
|
|
69
|
-
fileLength: number;
|
|
70
|
-
fileSha256: Buffer;
|
|
71
|
-
fileEncSha256: undefined;
|
|
72
|
-
bodyPath: string | undefined;
|
|
73
|
-
didSaveToTmpPath: boolean;
|
|
74
|
-
}>;
|
|
75
|
-
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
76
|
-
mediaKey: Buffer;
|
|
77
|
-
encWriteStream: Readable;
|
|
78
|
-
bodyPath: string | undefined;
|
|
79
|
-
mac: Buffer;
|
|
80
|
-
fileEncSha256: Buffer;
|
|
81
|
-
fileSha256: Buffer;
|
|
82
|
-
fileLength: number;
|
|
83
|
-
didSaveToTmpPath: boolean;
|
|
84
|
-
}>;
|
|
85
|
-
export type MediaDownloadOptions = {
|
|
86
|
-
startByte?: number;
|
|
87
|
-
endByte?: number;
|
|
88
|
-
options?: AxiosRequestConfig<any>;
|
|
89
|
-
};
|
|
90
|
-
export declare const getUrlFromDirectPath: (directPath: string) => string;
|
|
91
|
-
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
|
|
92
|
-
/**
|
|
93
|
-
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
|
|
94
|
-
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
|
|
95
|
-
* */
|
|
96
|
-
export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<Transform>;
|
|
97
|
-
export declare function extensionForMediaMessage(message: WAMessageContent): string;
|
|
98
|
-
export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
|
|
99
|
-
/**
|
|
100
|
-
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
101
|
-
*/
|
|
102
|
-
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
|
|
103
|
-
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
104
|
-
key: proto.IMessageKey;
|
|
105
|
-
media?: {
|
|
106
|
-
ciphertext: Uint8Array;
|
|
107
|
-
iv: Uint8Array;
|
|
108
|
-
} | undefined;
|
|
109
|
-
error?: Boom<any> | undefined;
|
|
110
|
-
};
|
|
111
|
-
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
112
|
-
ciphertext: Uint8Array;
|
|
113
|
-
iv: Uint8Array;
|
|
114
|
-
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
|
|
115
|
-
export declare const getStatusCodeForMediaRetry: (code: number) => any;
|
|
116
|
-
export {};
|