@hbmodsofc/baileys 1.7.8 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +8 -12
- package/lib/Defaults/index.js +124 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +39 -28
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +2 -9
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +16 -47
- package/lib/Signal/libsignal.d.ts +3 -7
- package/lib/Signal/libsignal.js +39 -224
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
- package/lib/Socket/business.d.ts +78 -94
- package/lib/Socket/business.js +11 -130
- package/lib/Socket/chats.d.ts +233 -63
- package/lib/Socket/chats.js +184 -234
- package/lib/Socket/groups.d.ts +41 -62
- package/lib/Socket/groups.js +64 -76
- package/lib/Socket/hbmods.d.ts +253 -0
- package/lib/Socket/hbmods.js +1 -0
- package/lib/Socket/index.d.ts +83 -129
- package/lib/Socket/index.js +6 -13
- package/lib/Socket/messages-recv.d.ts +48 -59
- package/lib/Socket/messages-recv.js +371 -516
- package/lib/Socket/messages-send.d.ts +67 -86
- package/lib/Socket/messages-send.js +1 -1091
- package/lib/Socket/newsletter.d.ts +64 -76
- package/lib/Socket/newsletter.js +1 -184
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +13 -19
- package/lib/Socket/socket.js +1 -805
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Auth.d.ts +10 -4
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +9 -29
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +14 -55
- package/lib/Types/GroupMetadata.d.ts +5 -15
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +49 -75
- package/lib/Types/Message.js +7 -10
- package/lib/Types/Newsletter.d.ts +98 -129
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -29
- package/lib/Types/Socket.d.ts +22 -48
- package/lib/Types/State.d.ts +2 -13
- package/lib/Types/State.js +0 -12
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +3 -10
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +102 -378
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +13 -19
- package/lib/Utils/chat-utils.d.ts +22 -21
- package/lib/Utils/chat-utils.js +154 -201
- package/lib/Utils/crypto.d.ts +19 -18
- package/lib/Utils/crypto.js +37 -78
- package/lib/Utils/decode-wa-message.d.ts +7 -34
- package/lib/Utils/decode-wa-message.js +66 -138
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +43 -81
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +133 -128
- package/lib/Utils/history.d.ts +5 -9
- package/lib/Utils/history.js +23 -17
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +12 -40
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +24 -23
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +2 -3
- package/lib/Utils/messages-media.d.ts +41 -37
- package/lib/Utils/messages-media.js +368 -252
- package/lib/Utils/messages.d.ts +15 -13
- package/lib/Utils/messages.js +261 -274
- package/lib/Utils/noise-handler.d.ts +15 -13
- package/lib/Utils/noise-handler.js +26 -20
- package/lib/Utils/process-message.d.ts +8 -9
- package/lib/Utils/process-message.js +93 -157
- package/lib/Utils/signal.d.ts +5 -6
- package/lib/Utils/signal.js +29 -37
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.js +7 -12
- package/lib/Utils/validate-connection.d.ts +6 -5
- package/lib/Utils/validate-connection.js +97 -39
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +14 -28
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +7 -4
- package/lib/WABinary/generic-utils.js +125 -40
- package/lib/WABinary/jid-utils.d.ts +8 -13
- package/lib/WABinary/jid-utils.js +16 -27
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/constants.js +2359 -2252
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAM/encode.js +11 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +15 -19
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -104
- package/WAProto/index.js +0 -37306
- package/lib/Signal/lid-mapping.d.ts +0 -26
- package/lib/Signal/lid-mapping.js +0 -146
- package/lib/Socket/communities.d.ts +0 -232
- package/lib/Socket/communities.js +0 -402
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.d.ts +0 -24
- package/lib/Types/Bussines.js +0 -2
- package/lib/Utils/lidToJid-test.d.ts +0 -11
- package/lib/Utils/lidToJid-test.js +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -81
- package/lib/Utils/message-retry-manager.js +0 -152
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
|
@@ -1,37 +1,4 @@
|
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getUrlInfo = void 0;
|
|
37
4
|
const messages_1 = require("./messages");
|
|
@@ -53,11 +20,12 @@ const getUrlInfo = async (text, opts = {
|
|
|
53
20
|
thumbnailWidth: THUMBNAIL_WIDTH_PX,
|
|
54
21
|
fetchOpts: { timeout: 3000 }
|
|
55
22
|
}) => {
|
|
23
|
+
var _a;
|
|
56
24
|
try {
|
|
57
25
|
// retries
|
|
58
26
|
const retries = 0;
|
|
59
27
|
const maxRetry = 5;
|
|
60
|
-
const { getLinkPreview } = await
|
|
28
|
+
const { getLinkPreview } = await import('link-preview-js');
|
|
61
29
|
let previewLink = text;
|
|
62
30
|
if (!text.startsWith('https://') && !text.startsWith('http://')) {
|
|
63
31
|
previewLink = 'https://' + previewLink;
|
|
@@ -71,9 +39,9 @@ const getUrlInfo = async (text, opts = {
|
|
|
71
39
|
if (retries >= maxRetry) {
|
|
72
40
|
return false;
|
|
73
41
|
}
|
|
74
|
-
if (forwardedURLObj.hostname === urlObj.hostname
|
|
75
|
-
forwardedURLObj.hostname === 'www.' + urlObj.hostname
|
|
76
|
-
'www.' + forwardedURLObj.hostname === urlObj.hostname) {
|
|
42
|
+
if (forwardedURLObj.hostname === urlObj.hostname
|
|
43
|
+
|| forwardedURLObj.hostname === 'www.' + urlObj.hostname
|
|
44
|
+
|| 'www.' + forwardedURLObj.hostname === urlObj.hostname) {
|
|
77
45
|
retries + 1;
|
|
78
46
|
return true;
|
|
79
47
|
}
|
|
@@ -98,15 +66,19 @@ const getUrlInfo = async (text, opts = {
|
|
|
98
66
|
mediaTypeOverride: 'thumbnail-link',
|
|
99
67
|
options: opts.fetchOpts
|
|
100
68
|
});
|
|
101
|
-
urlInfo.jpegThumbnail = imageMessage
|
|
69
|
+
urlInfo.jpegThumbnail = (imageMessage === null || imageMessage === void 0 ? void 0 : imageMessage.jpegThumbnail)
|
|
70
|
+
? Buffer.from(imageMessage.jpegThumbnail)
|
|
71
|
+
: undefined;
|
|
102
72
|
urlInfo.highQualityThumbnail = imageMessage || undefined;
|
|
103
73
|
}
|
|
104
74
|
else {
|
|
105
75
|
try {
|
|
106
|
-
urlInfo.jpegThumbnail = image
|
|
76
|
+
urlInfo.jpegThumbnail = image
|
|
77
|
+
? (await getCompressedJpegThumbnail(image, opts)).buffer
|
|
78
|
+
: undefined;
|
|
107
79
|
}
|
|
108
80
|
catch (error) {
|
|
109
|
-
opts.logger
|
|
81
|
+
(_a = opts.logger) === null || _a === void 0 ? void 0 : _a.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
|
|
110
82
|
}
|
|
111
83
|
}
|
|
112
84
|
return urlInfo;
|
package/lib/Utils/logger.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
child(obj: Record<string, unknown>): ILogger;
|
|
5
|
-
trace(obj: unknown, msg?: string): void;
|
|
6
|
-
debug(obj: unknown, msg?: string): void;
|
|
7
|
-
info(obj: unknown, msg?: string): void;
|
|
8
|
-
warn(obj: unknown, msg?: string): void;
|
|
9
|
-
error(obj: unknown, msg?: string): void;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: P.Logger<never, boolean>;
|
|
1
|
+
declare const _default: import("pino").Logger<{
|
|
2
|
+
timestamp: () => string;
|
|
3
|
+
}>;
|
|
12
4
|
export default _default;
|
package/lib/Utils/lt-hash.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
declare class
|
|
1
|
+
declare class d {
|
|
2
2
|
salt: string;
|
|
3
3
|
constructor(e: string);
|
|
4
|
-
add(e:
|
|
5
|
-
subtract(e:
|
|
6
|
-
subtractThenAdd(e:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
10
|
}
|
|
11
|
-
export declare const LT_HASH_ANTI_TAMPERING:
|
|
11
|
+
export declare const LT_HASH_ANTI_TAMPERING: d;
|
|
12
12
|
export {};
|
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -8,43 +8,44 @@ const crypto_1 = require("./crypto");
|
|
|
8
8
|
* if the same series of mutations was made sequentially.
|
|
9
9
|
*/
|
|
10
10
|
const o = 128;
|
|
11
|
-
class
|
|
11
|
+
class d {
|
|
12
12
|
constructor(e) {
|
|
13
13
|
this.salt = e;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
add(e, t) {
|
|
16
|
+
var r = this;
|
|
16
17
|
for (const item of t) {
|
|
17
|
-
e =
|
|
18
|
+
e = r._addSingle(e, item);
|
|
18
19
|
}
|
|
19
20
|
return e;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
subtract(e, t) {
|
|
23
|
+
var r = this;
|
|
22
24
|
for (const item of t) {
|
|
23
|
-
e =
|
|
25
|
+
e = r._subtractSingle(e, item);
|
|
24
26
|
}
|
|
25
27
|
return e;
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
subtractThenAdd(e, t, r) {
|
|
30
|
+
var n = this;
|
|
31
|
+
return n.add(n.subtract(e, r), t);
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
_addSingle(e, t) {
|
|
34
|
+
var r = this;
|
|
35
|
+
const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
36
|
+
return r.performPointwiseWithOverflow(e, n, ((e, t) => e + t));
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
_subtractSingle(e, t) {
|
|
39
|
+
var r = this;
|
|
40
|
+
const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
41
|
+
return r.performPointwiseWithOverflow(e, n, ((e, t) => e - t));
|
|
38
42
|
}
|
|
39
|
-
performPointwiseWithOverflow(e, t,
|
|
40
|
-
const n = new DataView(e);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const s = new DataView(out);
|
|
44
|
-
for (let offset = 0; offset < n.byteLength; offset += 2) {
|
|
45
|
-
s.setUint16(offset, op(n.getUint16(offset, true), i.getUint16(offset, true)), true);
|
|
43
|
+
performPointwiseWithOverflow(e, t, r) {
|
|
44
|
+
const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
|
|
45
|
+
for (let e = 0; e < n.byteLength; e += 2) {
|
|
46
|
+
s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0);
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
+
return a;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
exports.LT_HASH_ANTI_TAMPERING = new
|
|
51
|
+
exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const makeMutex: () => {
|
|
2
|
-
mutex<T>(code: () =>
|
|
2
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
3
3
|
};
|
|
4
4
|
export type Mutex = ReturnType<typeof makeMutex>;
|
|
5
5
|
export declare const makeKeyedMutex: () => {
|
|
6
|
-
mutex<T>(key: string, task: () =>
|
|
6
|
+
mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>;
|
|
7
7
|
};
|
package/lib/Utils/make-mutex.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeKeyedMutex = exports.makeMutex = void 0;
|
|
4
4
|
const makeMutex = () => {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
5
|
let task = Promise.resolve();
|
|
7
6
|
let taskTimeout;
|
|
8
7
|
return {
|
|
@@ -13,7 +12,7 @@ const makeMutex = () => {
|
|
|
13
12
|
try {
|
|
14
13
|
await task;
|
|
15
14
|
}
|
|
16
|
-
catch { }
|
|
15
|
+
catch (_a) { }
|
|
17
16
|
try {
|
|
18
17
|
// execute the current task
|
|
19
18
|
const result = await code();
|
|
@@ -26,7 +25,7 @@ const makeMutex = () => {
|
|
|
26
25
|
// we replace the existing task, appending the new piece of execution to it
|
|
27
26
|
// so the next task will have to wait for this one to finish
|
|
28
27
|
return task;
|
|
29
|
-
}
|
|
28
|
+
},
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
31
|
exports.makeMutex = makeMutex;
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
1
4
|
import { Boom } from '@hapi/boom';
|
|
2
|
-
import {
|
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
|
6
|
+
import type { Logger } from 'pino';
|
|
3
7
|
import { Readable, Transform } from 'stream';
|
|
4
8
|
import { URL } from 'url';
|
|
5
|
-
import { proto } from '../../WAProto
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { type BinaryNode } from '../WABinary';
|
|
9
|
-
import type { ILogger } from './logger';
|
|
9
|
+
import { proto } from '../../WAProto';
|
|
10
|
+
import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
|
|
11
|
+
import { BinaryNode } from '../WABinary';
|
|
10
12
|
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
11
|
-
export declare const getRawMediaUploadData: (media: WAMediaUpload, mediaType: MediaType, logger?: ILogger) => Promise<{
|
|
12
|
-
filePath: string;
|
|
13
|
-
fileSha256: Buffer<ArrayBufferLike>;
|
|
14
|
-
fileLength: number;
|
|
15
|
-
}>;
|
|
16
13
|
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
17
|
-
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType):
|
|
14
|
+
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
|
|
18
15
|
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
19
|
-
buffer:
|
|
16
|
+
buffer: Buffer;
|
|
20
17
|
original: {
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
18
|
+
width: number | undefined;
|
|
19
|
+
height: number | undefined;
|
|
23
20
|
};
|
|
24
21
|
}>;
|
|
25
22
|
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
26
|
-
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload
|
|
27
|
-
|
|
28
|
-
height: number;
|
|
29
|
-
}) => Promise<{
|
|
30
|
-
img: Buffer<ArrayBufferLike>;
|
|
23
|
+
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
24
|
+
img: Buffer;
|
|
31
25
|
}>;
|
|
32
26
|
/** gets the SHA256 of the given media message */
|
|
33
27
|
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
|
|
@@ -35,9 +29,9 @@ export declare function getAudioDuration(buffer: Buffer | string | Readable): Pr
|
|
|
35
29
|
/**
|
|
36
30
|
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
37
31
|
*/
|
|
38
|
-
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?:
|
|
32
|
+
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger): Promise<Uint8Array | undefined>;
|
|
39
33
|
export declare const toReadable: (buffer: Buffer) => Readable;
|
|
40
|
-
export declare const toBuffer: (stream: Readable) => Promise<Buffer
|
|
34
|
+
export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
|
|
41
35
|
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
|
|
42
36
|
readonly stream: Readable;
|
|
43
37
|
readonly type: "buffer";
|
|
@@ -53,7 +47,7 @@ export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig)
|
|
|
53
47
|
}>;
|
|
54
48
|
/** generates a thumbnail for a given media, if required */
|
|
55
49
|
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
56
|
-
logger?:
|
|
50
|
+
logger?: Logger;
|
|
57
51
|
}): Promise<{
|
|
58
52
|
thumbnail: string | undefined;
|
|
59
53
|
originalImageDimensions: {
|
|
@@ -66,22 +60,32 @@ export declare const getHttpStream: (url: string | URL, options?: AxiosRequestCo
|
|
|
66
60
|
}) => Promise<Readable>;
|
|
67
61
|
type EncryptedStreamOptions = {
|
|
68
62
|
saveOriginalFileIfRequired?: boolean;
|
|
69
|
-
logger?:
|
|
63
|
+
logger?: Logger;
|
|
70
64
|
opts?: AxiosRequestConfig;
|
|
71
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
|
+
}>;
|
|
72
75
|
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
73
|
-
mediaKey: Buffer
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
mac: Buffer
|
|
77
|
-
fileEncSha256: Buffer
|
|
78
|
-
fileSha256: Buffer
|
|
76
|
+
mediaKey: Buffer;
|
|
77
|
+
encWriteStream: Readable;
|
|
78
|
+
bodyPath: string | undefined;
|
|
79
|
+
mac: Buffer;
|
|
80
|
+
fileEncSha256: Buffer;
|
|
81
|
+
fileSha256: Buffer;
|
|
79
82
|
fileLength: number;
|
|
83
|
+
didSaveToTmpPath: boolean;
|
|
80
84
|
}>;
|
|
81
85
|
export type MediaDownloadOptions = {
|
|
82
86
|
startByte?: number;
|
|
83
87
|
endByte?: number;
|
|
84
|
-
options?: AxiosRequestConfig<
|
|
88
|
+
options?: AxiosRequestConfig<any>;
|
|
85
89
|
};
|
|
86
90
|
export declare const getUrlFromDirectPath: (directPath: string) => string;
|
|
87
91
|
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
|
|
@@ -95,18 +99,18 @@ export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logg
|
|
|
95
99
|
/**
|
|
96
100
|
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
97
101
|
*/
|
|
98
|
-
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) =>
|
|
102
|
+
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
|
|
99
103
|
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
100
|
-
key:
|
|
104
|
+
key: proto.IMessageKey;
|
|
101
105
|
media?: {
|
|
102
106
|
ciphertext: Uint8Array;
|
|
103
107
|
iv: Uint8Array;
|
|
104
|
-
};
|
|
105
|
-
error?: Boom;
|
|
108
|
+
} | undefined;
|
|
109
|
+
error?: Boom<any> | undefined;
|
|
106
110
|
};
|
|
107
111
|
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
108
112
|
ciphertext: Uint8Array;
|
|
109
113
|
iv: Uint8Array;
|
|
110
|
-
}, mediaKey: Uint8Array, msgId: string) =>
|
|
111
|
-
export declare const getStatusCodeForMediaRetry: (code: number) =>
|
|
114
|
+
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
|
|
115
|
+
export declare const getStatusCodeForMediaRetry: (code: number) => any;
|
|
112
116
|
export {};
|