@jkt48connect-corp/baileys 7.2.7 → 7.2.9
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/README.md +838 -94
- package/WAProto/WAProto.proto +969 -88
- package/WAProto/index.js +124901 -74525
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +5 -3
- package/lib/Defaults/phonenumber-mcc.json +221 -221
- package/lib/Signal/libsignal.js +18 -9
- package/lib/Socket/groups.js +1 -1
- package/lib/Socket/messages-recv.js +310 -151
- package/lib/Socket/messages-send.js +269 -36
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.js +7 -3
- package/lib/Store/make-in-memory-store.js +13 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +3 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.js +35 -23
- package/lib/Utils/decode-wa-message.js +43 -15
- package/lib/Utils/generics.js +32 -16
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages-media.js +38 -47
- package/lib/Utils/messages.js +430 -12
- package/lib/Utils/process-message.js +2 -2
- package/lib/Utils/use-multi-file-auth-state.js +17 -3
- package/lib/Utils/validate-connection.js +12 -23
- package/lib/WABinary/decode.js +17 -7
- package/lib/WABinary/encode.js +33 -17
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +4 -1
- package/package.json +15 -10
- package/WAProto/index.d.ts +0 -37016
- package/lib/Defaults/index.d.ts +0 -283
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/business.d.ts +0 -170
- package/lib/Socket/chats.d.ts +0 -80
- package/lib/Socket/community.d.ts +0 -219
- package/lib/Socket/community.js +0 -354
- package/lib/Socket/groups.d.ts +0 -114
- package/lib/Socket/index.d.ts +0 -172
- package/lib/Socket/messages-recv.d.ts +0 -158
- package/lib/Socket/messages-send.d.ts +0 -147
- package/lib/Socket/newsletter.d.ts +0 -133
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/socket.d.ts +0 -43
- 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 -54
- 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 -92
- 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/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 -97
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -18
- 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 -12
- package/lib/Utils/use-single-file-auth-statev2.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-statev2.js +0 -75
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -15
- 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/index.d.ts +0 -11
@@ -1,18 +0,0 @@
|
|
1
|
-
import type { Logger } from 'pino';
|
2
|
-
import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
|
3
|
-
/**
|
4
|
-
* Adds caching capability to a SignalKeyStore
|
5
|
-
* @param store the store to add caching to
|
6
|
-
* @param logger to log trace events
|
7
|
-
* @param _cache cache store to use
|
8
|
-
*/
|
9
|
-
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger: Logger, _cache?: CacheStore): SignalKeyStore;
|
10
|
-
/**
|
11
|
-
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
12
|
-
* this allows batch read & write operations & improves the performance of the lib
|
13
|
-
* @param state the key store to apply this capability to
|
14
|
-
* @param logger logger to log events
|
15
|
-
* @returns SignalKeyStore with transaction capability
|
16
|
-
*/
|
17
|
-
export declare const addTransactionCapability: (state: SignalKeyStore, logger: Logger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
|
18
|
-
export declare const initAuthCreds: () => AuthenticationCreds;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { BaileysEventEmitter } from '../Types';
|
2
|
-
/**
|
3
|
-
* Captures events from a baileys event emitter & stores them in a file
|
4
|
-
* @param ev The event emitter to read events from
|
5
|
-
* @param filename File to save to
|
6
|
-
*/
|
7
|
-
export declare const captureEventStream: (ev: BaileysEventEmitter, filename: string) => void;
|
8
|
-
/**
|
9
|
-
* Read event file and emit events from there
|
10
|
-
* @param filename filename containing event data
|
11
|
-
* @param delayIntervalMs delay between each event emit
|
12
|
-
*/
|
13
|
-
export declare const readAndEmitEventStream: (filename: string, delayIntervalMs?: number) => {
|
14
|
-
ev: BaileysEventEmitter;
|
15
|
-
task: Promise<void>;
|
16
|
-
};
|
package/lib/Utils/business.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types';
|
2
|
-
import { BinaryNode } from '../WABinary';
|
3
|
-
export declare const parseCatalogNode: (node: BinaryNode) => {
|
4
|
-
products: Product[];
|
5
|
-
nextPageCursor: string | undefined;
|
6
|
-
};
|
7
|
-
export declare const parseCollectionsNode: (node: BinaryNode) => {
|
8
|
-
collections: CatalogCollection[];
|
9
|
-
};
|
10
|
-
export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails;
|
11
|
-
export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode;
|
12
|
-
export declare const parseProductNode: (productNode: BinaryNode) => Product;
|
13
|
-
/**
|
14
|
-
* Uploads images not already uploaded to WA's servers
|
15
|
-
*/
|
16
|
-
export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>;
|
17
|
-
/**
|
18
|
-
* Uploads images not already uploaded to WA's servers
|
19
|
-
*/
|
20
|
-
export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
|
21
|
-
url: string;
|
22
|
-
}[]>;
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { AxiosRequestConfig } from 'axios';
|
3
|
-
import type { Logger } from 'pino';
|
4
|
-
import { proto } from '../../WAProto';
|
5
|
-
import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
6
|
-
import { BinaryNode } from '../WABinary';
|
7
|
-
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
8
|
-
export type ChatMutationMap = {
|
9
|
-
[index: string]: ChatMutation;
|
10
|
-
};
|
11
|
-
export declare const newLTHashState: () => LTHashState;
|
12
|
-
export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
|
13
|
-
patch: proto.ISyncdPatch;
|
14
|
-
state: LTHashState;
|
15
|
-
}>;
|
16
|
-
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
17
|
-
hash: Buffer;
|
18
|
-
indexValueMap: {
|
19
|
-
[indexMacBase64: string]: {
|
20
|
-
valueMac: Uint8Array | Buffer;
|
21
|
-
};
|
22
|
-
};
|
23
|
-
}>;
|
24
|
-
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
25
|
-
hash: Buffer;
|
26
|
-
indexValueMap: {
|
27
|
-
[indexMacBase64: string]: {
|
28
|
-
valueMac: Uint8Array | Buffer;
|
29
|
-
};
|
30
|
-
};
|
31
|
-
}>;
|
32
|
-
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
|
33
|
-
critical_block: {
|
34
|
-
patches: proto.ISyncdPatch[];
|
35
|
-
hasMorePatches: boolean;
|
36
|
-
snapshot?: proto.ISyncdSnapshot | undefined;
|
37
|
-
};
|
38
|
-
critical_unblock_low: {
|
39
|
-
patches: proto.ISyncdPatch[];
|
40
|
-
hasMorePatches: boolean;
|
41
|
-
snapshot?: proto.ISyncdSnapshot | undefined;
|
42
|
-
};
|
43
|
-
regular_high: {
|
44
|
-
patches: proto.ISyncdPatch[];
|
45
|
-
hasMorePatches: boolean;
|
46
|
-
snapshot?: proto.ISyncdSnapshot | undefined;
|
47
|
-
};
|
48
|
-
regular_low: {
|
49
|
-
patches: proto.ISyncdPatch[];
|
50
|
-
hasMorePatches: boolean;
|
51
|
-
snapshot?: proto.ISyncdSnapshot | undefined;
|
52
|
-
};
|
53
|
-
regular: {
|
54
|
-
patches: proto.ISyncdPatch[];
|
55
|
-
hasMorePatches: boolean;
|
56
|
-
snapshot?: proto.ISyncdSnapshot | undefined;
|
57
|
-
};
|
58
|
-
}>;
|
59
|
-
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer>;
|
60
|
-
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
|
61
|
-
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
62
|
-
state: LTHashState;
|
63
|
-
mutationMap: ChatMutationMap;
|
64
|
-
}>;
|
65
|
-
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
|
66
|
-
state: LTHashState;
|
67
|
-
mutationMap: ChatMutationMap;
|
68
|
-
}>;
|
69
|
-
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
70
|
-
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
|
71
|
-
export {};
|
package/lib/Utils/crypto.d.ts
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { KeyPair } from '../Types';
|
3
|
-
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
4
|
-
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array | Buffer;
|
5
|
-
export declare const Curve: {
|
6
|
-
generateKeyPair: () => KeyPair;
|
7
|
-
sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => Buffer;
|
8
|
-
sign: (privateKey: Uint8Array, buf: Uint8Array) => any;
|
9
|
-
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
|
10
|
-
};
|
11
|
-
export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) => {
|
12
|
-
keyPair: KeyPair;
|
13
|
-
signature: any;
|
14
|
-
keyId: number;
|
15
|
-
};
|
16
|
-
/**
|
17
|
-
* encrypt AES 256 GCM;
|
18
|
-
* where the tag tag is suffixed to the ciphertext
|
19
|
-
* */
|
20
|
-
export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer;
|
21
|
-
/**
|
22
|
-
* decrypt AES 256 GCM;
|
23
|
-
* where the auth tag is suffixed to the ciphertext
|
24
|
-
* */
|
25
|
-
export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer;
|
26
|
-
export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer;
|
27
|
-
export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer;
|
28
|
-
/** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
|
29
|
-
export declare function aesDecrypt(buffer: Buffer, key: Buffer): Buffer;
|
30
|
-
/** decrypt AES 256 CBC */
|
31
|
-
export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer;
|
32
|
-
export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer): Buffer;
|
33
|
-
export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer;
|
34
|
-
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): Buffer;
|
35
|
-
export declare function sha256(buffer: Buffer): Buffer;
|
36
|
-
export declare function md5(buffer: Buffer): Buffer;
|
37
|
-
export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number, info: {
|
38
|
-
salt?: Buffer;
|
39
|
-
info?: string;
|
40
|
-
}): Buffer;
|
41
|
-
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Buffer;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { Logger } from 'pino';
|
2
|
-
import { proto } from '../../WAProto';
|
3
|
-
import { SignalRepository } from '../Types';
|
4
|
-
import { BinaryNode } from '../WABinary';
|
5
|
-
/**
|
6
|
-
* Decode the received node as a message.
|
7
|
-
* @note this will only parse the message, not decrypt it
|
8
|
-
*/
|
9
|
-
export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
|
10
|
-
fullMessage: proto.IWebMessageInfo;
|
11
|
-
author: string;
|
12
|
-
sender: string;
|
13
|
-
};
|
14
|
-
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: Logger) => {
|
15
|
-
fullMessage: proto.IWebMessageInfo;
|
16
|
-
category: string;
|
17
|
-
author: string;
|
18
|
-
decrypt(): Promise<void>;
|
19
|
-
};
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { Logger } from 'pino';
|
2
|
-
import { BaileysEventEmitter, BaileysEventMap } from '../Types';
|
3
|
-
/**
|
4
|
-
* A map that contains a list of all events that have been triggered
|
5
|
-
*
|
6
|
-
* Note, this can contain different type of events
|
7
|
-
* this can make processing events extremely efficient -- since everything
|
8
|
-
* can be done in a single transaction
|
9
|
-
*/
|
10
|
-
type BaileysEventData = Partial<BaileysEventMap>;
|
11
|
-
type BaileysBufferableEventEmitter = BaileysEventEmitter & {
|
12
|
-
/** Use to process events in a batch */
|
13
|
-
process(handler: (events: BaileysEventData) => void | Promise<void>): (() => void);
|
14
|
-
/**
|
15
|
-
* starts buffering events, call flush() to release them
|
16
|
-
* */
|
17
|
-
buffer(): void;
|
18
|
-
/** buffers all events till the promise completes */
|
19
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
20
|
-
/**
|
21
|
-
* flushes all buffered events
|
22
|
-
* @param force if true, will flush all data regardless of any pending buffers
|
23
|
-
* @returns returns true if the flush actually happened, otherwise false
|
24
|
-
*/
|
25
|
-
flush(force?: boolean): boolean;
|
26
|
-
/** is there an ongoing buffer */
|
27
|
-
isBuffering(): boolean;
|
28
|
-
};
|
29
|
-
/**
|
30
|
-
* The event buffer logically consolidates different events into a single event
|
31
|
-
* making the data processing more efficient.
|
32
|
-
* @param ev the baileys event emitter
|
33
|
-
*/
|
34
|
-
export declare const makeEventBuffer: (logger: Logger) => BaileysBufferableEventEmitter;
|
35
|
-
export {};
|
package/lib/Utils/generics.d.ts
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { AxiosRequestConfig } from 'axios';
|
3
|
-
import { Logger } from 'pino';
|
4
|
-
import { proto } from '../../WAProto';
|
5
|
-
import { BaileysEventEmitter, BaileysEventMap, WACallUpdateType, WAVersion } from '../Types';
|
6
|
-
import { BinaryNode } from '../WABinary';
|
7
|
-
export declare const Browsers: {
|
8
|
-
ubuntu: (browser: any) => [string, string, string];
|
9
|
-
macOS: (browser: any) => [string, string, string];
|
10
|
-
baileys: (browser: any) => [string, string, string];
|
11
|
-
windows: (browser: any) => [string, string, string];
|
12
|
-
iOS: (browser: any) => [string, string, string];
|
13
|
-
linux: (browser: any) => [string, string, string];
|
14
|
-
/** The appropriate browser based on your OS & release */
|
15
|
-
appropriate: (browser: any) => [string, string, string];
|
16
|
-
};
|
17
|
-
export declare const BufferJSON: {
|
18
|
-
replacer: (k: any, value: any) => any;
|
19
|
-
reviver: (_: any, value: any) => any;
|
20
|
-
};
|
21
|
-
export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, meId?: string) => string;
|
22
|
-
export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;
|
23
|
-
export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;
|
24
|
-
export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;
|
25
|
-
export declare const generateRegistrationId: () => number;
|
26
|
-
export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;
|
27
|
-
export declare const toNumber: (t: Long | number | null | undefined) => number;
|
28
|
-
/** unix timestamp of a date in seconds */
|
29
|
-
export declare const unixTimestampSeconds: (date?: Date) => number;
|
30
|
-
export type DebouncedTimeout = ReturnType<typeof debouncedTimeout>;
|
31
|
-
export declare const debouncedTimeout: (intervalMs?: number, task?: () => void) => {
|
32
|
-
start: (newIntervalMs?: number, newTask?: () => void) => void;
|
33
|
-
cancel: () => void;
|
34
|
-
setTask: (newTask: () => void) => () => void;
|
35
|
-
setInterval: (newInterval: number) => number;
|
36
|
-
};
|
37
|
-
export declare const delay: (ms: number) => Promise<void>;
|
38
|
-
export declare const delayCancellable: (ms: number) => {
|
39
|
-
delay: Promise<void>;
|
40
|
-
cancel: () => void;
|
41
|
-
};
|
42
|
-
export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
|
43
|
-
export declare const generateMessageIDV2: (userId?: string) => string;
|
44
|
-
export declare const generateMessageID: () => string;
|
45
|
-
export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
46
|
-
export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
47
|
-
export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: Logger) => void;
|
48
|
-
/**
|
49
|
-
* utility that fetches latest baileys version from the master branch.
|
50
|
-
* Use to ensure your WA connection is always on the latest version
|
51
|
-
*/
|
52
|
-
export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<any>) => Promise<{
|
53
|
-
version: WAVersion;
|
54
|
-
isLatest: boolean;
|
55
|
-
error?: undefined;
|
56
|
-
} | {
|
57
|
-
version: WAVersion;
|
58
|
-
isLatest: boolean;
|
59
|
-
error: any;
|
60
|
-
}>;
|
61
|
-
/**
|
62
|
-
* A utility that fetches the latest web version of whatsapp.
|
63
|
-
* Use to ensure your WA connection is always on the latest version
|
64
|
-
*/
|
65
|
-
export declare const fetchLatestWaWebVersion: (options: AxiosRequestConfig<any>) => Promise<{
|
66
|
-
version: WAVersion;
|
67
|
-
isLatest: boolean;
|
68
|
-
error?: undefined;
|
69
|
-
} | {
|
70
|
-
version: WAVersion;
|
71
|
-
isLatest: boolean;
|
72
|
-
error: any;
|
73
|
-
}>;
|
74
|
-
/** unique message tag prefix for MD clients */
|
75
|
-
export declare const generateMdTagPrefix: () => string;
|
76
|
-
/**
|
77
|
-
* Given a type of receipt, returns what the new status of the message should be
|
78
|
-
* @param type type from receipt
|
79
|
-
*/
|
80
|
-
export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status;
|
81
|
-
/**
|
82
|
-
* Stream errors generally provide a reason, map that to a baileys DisconnectReason
|
83
|
-
* @param reason the string reason given, eg. "conflict"
|
84
|
-
*/
|
85
|
-
export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {
|
86
|
-
reason: string;
|
87
|
-
statusCode: number;
|
88
|
-
};
|
89
|
-
export declare const getCallStatusFromNode: ({ tag, attrs }: BinaryNode) => WACallUpdateType;
|
90
|
-
export declare const getCodeFromWSError: (error: Error) => number;
|
91
|
-
/**
|
92
|
-
* Is the given platform WA business
|
93
|
-
* @param platform AuthenticationCreds.platform
|
94
|
-
*/
|
95
|
-
export declare const isWABusinessPlatform: (platform: string) => boolean;
|
96
|
-
export declare function trimUndefined(obj: any): any;
|
97
|
-
export declare function bytesToCrockford(buffer: Buffer): string;
|
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,18 +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 './use-single-file-auth-statev2';
|
16
|
-
export * from './link-preview';
|
17
|
-
export * from './event-buffer';
|
18
|
-
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 {};
|
package/lib/Utils/messages.d.ts
DELETED
@@ -1,77 +0,0 @@
|
|
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 {};
|
@@ -1,21 +0,0 @@
|
|
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
|
-
};
|