@genuxofficial/baileys 1.0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +3344 -0
- package/WAProto/index.d.ts +37016 -0
- package/WAProto/index.js +101044 -0
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -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/queue_job.js +69 -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 +56 -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 +53 -0
- package/lib/Defaults/index.js +106 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +152 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +18 -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/websocket.js +62 -0
- package/lib/Socket/business.d.ts +149 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.d.ts +85 -0
- package/lib/Socket/chats.js +850 -0
- package/lib/Socket/groups.d.ts +124 -0
- package/lib/Socket/groups.js +314 -0
- package/lib/Socket/index.d.ts +149 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.d.ts +136 -0
- package/lib/Socket/messages-recv.js +912 -0
- package/lib/Socket/messages-send.d.ts +130 -0
- package/lib/Socket/messages-send.js +673 -0
- package/lib/Socket/socket.d.ts +45 -0
- package/lib/Socket/socket.js +622 -0
- package/lib/Socket/usync.d.ts +38 -0
- package/lib/Socket/usync.js +70 -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 +118 -0
- package/lib/Store/make-in-memory-store.js +420 -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 +105 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +108 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +56 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +46 -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 +271 -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 +118 -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/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +63 -0
- package/lib/Types/index.js +41 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +200 -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 +72 -0
- package/lib/Utils/chat-utils.js +745 -0
- package/lib/Utils/crypto.d.ts +42 -0
- package/lib/Utils/crypto.js +181 -0
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/decode-wa-message.js +205 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +520 -0
- package/lib/Utils/generics.d.ts +94 -0
- package/lib/Utils/generics.js +433 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/history.js +94 -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 +11 -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 +44 -0
- package/lib/Utils/messages-media.d.ts +108 -0
- package/lib/Utils/messages-media.js +667 -0
- package/lib/Utils/messages.d.ts +78 -0
- package/lib/Utils/messages.js +760 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.d.ts +42 -0
- package/lib/Utils/process-message.js +373 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +94 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/Utils/validate-connection.js +175 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +40 -0
- package/lib/WABinary/decode.d.ts +8 -0
- package/lib/WABinary/decode.js +254 -0
- package/lib/WABinary/encode.d.ts +4 -0
- package/lib/WABinary/encode.js +234 -0
- package/lib/WABinary/generic-utils.d.ts +16 -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 +31 -0
- package/lib/WABinary/jid-utils.js +62 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +18 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +39 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +4 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +31 -0
- package/package.json +104 -0
@@ -0,0 +1,271 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
4
|
+
/// <reference types="node" />
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
6
|
+
import type { Readable } from 'stream';
|
7
|
+
import type { URL } from 'url';
|
8
|
+
import { proto } from '../../WAProto';
|
9
|
+
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
10
|
+
import { BinaryNode } from '../WABinary';
|
11
|
+
import type { GroupMetadata } from './GroupMetadata';
|
12
|
+
import { CacheStore } from './Socket';
|
13
|
+
export { proto as WAProto };
|
14
|
+
export type WAMessage = proto.IWebMessageInfo;
|
15
|
+
export type WAMessageContent = proto.IMessage;
|
16
|
+
export type WAContactMessage = proto.Message.IContactMessage;
|
17
|
+
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
18
|
+
export type WAMessageKey = proto.IMessageKey;
|
19
|
+
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
20
|
+
export type WAContextInfo = proto.IContextInfo;
|
21
|
+
export type WALocationMessage = proto.Message.ILocationMessage;
|
22
|
+
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
23
|
+
export import WAMessageStubType = proto.WebMessageInfo.StubType;
|
24
|
+
export import WAMessageStatus = proto.WebMessageInfo.Status;
|
25
|
+
import { ILogger } from '../Utils/logger';
|
26
|
+
export type WAMediaPayloadURL = {
|
27
|
+
url: URL | string;
|
28
|
+
};
|
29
|
+
export type WAMediaPayloadStream = {
|
30
|
+
stream: Readable;
|
31
|
+
};
|
32
|
+
export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
|
33
|
+
/** Set of message types that are supported by the library */
|
34
|
+
export type MessageType = keyof proto.Message;
|
35
|
+
export type DownloadableMessage = {
|
36
|
+
mediaKey?: Uint8Array | null;
|
37
|
+
directPath?: string | null;
|
38
|
+
url?: string | null;
|
39
|
+
};
|
40
|
+
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
41
|
+
export type MediaConnInfo = {
|
42
|
+
auth: string;
|
43
|
+
ttl: number;
|
44
|
+
hosts: {
|
45
|
+
hostname: string;
|
46
|
+
maxContentLengthBytes: number;
|
47
|
+
}[];
|
48
|
+
fetchDate: Date;
|
49
|
+
};
|
50
|
+
export interface WAUrlInfo {
|
51
|
+
'canonical-url': string;
|
52
|
+
'matched-text': string;
|
53
|
+
title: string;
|
54
|
+
description?: string;
|
55
|
+
jpegThumbnail?: Buffer;
|
56
|
+
highQualityThumbnail?: proto.Message.IImageMessage;
|
57
|
+
originalThumbnailUrl?: string;
|
58
|
+
}
|
59
|
+
type Mentionable = {
|
60
|
+
/** list of jids that are mentioned in the accompanying text */
|
61
|
+
mentions?: string[];
|
62
|
+
};
|
63
|
+
type Contextable = {
|
64
|
+
/** add contextInfo to the message */
|
65
|
+
contextInfo?: proto.IContextInfo;
|
66
|
+
};
|
67
|
+
type ViewOnce = {
|
68
|
+
viewOnce?: boolean;
|
69
|
+
};
|
70
|
+
type Editable = {
|
71
|
+
edit?: WAMessageKey;
|
72
|
+
};
|
73
|
+
type WithDimensions = {
|
74
|
+
width?: number;
|
75
|
+
height?: number;
|
76
|
+
};
|
77
|
+
export type PollMessageOptions = {
|
78
|
+
name: string;
|
79
|
+
selectableCount?: number;
|
80
|
+
values: string[];
|
81
|
+
/** 32 byte message secret to encrypt poll selections */
|
82
|
+
messageSecret?: Uint8Array;
|
83
|
+
toAnnouncementGroup?: boolean;
|
84
|
+
};
|
85
|
+
type SharePhoneNumber = {
|
86
|
+
sharePhoneNumber: boolean;
|
87
|
+
};
|
88
|
+
type RequestPhoneNumber = {
|
89
|
+
requestPhoneNumber: boolean;
|
90
|
+
};
|
91
|
+
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
92
|
+
export type AnyMediaMessageContent = (({
|
93
|
+
image: WAMediaUpload;
|
94
|
+
caption?: string;
|
95
|
+
jpegThumbnail?: string;
|
96
|
+
} & Mentionable & Contextable & WithDimensions) | ({
|
97
|
+
video: WAMediaUpload;
|
98
|
+
caption?: string;
|
99
|
+
gifPlayback?: boolean;
|
100
|
+
jpegThumbnail?: string;
|
101
|
+
/** if set to true, will send as a `video note` */
|
102
|
+
ptv?: boolean;
|
103
|
+
} & Mentionable & Contextable & WithDimensions) | {
|
104
|
+
audio: WAMediaUpload;
|
105
|
+
/** if set to true, will send as a `voice note` */
|
106
|
+
ptt?: boolean;
|
107
|
+
/** optionally tell the duration of the audio */
|
108
|
+
seconds?: number;
|
109
|
+
} | ({
|
110
|
+
sticker: WAMediaUpload;
|
111
|
+
isAnimated?: boolean;
|
112
|
+
} & WithDimensions) | ({
|
113
|
+
document: WAMediaUpload;
|
114
|
+
mimetype: string;
|
115
|
+
fileName?: string;
|
116
|
+
caption?: string;
|
117
|
+
} & Contextable)) & {
|
118
|
+
mimetype?: string;
|
119
|
+
} & Editable;
|
120
|
+
export type ButtonReplyInfo = {
|
121
|
+
displayText: string;
|
122
|
+
id: string;
|
123
|
+
index: number;
|
124
|
+
};
|
125
|
+
export type GroupInviteInfo = {
|
126
|
+
inviteCode: string;
|
127
|
+
inviteExpiration: number;
|
128
|
+
text: string;
|
129
|
+
jid: string;
|
130
|
+
subject: string;
|
131
|
+
};
|
132
|
+
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
133
|
+
productImage: WAMediaUpload;
|
134
|
+
};
|
135
|
+
export type AnyRegularMessageContent = (({
|
136
|
+
text: string;
|
137
|
+
linkPreview?: WAUrlInfo | null;
|
138
|
+
} & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
|
139
|
+
poll: PollMessageOptions;
|
140
|
+
} & Mentionable & Contextable & Editable) | {
|
141
|
+
contacts: {
|
142
|
+
displayName?: string;
|
143
|
+
contacts: proto.Message.IContactMessage[];
|
144
|
+
};
|
145
|
+
} | {
|
146
|
+
location: WALocationMessage;
|
147
|
+
} | {
|
148
|
+
react: proto.Message.IReactionMessage;
|
149
|
+
} | {
|
150
|
+
buttonReply: ButtonReplyInfo;
|
151
|
+
type: 'template' | 'plain';
|
152
|
+
} | {
|
153
|
+
groupInvite: GroupInviteInfo;
|
154
|
+
} | {
|
155
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
156
|
+
} | {
|
157
|
+
pin: WAMessageKey;
|
158
|
+
type: proto.PinInChat.Type;
|
159
|
+
/**
|
160
|
+
* 24 hours, 7 days, 30 days
|
161
|
+
*/
|
162
|
+
time?: 86400 | 604800 | 2592000;
|
163
|
+
} | {
|
164
|
+
product: WASendableProduct;
|
165
|
+
businessOwnerJid?: string;
|
166
|
+
body?: string;
|
167
|
+
footer?: string;
|
168
|
+
} | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
|
169
|
+
export type AnyMessageContent = AnyRegularMessageContent | {
|
170
|
+
forward: WAMessage;
|
171
|
+
force?: boolean;
|
172
|
+
} | {
|
173
|
+
/** Delete your message or anyone's message in a group (admin required) */
|
174
|
+
delete: WAMessageKey;
|
175
|
+
} | {
|
176
|
+
disappearingMessagesInChat: boolean | number;
|
177
|
+
};
|
178
|
+
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
179
|
+
type MinimalRelayOptions = {
|
180
|
+
/** override the message ID with a custom provided string */
|
181
|
+
messageId?: string;
|
182
|
+
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
183
|
+
useCachedGroupMetadata?: boolean;
|
184
|
+
};
|
185
|
+
export type MessageRelayOptions = MinimalRelayOptions & {
|
186
|
+
/** only send to a specific participant; used when a message decryption fails for a single user */
|
187
|
+
participant?: {
|
188
|
+
jid: string;
|
189
|
+
count: number;
|
190
|
+
};
|
191
|
+
/** additional attributes to add to the WA binary node */
|
192
|
+
additionalAttributes?: {
|
193
|
+
[_: string]: string;
|
194
|
+
};
|
195
|
+
additionalNodes?: BinaryNode[];
|
196
|
+
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
197
|
+
useUserDevicesCache?: boolean;
|
198
|
+
/** jid list of participants for status@broadcast */
|
199
|
+
statusJidList?: string[];
|
200
|
+
};
|
201
|
+
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
202
|
+
/** optional, if you want to manually set the timestamp of the message */
|
203
|
+
timestamp?: Date;
|
204
|
+
/** the message you want to quote */
|
205
|
+
quoted?: WAMessage;
|
206
|
+
/** disappearing messages settings */
|
207
|
+
ephemeralExpiration?: number | string;
|
208
|
+
/** timeout for media upload to WA server */
|
209
|
+
mediaUploadTimeoutMs?: number;
|
210
|
+
/** jid list of participants for status@broadcast */
|
211
|
+
statusJidList?: string[];
|
212
|
+
/** backgroundcolor for status */
|
213
|
+
backgroundColor?: string;
|
214
|
+
/** font type for status */
|
215
|
+
font?: number;
|
216
|
+
/** if it is broadcast */
|
217
|
+
broadcast?: boolean;
|
218
|
+
};
|
219
|
+
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
220
|
+
userJid: string;
|
221
|
+
};
|
222
|
+
export type WAMediaUploadFunction = (readStream: Readable, opts: {
|
223
|
+
fileEncSha256B64: string;
|
224
|
+
mediaType: MediaType;
|
225
|
+
timeoutMs?: number;
|
226
|
+
}) => Promise<{
|
227
|
+
mediaUrl: string;
|
228
|
+
directPath: string;
|
229
|
+
}>;
|
230
|
+
export type MediaGenerationOptions = {
|
231
|
+
logger?: ILogger;
|
232
|
+
mediaTypeOverride?: MediaType;
|
233
|
+
upload: WAMediaUploadFunction;
|
234
|
+
/** cache media so it does not have to be uploaded again */
|
235
|
+
mediaCache?: CacheStore;
|
236
|
+
mediaUploadTimeoutMs?: number;
|
237
|
+
options?: AxiosRequestConfig;
|
238
|
+
backgroundColor?: string;
|
239
|
+
font?: number;
|
240
|
+
};
|
241
|
+
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
242
|
+
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
243
|
+
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
|
244
|
+
};
|
245
|
+
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
246
|
+
/**
|
247
|
+
* Type of message upsert
|
248
|
+
* 1. notify => notify the user, this message was just received
|
249
|
+
* 2. append => append the message to the chat history, no notification required
|
250
|
+
*/
|
251
|
+
export type MessageUpsertType = 'append' | 'notify';
|
252
|
+
export type MessageUserReceipt = proto.IUserReceipt;
|
253
|
+
export type WAMessageUpdate = {
|
254
|
+
update: Partial<WAMessage>;
|
255
|
+
key: proto.IMessageKey;
|
256
|
+
};
|
257
|
+
export type WAMessageCursor = {
|
258
|
+
before: WAMessageKey | undefined;
|
259
|
+
} | {
|
260
|
+
after: WAMessageKey | undefined;
|
261
|
+
};
|
262
|
+
export type MessageUserReceiptUpdate = {
|
263
|
+
key: proto.IMessageKey;
|
264
|
+
receipt: MessageUserReceipt;
|
265
|
+
};
|
266
|
+
export type MediaDecryptionKeyInfo = {
|
267
|
+
iv: Buffer;
|
268
|
+
cipherKey: Buffer;
|
269
|
+
macKey?: Buffer;
|
270
|
+
};
|
271
|
+
export 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 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,118 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
4
|
+
import type { Agent } from 'https';
|
5
|
+
import type { URL } from 'url';
|
6
|
+
import { proto } from '../../WAProto';
|
7
|
+
import { ILogger } from '../Utils/logger';
|
8
|
+
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
9
|
+
import { GroupMetadata } from './GroupMetadata';
|
10
|
+
import { MediaConnInfo } from './Message';
|
11
|
+
import { SignalRepository } from './Signal';
|
12
|
+
export type WAVersion = [number, number, number];
|
13
|
+
export type WABrowserDescription = [string, string, string];
|
14
|
+
export type CacheStore = {
|
15
|
+
/** get a cached key and change the stats */
|
16
|
+
get<T>(key: string): T | undefined;
|
17
|
+
/** set a key in the cache */
|
18
|
+
set<T>(key: string, value: T): void;
|
19
|
+
/** delete a key from the cache */
|
20
|
+
del(key: string): void;
|
21
|
+
/** flush all data */
|
22
|
+
flushAll(): void;
|
23
|
+
};
|
24
|
+
export type SocketConfig = {
|
25
|
+
/** the WS url to connect to WA */
|
26
|
+
waWebSocketUrl: string | URL;
|
27
|
+
/** Fails the connection if the socket times out in this interval */
|
28
|
+
connectTimeoutMs: number;
|
29
|
+
/** Default timeout for queries, undefined for no timeout */
|
30
|
+
defaultQueryTimeoutMs: number | undefined;
|
31
|
+
/** ping-pong interval for WS connection */
|
32
|
+
keepAliveIntervalMs: number;
|
33
|
+
/** should baileys use the mobile api instead of the multi device api
|
34
|
+
* @deprecated This feature has been removed
|
35
|
+
*/
|
36
|
+
mobile?: boolean;
|
37
|
+
/** proxy agent */
|
38
|
+
agent?: Agent;
|
39
|
+
/** logger */
|
40
|
+
logger: ILogger;
|
41
|
+
/** version to connect with */
|
42
|
+
version: WAVersion;
|
43
|
+
/** override browser config */
|
44
|
+
browser: WABrowserDescription;
|
45
|
+
/** agent used for fetch requests -- uploading/downloading media */
|
46
|
+
fetchAgent?: Agent;
|
47
|
+
/** should the QR be printed in the terminal */
|
48
|
+
printQRInTerminal: boolean;
|
49
|
+
/** should events be emitted for actions done by this socket connection */
|
50
|
+
emitOwnEvents: boolean;
|
51
|
+
/** custom upload hosts to upload media to */
|
52
|
+
customUploadHosts: MediaConnInfo['hosts'];
|
53
|
+
/** time to wait between sending new retry requests */
|
54
|
+
retryRequestDelayMs: number;
|
55
|
+
/** max retry count */
|
56
|
+
maxMsgRetryCount: number;
|
57
|
+
/** time to wait for the generation of the next QR in ms */
|
58
|
+
qrTimeout?: number;
|
59
|
+
/** provide an auth state object to maintain the auth state */
|
60
|
+
auth: AuthenticationState;
|
61
|
+
/** manage history processing with this control; by default will sync up everything */
|
62
|
+
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
|
63
|
+
/** transaction capability options for SignalKeyStore */
|
64
|
+
transactionOpts: TransactionCapabilityOptions;
|
65
|
+
/** marks the client as online whenever the socket successfully connects */
|
66
|
+
markOnlineOnConnect: boolean;
|
67
|
+
/** alphanumeric country code (USA -> US) for the number used */
|
68
|
+
countryCode: string;
|
69
|
+
/** provide a cache to store media, so does not have to be re-uploaded */
|
70
|
+
mediaCache?: CacheStore;
|
71
|
+
/**
|
72
|
+
* map to store the retry counts for failed messages;
|
73
|
+
* used to determine whether to retry a message or not */
|
74
|
+
msgRetryCounterCache?: CacheStore;
|
75
|
+
/** provide a cache to store a user's device list */
|
76
|
+
userDevicesCache?: CacheStore;
|
77
|
+
/** cache to store call offers */
|
78
|
+
callOfferCache?: CacheStore;
|
79
|
+
/** cache to track placeholder resends */
|
80
|
+
placeholderResendCache?: CacheStore;
|
81
|
+
/** width for link preview images */
|
82
|
+
linkPreviewImageThumbnailWidth: number;
|
83
|
+
/** Should Baileys ask the phone for full history, will be received async */
|
84
|
+
syncFullHistory: boolean;
|
85
|
+
/** Should baileys fire init queries automatically, default true */
|
86
|
+
fireInitQueries: boolean;
|
87
|
+
/**
|
88
|
+
* generate a high quality link preview,
|
89
|
+
* entails uploading the jpegThumbnail to WA
|
90
|
+
* */
|
91
|
+
generateHighQualityLinkPreview: boolean;
|
92
|
+
/**
|
93
|
+
* Returns if a jid should be ignored,
|
94
|
+
* no event for that jid will be triggered.
|
95
|
+
* Messages from that jid will also not be decrypted
|
96
|
+
* */
|
97
|
+
shouldIgnoreJid: (jid: string) => boolean | undefined;
|
98
|
+
/**
|
99
|
+
* Optionally patch the message before sending out
|
100
|
+
* */
|
101
|
+
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
|
102
|
+
/** verify app state MACs */
|
103
|
+
appStateMacVerification: {
|
104
|
+
patch: boolean;
|
105
|
+
snapshot: boolean;
|
106
|
+
};
|
107
|
+
/** options for axios */
|
108
|
+
options: AxiosRequestConfig<{}>;
|
109
|
+
/**
|
110
|
+
* fetch a message from your store
|
111
|
+
* implement this so that messages failed to send
|
112
|
+
* (solves the "this message can take a while" issue) can be retried
|
113
|
+
* */
|
114
|
+
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
115
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
116
|
+
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
|
117
|
+
makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
|
118
|
+
};
|
@@ -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,63 @@
|
|
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 type UserFacingSocketConfig = Partial<SocketConfig> & {
|
15
|
+
auth: AuthenticationState;
|
16
|
+
};
|
17
|
+
export type BrowsersMap = {
|
18
|
+
ubuntu(browser: string): [string, string, string];
|
19
|
+
macOS(browser: string): [string, string, string];
|
20
|
+
baileys(browser: string): [string, string, string];
|
21
|
+
windows(browser: string): [string, string, string];
|
22
|
+
appropriate(browser: string): [string, string, string];
|
23
|
+
};
|
24
|
+
export declare enum DisconnectReason {
|
25
|
+
connectionClosed = 428,
|
26
|
+
connectionLost = 408,
|
27
|
+
connectionReplaced = 440,
|
28
|
+
timedOut = 408,
|
29
|
+
loggedOut = 401,
|
30
|
+
badSession = 500,
|
31
|
+
restartRequired = 515,
|
32
|
+
multideviceMismatch = 411,
|
33
|
+
forbidden = 403,
|
34
|
+
unavailableService = 503
|
35
|
+
}
|
36
|
+
export type WAInitResponse = {
|
37
|
+
ref: string;
|
38
|
+
ttl: number;
|
39
|
+
status: 200;
|
40
|
+
};
|
41
|
+
export type WABusinessHoursConfig = {
|
42
|
+
day_of_week: string;
|
43
|
+
mode: string;
|
44
|
+
open_time?: number;
|
45
|
+
close_time?: number;
|
46
|
+
};
|
47
|
+
export type WABusinessProfile = {
|
48
|
+
description: string;
|
49
|
+
email: string | undefined;
|
50
|
+
business_hours: {
|
51
|
+
timezone?: string;
|
52
|
+
config?: WABusinessHoursConfig[];
|
53
|
+
business_config?: WABusinessHoursConfig[];
|
54
|
+
};
|
55
|
+
website: string[];
|
56
|
+
category?: string;
|
57
|
+
wid?: string;
|
58
|
+
address?: string;
|
59
|
+
};
|
60
|
+
export type CurveKeyPair = {
|
61
|
+
private: Uint8Array;
|
62
|
+
public: Uint8Array;
|
63
|
+
};
|