cuki-bailx 1.1.2 → 1.2.2

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 (116) hide show
  1. package/WAProto/index.js +79296 -118676
  2. package/engine-requirements.js +1 -1
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +6 -4
  5. package/lib/Defaults/index.js +102 -78
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -1
  8. package/lib/Socket/Client/index.d.ts +3 -2
  9. package/lib/Socket/Client/index.js +3 -2
  10. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  11. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  12. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  13. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -12
  14. package/lib/Socket/business.d.ts +58 -59
  15. package/lib/Socket/chats.d.ts +27 -29
  16. package/lib/Socket/chats.js +90 -97
  17. package/lib/Socket/dugong.d.ts +219 -0
  18. package/lib/Socket/dugong.js +441 -0
  19. package/lib/Socket/groups.d.ts +32 -41
  20. package/lib/Socket/groups.js +5 -20
  21. package/lib/Socket/index.d.ts +64 -63
  22. package/lib/Socket/index.js +2 -2
  23. package/lib/Socket/messages-recv.js +65 -9
  24. package/lib/Socket/messages-send.d.ts +47 -49
  25. package/lib/Socket/messages-send.js +312 -379
  26. package/lib/Socket/newsletter.d.ts +37 -39
  27. package/lib/Socket/newsletter.js +40 -54
  28. package/lib/Socket/registration.d.ts +267 -0
  29. package/lib/Socket/registration.js +166 -0
  30. package/lib/Socket/socket.d.ts +10 -10
  31. package/lib/Socket/socket.js +32 -39
  32. package/lib/Socket/socket.js.bak +630 -0
  33. package/lib/Socket/usync.d.ts +3 -3
  34. package/lib/Store/index.d.ts +2 -1
  35. package/lib/Store/index.js +3 -1
  36. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  37. package/lib/Store/make-cache-manager-store.js +83 -0
  38. package/lib/Store/make-in-memory-store.d.ts +24 -24
  39. package/lib/Store/make-in-memory-store.js +11 -13
  40. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  41. package/lib/Store/make-ordered-dictionary.js +2 -2
  42. package/lib/Types/Auth.d.ts +7 -0
  43. package/lib/Types/Call.d.ts +1 -1
  44. package/lib/Types/Chat.d.ts +7 -14
  45. package/lib/Types/Contact.d.ts +1 -5
  46. package/lib/Types/Events.d.ts +2 -44
  47. package/lib/Types/GroupMetadata.d.ts +2 -11
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +21 -148
  51. package/lib/Types/Message.js +2 -0
  52. package/lib/Types/Newsletter.d.ts +13 -0
  53. package/lib/Types/Newsletter.js +17 -3
  54. package/lib/Types/Socket.d.ts +9 -17
  55. package/lib/Types/index.d.ts +1 -8
  56. package/lib/Types/index.js +2 -2
  57. package/lib/Utils/auth-utils.d.ts +3 -3
  58. package/lib/Utils/auth-utils.js +13 -6
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +16 -15
  61. package/lib/Utils/chat-utils.js +35 -36
  62. package/lib/Utils/crypto.d.ts +16 -15
  63. package/lib/Utils/crypto.js +29 -71
  64. package/lib/Utils/decode-wa-message.d.ts +6 -22
  65. package/lib/Utils/decode-wa-message.js +56 -65
  66. package/lib/Utils/event-buffer.d.ts +2 -2
  67. package/lib/Utils/event-buffer.js +7 -11
  68. package/lib/Utils/generics.d.ts +20 -17
  69. package/lib/Utils/generics.js +23 -73
  70. package/lib/Utils/history.d.ts +0 -4
  71. package/lib/Utils/history.js +6 -4
  72. package/lib/Utils/link-preview.d.ts +2 -2
  73. package/lib/Utils/link-preview.js +1 -34
  74. package/lib/Utils/logger.d.ts +3 -10
  75. package/lib/Utils/lt-hash.d.ts +2 -2
  76. package/lib/Utils/lt-hash.js +6 -6
  77. package/lib/Utils/make-mutex.d.ts +2 -2
  78. package/lib/Utils/messages-media.d.ts +24 -28
  79. package/lib/Utils/messages-media.js +115 -263
  80. package/lib/Utils/messages.d.ts +10 -8
  81. package/lib/Utils/messages.js +72 -298
  82. package/lib/Utils/noise-handler.d.ts +12 -10
  83. package/lib/Utils/noise-handler.js +23 -18
  84. package/lib/Utils/process-message.d.ts +4 -5
  85. package/lib/Utils/process-message.js +23 -74
  86. package/lib/Utils/signal.d.ts +1 -2
  87. package/lib/Utils/signal.js +35 -37
  88. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  89. package/lib/Utils/use-multi-file-auth-state.js +6 -51
  90. package/lib/Utils/validate-connection.d.ts +4 -3
  91. package/lib/Utils/validate-connection.js +52 -20
  92. package/lib/WABinary/constants.d.ts +4 -4
  93. package/lib/WABinary/constants.js +13 -1276
  94. package/lib/WABinary/decode.d.ts +4 -3
  95. package/lib/WABinary/decode.js +13 -26
  96. package/lib/WABinary/encode.d.ts +2 -1
  97. package/lib/WABinary/encode.js +17 -39
  98. package/lib/WABinary/generic-utils.d.ts +3 -1
  99. package/lib/WABinary/generic-utils.js +85 -2
  100. package/lib/WABinary/jid-utils.d.ts +5 -10
  101. package/lib/WABinary/jid-utils.js +5 -26
  102. package/lib/WAM/BinaryInfo.d.ts +11 -2
  103. package/lib/WAM/encode.d.ts +2 -1
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  105. package/lib/index.d.ts +2 -6
  106. package/lib/index.js +7 -22
  107. package/lib/index.js.bak +37 -0
  108. package/package.json +103 -111
  109. package/LICENSE +0 -21
  110. package/WAProto/GenerateStatics.sh +0 -4
  111. package/WAProto/WAProto.proto +0 -4775
  112. package/WAProto/index.d.ts +0 -55057
  113. package/WAProto/index.ts.ts +0 -53473
  114. package/WAProto/p.html +0 -1
  115. package/lib/WABinary/jid-utils.js.bak +0 -83
  116. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -1,39 +1,32 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
1
4
  import { AxiosRequestConfig } from 'axios';
5
+ import type { Logger } from 'pino';
2
6
  import type { Readable } from 'stream';
3
7
  import type { URL } from 'url';
8
+ import { BinaryNode } from '../WABinary';
4
9
  import { proto } from '../../WAProto';
5
10
  import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
6
- import { BinaryNode } from '../WABinary';
7
11
  import type { GroupMetadata } from './GroupMetadata';
8
12
  import { CacheStore } from './Socket';
9
- import { ILogger } from '../Utils/logger';
10
13
  export { proto as WAProto };
11
- export type WAMessage = proto.IWebMessageInfo & {
12
- key: WAMessageKey;
13
- };
14
+ export type WAMessage = proto.IWebMessageInfo;
14
15
  export type WAMessageContent = proto.IMessage;
15
16
  export type WAContactMessage = proto.Message.IContactMessage;
16
17
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
17
- export type WAMessageKey = proto.IMessageKey & {
18
- senderPn?: string;
19
- senderLid?: string;
20
- participantLid?: string;
21
- server_id?: string;
22
- isViewOnce?: boolean;
23
- };
18
+ export type WAMessageKey = proto.IMessageKey;
24
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
25
20
  export type WAContextInfo = proto.IContextInfo;
26
21
  export type WALocationMessage = proto.Message.ILocationMessage;
27
22
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
28
- export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
29
- export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
30
- export type WAMediaPayloadURL = {
23
+ export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
+ export import WAMessageStatus = proto.WebMessageInfo.Status;
25
+ export type WAMediaUpload = Buffer | {
31
26
  url: URL | string;
32
- };
33
- export type WAMediaPayloadStream = {
27
+ } | {
34
28
  stream: Readable;
35
29
  };
36
- export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
37
30
  /** Set of message types that are supported by the library */
38
31
  export type MessageType = keyof proto.Message;
39
32
  export type DownloadableMessage = {
@@ -80,24 +73,6 @@ type Templatable = {
80
73
  templateButtons?: proto.IHydratedTemplateButton[];
81
74
  footer?: string;
82
75
  };
83
- type Interactiveable = {
84
- /** add buttons to the message */
85
- interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
86
- title?: string;
87
- subtitle?: string;
88
- media?: boolean;
89
- };
90
- type Shopable = {
91
- shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
92
- id?: string;
93
- title?: string;
94
- subtitle?: string;
95
- media?: boolean;
96
- };
97
- type Cardsable = {
98
- cards?: string[];
99
- subtitle?: string;
100
- };
101
76
  type Editable = {
102
77
  edit?: WAMessageKey;
103
78
  };
@@ -106,10 +81,8 @@ type Listable = {
106
81
  sections?: proto.Message.ListMessage.ISection[];
107
82
  /** Title of a List Message only */
108
83
  title?: string;
109
- /** Text of the button on the list (required) */
84
+ /** Text of the bnutton on the list (required) */
110
85
  buttonText?: string;
111
- /** ListType of a List Message only */
112
- listType?: proto.Message.ListMessage.ListType;
113
86
  };
114
87
  type WithDimensions = {
115
88
  width?: number;
@@ -121,7 +94,6 @@ export type PollMessageOptions = {
121
94
  values: string[];
122
95
  /** 32 byte message secret to encrypt poll selections */
123
96
  messageSecret?: Uint8Array;
124
- toAnnouncementGroup?: boolean;
125
97
  };
126
98
  type SharePhoneNumber = {
127
99
  sharePhoneNumber: boolean;
@@ -134,14 +106,14 @@ export type AnyMediaMessageContent = (({
134
106
  image: WAMediaUpload;
135
107
  caption?: string;
136
108
  jpegThumbnail?: string;
137
- } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
109
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
138
110
  video: WAMediaUpload;
139
111
  caption?: string;
140
112
  gifPlayback?: boolean;
141
113
  jpegThumbnail?: string;
142
114
  /** if set to true, will send as a `video note` */
143
115
  ptv?: boolean;
144
- } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
116
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
145
117
  audio: WAMediaUpload;
146
118
  /** if set to true, will send as a `voice note` */
147
119
  ptt?: boolean;
@@ -155,7 +127,7 @@ export type AnyMediaMessageContent = (({
155
127
  mimetype: string;
156
128
  fileName?: string;
157
129
  caption?: string;
158
- } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
130
+ } & Contextable & Buttonable & Templatable)) & {
159
131
  mimetype?: string;
160
132
  } & Editable;
161
133
  export type ButtonReplyInfo = {
@@ -163,76 +135,13 @@ export type ButtonReplyInfo = {
163
135
  id: string;
164
136
  index: number;
165
137
  };
166
- export type GroupInviteInfo = {
167
- inviteCode: string;
168
- inviteExpiration: number;
169
- text: string;
170
- jid: string;
171
- subject: string;
172
- };
173
- export type CallCreationInfo = {
174
- time?: number;
175
- title?: string;
176
- type?: number;
177
- };
178
- export type AdminInviteInfo = {
179
- inviteExpiration: number;
180
- text: string;
181
- jid: string;
182
- subject: string;
183
- thumbnail: Buffer;
184
- };
185
- export type PaymentInviteInfo = {
186
- type?: number;
187
- expiry?: number;
188
- };
189
- export type RequestPaymentInfo = {
190
- expiry: number;
191
- amount: number;
192
- currency: string;
193
- from: string;
194
- note?: string;
195
- sticker?: WAMediaUpload;
196
- background: string;
197
- /** add contextInfo to the message */
198
- contextInfo?: proto.IContextInfo;
199
- };
200
- export type EventsInfo = {
201
- isCanceled?: boolean;
202
- name: string;
203
- description: string;
204
- joinLink?: string;
205
- startTime?: number;
206
- messageSecret?: Uint8Array;
207
- };
208
- export type OrderInfo = {
209
- id: number;
210
- thumbnail: string;
211
- itemCount: number;
212
- status: number;
213
- surface: number;
214
- title: string;
215
- text: string;
216
- seller: string;
217
- token: string;
218
- amount: number;
219
- currency: string;
220
- };
221
138
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
222
139
  productImage: WAMediaUpload;
223
140
  };
224
- export type AlbumMedia = {
225
- image: WAMediaUpload;
226
- caption?: string;
227
- } | {
228
- video: WAMediaUpload;
229
- caption?: string;
230
- gifPlayback?: boolean;
231
- };
232
141
  export type AnyRegularMessageContent = (({
233
142
  text: string;
234
143
  linkPreview?: WAUrlInfo | null;
235
- } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
144
+ } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
236
145
  poll: PollMessageOptions;
237
146
  } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
238
147
  contacts: {
@@ -246,47 +155,14 @@ export type AnyRegularMessageContent = (({
246
155
  } | {
247
156
  buttonReply: ButtonReplyInfo;
248
157
  type: 'template' | 'plain';
249
- } | {
250
- groupInvite: GroupInviteInfo;
251
158
  } | {
252
159
  listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
253
160
  } | {
254
- pin: WAMessageKey;
255
- type: proto.PinInChat.Type;
256
- /**
257
- * 24 hours, 7 days, 30 days
258
- */
259
- time?: 86400 | 604800 | 2592000;
260
- } | {
261
- keep: WAMessageKey;
262
- type: number;
263
- /**
264
- * 24 hours, 7 days, 90 days
265
- */
266
- time?: 86400 | 604800 | 7776000;
267
- } | {
268
- paymentInvite: PaymentInviteInfo;
269
- } | {
270
- requestPayment: RequestPaymentInfo;
271
- } | {
272
- event: EventsInfo;
273
- } | {
274
- order: OrderInfo;
275
- } | {
276
- call: CallCreationInfo;
277
- } | {
278
- inviteAdmin: AdminInviteInfo;
279
- } | {
280
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
281
- } | ({
282
161
  product: WASendableProduct;
283
162
  businessOwnerJid?: string;
284
163
  body?: string;
285
164
  footer?: string;
286
- } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
287
- album: AlbumMedia[];
288
- caption?: string;
289
- } & Mentionable & Contextable & Editable)) & ViewOnce;
165
+ } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
290
166
  export type AnyMessageContent = AnyRegularMessageContent | {
291
167
  forward: WAMessage;
292
168
  force?: boolean;
@@ -300,8 +176,8 @@ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
300
176
  type MinimalRelayOptions = {
301
177
  /** override the message ID with a custom provided string */
302
178
  messageId?: string;
303
- /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
304
- useCachedGroupMetadata?: boolean;
179
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
180
+ cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
305
181
  };
306
182
  export type MessageRelayOptions = MinimalRelayOptions & {
307
183
  /** only send to a specific participant; used when a message decryption fails for a single user */
@@ -318,13 +194,13 @@ export type MessageRelayOptions = MinimalRelayOptions & {
318
194
  useUserDevicesCache?: boolean;
319
195
  /** jid list of participants for status@broadcast */
320
196
  statusJidList?: string[];
321
- newsletter?: boolean;
322
197
  };
323
198
  export type MiscMessageGenerationOptions = MinimalRelayOptions & {
324
199
  /** optional, if you want to manually set the timestamp of the message */
325
200
  timestamp?: Date;
326
201
  /** the message you want to quote */
327
202
  quoted?: WAMessage;
203
+ additionalNodes?: BinaryNode[];
328
204
  /** disappearing messages settings */
329
205
  ephemeralExpiration?: number | string;
330
206
  /** timeout for media upload to WA server */
@@ -337,8 +213,6 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
337
213
  font?: number;
338
214
  /** if it is broadcast */
339
215
  broadcast?: boolean;
340
- newsletter?: boolean;
341
- additionalNodes?: BinaryNode[];
342
216
  };
343
217
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
344
218
  userJid: string;
@@ -355,7 +229,7 @@ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMedi
355
229
  handle?: string;
356
230
  }>;
357
231
  export type MediaGenerationOptions = {
358
- logger?: ILogger;
232
+ logger?: Logger;
359
233
  mediaTypeOverride?: MediaType;
360
234
  upload: WAMediaUploadFunction;
361
235
  /** cache media so it does not have to be uploaded again */
@@ -369,7 +243,6 @@ export type MediaGenerationOptions = {
369
243
  };
370
244
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
371
245
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
372
- getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
373
246
  };
374
247
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
375
248
  /**
@@ -3,5 +3,7 @@ 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
6
7
  exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
8
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
7
9
  exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
@@ -77,3 +77,16 @@ export declare enum XWAPaths {
77
77
  NEWSLETTER = "xwa2_newsletter",
78
78
  METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
79
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
+ }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XWAPaths = exports.MexOperations = void 0;
3
+ exports.QueryIds = exports.XWAPaths = exports.MexOperations = void 0;
4
4
  var MexOperations;
5
5
  (function (MexOperations) {
6
6
  MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
7
  MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
8
  MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations || (exports.MexOperations = MexOperations = {}));
9
+ })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
10
10
  var XWAPaths;
11
11
  (function (XWAPaths) {
12
12
  XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
@@ -15,4 +15,18 @@ 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 = XWAPaths = {}));
18
+ })(XWAPaths = exports.XWAPaths || (exports.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 || (exports.QueryIds = {}));
@@ -1,12 +1,13 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { AxiosRequestConfig } from 'axios';
2
4
  import type { Agent } from 'https';
5
+ import type { Logger } from 'pino';
3
6
  import type { URL } from 'url';
4
7
  import { proto } from '../../WAProto';
5
8
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
6
- import { GroupMetadata } from './GroupMetadata';
7
9
  import { MediaConnInfo } from './Message';
8
10
  import { SignalRepository } from './Signal';
9
- import { ILogger } from '../Utils/logger';
10
11
  export type WAVersion = [number, number, number];
11
12
  export type WABrowserDescription = [string, string, string];
12
13
  export type CacheStore = {
@@ -19,9 +20,6 @@ export type CacheStore = {
19
20
  /** flush all data */
20
21
  flushAll(): void;
21
22
  };
22
- export type PatchedMessageWithRecipientJID = proto.IMessage & {
23
- recipientJid?: string;
24
- };
25
23
  export type SocketConfig = {
26
24
  /** the WS url to connect to WA */
27
25
  waWebSocketUrl: string | URL;
@@ -31,14 +29,12 @@ export type SocketConfig = {
31
29
  defaultQueryTimeoutMs: number | undefined;
32
30
  /** ping-pong interval for WS connection */
33
31
  keepAliveIntervalMs: number;
34
- /** should baileys use the mobile api instead of the multi device api
35
- * @deprecated This feature has been removed
36
- */
32
+ /** should baileys use the mobile api instead of the multi device api */
37
33
  mobile?: boolean;
38
34
  /** proxy agent */
39
35
  agent?: Agent;
40
- /** logger */
41
- logger: ILogger;
36
+ /** pino logger */
37
+ logger: Logger;
42
38
  /** version to connect with */
43
39
  version: WAVersion;
44
40
  /** override browser config */
@@ -65,8 +61,6 @@ export type SocketConfig = {
65
61
  transactionOpts: TransactionCapabilityOptions;
66
62
  /** marks the client as online whenever the socket successfully connects */
67
63
  markOnlineOnConnect: boolean;
68
- /** alphanumeric country code (USA -> US) for the number used */
69
- countryCode: string;
70
64
  /** provide a cache to store media, so does not have to be re-uploaded */
71
65
  mediaCache?: CacheStore;
72
66
  /**
@@ -77,8 +71,6 @@ export type SocketConfig = {
77
71
  userDevicesCache?: CacheStore;
78
72
  /** cache to store call offers */
79
73
  callOfferCache?: CacheStore;
80
- /** cache to track placeholder resends */
81
- placeholderResendCache?: CacheStore;
82
74
  /** width for link preview images */
83
75
  linkPreviewImageThumbnailWidth: number;
84
76
  /** Should Baileys ask the phone for full history, will be received async */
@@ -99,7 +91,7 @@ export type SocketConfig = {
99
91
  /**
100
92
  * Optionally patch the message before sending out
101
93
  * */
102
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
94
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
103
95
  /** verify app state MACs */
104
96
  appStateMacVerification: {
105
97
  patch: boolean;
@@ -113,7 +105,7 @@ export type SocketConfig = {
113
105
  * (solves the "this message can take a while" issue) can be retried
114
106
  * */
115
107
  getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
116
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
117
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
118
108
  makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
109
+ /** Socket passthrough */
110
+ socket?: any;
119
111
  };
@@ -1,10 +1,10 @@
1
1
  export * from './Auth';
2
2
  export * from './GroupMetadata';
3
- export * from './Newsletter';
4
3
  export * from './Chat';
5
4
  export * from './Contact';
6
5
  export * from './State';
7
6
  export * from './Message';
7
+ export * from './Newsletter';
8
8
  export * from './Socket';
9
9
  export * from './Events';
10
10
  export * from './Product';
@@ -15,13 +15,6 @@ 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
- appropriate(browser: string): [string, string, string];
24
- };
25
18
  export declare enum DisconnectReason {
26
19
  connectionClosed = 428,
27
20
  connectionLost = 408,
@@ -17,11 +17,11 @@ 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);
21
20
  __exportStar(require("./Chat"), exports);
22
21
  __exportStar(require("./Contact"), exports);
23
22
  __exportStar(require("./State"), exports);
24
23
  __exportStar(require("./Message"), exports);
24
+ __exportStar(require("./Newsletter"), exports);
25
25
  __exportStar(require("./Socket"), exports);
26
26
  __exportStar(require("./Events"), exports);
27
27
  __exportStar(require("./Product"), exports);
@@ -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 = DisconnectReason = {}));
42
+ })(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
@@ -1,12 +1,12 @@
1
+ import type { Logger } from 'pino';
1
2
  import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
2
- import { ILogger } from './logger';
3
3
  /**
4
4
  * Adds caching capability to a SignalKeyStore
5
5
  * @param store the store to add caching to
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: Logger, _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
@@ -14,5 +14,5 @@ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logge
14
14
  * @param logger logger to log events
15
15
  * @returns SignalKeyStore with transaction capability
16
16
  */
17
- export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
17
+ export declare const addTransactionCapability: (state: SignalKeyStore, logger: Logger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
18
18
  export declare const initAuthCreds: () => AuthenticationCreds;
@@ -3,10 +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 = void 0;
7
- exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
6
+ exports.initAuthCreds = exports.addTransactionCapability = exports.makeCacheableSignalKeyStore = void 0;
8
7
  const crypto_1 = require("crypto");
9
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
8
+ const node_cache_1 = __importDefault(require("node-cache"));
9
+ const uuid_1 = require("uuid");
10
10
  const Defaults_1 = require("../Defaults");
11
11
  const crypto_2 = require("./crypto");
12
12
  const generics_1 = require("./generics");
@@ -18,7 +18,7 @@ const generics_1 = require("./generics");
18
18
  */
19
19
  function makeCacheableSignalKeyStore(store, logger, _cache) {
20
20
  const cache = _cache || new node_cache_1.default({
21
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
21
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
22
22
  useClones: false,
23
23
  deleteOnExpire: true,
24
24
  });
@@ -39,7 +39,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
39
39
  }
40
40
  }
41
41
  if (idsToFetch.length) {
42
- logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
42
+ logger.trace({ items: idsToFetch.length }, 'loading from store');
43
43
  const fetched = await store.get(type, idsToFetch);
44
44
  for (const id of idsToFetch) {
45
45
  const item = fetched[id];
@@ -59,7 +59,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
59
59
  keys += 1;
60
60
  }
61
61
  }
62
- logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
62
+ logger.trace({ keys }, 'updated cache');
63
63
  await store.set(data);
64
64
  },
65
65
  async clear() {
@@ -69,6 +69,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
69
69
  }
70
70
  };
71
71
  }
72
+ exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
72
73
  /**
73
74
  * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
74
75
  * this allows batch read & write operations & improves the performance of the lib
@@ -190,7 +191,13 @@ const initAuthCreds = () => {
190
191
  accountSettings: {
191
192
  unarchiveChats: false
192
193
  },
194
+ // mobile creds
195
+ deviceId: Buffer.from((0, uuid_1.v4)().replace(/-/g, ''), 'hex').toString('base64url'),
196
+ phoneId: (0, uuid_1.v4)(),
197
+ identityId: (0, crypto_1.randomBytes)(20),
193
198
  registered: false,
199
+ backupToken: (0, crypto_1.randomBytes)(20),
200
+ registration: {},
194
201
  pairingCode: undefined,
195
202
  lastPropHash: undefined,
196
203
  routingInfo: undefined,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadingNecessaryImages = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
4
- exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
3
+ exports.uploadingNecessaryImages = exports.uploadingNecessaryImagesOfProduct = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
5
4
  const boom_1 = require("@hapi/boom");
6
5
  const crypto_1 = require("crypto");
7
6
  const WABinary_1 = require("../WABinary");
@@ -189,6 +188,7 @@ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, time
189
188
  };
190
189
  return product;
191
190
  }
191
+ exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
192
192
  /**
193
193
  * Uploads images not already uploaded to WA's servers
194
194
  */
@@ -1,8 +1,9 @@
1
+ /// <reference types="node" />
1
2
  import { AxiosRequestConfig } from 'axios';
3
+ import type { Logger } from 'pino';
2
4
  import { proto } from '../../WAProto';
3
5
  import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
4
6
  import { BinaryNode } from '../WABinary';
5
- import { ILogger } from './logger';
6
7
  type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
7
8
  export type ChatMutationMap = {
8
9
  [index: string]: ChatMutation;
@@ -13,7 +14,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
13
14
  state: LTHashState;
14
15
  }>;
15
16
  export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
16
- hash: Buffer<any>;
17
+ hash: Buffer;
17
18
  indexValueMap: {
18
19
  [indexMacBase64: string]: {
19
20
  valueMac: Uint8Array | Buffer;
@@ -21,7 +22,7 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
21
22
  };
22
23
  }>;
23
24
  export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
24
- hash: Buffer<any>;
25
+ hash: Buffer;
25
26
  indexValueMap: {
26
27
  [indexMacBase64: string]: {
27
28
  valueMac: Uint8Array | Buffer;
@@ -29,42 +30,42 @@ export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchNam
29
30
  };
30
31
  }>;
31
32
  export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
32
- critical_unblock_low: {
33
+ critical_block: {
33
34
  patches: proto.ISyncdPatch[];
34
35
  hasMorePatches: boolean;
35
- snapshot?: proto.ISyncdSnapshot;
36
+ snapshot?: proto.ISyncdSnapshot | undefined;
36
37
  };
37
- regular_high: {
38
+ critical_unblock_low: {
38
39
  patches: proto.ISyncdPatch[];
39
40
  hasMorePatches: boolean;
40
- snapshot?: proto.ISyncdSnapshot;
41
+ snapshot?: proto.ISyncdSnapshot | undefined;
41
42
  };
42
- regular_low: {
43
+ regular_high: {
43
44
  patches: proto.ISyncdPatch[];
44
45
  hasMorePatches: boolean;
45
- snapshot?: proto.ISyncdSnapshot;
46
+ snapshot?: proto.ISyncdSnapshot | undefined;
46
47
  };
47
- critical_block: {
48
+ regular_low: {
48
49
  patches: proto.ISyncdPatch[];
49
50
  hasMorePatches: boolean;
50
- snapshot?: proto.ISyncdSnapshot;
51
+ snapshot?: proto.ISyncdSnapshot | undefined;
51
52
  };
52
53
  regular: {
53
54
  patches: proto.ISyncdPatch[];
54
55
  hasMorePatches: boolean;
55
- snapshot?: proto.ISyncdSnapshot;
56
+ snapshot?: proto.ISyncdSnapshot | undefined;
56
57
  };
57
58
  }>;
58
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer<ArrayBuffer>>;
59
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer>;
59
60
  export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
60
61
  export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
61
62
  state: LTHashState;
62
63
  mutationMap: ChatMutationMap;
63
64
  }>;
64
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: ILogger, validateMacs?: boolean) => Promise<{
65
+ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
65
66
  state: LTHashState;
66
67
  mutationMap: ChatMutationMap;
67
68
  }>;
68
69
  export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
69
- export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
70
+ export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
70
71
  export {};