mod-baileys 1.0.1 → 1.0.3
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 +21 -0
- package/README.md +13 -60
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +6 -6
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +5 -5
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +3 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +1 -1
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +2 -2
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +6 -6
- package/lib/Socket/index.d.ts +173 -0
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/luxu.d.ts +268 -0
- package/lib/Socket/{dew.js → luxu.js} +11 -11
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +10 -10
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +5 -8
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +4 -4
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +10 -9
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +2 -2
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +3 -3
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +7 -7
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +110 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Events.d.ts +157 -0
- package/lib/Types/GroupMetadata.d.ts +55 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/Message.d.ts +273 -0
- package/lib/Types/Message.js +1 -1
- package/lib/Types/Newsletter.d.ts +103 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Socket.d.ts +111 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/index.d.ts +57 -0
- package/lib/Types/index.js +12 -12
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +2 -2
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +7 -7
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +3 -3
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +4 -4
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +5 -5
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +6 -6
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +17 -17
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +1 -1
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/messages-media.d.ts +116 -0
- package/lib/Utils/messages-media.js +80 -30
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +8 -8
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +4 -4
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +7 -7
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +4 -4
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +3 -3
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +6 -6
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +2 -2
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +2 -2
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -5
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WAM/BinaryInfo.d.ts +17 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +1 -1
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/index.d.ts +4 -4
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +4 -4
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/index.js +3 -3
- package/lib/index.d.ts +12 -0
- package/lib/index.js +10 -18
- package/lib/temp +1 -0
- package/package.json +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUrlInfo = void 0;
|
|
4
|
-
const messages_1 = require("
|
|
5
|
-
const messages_media_1 = require("
|
|
4
|
+
const messages_1 = require("./messages");
|
|
5
|
+
const messages_media_1 = require("./messages-media");
|
|
6
6
|
const THUMBNAIL_WIDTH_PX = 192;
|
|
7
7
|
/** Fetches an image and generates a thumbnail for it */
|
|
8
8
|
const getCompressedJpegThumbnail = async (url, { thumbnailWidth, fetchOpts }) => {
|
|
@@ -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 {};
|
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LT_HASH_ANTI_TAMPERING = void 0;
|
|
4
|
-
const crypto_1 = require("
|
|
4
|
+
const crypto_1 = require("./crypto");
|
|
5
5
|
/**
|
|
6
6
|
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
7
7
|
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
@@ -0,0 +1,116 @@
|
|
|
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 {};
|
|
@@ -32,11 +32,11 @@ const fs_1 = require("fs");
|
|
|
32
32
|
const os_1 = require("os");
|
|
33
33
|
const path_1 = require("path");
|
|
34
34
|
const stream_1 = require("stream");
|
|
35
|
-
const WAProto_1 = require("
|
|
36
|
-
const Defaults_1 = require("
|
|
37
|
-
const WABinary_1 = require("
|
|
38
|
-
const crypto_1 = require("
|
|
39
|
-
const generics_1 = require("
|
|
35
|
+
const WAProto_1 = require("../../WAProto");
|
|
36
|
+
const Defaults_1 = require("../Defaults");
|
|
37
|
+
const WABinary_1 = require("../WABinary");
|
|
38
|
+
const crypto_1 = require("./crypto");
|
|
39
|
+
const generics_1 = require("./generics");
|
|
40
40
|
const getTmpFilesDirectory = () => (0, os_1.tmpdir)();
|
|
41
41
|
const getImageProcessingLibrary = async () => {
|
|
42
42
|
const [_jimp, sharp] = await Promise.all([
|
|
@@ -394,22 +394,37 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
394
394
|
let bodyPath;
|
|
395
395
|
let didSaveToTmpPath = false;
|
|
396
396
|
try {
|
|
397
|
-
const buffer = await (0, exports.toBuffer)(stream);
|
|
398
397
|
if (type === 'file') {
|
|
399
398
|
bodyPath = media.url;
|
|
400
399
|
}
|
|
401
|
-
else
|
|
400
|
+
else {
|
|
402
401
|
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageID)());
|
|
403
|
-
(0, fs_1.writeFileSync)(bodyPath, buffer);
|
|
404
402
|
didSaveToTmpPath = true;
|
|
405
403
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
const writeStream = didSaveToTmpPath ? (0, fs_1.createWriteStream)(bodyPath) : undefined;
|
|
405
|
+
let fileLength = 0;
|
|
406
|
+
const fileSha256Hash = Crypto.createHash('sha256');
|
|
407
|
+
for await (const data of stream) {
|
|
408
|
+
fileLength += data.length;
|
|
409
|
+
fileSha256Hash.update(data);
|
|
410
|
+
if (writeStream) {
|
|
411
|
+
if (!writeStream.write(data)) {
|
|
412
|
+
await (0, events_1.once)(writeStream, 'drain');
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (writeStream) {
|
|
417
|
+
writeStream.end();
|
|
418
|
+
await new Promise((resolve, reject) => {
|
|
419
|
+
writeStream.on('finish', resolve);
|
|
420
|
+
writeStream.on('error', reject);
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
const fileSha256 = fileSha256Hash.digest();
|
|
409
424
|
logger === null || logger === void 0 ? void 0 : logger.debug('prepare stream data successfully');
|
|
410
425
|
return {
|
|
411
426
|
mediaKey: undefined,
|
|
412
|
-
encWriteStream:
|
|
427
|
+
encWriteStream: (0, fs_1.createReadStream)(bodyPath),
|
|
413
428
|
fileLength,
|
|
414
429
|
fileSha256,
|
|
415
430
|
fileEncSha256: undefined,
|
|
@@ -449,7 +464,8 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
449
464
|
|
|
450
465
|
const mediaKey = Crypto.randomBytes(32);
|
|
451
466
|
const { cipherKey, iv, macKey } = getMediaKeys(mediaKey, mediaType);
|
|
452
|
-
const
|
|
467
|
+
const encBodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageID)() + '.enc');
|
|
468
|
+
const encWriteStream = (0, fs_1.createWriteStream)(encBodyPath);
|
|
453
469
|
let bodyPath;
|
|
454
470
|
let writeStream;
|
|
455
471
|
let didSaveToTmpPath = false;
|
|
@@ -486,23 +502,40 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
486
502
|
await (0, events_1.once)(writeStream, 'drain');
|
|
487
503
|
}
|
|
488
504
|
}
|
|
489
|
-
|
|
505
|
+
const encData = aes.update(data);
|
|
506
|
+
sha256Enc = sha256Enc.update(encData);
|
|
507
|
+
hmac = hmac.update(encData);
|
|
508
|
+
if (!encWriteStream.write(encData)) {
|
|
509
|
+
await (0, events_1.once)(encWriteStream, 'drain');
|
|
510
|
+
}
|
|
490
511
|
}
|
|
491
512
|
|
|
492
|
-
|
|
513
|
+
const encFinal = aes.final();
|
|
514
|
+
sha256Enc = sha256Enc.update(encFinal);
|
|
515
|
+
hmac = hmac.update(encFinal);
|
|
516
|
+
if (!encWriteStream.write(encFinal)) {
|
|
517
|
+
await (0, events_1.once)(encWriteStream, 'drain');
|
|
518
|
+
}
|
|
493
519
|
const mac = hmac.digest().slice(0, 10);
|
|
494
520
|
sha256Enc = sha256Enc.update(mac);
|
|
495
521
|
const fileSha256 = sha256Plain.digest();
|
|
496
522
|
const fileEncSha256 = sha256Enc.digest();
|
|
497
523
|
|
|
498
|
-
encWriteStream.
|
|
499
|
-
encWriteStream.
|
|
524
|
+
encWriteStream.write(mac);
|
|
525
|
+
encWriteStream.end();
|
|
526
|
+
|
|
500
527
|
writeStream === null || writeStream === void 0 ? void 0 : writeStream.end();
|
|
528
|
+
|
|
529
|
+
await new Promise((resolve, reject) => {
|
|
530
|
+
encWriteStream.on('finish', resolve);
|
|
531
|
+
encWriteStream.on('error', reject);
|
|
532
|
+
});
|
|
533
|
+
|
|
501
534
|
finalStream.destroy();
|
|
502
535
|
|
|
503
536
|
return {
|
|
504
537
|
mediaKey,
|
|
505
|
-
encWriteStream,
|
|
538
|
+
encWriteStream: (0, fs_1.createReadStream)(encBodyPath),
|
|
506
539
|
bodyPath,
|
|
507
540
|
mac,
|
|
508
541
|
fileEncSha256,
|
|
@@ -520,6 +553,12 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
520
553
|
sha256Enc.destroy();
|
|
521
554
|
finalStream.destroy();
|
|
522
555
|
|
|
556
|
+
try {
|
|
557
|
+
await fs_1.promises.unlink(encBodyPath);
|
|
558
|
+
}
|
|
559
|
+
catch (err) {
|
|
560
|
+
}
|
|
561
|
+
|
|
523
562
|
if (didSaveToTmpPath) {
|
|
524
563
|
try {
|
|
525
564
|
await fs_1.promises.unlink(bodyPath);
|
|
@@ -529,12 +568,6 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
529
568
|
}
|
|
530
569
|
throw error;
|
|
531
570
|
}
|
|
532
|
-
|
|
533
|
-
function onChunk(buff) {
|
|
534
|
-
sha256Enc = sha256Enc.update(buff);
|
|
535
|
-
hmac = hmac.update(buff);
|
|
536
|
-
encWriteStream.push(buff);
|
|
537
|
-
}
|
|
538
571
|
};
|
|
539
572
|
exports.encryptedStream = encryptedStream;
|
|
540
573
|
const DEF_HOST = 'mmg.whatsapp.net';
|
|
@@ -662,13 +695,25 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
662
695
|
let uploadInfo = await refreshMediaConn(false);
|
|
663
696
|
let urls;
|
|
664
697
|
const hosts = [...customUploadHosts, ...uploadInfo.hosts];
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
698
|
+
|
|
699
|
+
let reqBody = stream;
|
|
700
|
+
let fileStreamPath;
|
|
701
|
+
|
|
702
|
+
if (Buffer.isBuffer(stream)) {
|
|
703
|
+
reqBody = stream;
|
|
704
|
+
} else if (stream instanceof fs_1.ReadStream || (stream.path && typeof stream.path === 'string')) {
|
|
705
|
+
fileStreamPath = stream.path;
|
|
706
|
+
} else {
|
|
707
|
+
const tempPath = (0, path_1.join)(getTmpFilesDirectory(), `upload-${(0, generics_1.generateMessageID)()}`);
|
|
708
|
+
const writeStream = (0, fs_1.createWriteStream)(tempPath);
|
|
709
|
+
await new Promise((resolve, reject) => {
|
|
710
|
+
stream.pipe(writeStream);
|
|
711
|
+
writeStream.on('finish', resolve);
|
|
712
|
+
writeStream.on('error', reject);
|
|
713
|
+
});
|
|
714
|
+
fileStreamPath = tempPath;
|
|
670
715
|
}
|
|
671
|
-
|
|
716
|
+
|
|
672
717
|
fileEncSha256B64 = (0, exports.encodeBase64EncodedStringForUpload)(fileEncSha256B64);
|
|
673
718
|
let media = Defaults_1.MEDIA_PATH_MAP[mediaType];
|
|
674
719
|
if (newsletter) {
|
|
@@ -683,6 +728,11 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
683
728
|
if (maxContentLengthBytes && reqBody.length > maxContentLengthBytes) {
|
|
684
729
|
throw new boom_1.Boom(`Body too large for "${hostname}"`, { statusCode: 413 });
|
|
685
730
|
}
|
|
731
|
+
|
|
732
|
+
if (fileStreamPath) {
|
|
733
|
+
reqBody = (0, fs_1.createReadStream)(fileStreamPath);
|
|
734
|
+
}
|
|
735
|
+
|
|
686
736
|
const body = await axios.post(url, reqBody, {
|
|
687
737
|
...options,
|
|
688
738
|
headers: {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Logger } from 'pino';
|
|
4
|
+
import { type Transform } from 'stream';
|
|
5
|
+
import { proto } from '../../WAProto';
|
|
6
|
+
import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
|
|
7
|
+
import { MediaDownloadOptions } from './messages-media';
|
|
8
|
+
/**
|
|
9
|
+
* Uses a regex to test whether the string contains a URL, and returns the URL if it does.
|
|
10
|
+
* @param text eg. hello https://google.com
|
|
11
|
+
* @returns the URL, eg. https://google.com
|
|
12
|
+
*/
|
|
13
|
+
export declare const extractUrlFromText: (text: string) => string | undefined;
|
|
14
|
+
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => Promise<import("../Types").WAUrlInfo | undefined>;
|
|
15
|
+
export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
|
|
16
|
+
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
|
|
17
|
+
/**
|
|
18
|
+
* Generate forwarded message content like WA does
|
|
19
|
+
* @param message the message to forward
|
|
20
|
+
* @param options.forceForward will show the message as forwarded even if it is from you
|
|
21
|
+
*/
|
|
22
|
+
export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage;
|
|
23
|
+
export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>;
|
|
24
|
+
export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo;
|
|
25
|
+
export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
26
|
+
/** Get the key to access the true type of content */
|
|
27
|
+
export declare const getContentType: (content: WAProto.IMessage | undefined) => keyof proto.IMessage | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes ephemeral, view once messages to regular message content
|
|
30
|
+
* Eg. image messages in ephemeral messages, in view once messages etc.
|
|
31
|
+
* @param content
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Extract the true message content from a message
|
|
37
|
+
* Eg. extracts the inner message from a disappearing message/view once message
|
|
38
|
+
*/
|
|
39
|
+
export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the device predicted by message ID
|
|
42
|
+
*/
|
|
43
|
+
export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop";
|
|
44
|
+
/** Upserts a receipt in the message */
|
|
45
|
+
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => void;
|
|
46
|
+
/** Update the message with a new reaction */
|
|
47
|
+
export declare const updateMessageWithReaction: (msg: Pick<WAMessage, 'reactions'>, reaction: proto.IReaction) => void;
|
|
48
|
+
/** Update the message with a new poll update */
|
|
49
|
+
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, 'pollUpdates'>, update: proto.IPollUpdate) => void;
|
|
50
|
+
type VoteAggregation = {
|
|
51
|
+
name: string;
|
|
52
|
+
voters: string[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Aggregates all poll updates in a poll.
|
|
56
|
+
* @param msg the poll creation message
|
|
57
|
+
* @param meId your jid
|
|
58
|
+
* @returns A list of options & their voters
|
|
59
|
+
*/
|
|
60
|
+
export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick<WAMessage, 'pollUpdates' | 'message'>, meId?: string): VoteAggregation[];
|
|
61
|
+
/** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
|
|
62
|
+
export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[]) => {
|
|
63
|
+
jid: string;
|
|
64
|
+
participant: string | undefined;
|
|
65
|
+
messageIds: string[];
|
|
66
|
+
}[];
|
|
67
|
+
type DownloadMediaMessageContext = {
|
|
68
|
+
reuploadRequest: (msg: WAMessage) => Promise<WAMessage>;
|
|
69
|
+
logger: Logger;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Downloads the given message. Throws an error if it's not a media message
|
|
73
|
+
*/
|
|
74
|
+
export declare const downloadMediaMessage: <Type extends "stream" | "buffer">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer : Transform>;
|
|
75
|
+
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
76
|
+
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
77
|
+
export {};
|
package/lib/Utils/messages.js
CHANGED
|
@@ -8,13 +8,13 @@ const boom_1 = require("@hapi/boom");
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
|
-
const WAProto_1 = require("
|
|
12
|
-
const Defaults_1 = require("
|
|
13
|
-
const Types_1 = require("
|
|
14
|
-
const WABinary_1 = require("
|
|
15
|
-
const crypto_2 = require("
|
|
16
|
-
const generics_1 = require("
|
|
17
|
-
const messages_media_1 = require("
|
|
11
|
+
const WAProto_1 = require("../../WAProto");
|
|
12
|
+
const Defaults_1 = require("../Defaults");
|
|
13
|
+
const Types_1 = require("../Types");
|
|
14
|
+
const WABinary_1 = require("../WABinary");
|
|
15
|
+
const crypto_2 = require("./crypto");
|
|
16
|
+
const generics_1 = require("./generics");
|
|
17
|
+
const messages_media_1 = require("./messages-media");
|
|
18
18
|
const MIMETYPE_MAP = {
|
|
19
19
|
image: 'image/jpeg',
|
|
20
20
|
video: 'video/mp4',
|
|
@@ -813,4 +813,4 @@ const assertMediaContent = (content) => {
|
|
|
813
813
|
}
|
|
814
814
|
return mediaContent;
|
|
815
815
|
};
|
|
816
|
-
exports.assertMediaContent = assertMediaContent;
|
|
816
|
+
exports.assertMediaContent = assertMediaContent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import { KeyPair } from '../Types';
|
|
5
|
+
import { BinaryNode } from '../WABinary';
|
|
6
|
+
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, mobile, logger, routingInfo }: {
|
|
7
|
+
keyPair: KeyPair;
|
|
8
|
+
NOISE_HEADER: Uint8Array;
|
|
9
|
+
mobile: boolean;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
routingInfo?: Buffer | undefined;
|
|
12
|
+
}) => {
|
|
13
|
+
encrypt: (plaintext: Uint8Array) => Buffer;
|
|
14
|
+
decrypt: (ciphertext: Uint8Array) => Buffer;
|
|
15
|
+
authenticate: (data: Uint8Array) => void;
|
|
16
|
+
mixIntoKey: (data: Uint8Array) => void;
|
|
17
|
+
finishInit: () => void;
|
|
18
|
+
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Buffer;
|
|
19
|
+
encodeFrame: (data: Buffer | Uint8Array) => Buffer;
|
|
20
|
+
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => void;
|
|
21
|
+
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeNoiseHandler = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
|
-
const WAProto_1 = require("
|
|
6
|
-
const Defaults_1 = require("
|
|
7
|
-
const WABinary_1 = require("
|
|
8
|
-
const crypto_1 = require("
|
|
5
|
+
const WAProto_1 = require("../../WAProto");
|
|
6
|
+
const Defaults_1 = require("../Defaults");
|
|
7
|
+
const WABinary_1 = require("../WABinary");
|
|
8
|
+
const crypto_1 = require("./crypto");
|
|
9
9
|
const generateIV = (counter) => {
|
|
10
10
|
const iv = new ArrayBuffer(12);
|
|
11
11
|
new DataView(iv).setUint32(8, counter);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { Logger } from 'pino';
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import { AuthenticationCreds, BaileysEventEmitter, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
|
|
5
|
+
type ProcessMessageContext = {
|
|
6
|
+
shouldProcessHistoryMsg: boolean;
|
|
7
|
+
creds: AuthenticationCreds;
|
|
8
|
+
keyStore: SignalKeyStoreWithTransaction;
|
|
9
|
+
ev: BaileysEventEmitter;
|
|
10
|
+
getMessage: SocketConfig['getMessage'];
|
|
11
|
+
logger?: Logger;
|
|
12
|
+
options: AxiosRequestConfig<{}>;
|
|
13
|
+
};
|
|
14
|
+
/** Cleans a received message to further processing */
|
|
15
|
+
export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void;
|
|
16
|
+
export declare const isRealMessage: (message: proto.IWebMessageInfo, meId: string) => boolean | undefined;
|
|
17
|
+
export declare const shouldIncrementChatUnread: (message: proto.IWebMessageInfo) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get the ID of the chat from the given key.
|
|
20
|
+
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
21
|
+
*/
|
|
22
|
+
export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string;
|
|
23
|
+
type PollContext = {
|
|
24
|
+
/** normalised jid of the person that created the poll */
|
|
25
|
+
pollCreatorJid: string;
|
|
26
|
+
/** ID of the poll creation message */
|
|
27
|
+
pollMsgId: string;
|
|
28
|
+
/** poll creation message enc key */
|
|
29
|
+
pollEncKey: Uint8Array;
|
|
30
|
+
/** jid of the person that voted */
|
|
31
|
+
voterJid: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Decrypt a poll vote
|
|
35
|
+
* @param vote encrypted vote
|
|
36
|
+
* @param ctx additional info about the poll required for decryption
|
|
37
|
+
* @returns list of SHA256 options
|
|
38
|
+
*/
|
|
39
|
+
export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage;
|
|
40
|
+
declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>;
|
|
41
|
+
export default processMessage;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decryptPollVote = exports.getChatId = exports.shouldIncrementChatUnread = exports.isRealMessage = exports.cleanMessage = void 0;
|
|
4
|
-
const WAProto_1 = require("
|
|
5
|
-
const Types_1 = require("
|
|
6
|
-
const messages_1 = require("
|
|
7
|
-
const WABinary_1 = require("
|
|
8
|
-
const crypto_1 = require("
|
|
9
|
-
const generics_1 = require("
|
|
10
|
-
const history_1 = require("
|
|
4
|
+
const WAProto_1 = require("../../WAProto");
|
|
5
|
+
const Types_1 = require("../Types");
|
|
6
|
+
const messages_1 = require("../Utils/messages");
|
|
7
|
+
const WABinary_1 = require("../WABinary");
|
|
8
|
+
const crypto_1 = require("./crypto");
|
|
9
|
+
const generics_1 = require("./generics");
|
|
10
|
+
const history_1 = require("./history");
|
|
11
11
|
const REAL_MSG_STUB_TYPES = new Set([
|
|
12
12
|
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
13
13
|
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SignalRepository } from '../Types';
|
|
2
|
+
import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
|
|
3
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
4
|
+
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
|
|
5
|
+
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
|
6
|
+
[id: string]: KeyPair;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: number) => {
|
|
9
|
+
newPreKeys: {
|
|
10
|
+
[id: number]: KeyPair;
|
|
11
|
+
};
|
|
12
|
+
lastPreKeyId: number;
|
|
13
|
+
preKeysRange: readonly [number, number];
|
|
14
|
+
};
|
|
15
|
+
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
|
16
|
+
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
|
|
17
|
+
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
|
|
18
|
+
export declare const extractDeviceJids: (result: BinaryNode, myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
|
|
19
|
+
/**
|
|
20
|
+
* get the next N keys for upload or processing
|
|
21
|
+
* @param count number of pre-keys to get or generate
|
|
22
|
+
*/
|
|
23
|
+
export declare const getNextPreKeys: ({ creds, keys }: AuthenticationState, count: number) => Promise<{
|
|
24
|
+
update: Partial<AuthenticationCreds>;
|
|
25
|
+
preKeys: {
|
|
26
|
+
[id: string]: KeyPair;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
export declare const getNextPreKeysNode: (state: AuthenticationState, count: number) => Promise<{
|
|
30
|
+
update: Partial<AuthenticationCreds>;
|
|
31
|
+
node: BinaryNode;
|
|
32
|
+
}>;
|
package/lib/Utils/signal.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNextPreKeysNode = exports.getNextPreKeys = exports.extractDeviceJids = exports.parseAndInjectE2ESessions = exports.xmppPreKey = exports.xmppSignedPreKey = exports.generateOrGetPreKeys = exports.getPreKeys = exports.createSignalIdentity = void 0;
|
|
4
|
-
const Defaults_1 = require("
|
|
5
|
-
const WABinary_1 = require("
|
|
6
|
-
const crypto_1 = require("
|
|
4
|
+
const Defaults_1 = require("../Defaults");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
6
|
+
const crypto_1 = require("./crypto");
|
|
7
7
|
const lodash_1 = require("lodash")
|
|
8
|
-
const generics_1 = require("
|
|
8
|
+
const generics_1 = require("./generics");
|
|
9
9
|
const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
10
10
|
return {
|
|
11
11
|
identifier: { name: wid, deviceId: 0 },
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticationState } from '../Types';
|
|
2
|
+
/**
|
|
3
|
+
* stores the full authentication state in a single folder.
|
|
4
|
+
* Far more efficient than singlefileauthstate
|
|
5
|
+
*
|
|
6
|
+
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
7
|
+
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
8
|
+
* */
|
|
9
|
+
export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
|
10
|
+
state: AuthenticationState;
|
|
11
|
+
saveCreds: () => Promise<void>;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
@@ -4,9 +4,9 @@ exports.useMultiFileAuthState = void 0;
|
|
|
4
4
|
const async_mutex_1 = require("async-mutex");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const WAProto_1 = require("
|
|
8
|
-
const auth_utils_1 = require("
|
|
9
|
-
const generics_1 = require("
|
|
7
|
+
const WAProto_1 = require("../../WAProto");
|
|
8
|
+
const auth_utils_1 = require("./auth-utils");
|
|
9
|
+
const generics_1 = require("./generics");
|
|
10
10
|
const fileLocks = new Map();
|
|
11
11
|
const getFileLock = (path) => {
|
|
12
12
|
let mutex = fileLocks.get(path);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { proto } from '../../WAProto';
|
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload;
|
|
5
|
+
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
6
|
+
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
7
|
+
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
8
|
+
creds: Partial<AuthenticationCreds>;
|
|
9
|
+
reply: BinaryNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array;
|