@d0v3riz/baileys 6.3.0 → 6.4.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 (57) hide show
  1. package/README.md +6 -5
  2. package/WAProto/WAProto.proto +58 -24
  3. package/WAProto/index.d.ts +649 -410
  4. package/WAProto/index.js +1632 -985
  5. package/WASignalGroup/group_cipher.js +38 -24
  6. package/WASignalGroup/queue_job.js +69 -0
  7. package/WASignalGroup/sender_key_record.js +4 -2
  8. package/lib/Defaults/baileys-version.json +1 -1
  9. package/lib/Defaults/index.js +1 -1
  10. package/lib/Socket/Client/abstract-socket-client.d.ts +1 -0
  11. package/lib/Socket/business.d.ts +5 -3
  12. package/lib/Socket/chats.d.ts +6 -5
  13. package/lib/Socket/groups.d.ts +4 -2
  14. package/lib/Socket/groups.js +1 -1
  15. package/lib/Socket/index.d.ts +9 -7
  16. package/lib/Socket/messages-recv.d.ts +6 -3
  17. package/lib/Socket/messages-recv.js +79 -3
  18. package/lib/Socket/messages-send.d.ts +4 -2
  19. package/lib/Socket/messages-send.js +17 -8
  20. package/lib/Socket/registration.d.ts +6 -4
  21. package/lib/Socket/socket.d.ts +4 -3
  22. package/lib/Socket/socket.js +69 -9
  23. package/lib/Store/make-in-memory-store.d.ts +2 -2
  24. package/lib/Types/Auth.d.ts +19 -17
  25. package/lib/Types/Call.d.ts +2 -2
  26. package/lib/Types/Chat.d.ts +13 -13
  27. package/lib/Types/Events.d.ts +3 -3
  28. package/lib/Types/GroupMetadata.d.ts +4 -2
  29. package/lib/Types/LabelAssociation.d.ts +2 -2
  30. package/lib/Types/Message.d.ts +57 -45
  31. package/lib/Types/Product.d.ts +14 -14
  32. package/lib/Types/Signal.d.ts +10 -10
  33. package/lib/Types/Socket.d.ts +5 -4
  34. package/lib/Types/State.d.ts +2 -2
  35. package/lib/Types/index.d.ts +5 -5
  36. package/lib/Utils/auth-utils.js +3 -1
  37. package/lib/Utils/chat-utils.d.ts +4 -4
  38. package/lib/Utils/crypto.d.ts +3 -0
  39. package/lib/Utils/crypto.js +15 -1
  40. package/lib/Utils/event-buffer.d.ts +2 -2
  41. package/lib/Utils/event-buffer.js +3 -3
  42. package/lib/Utils/generics.d.ts +7 -6
  43. package/lib/Utils/generics.js +25 -27
  44. package/lib/Utils/link-preview.d.ts +1 -1
  45. package/lib/Utils/link-preview.js +1 -24
  46. package/lib/Utils/make-mutex.d.ts +1 -1
  47. package/lib/Utils/messages-media.d.ts +9 -3
  48. package/lib/Utils/messages-media.js +54 -6
  49. package/lib/Utils/messages.d.ts +6 -5
  50. package/lib/Utils/messages.js +37 -7
  51. package/lib/Utils/process-message.d.ts +2 -2
  52. package/lib/Utils/validate-connection.js +1 -2
  53. package/lib/WABinary/jid-utils.d.ts +4 -4
  54. package/lib/WABinary/types.d.ts +4 -4
  55. package/lib/index.d.ts +2 -1
  56. package/lib/index.js +2 -0
  57. package/package.json +6 -5
@@ -246,15 +246,17 @@ const makeMessagesSocket = (config) => {
246
246
  }));
247
247
  return { nodes, shouldIncludeDeviceIdentity };
248
248
  };
249
- const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata }) => {
249
+ const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }) => {
250
250
  const meId = authState.creds.me.id;
251
251
  let shouldIncludeDeviceIdentity = false;
252
252
  const { user, server } = (0, WABinary_1.jidDecode)(jid);
253
+ const statusJid = 'status@broadcast';
253
254
  const isGroup = server === 'g.us';
255
+ const isStatus = jid === statusJid;
254
256
  msgId = msgId || (0, Utils_1.generateMessageID)();
255
257
  useUserDevicesCache = useUserDevicesCache !== false;
256
258
  const participants = [];
257
- const destinationJid = (0, WABinary_1.jidEncode)(user, isGroup ? 'g.us' : 's.whatsapp.net');
259
+ const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
258
260
  const binaryNodeContent = [];
259
261
  const devices = [];
260
262
  const meMsg = {
@@ -267,7 +269,7 @@ const makeMessagesSocket = (config) => {
267
269
  // when the retry request is not for a group
268
270
  // only send to the specific device that asked for a retry
269
271
  // otherwise the message is sent out to every device that should be a recipient
270
- if (!isGroup) {
272
+ if (!isGroup && !isStatus) {
271
273
  additionalAttributes = { ...additionalAttributes, 'device_fanout': 'false' };
272
274
  }
273
275
  const { user, device } = (0, WABinary_1.jidDecode)(participant.jid);
@@ -275,20 +277,20 @@ const makeMessagesSocket = (config) => {
275
277
  }
276
278
  await authState.keys.transaction(async () => {
277
279
  const mediaType = getMediaType(message);
278
- if (isGroup) {
280
+ if (isGroup || isStatus) {
279
281
  const [groupData, senderKeyMap] = await Promise.all([
280
282
  (async () => {
281
283
  let groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined;
282
284
  if (groupData) {
283
285
  logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
284
286
  }
285
- if (!groupData) {
287
+ if (!groupData && !isStatus) {
286
288
  groupData = await groupMetadata(jid);
287
289
  }
288
290
  return groupData;
289
291
  })(),
290
292
  (async () => {
291
- if (!participant) {
293
+ if (!participant && !isStatus) {
292
294
  const result = await authState.keys.get('sender-key-memory', [jid]);
293
295
  return result[jid] || {};
294
296
  }
@@ -296,7 +298,10 @@ const makeMessagesSocket = (config) => {
296
298
  })()
297
299
  ]);
298
300
  if (!participant) {
299
- const participantsList = groupData.participants.map(p => p.id);
301
+ const participantsList = (groupData && !isStatus) ? groupData.participants.map(p => p.id) : [];
302
+ if (isStatus && statusJidList) {
303
+ participantsList.push(...statusJidList);
304
+ }
300
305
  const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
301
306
  devices.push(...additionalDevices);
302
307
  }
@@ -623,6 +628,7 @@ const makeMessagesSocket = (config) => {
623
628
  ...options,
624
629
  });
625
630
  const isDeleteMsg = 'delete' in content && !!content.delete;
631
+ const isEditMsg = 'edit' in content && !!content.edit;
626
632
  const additionalAttributes = {};
627
633
  // required for delete
628
634
  if (isDeleteMsg) {
@@ -634,7 +640,10 @@ const makeMessagesSocket = (config) => {
634
640
  additionalAttributes.edit = '7';
635
641
  }
636
642
  }
637
- await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, cachedGroupMetadata: options.cachedGroupMetadata, additionalAttributes });
643
+ else if (isEditMsg) {
644
+ additionalAttributes.edit = '1';
645
+ }
646
+ await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, cachedGroupMetadata: options.cachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList });
638
647
  if (config.emitOwnEvents) {
639
648
  process.nextTick(() => {
640
649
  processingMutex.mutex(() => (upsertMessage(fullMsg, 'append')));
@@ -3,7 +3,7 @@ import { AxiosRequestConfig } from 'axios';
3
3
  import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
4
4
  export declare const makeRegistrationSocket: (config: SocketConfig) => {
5
5
  register: (code: string) => Promise<ExistsResponse>;
6
- requestRegistrationCode: (registrationOptions?: RegistrationOptions | undefined) => Promise<ExistsResponse>;
6
+ requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
7
7
  getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
8
8
  getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
9
9
  products: import("../Types").Product[];
@@ -22,7 +22,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
22
22
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
23
23
  getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
24
24
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
25
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata }: import("../Types").MessageRelayOptions) => Promise<string>;
25
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
26
26
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
27
27
  sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
28
28
  readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
@@ -47,6 +47,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
47
47
  groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
48
48
  status: string;
49
49
  jid: string;
50
+ content: import("../WABinary").BinaryNode;
50
51
  }[]>;
51
52
  groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
52
53
  groupInviteCode: (jid: string) => Promise<string | undefined>;
@@ -97,7 +98,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
97
98
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
98
99
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
99
100
  type: "md";
100
- ws: import("./Client").MobileSocketClient | import("./Client").WebSocketClient;
101
+ ws: import("./Client/mobile-socket-client").MobileSocketClient | import("./Client/web-socket-client").WebSocketClient;
101
102
  ev: import("../Types").BaileysEventEmitter & {
102
103
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
103
104
  buffer(): void;
@@ -122,6 +123,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
122
123
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
123
124
  uploadPreKeys: (count?: number) => Promise<void>;
124
125
  uploadPreKeysToServerIfRequired: () => Promise<void>;
126
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
125
127
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
126
128
  };
127
129
  export interface RegistrationData {
@@ -154,7 +156,7 @@ export interface RegistrationOptions {
154
156
  */
155
157
  method?: 'sms' | 'voice';
156
158
  }
157
- export declare type RegistrationParams = RegistrationData & RegistrationOptions;
159
+ export type RegistrationParams = RegistrationData & RegistrationOptions;
158
160
  export declare function registrationParams(params: RegistrationParams): {
159
161
  cc: string;
160
162
  in: string;
@@ -26,17 +26,18 @@ export declare const makeSocket: (config: SocketConfig) => {
26
26
  signalRepository: import("../Types").SignalRepository;
27
27
  readonly user: import("../Types").Contact | undefined;
28
28
  generateMessageTag: () => string;
29
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
29
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
30
30
  waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
31
31
  waitForSocketOpen: () => Promise<void>;
32
32
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
33
33
  sendNode: (frame: BinaryNode) => Promise<void>;
34
- logout: (msg?: string | undefined) => Promise<void>;
34
+ logout: (msg?: string) => Promise<void>;
35
35
  end: (error: Error | undefined) => void;
36
36
  onUnexpectedError: (err: Error | Boom, msg: string) => void;
37
37
  uploadPreKeys: (count?: number) => Promise<void>;
38
38
  uploadPreKeysToServerIfRequired: () => Promise<void>;
39
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
39
40
  /** Waits for the connection to WA to reach a state */
40
41
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
41
42
  };
42
- export declare type Socket = ReturnType<typeof makeSocket>;
43
+ export type Socket = ReturnType<typeof makeSocket>;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeSocket = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
4
  const boom_1 = require("@hapi/boom");
5
+ const crypto_1 = require("crypto");
6
6
  const url_1 = require("url");
7
7
  const util_1 = require("util");
8
8
  const WAProto_1 = require("../../WAProto");
9
9
  const Defaults_1 = require("../Defaults");
10
10
  const Types_1 = require("../Types");
11
11
  const Utils_1 = require("../Utils");
12
- const event_buffer_1 = require("../Utils/event-buffer");
13
12
  const WABinary_1 = require("../WABinary");
14
13
  const Client_1 = require("./Client");
15
14
  /**
@@ -19,16 +18,15 @@ const Client_1 = require("./Client");
19
18
  * - query phone connection
20
19
  */
21
20
  const makeSocket = (config) => {
22
- var _a, _b;
23
21
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
24
22
  let url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
25
- config.mobile = config.mobile || ((_b = (_a = config.auth) === null || _a === void 0 ? void 0 : _a.creds) === null || _b === void 0 ? void 0 : _b.registered) || url.protocol === 'tcp:';
23
+ config.mobile = config.mobile || url.protocol === 'tcp:';
26
24
  if (config.mobile && url.protocol !== 'tcp:') {
27
25
  url = new url_1.URL(`tcp://${Defaults_1.MOBILE_ENDPOINT}:${Defaults_1.MOBILE_PORT}`);
28
26
  }
29
27
  const ws = config.mobile ? new Client_1.MobileSocketClient(url, config) : new Client_1.WebSocketClient(url, config);
30
28
  ws.connect();
31
- const ev = (0, event_buffer_1.makeEventBuffer)(logger);
29
+ const ev = (0, Utils_1.makeEventBuffer)(logger);
32
30
  /** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
33
31
  const ephemeralKeyPair = Utils_1.Curve.generateKeyPair();
34
32
  /** WA noise protocol wrapper */
@@ -106,15 +104,14 @@ const makeSocket = (config) => {
106
104
  };
107
105
  /**
108
106
  * Wait for a message with a certain tag to be received
109
- * @param tag the message tag to await
110
- * @param json query that was sent
107
+ * @param msgId the message tag to await
111
108
  * @param timeoutMs timeout after which the promise will reject
112
109
  */
113
110
  const waitForMessage = async (msgId, timeoutMs = defaultQueryTimeoutMs) => {
114
111
  let onRecv;
115
112
  let onErr;
116
113
  try {
117
- const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
114
+ return await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
118
115
  onRecv = resolve;
119
116
  onErr = err => {
120
117
  reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
@@ -123,7 +120,6 @@ const makeSocket = (config) => {
123
120
  ws.on('close', onErr); // if the socket closes, you'll never receive the message
124
121
  ws.off('error', onErr);
125
122
  });
126
- return result;
127
123
  }
128
124
  finally {
129
125
  ws.off(`TAG:${msgId}`, onRecv);
@@ -364,6 +360,69 @@ const makeSocket = (config) => {
364
360
  }
365
361
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
366
362
  };
363
+ const requestPairingCode = async (phoneNumber) => {
364
+ authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
365
+ authState.creds.me = {
366
+ id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
367
+ name: '~'
368
+ };
369
+ ev.emit('creds.update', authState.creds);
370
+ await sendNode({
371
+ tag: 'iq',
372
+ attrs: {
373
+ to: WABinary_1.S_WHATSAPP_NET,
374
+ type: 'set',
375
+ id: generateMessageTag(),
376
+ xmlns: 'md'
377
+ },
378
+ content: [
379
+ {
380
+ tag: 'link_code_companion_reg',
381
+ attrs: {
382
+ jid: authState.creds.me.id,
383
+ stage: 'companion_hello',
384
+ // eslint-disable-next-line camelcase
385
+ should_show_push_notification: 'true'
386
+ },
387
+ content: [
388
+ {
389
+ tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
390
+ attrs: {},
391
+ content: await generatePairingKey()
392
+ },
393
+ {
394
+ tag: 'companion_server_auth_key_pub',
395
+ attrs: {},
396
+ content: authState.creds.noiseKey.public
397
+ },
398
+ {
399
+ tag: 'companion_platform_id',
400
+ attrs: {},
401
+ content: '49' // Chrome
402
+ },
403
+ {
404
+ tag: 'companion_platform_display',
405
+ attrs: {},
406
+ content: config.browser[0]
407
+ },
408
+ {
409
+ tag: 'link_code_pairing_nonce',
410
+ attrs: {},
411
+ content: '0'
412
+ }
413
+ ]
414
+ }
415
+ ]
416
+ });
417
+ return authState.creds.pairingCode;
418
+ };
419
+ async function generatePairingKey() {
420
+ const salt = (0, crypto_1.randomBytes)(32);
421
+ const randomIv = (0, crypto_1.randomBytes)(16);
422
+ const key = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
423
+ const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
424
+ return Buffer.concat([salt, randomIv, ciphered]);
425
+ }
367
426
  ws.on('message', onMessageRecieved);
368
427
  ws.on('open', async () => {
369
428
  try {
@@ -511,6 +570,7 @@ const makeSocket = (config) => {
511
570
  onUnexpectedError,
512
571
  uploadPreKeys,
513
572
  uploadPreKeysToServerIfRequired,
573
+ requestPairingCode,
514
574
  /** Waits for the connection to WA to reach a state */
515
575
  waitForConnectionUpdate: (0, Utils_1.bindWaitForConnectionUpdate)(ev),
516
576
  };
@@ -7,14 +7,14 @@ import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata
7
7
  import { Label } from '../Types/Label';
8
8
  import { LabelAssociation } from '../Types/LabelAssociation';
9
9
  import { ObjectRepository } from './object-repository';
10
- declare type WASocket = ReturnType<typeof makeMDSocket>;
10
+ type WASocket = ReturnType<typeof makeMDSocket>;
11
11
  export declare const waChatKey: (pin: boolean) => {
12
12
  key: (c: Chat) => string;
13
13
  compare: (k1: string, k2: string) => number;
14
14
  };
15
15
  export declare const waMessageID: (m: WAMessage) => string;
16
16
  export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>;
17
- export declare type BaileysInMemoryStoreConfig = {
17
+ export type BaileysInMemoryStoreConfig = {
18
18
  chatKey?: Comparable<Chat, string>;
19
19
  labelAssociationKey?: Comparable<LabelAssociation, string>;
20
20
  logger?: Logger;
@@ -3,25 +3,25 @@ import type { proto } from '../../WAProto';
3
3
  import { RegistrationOptions } from '../Socket/registration';
4
4
  import type { Contact } from './Contact';
5
5
  import type { MinimalMessage } from './Message';
6
- export declare type KeyPair = {
6
+ export type KeyPair = {
7
7
  public: Uint8Array;
8
8
  private: Uint8Array;
9
9
  };
10
- export declare type SignedKeyPair = {
10
+ export type SignedKeyPair = {
11
11
  keyPair: KeyPair;
12
12
  signature: Uint8Array;
13
13
  keyId: number;
14
14
  timestampS?: number;
15
15
  };
16
- export declare type ProtocolAddress = {
16
+ export type ProtocolAddress = {
17
17
  name: string;
18
18
  deviceId: number;
19
19
  };
20
- export declare type SignalIdentity = {
20
+ export type SignalIdentity = {
21
21
  identifier: ProtocolAddress;
22
22
  identifierKey: Uint8Array;
23
23
  };
24
- export declare type LTHashState = {
24
+ export type LTHashState = {
25
25
  version: number;
26
26
  hash: Buffer;
27
27
  indexValueMap: {
@@ -30,20 +30,21 @@ export declare type LTHashState = {
30
30
  };
31
31
  };
32
32
  };
33
- export declare type SignalCreds = {
33
+ export type SignalCreds = {
34
34
  readonly signedIdentityKey: KeyPair;
35
35
  readonly signedPreKey: SignedKeyPair;
36
36
  readonly registrationId: number;
37
37
  };
38
- export declare type AccountSettings = {
38
+ export type AccountSettings = {
39
39
  /** unarchive chats when a new message is received */
40
40
  unarchiveChats: boolean;
41
41
  /** the default mode to start new conversations with */
42
42
  defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
43
43
  };
44
- export declare type AuthenticationCreds = SignalCreds & {
44
+ export type AuthenticationCreds = SignalCreds & {
45
45
  readonly noiseKey: KeyPair;
46
- readonly advSecretKey: string;
46
+ readonly pairingEphemeralKeyPair: KeyPair;
47
+ advSecretKey: string;
47
48
  me?: Contact;
48
49
  account?: proto.IADVSignedDeviceIdentity;
49
50
  signalIdentities?: SignalIdentity[];
@@ -62,8 +63,9 @@ export declare type AuthenticationCreds = SignalCreds & {
62
63
  registered: boolean;
63
64
  backupToken: Buffer;
64
65
  registration: RegistrationOptions;
66
+ pairingCode: string | undefined;
65
67
  };
66
- export declare type SignalDataTypeMap = {
68
+ export type SignalDataTypeMap = {
67
69
  'pre-key': KeyPair;
68
70
  'session': Uint8Array;
69
71
  'sender-key': Uint8Array;
@@ -73,13 +75,13 @@ export declare type SignalDataTypeMap = {
73
75
  'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
74
76
  'app-state-sync-version': LTHashState;
75
77
  };
76
- export declare type SignalDataSet = {
78
+ export type SignalDataSet = {
77
79
  [T in keyof SignalDataTypeMap]?: {
78
80
  [id: string]: SignalDataTypeMap[T] | null;
79
81
  };
80
82
  };
81
- declare type Awaitable<T> = T | Promise<T>;
82
- export declare type SignalKeyStore = {
83
+ type Awaitable<T> = T | Promise<T>;
84
+ export type SignalKeyStore = {
83
85
  get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
84
86
  [id: string]: SignalDataTypeMap[T];
85
87
  }>;
@@ -87,19 +89,19 @@ export declare type SignalKeyStore = {
87
89
  /** clear all the data in the store */
88
90
  clear?(): Awaitable<void>;
89
91
  };
90
- export declare type SignalKeyStoreWithTransaction = SignalKeyStore & {
92
+ export type SignalKeyStoreWithTransaction = SignalKeyStore & {
91
93
  isInTransaction: () => boolean;
92
94
  transaction<T>(exec: () => Promise<T>): Promise<T>;
93
95
  };
94
- export declare type TransactionCapabilityOptions = {
96
+ export type TransactionCapabilityOptions = {
95
97
  maxCommitRetries: number;
96
98
  delayBetweenTriesMs: number;
97
99
  };
98
- export declare type SignalAuthState = {
100
+ export type SignalAuthState = {
99
101
  creds: SignalCreds;
100
102
  keys: SignalKeyStore | SignalKeyStoreWithTransaction;
101
103
  };
102
- export declare type AuthenticationState = {
104
+ export type AuthenticationState = {
103
105
  creds: AuthenticationCreds;
104
106
  keys: SignalKeyStore;
105
107
  };
@@ -1,5 +1,5 @@
1
- export declare type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
2
- export declare type WACallEvent = {
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
2
+ export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
5
5
  isGroup?: boolean;
@@ -5,33 +5,33 @@ import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
5
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
6
  import type { MinimalMessage } from './Message';
7
7
  /** privacy settings in WhatsApp Web */
8
- export declare type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
- export declare type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
10
- export declare type WAReadReceiptsValue = 'all' | 'none';
8
+ export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
+ export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
10
+ export type WAReadReceiptsValue = 'all' | 'none';
11
11
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
- export declare type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
12
+ export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
13
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
14
- export declare type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
14
+ export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
15
15
  export interface PresenceData {
16
16
  lastKnownPresence: WAPresence;
17
17
  lastSeen?: number;
18
18
  }
19
- export declare type ChatMutation = {
19
+ export type ChatMutation = {
20
20
  syncAction: proto.ISyncActionData;
21
21
  index: string[];
22
22
  };
23
- export declare type WAPatchCreate = {
23
+ export type WAPatchCreate = {
24
24
  syncAction: proto.ISyncActionValue;
25
25
  index: string[];
26
26
  type: WAPatchName;
27
27
  apiVersion: number;
28
28
  operation: proto.SyncdMutation.SyncdOperation;
29
29
  };
30
- export declare type Chat = proto.IConversation & {
30
+ export type Chat = proto.IConversation & {
31
31
  /** unix timestamp of when the last message was received in the chat */
32
32
  lastMessageRecvTimestamp?: number;
33
33
  };
34
- export declare type ChatUpdate = Partial<Chat & {
34
+ export type ChatUpdate = Partial<Chat & {
35
35
  /**
36
36
  * if specified in the update,
37
37
  * the EV buffer will check if the condition gets fulfilled before applying the update
@@ -47,8 +47,8 @@ export declare type ChatUpdate = Partial<Chat & {
47
47
  * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
48
48
  * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
49
49
  * */
50
- export declare type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
51
- export declare type ChatModification = {
50
+ export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
51
+ export type ChatModification = {
52
52
  archive: boolean;
53
53
  lastMessages: LastMessageList;
54
54
  } | {
@@ -89,7 +89,7 @@ export declare type ChatModification = {
89
89
  } | {
90
90
  removeMessageLabel: MessageLabelAssociationActionBody;
91
91
  };
92
- export declare type InitialReceivedChatsState = {
92
+ export type InitialReceivedChatsState = {
93
93
  [jid: string]: {
94
94
  /** the last message received from the other party */
95
95
  lastMsgRecvTimestamp?: number;
@@ -97,6 +97,6 @@ export declare type InitialReceivedChatsState = {
97
97
  lastMsgTimestamp: number;
98
98
  };
99
99
  };
100
- export declare type InitialAppStateSyncOptions = {
100
+ export type InitialAppStateSyncOptions = {
101
101
  accountSettings: AccountSettings;
102
102
  };
@@ -9,7 +9,7 @@ import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
11
  import { ConnectionState } from './State';
12
- export declare type BaileysEventMap = {
12
+ export type BaileysEventMap = {
13
13
  /** connection state has been updated -- WS closed, opened, connecting etc. */
14
14
  'connection.update': Partial<ConnectionState>;
15
15
  /** credentials updated -- some metadata, keys or something */
@@ -88,7 +88,7 @@ export declare type BaileysEventMap = {
88
88
  type: 'add' | 'remove';
89
89
  };
90
90
  };
91
- export declare type BufferedEventData = {
91
+ export type BufferedEventData = {
92
92
  historySets: {
93
93
  chats: {
94
94
  [jid: string]: Chat;
@@ -143,7 +143,7 @@ export declare type BufferedEventData = {
143
143
  [jid: string]: Partial<GroupMetadata>;
144
144
  };
145
145
  };
146
- export declare type BaileysEvent = keyof BaileysEventMap;
146
+ export type BaileysEvent = keyof BaileysEventMap;
147
147
  export interface BaileysEventEmitter {
148
148
  on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
149
149
  off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
@@ -1,10 +1,10 @@
1
1
  import { Contact } from './Contact';
2
- export declare type GroupParticipant = (Contact & {
2
+ export type GroupParticipant = (Contact & {
3
3
  isAdmin?: boolean;
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
6
  });
7
- export declare type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
8
8
  export interface GroupMetadata {
9
9
  id: string;
10
10
  owner: string | undefined;
@@ -26,6 +26,8 @@ export interface GroupMetadata {
26
26
  participants: GroupParticipant[];
27
27
  ephemeralDuration?: number;
28
28
  inviteCode?: string;
29
+ /** the person who added you */
30
+ author?: string;
29
31
  }
30
32
  export interface WAGroupCreateResponse {
31
33
  status: number;
@@ -3,7 +3,7 @@ export declare enum LabelAssociationType {
3
3
  Chat = "label_jid",
4
4
  Message = "label_message"
5
5
  }
6
- export declare type LabelAssociationTypes = `${LabelAssociationType}`;
6
+ export type LabelAssociationTypes = `${LabelAssociationType}`;
7
7
  /** Association for chat */
8
8
  export interface ChatLabelAssociation {
9
9
  type: LabelAssociationType.Chat;
@@ -17,7 +17,7 @@ export interface MessageLabelAssociation {
17
17
  messageId: string;
18
18
  labelId: string;
19
19
  }
20
- export declare type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation;
20
+ export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation;
21
21
  /** Body for add/remove chat label association action */
22
22
  export interface ChatLabelAssociationActionBody {
23
23
  labelId: string;