@jkt48connect-corp/baileys 7.2.7 → 7.2.8

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.
Files changed (102) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +838 -94
  3. package/WAProto/WAProto.proto +969 -88
  4. package/WAProto/index.d.ts +13199 -1260
  5. package/WAProto/index.js +124901 -74525
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.d.ts +7 -8
  8. package/lib/Defaults/index.js +5 -3
  9. package/lib/Defaults/phonenumber-mcc.json +221 -221
  10. package/lib/Signal/libsignal.js +18 -9
  11. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -2
  12. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -1
  13. package/lib/Socket/business.d.ts +40 -40
  14. package/lib/Socket/chats.d.ts +13 -14
  15. package/lib/Socket/groups.d.ts +20 -21
  16. package/lib/Socket/groups.js +1 -1
  17. package/lib/Socket/index.d.ts +49 -49
  18. package/lib/Socket/messages-recv.d.ts +39 -39
  19. package/lib/Socket/messages-recv.js +310 -151
  20. package/lib/Socket/messages-send.d.ts +33 -31
  21. package/lib/Socket/messages-send.js +269 -36
  22. package/lib/Socket/newsletter.d.ts +24 -25
  23. package/lib/Socket/newsletter.js +3 -3
  24. package/lib/Socket/registration.d.ts +49 -52
  25. package/lib/Socket/registration.js +7 -7
  26. package/lib/Socket/socket.d.ts +6 -7
  27. package/lib/Socket/socket.js +7 -3
  28. package/lib/Store/make-cache-manager-store.d.ts +1 -0
  29. package/lib/Store/make-in-memory-store.d.ts +3 -4
  30. package/lib/Store/make-in-memory-store.js +13 -11
  31. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  32. package/lib/Types/Auth.d.ts +0 -1
  33. package/lib/Types/Call.d.ts +1 -1
  34. package/lib/Types/Chat.d.ts +12 -7
  35. package/lib/Types/Events.d.ts +17 -2
  36. package/lib/Types/GroupMetadata.d.ts +3 -1
  37. package/lib/Types/Label.d.ts +11 -0
  38. package/lib/Types/Label.js +1 -1
  39. package/lib/Types/LabelAssociation.js +1 -1
  40. package/lib/Types/Message.d.ts +164 -13
  41. package/lib/Types/Newsletter.js +3 -3
  42. package/lib/Types/Socket.d.ts +7 -2
  43. package/lib/Types/index.d.ts +9 -0
  44. package/lib/Types/index.js +1 -1
  45. package/lib/Utils/auth-utils.js +3 -3
  46. package/lib/Utils/business.d.ts +1 -1
  47. package/lib/Utils/business.js +2 -2
  48. package/lib/Utils/chat-utils.d.ts +11 -12
  49. package/lib/Utils/chat-utils.js +41 -20
  50. package/lib/Utils/crypto.d.ts +15 -16
  51. package/lib/Utils/crypto.js +35 -23
  52. package/lib/Utils/decode-wa-message.d.ts +17 -0
  53. package/lib/Utils/decode-wa-message.js +43 -15
  54. package/lib/Utils/generics.d.ts +10 -19
  55. package/lib/Utils/generics.js +32 -16
  56. package/lib/Utils/history.d.ts +6 -2
  57. package/lib/Utils/history.js +3 -0
  58. package/lib/Utils/index.d.ts +0 -1
  59. package/lib/Utils/index.js +0 -1
  60. package/lib/Utils/logger.d.ts +1 -3
  61. package/lib/Utils/make-mutex.d.ts +2 -2
  62. package/lib/Utils/messages-media.d.ts +25 -28
  63. package/lib/Utils/messages-media.js +38 -47
  64. package/lib/Utils/messages.d.ts +5 -8
  65. package/lib/Utils/messages.js +430 -12
  66. package/lib/Utils/noise-handler.d.ts +4 -5
  67. package/lib/Utils/process-message.js +2 -2
  68. package/lib/Utils/use-multi-file-auth-state.js +17 -3
  69. package/lib/Utils/validate-connection.d.ts +2 -2
  70. package/lib/Utils/validate-connection.js +12 -23
  71. package/lib/WABinary/decode.d.ts +1 -2
  72. package/lib/WABinary/decode.js +17 -7
  73. package/lib/WABinary/encode.d.ts +1 -2
  74. package/lib/WABinary/encode.js +33 -17
  75. package/lib/WABinary/generic-utils.d.ts +2 -3
  76. package/lib/WABinary/generic-utils.js +2 -2
  77. package/lib/WABinary/jid-utils.d.ts +1 -1
  78. package/lib/WAM/BinaryInfo.d.ts +2 -11
  79. package/lib/WAM/encode.d.ts +1 -2
  80. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  81. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  82. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  83. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  84. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  85. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  86. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  87. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  88. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  89. package/lib/WAUSync/Protocols/index.js +20 -0
  90. package/lib/WAUSync/USyncQuery.d.ts +26 -0
  91. package/lib/WAUSync/USyncQuery.js +79 -0
  92. package/lib/WAUSync/USyncUser.d.ts +10 -0
  93. package/lib/WAUSync/USyncUser.js +22 -0
  94. package/lib/WAUSync/index.d.ts +3 -0
  95. package/lib/WAUSync/index.js +19 -0
  96. package/lib/index.js +4 -1
  97. package/package.json +15 -10
  98. package/lib/Socket/community.d.ts +0 -219
  99. package/lib/Socket/community.js +0 -354
  100. package/lib/Utils/use-single-file-auth-statev2.d.ts +0 -12
  101. package/lib/Utils/use-single-file-auth-statev2.js +0 -75
  102. package/lib/index.d.ts +0 -11
@@ -1,13 +1,16 @@
1
1
  import type { proto } from '../../WAProto';
2
2
  import type { AccountSettings } from './Auth';
3
3
  import type { BufferedEventData } from './Events';
4
+ import type { LabelActionBody } from './Label';
4
5
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
6
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage } from './Message';
7
+ import type { MinimalMessage, WAMessageKey } from './Message';
7
8
  /** privacy settings in WhatsApp Web */
8
9
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
10
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
11
+ export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
10
12
  export type WAReadReceiptsValue = 'all' | 'none';
13
+ export type WAPrivacyCallValue = 'all' | 'known';
11
14
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
15
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
16
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
@@ -59,12 +62,12 @@ export type ChatModification = {
59
62
  /** mute for duration, or provide timestamp of mute to remove*/
60
63
  mute: number | null;
61
64
  } | {
62
- clear: 'all' | {
63
- messages: {
64
- id: string;
65
- fromMe?: boolean;
66
- timestamp: number;
67
- }[];
65
+ clear: boolean;
66
+ } | {
67
+ deleteForMe: {
68
+ deleteMedia: boolean;
69
+ key: WAMessageKey;
70
+ timestamp: number;
68
71
  };
69
72
  } | {
70
73
  star: {
@@ -80,6 +83,8 @@ export type ChatModification = {
80
83
  } | {
81
84
  delete: true;
82
85
  lastMessages: LastMessageList;
86
+ } | {
87
+ addLabel: LabelActionBody;
83
88
  } | {
84
89
  addChatLabel: ChatLabelAssociationActionBody;
85
90
  } | {
@@ -4,7 +4,7 @@ import { AuthenticationCreds } from './Auth';
4
4
  import { WACallEvent } from './Call';
5
5
  import { Chat, ChatUpdate, PresenceData } from './Chat';
6
6
  import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction } from './GroupMetadata';
7
+ import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
8
8
  import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
@@ -19,7 +19,10 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest: boolean;
22
+ isLatest?: boolean;
23
+ progress?: number | null;
24
+ syncType?: proto.HistorySync.HistorySyncType;
25
+ peerDataRequestSessionId?: string | null;
23
26
  };
24
27
  /** upsert chats */
25
28
  'chats.upsert': Chat[];
@@ -58,10 +61,12 @@ export type BaileysEventMap = {
58
61
  /**
59
62
  * add/update the given messages. If they were received while the connection was online,
60
63
  * the update will have type: "notify"
64
+ * if requestId is provided, then the messages was received from the phone due to it being unavailable
61
65
  * */
62
66
  'messages.upsert': {
63
67
  messages: WAMessage[];
64
68
  type: MessageUpsertType;
69
+ requestId?: string;
65
70
  };
66
71
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
67
72
  'messages.reaction': {
@@ -78,6 +83,13 @@ export type BaileysEventMap = {
78
83
  participants: string[];
79
84
  action: ParticipantAction;
80
85
  };
86
+ 'group.join-request': {
87
+ id: string;
88
+ author: string;
89
+ participant: string;
90
+ action: RequestJoinAction;
91
+ method: RequestJoinMethod;
92
+ };
81
93
  'blocklist.set': {
82
94
  blocklist: string[];
83
95
  };
@@ -106,6 +118,9 @@ export type BufferedEventData = {
106
118
  };
107
119
  empty: boolean;
108
120
  isLatest: boolean;
121
+ progress?: number | null;
122
+ syncType?: proto.HistorySync.HistorySyncType;
123
+ peerDataRequestSessionId?: string;
109
124
  };
110
125
  chatUpserts: {
111
126
  [jid: string]: Chat;
@@ -4,7 +4,9 @@ export type GroupParticipant = (Contact & {
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
6
  });
7
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
8
+ export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
9
+ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
8
10
  export interface GroupMetadata {
9
11
  id: string;
10
12
  owner: string | undefined;
@@ -10,6 +10,17 @@ 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
+ }
13
24
  /** WhatsApp has 20 predefined colors */
14
25
  export declare enum LabelColor {
15
26
  Color1 = 0,
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
27
+ })(LabelColor || (exports.LabelColor = LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
9
+ })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import { AxiosRequestConfig } from 'axios';
5
2
  import type { Logger } from 'pino';
6
3
  import type { Readable } from 'stream';
@@ -19,6 +16,7 @@ export type WAMessageKey = proto.IMessageKey;
19
16
  export type WATextMessage = proto.Message.IExtendedTextMessage;
20
17
  export type WAContextInfo = proto.IContextInfo;
21
18
  export type WALocationMessage = proto.Message.ILocationMessage;
19
+ export type WALiveLocationMessage = proto.Message.ILiveLocationMessage;
22
20
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
23
21
  export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
22
  export import WAMessageStatus = proto.WebMessageInfo.Status;
@@ -53,6 +51,19 @@ export interface WAUrlInfo {
53
51
  highQualityThumbnail?: proto.Message.IImageMessage;
54
52
  originalThumbnailUrl?: string;
55
53
  }
54
+ export interface Media {
55
+ image?: WAMediaUpload;
56
+ video?: WAMediaUpload;
57
+ }
58
+ export interface Carousel {
59
+ image?: WAMediaUpload;
60
+ video?: WAMediaUpload;
61
+ product?: WASendableProduct;
62
+ title?: string;
63
+ caption?: string;
64
+ footer?: string;
65
+ buttons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
66
+ }
56
67
  type Mentionable = {
57
68
  /** list of jids that are mentioned in the accompanying text */
58
69
  mentions?: string[];
@@ -73,6 +84,35 @@ type Templatable = {
73
84
  templateButtons?: proto.IHydratedTemplateButton[];
74
85
  footer?: string;
75
86
  };
87
+ type Interactiveable = {
88
+ /** add buttons to the message (conflicts with normal buttons)*/
89
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
90
+ title?: string;
91
+ subtitle?: string;
92
+ media?: boolean;
93
+ };
94
+ type Shopable = {
95
+ shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
96
+ id?: string;
97
+ title?: string;
98
+ subtitle?: string;
99
+ media?: boolean;
100
+ };
101
+ type Collectionable = {
102
+ collection?: {
103
+ bizJid?: string;
104
+ id?: string;
105
+ version?: number;
106
+ };
107
+ title?: string;
108
+ subtitle?: string;
109
+ media?: boolean;
110
+ };
111
+ type Cardsable = {
112
+ cards?: Carousel[];
113
+ title?: string;
114
+ subtitle?: string;
115
+ };
76
116
  type Editable = {
77
117
  edit?: WAMessageKey;
78
118
  };
@@ -81,7 +121,7 @@ type Listable = {
81
121
  sections?: proto.Message.ListMessage.ISection[];
82
122
  /** Title of a List Message only */
83
123
  title?: string;
84
- /** Text of the bnutton on the list (required) */
124
+ /** Text of the button on the list (required) */
85
125
  buttonText?: string;
86
126
  };
87
127
  type WithDimensions = {
@@ -94,6 +134,12 @@ export type PollMessageOptions = {
94
134
  values: string[];
95
135
  /** 32 byte message secret to encrypt poll selections */
96
136
  messageSecret?: Uint8Array;
137
+ toAnnouncementGroup?: boolean;
138
+ };
139
+ export type PollResultMessage = {
140
+ name: string;
141
+ votes: proto.Message.PollResultSnapshotMessage.PollVote[];
142
+ messageSecret?: Uint8Array;
97
143
  };
98
144
  type SharePhoneNumber = {
99
145
  sharePhoneNumber: boolean;
@@ -101,19 +147,22 @@ type SharePhoneNumber = {
101
147
  type RequestPhoneNumber = {
102
148
  requestPhoneNumber: boolean;
103
149
  };
150
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
151
+ productImage: WAMediaUpload;
152
+ };
104
153
  export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
105
154
  export type AnyMediaMessageContent = (({
106
155
  image: WAMediaUpload;
107
156
  caption?: string;
108
157
  jpegThumbnail?: string;
109
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
158
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | ({
110
159
  video: WAMediaUpload;
111
160
  caption?: string;
112
161
  gifPlayback?: boolean;
113
162
  jpegThumbnail?: string;
114
163
  /** if set to true, will send as a `video note` */
115
164
  ptv?: boolean;
116
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
165
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | {
117
166
  audio: WAMediaUpload;
118
167
  /** if set to true, will send as a `voice note` */
119
168
  ptt?: boolean;
@@ -127,22 +176,89 @@ export type AnyMediaMessageContent = (({
127
176
  mimetype: string;
128
177
  fileName?: string;
129
178
  caption?: string;
130
- } & Contextable & Buttonable & Templatable)) & {
179
+ } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable)) & {
131
180
  mimetype?: string;
132
181
  } & Editable;
133
182
  export type ButtonReplyInfo = {
134
183
  displayText: string;
135
184
  id: string;
136
185
  index: number;
186
+ text: string;
187
+ nativeFlow: proto.Message.InteractiveResponseMessage.NativeFlowResponseMessage;
137
188
  };
138
- export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
139
- productImage: WAMediaUpload;
189
+ export type GroupInviteInfo = {
190
+ inviteCode: string;
191
+ inviteExpiration: number;
192
+ text: string;
193
+ jid: string;
194
+ subject: string;
195
+ thumbnail: Buffer;
196
+ };
197
+ export type PinInChatInfo = {
198
+ key: WAMessageKey;
199
+ type?: number;
200
+ time?: number;
201
+ };
202
+ export type KeepInChatInfo = {
203
+ key: WAMessageKey;
204
+ type?: number;
205
+ time?: number;
206
+ };
207
+ export type CallCreationInfo = {
208
+ time?: number;
209
+ title?: string;
210
+ type?: number;
211
+ };
212
+ export type PaymentInviteInfo = {
213
+ type?: number;
214
+ expiry?: number;
215
+ };
216
+ export type RequestPaymentInfo = {
217
+ expiry: number;
218
+ amount: number;
219
+ currency: string;
220
+ from: string;
221
+ note?: string;
222
+ sticker?: WAMediaUpload;
223
+ background: string;
224
+ /** add contextInfo to the message */
225
+ contextInfo?: proto.IContextInfo;
226
+ };
227
+ export type EventsInfo = {
228
+ isCanceled?: boolean;
229
+ name: string;
230
+ description: string;
231
+ joinLink?: string;
232
+ startTime?: number;
233
+ messageSecret?: Uint8Array;
234
+ };
235
+ export type AdminInviteInfo = {
236
+ inviteExpiration: number;
237
+ text: string;
238
+ jid: string;
239
+ subject: string;
240
+ thumbnail: Buffer;
241
+ };
242
+ export type OrderInfo = {
243
+ id: number;
244
+ thumbnail: string;
245
+ itemCount: number;
246
+ status: number;
247
+ surface: number;
248
+ title: string;
249
+ text: string;
250
+ seller: string;
251
+ token: string;
252
+ amount: number;
253
+ currency: string;
140
254
  };
141
255
  export type AnyRegularMessageContent = (({
142
256
  text: string;
143
257
  linkPreview?: WAUrlInfo | null;
144
- } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
258
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
145
259
  poll: PollMessageOptions;
260
+ } | {
261
+ pollResult: PollResultMessage;
146
262
  } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
147
263
  contacts: {
148
264
  displayName?: string;
@@ -150,19 +266,49 @@ export type AnyRegularMessageContent = (({
150
266
  };
151
267
  } | {
152
268
  location: WALocationMessage;
269
+ } | {
270
+ liveLocation: WALiveLocationMessage;
153
271
  } | {
154
272
  react: proto.Message.IReactionMessage;
155
273
  } | {
156
274
  buttonReply: ButtonReplyInfo;
157
- type: 'template' | 'plain';
275
+ type: 'template' | 'plain' | 'interactive';
158
276
  } | {
159
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
277
+ groupInvite: GroupInviteInfo;
278
+ } | {
279
+ pin: WAMessageKey;
280
+ type: proto.PinInChat.Type;
281
+ /**
282
+ * 24 hours, 7 days, 30 days
283
+ */
284
+ time?: 86400 | 604800 | 2592000;
285
+ } | {
286
+ keep: WAMessageKey;
287
+ type: number;
288
+ /**
289
+ * 24 hours, 7 days, 90 days
290
+ */
291
+ time?: 86400 | 604800 | 7776000;
292
+ } | {
293
+ paymentInvite: PaymentInviteInfo;
294
+ } | {
295
+ requestPayment: RequestPaymentInfo;
296
+ } | {
297
+ event: EventsInfo;
160
298
  } | {
299
+ order: OrderInfo;
300
+ } | {
301
+ call: CallCreationInfo;
302
+ } | {
303
+ inviteAdmin: AdminInviteInfo;
304
+ } | {
305
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
306
+ } | ({
161
307
  product: WASendableProduct;
162
308
  businessOwnerJid?: string;
163
309
  body?: string;
164
310
  footer?: string;
165
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
311
+ } & Mentionable & Contextable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
166
312
  export type AnyMessageContent = AnyRegularMessageContent | {
167
313
  forward: WAMessage;
168
314
  force?: boolean;
@@ -213,6 +359,8 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
213
359
  font?: number;
214
360
  /** if it is broadcast */
215
361
  broadcast?: boolean;
362
+ /** delay of message time */
363
+ delay?: number;
216
364
  };
217
365
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
218
366
  userJid: string;
@@ -236,6 +384,8 @@ export type MediaGenerationOptions = {
236
384
  mediaCache?: CacheStore;
237
385
  mediaUploadTimeoutMs?: number;
238
386
  options?: AxiosRequestConfig;
387
+ /** the message you want to quote */
388
+ quoted?: WAMessage;
239
389
  backgroundColor?: string;
240
390
  font?: number;
241
391
  /** The message is for newsletter? */
@@ -243,6 +393,7 @@ export type MediaGenerationOptions = {
243
393
  };
244
394
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
245
395
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
396
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
246
397
  };
247
398
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
248
399
  /**
@@ -6,7 +6,7 @@ var MexOperations;
6
6
  MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
7
  MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
8
  MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
9
+ })(MexOperations || (exports.MexOperations = MexOperations = {}));
10
10
  var XWAPaths;
11
11
  (function (XWAPaths) {
12
12
  XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
@@ -15,7 +15,7 @@ var XWAPaths;
15
15
  XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
16
  XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
17
  XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
- })(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
18
+ })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
19
  var QueryIds;
20
20
  (function (QueryIds) {
21
21
  QueryIds["JOB_MUTATION"] = "7150902998257522";
@@ -29,4 +29,4 @@ var QueryIds;
29
29
  QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
30
  QueryIds["DELETE"] = "8316537688363079";
31
31
  QueryIds["DEMOTE"] = "6551828931592903";
32
- })(QueryIds = exports.QueryIds || (exports.QueryIds = {}));
32
+ })(QueryIds || (exports.QueryIds = QueryIds = {}));
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AxiosRequestConfig } from 'axios';
4
2
  import type { Agent } from 'https';
5
3
  import type { Logger } from 'pino';
6
4
  import type { URL } from 'url';
7
5
  import { proto } from '../../WAProto';
8
6
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
+ import { GroupMetadata } from './GroupMetadata';
9
8
  import { MediaConnInfo } from './Message';
10
9
  import { SignalRepository } from './Signal';
11
10
  export type WAVersion = [number, number, number];
@@ -61,6 +60,8 @@ export type SocketConfig = {
61
60
  transactionOpts: TransactionCapabilityOptions;
62
61
  /** marks the client as online whenever the socket successfully connects */
63
62
  markOnlineOnConnect: boolean;
63
+ /** alphanumeric country code (USA -> US) for the number used */
64
+ countryCode: string;
64
65
  /** provide a cache to store media, so does not have to be re-uploaded */
65
66
  mediaCache?: CacheStore;
66
67
  /**
@@ -71,6 +72,8 @@ export type SocketConfig = {
71
72
  userDevicesCache?: CacheStore;
72
73
  /** cache to store call offers */
73
74
  callOfferCache?: CacheStore;
75
+ /** cache to track placeholder resends */
76
+ placeholderResendCache?: CacheStore;
74
77
  /** width for link preview images */
75
78
  linkPreviewImageThumbnailWidth: number;
76
79
  /** Should Baileys ask the phone for full history, will be received async */
@@ -105,6 +108,8 @@ export type SocketConfig = {
105
108
  * (solves the "this message can take a while" issue) can be retried
106
109
  * */
107
110
  getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
111
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
112
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
108
113
  makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
109
114
  /** Socket passthrough */
110
115
  socket?: any;
@@ -15,6 +15,15 @@ import { SocketConfig } from './Socket';
15
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
16
  auth: AuthenticationState;
17
17
  };
18
+ export type BrowsersMap = {
19
+ ubuntu(browser: string): [string, string, string];
20
+ macOS(browser: string): [string, string, string];
21
+ baileys(browser: string): [string, string, string];
22
+ windows(browser: string): [string, string, string];
23
+ iOS(browser: string): [string, string, string];
24
+ linux(browser: string): [string, string, string];
25
+ appropriate(browser: string): [string, string, string];
26
+ };
18
27
  export declare enum DisconnectReason {
19
28
  connectionClosed = 428,
20
29
  connectionLost = 408,
@@ -39,4 +39,4 @@ var DisconnectReason;
39
39
  DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
40
40
  DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
41
41
  DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
42
- })(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
42
+ })(DisconnectReason || (exports.DisconnectReason = DisconnectReason = {}));
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initAuthCreds = exports.addTransactionCapability = exports.makeCacheableSignalKeyStore = void 0;
6
+ exports.initAuthCreds = exports.addTransactionCapability = void 0;
7
+ exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
7
8
  const crypto_1 = require("crypto");
8
9
  const node_cache_1 = __importDefault(require("node-cache"));
9
10
  const uuid_1 = require("uuid");
@@ -18,7 +19,7 @@ const generics_1 = require("./generics");
18
19
  */
19
20
  function makeCacheableSignalKeyStore(store, logger, _cache) {
20
21
  const cache = _cache || new node_cache_1.default({
21
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
22
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
22
23
  useClones: false,
23
24
  deleteOnExpire: true,
24
25
  });
@@ -69,7 +70,6 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
69
70
  }
70
71
  };
71
72
  }
72
- exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
73
73
  /**
74
74
  * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
75
75
  * this allows batch read & write operations & improves the performance of the lib
@@ -2,7 +2,7 @@ import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate,
2
2
  import { BinaryNode } from '../WABinary';
3
3
  export declare const parseCatalogNode: (node: BinaryNode) => {
4
4
  products: Product[];
5
- nextPageCursor: string | undefined;
5
+ nextPageCursor: any;
6
6
  };
7
7
  export declare const parseCollectionsNode: (node: BinaryNode) => {
8
8
  collections: CatalogCollection[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadingNecessaryImages = exports.uploadingNecessaryImagesOfProduct = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
3
+ exports.uploadingNecessaryImages = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
4
+ exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
4
5
  const boom_1 = require("@hapi/boom");
5
6
  const crypto_1 = require("crypto");
6
7
  const WABinary_1 = require("../WABinary");
@@ -188,7 +189,6 @@ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, time
188
189
  };
189
190
  return product;
190
191
  }
191
- exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
192
192
  /**
193
193
  * Uploads images not already uploaded to WA's servers
194
194
  */
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { AxiosRequestConfig } from 'axios';
3
2
  import type { Logger } from 'pino';
4
3
  import { proto } from '../../WAProto';
@@ -14,7 +13,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
14
13
  state: LTHashState;
15
14
  }>;
16
15
  export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
17
- hash: Buffer;
16
+ hash: any;
18
17
  indexValueMap: {
19
18
  [indexMacBase64: string]: {
20
19
  valueMac: Uint8Array | Buffer;
@@ -22,47 +21,47 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
22
21
  };
23
22
  }>;
24
23
  export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
25
- hash: Buffer;
24
+ hash: any;
26
25
  indexValueMap: {
27
26
  [indexMacBase64: string]: {
28
27
  valueMac: Uint8Array | Buffer;
29
28
  };
30
29
  };
31
30
  }>;
32
- export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
31
+ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
33
32
  critical_block: {
34
33
  patches: proto.ISyncdPatch[];
35
34
  hasMorePatches: boolean;
36
- snapshot?: proto.ISyncdSnapshot | undefined;
35
+ snapshot?: proto.ISyncdSnapshot;
37
36
  };
38
37
  critical_unblock_low: {
39
38
  patches: proto.ISyncdPatch[];
40
39
  hasMorePatches: boolean;
41
- snapshot?: proto.ISyncdSnapshot | undefined;
40
+ snapshot?: proto.ISyncdSnapshot;
42
41
  };
43
42
  regular_high: {
44
43
  patches: proto.ISyncdPatch[];
45
44
  hasMorePatches: boolean;
46
- snapshot?: proto.ISyncdSnapshot | undefined;
45
+ snapshot?: proto.ISyncdSnapshot;
47
46
  };
48
47
  regular_low: {
49
48
  patches: proto.ISyncdPatch[];
50
49
  hasMorePatches: boolean;
51
- snapshot?: proto.ISyncdSnapshot | undefined;
50
+ snapshot?: proto.ISyncdSnapshot;
52
51
  };
53
52
  regular: {
54
53
  patches: proto.ISyncdPatch[];
55
54
  hasMorePatches: boolean;
56
- snapshot?: proto.ISyncdSnapshot | undefined;
55
+ snapshot?: proto.ISyncdSnapshot;
57
56
  };
58
57
  }>;
59
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer>;
60
- export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
58
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<any>;
59
+ export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
61
60
  export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
62
61
  state: LTHashState;
63
62
  mutationMap: ChatMutationMap;
64
63
  }>;
65
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
64
+ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
66
65
  state: LTHashState;
67
66
  mutationMap: ChatMutationMap;
68
67
  }>;