@jkt48connect-corp/baileys 7.2.9 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WAProto/index.d.ts +48955 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +284 -0
- package/lib/Defaults/index.js +5 -5
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +170 -0
- package/lib/Socket/chats.d.ts +81 -0
- package/lib/Socket/chats.js +51 -48
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +1 -0
- package/lib/Socket/index.d.ts +172 -0
- package/lib/Socket/messages-recv.d.ts +158 -0
- package/lib/Socket/messages-send.d.ts +155 -0
- package/lib/Socket/messages-send.js +105 -77
- package/lib/Socket/newsletter.d.ts +132 -0
- package/lib/Socket/registration.d.ts +264 -0
- package/lib/Socket/socket.d.ts +44 -0
- package/lib/Socket/socket.js +15 -8
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +24 -13
- 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 +109 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +107 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/GroupMetadata.d.ts +56 -0
- package/lib/Types/Label.d.ts +46 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/Message.d.ts +433 -0
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Socket.d.ts +116 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/generics.d.ts +88 -0
- package/lib/Utils/generics.js +2 -2
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/messages-media.d.ts +113 -0
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +73 -12
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +11 -19
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -7
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +23 -12
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.js +1 -3
- package/package.json +7 -4
- package/LICENSE +0 -21
@@ -0,0 +1,78 @@
|
|
1
|
+
import { WAMediaUpload } from './Message';
|
2
|
+
export type CatalogResult = {
|
3
|
+
data: {
|
4
|
+
paging: {
|
5
|
+
cursors: {
|
6
|
+
before: string;
|
7
|
+
after: string;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
data: any[];
|
11
|
+
};
|
12
|
+
};
|
13
|
+
export type ProductCreateResult = {
|
14
|
+
data: {
|
15
|
+
product: {};
|
16
|
+
};
|
17
|
+
};
|
18
|
+
export type CatalogStatus = {
|
19
|
+
status: string;
|
20
|
+
canAppeal: boolean;
|
21
|
+
};
|
22
|
+
export type CatalogCollection = {
|
23
|
+
id: string;
|
24
|
+
name: string;
|
25
|
+
products: Product[];
|
26
|
+
status: CatalogStatus;
|
27
|
+
};
|
28
|
+
export type ProductAvailability = 'in stock';
|
29
|
+
export type ProductBase = {
|
30
|
+
name: string;
|
31
|
+
retailerId?: string;
|
32
|
+
url?: string;
|
33
|
+
description: string;
|
34
|
+
price: number;
|
35
|
+
currency: string;
|
36
|
+
isHidden?: boolean;
|
37
|
+
};
|
38
|
+
export type ProductCreate = ProductBase & {
|
39
|
+
/** ISO country code for product origin. Set to undefined for no country */
|
40
|
+
originCountryCode: string | undefined;
|
41
|
+
/** images of the product */
|
42
|
+
images: WAMediaUpload[];
|
43
|
+
};
|
44
|
+
export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
|
45
|
+
export type Product = ProductBase & {
|
46
|
+
id: string;
|
47
|
+
imageUrls: {
|
48
|
+
[_: string]: string;
|
49
|
+
};
|
50
|
+
reviewStatus: {
|
51
|
+
[_: string]: string;
|
52
|
+
};
|
53
|
+
availability: ProductAvailability;
|
54
|
+
};
|
55
|
+
export type OrderPrice = {
|
56
|
+
currency: string;
|
57
|
+
total: number;
|
58
|
+
};
|
59
|
+
export type OrderProduct = {
|
60
|
+
id: string;
|
61
|
+
imageUrl: string;
|
62
|
+
name: string;
|
63
|
+
quantity: number;
|
64
|
+
currency: string;
|
65
|
+
price: number;
|
66
|
+
};
|
67
|
+
export type OrderDetails = {
|
68
|
+
price: OrderPrice;
|
69
|
+
products: OrderProduct[];
|
70
|
+
};
|
71
|
+
export type CatalogCursor = string;
|
72
|
+
export type GetCatalogOptions = {
|
73
|
+
/** cursor to start from */
|
74
|
+
cursor?: CatalogCursor;
|
75
|
+
/** number of products to fetch */
|
76
|
+
limit?: number;
|
77
|
+
jid?: string;
|
78
|
+
};
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { proto } from '../../WAProto';
|
2
|
+
type DecryptGroupSignalOpts = {
|
3
|
+
group: string;
|
4
|
+
authorJid: string;
|
5
|
+
msg: Uint8Array;
|
6
|
+
};
|
7
|
+
type ProcessSenderKeyDistributionMessageOpts = {
|
8
|
+
item: proto.Message.ISenderKeyDistributionMessage;
|
9
|
+
authorJid: string;
|
10
|
+
};
|
11
|
+
type DecryptSignalProtoOpts = {
|
12
|
+
jid: string;
|
13
|
+
type: 'pkmsg' | 'msg';
|
14
|
+
ciphertext: Uint8Array;
|
15
|
+
};
|
16
|
+
type EncryptMessageOpts = {
|
17
|
+
jid: string;
|
18
|
+
data: Uint8Array;
|
19
|
+
};
|
20
|
+
type EncryptGroupMessageOpts = {
|
21
|
+
group: string;
|
22
|
+
data: Uint8Array;
|
23
|
+
meId: string;
|
24
|
+
};
|
25
|
+
type PreKey = {
|
26
|
+
keyId: number;
|
27
|
+
publicKey: Uint8Array;
|
28
|
+
};
|
29
|
+
type SignedPreKey = PreKey & {
|
30
|
+
signature: Uint8Array;
|
31
|
+
};
|
32
|
+
type E2ESession = {
|
33
|
+
registrationId: number;
|
34
|
+
identityKey: Uint8Array;
|
35
|
+
signedPreKey: SignedPreKey;
|
36
|
+
preKey: PreKey;
|
37
|
+
};
|
38
|
+
type E2ESessionOpts = {
|
39
|
+
jid: string;
|
40
|
+
session: E2ESession;
|
41
|
+
};
|
42
|
+
export type SignalRepository = {
|
43
|
+
decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>;
|
44
|
+
processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>;
|
45
|
+
decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>;
|
46
|
+
encryptMessage(opts: EncryptMessageOpts): Promise<{
|
47
|
+
type: 'pkmsg' | 'msg';
|
48
|
+
ciphertext: Uint8Array;
|
49
|
+
}>;
|
50
|
+
encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
|
51
|
+
senderKeyDistributionMessage: Uint8Array;
|
52
|
+
ciphertext: Uint8Array;
|
53
|
+
}>;
|
54
|
+
injectE2ESession(opts: E2ESessionOpts): Promise<void>;
|
55
|
+
jidToSignalProtocolAddress(jid: string): string;
|
56
|
+
};
|
57
|
+
export {};
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
2
|
+
import type { Agent } from 'https';
|
3
|
+
import type { Logger } from 'pino';
|
4
|
+
import type { URL } from 'url';
|
5
|
+
import { proto } from '../../WAProto';
|
6
|
+
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
7
|
+
import { GroupMetadata } from './GroupMetadata';
|
8
|
+
import { MediaConnInfo } from './Message';
|
9
|
+
import { SignalRepository } from './Signal';
|
10
|
+
export type WAVersion = [number, number, number];
|
11
|
+
export type WABrowserDescription = [string, string, string];
|
12
|
+
export type CacheStore = {
|
13
|
+
/** get a cached key and change the stats */
|
14
|
+
get<T>(key: string): T | undefined;
|
15
|
+
/** set a key in the cache */
|
16
|
+
set<T>(key: string, value: T): void;
|
17
|
+
/** delete a key from the cache */
|
18
|
+
del(key: string): void;
|
19
|
+
/** flush all data */
|
20
|
+
flushAll(): void;
|
21
|
+
};
|
22
|
+
export type SocketConfig = {
|
23
|
+
/** the WS url to connect to WA */
|
24
|
+
waWebSocketUrl: string | URL;
|
25
|
+
/** Fails the connection if the socket times out in this interval */
|
26
|
+
connectTimeoutMs: number;
|
27
|
+
/** Default timeout for queries, undefined for no timeout */
|
28
|
+
defaultQueryTimeoutMs: number | undefined;
|
29
|
+
/** ping-pong interval for WS connection */
|
30
|
+
keepAliveIntervalMs: number;
|
31
|
+
/** should baileys use the mobile api instead of the multi device api */
|
32
|
+
mobile?: boolean;
|
33
|
+
/** proxy agent */
|
34
|
+
agent?: Agent;
|
35
|
+
/** pino logger */
|
36
|
+
logger: Logger;
|
37
|
+
/** version to connect with */
|
38
|
+
version: WAVersion;
|
39
|
+
/** override browser config */
|
40
|
+
browser: WABrowserDescription;
|
41
|
+
/** agent used for fetch requests -- uploading/downloading media */
|
42
|
+
fetchAgent?: Agent;
|
43
|
+
/** should the QR be printed in the terminal */
|
44
|
+
printQRInTerminal: boolean;
|
45
|
+
/** should events be emitted for actions done by this socket connection */
|
46
|
+
emitOwnEvents: boolean;
|
47
|
+
/** custom upload hosts to upload media to */
|
48
|
+
customUploadHosts: MediaConnInfo['hosts'];
|
49
|
+
/** time to wait between sending new retry requests */
|
50
|
+
retryRequestDelayMs: number;
|
51
|
+
/** max retry count */
|
52
|
+
maxMsgRetryCount: number;
|
53
|
+
/** time to wait for the generation of the next QR in ms */
|
54
|
+
qrTimeout?: number;
|
55
|
+
/** provide an auth state object to maintain the auth state */
|
56
|
+
auth: AuthenticationState;
|
57
|
+
/** manage history processing with this control; by default will sync up everything */
|
58
|
+
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
|
59
|
+
/** transaction capability options for SignalKeyStore */
|
60
|
+
transactionOpts: TransactionCapabilityOptions;
|
61
|
+
/** marks the client as online whenever the socket successfully connects */
|
62
|
+
markOnlineOnConnect: boolean;
|
63
|
+
/** alphanumeric country code (USA -> US) for the number used */
|
64
|
+
countryCode: string;
|
65
|
+
/** provide a cache to store media, so does not have to be re-uploaded */
|
66
|
+
mediaCache?: CacheStore;
|
67
|
+
/**
|
68
|
+
* map to store the retry counts for failed messages;
|
69
|
+
* used to determine whether to retry a message or not */
|
70
|
+
msgRetryCounterCache?: CacheStore;
|
71
|
+
/** provide a cache to store a user's device list */
|
72
|
+
userDevicesCache?: CacheStore;
|
73
|
+
/** cache to store call offers */
|
74
|
+
callOfferCache?: CacheStore;
|
75
|
+
/** cache to track placeholder resends */
|
76
|
+
placeholderResendCache?: CacheStore;
|
77
|
+
/** width for link preview images */
|
78
|
+
linkPreviewImageThumbnailWidth: number;
|
79
|
+
/** Should Baileys ask the phone for full history, will be received async */
|
80
|
+
syncFullHistory: boolean;
|
81
|
+
/** Should baileys fire init queries automatically, default true */
|
82
|
+
fireInitQueries: boolean;
|
83
|
+
/**
|
84
|
+
* generate a high quality link preview,
|
85
|
+
* entails uploading the jpegThumbnail to WA
|
86
|
+
* */
|
87
|
+
generateHighQualityLinkPreview: boolean;
|
88
|
+
/**
|
89
|
+
* Returns if a jid should be ignored,
|
90
|
+
* no event for that jid will be triggered.
|
91
|
+
* Messages from that jid will also not be decrypted
|
92
|
+
* */
|
93
|
+
shouldIgnoreJid: (jid: string) => boolean | undefined;
|
94
|
+
/**
|
95
|
+
* Optionally patch the message before sending out
|
96
|
+
* */
|
97
|
+
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
|
98
|
+
/** verify app state MACs */
|
99
|
+
appStateMacVerification: {
|
100
|
+
patch: boolean;
|
101
|
+
snapshot: boolean;
|
102
|
+
};
|
103
|
+
/** options for axios */
|
104
|
+
options: AxiosRequestConfig<{}>;
|
105
|
+
/**
|
106
|
+
* fetch a message from your store
|
107
|
+
* implement this so that messages failed to send
|
108
|
+
* (solves the "this message can take a while" issue) can be retried
|
109
|
+
* */
|
110
|
+
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
111
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
112
|
+
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
|
113
|
+
makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
|
114
|
+
/** Socket passthrough */
|
115
|
+
socket?: any;
|
116
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { Contact } from './Contact';
|
2
|
+
export type WAConnectionState = 'open' | 'connecting' | 'close';
|
3
|
+
export type ConnectionState = {
|
4
|
+
/** connection is now open, connecting or closed */
|
5
|
+
connection: WAConnectionState;
|
6
|
+
/** the error that caused the connection to close */
|
7
|
+
lastDisconnect?: {
|
8
|
+
error: Error | undefined;
|
9
|
+
date: Date;
|
10
|
+
};
|
11
|
+
/** is this a new login */
|
12
|
+
isNewLogin?: boolean;
|
13
|
+
/** the current QR code */
|
14
|
+
qr?: string;
|
15
|
+
/** has the device received all pending notifications while it was offline */
|
16
|
+
receivedPendingNotifications?: boolean;
|
17
|
+
/** legacy connection options */
|
18
|
+
legacy?: {
|
19
|
+
phoneConnected: boolean;
|
20
|
+
user?: Contact;
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* if the client is shown as an active, online client.
|
24
|
+
* If this is false, the primary phone and other devices will receive notifs
|
25
|
+
* */
|
26
|
+
isOnline?: boolean;
|
27
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { BinaryNode } from '../WABinary';
|
2
|
+
import { USyncUser } from '../WAUSync';
|
3
|
+
/**
|
4
|
+
* Defines the interface for a USyncQuery protocol
|
5
|
+
*/
|
6
|
+
export interface USyncQueryProtocol {
|
7
|
+
/**
|
8
|
+
* The name of the protocol
|
9
|
+
*/
|
10
|
+
name: string;
|
11
|
+
/**
|
12
|
+
* Defines what goes inside the query part of a USyncQuery
|
13
|
+
*/
|
14
|
+
getQueryElement: () => BinaryNode;
|
15
|
+
/**
|
16
|
+
* Defines what goes inside the user part of a USyncQuery
|
17
|
+
*/
|
18
|
+
getUserElement: (user: USyncUser) => BinaryNode | null;
|
19
|
+
/**
|
20
|
+
* Parse the result of the query
|
21
|
+
* @param data Data from the result
|
22
|
+
* @returns Whatever the protocol is supposed to return
|
23
|
+
*/
|
24
|
+
parser: (data: BinaryNode) => unknown;
|
25
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
export * from './Auth';
|
2
|
+
export * from './GroupMetadata';
|
3
|
+
export * from './Chat';
|
4
|
+
export * from './Contact';
|
5
|
+
export * from './State';
|
6
|
+
export * from './Message';
|
7
|
+
export * from './Newsletter';
|
8
|
+
export * from './Socket';
|
9
|
+
export * from './Events';
|
10
|
+
export * from './Product';
|
11
|
+
export * from './Call';
|
12
|
+
export * from './Signal';
|
13
|
+
import { AuthenticationState } from './Auth';
|
14
|
+
import { SocketConfig } from './Socket';
|
15
|
+
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
16
|
+
auth: AuthenticationState;
|
17
|
+
};
|
18
|
+
export type BrowsersMap = {
|
19
|
+
ubuntu(browser: string): [string, string, string];
|
20
|
+
macOS(browser: string): [string, string, string];
|
21
|
+
baileys(browser: string): [string, string, string];
|
22
|
+
windows(browser: string): [string, string, string];
|
23
|
+
iOS(browser: string): [string, string, string];
|
24
|
+
linux(browser: string): [string, string, string];
|
25
|
+
appropriate(browser: string): [string, string, string];
|
26
|
+
};
|
27
|
+
export declare enum DisconnectReason {
|
28
|
+
connectionClosed = 428,
|
29
|
+
connectionLost = 408,
|
30
|
+
connectionReplaced = 440,
|
31
|
+
timedOut = 408,
|
32
|
+
loggedOut = 401,
|
33
|
+
badSession = 500,
|
34
|
+
restartRequired = 515,
|
35
|
+
multideviceMismatch = 411,
|
36
|
+
forbidden = 403,
|
37
|
+
unavailableService = 503
|
38
|
+
}
|
39
|
+
export type WAInitResponse = {
|
40
|
+
ref: string;
|
41
|
+
ttl: number;
|
42
|
+
status: 200;
|
43
|
+
};
|
44
|
+
export type WABusinessHoursConfig = {
|
45
|
+
day_of_week: string;
|
46
|
+
mode: string;
|
47
|
+
open_time?: number;
|
48
|
+
close_time?: number;
|
49
|
+
};
|
50
|
+
export type WABusinessProfile = {
|
51
|
+
description: string;
|
52
|
+
email: string | undefined;
|
53
|
+
business_hours: {
|
54
|
+
timezone?: string;
|
55
|
+
config?: WABusinessHoursConfig[];
|
56
|
+
business_config?: WABusinessHoursConfig[];
|
57
|
+
};
|
58
|
+
website: string[];
|
59
|
+
category?: string;
|
60
|
+
wid?: string;
|
61
|
+
address?: string;
|
62
|
+
};
|
63
|
+
export type CurveKeyPair = {
|
64
|
+
private: Uint8Array;
|
65
|
+
public: Uint8Array;
|
66
|
+
};
|
@@ -0,0 +1,18 @@
|
|
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;
|
@@ -0,0 +1,16 @@
|
|
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
|
+
};
|
@@ -0,0 +1,22 @@
|
|
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: any;
|
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
|
+
}[]>;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
2
|
+
import type { Logger } from 'pino';
|
3
|
+
import { proto } from '../../WAProto';
|
4
|
+
import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
5
|
+
import { BinaryNode } from '../WABinary';
|
6
|
+
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
7
|
+
export type ChatMutationMap = {
|
8
|
+
[index: string]: ChatMutation;
|
9
|
+
};
|
10
|
+
export declare const newLTHashState: () => LTHashState;
|
11
|
+
export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
|
12
|
+
patch: proto.ISyncdPatch;
|
13
|
+
state: LTHashState;
|
14
|
+
}>;
|
15
|
+
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
16
|
+
hash: any;
|
17
|
+
indexValueMap: {
|
18
|
+
[indexMacBase64: string]: {
|
19
|
+
valueMac: Uint8Array | Buffer;
|
20
|
+
};
|
21
|
+
};
|
22
|
+
}>;
|
23
|
+
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
24
|
+
hash: any;
|
25
|
+
indexValueMap: {
|
26
|
+
[indexMacBase64: string]: {
|
27
|
+
valueMac: Uint8Array | Buffer;
|
28
|
+
};
|
29
|
+
};
|
30
|
+
}>;
|
31
|
+
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
|
32
|
+
critical_block: {
|
33
|
+
patches: proto.ISyncdPatch[];
|
34
|
+
hasMorePatches: boolean;
|
35
|
+
snapshot?: proto.ISyncdSnapshot;
|
36
|
+
};
|
37
|
+
critical_unblock_low: {
|
38
|
+
patches: proto.ISyncdPatch[];
|
39
|
+
hasMorePatches: boolean;
|
40
|
+
snapshot?: proto.ISyncdSnapshot;
|
41
|
+
};
|
42
|
+
regular_high: {
|
43
|
+
patches: proto.ISyncdPatch[];
|
44
|
+
hasMorePatches: boolean;
|
45
|
+
snapshot?: proto.ISyncdSnapshot;
|
46
|
+
};
|
47
|
+
regular_low: {
|
48
|
+
patches: proto.ISyncdPatch[];
|
49
|
+
hasMorePatches: boolean;
|
50
|
+
snapshot?: proto.ISyncdSnapshot;
|
51
|
+
};
|
52
|
+
regular: {
|
53
|
+
patches: proto.ISyncdPatch[];
|
54
|
+
hasMorePatches: boolean;
|
55
|
+
snapshot?: proto.ISyncdSnapshot;
|
56
|
+
};
|
57
|
+
}>;
|
58
|
+
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<any>;
|
59
|
+
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
|
60
|
+
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
61
|
+
state: LTHashState;
|
62
|
+
mutationMap: ChatMutationMap;
|
63
|
+
}>;
|
64
|
+
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
|
65
|
+
state: LTHashState;
|
66
|
+
mutationMap: ChatMutationMap;
|
67
|
+
}>;
|
68
|
+
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
69
|
+
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
|
70
|
+
export {};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { KeyPair } from '../Types';
|
2
|
+
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
3
|
+
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => any;
|
4
|
+
export declare const Curve: {
|
5
|
+
generateKeyPair: () => KeyPair;
|
6
|
+
sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => any;
|
7
|
+
sign: (privateKey: Uint8Array, buf: Uint8Array) => any;
|
8
|
+
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
|
9
|
+
};
|
10
|
+
export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) => {
|
11
|
+
keyPair: KeyPair;
|
12
|
+
signature: any;
|
13
|
+
keyId: number;
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* encrypt AES 256 GCM;
|
17
|
+
* where the tag tag is suffixed to the ciphertext
|
18
|
+
* */
|
19
|
+
export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): any;
|
20
|
+
/**
|
21
|
+
* decrypt AES 256 GCM;
|
22
|
+
* where the auth tag is suffixed to the ciphertext
|
23
|
+
* */
|
24
|
+
export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): any;
|
25
|
+
export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): any;
|
26
|
+
export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): any;
|
27
|
+
/** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
|
28
|
+
export declare function aesDecrypt(buffer: Buffer, key: Buffer): any;
|
29
|
+
/** decrypt AES 256 CBC */
|
30
|
+
export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): any;
|
31
|
+
export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer): any;
|
32
|
+
export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): any;
|
33
|
+
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): any;
|
34
|
+
export declare function sha256(buffer: Buffer): any;
|
35
|
+
export declare function md5(buffer: Buffer): any;
|
36
|
+
export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number, info: {
|
37
|
+
salt?: Buffer;
|
38
|
+
info?: string;
|
39
|
+
}): any;
|
40
|
+
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<any>;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { Logger } from 'pino';
|
2
|
+
import { proto } from '../../WAProto';
|
3
|
+
import { SignalRepository } from '../Types';
|
4
|
+
import { BinaryNode } from '../WABinary';
|
5
|
+
export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
|
6
|
+
export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled";
|
7
|
+
export declare const NACK_REASONS: {
|
8
|
+
ParsingError: number;
|
9
|
+
UnrecognizedStanza: number;
|
10
|
+
UnrecognizedStanzaClass: number;
|
11
|
+
UnrecognizedStanzaType: number;
|
12
|
+
InvalidProtobuf: number;
|
13
|
+
InvalidHostedCompanionStanza: number;
|
14
|
+
MissingMessageSecret: number;
|
15
|
+
SignalErrorOldCounter: number;
|
16
|
+
MessageDeletedOnPeer: number;
|
17
|
+
UnhandledError: number;
|
18
|
+
UnsupportedAdminRevoke: number;
|
19
|
+
UnsupportedLIDGroup: number;
|
20
|
+
DBOperationFailed: number;
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* Decode the received node as a message.
|
24
|
+
* @note this will only parse the message, not decrypt it
|
25
|
+
*/
|
26
|
+
export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
|
27
|
+
fullMessage: proto.IWebMessageInfo;
|
28
|
+
author: string;
|
29
|
+
sender: string;
|
30
|
+
};
|
31
|
+
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: Logger) => {
|
32
|
+
fullMessage: proto.IWebMessageInfo;
|
33
|
+
category: string;
|
34
|
+
author: string;
|
35
|
+
decrypt(): Promise<void>;
|
36
|
+
};
|
@@ -0,0 +1,35 @@
|
|
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 {};
|