@genuxofficial/baileys 1.0.0 → 3.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/README.md +5 -1
- package/WAProto/WAProto.proto +1385 -96
- package/WAProto/index.d.ts +19244 -2787
- package/WAProto/index.js +138202 -74217
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +1 -0
- package/lib/Socket/business.d.ts +47 -17
- package/lib/Socket/chats.d.ts +10 -9
- package/lib/Socket/chats.js +36 -16
- package/lib/Socket/groups.d.ts +12 -11
- package/lib/Socket/groups.js +16 -3
- package/lib/Socket/index.d.ts +52 -22
- package/lib/Socket/messages-recv.d.ts +46 -15
- package/lib/Socket/messages-recv.js +158 -23
- package/lib/Socket/messages-send.d.ts +39 -11
- package/lib/Socket/messages-send.js +188 -22
- package/lib/Socket/newsletter.d.ts +137 -0
- package/lib/Socket/newsletter.js +256 -0
- package/lib/Socket/socket.d.ts +4 -4
- package/lib/Socket/socket.js +25 -12
- package/lib/Socket/usync.d.ts +5 -5
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.js +14 -5
- package/lib/Types/Chat.d.ts +6 -5
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +6 -0
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +150 -12
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Socket.d.ts +8 -3
- package/lib/Types/index.d.ts +1 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/auth-utils.d.ts +1 -1
- package/lib/Utils/auth-utils.js +3 -4
- package/lib/Utils/business.js +15 -3
- package/lib/Utils/chat-utils.js +0 -16
- package/lib/Utils/crypto.js +6 -4
- package/lib/Utils/decode-wa-message.d.ts +5 -3
- package/lib/Utils/decode-wa-message.js +158 -31
- package/lib/Utils/event-buffer.js +1 -3
- package/lib/Utils/generics.d.ts +3 -2
- package/lib/Utils/generics.js +16 -36
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/link-preview.d.ts +1 -1
- package/lib/Utils/link-preview.js +1 -24
- package/lib/Utils/make-mutex.js +0 -1
- package/lib/Utils/messages-media.d.ts +14 -5
- package/lib/Utils/messages-media.js +130 -69
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.js +309 -57
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.js +0 -1
- package/lib/Utils/use-multi-file-auth-state.js +44 -13
- package/lib/Utils/validate-connection.js +1 -3
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/encode.js +13 -5
- package/lib/WABinary/generic-utils.d.ts +3 -5
- package/lib/WABinary/generic-utils.js +34 -19
- package/lib/WABinary/jid-utils.d.ts +12 -3
- package/lib/WABinary/jid-utils.js +29 -4
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +21 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/USyncQuery.d.ts +2 -0
- package/lib/WAUSync/USyncQuery.js +10 -0
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/WAUSync/USyncUser.js +4 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +20 -12
- package/WAProto/GenerateStatics.sh +0 -4
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
package/lib/Types/Events.d.ts
CHANGED
@@ -9,6 +9,7 @@ import { Label } from './Label';
|
|
9
9
|
import { LabelAssociation } from './LabelAssociation';
|
10
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
11
11
|
import { ConnectionState } from './State';
|
12
|
+
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
12
13
|
export type BaileysEventMap = {
|
13
14
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
14
15
|
'connection.update': Partial<ConnectionState>;
|
@@ -90,6 +91,32 @@ export type BaileysEventMap = {
|
|
90
91
|
action: RequestJoinAction;
|
91
92
|
method: RequestJoinMethod;
|
92
93
|
};
|
94
|
+
'newsletter.reaction': {
|
95
|
+
id: string;
|
96
|
+
server_id: string;
|
97
|
+
reaction: {
|
98
|
+
code?: string;
|
99
|
+
count?: number;
|
100
|
+
removed?: boolean;
|
101
|
+
};
|
102
|
+
};
|
103
|
+
'newsletter.view': {
|
104
|
+
id: string;
|
105
|
+
server_id: string;
|
106
|
+
count: number;
|
107
|
+
};
|
108
|
+
/**don't handles subscribe/unsubscribe actions */
|
109
|
+
'newsletter-participants.update': {
|
110
|
+
id: string;
|
111
|
+
author: string;
|
112
|
+
user: string;
|
113
|
+
new_role: NewsletterViewRole;
|
114
|
+
action: SubscriberAction;
|
115
|
+
};
|
116
|
+
'newsletter-settings.update': {
|
117
|
+
id: string;
|
118
|
+
update: NewsletterSettingsUpdate;
|
119
|
+
};
|
93
120
|
'blocklist.set': {
|
94
121
|
blocklist: string[];
|
95
122
|
};
|
@@ -3,22 +3,28 @@ export type GroupParticipant = (Contact & {
|
|
3
3
|
isAdmin?: boolean;
|
4
4
|
isSuperAdmin?: boolean;
|
5
5
|
admin?: 'admin' | 'superadmin' | null;
|
6
|
+
phoneNumber?: string | undefined;
|
6
7
|
});
|
7
8
|
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
|
8
9
|
export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
9
10
|
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
10
11
|
export interface GroupMetadata {
|
11
12
|
id: string;
|
13
|
+
/** group uses 'lid' or 'pn' to send messages */
|
14
|
+
addressingMode: "pn" | "lid";
|
12
15
|
owner: string | undefined;
|
13
16
|
subject: string;
|
14
17
|
/** group subject owner */
|
15
18
|
subjectOwner?: string;
|
19
|
+
subjectOwnerPhoneNumber?: string;
|
16
20
|
/** group subject modification date */
|
17
21
|
subjectTime?: number;
|
18
22
|
creation?: number;
|
19
23
|
desc?: string;
|
20
24
|
descOwner?: string;
|
25
|
+
descOwnerPhoneNumber?: string;
|
21
26
|
descId?: string;
|
27
|
+
descTime?: number;
|
22
28
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
23
29
|
linkedParent?: string;
|
24
30
|
/** is set when the group only allows admins to change group settings */
|
package/lib/Types/Label.d.ts
CHANGED
@@ -10,17 +10,6 @@ export interface Label {
|
|
10
10
|
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
11
11
|
predefinedId?: string;
|
12
12
|
}
|
13
|
-
export interface LabelActionBody {
|
14
|
-
id: string;
|
15
|
-
/** Label name */
|
16
|
-
name?: string;
|
17
|
-
/** Label color ID */
|
18
|
-
color?: number;
|
19
|
-
/** Is label has been deleted */
|
20
|
-
deleted?: boolean;
|
21
|
-
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
22
|
-
predefinedId?: number;
|
23
|
-
}
|
24
13
|
/** WhatsApp has 20 predefined colors */
|
25
14
|
export declare enum LabelColor {
|
26
15
|
Color1 = 0,
|
package/lib/Types/Message.d.ts
CHANGED
@@ -10,19 +10,21 @@ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
10
10
|
import { BinaryNode } from '../WABinary';
|
11
11
|
import type { GroupMetadata } from './GroupMetadata';
|
12
12
|
import { CacheStore } from './Socket';
|
13
|
+
import { ILogger } from '../Utils/logger';
|
13
14
|
export { proto as WAProto };
|
14
15
|
export type WAMessage = proto.IWebMessageInfo;
|
15
16
|
export type WAMessageContent = proto.IMessage;
|
16
17
|
export type WAContactMessage = proto.Message.IContactMessage;
|
17
18
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
18
|
-
export type WAMessageKey = proto.IMessageKey
|
19
|
+
export type WAMessageKey = proto.IMessageKey & {
|
20
|
+
server_id?: string;
|
21
|
+
};
|
19
22
|
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
20
23
|
export type WAContextInfo = proto.IContextInfo;
|
21
24
|
export type WALocationMessage = proto.Message.ILocationMessage;
|
22
25
|
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
23
|
-
export
|
24
|
-
export
|
25
|
-
import { ILogger } from '../Utils/logger';
|
26
|
+
export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
|
27
|
+
export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
|
26
28
|
export type WAMediaPayloadURL = {
|
27
29
|
url: URL | string;
|
28
30
|
};
|
@@ -67,9 +69,46 @@ type Contextable = {
|
|
67
69
|
type ViewOnce = {
|
68
70
|
viewOnce?: boolean;
|
69
71
|
};
|
72
|
+
type Buttonable = {
|
73
|
+
/** add buttons to the message */
|
74
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
75
|
+
};
|
76
|
+
type Templatable = {
|
77
|
+
/** add buttons to the message (conflicts with normal buttons)*/
|
78
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
79
|
+
footer?: string;
|
80
|
+
};
|
81
|
+
type Interactiveable = {
|
82
|
+
/** add buttons to the message */
|
83
|
+
interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
|
84
|
+
title?: string;
|
85
|
+
subtitle?: string;
|
86
|
+
media?: boolean;
|
87
|
+
};
|
88
|
+
type Shopable = {
|
89
|
+
shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
|
90
|
+
id?: string;
|
91
|
+
title?: string;
|
92
|
+
subtitle?: string;
|
93
|
+
media?: boolean;
|
94
|
+
};
|
95
|
+
type Cardsable = {
|
96
|
+
cards?: string[];
|
97
|
+
subtitle?: string;
|
98
|
+
};
|
70
99
|
type Editable = {
|
71
100
|
edit?: WAMessageKey;
|
72
101
|
};
|
102
|
+
type Listable = {
|
103
|
+
/** Sections of the List */
|
104
|
+
sections?: proto.Message.ListMessage.ISection[];
|
105
|
+
/** Title of a List Message only */
|
106
|
+
title?: string;
|
107
|
+
/** Text of the button on the list (required) */
|
108
|
+
buttonText?: string;
|
109
|
+
/** ListType of a List Message only */
|
110
|
+
listType?: proto.Message.ListMessage.ListType;
|
111
|
+
};
|
73
112
|
type WithDimensions = {
|
74
113
|
width?: number;
|
75
114
|
height?: number;
|
@@ -93,14 +132,14 @@ export type AnyMediaMessageContent = (({
|
|
93
132
|
image: WAMediaUpload;
|
94
133
|
caption?: string;
|
95
134
|
jpegThumbnail?: string;
|
96
|
-
} & Mentionable & Contextable & WithDimensions) | ({
|
135
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
|
97
136
|
video: WAMediaUpload;
|
98
137
|
caption?: string;
|
99
138
|
gifPlayback?: boolean;
|
100
139
|
jpegThumbnail?: string;
|
101
140
|
/** if set to true, will send as a `video note` */
|
102
141
|
ptv?: boolean;
|
103
|
-
} & Mentionable & Contextable & WithDimensions) | {
|
142
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
|
104
143
|
audio: WAMediaUpload;
|
105
144
|
/** if set to true, will send as a `voice note` */
|
106
145
|
ptt?: boolean;
|
@@ -114,7 +153,7 @@ export type AnyMediaMessageContent = (({
|
|
114
153
|
mimetype: string;
|
115
154
|
fileName?: string;
|
116
155
|
caption?: string;
|
117
|
-
} & Contextable)) & {
|
156
|
+
} & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
|
118
157
|
mimetype?: string;
|
119
158
|
} & Editable;
|
120
159
|
export type ButtonReplyInfo = {
|
@@ -129,15 +168,63 @@ export type GroupInviteInfo = {
|
|
129
168
|
jid: string;
|
130
169
|
subject: string;
|
131
170
|
};
|
171
|
+
export type CallCreationInfo = {
|
172
|
+
time?: number;
|
173
|
+
title?: string;
|
174
|
+
type?: number;
|
175
|
+
};
|
176
|
+
export type AdminInviteInfo = {
|
177
|
+
inviteExpiration: number;
|
178
|
+
text: string;
|
179
|
+
jid: string;
|
180
|
+
subject: string;
|
181
|
+
thumbnail: Buffer;
|
182
|
+
};
|
183
|
+
export type PaymentInviteInfo = {
|
184
|
+
type?: number;
|
185
|
+
expiry?: number;
|
186
|
+
};
|
187
|
+
export type RequestPaymentInfo = {
|
188
|
+
expiry: number;
|
189
|
+
amount: number;
|
190
|
+
currency: string;
|
191
|
+
from: string;
|
192
|
+
note?: string;
|
193
|
+
sticker?: WAMediaUpload;
|
194
|
+
background: string;
|
195
|
+
/** add contextInfo to the message */
|
196
|
+
contextInfo?: proto.IContextInfo;
|
197
|
+
};
|
198
|
+
export type EventsInfo = {
|
199
|
+
isCanceled?: boolean;
|
200
|
+
name: string;
|
201
|
+
description: string;
|
202
|
+
joinLink?: string;
|
203
|
+
startTime?: number;
|
204
|
+
messageSecret?: Uint8Array;
|
205
|
+
};
|
206
|
+
export type OrderInfo = {
|
207
|
+
id: number;
|
208
|
+
thumbnail: string;
|
209
|
+
itemCount: number;
|
210
|
+
status: number;
|
211
|
+
surface: number;
|
212
|
+
title: string;
|
213
|
+
text: string;
|
214
|
+
seller: string;
|
215
|
+
token: string;
|
216
|
+
amount: number;
|
217
|
+
currency: string;
|
218
|
+
};
|
132
219
|
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
133
220
|
productImage: WAMediaUpload;
|
134
221
|
};
|
135
222
|
export type AnyRegularMessageContent = (({
|
136
223
|
text: string;
|
137
224
|
linkPreview?: WAUrlInfo | null;
|
138
|
-
} & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
|
225
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
|
139
226
|
poll: PollMessageOptions;
|
140
|
-
} & Mentionable & Contextable & Editable) | {
|
227
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
141
228
|
contacts: {
|
142
229
|
displayName?: string;
|
143
230
|
contacts: proto.Message.IContactMessage[];
|
@@ -161,11 +248,32 @@ export type AnyRegularMessageContent = (({
|
|
161
248
|
*/
|
162
249
|
time?: 86400 | 604800 | 2592000;
|
163
250
|
} | {
|
251
|
+
keep: WAMessageKey;
|
252
|
+
type: number;
|
253
|
+
/**
|
254
|
+
* 24 hours, 7 days, 90 days
|
255
|
+
*/
|
256
|
+
time?: 86400 | 604800 | 7776000;
|
257
|
+
} | {
|
258
|
+
paymentInvite: PaymentInviteInfo;
|
259
|
+
} | {
|
260
|
+
requestPayment: RequestPaymentInfo;
|
261
|
+
} | {
|
262
|
+
event: EventsInfo;
|
263
|
+
} | {
|
264
|
+
order: OrderInfo;
|
265
|
+
} | {
|
266
|
+
call: CallCreationInfo;
|
267
|
+
} | {
|
268
|
+
inviteAdmin: AdminInviteInfo;
|
269
|
+
} | {
|
270
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
271
|
+
} | ({
|
164
272
|
product: WASendableProduct;
|
165
273
|
businessOwnerJid?: string;
|
166
274
|
body?: string;
|
167
275
|
footer?: string;
|
168
|
-
} | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
|
276
|
+
} & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
|
169
277
|
export type AnyMessageContent = AnyRegularMessageContent | {
|
170
278
|
forward: WAMessage;
|
171
279
|
force?: boolean;
|
@@ -197,6 +305,7 @@ export type MessageRelayOptions = MinimalRelayOptions & {
|
|
197
305
|
useUserDevicesCache?: boolean;
|
198
306
|
/** jid list of participants for status@broadcast */
|
199
307
|
statusJidList?: string[];
|
308
|
+
newsletter?: boolean;
|
200
309
|
};
|
201
310
|
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
202
311
|
/** optional, if you want to manually set the timestamp of the message */
|
@@ -215,17 +324,44 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
215
324
|
font?: number;
|
216
325
|
/** if it is broadcast */
|
217
326
|
broadcast?: boolean;
|
327
|
+
newsletter?: boolean;
|
328
|
+
additionalNodes?: BinaryNode[];
|
218
329
|
};
|
219
330
|
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
220
331
|
userJid: string;
|
221
332
|
};
|
222
|
-
export type
|
333
|
+
export type PrepareStreamResult = {
|
334
|
+
type: 'prepare';
|
335
|
+
mediaKey: undefined;
|
336
|
+
encWriteStream: Buffer;
|
337
|
+
fileLength: number;
|
338
|
+
fileSha256: Buffer;
|
339
|
+
fileEncSha256: undefined;
|
340
|
+
bodyPath: string | undefined;
|
341
|
+
didSaveToTmpPath: boolean;
|
342
|
+
};
|
343
|
+
export type EncryptedStreamResult = {
|
344
|
+
type: 'encrypted';
|
345
|
+
mediaKey: Buffer;
|
346
|
+
originalFilePath: string | undefined;
|
347
|
+
encFilePath: string;
|
348
|
+
mac: Buffer;
|
349
|
+
fileEncSha256: Buffer;
|
350
|
+
fileSha256: Buffer;
|
351
|
+
fileLength: number;
|
352
|
+
didSaveToTmpPath: boolean;
|
353
|
+
};
|
354
|
+
export type StreamResult = PrepareStreamResult | EncryptedStreamResult;
|
355
|
+
export type WAMediaUploadFunctionOpts = {
|
223
356
|
fileEncSha256B64: string;
|
224
357
|
mediaType: MediaType;
|
358
|
+
newsletter?: boolean;
|
225
359
|
timeoutMs?: number;
|
226
|
-
}
|
360
|
+
};
|
361
|
+
export type WAMediaUploadFunction = (encFilePath: string, opts: WAMediaUploadFunctionOpts) => Promise<{
|
227
362
|
mediaUrl: string;
|
228
363
|
directPath: string;
|
364
|
+
handle?: string;
|
229
365
|
}>;
|
230
366
|
export type MediaGenerationOptions = {
|
231
367
|
logger?: ILogger;
|
@@ -237,6 +373,8 @@ export type MediaGenerationOptions = {
|
|
237
373
|
options?: AxiosRequestConfig;
|
238
374
|
backgroundColor?: string;
|
239
375
|
font?: number;
|
376
|
+
/** The message is for newsletter? */
|
377
|
+
newsletter?: boolean;
|
240
378
|
};
|
241
379
|
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
242
380
|
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
package/lib/Types/Message.js
CHANGED
@@ -3,7 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
|
4
4
|
const WAProto_1 = require("../../WAProto");
|
5
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
6
|
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
8
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
9
7
|
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { proto } from '../../WAProto';
|
2
|
+
export type NewsletterReactionMode = 'ALL' | 'BASIC' | 'NONE';
|
3
|
+
export type NewsletterState = 'ACTIVE' | 'GEOSUSPENDED' | 'SUSPENDED';
|
4
|
+
export type NewsletterVerification = 'VERIFIED' | 'UNVERIFIED';
|
5
|
+
export type NewsletterMute = 'ON' | 'OFF' | 'UNDEFINED';
|
6
|
+
export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
|
7
|
+
export type NewsletterViewerMetadata = {
|
8
|
+
mute: NewsletterMute;
|
9
|
+
view_role: NewsletterViewRole;
|
10
|
+
};
|
11
|
+
export type NewsletterMetadata = {
|
12
|
+
/**jid of newsletter */
|
13
|
+
id: string;
|
14
|
+
/**state of newsletter */
|
15
|
+
state: NewsletterState;
|
16
|
+
/**creation timestamp of newsletter */
|
17
|
+
creation_time: number;
|
18
|
+
/**name of newsletter */
|
19
|
+
name: string;
|
20
|
+
/**timestamp of last name modification of newsletter */
|
21
|
+
nameTime: number;
|
22
|
+
/**description of newsletter */
|
23
|
+
description: string;
|
24
|
+
/**timestamp of last description modification of newsletter */
|
25
|
+
descriptionTime: number;
|
26
|
+
/**invite code of newsletter */
|
27
|
+
invite: string;
|
28
|
+
/**i dont know */
|
29
|
+
handle: null;
|
30
|
+
/**direct path of picture */
|
31
|
+
picture: string | null;
|
32
|
+
/**direct path of picture preview (lower quality) */
|
33
|
+
preview: string | null;
|
34
|
+
/**reaction mode of newsletter */
|
35
|
+
reaction_codes?: NewsletterReactionMode;
|
36
|
+
/**subscribers count of newsletter */
|
37
|
+
subscribers: number;
|
38
|
+
/**verification state of newsletter */
|
39
|
+
verification: NewsletterVerification;
|
40
|
+
/**viewer metadata */
|
41
|
+
viewer_metadata: NewsletterViewerMetadata;
|
42
|
+
};
|
43
|
+
export type SubscriberAction = 'promote' | 'demote';
|
44
|
+
export type ReactionModeUpdate = {
|
45
|
+
reaction_codes: {
|
46
|
+
blocked_codes: null;
|
47
|
+
enabled_ts_sec: null;
|
48
|
+
value: NewsletterReactionMode;
|
49
|
+
};
|
50
|
+
};
|
51
|
+
/**only exists reaction mode update */
|
52
|
+
export type NewsletterSettingsUpdate = ReactionModeUpdate;
|
53
|
+
export type NewsletterReaction = {
|
54
|
+
count: number;
|
55
|
+
code: string;
|
56
|
+
};
|
57
|
+
export type NewsletterFetchedUpdate = {
|
58
|
+
/**id of message in newsletter, starts from 100 */
|
59
|
+
server_id: string;
|
60
|
+
/**count of views in this message */
|
61
|
+
views?: number;
|
62
|
+
/**reactions in this message */
|
63
|
+
reactions: NewsletterReaction[];
|
64
|
+
/**the message, if you requested only updates, you will not receive message */
|
65
|
+
message?: proto.IWebMessageInfo;
|
66
|
+
};
|
67
|
+
export declare enum MexOperations {
|
68
|
+
PROMOTE = "NotificationNewsletterAdminPromote",
|
69
|
+
DEMOTE = "NotificationNewsletterAdminDemote",
|
70
|
+
UPDATE = "NotificationNewsletterUpdate"
|
71
|
+
}
|
72
|
+
export declare enum XWAPaths {
|
73
|
+
PROMOTE = "xwa2_notify_newsletter_admin_promote",
|
74
|
+
DEMOTE = "xwa2_notify_newsletter_admin_demote",
|
75
|
+
ADMIN_COUNT = "xwa2_newsletter_admin",
|
76
|
+
CREATE = "xwa2_newsletter_create",
|
77
|
+
NEWSLETTER = "xwa2_newsletter",
|
78
|
+
METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
|
79
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.XWAPaths = exports.MexOperations = void 0;
|
4
|
+
var MexOperations;
|
5
|
+
(function (MexOperations) {
|
6
|
+
MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
|
7
|
+
MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
|
8
|
+
MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
|
9
|
+
})(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
|
10
|
+
var XWAPaths;
|
11
|
+
(function (XWAPaths) {
|
12
|
+
XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
|
13
|
+
XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
|
14
|
+
XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
|
15
|
+
XWAPaths["CREATE"] = "xwa2_newsletter_create";
|
16
|
+
XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
|
17
|
+
XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
|
18
|
+
})(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
|
package/lib/Types/Socket.d.ts
CHANGED
@@ -4,11 +4,11 @@ import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
import type { Agent } from 'https';
|
5
5
|
import type { URL } from 'url';
|
6
6
|
import { proto } from '../../WAProto';
|
7
|
-
import { ILogger } from '../Utils/logger';
|
8
7
|
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
9
8
|
import { GroupMetadata } from './GroupMetadata';
|
10
9
|
import { MediaConnInfo } from './Message';
|
11
10
|
import { SignalRepository } from './Signal';
|
11
|
+
import { ILogger } from '../Utils/logger';
|
12
12
|
export type WAVersion = [number, number, number];
|
13
13
|
export type WABrowserDescription = [string, string, string];
|
14
14
|
export type CacheStore = {
|
@@ -21,6 +21,9 @@ export type CacheStore = {
|
|
21
21
|
/** flush all data */
|
22
22
|
flushAll(): void;
|
23
23
|
};
|
24
|
+
export type PatchedMessageWithRecipientJID = proto.IMessage & {
|
25
|
+
recipientJid?: string;
|
26
|
+
};
|
24
27
|
export type SocketConfig = {
|
25
28
|
/** the WS url to connect to WA */
|
26
29
|
waWebSocketUrl: string | URL;
|
@@ -31,7 +34,7 @@ export type SocketConfig = {
|
|
31
34
|
/** ping-pong interval for WS connection */
|
32
35
|
keepAliveIntervalMs: number;
|
33
36
|
/** should baileys use the mobile api instead of the multi device api
|
34
|
-
|
37
|
+
* @deprecated This feature has been removed
|
35
38
|
*/
|
36
39
|
mobile?: boolean;
|
37
40
|
/** proxy agent */
|
@@ -82,6 +85,8 @@ export type SocketConfig = {
|
|
82
85
|
linkPreviewImageThumbnailWidth: number;
|
83
86
|
/** Should Baileys ask the phone for full history, will be received async */
|
84
87
|
syncFullHistory: boolean;
|
88
|
+
/** Ignore Message when offline, default is false */
|
89
|
+
ignoreMsgLoading: boolean;
|
85
90
|
/** Should baileys fire init queries automatically, default true */
|
86
91
|
fireInitQueries: boolean;
|
87
92
|
/**
|
@@ -98,7 +103,7 @@ export type SocketConfig = {
|
|
98
103
|
/**
|
99
104
|
* Optionally patch the message before sending out
|
100
105
|
* */
|
101
|
-
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids
|
106
|
+
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
|
102
107
|
/** verify app state MACs */
|
103
108
|
appStateMacVerification: {
|
104
109
|
patch: boolean;
|
package/lib/Types/index.d.ts
CHANGED
package/lib/Types/index.js
CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.DisconnectReason = void 0;
|
18
18
|
__exportStar(require("./Auth"), exports);
|
19
19
|
__exportStar(require("./GroupMetadata"), exports);
|
20
|
+
__exportStar(require("./Newsletter"), exports);
|
20
21
|
__exportStar(require("./Chat"), exports);
|
21
22
|
__exportStar(require("./Contact"), exports);
|
22
23
|
__exportStar(require("./State"), exports);
|
@@ -6,7 +6,7 @@ import { ILogger } from './logger';
|
|
6
6
|
* @param logger to log trace events
|
7
7
|
* @param _cache cache store to use
|
8
8
|
*/
|
9
|
-
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger
|
9
|
+
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore;
|
10
10
|
/**
|
11
11
|
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
12
12
|
* this allows batch read & write operations & improves the performance of the lib
|
package/lib/Utils/auth-utils.js
CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.initAuthCreds = exports.addTransactionCapability = exports.makeCacheableSignalKeyStore = void 0;
|
7
|
-
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
8
7
|
const crypto_1 = require("crypto");
|
8
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
9
9
|
const Defaults_1 = require("../Defaults");
|
10
10
|
const crypto_2 = require("./crypto");
|
11
11
|
const generics_1 = require("./generics");
|
@@ -38,7 +38,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
38
38
|
}
|
39
39
|
}
|
40
40
|
if (idsToFetch.length) {
|
41
|
-
logger.trace({ items: idsToFetch.length }, 'loading from store');
|
41
|
+
logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
|
42
42
|
const fetched = await store.get(type, idsToFetch);
|
43
43
|
for (const id of idsToFetch) {
|
44
44
|
const item = fetched[id];
|
@@ -58,7 +58,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
58
58
|
keys += 1;
|
59
59
|
}
|
60
60
|
}
|
61
|
-
logger.trace({ keys }, 'updated cache');
|
61
|
+
logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
|
62
62
|
await store.set(data);
|
63
63
|
},
|
64
64
|
async clear() {
|
@@ -142,7 +142,6 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
142
142
|
let tries = maxCommitRetries;
|
143
143
|
while (tries) {
|
144
144
|
tries -= 1;
|
145
|
-
//eslint-disable-next-line max-depth
|
146
145
|
try {
|
147
146
|
await state.set(mutations);
|
148
147
|
logger.trace({ dbQueriesInTransaction }, 'committed transaction');
|
package/lib/Utils/business.js
CHANGED
@@ -3,7 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uploadingNecessaryImages = exports.uploadingNecessaryImagesOfProduct = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
4
4
|
const boom_1 = require("@hapi/boom");
|
5
5
|
const crypto_1 = require("crypto");
|
6
|
+
//new import
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const os_1 = require("os");
|
9
|
+
const path_1 = require("path");
|
6
10
|
const WABinary_1 = require("../WABinary");
|
11
|
+
//import { getStream, getUrlFromDirectPath, toReadable } from './messages-media'
|
12
|
+
const generics_1 = require("./generics");
|
7
13
|
const messages_media_1 = require("./messages-media");
|
8
14
|
const parseCatalogNode = (node) => {
|
9
15
|
const catalogNode = (0, WABinary_1.getBinaryNodeChild)(node, 'product_catalog');
|
@@ -202,17 +208,23 @@ const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30
|
|
202
208
|
}
|
203
209
|
const { stream } = await (0, messages_media_1.getStream)(img);
|
204
210
|
const hasher = (0, crypto_1.createHash)('sha256');
|
205
|
-
const contentBlocks = []
|
211
|
+
//const contentBlocks: Buffer[] = []
|
212
|
+
const filePath = (0, path_1.join)((0, os_1.tmpdir)(), 'img' + (0, generics_1.generateMessageIDV2)());
|
213
|
+
const encFileWriteStream = (0, fs_1.createWriteStream)(filePath);
|
206
214
|
for await (const block of stream) {
|
207
215
|
hasher.update(block);
|
208
|
-
contentBlocks.push(block)
|
216
|
+
//contentBlocks.push(block)
|
217
|
+
encFileWriteStream.write(block);
|
209
218
|
}
|
210
219
|
const sha = hasher.digest('base64');
|
211
|
-
const { directPath } = await waUploadToServer(
|
220
|
+
const { directPath } = await waUploadToServer(filePath, {
|
212
221
|
mediaType: 'product-catalog-image',
|
213
222
|
fileEncSha256B64: sha,
|
214
223
|
timeoutMs
|
215
224
|
});
|
225
|
+
await fs_1.promises
|
226
|
+
.unlink(filePath)
|
227
|
+
.catch(err => console.log('Error deleting temp file ', err));
|
216
228
|
return { url: (0, messages_media_1.getUrlFromDirectPath)(directPath) };
|
217
229
|
}));
|
218
230
|
return results;
|
package/lib/Utils/chat-utils.js
CHANGED
@@ -496,22 +496,6 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
496
496
|
operation: OP.SET,
|
497
497
|
};
|
498
498
|
}
|
499
|
-
else if ('addLabel' in mod) {
|
500
|
-
patch = {
|
501
|
-
syncAction: {
|
502
|
-
labelEditAction: {
|
503
|
-
name: mod.addLabel.name,
|
504
|
-
color: mod.addLabel.color,
|
505
|
-
predefinedId: mod.addLabel.predefinedId,
|
506
|
-
deleted: mod.addLabel.deleted
|
507
|
-
}
|
508
|
-
},
|
509
|
-
index: ['label_edit', mod.addLabel.id],
|
510
|
-
type: 'regular',
|
511
|
-
apiVersion: 3,
|
512
|
-
operation: OP.SET,
|
513
|
-
};
|
514
|
-
}
|
515
499
|
else if ('addChatLabel' in mod) {
|
516
500
|
patch = {
|
517
501
|
syncAction: {
|
package/lib/Utils/crypto.js
CHANGED
@@ -27,6 +27,8 @@ exports.derivePairingCodeKey = exports.hkdf = exports.md5 = exports.sha256 = exp
|
|
27
27
|
const crypto_1 = require("crypto");
|
28
28
|
const libsignal = __importStar(require("libsignal"));
|
29
29
|
const Defaults_1 = require("../Defaults");
|
30
|
+
// insure browser & node compatibility
|
31
|
+
const { subtle } = globalThis.crypto;
|
30
32
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
31
33
|
const generateSignalPubKey = (pubKey) => (pubKey.length === 33
|
32
34
|
? pubKey
|
@@ -148,9 +150,9 @@ async function hkdf(buffer, expandedLength, info) {
|
|
148
150
|
? new TextEncoder().encode(info.info)
|
149
151
|
: new Uint8Array(0);
|
150
152
|
// Import the input key material
|
151
|
-
const importedKey = await
|
153
|
+
const importedKey = await subtle.importKey('raw', inputKeyMaterial, { name: 'HKDF' }, false, ['deriveBits']);
|
152
154
|
// Derive bits using HKDF
|
153
|
-
const derivedBits = await
|
155
|
+
const derivedBits = await subtle.deriveBits({
|
154
156
|
name: 'HKDF',
|
155
157
|
hash: 'SHA-256',
|
156
158
|
salt: salt,
|
@@ -166,10 +168,10 @@ async function derivePairingCodeKey(pairingCode, salt) {
|
|
166
168
|
const pairingCodeBuffer = encoder.encode(pairingCode);
|
167
169
|
const saltBuffer = salt instanceof Uint8Array ? salt : new Uint8Array(salt);
|
168
170
|
// Import the pairing code as key material
|
169
|
-
const keyMaterial = await
|
171
|
+
const keyMaterial = await subtle.importKey('raw', pairingCodeBuffer, { name: 'PBKDF2' }, false, ['deriveBits']);
|
170
172
|
// Derive bits using PBKDF2 with the same parameters
|
171
173
|
// 2 << 16 = 131,072 iterations
|
172
|
-
const derivedBits = await
|
174
|
+
const derivedBits = await subtle.deriveBits({
|
173
175
|
name: 'PBKDF2',
|
174
176
|
salt: saltBuffer,
|
175
177
|
iterations: 2 << 16,
|