@d0v3riz/baileys 6.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/README.md +956 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +2845 -0
- package/WAProto/index.d.ts +32006 -0
- package/WAProto/index.js +87184 -0
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +106 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/readme.md +6 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +54 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/WASignalGroup/sender_message_key.js +39 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +284 -0
- package/lib/Defaults/index.js +115 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +151 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +16 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +19 -0
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +124 -0
- package/lib/Socket/business.js +259 -0
- package/lib/Socket/chats.d.ts +74 -0
- package/lib/Socket/chats.js +838 -0
- package/lib/Socket/groups.d.ts +105 -0
- package/lib/Socket/groups.js +291 -0
- package/lib/Socket/index.d.ts +126 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.d.ts +112 -0
- package/lib/Socket/messages-recv.js +641 -0
- package/lib/Socket/messages-send.d.ts +110 -0
- package/lib/Socket/messages-send.js +648 -0
- package/lib/Socket/registration.d.ts +211 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +42 -0
- package/lib/Socket/socket.js +527 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +117 -0
- package/lib/Store/make-in-memory-store.js +435 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +106 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +12 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +18 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +152 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +42 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.d.ts +245 -0
- package/lib/Types/Message.js +9 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +106 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/index.d.ts +54 -0
- package/lib/Types/index.js +39 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +202 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +710 -0
- package/lib/Utils/crypto.d.ts +38 -0
- package/lib/Utils/crypto.js +137 -0
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +160 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +514 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +368 -0
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +91 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +33 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +116 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/messages-media.d.ts +101 -0
- package/lib/Utils/messages-media.js +632 -0
- package/lib/Utils/messages.d.ts +75 -0
- package/lib/Utils/messages.js +738 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +142 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +297 -0
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +151 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +80 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +188 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +40 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +252 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +228 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +27 -0
- package/lib/WABinary/jid-utils.js +56 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +27 -0
- package/package.json +100 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
4
|
+
import type { Readable } from 'stream';
|
|
5
|
+
import type { URL } from 'url';
|
|
6
|
+
import { proto } from '../../WAProto';
|
|
7
|
+
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
8
|
+
import type { GroupMetadata } from './GroupMetadata';
|
|
9
|
+
import { CacheStore } from './Socket';
|
|
10
|
+
export { proto as WAProto };
|
|
11
|
+
export declare type WAMessage = proto.IWebMessageInfo;
|
|
12
|
+
export declare type WAMessageContent = proto.IMessage;
|
|
13
|
+
export declare type WAContactMessage = proto.Message.IContactMessage;
|
|
14
|
+
export declare type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
|
15
|
+
export declare type WAMessageKey = proto.IMessageKey;
|
|
16
|
+
export declare type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
17
|
+
export declare type WAContextInfo = proto.IContextInfo;
|
|
18
|
+
export declare type WALocationMessage = proto.Message.ILocationMessage;
|
|
19
|
+
export declare type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
20
|
+
export import WAMessageStubType = proto.WebMessageInfo.StubType;
|
|
21
|
+
export import WAMessageStatus = proto.WebMessageInfo.Status;
|
|
22
|
+
export declare type WAMediaUpload = Buffer | {
|
|
23
|
+
url: URL | string;
|
|
24
|
+
} | {
|
|
25
|
+
stream: Readable;
|
|
26
|
+
};
|
|
27
|
+
/** Set of message types that are supported by the library */
|
|
28
|
+
export declare type MessageType = keyof proto.Message;
|
|
29
|
+
export declare type DownloadableMessage = {
|
|
30
|
+
mediaKey?: Uint8Array | null;
|
|
31
|
+
directPath?: string | null;
|
|
32
|
+
url?: string | null;
|
|
33
|
+
};
|
|
34
|
+
export declare type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
|
35
|
+
export declare type MediaConnInfo = {
|
|
36
|
+
auth: string;
|
|
37
|
+
ttl: number;
|
|
38
|
+
hosts: {
|
|
39
|
+
hostname: string;
|
|
40
|
+
maxContentLengthBytes: number;
|
|
41
|
+
}[];
|
|
42
|
+
fetchDate: Date;
|
|
43
|
+
};
|
|
44
|
+
export interface WAUrlInfo {
|
|
45
|
+
'canonical-url': string;
|
|
46
|
+
'matched-text': string;
|
|
47
|
+
title: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
jpegThumbnail?: Buffer;
|
|
50
|
+
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
51
|
+
originalThumbnailUrl?: string;
|
|
52
|
+
}
|
|
53
|
+
declare type Mentionable = {
|
|
54
|
+
/** list of jids that are mentioned in the accompanying text */
|
|
55
|
+
mentions?: string[];
|
|
56
|
+
};
|
|
57
|
+
declare type Contextable = {
|
|
58
|
+
/** add contextInfo to the message */
|
|
59
|
+
contextInfo?: proto.IContextInfo;
|
|
60
|
+
};
|
|
61
|
+
declare type ViewOnce = {
|
|
62
|
+
viewOnce?: boolean;
|
|
63
|
+
};
|
|
64
|
+
declare type Buttonable = {
|
|
65
|
+
/** add buttons to the message */
|
|
66
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
67
|
+
};
|
|
68
|
+
declare type Templatable = {
|
|
69
|
+
/** add buttons to the message (conflicts with normal buttons)*/
|
|
70
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
|
71
|
+
footer?: string;
|
|
72
|
+
};
|
|
73
|
+
declare type Editable = {
|
|
74
|
+
edit?: WAMessageKey;
|
|
75
|
+
};
|
|
76
|
+
declare type Listable = {
|
|
77
|
+
/** Sections of the List */
|
|
78
|
+
sections?: proto.Message.ListMessage.ISection[];
|
|
79
|
+
/** Title of a List Message only */
|
|
80
|
+
title?: string;
|
|
81
|
+
/** Text of the bnutton on the list (required) */
|
|
82
|
+
buttonText?: string;
|
|
83
|
+
};
|
|
84
|
+
declare type WithDimensions = {
|
|
85
|
+
width?: number;
|
|
86
|
+
height?: number;
|
|
87
|
+
};
|
|
88
|
+
export declare type PollMessageOptions = {
|
|
89
|
+
name: string;
|
|
90
|
+
selectableCount?: number;
|
|
91
|
+
values: string[];
|
|
92
|
+
/** 32 byte message secret to encrypt poll selections */
|
|
93
|
+
messageSecret?: Uint8Array;
|
|
94
|
+
};
|
|
95
|
+
export declare type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
96
|
+
export declare type AnyMediaMessageContent = (({
|
|
97
|
+
image: WAMediaUpload;
|
|
98
|
+
caption?: string;
|
|
99
|
+
jpegThumbnail?: string;
|
|
100
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
|
|
101
|
+
video: WAMediaUpload;
|
|
102
|
+
caption?: string;
|
|
103
|
+
gifPlayback?: boolean;
|
|
104
|
+
jpegThumbnail?: string;
|
|
105
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
|
|
106
|
+
audio: WAMediaUpload;
|
|
107
|
+
/** if set to true, will send as a `voice note` */
|
|
108
|
+
ptt?: boolean;
|
|
109
|
+
/** optionally tell the duration of the audio */
|
|
110
|
+
seconds?: number;
|
|
111
|
+
} | ({
|
|
112
|
+
sticker: WAMediaUpload;
|
|
113
|
+
isAnimated?: boolean;
|
|
114
|
+
} & WithDimensions) | ({
|
|
115
|
+
document: WAMediaUpload;
|
|
116
|
+
mimetype: string;
|
|
117
|
+
fileName?: string;
|
|
118
|
+
caption?: string;
|
|
119
|
+
} & Contextable & Buttonable & Templatable)) & {
|
|
120
|
+
mimetype?: string;
|
|
121
|
+
} & Editable;
|
|
122
|
+
export declare type ButtonReplyInfo = {
|
|
123
|
+
displayText: string;
|
|
124
|
+
id: string;
|
|
125
|
+
index: number;
|
|
126
|
+
};
|
|
127
|
+
export declare type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
128
|
+
productImage: WAMediaUpload;
|
|
129
|
+
};
|
|
130
|
+
export declare type AnyRegularMessageContent = (({
|
|
131
|
+
text: string;
|
|
132
|
+
linkPreview?: WAUrlInfo | null;
|
|
133
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
134
|
+
poll: PollMessageOptions;
|
|
135
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
136
|
+
contacts: {
|
|
137
|
+
displayName?: string;
|
|
138
|
+
contacts: proto.Message.IContactMessage[];
|
|
139
|
+
};
|
|
140
|
+
} | {
|
|
141
|
+
location: WALocationMessage;
|
|
142
|
+
} | {
|
|
143
|
+
react: proto.Message.IReactionMessage;
|
|
144
|
+
} | {
|
|
145
|
+
buttonReply: ButtonReplyInfo;
|
|
146
|
+
type: 'template' | 'plain';
|
|
147
|
+
} | {
|
|
148
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
149
|
+
} | {
|
|
150
|
+
product: WASendableProduct;
|
|
151
|
+
businessOwnerJid?: string;
|
|
152
|
+
body?: string;
|
|
153
|
+
footer?: string;
|
|
154
|
+
}) & ViewOnce;
|
|
155
|
+
export declare type AnyMessageContent = AnyRegularMessageContent | {
|
|
156
|
+
forward: WAMessage;
|
|
157
|
+
force?: boolean;
|
|
158
|
+
} | {
|
|
159
|
+
/** Delete your message or anyone's message in a group (admin required) */
|
|
160
|
+
delete: WAMessageKey;
|
|
161
|
+
} | {
|
|
162
|
+
disappearingMessagesInChat: boolean | number;
|
|
163
|
+
};
|
|
164
|
+
export declare type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
165
|
+
declare type MinimalRelayOptions = {
|
|
166
|
+
/** override the message ID with a custom provided string */
|
|
167
|
+
messageId?: string;
|
|
168
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
169
|
+
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
|
|
170
|
+
};
|
|
171
|
+
export declare type MessageRelayOptions = MinimalRelayOptions & {
|
|
172
|
+
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
173
|
+
participant?: {
|
|
174
|
+
jid: string;
|
|
175
|
+
count: number;
|
|
176
|
+
};
|
|
177
|
+
/** additional attributes to add to the WA binary node */
|
|
178
|
+
additionalAttributes?: {
|
|
179
|
+
[_: string]: string;
|
|
180
|
+
};
|
|
181
|
+
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
|
182
|
+
useUserDevicesCache?: boolean;
|
|
183
|
+
};
|
|
184
|
+
export declare type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
185
|
+
/** optional, if you want to manually set the timestamp of the message */
|
|
186
|
+
timestamp?: Date;
|
|
187
|
+
/** the message you want to quote */
|
|
188
|
+
quoted?: WAMessage;
|
|
189
|
+
/** additional contextInfo */
|
|
190
|
+
contextInfo?: proto.IMessageContextInfo;
|
|
191
|
+
/** disappearing messages settings */
|
|
192
|
+
ephemeralExpiration?: number | string;
|
|
193
|
+
/** timeout for media upload to WA server */
|
|
194
|
+
mediaUploadTimeoutMs?: number;
|
|
195
|
+
};
|
|
196
|
+
export declare type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
197
|
+
userJid: string;
|
|
198
|
+
};
|
|
199
|
+
export declare type WAMediaUploadFunction = (readStream: Readable, opts: {
|
|
200
|
+
fileEncSha256B64: string;
|
|
201
|
+
mediaType: MediaType;
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
}) => Promise<{
|
|
204
|
+
mediaUrl: string;
|
|
205
|
+
directPath: string;
|
|
206
|
+
}>;
|
|
207
|
+
export declare type MediaGenerationOptions = {
|
|
208
|
+
logger?: Logger;
|
|
209
|
+
mediaTypeOverride?: MediaType;
|
|
210
|
+
upload: WAMediaUploadFunction;
|
|
211
|
+
/** cache media so it does not have to be uploaded again */
|
|
212
|
+
mediaCache?: CacheStore;
|
|
213
|
+
mediaUploadTimeoutMs?: number;
|
|
214
|
+
options?: AxiosRequestConfig;
|
|
215
|
+
};
|
|
216
|
+
export declare type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
217
|
+
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
218
|
+
};
|
|
219
|
+
export declare type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
220
|
+
/**
|
|
221
|
+
* Type of message upsert
|
|
222
|
+
* 1. notify => notify the user, this message was just received
|
|
223
|
+
* 2. append => append the message to the chat history, no notification required
|
|
224
|
+
*/
|
|
225
|
+
export declare type MessageUpsertType = 'append' | 'notify';
|
|
226
|
+
export declare type MessageUserReceipt = proto.IUserReceipt;
|
|
227
|
+
export declare type WAMessageUpdate = {
|
|
228
|
+
update: Partial<WAMessage>;
|
|
229
|
+
key: proto.IMessageKey;
|
|
230
|
+
};
|
|
231
|
+
export declare type WAMessageCursor = {
|
|
232
|
+
before: WAMessageKey | undefined;
|
|
233
|
+
} | {
|
|
234
|
+
after: WAMessageKey | undefined;
|
|
235
|
+
};
|
|
236
|
+
export declare type MessageUserReceiptUpdate = {
|
|
237
|
+
key: proto.IMessageKey;
|
|
238
|
+
receipt: MessageUserReceipt;
|
|
239
|
+
};
|
|
240
|
+
export declare type MediaDecryptionKeyInfo = {
|
|
241
|
+
iv: Buffer;
|
|
242
|
+
cipherKey: Buffer;
|
|
243
|
+
macKey?: Buffer;
|
|
244
|
+
};
|
|
245
|
+
export declare type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
|
|
4
|
+
const WAProto_1 = require("../../WAProto");
|
|
5
|
+
Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
|
6
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
7
|
+
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
|
8
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
9
|
+
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { WAMediaUpload } from './Message';
|
|
2
|
+
export declare type CatalogResult = {
|
|
3
|
+
data: {
|
|
4
|
+
paging: {
|
|
5
|
+
cursors: {
|
|
6
|
+
before: string;
|
|
7
|
+
after: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
data: any[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type ProductCreateResult = {
|
|
14
|
+
data: {
|
|
15
|
+
product: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type CatalogStatus = {
|
|
19
|
+
status: string;
|
|
20
|
+
canAppeal: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type CatalogCollection = {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
products: Product[];
|
|
26
|
+
status: CatalogStatus;
|
|
27
|
+
};
|
|
28
|
+
export declare type ProductAvailability = 'in stock';
|
|
29
|
+
export declare 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 declare 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 declare type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
|
|
45
|
+
export declare type Product = ProductBase & {
|
|
46
|
+
id: string;
|
|
47
|
+
imageUrls: {
|
|
48
|
+
[_: string]: string;
|
|
49
|
+
};
|
|
50
|
+
reviewStatus: {
|
|
51
|
+
[_: string]: string;
|
|
52
|
+
};
|
|
53
|
+
availability: ProductAvailability;
|
|
54
|
+
};
|
|
55
|
+
export declare type OrderPrice = {
|
|
56
|
+
currency: string;
|
|
57
|
+
total: number;
|
|
58
|
+
};
|
|
59
|
+
export declare type OrderProduct = {
|
|
60
|
+
id: string;
|
|
61
|
+
imageUrl: string;
|
|
62
|
+
name: string;
|
|
63
|
+
quantity: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
price: number;
|
|
66
|
+
};
|
|
67
|
+
export declare type OrderDetails = {
|
|
68
|
+
price: OrderPrice;
|
|
69
|
+
products: OrderProduct[];
|
|
70
|
+
};
|
|
71
|
+
export declare type CatalogCursor = string;
|
|
72
|
+
export declare 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
|
+
declare type DecryptGroupSignalOpts = {
|
|
3
|
+
group: string;
|
|
4
|
+
authorJid: string;
|
|
5
|
+
msg: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
declare type ProcessSenderKeyDistributionMessageOpts = {
|
|
8
|
+
item: proto.Message.ISenderKeyDistributionMessage;
|
|
9
|
+
authorJid: string;
|
|
10
|
+
};
|
|
11
|
+
declare type DecryptSignalProtoOpts = {
|
|
12
|
+
jid: string;
|
|
13
|
+
type: 'pkmsg' | 'msg';
|
|
14
|
+
ciphertext: Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
declare type EncryptMessageOpts = {
|
|
17
|
+
jid: string;
|
|
18
|
+
data: Uint8Array;
|
|
19
|
+
};
|
|
20
|
+
declare type EncryptGroupMessageOpts = {
|
|
21
|
+
group: string;
|
|
22
|
+
data: Uint8Array;
|
|
23
|
+
meId: string;
|
|
24
|
+
};
|
|
25
|
+
declare type PreKey = {
|
|
26
|
+
keyId: number;
|
|
27
|
+
publicKey: Uint8Array;
|
|
28
|
+
};
|
|
29
|
+
declare type SignedPreKey = PreKey & {
|
|
30
|
+
signature: Uint8Array;
|
|
31
|
+
};
|
|
32
|
+
declare type E2ESession = {
|
|
33
|
+
registrationId: number;
|
|
34
|
+
identityKey: Uint8Array;
|
|
35
|
+
signedPreKey: SignedPreKey;
|
|
36
|
+
preKey: PreKey;
|
|
37
|
+
};
|
|
38
|
+
declare type E2ESessionOpts = {
|
|
39
|
+
jid: string;
|
|
40
|
+
session: E2ESession;
|
|
41
|
+
};
|
|
42
|
+
export declare 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,106 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type { Agent } from 'https';
|
|
4
|
+
import type { Logger } from 'pino';
|
|
5
|
+
import type { URL } from 'url';
|
|
6
|
+
import { proto } from '../../WAProto';
|
|
7
|
+
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
|
8
|
+
import { MediaConnInfo } from './Message';
|
|
9
|
+
import { SignalRepository } from './Signal';
|
|
10
|
+
export declare type WAVersion = [number, number, number];
|
|
11
|
+
export declare type WABrowserDescription = [string, string, string];
|
|
12
|
+
export declare 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 declare 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
|
+
/** time to wait for the generation of the next QR in ms */
|
|
52
|
+
qrTimeout?: number;
|
|
53
|
+
/** provide an auth state object to maintain the auth state */
|
|
54
|
+
auth: AuthenticationState;
|
|
55
|
+
/** manage history processing with this control; by default will sync up everything */
|
|
56
|
+
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
|
|
57
|
+
/** transaction capability options for SignalKeyStore */
|
|
58
|
+
transactionOpts: TransactionCapabilityOptions;
|
|
59
|
+
/** marks the client as online whenever the socket successfully connects */
|
|
60
|
+
markOnlineOnConnect: boolean;
|
|
61
|
+
/** provide a cache to store media, so does not have to be re-uploaded */
|
|
62
|
+
mediaCache?: CacheStore;
|
|
63
|
+
/**
|
|
64
|
+
* map to store the retry counts for failed messages;
|
|
65
|
+
* used to determine whether to retry a message or not */
|
|
66
|
+
msgRetryCounterCache?: CacheStore;
|
|
67
|
+
/** provide a cache to store a user's device list */
|
|
68
|
+
userDevicesCache?: CacheStore;
|
|
69
|
+
/** cache to store call offers */
|
|
70
|
+
callOfferCache?: CacheStore;
|
|
71
|
+
/** width for link preview images */
|
|
72
|
+
linkPreviewImageThumbnailWidth: number;
|
|
73
|
+
/** Should Baileys ask the phone for full history, will be received async */
|
|
74
|
+
syncFullHistory: boolean;
|
|
75
|
+
/** Should baileys fire init queries automatically, default true */
|
|
76
|
+
fireInitQueries: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* generate a high quality link preview,
|
|
79
|
+
* entails uploading the jpegThumbnail to WA
|
|
80
|
+
* */
|
|
81
|
+
generateHighQualityLinkPreview: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Returns if a jid should be ignored,
|
|
84
|
+
* no event for that jid will be triggered.
|
|
85
|
+
* Messages from that jid will also not be decrypted
|
|
86
|
+
* */
|
|
87
|
+
shouldIgnoreJid: (jid: string) => boolean | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Optionally patch the message before sending out
|
|
90
|
+
* */
|
|
91
|
+
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
|
|
92
|
+
/** verify app state MACs */
|
|
93
|
+
appStateMacVerification: {
|
|
94
|
+
patch: boolean;
|
|
95
|
+
snapshot: boolean;
|
|
96
|
+
};
|
|
97
|
+
/** options for axios */
|
|
98
|
+
options: AxiosRequestConfig<{}>;
|
|
99
|
+
/**
|
|
100
|
+
* fetch a message from your store
|
|
101
|
+
* implement this so that messages failed to send
|
|
102
|
+
* (solves the "this message can take a while" issue) can be retried
|
|
103
|
+
* */
|
|
104
|
+
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
|
105
|
+
makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
|
|
106
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Contact } from './Contact';
|
|
2
|
+
export declare type WAConnectionState = 'open' | 'connecting' | 'close';
|
|
3
|
+
export declare 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,54 @@
|
|
|
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 './Socket';
|
|
8
|
+
export * from './Events';
|
|
9
|
+
export * from './Product';
|
|
10
|
+
export * from './Call';
|
|
11
|
+
export * from './Signal';
|
|
12
|
+
import { AuthenticationState } from './Auth';
|
|
13
|
+
import { SocketConfig } from './Socket';
|
|
14
|
+
export declare type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
15
|
+
auth: AuthenticationState;
|
|
16
|
+
};
|
|
17
|
+
export declare enum DisconnectReason {
|
|
18
|
+
connectionClosed = 428,
|
|
19
|
+
connectionLost = 408,
|
|
20
|
+
connectionReplaced = 440,
|
|
21
|
+
timedOut = 408,
|
|
22
|
+
loggedOut = 401,
|
|
23
|
+
badSession = 500,
|
|
24
|
+
restartRequired = 515,
|
|
25
|
+
multideviceMismatch = 411
|
|
26
|
+
}
|
|
27
|
+
export declare type WAInitResponse = {
|
|
28
|
+
ref: string;
|
|
29
|
+
ttl: number;
|
|
30
|
+
status: 200;
|
|
31
|
+
};
|
|
32
|
+
export declare type WABusinessHoursConfig = {
|
|
33
|
+
day_of_week: string;
|
|
34
|
+
mode: string;
|
|
35
|
+
open_time?: number;
|
|
36
|
+
close_time?: number;
|
|
37
|
+
};
|
|
38
|
+
export declare type WABusinessProfile = {
|
|
39
|
+
description: string;
|
|
40
|
+
email: string | undefined;
|
|
41
|
+
business_hours: {
|
|
42
|
+
timezone?: string;
|
|
43
|
+
config?: WABusinessHoursConfig[];
|
|
44
|
+
business_config?: WABusinessHoursConfig[];
|
|
45
|
+
};
|
|
46
|
+
website: string[];
|
|
47
|
+
category?: string;
|
|
48
|
+
wid?: string;
|
|
49
|
+
address?: string;
|
|
50
|
+
};
|
|
51
|
+
export declare type CurveKeyPair = {
|
|
52
|
+
private: Uint8Array;
|
|
53
|
+
public: Uint8Array;
|
|
54
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DisconnectReason = void 0;
|
|
18
|
+
__exportStar(require("./Auth"), exports);
|
|
19
|
+
__exportStar(require("./GroupMetadata"), exports);
|
|
20
|
+
__exportStar(require("./Chat"), exports);
|
|
21
|
+
__exportStar(require("./Contact"), exports);
|
|
22
|
+
__exportStar(require("./State"), exports);
|
|
23
|
+
__exportStar(require("./Message"), exports);
|
|
24
|
+
__exportStar(require("./Socket"), exports);
|
|
25
|
+
__exportStar(require("./Events"), exports);
|
|
26
|
+
__exportStar(require("./Product"), exports);
|
|
27
|
+
__exportStar(require("./Call"), exports);
|
|
28
|
+
__exportStar(require("./Signal"), exports);
|
|
29
|
+
var DisconnectReason;
|
|
30
|
+
(function (DisconnectReason) {
|
|
31
|
+
DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
|
|
32
|
+
DisconnectReason[DisconnectReason["connectionLost"] = 408] = "connectionLost";
|
|
33
|
+
DisconnectReason[DisconnectReason["connectionReplaced"] = 440] = "connectionReplaced";
|
|
34
|
+
DisconnectReason[DisconnectReason["timedOut"] = 408] = "timedOut";
|
|
35
|
+
DisconnectReason[DisconnectReason["loggedOut"] = 401] = "loggedOut";
|
|
36
|
+
DisconnectReason[DisconnectReason["badSession"] = 500] = "badSession";
|
|
37
|
+
DisconnectReason[DisconnectReason["restartRequired"] = 515] = "restartRequired";
|
|
38
|
+
DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
|
|
39
|
+
})(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
|
|
@@ -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;
|