@genuxofficial/baileys 1.0.0 → 2.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.
Files changed (99) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/WAProto/index.d.ts +19244 -2787
  4. package/WAProto/index.js +138202 -74217
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.d.ts +3 -5
  8. package/lib/Defaults/index.js +7 -6
  9. package/lib/Signal/libsignal.js +18 -9
  10. package/lib/Socket/Client/types.d.ts +0 -2
  11. package/lib/Socket/Client/websocket.js +1 -1
  12. package/lib/Socket/business.d.ts +65 -37
  13. package/lib/Socket/chats.d.ts +22 -18
  14. package/lib/Socket/chats.js +110 -6
  15. package/lib/Socket/groups.d.ts +30 -26
  16. package/lib/Socket/groups.js +20 -6
  17. package/lib/Socket/index.d.ts +66 -38
  18. package/lib/Socket/messages-recv.d.ts +63 -33
  19. package/lib/Socket/messages-recv.js +174 -27
  20. package/lib/Socket/messages-send.d.ts +55 -29
  21. package/lib/Socket/messages-send.js +190 -26
  22. package/lib/Socket/newsletter.d.ts +140 -0
  23. package/lib/Socket/newsletter.js +252 -0
  24. package/lib/Socket/socket.d.ts +8 -10
  25. package/lib/Socket/socket.js +26 -13
  26. package/lib/Socket/usync.d.ts +10 -12
  27. package/lib/Socket/usync.js +10 -15
  28. package/lib/Store/index.d.ts +1 -2
  29. package/lib/Store/index.js +1 -3
  30. package/lib/Store/make-in-memory-store.d.ts +1 -1
  31. package/lib/Store/make-in-memory-store.js +14 -5
  32. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  33. package/lib/Types/Auth.d.ts +0 -2
  34. package/lib/Types/Chat.d.ts +7 -0
  35. package/lib/Types/Contact.d.ts +5 -0
  36. package/lib/Types/Events.d.ts +27 -0
  37. package/lib/Types/GroupMetadata.d.ts +7 -0
  38. package/lib/Types/Label.js +1 -1
  39. package/lib/Types/LabelAssociation.js +1 -1
  40. package/lib/Types/Message.d.ts +129 -16
  41. package/lib/Types/Message.js +0 -2
  42. package/lib/Types/Newsletter.d.ts +79 -0
  43. package/lib/Types/Newsletter.js +18 -0
  44. package/lib/Types/Socket.d.ts +8 -5
  45. package/lib/Types/index.d.ts +1 -0
  46. package/lib/Types/index.js +2 -1
  47. package/lib/Utils/auth-utils.d.ts +1 -1
  48. package/lib/Utils/auth-utils.js +6 -7
  49. package/lib/Utils/business.js +2 -2
  50. package/lib/Utils/chat-utils.d.ts +8 -10
  51. package/lib/Utils/chat-utils.js +11 -0
  52. package/lib/Utils/crypto.d.ts +14 -16
  53. package/lib/Utils/crypto.js +40 -26
  54. package/lib/Utils/decode-wa-message.d.ts +5 -3
  55. package/lib/Utils/decode-wa-message.js +171 -29
  56. package/lib/Utils/event-buffer.js +1 -3
  57. package/lib/Utils/generics.d.ts +35 -9
  58. package/lib/Utils/generics.js +93 -27
  59. package/lib/Utils/history.d.ts +2 -2
  60. package/lib/Utils/link-preview.d.ts +1 -1
  61. package/lib/Utils/link-preview.js +17 -7
  62. package/lib/Utils/make-mutex.d.ts +2 -2
  63. package/lib/Utils/make-mutex.js +0 -1
  64. package/lib/Utils/messages-media.d.ts +35 -16
  65. package/lib/Utils/messages-media.js +168 -43
  66. package/lib/Utils/messages.d.ts +6 -9
  67. package/lib/Utils/messages.js +297 -37
  68. package/lib/Utils/noise-handler.d.ts +5 -7
  69. package/lib/Utils/process-message.js +2 -3
  70. package/lib/Utils/use-multi-file-auth-state.js +44 -13
  71. package/lib/Utils/validate-connection.d.ts +2 -2
  72. package/lib/Utils/validate-connection.js +1 -3
  73. package/lib/WABinary/decode.d.ts +2 -4
  74. package/lib/WABinary/decode.js +20 -9
  75. package/lib/WABinary/encode.d.ts +1 -3
  76. package/lib/WABinary/encode.js +30 -12
  77. package/lib/WABinary/generic-utils.d.ts +1 -3
  78. package/lib/WABinary/generic-utils.js +2 -2
  79. package/lib/WABinary/jid-utils.d.ts +9 -4
  80. package/lib/WABinary/jid-utils.js +25 -4
  81. package/lib/WAM/BinaryInfo.d.ts +2 -12
  82. package/lib/WAM/encode.d.ts +1 -3
  83. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  84. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
  85. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  86. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -5
  87. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  88. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  89. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  90. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  91. package/lib/WAUSync/USyncQuery.d.ts +2 -0
  92. package/lib/WAUSync/USyncQuery.js +27 -13
  93. package/lib/WAUSync/USyncUser.d.ts +2 -0
  94. package/lib/WAUSync/USyncUser.js +4 -0
  95. package/lib/index.d.ts +2 -1
  96. package/lib/index.js +3 -1
  97. package/package.json +59 -57
  98. package/WAProto/GenerateStatics.sh +0 -4
  99. package/WAProto/WAProto.proto +0 -3344
@@ -3,22 +3,29 @@ export type GroupParticipant = (Contact & {
3
3
  isAdmin?: boolean;
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
+ lid?: string;
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;
16
+ onwerPn?: string | undefined;
13
17
  subject: string;
14
18
  /** group subject owner */
15
19
  subjectOwner?: string;
20
+ subjectOwnerPn?: string;
16
21
  /** group subject modification date */
17
22
  subjectTime?: number;
18
23
  creation?: number;
19
24
  desc?: string;
20
25
  descOwner?: string;
26
+ descOwnerPn?: string;
21
27
  descId?: string;
28
+ descTime?: number;
22
29
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
23
30
  linkedParent?: string;
24
31
  /** is set when the group only allows admins to change group settings */
@@ -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,7 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
1
  import { AxiosRequestConfig } from 'axios';
6
2
  import type { Readable } from 'stream';
7
3
  import type { URL } from 'url';
@@ -10,19 +6,22 @@ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
10
6
  import { BinaryNode } from '../WABinary';
11
7
  import type { GroupMetadata } from './GroupMetadata';
12
8
  import { CacheStore } from './Socket';
9
+ import { ILogger } from '../Utils/logger';
13
10
  export { proto as WAProto };
14
11
  export type WAMessage = proto.IWebMessageInfo;
15
12
  export type WAMessageContent = proto.IMessage;
16
13
  export type WAContactMessage = proto.Message.IContactMessage;
17
14
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
18
- export type WAMessageKey = proto.IMessageKey;
15
+ export type WAMessageKey = proto.IMessageKey & {
16
+ lid?: string;
17
+ server_id?: string;
18
+ };
19
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
20
20
  export type WAContextInfo = proto.IContextInfo;
21
21
  export type WALocationMessage = proto.Message.ILocationMessage;
22
22
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
23
- export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
- export import WAMessageStatus = proto.WebMessageInfo.Status;
25
- import { ILogger } from '../Utils/logger';
23
+ export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
24
+ export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
26
25
  export type WAMediaPayloadURL = {
27
26
  url: URL | string;
28
27
  };
@@ -67,9 +66,46 @@ type Contextable = {
67
66
  type ViewOnce = {
68
67
  viewOnce?: boolean;
69
68
  };
69
+ type Buttonable = {
70
+ /** add buttons to the message */
71
+ buttons?: proto.Message.ButtonsMessage.IButton[];
72
+ };
73
+ type Templatable = {
74
+ /** add buttons to the message (conflicts with normal buttons)*/
75
+ templateButtons?: proto.IHydratedTemplateButton[];
76
+ footer?: string;
77
+ };
78
+ type Interactiveable = {
79
+ /** add buttons to the message */
80
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
81
+ title?: string;
82
+ subtitle?: string;
83
+ media?: boolean;
84
+ };
85
+ type Shopable = {
86
+ shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
87
+ id?: string;
88
+ title?: string;
89
+ subtitle?: string;
90
+ media?: boolean;
91
+ };
92
+ type Cardsable = {
93
+ cards?: string[];
94
+ subtitle?: string;
95
+ };
70
96
  type Editable = {
71
97
  edit?: WAMessageKey;
72
98
  };
99
+ type Listable = {
100
+ /** Sections of the List */
101
+ sections?: proto.Message.ListMessage.ISection[];
102
+ /** Title of a List Message only */
103
+ title?: string;
104
+ /** Text of the button on the list (required) */
105
+ buttonText?: string;
106
+ /** ListType of a List Message only */
107
+ listType?: proto.Message.ListMessage.ListType;
108
+ };
73
109
  type WithDimensions = {
74
110
  width?: number;
75
111
  height?: number;
@@ -93,14 +129,14 @@ export type AnyMediaMessageContent = (({
93
129
  image: WAMediaUpload;
94
130
  caption?: string;
95
131
  jpegThumbnail?: string;
96
- } & Mentionable & Contextable & WithDimensions) | ({
132
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
97
133
  video: WAMediaUpload;
98
134
  caption?: string;
99
135
  gifPlayback?: boolean;
100
136
  jpegThumbnail?: string;
101
137
  /** if set to true, will send as a `video note` */
102
138
  ptv?: boolean;
103
- } & Mentionable & Contextable & WithDimensions) | {
139
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
104
140
  audio: WAMediaUpload;
105
141
  /** if set to true, will send as a `voice note` */
106
142
  ptt?: boolean;
@@ -114,7 +150,7 @@ export type AnyMediaMessageContent = (({
114
150
  mimetype: string;
115
151
  fileName?: string;
116
152
  caption?: string;
117
- } & Contextable)) & {
153
+ } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
118
154
  mimetype?: string;
119
155
  } & Editable;
120
156
  export type ButtonReplyInfo = {
@@ -129,15 +165,63 @@ export type GroupInviteInfo = {
129
165
  jid: string;
130
166
  subject: string;
131
167
  };
168
+ export type CallCreationInfo = {
169
+ time?: number;
170
+ title?: string;
171
+ type?: number;
172
+ };
173
+ export type AdminInviteInfo = {
174
+ inviteExpiration: number;
175
+ text: string;
176
+ jid: string;
177
+ subject: string;
178
+ thumbnail: Buffer;
179
+ };
180
+ export type PaymentInviteInfo = {
181
+ type?: number;
182
+ expiry?: number;
183
+ };
184
+ export type RequestPaymentInfo = {
185
+ expiry: number;
186
+ amount: number;
187
+ currency: string;
188
+ from: string;
189
+ note?: string;
190
+ sticker?: WAMediaUpload;
191
+ background: string;
192
+ /** add contextInfo to the message */
193
+ contextInfo?: proto.IContextInfo;
194
+ };
195
+ export type EventsInfo = {
196
+ isCanceled?: boolean;
197
+ name: string;
198
+ description: string;
199
+ joinLink?: string;
200
+ startTime?: number;
201
+ messageSecret?: Uint8Array;
202
+ };
203
+ export type OrderInfo = {
204
+ id: number;
205
+ thumbnail: string;
206
+ itemCount: number;
207
+ status: number;
208
+ surface: number;
209
+ title: string;
210
+ text: string;
211
+ seller: string;
212
+ token: string;
213
+ amount: number;
214
+ currency: string;
215
+ };
132
216
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
133
217
  productImage: WAMediaUpload;
134
218
  };
135
219
  export type AnyRegularMessageContent = (({
136
220
  text: string;
137
221
  linkPreview?: WAUrlInfo | null;
138
- } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
222
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
139
223
  poll: PollMessageOptions;
140
- } & Mentionable & Contextable & Editable) | {
224
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
141
225
  contacts: {
142
226
  displayName?: string;
143
227
  contacts: proto.Message.IContactMessage[];
@@ -161,11 +245,32 @@ export type AnyRegularMessageContent = (({
161
245
  */
162
246
  time?: 86400 | 604800 | 2592000;
163
247
  } | {
248
+ keep: WAMessageKey;
249
+ type: number;
250
+ /**
251
+ * 24 hours, 7 days, 90 days
252
+ */
253
+ time?: 86400 | 604800 | 7776000;
254
+ } | {
255
+ paymentInvite: PaymentInviteInfo;
256
+ } | {
257
+ requestPayment: RequestPaymentInfo;
258
+ } | {
259
+ event: EventsInfo;
260
+ } | {
261
+ order: OrderInfo;
262
+ } | {
263
+ call: CallCreationInfo;
264
+ } | {
265
+ inviteAdmin: AdminInviteInfo;
266
+ } | {
267
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
268
+ } | ({
164
269
  product: WASendableProduct;
165
270
  businessOwnerJid?: string;
166
271
  body?: string;
167
272
  footer?: string;
168
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
273
+ } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
169
274
  export type AnyMessageContent = AnyRegularMessageContent | {
170
275
  forward: WAMessage;
171
276
  force?: boolean;
@@ -197,6 +302,7 @@ export type MessageRelayOptions = MinimalRelayOptions & {
197
302
  useUserDevicesCache?: boolean;
198
303
  /** jid list of participants for status@broadcast */
199
304
  statusJidList?: string[];
305
+ newsletter?: boolean;
200
306
  };
201
307
  export type MiscMessageGenerationOptions = MinimalRelayOptions & {
202
308
  /** optional, if you want to manually set the timestamp of the message */
@@ -215,17 +321,22 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
215
321
  font?: number;
216
322
  /** if it is broadcast */
217
323
  broadcast?: boolean;
324
+ newsletter?: boolean;
325
+ additionalNodes?: BinaryNode[];
218
326
  };
219
327
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
220
328
  userJid: string;
221
329
  };
222
- export type WAMediaUploadFunction = (readStream: Readable, opts: {
330
+ export type WAMediaUploadFunctionOpts = {
223
331
  fileEncSha256B64: string;
224
332
  mediaType: MediaType;
333
+ newsletter?: boolean;
225
334
  timeoutMs?: number;
226
- }) => Promise<{
335
+ };
336
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
227
337
  mediaUrl: string;
228
338
  directPath: string;
339
+ handle?: string;
229
340
  }>;
230
341
  export type MediaGenerationOptions = {
231
342
  logger?: ILogger;
@@ -237,6 +348,8 @@ export type MediaGenerationOptions = {
237
348
  options?: AxiosRequestConfig;
238
349
  backgroundColor?: string;
239
350
  font?: number;
351
+ /** The message is for newsletter? */
352
+ newsletter?: boolean;
240
353
  };
241
354
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
242
355
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
@@ -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 = 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 = {}));
@@ -1,14 +1,12 @@
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 { URL } from 'url';
6
4
  import { proto } from '../../WAProto';
7
- import { ILogger } from '../Utils/logger';
8
5
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
9
6
  import { GroupMetadata } from './GroupMetadata';
10
7
  import { MediaConnInfo } from './Message';
11
8
  import { SignalRepository } from './Signal';
9
+ import { ILogger } from '../Utils/logger';
12
10
  export type WAVersion = [number, number, number];
13
11
  export type WABrowserDescription = [string, string, string];
14
12
  export type CacheStore = {
@@ -21,6 +19,9 @@ export type CacheStore = {
21
19
  /** flush all data */
22
20
  flushAll(): void;
23
21
  };
22
+ export type PatchedMessageWithRecipientJID = proto.IMessage & {
23
+ recipientJid?: string;
24
+ };
24
25
  export type SocketConfig = {
25
26
  /** the WS url to connect to WA */
26
27
  waWebSocketUrl: string | URL;
@@ -31,7 +32,7 @@ export type SocketConfig = {
31
32
  /** ping-pong interval for WS connection */
32
33
  keepAliveIntervalMs: number;
33
34
  /** should baileys use the mobile api instead of the multi device api
34
- * @deprecated This feature has been removed
35
+ * @deprecated This feature has been removed
35
36
  */
36
37
  mobile?: boolean;
37
38
  /** proxy agent */
@@ -82,6 +83,8 @@ export type SocketConfig = {
82
83
  linkPreviewImageThumbnailWidth: number;
83
84
  /** Should Baileys ask the phone for full history, will be received async */
84
85
  syncFullHistory: boolean;
86
+ /** Ignore Message when offline, default is false */
87
+ ignoreMsgLoading: boolean;
85
88
  /** Should baileys fire init queries automatically, default true */
86
89
  fireInitQueries: boolean;
87
90
  /**
@@ -98,7 +101,7 @@ export type SocketConfig = {
98
101
  /**
99
102
  * Optionally patch the message before sending out
100
103
  * */
101
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
104
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
102
105
  /** verify app state MACs */
103
106
  appStateMacVerification: {
104
107
  patch: boolean;
@@ -1,5 +1,6 @@
1
1
  export * from './Auth';
2
2
  export * from './GroupMetadata';
3
+ export * from './Newsletter';
3
4
  export * from './Chat';
4
5
  export * from './Contact';
5
6
  export * from './State';
@@ -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);
@@ -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 = {}));
@@ -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: ILogger, _cache?: CacheStore): SignalKeyStore;
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
@@ -3,9 +3,10 @@ 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;
7
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
6
+ exports.initAuthCreds = exports.addTransactionCapability = void 0;
7
+ exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
8
8
  const crypto_1 = require("crypto");
9
+ const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
10
  const Defaults_1 = require("../Defaults");
10
11
  const crypto_2 = require("./crypto");
11
12
  const generics_1 = require("./generics");
@@ -17,7 +18,7 @@ const generics_1 = require("./generics");
17
18
  */
18
19
  function makeCacheableSignalKeyStore(store, logger, _cache) {
19
20
  const cache = _cache || new node_cache_1.default({
20
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
21
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
21
22
  useClones: false,
22
23
  deleteOnExpire: true,
23
24
  });
@@ -38,7 +39,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
38
39
  }
39
40
  }
40
41
  if (idsToFetch.length) {
41
- logger.trace({ items: idsToFetch.length }, 'loading from store');
42
+ logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
42
43
  const fetched = await store.get(type, idsToFetch);
43
44
  for (const id of idsToFetch) {
44
45
  const item = fetched[id];
@@ -58,7 +59,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
58
59
  keys += 1;
59
60
  }
60
61
  }
61
- logger.trace({ keys }, 'updated cache');
62
+ logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
62
63
  await store.set(data);
63
64
  },
64
65
  async clear() {
@@ -68,7 +69,6 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
68
69
  }
69
70
  };
70
71
  }
71
- exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
72
72
  /**
73
73
  * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
74
74
  * this allows batch read & write operations & improves the performance of the lib
@@ -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');
@@ -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,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AxiosRequestConfig } from 'axios';
4
2
  import { proto } from '../../WAProto';
5
3
  import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
@@ -15,7 +13,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
15
13
  state: LTHashState;
16
14
  }>;
17
15
  export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
18
- hash: Buffer;
16
+ hash: Buffer<any>;
19
17
  indexValueMap: {
20
18
  [indexMacBase64: string]: {
21
19
  valueMac: Uint8Array | Buffer;
@@ -23,7 +21,7 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
23
21
  };
24
22
  }>;
25
23
  export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
26
- hash: Buffer;
24
+ hash: Buffer<any>;
27
25
  indexValueMap: {
28
26
  [indexMacBase64: string]: {
29
27
  valueMac: Uint8Array | Buffer;
@@ -34,30 +32,30 @@ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosReq
34
32
  critical_block: {
35
33
  patches: proto.ISyncdPatch[];
36
34
  hasMorePatches: boolean;
37
- snapshot?: proto.ISyncdSnapshot | undefined;
35
+ snapshot?: proto.ISyncdSnapshot;
38
36
  };
39
37
  critical_unblock_low: {
40
38
  patches: proto.ISyncdPatch[];
41
39
  hasMorePatches: boolean;
42
- snapshot?: proto.ISyncdSnapshot | undefined;
40
+ snapshot?: proto.ISyncdSnapshot;
43
41
  };
44
42
  regular_high: {
45
43
  patches: proto.ISyncdPatch[];
46
44
  hasMorePatches: boolean;
47
- snapshot?: proto.ISyncdSnapshot | undefined;
45
+ snapshot?: proto.ISyncdSnapshot;
48
46
  };
49
47
  regular_low: {
50
48
  patches: proto.ISyncdPatch[];
51
49
  hasMorePatches: boolean;
52
- snapshot?: proto.ISyncdSnapshot | undefined;
50
+ snapshot?: proto.ISyncdSnapshot;
53
51
  };
54
52
  regular: {
55
53
  patches: proto.ISyncdPatch[];
56
54
  hasMorePatches: boolean;
57
- snapshot?: proto.ISyncdSnapshot | undefined;
55
+ snapshot?: proto.ISyncdSnapshot;
58
56
  };
59
57
  }>;
60
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<Buffer>;
58
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<Buffer<ArrayBuffer>>;
61
59
  export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
62
60
  export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
63
61
  state: LTHashState;
@@ -456,6 +456,17 @@ const chatModificationToAppPatch = (mod, jid) => {
456
456
  operation: OP.SET
457
457
  };
458
458
  }
459
+ else if ('contact' in mod) {
460
+ patch = {
461
+ syncAction: {
462
+ contactAction: mod.contact || {}
463
+ },
464
+ index: ['contact', jid],
465
+ type: 'critical_unblock_low',
466
+ apiVersion: 2,
467
+ operation: mod.contact ? OP.SET : OP.REMOVE
468
+ };
469
+ }
459
470
  else if ('star' in mod) {
460
471
  const key = mod.star.messages[0];
461
472
  patch = {