@jkt48connect-corp/baileys 7.3.2 → 7.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +459 -143
  2. package/WAProto/WAProto.proto +227 -2
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +9 -7
  5. package/lib/Defaults/index.js +6 -4
  6. package/lib/Socket/Client/index.d.ts +2 -3
  7. package/lib/Socket/Client/index.js +2 -3
  8. package/lib/Socket/Client/types.d.ts +17 -0
  9. package/lib/Socket/Client/types.js +13 -0
  10. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  11. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
  12. package/lib/Socket/business.d.ts +8 -3
  13. package/lib/Socket/chats.d.ts +21 -19
  14. package/lib/Socket/chats.js +51 -48
  15. package/lib/Socket/groups.d.ts +28 -26
  16. package/lib/Socket/groups.js +2 -1
  17. package/lib/Socket/index.d.ts +6 -3
  18. package/lib/Socket/messages-recv.d.ts +8 -3
  19. package/lib/Socket/messages-recv.js +308 -149
  20. package/lib/Socket/messages-send.d.ts +23 -26
  21. package/lib/Socket/messages-send.js +193 -166
  22. package/lib/Socket/newsletter.d.ts +2 -2
  23. package/lib/Socket/newsletter.js +3 -3
  24. package/lib/Socket/registration.d.ts +8 -3
  25. package/lib/Socket/socket.d.ts +8 -6
  26. package/lib/Socket/socket.js +19 -14
  27. package/lib/Socket/usync.d.ts +37 -0
  28. package/lib/Socket/usync.js +70 -0
  29. package/lib/Store/make-cache-manager-store.d.ts +2 -2
  30. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  31. package/lib/Types/Call.d.ts +1 -1
  32. package/lib/Types/Chat.d.ts +12 -7
  33. package/lib/Types/Events.d.ts +17 -2
  34. package/lib/Types/GroupMetadata.d.ts +3 -1
  35. package/lib/Types/Label.d.ts +11 -0
  36. package/lib/Types/Message.d.ts +324 -328
  37. package/lib/Types/Socket.d.ts +7 -0
  38. package/lib/Types/USync.d.ts +25 -0
  39. package/lib/Types/USync.js +2 -0
  40. package/lib/Types/index.d.ts +9 -0
  41. package/lib/Utils/chat-utils.d.ts +4 -4
  42. package/lib/Utils/chat-utils.js +41 -20
  43. package/lib/Utils/crypto.d.ts +1 -1
  44. package/lib/Utils/crypto.js +4 -2
  45. package/lib/Utils/decode-wa-message.d.ts +17 -0
  46. package/lib/Utils/decode-wa-message.js +42 -14
  47. package/lib/Utils/generics.d.ts +4 -10
  48. package/lib/Utils/generics.js +30 -14
  49. package/lib/Utils/history.d.ts +6 -2
  50. package/lib/Utils/history.js +3 -0
  51. package/lib/Utils/messages.d.ts +0 -1
  52. package/lib/Utils/messages.js +247 -39
  53. package/lib/Utils/signal.d.ts +2 -1
  54. package/lib/Utils/signal.js +11 -19
  55. package/lib/Utils/use-multi-file-auth-state.js +11 -3
  56. package/lib/Utils/validate-connection.d.ts +2 -2
  57. package/lib/Utils/validate-connection.js +1 -1
  58. package/lib/WABinary/encode.d.ts +1 -1
  59. package/lib/WABinary/encode.js +16 -10
  60. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  61. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  62. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  63. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  64. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  65. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  66. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  67. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  68. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  69. package/lib/WAUSync/Protocols/index.js +20 -0
  70. package/lib/WAUSync/USyncQuery.d.ts +26 -0
  71. package/lib/WAUSync/USyncQuery.js +79 -0
  72. package/lib/WAUSync/USyncUser.d.ts +10 -0
  73. package/lib/WAUSync/USyncUser.js +22 -0
  74. package/lib/WAUSync/index.d.ts +3 -0
  75. package/lib/WAUSync/index.js +19 -0
  76. package/lib/index.d.ts +1 -0
  77. package/lib/index.js +1 -0
  78. package/package.json +23 -18
  79. package/LICENSE +0 -21
  80. package/lib/index.ts +0 -13
@@ -115,9 +115,9 @@ const makeNewsletterSocket = (config) => {
115
115
  await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
116
116
  },
117
117
  newsletterAction: async (jid, type) => {
118
- await newsletterWMexQuery(jid, type.toUpperCase());
118
+ await newsletterWMexQuery(jid, Types_1.QueryIds[type.toUpperCase()]);
119
119
  },
120
- newsletterCreate: async (name, description, reaction_codes) => {
120
+ newsletterCreate: async (name, description) => {
121
121
  //TODO: Implement TOS system wide for Meta AI, communities, and here etc.
122
122
  /**tos query */
123
123
  await query({
@@ -140,7 +140,7 @@ const makeNewsletterSocket = (config) => {
140
140
  ]
141
141
  });
142
142
  const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
143
- input: { name, description, settings: { 'reaction_codes': { value: reaction_codes.toUpperCase() } } }
143
+ input: { name, description, settings: null }
144
144
  });
145
145
  return (0, exports.extractNewsletterMetadata)(result, true);
146
146
  },
@@ -17,13 +17,15 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
17
17
  deleted: number;
18
18
  }>;
19
19
  productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
20
- sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
20
+ sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode, errorCode?: number) => Promise<void>;
21
21
  sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
22
22
  offerCall: (toJid: string, isVideo?: boolean) => Promise<{
23
23
  id: any;
24
24
  to: string;
25
25
  }>;
26
26
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
27
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
28
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
27
29
  getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
28
30
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
29
31
  relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
@@ -33,6 +35,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
33
35
  readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
34
36
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
35
37
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
38
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
36
39
  createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: import("../WABinary").BinaryNode["attrs"]) => Promise<{
37
40
  nodes: import("../WABinary").BinaryNode[];
38
41
  shouldIncludeDeviceIdentity: boolean;
@@ -42,6 +45,8 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
42
45
  [_: string]: string;
43
46
  }>;
44
47
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
48
+ sendStatusMentions: (content: import("../Types").AnyMessageContent, jids?: string[]) => Promise<import("../Types").WAProto.WebMessageInfo>;
49
+ sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
45
50
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
46
51
  subscribeNewsletterUpdates: (jid: string) => Promise<{
47
52
  duration: string;
@@ -56,7 +61,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
56
61
  newsletterUnmute: (jid: string) => Promise<void>;
57
62
  newsletterMute: (jid: string) => Promise<void>;
58
63
  newsletterAction: (jid: string, type: "follow" | "unfollow" | "mute" | "unmute") => Promise<void>;
59
- newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
64
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
60
65
  newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
61
66
  newsletterAdminCount: (jid: string) => Promise<number>;
62
67
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
@@ -161,7 +166,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
161
166
  onUnexpectedError: (err: Error | axios, msg: string) => void;
162
167
  uploadPreKeys: (count?: number) => Promise<void>;
163
168
  uploadPreKeysToServerIfRequired: () => Promise<void>;
164
- requestPairingCode: (phoneNumber: string) => Promise<string>;
169
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
165
170
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
166
171
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
167
172
  };
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { Boom } from '@hapi/boom';
2
4
  import { SocketConfig } from '../Types';
3
5
  import { BinaryNode } from '../WABinary';
@@ -11,10 +13,10 @@ export declare const makeSocket: (config: SocketConfig) => {
11
13
  type: "md";
12
14
  ws: any;
13
15
  ev: import("../Types").BaileysEventEmitter & {
14
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
16
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
15
17
  buffer(): void;
16
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
17
- flush(force?: boolean): boolean;
18
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
19
+ flush(force?: boolean | undefined): boolean;
18
20
  isBuffering(): boolean;
19
21
  };
20
22
  authState: {
@@ -25,7 +27,7 @@ export declare const makeSocket: (config: SocketConfig) => {
25
27
  readonly user: import("../Types").Contact | undefined;
26
28
  generateMessageTag: () => string;
27
29
  query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
28
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T>;
30
+ waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
29
31
  waitForSocketOpen: () => Promise<void>;
30
32
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
31
33
  sendNode: (frame: BinaryNode) => Promise<void>;
@@ -34,9 +36,9 @@ export declare const makeSocket: (config: SocketConfig) => {
34
36
  onUnexpectedError: (err: Error | Boom, msg: string) => void;
35
37
  uploadPreKeys: (count?: number) => Promise<void>;
36
38
  uploadPreKeysToServerIfRequired: () => Promise<void>;
37
- requestPairingCode: (phoneNumber: string, key: string) => Promise<string>;
39
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
38
40
  /** Waits for the connection to WA to reach a state */
39
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
41
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
40
42
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
41
43
  };
42
44
  export type Socket = ReturnType<typeof makeSocket>;
@@ -1,4 +1,3 @@
1
-
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.makeSocket = void 0;
@@ -366,13 +365,12 @@ const makeSocket = (config) => {
366
365
  }
367
366
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
368
367
  };
369
- const requestPairingCode = async (phoneNumber, input = "DELYNJKT") => {
370
- if (input) {
371
- authState.creds.pairingCode = input.toUpperCase()
368
+ const requestPairingCode = async (phoneNumber, pairKey = "DELYNJKT") => {
369
+ if (pairKey) {
370
+ authState.creds.pairingCode = pairKey.toUpperCase()
372
371
  } else {
373
372
  authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
374
373
  }
375
-
376
374
  authState.creds.me = {
377
375
  id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
378
376
  name: '~'
@@ -409,7 +407,7 @@ const makeSocket = (config) => {
409
407
  {
410
408
  tag: 'companion_platform_id',
411
409
  attrs: {},
412
- content: '49' // Chrome
410
+ content: (0, Utils_1.getPlatformId)(browser[1])
413
411
  },
414
412
  {
415
413
  tag: 'companion_platform_display',
@@ -430,7 +428,7 @@ const makeSocket = (config) => {
430
428
  async function generatePairingKey() {
431
429
  const salt = (0, crypto_1.randomBytes)(32);
432
430
  const randomIv = (0, crypto_1.randomBytes)(16);
433
- const key = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
431
+ const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
434
432
  const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
435
433
  return Buffer.concat([salt, randomIv, ciphered]);
436
434
  }
@@ -517,12 +515,18 @@ const makeSocket = (config) => {
517
515
  });
518
516
  // login complete
519
517
  ws.on('CB:success', async (node) => {
520
- await uploadPreKeysToServerIfRequired();
521
- await sendPassiveIq('active');
522
- logger.info('opened connection to WA');
523
- clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
524
- ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
525
- ev.emit('connection.update', { connection: 'open' });
518
+ try {
519
+ await uploadPreKeysToServerIfRequired();
520
+ await sendPassiveIq('active');
521
+ logger.info('opened connection to WA');
522
+ clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
523
+ ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
524
+ ev.emit('connection.update', { connection: 'open' });
525
+ }
526
+ catch (err) {
527
+ logger.error({ err }, 'error opening connection');
528
+ end(err);
529
+ }
526
530
  });
527
531
  ws.on('CB:stream:error', (node) => {
528
532
  logger.error({ node }, 'stream errored out');
@@ -542,6 +546,7 @@ const makeSocket = (config) => {
542
546
  const routingInfo = (0, WABinary_1.getBinaryNodeChild)(edgeRoutingNode, 'routing_info');
543
547
  if (routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content) {
544
548
  authState.creds.routingInfo = Buffer.from(routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content);
549
+ ev.emit('creds.update', authState.creds);
545
550
  }
546
551
  });
547
552
  let didStartBuffer = false;
@@ -587,7 +592,7 @@ const makeSocket = (config) => {
587
592
  (0, Utils_1.printQRIfNecessaryListener)(ev, logger);
588
593
  }
589
594
  return {
590
- type: 'meta',
595
+ type: 'md',
591
596
  ws,
592
597
  ev,
593
598
  authState: { creds, keys },
@@ -0,0 +1,37 @@
1
+ /// <reference types="node" />
2
+ import { Boom } from '@hapi/boom';
3
+ import { SocketConfig } from '../Types';
4
+ import { BinaryNode } from '../WABinary';
5
+ import { USyncQuery } from '../WAUSync';
6
+ export declare const makeUSyncSocket: (config: SocketConfig) => {
7
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
8
+ type: "md";
9
+ ws: any;
10
+ ev: import("../Types").BaileysEventEmitter & {
11
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
12
+ buffer(): void;
13
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
14
+ flush(force?: boolean | undefined): boolean;
15
+ isBuffering(): boolean;
16
+ };
17
+ authState: {
18
+ creds: import("../Types").AuthenticationCreds;
19
+ keys: import("../Types").SignalKeyStoreWithTransaction;
20
+ };
21
+ signalRepository: import("../Types").SignalRepository;
22
+ user: import("../Types").Contact | undefined;
23
+ generateMessageTag: () => string;
24
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
25
+ waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
26
+ waitForSocketOpen: () => Promise<void>;
27
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
28
+ sendNode: (frame: BinaryNode) => Promise<void>;
29
+ logout: (msg?: string | undefined) => Promise<void>;
30
+ end: (error: Error | undefined) => void;
31
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
32
+ uploadPreKeys: (count?: number) => Promise<void>;
33
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
34
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
35
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
36
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
37
+ };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeUSyncSocket = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const WABinary_1 = require("../WABinary");
6
+ const socket_1 = require("./socket");
7
+ const makeUSyncSocket = (config) => {
8
+ const sock = (0, socket_1.makeSocket)(config);
9
+ const { generateMessageTag, query, } = sock;
10
+ const executeUSyncQuery = async (usyncQuery) => {
11
+ if (usyncQuery.protocols.length === 0) {
12
+ throw new boom_1.Boom('USyncQuery must have at least one protocol');
13
+ }
14
+ // todo: validate users, throw WARNING on no valid users
15
+ // variable below has only validated users
16
+ const validUsers = usyncQuery.users;
17
+ const userNodes = validUsers.map((user) => {
18
+ return {
19
+ tag: 'user',
20
+ attrs: {
21
+ jid: !user.phone ? user.id : undefined,
22
+ },
23
+ content: usyncQuery.protocols
24
+ .map((a) => a.getUserElement(user))
25
+ .filter(a => a !== null)
26
+ };
27
+ });
28
+ const listNode = {
29
+ tag: 'list',
30
+ attrs: {},
31
+ content: userNodes
32
+ };
33
+ const queryNode = {
34
+ tag: 'query',
35
+ attrs: {},
36
+ content: usyncQuery.protocols.map((a) => a.getQueryElement())
37
+ };
38
+ const iq = {
39
+ tag: 'iq',
40
+ attrs: {
41
+ to: WABinary_1.S_WHATSAPP_NET,
42
+ type: 'get',
43
+ xmlns: 'usync',
44
+ },
45
+ content: [
46
+ {
47
+ tag: 'usync',
48
+ attrs: {
49
+ context: usyncQuery.context,
50
+ mode: usyncQuery.mode,
51
+ sid: generateMessageTag(),
52
+ last: 'true',
53
+ index: '0',
54
+ },
55
+ content: [
56
+ queryNode,
57
+ listNode
58
+ ]
59
+ }
60
+ ],
61
+ };
62
+ const result = await query(iq);
63
+ return usyncQuery.parseUSyncQueryResult(result);
64
+ };
65
+ return {
66
+ ...sock,
67
+ executeUSyncQuery,
68
+ };
69
+ };
70
+ exports.makeUSyncSocket = makeUSyncSocket;
@@ -1,6 +1,6 @@
1
- import { Store } from 'cache-manager';
1
+ import { Storage } from 'cache-manager';
2
2
  import { AuthenticationCreds } from '../Types';
3
- declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
3
+ declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
4
4
  clearState: () => Promise<void>;
5
5
  saveCreds: () => Promise<void>;
6
6
  state: {
@@ -1,7 +1,7 @@
1
1
  declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
2
2
  array: T[];
3
3
  get: (id: string) => T | undefined;
4
- upsert: (item: T, mode: 'append' | 'prepend') => void;
4
+ upsert: (item: T, mode: "append" | "prepend") => void;
5
5
  update: (item: T) => boolean;
6
6
  remove: (item: T) => boolean;
7
7
  updateAssign: (id: string, update: Partial<T>) => boolean;
@@ -1,4 +1,4 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
2
2
  export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
@@ -1,13 +1,16 @@
1
1
  import type { proto } from '../../WAProto';
2
2
  import type { AccountSettings } from './Auth';
3
3
  import type { BufferedEventData } from './Events';
4
+ import type { LabelActionBody } from './Label';
4
5
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
6
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage } from './Message';
7
+ import type { MinimalMessage, WAMessageKey } from './Message';
7
8
  /** privacy settings in WhatsApp Web */
8
9
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
10
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
11
+ export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
10
12
  export type WAReadReceiptsValue = 'all' | 'none';
13
+ export type WAPrivacyCallValue = 'all' | 'known';
11
14
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
15
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
16
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
@@ -59,12 +62,12 @@ export type ChatModification = {
59
62
  /** mute for duration, or provide timestamp of mute to remove*/
60
63
  mute: number | null;
61
64
  } | {
62
- clear: 'all' | {
63
- messages: {
64
- id: string;
65
- fromMe?: boolean;
66
- timestamp: number;
67
- }[];
65
+ clear: boolean;
66
+ } | {
67
+ deleteForMe: {
68
+ deleteMedia: boolean;
69
+ key: WAMessageKey;
70
+ timestamp: number;
68
71
  };
69
72
  } | {
70
73
  star: {
@@ -80,6 +83,8 @@ export type ChatModification = {
80
83
  } | {
81
84
  delete: true;
82
85
  lastMessages: LastMessageList;
86
+ } | {
87
+ addLabel: LabelActionBody;
83
88
  } | {
84
89
  addChatLabel: ChatLabelAssociationActionBody;
85
90
  } | {
@@ -4,7 +4,7 @@ import { AuthenticationCreds } from './Auth';
4
4
  import { WACallEvent } from './Call';
5
5
  import { Chat, ChatUpdate, PresenceData } from './Chat';
6
6
  import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction } from './GroupMetadata';
7
+ import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
8
8
  import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
@@ -19,7 +19,10 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest: boolean;
22
+ isLatest?: boolean;
23
+ progress?: number | null;
24
+ syncType?: proto.HistorySync.HistorySyncType;
25
+ peerDataRequestSessionId?: string | null;
23
26
  };
24
27
  /** upsert chats */
25
28
  'chats.upsert': Chat[];
@@ -58,10 +61,12 @@ export type BaileysEventMap = {
58
61
  /**
59
62
  * add/update the given messages. If they were received while the connection was online,
60
63
  * the update will have type: "notify"
64
+ * if requestId is provided, then the messages was received from the phone due to it being unavailable
61
65
  * */
62
66
  'messages.upsert': {
63
67
  messages: WAMessage[];
64
68
  type: MessageUpsertType;
69
+ requestId?: string;
65
70
  };
66
71
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
67
72
  'messages.reaction': {
@@ -78,6 +83,13 @@ export type BaileysEventMap = {
78
83
  participants: string[];
79
84
  action: ParticipantAction;
80
85
  };
86
+ 'group.join-request': {
87
+ id: string;
88
+ author: string;
89
+ participant: string;
90
+ action: RequestJoinAction;
91
+ method: RequestJoinMethod;
92
+ };
81
93
  'blocklist.set': {
82
94
  blocklist: string[];
83
95
  };
@@ -106,6 +118,9 @@ export type BufferedEventData = {
106
118
  };
107
119
  empty: boolean;
108
120
  isLatest: boolean;
121
+ progress?: number | null;
122
+ syncType?: proto.HistorySync.HistorySyncType;
123
+ peerDataRequestSessionId?: string;
109
124
  };
110
125
  chatUpserts: {
111
126
  [jid: string]: Chat;
@@ -4,7 +4,9 @@ export type GroupParticipant = (Contact & {
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
6
  });
7
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
8
+ export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
9
+ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
8
10
  export interface GroupMetadata {
9
11
  id: string;
10
12
  owner: string | undefined;
@@ -10,6 +10,17 @@ export interface Label {
10
10
  /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
11
  predefinedId?: string;
12
12
  }
13
+ export interface LabelActionBody {
14
+ id: string;
15
+ /** Label name */
16
+ name?: string;
17
+ /** Label color ID */
18
+ color?: number;
19
+ /** Is label has been deleted */
20
+ deleted?: boolean;
21
+ /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
22
+ predefinedId?: number;
23
+ }
13
24
  /** WhatsApp has 20 predefined colors */
14
25
  export declare enum LabelColor {
15
26
  Color1 = 0,