Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.d.ts
1129 views
1
/// <reference types="node" />
2
/// <reference types="node" />
3
import { Boom } from '@hapi/boom';
4
import { AxiosRequestConfig } from 'axios';
5
import type { Logger } from 'pino';
6
import { Readable, Transform } from 'stream';
7
import { URL } from 'url';
8
import { proto } from '../../WAProto';
9
import { CommonSocketConfig, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
10
import { BinaryNode } from '../WABinary';
11
export declare const hkdfInfoKey: (type: MediaType) => string;
12
/** generates all the keys required to encrypt/decrypt & sign a media message */
13
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
14
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<Buffer>;
15
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
16
img: Buffer;
17
}>;
18
/** gets the SHA256 of the given media message */
19
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
20
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;
21
export declare const toReadable: (buffer: Buffer) => Readable;
22
export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
23
export declare const getStream: (item: WAMediaUpload) => Promise<{
24
stream: Readable;
25
type: string;
26
}>;
27
/** generates a thumbnail for a given media, if required */
28
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
29
logger?: Logger;
30
}): Promise<string | undefined>;
31
export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
32
isStream?: true;
33
}) => Promise<Readable>;
34
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, saveOriginalFileIfRequired?: boolean, logger?: Logger) => Promise<{
35
mediaKey: Buffer;
36
encWriteStream: Readable;
37
bodyPath: string | undefined;
38
mac: Buffer;
39
fileEncSha256: Buffer;
40
fileSha256: Buffer;
41
fileLength: number;
42
didSaveToTmpPath: boolean;
43
}>;
44
export declare type MediaDownloadOptions = {
45
startByte?: number;
46
endByte?: number;
47
};
48
export declare const getUrlFromDirectPath: (directPath: string) => string;
49
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
50
/**
51
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
52
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
53
* */
54
export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte }?: MediaDownloadOptions) => Promise<Transform>;
55
export declare function extensionForMediaMessage(message: WAMessageContent): string;
56
export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger }: CommonSocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
57
/**
58
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
59
*/
60
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
61
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
62
key: proto.IMessageKey;
63
media?: {
64
ciphertext: Uint8Array;
65
iv: Uint8Array;
66
} | undefined;
67
error?: Boom<any> | undefined;
68
};
69
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
70
ciphertext: Uint8Array;
71
iv: Uint8Array;
72
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
73
export declare const getStatusCodeForMediaRetry: (code: number) => any;
74
75