alipclutch-baileys 8.3.0 → 8.4.1
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 +3 -1
- package/README.md +10 -9
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +55057 -0
- package/WAProto/index.js +56887 -17535
- package/WAProto/index.ts.ts +53473 -0
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +16 -7
- package/lib/Defaults/index.js +90 -119
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/types.d.ts +0 -1
- package/lib/Socket/Client/types.js +0 -1
- package/lib/Socket/Client/websocket.d.ts +0 -1
- package/lib/Socket/Client/websocket.js +0 -1
- package/lib/Socket/business.d.ts +59 -58
- package/lib/Socket/chats.d.ts +45 -230
- package/lib/Socket/chats.js +139 -238
- package/lib/Socket/groups.d.ts +41 -32
- package/lib/Socket/groups.js +38 -23
- package/lib/Socket/index.d.ts +63 -64
- package/lib/Socket/index.js +2 -3
- package/lib/Socket/messages-recv.js +9 -65
- package/lib/Socket/messages-send.d.ts +49 -47
- package/lib/Socket/messages-send.js +584 -395
- package/lib/Socket/newsletter.d.ts +39 -37
- package/lib/Socket/newsletter.js +88 -123
- package/lib/Socket/setup.js +433 -0
- package/lib/Socket/{dugong.d.ts → setup.ts} +17 -52
- package/lib/Socket/socket.d.ts +10 -10
- package/lib/Socket/socket.js +62 -38
- package/lib/Socket/usync.d.ts +3 -4
- package/lib/Socket/usync.js +0 -1
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +24 -24
- package/lib/Store/make-in-memory-store.js +26 -14
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +0 -7
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +14 -7
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +44 -2
- package/lib/Types/GroupMetadata.d.ts +11 -2
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +148 -21
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +73 -97
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Types/Socket.d.ts +17 -9
- package/lib/Types/index.d.ts +8 -1
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +6 -13
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +15 -16
- package/lib/Utils/chat-utils.js +36 -35
- package/lib/Utils/crypto.d.ts +15 -16
- package/lib/Utils/crypto.js +71 -29
- package/lib/Utils/decode-wa-message.d.ts +22 -6
- package/lib/Utils/decode-wa-message.js +65 -56
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +11 -7
- package/lib/Utils/generics.d.ts +17 -20
- package/lib/Utils/generics.js +95 -75
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +4 -6
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -3
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -24
- package/lib/Utils/messages-media.js +272 -111
- package/lib/Utils/messages.d.ts +13 -10
- package/lib/Utils/messages.js +323 -50
- package/lib/Utils/noise-handler.d.ts +10 -12
- package/lib/Utils/noise-handler.js +18 -23
- package/lib/Utils/process-message.d.ts +5 -4
- package/lib/Utils/process-message.js +108 -25
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +26 -26
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
- package/lib/Utils/use-multi-file-auth-state.js +51 -6
- package/lib/Utils/validate-connection.d.ts +3 -4
- package/lib/Utils/validate-connection.js +90 -66
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +26 -13
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +137 -152
- package/lib/WABinary/generic-utils.d.ts +1 -4
- package/lib/WABinary/generic-utils.js +37 -125
- package/lib/WABinary/jid-utils.d.ts +11 -5
- package/lib/WABinary/jid-utils.js +28 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +27 -15
- package/package.json +18 -31
- package/engine-requirements.js +0 -10
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- 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/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/dugong.js +0 -483
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-cache-manager-store.js +0 -83
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { ILogger } from './logger';
|
|
3
3
|
import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
|
|
4
4
|
export type URLGenerationOptions = {
|
|
5
5
|
thumbnailWidth: number;
|
|
@@ -10,7 +10,7 @@ export type URLGenerationOptions = {
|
|
|
10
10
|
headers?: AxiosRequestConfig<{}>['headers'];
|
|
11
11
|
};
|
|
12
12
|
uploadImage?: WAMediaUploadFunction;
|
|
13
|
-
logger?:
|
|
13
|
+
logger?: ILogger;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
@@ -1,4 +1,37 @@
|
|
|
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.getUrlInfo = void 0;
|
|
4
37
|
const messages_1 = require("./messages");
|
|
@@ -25,7 +58,7 @@ const getUrlInfo = async (text, opts = {
|
|
|
25
58
|
// retries
|
|
26
59
|
const retries = 0;
|
|
27
60
|
const maxRetry = 5;
|
|
28
|
-
const { getLinkPreview } = await
|
|
61
|
+
const { getLinkPreview } = await Promise.resolve().then(() => __importStar(require('link-preview-js')));
|
|
29
62
|
let previewLink = text;
|
|
30
63
|
if (!text.startsWith('https://') && !text.startsWith('http://')) {
|
|
31
64
|
previewLink = 'https://' + previewLink;
|
package/lib/Utils/logger.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface ILogger {
|
|
2
|
+
level: string;
|
|
3
|
+
child(obj: Record<string, unknown>): ILogger;
|
|
4
|
+
trace(obj: unknown, msg?: string): any;
|
|
5
|
+
debug(obj: unknown, msg?: string): any;
|
|
6
|
+
info(obj: unknown, msg?: string): any;
|
|
7
|
+
warn(obj: unknown, msg?: string): any;
|
|
8
|
+
error(obj: unknown, msg?: string): any;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: import("pino").Logger<never, boolean>;
|
|
4
11
|
export default _default;
|
package/lib/Utils/lt-hash.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ declare class d {
|
|
|
4
4
|
add(e: any, t: any): any;
|
|
5
5
|
subtract(e: any, t: any): any;
|
|
6
6
|
subtractThenAdd(e: any, t: any, r: any): any;
|
|
7
|
-
_addSingle(e: any, t: any): ArrayBuffer
|
|
8
|
-
_subtractSingle(e: any, t: any): ArrayBuffer
|
|
7
|
+
_addSingle(e: any, t: any): Promise<ArrayBuffer>;
|
|
8
|
+
_subtractSingle(e: any, t: any): Promise<ArrayBuffer>;
|
|
9
9
|
performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer;
|
|
10
10
|
}
|
|
11
11
|
export declare const LT_HASH_ANTI_TAMPERING: d;
|
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -30,15 +30,15 @@ class d {
|
|
|
30
30
|
var n = this;
|
|
31
31
|
return n.add(n.subtract(e, r), t);
|
|
32
32
|
}
|
|
33
|
-
_addSingle(e, t) {
|
|
33
|
+
async _addSingle(e, t) {
|
|
34
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));
|
|
35
|
+
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
36
|
+
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e + t));
|
|
37
37
|
}
|
|
38
|
-
_subtractSingle(e, t) {
|
|
38
|
+
async _subtractSingle(e, t) {
|
|
39
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));
|
|
40
|
+
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
41
|
+
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e - t));
|
|
42
42
|
}
|
|
43
43
|
performPointwiseWithOverflow(e, t, r) {
|
|
44
44
|
const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const makeMutex: () => {
|
|
2
|
-
mutex<T>(code: () => T |
|
|
2
|
+
mutex<T>(code: () => Promise<T> | 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: () => T |
|
|
6
|
+
mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
|
|
7
7
|
};
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { Boom } from '@hapi/boom';
|
|
5
2
|
import { AxiosRequestConfig } from 'axios';
|
|
6
|
-
import type { Logger } from 'pino';
|
|
7
3
|
import { Readable, Transform } from 'stream';
|
|
8
4
|
import { URL } from 'url';
|
|
9
5
|
import { proto } from '../../WAProto';
|
|
10
6
|
import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
|
|
11
7
|
import { BinaryNode } from '../WABinary';
|
|
8
|
+
import { ILogger } from './logger';
|
|
12
9
|
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
13
10
|
/** 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
|
|
11
|
+
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
|
|
12
|
+
export declare function uploadFile(buffer: Buffer, logger?: ILogger): Promise<string>;
|
|
13
|
+
export declare function vid2jpg(videoUrl: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Originally written by Techwiz (https://github.com/techwiz37)
|
|
16
|
+
* Modified for customization and improvements
|
|
17
|
+
*/
|
|
18
|
+
export declare const extractVideoThumb: (videoPath: string) => Promise<Buffer<ArrayBufferLike>>;
|
|
15
19
|
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
16
|
-
buffer: Buffer
|
|
20
|
+
buffer: Buffer<ArrayBufferLike>;
|
|
17
21
|
original: {
|
|
18
|
-
width: number
|
|
19
|
-
height: number
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
20
24
|
};
|
|
21
25
|
}>;
|
|
22
26
|
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
23
27
|
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
24
|
-
img: Buffer
|
|
28
|
+
img: Buffer<ArrayBufferLike>;
|
|
25
29
|
}>;
|
|
26
30
|
/** gets the SHA256 of the given media message */
|
|
27
31
|
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
|
|
@@ -29,9 +33,9 @@ export declare function getAudioDuration(buffer: Buffer | string | Readable): Pr
|
|
|
29
33
|
/**
|
|
30
34
|
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
31
35
|
*/
|
|
32
|
-
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?:
|
|
36
|
+
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array<ArrayBuffer> | undefined>;
|
|
33
37
|
export declare const toReadable: (buffer: Buffer) => Readable;
|
|
34
|
-
export declare const toBuffer: (stream: Readable) => Promise<Buffer
|
|
38
|
+
export declare const toBuffer: (stream: Readable) => Promise<Buffer<ArrayBuffer>>;
|
|
35
39
|
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
|
|
36
40
|
readonly stream: Readable;
|
|
37
41
|
readonly type: "buffer";
|
|
@@ -47,7 +51,7 @@ export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig)
|
|
|
47
51
|
}>;
|
|
48
52
|
/** generates a thumbnail for a given media, if required */
|
|
49
53
|
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
50
|
-
logger?:
|
|
54
|
+
logger?: ILogger;
|
|
51
55
|
}): Promise<{
|
|
52
56
|
thumbnail: string | undefined;
|
|
53
57
|
originalImageDimensions: {
|
|
@@ -60,25 +64,25 @@ export declare const getHttpStream: (url: string | URL, options?: AxiosRequestCo
|
|
|
60
64
|
}) => Promise<Readable>;
|
|
61
65
|
type EncryptedStreamOptions = {
|
|
62
66
|
saveOriginalFileIfRequired?: boolean;
|
|
63
|
-
logger?:
|
|
67
|
+
logger?: ILogger;
|
|
64
68
|
opts?: AxiosRequestConfig;
|
|
65
69
|
};
|
|
66
70
|
export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
67
71
|
mediaKey: undefined;
|
|
68
|
-
encWriteStream: Buffer
|
|
72
|
+
encWriteStream: Buffer<ArrayBuffer>;
|
|
69
73
|
fileLength: number;
|
|
70
|
-
fileSha256: Buffer
|
|
74
|
+
fileSha256: Buffer<ArrayBufferLike>;
|
|
71
75
|
fileEncSha256: undefined;
|
|
72
76
|
bodyPath: string | undefined;
|
|
73
77
|
didSaveToTmpPath: boolean;
|
|
74
78
|
}>;
|
|
75
79
|
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
76
|
-
mediaKey: Buffer
|
|
80
|
+
mediaKey: Buffer<ArrayBufferLike>;
|
|
77
81
|
encWriteStream: Readable;
|
|
78
82
|
bodyPath: string | undefined;
|
|
79
|
-
mac: Buffer
|
|
80
|
-
fileEncSha256: Buffer
|
|
81
|
-
fileSha256: Buffer
|
|
83
|
+
mac: Buffer<ArrayBuffer>;
|
|
84
|
+
fileEncSha256: Buffer<ArrayBufferLike>;
|
|
85
|
+
fileSha256: Buffer<ArrayBufferLike>;
|
|
82
86
|
fileLength: number;
|
|
83
87
|
didSaveToTmpPath: boolean;
|
|
84
88
|
}>;
|
|
@@ -99,18 +103,18 @@ export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logg
|
|
|
99
103
|
/**
|
|
100
104
|
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
101
105
|
*/
|
|
102
|
-
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode
|
|
106
|
+
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => Promise<BinaryNode>;
|
|
103
107
|
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
104
|
-
key:
|
|
108
|
+
key: import("../Types").WAMessageKey;
|
|
105
109
|
media?: {
|
|
106
110
|
ciphertext: Uint8Array;
|
|
107
111
|
iv: Uint8Array;
|
|
108
|
-
}
|
|
109
|
-
error?: Boom
|
|
112
|
+
};
|
|
113
|
+
error?: Boom;
|
|
110
114
|
};
|
|
111
115
|
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
112
116
|
ciphertext: Uint8Array;
|
|
113
117
|
iv: Uint8Array;
|
|
114
|
-
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification
|
|
118
|
+
}, mediaKey: Uint8Array, msgId: string) => Promise<proto.MediaRetryNotification>;
|
|
115
119
|
export declare const getStatusCodeForMediaRetry: (code: number) => any;
|
|
116
120
|
export {};
|