@realvare/based 2.7.62 → 2.7.71
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 +1062 -282
- package/WAProto/WAProto.proto +1073 -244
- package/WAProto/index.d.ts +16282 -8183
- package/WAProto/index.js +76605 -50628
- package/engine-requirements.js +10 -10
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +4 -2
- package/lib/Defaults/index.js +8 -6
- package/lib/Signal/Group/ciphertext-message.d.ts +1 -1
- package/lib/Signal/Group/ciphertext-message.js +1 -1
- package/lib/Signal/Group/sender-message-key.d.ts +1 -1
- package/lib/Signal/Group/sender-message-key.js +1 -1
- package/lib/Signal/libsignal.d.ts +1 -1
- package/lib/Socket/business.d.ts +1 -1
- package/lib/Socket/business.js +1 -1
- package/lib/Socket/chats.d.ts +4 -1
- package/lib/Socket/chats.js +213 -36
- package/lib/Socket/groups.js +87 -15
- package/lib/Socket/index.js +9 -0
- package/lib/Socket/messages-interactive.js +259 -0
- package/lib/Socket/messages-recv.js +1473 -1228
- package/lib/Socket/messages-send.js +437 -469
- package/lib/Socket/socket.js +143 -26
- package/lib/Socket/usync.js +57 -4
- package/lib/Store/make-in-memory-store.js +28 -15
- package/lib/Types/Auth.d.ts +4 -0
- package/lib/Types/Message.d.ts +316 -6
- package/lib/Types/Message.js +1 -1
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Utils/cache-manager.d.ts +16 -0
- package/lib/Utils/cache-manager.js +22 -5
- package/lib/Utils/chat-utils.js +17 -13
- package/lib/Utils/decode-wa-message.js +1 -11
- package/lib/Utils/event-buffer.js +103 -2
- package/lib/Utils/generics.js +5 -6
- package/lib/Utils/index.d.ts +5 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/jid-validation.d.ts +2 -0
- package/lib/Utils/jid-validation.js +43 -10
- package/lib/Utils/link-preview.js +38 -28
- package/lib/Utils/messages-media.d.ts +1 -1
- package/lib/Utils/messages-media.js +22 -53
- package/lib/Utils/messages.js +653 -65
- package/lib/Utils/performance-config.d.ts +2 -0
- package/lib/Utils/performance-config.js +16 -7
- package/lib/Utils/process-message.js +124 -12
- package/lib/Utils/rate-limiter.js +15 -20
- package/lib/WABinary/generic-utils.js +5 -1
- package/lib/WABinary/jid-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.js +265 -5
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +75 -5
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +59 -6
- package/lib/WAUSync/USyncQuery.js +64 -6
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -4
- package/package.json +10 -15
- package/WAProto/index.ts.ts +0 -53473
package/lib/Types/Message.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type WAMessageKey = proto.IMessageKey & {
|
|
|
18
18
|
senderPn?: string;
|
|
19
19
|
senderLid?: string;
|
|
20
20
|
participantLid?: string;
|
|
21
|
+
remoteLid?: string;
|
|
22
|
+
remoteJidNormalized?: string;
|
|
21
23
|
server_id?: string;
|
|
22
24
|
isViewOnce?: boolean;
|
|
23
25
|
};
|
|
@@ -31,6 +33,9 @@ export interface StickerPackMessage {
|
|
|
31
33
|
description?: string;
|
|
32
34
|
cover?: WAMediaUpload;
|
|
33
35
|
stickers: Sticker[];
|
|
36
|
+
stickerPackId?: string;
|
|
37
|
+
origin?: 0 | 1 | 2; // FIRST_PARTY = 0, THIRD_PARTY = 1, USER_CREATED = 2
|
|
38
|
+
caption?: string;
|
|
34
39
|
}
|
|
35
40
|
export interface Sticker {
|
|
36
41
|
sticker: WAMediaUpload;
|
|
@@ -102,6 +107,13 @@ type Interactiveable = {
|
|
|
102
107
|
title?: string;
|
|
103
108
|
subtitle?: string;
|
|
104
109
|
media?: boolean;
|
|
110
|
+
/** Footer with optional audio attachment */
|
|
111
|
+
footer?: string | {
|
|
112
|
+
text: string;
|
|
113
|
+
audio?: WAMediaUpload;
|
|
114
|
+
};
|
|
115
|
+
/** Product message in header */
|
|
116
|
+
headerProduct?: WASendableProduct;
|
|
105
117
|
};
|
|
106
118
|
type Shopable = {
|
|
107
119
|
shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
|
|
@@ -110,9 +122,26 @@ type Shopable = {
|
|
|
110
122
|
subtitle?: string;
|
|
111
123
|
media?: boolean;
|
|
112
124
|
};
|
|
125
|
+
type Collectionable = {
|
|
126
|
+
collection?: {
|
|
127
|
+
bizJid: string;
|
|
128
|
+
id: string;
|
|
129
|
+
messageVersion?: number;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
type Invoiceable = {
|
|
133
|
+
invoice?: {
|
|
134
|
+
note: string;
|
|
135
|
+
token: string;
|
|
136
|
+
attachmentType?: 0 | 1; // 0 = IMAGE, 1 = PDF
|
|
137
|
+
attachment?: WAMediaUpload;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
113
140
|
type Cardsable = {
|
|
114
141
|
cards?: CarouselCard[];
|
|
115
142
|
subtitle?: string;
|
|
143
|
+
/** Carousel card type: 1 = HSCROLL_CARDS, 2 = ALBUM_IMAGE */
|
|
144
|
+
carouselCardType?: 1 | 2;
|
|
116
145
|
};
|
|
117
146
|
|
|
118
147
|
type CarouselCard = {
|
|
@@ -164,7 +193,7 @@ export type AnyMediaMessageContent = (({
|
|
|
164
193
|
image: WAMediaUpload;
|
|
165
194
|
caption?: string;
|
|
166
195
|
jpegThumbnail?: string;
|
|
167
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
|
|
196
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Invoiceable & Cardsable & WithDimensions) | ({
|
|
168
197
|
video: WAMediaUpload;
|
|
169
198
|
caption?: string;
|
|
170
199
|
gifPlayback?: boolean;
|
|
@@ -192,6 +221,7 @@ export type ButtonReplyInfo = {
|
|
|
192
221
|
displayText: string;
|
|
193
222
|
id: string;
|
|
194
223
|
index: number;
|
|
224
|
+
carouselCardIndex?: number; // For carousel button replies
|
|
195
225
|
};
|
|
196
226
|
export type GroupInviteInfo = {
|
|
197
227
|
inviteCode: string;
|
|
@@ -235,6 +265,96 @@ export type EventsInfo = {
|
|
|
235
265
|
startTime?: number;
|
|
236
266
|
messageSecret?: Uint8Array;
|
|
237
267
|
};
|
|
268
|
+
export type CommentInfo = {
|
|
269
|
+
message: proto.IMessage;
|
|
270
|
+
targetMessageKey: WAMessageKey;
|
|
271
|
+
};
|
|
272
|
+
export type QuestionInfo = {
|
|
273
|
+
text: string;
|
|
274
|
+
contextInfo?: proto.IContextInfo;
|
|
275
|
+
};
|
|
276
|
+
export type QuestionResponseInfo = {
|
|
277
|
+
key: WAMessageKey;
|
|
278
|
+
text: string;
|
|
279
|
+
};
|
|
280
|
+
export type StatusQuestionAnswerInfo = {
|
|
281
|
+
key: WAMessageKey;
|
|
282
|
+
text: string;
|
|
283
|
+
};
|
|
284
|
+
export type StatusQuotedInfo = {
|
|
285
|
+
type: proto.Message.StatusQuotedMessage.StatusQuotedMessageType;
|
|
286
|
+
text: string;
|
|
287
|
+
thumbnail?: Buffer;
|
|
288
|
+
originalStatusId?: WAMessageKey;
|
|
289
|
+
};
|
|
290
|
+
export type StatusStickerInteractionInfo = {
|
|
291
|
+
key: WAMessageKey;
|
|
292
|
+
stickerKey: string;
|
|
293
|
+
type: proto.Message.StatusStickerInteractionMessage.StatusStickerType;
|
|
294
|
+
};
|
|
295
|
+
export type PollMessageOptionsV4 = PollMessageOptions & { pollType: proto.Message.PollType; };
|
|
296
|
+
export type PollMessageOptionsV5 = PollMessageOptions & { pollType: proto.Message.PollType; };
|
|
297
|
+
export type PollResultSnapshotMessageV3 = {
|
|
298
|
+
pollCreationMessageKey: WAMessageKey;
|
|
299
|
+
pollResult?: {
|
|
300
|
+
vote: {
|
|
301
|
+
selectedOptions: Uint8Array[];
|
|
302
|
+
};
|
|
303
|
+
senderTimestampMs: number;
|
|
304
|
+
};
|
|
305
|
+
selectedOptions?: Uint8Array[];
|
|
306
|
+
contextInfo?: proto.IContextInfo;
|
|
307
|
+
pollType?: proto.Message.PollType;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export type TemplateButton = proto.TemplateButton;
|
|
311
|
+
|
|
312
|
+
export type HydratedFourRowTemplateInfo = {
|
|
313
|
+
text?: string;
|
|
314
|
+
footer?: string;
|
|
315
|
+
header?: InteractiveMessageHeader;
|
|
316
|
+
buttons: TemplateButton[];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export type FourRowTemplateInfo = {
|
|
320
|
+
text?: string;
|
|
321
|
+
footer?: string;
|
|
322
|
+
header?: InteractiveMessageHeader;
|
|
323
|
+
buttons: TemplateButton[];
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export type RichResponseInfo = {
|
|
327
|
+
messageType?: proto.AIRichResponseMessageType;
|
|
328
|
+
submessages?: proto.Message.AIRichResponseSubMessage[];
|
|
329
|
+
unifiedResponse?: proto.Message.AIRichResponseUnifiedResponse;
|
|
330
|
+
contextInfo?: proto.IContextInfo;
|
|
331
|
+
};
|
|
332
|
+
export type EventResponseInfo = {
|
|
333
|
+
response: proto.Message.EventResponseMessage.EventResponseType; // GOING = 1, NOT_GOING = 2, MAYBE = 3
|
|
334
|
+
timestampMs?: number;
|
|
335
|
+
extraGuestCount?: number;
|
|
336
|
+
};
|
|
337
|
+
export type StatusMentionInfo = {
|
|
338
|
+
quotedStatus: proto.IMessage;
|
|
339
|
+
};
|
|
340
|
+
export type GroupStatusInfo = {
|
|
341
|
+
message: proto.IMessage;
|
|
342
|
+
};
|
|
343
|
+
export type BotTaskInfo = {
|
|
344
|
+
message: proto.IMessage;
|
|
345
|
+
};
|
|
346
|
+
export type LimitSharingInfo = {
|
|
347
|
+
message: proto.IMessage;
|
|
348
|
+
};
|
|
349
|
+
export type StatusAddYoursInfo = {
|
|
350
|
+
message: proto.IMessage;
|
|
351
|
+
};
|
|
352
|
+
export type BotForwardedInfo = {
|
|
353
|
+
message: proto.IMessage;
|
|
354
|
+
};
|
|
355
|
+
export type EventCoverImageInfo = {
|
|
356
|
+
message: proto.IMessage;
|
|
357
|
+
};
|
|
238
358
|
export type OrderInfo = {
|
|
239
359
|
id: number;
|
|
240
360
|
thumbnail: string;
|
|
@@ -263,7 +383,15 @@ export type AnyRegularMessageContent = (({
|
|
|
263
383
|
text: string;
|
|
264
384
|
linkPreview?: WAUrlInfo | null;
|
|
265
385
|
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
386
|
+
template: FourRowTemplateInfo | HydratedFourRowTemplateInfo;
|
|
387
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | ({
|
|
266
388
|
poll: PollMessageOptions;
|
|
389
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
|
|
390
|
+
pollV4: PollMessageOptionsV4;
|
|
391
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
|
|
392
|
+
pollV5: PollMessageOptionsV5;
|
|
393
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
|
|
394
|
+
pollResultSnapshotV3: PollResultSnapshotMessageV3;
|
|
267
395
|
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
268
396
|
contacts: {
|
|
269
397
|
displayName?: string;
|
|
@@ -281,12 +409,17 @@ export type AnyRegularMessageContent = (({
|
|
|
281
409
|
} | {
|
|
282
410
|
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
283
411
|
} | {
|
|
284
|
-
pin: WAMessageKey
|
|
285
|
-
|
|
412
|
+
pin: WAMessageKey | {
|
|
413
|
+
key: WAMessageKey;
|
|
414
|
+
type?: 1 | 2; // 1 = PIN_FOR_ALL, 2 = UNPIN_FOR_ALL
|
|
415
|
+
time?: number; // Duration in seconds (24 hours = 86400, 7 days = 604800, 30 days = 2592000)
|
|
416
|
+
};
|
|
417
|
+
type?: 1 | 2; // 1 = PIN_FOR_ALL, 2 = UNPIN_FOR_ALL (only used if pin is WAMessageKey)
|
|
286
418
|
/**
|
|
287
|
-
* 24 hours, 7 days, 30 days
|
|
419
|
+
* Duration in seconds for pin (24 hours = 86400, 7 days = 604800, 30 days = 2592000)
|
|
420
|
+
* Only used when type = 1 (PIN_FOR_ALL)
|
|
288
421
|
*/
|
|
289
|
-
time?:
|
|
422
|
+
time?: number;
|
|
290
423
|
} | {
|
|
291
424
|
keep: WAMessageKey;
|
|
292
425
|
type: number;
|
|
@@ -300,6 +433,168 @@ export type AnyRegularMessageContent = (({
|
|
|
300
433
|
requestPayment: RequestPaymentInfo;
|
|
301
434
|
} | {
|
|
302
435
|
event: EventsInfo;
|
|
436
|
+
} | {
|
|
437
|
+
comment: CommentInfo;
|
|
438
|
+
} | {
|
|
439
|
+
question: QuestionInfo;
|
|
440
|
+
} | {
|
|
441
|
+
questionResponse: QuestionResponseInfo;
|
|
442
|
+
} | {
|
|
443
|
+
statusQuestionAnswer: StatusQuestionAnswerInfo;
|
|
444
|
+
} | {
|
|
445
|
+
statusQuoted: StatusQuotedInfo;
|
|
446
|
+
} | {
|
|
447
|
+
statusStickerInteraction: StatusStickerInteractionInfo;
|
|
448
|
+
} | {
|
|
449
|
+
richResponse: RichResponseInfo;
|
|
450
|
+
} | {
|
|
451
|
+
eventResponse: EventResponseInfo;
|
|
452
|
+
} | {
|
|
453
|
+
statusMention: StatusMentionInfo;
|
|
454
|
+
} | {
|
|
455
|
+
groupStatus: GroupStatusInfo;
|
|
456
|
+
} | {
|
|
457
|
+
botTask: BotTaskInfo;
|
|
458
|
+
} | {
|
|
459
|
+
limitSharing: LimitSharingInfo;
|
|
460
|
+
} | {
|
|
461
|
+
statusAddYours: StatusAddYoursInfo;
|
|
462
|
+
} | {
|
|
463
|
+
botForwarded: BotForwardedInfo;
|
|
464
|
+
} | {
|
|
465
|
+
eventCoverImage: EventCoverImageInfo;
|
|
466
|
+
} | {
|
|
467
|
+
bCall: {
|
|
468
|
+
sessionId: string;
|
|
469
|
+
mediaType?: 0 | 1 | 2; // UNKNOWN = 0, AUDIO = 1, VIDEO = 2
|
|
470
|
+
masterKey?: Uint8Array;
|
|
471
|
+
caption?: string;
|
|
472
|
+
};
|
|
473
|
+
} | {
|
|
474
|
+
callLog: {
|
|
475
|
+
isVideo?: boolean;
|
|
476
|
+
callOutcome?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; // CONNECTED, MISSED, FAILED, etc.
|
|
477
|
+
durationSecs?: number;
|
|
478
|
+
callType?: 0 | 1 | 2; // REGULAR = 0, SCHEDULED_CALL = 1, VOICE_CHAT = 2
|
|
479
|
+
participants?: Array<{
|
|
480
|
+
jid: string;
|
|
481
|
+
callOutcome?: number;
|
|
482
|
+
}>;
|
|
483
|
+
};
|
|
484
|
+
} | {
|
|
485
|
+
encComment: {
|
|
486
|
+
targetMessageKey: WAMessageKey;
|
|
487
|
+
encPayload: Uint8Array;
|
|
488
|
+
encIv: Uint8Array;
|
|
489
|
+
};
|
|
490
|
+
} | {
|
|
491
|
+
encEventResponse: {
|
|
492
|
+
eventCreationMessageKey: WAMessageKey;
|
|
493
|
+
encPayload: Uint8Array;
|
|
494
|
+
encIv: Uint8Array;
|
|
495
|
+
};
|
|
496
|
+
} | {
|
|
497
|
+
messageHistoryBundle: {
|
|
498
|
+
mimetype?: string;
|
|
499
|
+
media?: WAMediaUpload;
|
|
500
|
+
contextInfo?: proto.IContextInfo;
|
|
501
|
+
messageHistoryMetadata?: {
|
|
502
|
+
historyReceivers?: string[];
|
|
503
|
+
oldestMessageTimestamp?: number;
|
|
504
|
+
messageCount?: number;
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
} | {
|
|
508
|
+
messageHistoryNotice: {
|
|
509
|
+
contextInfo?: proto.IContextInfo;
|
|
510
|
+
messageHistoryMetadata?: {
|
|
511
|
+
historyReceivers?: string[];
|
|
512
|
+
oldestMessageTimestamp?: number;
|
|
513
|
+
messageCount?: number;
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
} | {
|
|
517
|
+
inviteFollower: {
|
|
518
|
+
newsletterJid: string;
|
|
519
|
+
newsletterName: string;
|
|
520
|
+
thumbnail?: Buffer;
|
|
521
|
+
caption?: string;
|
|
522
|
+
contextInfo?: proto.IContextInfo;
|
|
523
|
+
};
|
|
524
|
+
} | {
|
|
525
|
+
placeholder: {
|
|
526
|
+
type?: 0; // MASK_LINKED_DEVICES = 0
|
|
527
|
+
};
|
|
528
|
+
} | {
|
|
529
|
+
secretEncrypted: {
|
|
530
|
+
targetMessageKey: WAMessageKey;
|
|
531
|
+
encPayload: Uint8Array;
|
|
532
|
+
encIv: Uint8Array;
|
|
533
|
+
secretEncType?: 0 | 1 | 2; // UNKNOWN = 0, EVENT_EDIT = 1, MESSAGE_EDIT = 2
|
|
534
|
+
};
|
|
535
|
+
} | {
|
|
536
|
+
statusNotification: {
|
|
537
|
+
responseMessageKey?: WAMessageKey;
|
|
538
|
+
originalMessageKey?: WAMessageKey;
|
|
539
|
+
type?: 0 | 1 | 2 | 3; // UNKNOWN = 0, STATUS_ADD_YOURS = 1, STATUS_RESHARE = 2, STATUS_QUESTION_ANSWER_RESHARE = 3
|
|
540
|
+
};
|
|
541
|
+
} | {
|
|
542
|
+
stickerSyncRMR: {
|
|
543
|
+
filehash?: string[];
|
|
544
|
+
rmrSource?: string;
|
|
545
|
+
requestTimestamp?: number;
|
|
546
|
+
};
|
|
547
|
+
} | {
|
|
548
|
+
sendPayment: {
|
|
549
|
+
requestMessageKey: WAMessageKey;
|
|
550
|
+
noteMessage?: proto.IMessage;
|
|
551
|
+
background?: proto.IPaymentBackground;
|
|
552
|
+
transactionData?: string;
|
|
553
|
+
};
|
|
554
|
+
} | {
|
|
555
|
+
declinePayment: {
|
|
556
|
+
key: WAMessageKey;
|
|
557
|
+
};
|
|
558
|
+
} | {
|
|
559
|
+
cancelPayment: {
|
|
560
|
+
key: WAMessageKey;
|
|
561
|
+
};
|
|
562
|
+
} | {
|
|
563
|
+
scheduledCallEdit: {
|
|
564
|
+
key: WAMessageKey;
|
|
565
|
+
editType?: 0 | 1; // UNKNOWN = 0, CANCEL = 1
|
|
566
|
+
};
|
|
567
|
+
} | {
|
|
568
|
+
pollResultSnapshot: {
|
|
569
|
+
name: string;
|
|
570
|
+
pollVotes?: Array<{
|
|
571
|
+
optionName: string;
|
|
572
|
+
optionVoteCount: number;
|
|
573
|
+
}>;
|
|
574
|
+
contextInfo?: proto.IContextInfo;
|
|
575
|
+
pollType?: 0 | 1; // POLL = 0, QUIZ = 1
|
|
576
|
+
};
|
|
577
|
+
} | {
|
|
578
|
+
pollUpdate: {
|
|
579
|
+
pollCreationMessageKey: WAMessageKey;
|
|
580
|
+
vote?: {
|
|
581
|
+
encPayload: Uint8Array;
|
|
582
|
+
encIv: Uint8Array;
|
|
583
|
+
};
|
|
584
|
+
metadata?: {};
|
|
585
|
+
senderTimestampMs?: number;
|
|
586
|
+
};
|
|
587
|
+
} | {
|
|
588
|
+
deviceSent: {
|
|
589
|
+
destinationJid: string;
|
|
590
|
+
message: AnyRegularMessageContent;
|
|
591
|
+
phash?: string;
|
|
592
|
+
};
|
|
593
|
+
} | {
|
|
594
|
+
chat: {
|
|
595
|
+
displayName: string;
|
|
596
|
+
id: string;
|
|
597
|
+
};
|
|
303
598
|
} | {
|
|
304
599
|
order: OrderInfo;
|
|
305
600
|
} | {
|
|
@@ -316,7 +611,22 @@ export type AnyRegularMessageContent = (({
|
|
|
316
611
|
} & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
|
|
317
612
|
album: AlbumMedia[];
|
|
318
613
|
caption?: string;
|
|
319
|
-
} & Mentionable & Contextable & Editable) | {
|
|
614
|
+
} & Mentionable & Contextable & Editable) | {
|
|
615
|
+
stickerPack: StickerPackMessage;
|
|
616
|
+
} | {
|
|
617
|
+
interactiveResponse: {
|
|
618
|
+
body?: {
|
|
619
|
+
text: string;
|
|
620
|
+
format?: 0 | 1; // DEFAULT = 0, EXTENSIONS_1 = 1
|
|
621
|
+
};
|
|
622
|
+
nativeFlowResponse?: {
|
|
623
|
+
name: string;
|
|
624
|
+
paramsJson: string;
|
|
625
|
+
version?: number;
|
|
626
|
+
};
|
|
627
|
+
contextInfo?: proto.IContextInfo;
|
|
628
|
+
};
|
|
629
|
+
}) & ViewOnce;
|
|
320
630
|
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
321
631
|
forward: WAMessage;
|
|
322
632
|
force?: boolean;
|
package/lib/Types/Message.js
CHANGED
|
@@ -4,4 +4,4 @@ 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
6
|
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
|
7
|
-
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|
|
7
|
+
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export type SocketConfig = {
|
|
|
55
55
|
retryRequestDelayMs: number;
|
|
56
56
|
/** max retry count */
|
|
57
57
|
maxMsgRetryCount: number;
|
|
58
|
+
/** optional max query retries */
|
|
59
|
+
maxQueryRetries?: number;
|
|
58
60
|
/** time to wait for the generation of the next QR in ms */
|
|
59
61
|
qrTimeout?: number;
|
|
60
62
|
/** provide an auth state object to maintain the auth state */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const cacheManager: {
|
|
2
|
+
setMessageStore(msgStore: any): void;
|
|
3
|
+
startMemoryMonitoring(threshold: number): void;
|
|
4
|
+
evictLeastUsed(): void;
|
|
5
|
+
get(cacheName: string, key: string): any;
|
|
6
|
+
set(cacheName: string, key: string, value: any, ttl?: number): any;
|
|
7
|
+
setAsync<T>(cacheName: string, key: string, fetchData: () => Promise<T>, ttl?: number): Promise<any>;
|
|
8
|
+
del(cacheName: string, key: string): any;
|
|
9
|
+
getStats(cacheName: string): any;
|
|
10
|
+
on(event: 'bad_ack', callback: (key: any) => void): void;
|
|
11
|
+
cleanupBadAck(key: any): void;
|
|
12
|
+
shutdown(): void;
|
|
13
|
+
caches?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
export declare const CacheManager: typeof cacheManager;
|
|
16
|
+
export default cacheManager;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheManager = exports.default = void 0;
|
|
2
4
|
const NodeCache = require('node-cache');
|
|
3
5
|
const { getPerformanceConfig } = require('./performance-config');
|
|
4
6
|
|
|
@@ -55,12 +57,18 @@ class CacheManager {
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
set(cacheName, key, value, ttl = undefined) {
|
|
58
|
-
|
|
60
|
+
const ttlSeconds = typeof ttl === 'number' ? ttl / 1000 : ttl;
|
|
61
|
+
return this.caches[cacheName]?.set(key, value, ttlSeconds);
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
async setAsync(cacheName, key, fetchData, ttl = undefined) {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
try {
|
|
66
|
+
const value = await fetchData();
|
|
67
|
+
return this.set(cacheName, key, value, ttl);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// If fetchData fails, don't cache the error
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
del(cacheName, key) {
|
|
@@ -68,7 +76,14 @@ class CacheManager {
|
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
getStats(cacheName) {
|
|
71
|
-
|
|
79
|
+
if (!this.caches || !this.caches[cacheName]) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return this.caches[cacheName].getStats();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
// Enhanced cleanup for bad ACK entries
|
|
@@ -94,4 +109,6 @@ class CacheManager {
|
|
|
94
109
|
}
|
|
95
110
|
}
|
|
96
111
|
|
|
97
|
-
|
|
112
|
+
const cacheManager = new CacheManager();
|
|
113
|
+
exports.default = cacheManager;
|
|
114
|
+
exports.CacheManager = cacheManager;
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -196,21 +196,25 @@ const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncK
|
|
|
196
196
|
};
|
|
197
197
|
exports.decodeSyncdMutations = decodeSyncdMutations;
|
|
198
198
|
const decodeSyncdPatch = async (msg, name, initialState, getAppStateSyncKey, onMutation, validateMacs) => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
try {
|
|
200
|
+
if (validateMacs) {
|
|
201
|
+
const base64Key = Buffer.from(msg.keyId.id).toString('base64');
|
|
202
|
+
const mainKeyObj = await getAppStateSyncKey(base64Key);
|
|
203
|
+
if (!mainKeyObj) {
|
|
204
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode patch`, { statusCode: 404, data: { msg } });
|
|
205
|
+
}
|
|
206
|
+
const mainKey = await mutationKeys(mainKeyObj.keyData);
|
|
207
|
+
const mutationmacs = msg.mutations.map(mutation => mutation.record.value.blob.slice(-32));
|
|
208
|
+
const patchMac = generatePatchMac(msg.snapshotMac, mutationmacs, (0, generics_1.toNumber)(msg.version.version), name, mainKey.patchMacKey);
|
|
209
|
+
if (Buffer.compare(patchMac, msg.patchMac) !== 0) {
|
|
210
|
+
throw new boom_1.Boom('Invalid patch mac');
|
|
211
|
+
}
|
|
210
212
|
}
|
|
213
|
+
const result = await (0, exports.decodeSyncdMutations)(msg.mutations, initialState, getAppStateSyncKey, onMutation, validateMacs);
|
|
214
|
+
return result;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw error;
|
|
211
217
|
}
|
|
212
|
-
const result = await (0, exports.decodeSyncdMutations)(msg.mutations, initialState, getAppStateSyncKey, onMutation, validateMacs);
|
|
213
|
-
return result;
|
|
214
218
|
};
|
|
215
219
|
exports.decodeSyncdPatch = decodeSyncdPatch;
|
|
216
220
|
const extractSyncdPatches = async (result, options) => {
|
|
@@ -29,25 +29,15 @@ exports.NACK_REASONS = {
|
|
|
29
29
|
*/
|
|
30
30
|
function decodeMessageNode(stanza, meId, meLid) {
|
|
31
31
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
-
if (!stanza || !stanza.attrs) {
|
|
33
|
-
throw new boom_1.Boom('Invalid stanza or missing attributes', { statusCode: 400 });
|
|
34
|
-
}
|
|
35
32
|
let msgType;
|
|
36
33
|
let chatId;
|
|
37
34
|
let author;
|
|
38
35
|
const msgId = stanza.attrs.id;
|
|
39
|
-
if (!msgId) {
|
|
40
|
-
throw new boom_1.Boom('Missing message ID', { statusCode: 400 });
|
|
41
|
-
}
|
|
42
36
|
const from = stanza.attrs.from;
|
|
43
|
-
if (!from) {
|
|
44
|
-
throw new boom_1.Boom('Missing sender JID', { statusCode: 400 });
|
|
45
|
-
}
|
|
46
37
|
const senderPn = (_a = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _a === void 0 ? void 0 : _a.sender_pn;
|
|
47
38
|
const senderLid = (_b = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _b === void 0 ? void 0 : _b.sender_lid;
|
|
48
39
|
const participant = stanza.attrs.participant;
|
|
49
40
|
const participantLid = (_c = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _c === void 0 ? void 0 : _c.participant_lid;
|
|
50
|
-
const participantPn = (_d = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _d === void 0 ? void 0 : _d.participant_pn;
|
|
51
41
|
const recipient = stanza.attrs.recipient;
|
|
52
42
|
const isMe = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meId);
|
|
53
43
|
const isMeLid = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meLid);
|
|
@@ -214,4 +204,4 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
214
204
|
}
|
|
215
205
|
};
|
|
216
206
|
};
|
|
217
|
-
exports.decryptMessageNode = decryptMessageNode;
|
|
207
|
+
exports.decryptMessageNode = decryptMessageNode;
|