gifted-baileys 1.5.0 → 1.5.4

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 (120) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1429 -684
  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 +2 -2
  8. package/lib/Defaults/index.js +6 -5
  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/index.d.ts +2 -3
  13. package/lib/Socket/Client/index.js +2 -3
  14. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -1
  15. package/lib/Socket/Client/types.d.ts +17 -0
  16. package/lib/Socket/Client/types.js +13 -0
  17. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  18. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
  19. package/lib/Socket/business.d.ts +64 -29
  20. package/lib/Socket/business.js +1 -0
  21. package/lib/Socket/chats.d.ts +10 -8
  22. package/lib/Socket/chats.js +114 -97
  23. package/lib/Socket/groups.d.ts +10 -8
  24. package/lib/Socket/groups.js +4 -2
  25. package/lib/Socket/index.d.ts +70 -35
  26. package/lib/Socket/messages-recv.d.ts +63 -29
  27. package/lib/Socket/messages-recv.js +374 -155
  28. package/lib/Socket/messages-send.d.ts +48 -12
  29. package/lib/Socket/messages-send.js +445 -87
  30. package/lib/Socket/newsletter.d.ts +132 -0
  31. package/lib/Socket/newsletter.js +236 -0
  32. package/lib/Socket/registration.d.ts +73 -41
  33. package/lib/Socket/registration.js +7 -7
  34. package/lib/Socket/socket.d.ts +2 -0
  35. package/lib/Socket/socket.js +56 -15
  36. package/lib/Socket/usync.d.ts +37 -0
  37. package/lib/Socket/usync.js +70 -0
  38. package/lib/Store/make-cache-manager-store.d.ts +2 -1
  39. package/lib/Store/make-in-memory-store.d.ts +2 -1
  40. package/lib/Store/make-in-memory-store.js +40 -46
  41. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  42. package/lib/Types/Auth.d.ts +2 -1
  43. package/lib/Types/Call.d.ts +1 -1
  44. package/lib/Types/Chat.d.ts +12 -7
  45. package/lib/Types/Events.d.ts +17 -2
  46. package/lib/Types/GroupMetadata.d.ts +6 -2
  47. package/lib/Types/Label.d.ts +11 -0
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +184 -12
  51. package/lib/Types/Newsletter.d.ts +92 -0
  52. package/lib/Types/Newsletter.js +32 -0
  53. package/lib/Types/Socket.d.ts +7 -2
  54. package/lib/Types/USync.d.ts +25 -0
  55. package/lib/Types/USync.js +2 -0
  56. package/lib/Types/index.d.ts +10 -0
  57. package/lib/Types/index.js +2 -1
  58. package/lib/Utils/auth-utils.js +5 -3
  59. package/lib/Utils/business.d.ts +1 -1
  60. package/lib/Utils/business.js +2 -2
  61. package/lib/Utils/chat-utils.d.ts +11 -12
  62. package/lib/Utils/chat-utils.js +41 -20
  63. package/lib/Utils/crypto.d.ts +15 -16
  64. package/lib/Utils/crypto.js +35 -23
  65. package/lib/Utils/decode-wa-message.d.ts +17 -0
  66. package/lib/Utils/decode-wa-message.js +65 -13
  67. package/lib/Utils/generics.d.ts +11 -17
  68. package/lib/Utils/generics.js +47 -13
  69. package/lib/Utils/history.d.ts +6 -2
  70. package/lib/Utils/history.js +3 -0
  71. package/lib/Utils/link-preview.js +1 -1
  72. package/lib/Utils/logger.d.ts +1 -3
  73. package/lib/Utils/make-mutex.d.ts +2 -2
  74. package/lib/Utils/messages-media.d.ts +31 -25
  75. package/lib/Utils/messages-media.js +95 -53
  76. package/lib/Utils/messages.d.ts +2 -1
  77. package/lib/Utils/messages.js +515 -34
  78. package/lib/Utils/noise-handler.d.ts +6 -6
  79. package/lib/Utils/noise-handler.js +16 -3
  80. package/lib/Utils/process-message.js +4 -3
  81. package/lib/Utils/signal.d.ts +2 -1
  82. package/lib/Utils/signal.js +11 -19
  83. package/lib/Utils/use-multi-file-auth-state.js +11 -3
  84. package/lib/Utils/validate-connection.js +16 -2
  85. package/lib/WABinary/decode.d.ts +1 -2
  86. package/lib/WABinary/decode.js +17 -7
  87. package/lib/WABinary/encode.d.ts +1 -2
  88. package/lib/WABinary/encode.js +33 -17
  89. package/lib/WABinary/generic-utils.d.ts +2 -3
  90. package/lib/WABinary/generic-utils.js +2 -2
  91. package/lib/WABinary/jid-utils.d.ts +4 -2
  92. package/lib/WABinary/jid-utils.js +4 -1
  93. package/lib/WAM/BinaryInfo.d.ts +8 -0
  94. package/lib/WAM/BinaryInfo.js +13 -0
  95. package/lib/WAM/constants.d.ts +38 -0
  96. package/lib/WAM/constants.js +15350 -0
  97. package/lib/WAM/encode.d.ts +2 -0
  98. package/lib/WAM/encode.js +155 -0
  99. package/lib/WAM/index.d.ts +3 -0
  100. package/lib/WAM/index.js +19 -0
  101. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  102. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  103. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  104. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  105. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  106. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  107. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  108. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  109. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  110. package/lib/WAUSync/Protocols/index.js +20 -0
  111. package/lib/WAUSync/USyncQuery.d.ts +26 -0
  112. package/lib/WAUSync/USyncQuery.js +79 -0
  113. package/lib/WAUSync/USyncUser.d.ts +10 -0
  114. package/lib/WAUSync/USyncUser.js +22 -0
  115. package/lib/WAUSync/index.d.ts +3 -0
  116. package/lib/WAUSync/index.js +19 -0
  117. package/lib/gifted +1 -0
  118. package/lib/index.js +2 -0
  119. package/package.json +10 -7
  120. package/lib/index.d.ts +0 -10
@@ -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 = {}));
@@ -5,6 +5,7 @@ import { AxiosRequestConfig } from 'axios';
5
5
  import type { Logger } from 'pino';
6
6
  import type { Readable } from 'stream';
7
7
  import type { URL } from 'url';
8
+ import { BinaryNode } from '../WABinary';
8
9
  import { proto } from '../../WAProto';
9
10
  import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
10
11
  import type { GroupMetadata } from './GroupMetadata';
@@ -18,6 +19,7 @@ export type WAMessageKey = proto.IMessageKey;
18
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
19
20
  export type WAContextInfo = proto.IContextInfo;
20
21
  export type WALocationMessage = proto.Message.ILocationMessage;
22
+ export type WALiveLocationMessage = proto.Message.ILiveLocationMessage;
21
23
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
22
24
  export import WAMessageStubType = proto.WebMessageInfo.StubType;
23
25
  export import WAMessageStatus = proto.WebMessageInfo.Status;
@@ -26,6 +28,7 @@ export type WAMediaUpload = Buffer | {
26
28
  } | {
27
29
  stream: Readable;
28
30
  };
31
+ export import Annotations = proto.IInteractiveAnnotation;
29
32
  /** Set of message types that are supported by the library */
30
33
  export type MessageType = keyof proto.Message;
31
34
  export type DownloadableMessage = {
@@ -52,6 +55,19 @@ export interface WAUrlInfo {
52
55
  highQualityThumbnail?: proto.Message.IImageMessage;
53
56
  originalThumbnailUrl?: string;
54
57
  }
58
+ export interface Media {
59
+ image?: WAMediaUpload;
60
+ video?: WAMediaUpload;
61
+ }
62
+ export interface Carousel {
63
+ image?: WAMediaUpload;
64
+ video?: WAMediaUpload;
65
+ product?: WASendableProduct;
66
+ title?: string;
67
+ caption?: string;
68
+ footer?: string;
69
+ buttons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
70
+ }
55
71
  type Mentionable = {
56
72
  /** list of jids that are mentioned in the accompanying text */
57
73
  mentions?: string[];
@@ -72,6 +88,35 @@ type Templatable = {
72
88
  templateButtons?: proto.IHydratedTemplateButton[];
73
89
  footer?: string;
74
90
  };
91
+ type Interactiveable = {
92
+ /** add buttons to the message (conflicts with normal buttons)*/
93
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
94
+ title?: string;
95
+ subtitle?: string;
96
+ media?: boolean;
97
+ };
98
+ type Shopable = {
99
+ shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
100
+ id?: string;
101
+ title?: string;
102
+ subtitle?: string;
103
+ media?: boolean;
104
+ };
105
+ type Collectionable = {
106
+ collection?: {
107
+ bizJid?: string;
108
+ id?: string;
109
+ version?: number;
110
+ };
111
+ title?: string;
112
+ subtitle?: string;
113
+ media?: boolean;
114
+ };
115
+ type Cardsable = {
116
+ cards?: Carousel[];
117
+ title?: string;
118
+ subtitle?: string;
119
+ };
75
120
  type Editable = {
76
121
  edit?: WAMessageKey;
77
122
  };
@@ -80,7 +125,7 @@ type Listable = {
80
125
  sections?: proto.Message.ListMessage.ISection[];
81
126
  /** Title of a List Message only */
82
127
  title?: string;
83
- /** Text of the bnutton on the list (required) */
128
+ /** Text of the button on the list (required) */
84
129
  buttonText?: string;
85
130
  };
86
131
  type WithDimensions = {
@@ -93,6 +138,12 @@ export type PollMessageOptions = {
93
138
  values: string[];
94
139
  /** 32 byte message secret to encrypt poll selections */
95
140
  messageSecret?: Uint8Array;
141
+ toAnnouncementGroup?: boolean;
142
+ };
143
+ export type PollResultMessage = {
144
+ name: string;
145
+ votes: proto.Message.PollResultSnapshotMessage.PollVote[];
146
+ messageSecret?: Uint8Array;
96
147
  };
97
148
  type SharePhoneNumber = {
98
149
  sharePhoneNumber: boolean;
@@ -100,46 +151,123 @@ type SharePhoneNumber = {
100
151
  type RequestPhoneNumber = {
101
152
  requestPhoneNumber: boolean;
102
153
  };
154
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
155
+ productImage: WAMediaUpload;
156
+ };
103
157
  export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
104
158
  export type AnyMediaMessageContent = (({
105
159
  image: WAMediaUpload;
106
160
  caption?: string;
107
161
  jpegThumbnail?: string;
108
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
162
+ annotations?: Annotations;
163
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | ({
109
164
  video: WAMediaUpload;
110
165
  caption?: string;
111
166
  gifPlayback?: boolean;
112
167
  jpegThumbnail?: string;
113
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
168
+ /** if set to true, will send as a `video note` */
169
+ ptv?: boolean;
170
+ annotations?: Annotations;
171
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | {
114
172
  audio: WAMediaUpload;
115
173
  /** if set to true, will send as a `voice note` */
116
174
  ptt?: boolean;
117
175
  /** optionally tell the duration of the audio */
118
176
  seconds?: number;
177
+ annotations?: Annotations;
119
178
  } | ({
120
179
  sticker: WAMediaUpload;
121
180
  isAnimated?: boolean;
181
+ annotations?: Annotations;
122
182
  } & WithDimensions) | ({
123
183
  document: WAMediaUpload;
124
184
  mimetype: string;
125
185
  fileName?: string;
126
186
  caption?: string;
127
- } & Contextable & Buttonable & Templatable)) & {
187
+ annotations?: Annotations;
188
+ } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable)) & {
128
189
  mimetype?: string;
129
190
  } & Editable;
130
191
  export type ButtonReplyInfo = {
131
192
  displayText: string;
132
193
  id: string;
133
194
  index: number;
195
+ text: string;
196
+ nativeFlow: proto.Message.InteractiveResponseMessage.NativeFlowResponseMessage;
134
197
  };
135
- export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
136
- productImage: WAMediaUpload;
198
+ export type GroupInviteInfo = {
199
+ inviteCode: string;
200
+ inviteExpiration: number;
201
+ text: string;
202
+ jid: string;
203
+ subject: string;
204
+ thumbnail: Buffer;
205
+ };
206
+ export type PinInChatInfo = {
207
+ key: WAMessageKey;
208
+ type?: number;
209
+ time?: number;
210
+ };
211
+ export type KeepInChatInfo = {
212
+ key: WAMessageKey;
213
+ type?: number;
214
+ time?: number;
215
+ };
216
+ export type CallCreationInfo = {
217
+ time?: number;
218
+ title?: string;
219
+ type?: number;
220
+ };
221
+ export type PaymentInviteInfo = {
222
+ type?: number;
223
+ expiry?: number;
224
+ };
225
+ export type RequestPaymentInfo = {
226
+ expiry: number;
227
+ amount: number;
228
+ currency: string;
229
+ from: string;
230
+ note?: string;
231
+ sticker?: WAMediaUpload;
232
+ background: string;
233
+ /** add contextInfo to the message */
234
+ contextInfo?: proto.IContextInfo;
235
+ };
236
+ export type EventsInfo = {
237
+ isCanceled?: boolean;
238
+ name: string;
239
+ description: string;
240
+ joinLink?: string;
241
+ startTime?: number;
242
+ messageSecret?: Uint8Array;
243
+ };
244
+ export type AdminInviteInfo = {
245
+ inviteExpiration: number;
246
+ text: string;
247
+ jid: string;
248
+ subject: string;
249
+ thumbnail: Buffer;
250
+ };
251
+ export type OrderInfo = {
252
+ id: number;
253
+ thumbnail: string;
254
+ itemCount: number;
255
+ status: number;
256
+ surface: number;
257
+ title: string;
258
+ text: string;
259
+ seller: string;
260
+ token: string;
261
+ amount: number;
262
+ currency: string;
137
263
  };
138
264
  export type AnyRegularMessageContent = (({
139
265
  text: string;
140
266
  linkPreview?: WAUrlInfo | null;
141
- } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
267
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
142
268
  poll: PollMessageOptions;
269
+ } | {
270
+ pollResult: PollResultMessage;
143
271
  } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
144
272
  contacts: {
145
273
  displayName?: string;
@@ -147,19 +275,49 @@ export type AnyRegularMessageContent = (({
147
275
  };
148
276
  } | {
149
277
  location: WALocationMessage;
278
+ } | {
279
+ liveLocation: WALiveLocationMessage;
150
280
  } | {
151
281
  react: proto.Message.IReactionMessage;
152
282
  } | {
153
283
  buttonReply: ButtonReplyInfo;
154
- type: 'template' | 'plain';
284
+ type: 'template' | 'plain' | 'interactive';
155
285
  } | {
156
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
286
+ groupInvite: GroupInviteInfo;
287
+ } | {
288
+ pin: WAMessageKey;
289
+ type: proto.PinInChat.Type;
290
+ /**
291
+ * 24 hours, 7 days, 30 days
292
+ */
293
+ time?: 86400 | 604800 | 2592000;
294
+ } | {
295
+ keep: WAMessageKey;
296
+ type: number;
297
+ /**
298
+ * 24 hours, 7 days, 90 days
299
+ */
300
+ time?: 86400 | 604800 | 7776000;
301
+ } | {
302
+ paymentInvite: PaymentInviteInfo;
303
+ } | {
304
+ requestPayment: RequestPaymentInfo;
305
+ } | {
306
+ event: EventsInfo;
307
+ } | {
308
+ order: OrderInfo;
157
309
  } | {
310
+ call: CallCreationInfo;
311
+ } | {
312
+ inviteAdmin: AdminInviteInfo;
313
+ } | {
314
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
315
+ } | ({
158
316
  product: WASendableProduct;
159
317
  businessOwnerJid?: string;
160
318
  body?: string;
161
319
  footer?: string;
162
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
320
+ } & Mentionable & Contextable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
163
321
  export type AnyMessageContent = AnyRegularMessageContent | {
164
322
  forward: WAMessage;
165
323
  force?: boolean;
@@ -186,6 +344,7 @@ export type MessageRelayOptions = MinimalRelayOptions & {
186
344
  additionalAttributes?: {
187
345
  [_: string]: string;
188
346
  };
347
+ additionalNodes?: BinaryNode[];
189
348
  /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
190
349
  useUserDevicesCache?: boolean;
191
350
  /** jid list of participants for status@broadcast */
@@ -196,6 +355,7 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
196
355
  timestamp?: Date;
197
356
  /** the message you want to quote */
198
357
  quoted?: WAMessage;
358
+ additionalNodes?: BinaryNode[];
199
359
  /** disappearing messages settings */
200
360
  ephemeralExpiration?: number | string;
201
361
  /** timeout for media upload to WA server */
@@ -206,17 +366,24 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
206
366
  backgroundColor?: string;
207
367
  /** font type for status */
208
368
  font?: number;
369
+ /** if it is broadcast */
370
+ broadcast?: boolean;
371
+ /** delay of message time */
372
+ delay?: number;
209
373
  };
210
374
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
211
375
  userJid: string;
212
376
  };
213
- export type WAMediaUploadFunction = (readStream: Readable, opts: {
377
+ export type WAMediaUploadFunctionOpts = {
214
378
  fileEncSha256B64: string;
215
379
  mediaType: MediaType;
380
+ newsletter?: boolean;
216
381
  timeoutMs?: number;
217
- }) => Promise<{
382
+ };
383
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
218
384
  mediaUrl: string;
219
385
  directPath: string;
386
+ handle?: string;
220
387
  }>;
221
388
  export type MediaGenerationOptions = {
222
389
  logger?: Logger;
@@ -226,11 +393,16 @@ export type MediaGenerationOptions = {
226
393
  mediaCache?: CacheStore;
227
394
  mediaUploadTimeoutMs?: number;
228
395
  options?: AxiosRequestConfig;
396
+ /** the message you want to quote */
397
+ quoted?: WAMessage;
229
398
  backgroundColor?: string;
230
399
  font?: number;
400
+ /** The message is for newsletter? */
401
+ newsletter?: boolean;
231
402
  };
232
403
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
233
404
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
405
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
234
406
  };
235
407
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
236
408
  /**
@@ -0,0 +1,92 @@
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
+ }
80
+ export declare enum QueryIds {
81
+ JOB_MUTATION = "7150902998257522",
82
+ METADATA = "6620195908089573",
83
+ UNFOLLOW = "7238632346214362",
84
+ FOLLOW = "7871414976211147",
85
+ UNMUTE = "7337137176362961",
86
+ MUTE = "25151904754424642",
87
+ CREATE = "6996806640408138",
88
+ ADMIN_COUNT = "7130823597031706",
89
+ CHANGE_OWNER = "7341777602580933",
90
+ DELETE = "8316537688363079",
91
+ DEMOTE = "6551828931592903"
92
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryIds = 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 = 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 = XWAPaths = {}));
19
+ var QueryIds;
20
+ (function (QueryIds) {
21
+ QueryIds["JOB_MUTATION"] = "7150902998257522";
22
+ QueryIds["METADATA"] = "6620195908089573";
23
+ QueryIds["UNFOLLOW"] = "7238632346214362";
24
+ QueryIds["FOLLOW"] = "7871414976211147";
25
+ QueryIds["UNMUTE"] = "7337137176362961";
26
+ QueryIds["MUTE"] = "25151904754424642";
27
+ QueryIds["CREATE"] = "6996806640408138";
28
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
29
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
+ QueryIds["DELETE"] = "8316537688363079";
31
+ QueryIds["DEMOTE"] = "6551828931592903";
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;
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,7 @@ export * from './Chat';
4
4
  export * from './Contact';
5
5
  export * from './State';
6
6
  export * from './Message';
7
+ export * from './Newsletter';
7
8
  export * from './Socket';
8
9
  export * from './Events';
9
10
  export * from './Product';
@@ -14,6 +15,15 @@ import { SocketConfig } from './Socket';
14
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
15
16
  auth: AuthenticationState;
16
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
+ };
17
27
  export declare enum DisconnectReason {
18
28
  connectionClosed = 428,
19
29
  connectionLost = 408,
@@ -21,6 +21,7 @@ __exportStar(require("./Chat"), exports);
21
21
  __exportStar(require("./Contact"), exports);
22
22
  __exportStar(require("./State"), exports);
23
23
  __exportStar(require("./Message"), exports);
24
+ __exportStar(require("./Newsletter"), exports);
24
25
  __exportStar(require("./Socket"), exports);
25
26
  __exportStar(require("./Events"), exports);
26
27
  __exportStar(require("./Product"), exports);
@@ -38,4 +39,4 @@ var DisconnectReason;
38
39
  DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
39
40
  DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
40
41
  DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
41
- })(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
@@ -199,6 +199,8 @@ const initAuthCreds = () => {
199
199
  backupToken: (0, crypto_1.randomBytes)(20),
200
200
  registration: {},
201
201
  pairingCode: undefined,
202
+ lastPropHash: undefined,
203
+ routingInfo: undefined,
202
204
  };
203
205
  };
204
206
  exports.initAuthCreds = initAuthCreds;
@@ -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
  */