alipclutch-baileys 8.5.2 → 8.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +11 -5
  2. package/WAProto/index.js +77698 -117050
  3. package/engine-requirements.js +10 -0
  4. package/lib/Defaults/baileys-version.json +2 -2
  5. package/lib/Defaults/index.d.ts +7 -16
  6. package/lib/Defaults/index.js +119 -90
  7. package/lib/Defaults/phonenumber-mcc.json +223 -0
  8. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  9. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  10. package/lib/Socket/Client/index.d.ts +3 -2
  11. package/lib/Socket/Client/index.js +3 -2
  12. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  13. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  14. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  15. package/lib/Socket/Client/web-socket-client.js +62 -0
  16. package/lib/Socket/business.d.ts +58 -59
  17. package/lib/Socket/chats.d.ts +230 -45
  18. package/lib/Socket/chats.js +238 -139
  19. package/lib/Socket/groups.d.ts +32 -41
  20. package/lib/Socket/groups.js +23 -38
  21. package/lib/Socket/index.d.ts +64 -63
  22. package/lib/Socket/index.js +3 -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 +395 -543
  26. package/lib/Socket/newsletter.d.ts +37 -39
  27. package/lib/Socket/newsletter.js +123 -88
  28. package/lib/Socket/registration.d.ts +267 -0
  29. package/lib/Socket/registration.js +166 -0
  30. package/lib/Socket/setup.d.ts +253 -0
  31. package/lib/Socket/setup.js +4 -5
  32. package/lib/Socket/socket.d.ts +43 -270
  33. package/lib/Socket/socket.js +38 -62
  34. package/lib/Socket/usync.d.ts +3 -3
  35. package/lib/Store/index.d.ts +2 -1
  36. package/lib/Store/index.js +3 -1
  37. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  38. package/lib/Store/make-cache-manager-store.js +83 -0
  39. package/lib/Store/make-in-memory-store.d.ts +24 -24
  40. package/lib/Store/make-in-memory-store.js +14 -26
  41. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  42. package/lib/Store/make-ordered-dictionary.js +2 -2
  43. package/lib/Types/Auth.d.ts +7 -0
  44. package/lib/Types/Call.d.ts +1 -1
  45. package/lib/Types/Chat.d.ts +7 -14
  46. package/lib/Types/Contact.d.ts +1 -5
  47. package/lib/Types/Events.d.ts +2 -44
  48. package/lib/Types/GroupMetadata.d.ts +2 -11
  49. package/lib/Types/Label.js +1 -1
  50. package/lib/Types/LabelAssociation.js +1 -1
  51. package/lib/Types/Message.d.ts +21 -148
  52. package/lib/Types/Message.js +2 -0
  53. package/lib/Types/Newsletter.d.ts +97 -73
  54. package/lib/Types/Newsletter.js +38 -18
  55. package/lib/Types/Socket.d.ts +9 -17
  56. package/lib/Types/index.d.ts +1 -8
  57. package/lib/Types/index.js +2 -2
  58. package/lib/Utils/auth-utils.d.ts +3 -3
  59. package/lib/Utils/auth-utils.js +13 -6
  60. package/lib/Utils/business.js +2 -2
  61. package/lib/Utils/chat-utils.d.ts +16 -15
  62. package/lib/Utils/chat-utils.js +35 -36
  63. package/lib/Utils/crypto.d.ts +16 -15
  64. package/lib/Utils/crypto.js +29 -71
  65. package/lib/Utils/decode-wa-message.d.ts +6 -22
  66. package/lib/Utils/decode-wa-message.js +56 -65
  67. package/lib/Utils/event-buffer.d.ts +2 -2
  68. package/lib/Utils/event-buffer.js +7 -11
  69. package/lib/Utils/generics.d.ts +20 -17
  70. package/lib/Utils/generics.js +75 -95
  71. package/lib/Utils/history.d.ts +0 -4
  72. package/lib/Utils/history.js +6 -4
  73. package/lib/Utils/link-preview.d.ts +2 -2
  74. package/lib/Utils/link-preview.js +1 -34
  75. package/lib/Utils/logger.d.ts +3 -10
  76. package/lib/Utils/lt-hash.d.ts +2 -2
  77. package/lib/Utils/lt-hash.js +6 -6
  78. package/lib/Utils/make-mutex.d.ts +2 -2
  79. package/lib/Utils/messages-media.d.ts +24 -28
  80. package/lib/Utils/messages-media.js +111 -272
  81. package/lib/Utils/messages.d.ts +10 -13
  82. package/lib/Utils/messages.js +50 -323
  83. package/lib/Utils/noise-handler.d.ts +12 -10
  84. package/lib/Utils/noise-handler.js +23 -18
  85. package/lib/Utils/process-message.d.ts +4 -5
  86. package/lib/Utils/process-message.js +25 -108
  87. package/lib/Utils/signal.d.ts +1 -2
  88. package/lib/Utils/signal.js +26 -26
  89. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  90. package/lib/Utils/use-multi-file-auth-state.js +6 -51
  91. package/lib/Utils/validate-connection.d.ts +4 -3
  92. package/lib/Utils/validate-connection.js +1 -1
  93. package/lib/WABinary/constants.d.ts +27 -24
  94. package/lib/WABinary/constants.js +13 -1276
  95. package/lib/WABinary/decode.d.ts +4 -3
  96. package/lib/WABinary/decode.js +13 -26
  97. package/lib/WABinary/encode.d.ts +2 -1
  98. package/lib/WABinary/encode.js +152 -137
  99. package/lib/WABinary/generic-utils.d.ts +4 -1
  100. package/lib/WABinary/generic-utils.js +125 -37
  101. package/lib/WABinary/jid-utils.d.ts +5 -11
  102. package/lib/WABinary/jid-utils.js +5 -28
  103. package/lib/WAM/BinaryInfo.d.ts +11 -2
  104. package/lib/WAM/encode.d.ts +2 -1
  105. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  106. package/lib/index.d.ts +1 -0
  107. package/lib/index.js +15 -27
  108. package/package.json +31 -18
  109. package/WAProto/GenerateStatics.sh +0 -4
  110. package/WAProto/WAProto.proto +0 -4775
  111. package/WAProto/index.d.ts +0 -55057
  112. package/WAProto/index.ts.ts +0 -53473
  113. package/lib/Socket/setup.ts +0 -623
  114. package/lib/WABinary/jid-utils.js.bak +0 -83
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cache_manager_1 = require("cache-manager");
7
+ const WAProto_1 = require("../../WAProto");
8
+ const Utils_1 = require("../Utils");
9
+ const logger_1 = __importDefault(require("../Utils/logger"));
10
+ const makeCacheManagerAuthState = async (store, sessionKey) => {
11
+ const defaultKey = (file) => `${sessionKey}:${file}`;
12
+ const databaseConn = await (0, cache_manager_1.caching)(store);
13
+ const writeData = async (file, data) => {
14
+ let ttl = undefined;
15
+ if (file === 'creds') {
16
+ ttl = 63115200; // 2 years
17
+ }
18
+ await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl);
19
+ };
20
+ const readData = async (file) => {
21
+ try {
22
+ const data = await databaseConn.get(defaultKey(file));
23
+ if (data) {
24
+ return JSON.parse(data, Utils_1.BufferJSON.reviver);
25
+ }
26
+ return null;
27
+ }
28
+ catch (error) {
29
+ logger_1.default.error(error);
30
+ return null;
31
+ }
32
+ };
33
+ const removeData = async (file) => {
34
+ try {
35
+ return await databaseConn.del(defaultKey(file));
36
+ }
37
+ catch (_a) {
38
+ logger_1.default.error(`Error removing ${file} from session ${sessionKey}`);
39
+ }
40
+ };
41
+ const clearState = async () => {
42
+ try {
43
+ const result = await databaseConn.store.keys(`${sessionKey}*`);
44
+ await Promise.all(result.map(async (key) => await databaseConn.del(key)));
45
+ }
46
+ catch (err) {
47
+ }
48
+ };
49
+ const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)();
50
+ return {
51
+ clearState,
52
+ saveCreds: () => writeData('creds', creds),
53
+ state: {
54
+ creds,
55
+ keys: {
56
+ get: async (type, ids) => {
57
+ const data = {};
58
+ await Promise.all(ids.map(async (id) => {
59
+ let value = await readData(`${type}-${id}`);
60
+ if (type === 'app-state-sync-key' && value) {
61
+ value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
62
+ }
63
+ data[id] = value;
64
+ }));
65
+ return data;
66
+ },
67
+ set: async (data) => {
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ const tasks = [];
70
+ for (const category in data) {
71
+ for (const id in data[category]) {
72
+ const value = data[category][id];
73
+ const key = `${category}-${id}`;
74
+ tasks.push(value ? writeData(key, value) : removeData(key));
75
+ }
76
+ }
77
+ await Promise.all(tasks);
78
+ },
79
+ }
80
+ }
81
+ };
82
+ };
83
+ exports.default = makeCacheManagerAuthState;
@@ -1,11 +1,11 @@
1
1
  import type KeyedDB from '@adiwajshing/keyed-db';
2
2
  import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
3
+ import type { Logger } from 'pino';
3
4
  import { proto } from '../../WAProto';
4
5
  import type makeMDSocket from '../Socket';
5
6
  import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
6
7
  import { Label } from '../Types/Label';
7
8
  import { LabelAssociation } from '../Types/LabelAssociation';
8
- import { ILogger } from '../Utils/logger';
9
9
  import { ObjectRepository } from './object-repository';
10
10
  type WASocket = ReturnType<typeof makeMDSocket>;
11
11
  export declare const waChatKey: (pin: boolean) => {
@@ -17,7 +17,7 @@ export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
17
17
  export type BaileysInMemoryStoreConfig = {
18
18
  chatKey?: Comparable<Chat, string>;
19
19
  labelAssociationKey?: Comparable<LabelAssociation, string>;
20
- logger?: ILogger;
20
+ logger?: Logger;
21
21
  socket?: WASocket;
22
22
  };
23
23
  declare const _default: (config: BaileysInMemoryStoreConfig) => {
@@ -27,16 +27,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
27
27
  };
28
28
  messages: {
29
29
  [_: string]: {
30
- array: WAMessage[];
31
- get: (id: string) => WAMessage | undefined;
32
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
33
- update: (item: WAMessage) => boolean;
34
- remove: (item: WAMessage) => boolean;
35
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
30
+ array: proto.IWebMessageInfo[];
31
+ get: (id: string) => proto.IWebMessageInfo | undefined;
32
+ upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
33
+ update: (item: proto.IWebMessageInfo) => boolean;
34
+ remove: (item: proto.IWebMessageInfo) => boolean;
35
+ updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
36
36
  clear: () => void;
37
- filter: (contain: (item: WAMessage) => boolean) => void;
38
- toJSON: () => WAMessage[];
39
- fromJSON: (newItems: WAMessage[]) => void;
37
+ filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
38
+ toJSON: () => proto.IWebMessageInfo[];
39
+ fromJSON: (newItems: proto.IWebMessageInfo[]) => void;
40
40
  };
41
41
  };
42
42
  groupMetadata: {
@@ -52,7 +52,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
52
52
  labelAssociations: KeyedDB<LabelAssociation, string>;
53
53
  bind: (ev: BaileysEventEmitter) => void;
54
54
  /** loads messages from the store, if not found -- uses the legacy connection */
55
- loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
55
+ loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<proto.IWebMessageInfo[]>;
56
56
  /**
57
57
  * Get all available labels for profile
58
58
  *
@@ -72,8 +72,8 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
72
72
  * @returns Label IDs
73
73
  **/
74
74
  getMessageLabels: (messageId: string) => string[];
75
- loadMessage: (jid: string, id: string) => Promise<WAMessage | undefined>;
76
- mostRecentMessage: (jid: string) => Promise<WAMessage>;
75
+ loadMessage: (jid: string, id: string) => Promise<proto.IWebMessageInfo | undefined>;
76
+ mostRecentMessage: (jid: string) => Promise<proto.IWebMessageInfo>;
77
77
  fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
78
78
  fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
79
79
  fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
@@ -84,16 +84,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
84
84
  };
85
85
  messages: {
86
86
  [_: string]: {
87
- array: WAMessage[];
88
- get: (id: string) => WAMessage | undefined;
89
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
90
- update: (item: WAMessage) => boolean;
91
- remove: (item: WAMessage) => boolean;
92
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
87
+ array: proto.IWebMessageInfo[];
88
+ get: (id: string) => proto.IWebMessageInfo | undefined;
89
+ upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
90
+ update: (item: proto.IWebMessageInfo) => boolean;
91
+ remove: (item: proto.IWebMessageInfo) => boolean;
92
+ updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
93
93
  clear: () => void;
94
- filter: (contain: (item: WAMessage) => boolean) => void;
95
- toJSON: () => WAMessage[];
96
- fromJSON: (newItems: WAMessage[]) => void;
94
+ filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
95
+ toJSON: () => proto.IWebMessageInfo[];
96
+ fromJSON: (newItems: proto.IWebMessageInfo[]) => void;
97
97
  };
98
98
  };
99
99
  labels: ObjectRepository<Label>;
@@ -105,7 +105,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
105
105
  [id: string]: Contact;
106
106
  };
107
107
  messages: {
108
- [id: string]: WAMessage[];
108
+ [id: string]: proto.IWebMessageInfo[];
109
109
  };
110
110
  labels: {
111
111
  [labelId: string]: Label;
@@ -74,11 +74,7 @@ exports.default = (config) => {
74
74
  ev.on('connection.update', update => {
75
75
  Object.assign(state, update);
76
76
  });
77
- ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
78
- if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
79
- return; // FOR NOW,
80
- //TODO: HANDLE
81
- }
77
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
82
78
  if (isLatest) {
83
79
  chats.clear();
84
80
  for (const id in messages) {
@@ -191,14 +187,16 @@ exports.default = (config) => {
191
187
  const jid = (0, WABinary_1.jidNormalizedUser)(msg.key.remoteJid);
192
188
  const list = assertMessageList(jid);
193
189
  list.upsert(msg, 'append');
194
- if (type === 'notify' && !chats.get(jid)) {
195
- ev.emit('chats.upsert', [
196
- {
197
- id: jid,
198
- conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
199
- unreadCount: 1
200
- }
201
- ]);
190
+ if (type === 'notify') {
191
+ if (!chats.get(jid)) {
192
+ ev.emit('chats.upsert', [
193
+ {
194
+ id: jid,
195
+ conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
196
+ unreadCount: 1
197
+ }
198
+ ]);
199
+ }
202
200
  }
203
201
  }
204
202
  break;
@@ -420,19 +418,9 @@ exports.default = (config) => {
420
418
  const { readFileSync, existsSync } = require('fs');
421
419
  if (existsSync(path)) {
422
420
  logger.debug({ path }, 'reading from file');
423
- try {
424
- const jsonStr = readFileSync(path, { encoding: 'utf-8' });
425
- if (jsonStr.trim().length) {
426
- const json = JSON.parse(jsonStr);
427
- fromJSON(json);
428
- }
429
- else {
430
- logger.warn({ path }, 'skipping empty json file');
431
- }
432
- }
433
- catch (err) {
434
- logger.warn({ path, err }, 'failed to parse json from file');
435
- }
421
+ const jsonStr = readFileSync(path, { encoding: 'utf-8' });
422
+ const json = JSON.parse(jsonStr);
423
+ fromJSON(json);
436
424
  }
437
425
  }
438
426
  };
@@ -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;
@@ -56,9 +56,9 @@ function makeOrderedDictionary(idGetter) {
56
56
  },
57
57
  clear: () => {
58
58
  array.splice(0, array.length);
59
- for (const key of Object.keys(dict)) {
59
+ Object.keys(dict).forEach(key => {
60
60
  delete dict[key];
61
- }
61
+ });
62
62
  },
63
63
  filter: (contain) => {
64
64
  let i = 0;
@@ -1,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import type { proto } from '../../WAProto';
3
+ import { RegistrationOptions } from '../Socket/registration';
2
4
  import type { Contact } from './Contact';
3
5
  import type { MinimalMessage } from './Message';
4
6
  export type KeyPair = {
@@ -55,7 +57,12 @@ export type AuthenticationCreds = SignalCreds & {
55
57
  /** number of times history & app state has been synced */
56
58
  accountSyncCounter: number;
57
59
  accountSettings: AccountSettings;
60
+ deviceId: string;
61
+ phoneId: string;
62
+ identityId: Buffer;
58
63
  registered: boolean;
64
+ backupToken: Buffer;
65
+ registration: RegistrationOptions;
59
66
  pairingCode: string | undefined;
60
67
  lastPropHash: string | undefined;
61
68
  routingInfo: Buffer | undefined;
@@ -1,4 +1,4 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
2
2
  export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
@@ -3,13 +3,10 @@ import type { AccountSettings } from './Auth';
3
3
  import type { BufferedEventData } from './Events';
4
4
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
5
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage, WAMessageKey } from './Message';
6
+ import type { MinimalMessage } from './Message';
7
7
  /** privacy settings in WhatsApp Web */
8
8
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
- export type WAPrivacyCallValue = 'all' | 'known';
10
- export type WAPrivacyMessagesValue = 'all' | 'contacts';
11
9
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
12
- export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
13
10
  export type WAReadReceiptsValue = 'all' | 'none';
14
11
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
15
12
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
@@ -19,10 +16,6 @@ export interface PresenceData {
19
16
  lastKnownPresence: WAPresence;
20
17
  lastSeen?: number;
21
18
  }
22
- export type BotListInfo = {
23
- jid: string;
24
- personaId: string;
25
- };
26
19
  export type ChatMutation = {
27
20
  syncAction: proto.ISyncActionData;
28
21
  index: string[];
@@ -66,12 +59,12 @@ export type ChatModification = {
66
59
  /** mute for duration, or provide timestamp of mute to remove*/
67
60
  mute: number | null;
68
61
  } | {
69
- clear: boolean;
70
- } | {
71
- deleteForMe: {
72
- deleteMedia: boolean;
73
- key: WAMessageKey;
74
- timestamp: number;
62
+ clear: 'all' | {
63
+ messages: {
64
+ id: string;
65
+ fromMe?: boolean;
66
+ timestamp: number;
67
+ }[];
75
68
  };
76
69
  } | {
77
70
  star: {
@@ -1,10 +1,6 @@
1
1
  export interface Contact {
2
- /** ID either in lid or jid format **/
3
2
  id: string;
4
- /** ID in Lid (anonymous) format (@lid) **/
5
3
  lid?: string;
6
- /** ID in Phone Number format (@s.whatsapp.net) **/
7
- jid?: string;
8
4
  /** name of the contact, you have saved on your WA */
9
5
  name?: string;
10
6
  /** name of the contact, the contact has set on their own on WA */
@@ -18,6 +14,6 @@ export interface Contact {
18
14
  * null => if the profile picture has not been set (default profile picture)
19
15
  * any other string => url of the profile picture
20
16
  */
21
- imgUrl?: string | null;
17
+ imgUrl?: string | null | 'changed';
22
18
  status?: string;
23
19
  }
@@ -4,12 +4,11 @@ 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, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
7
+ import { GroupMetadata, ParticipantAction } from './GroupMetadata';
8
8
  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
- import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
13
12
  export type BaileysEventMap = {
14
13
  /** connection state has been updated -- WS closed, opened, connecting etc. */
15
14
  'connection.update': Partial<ConnectionState>;
@@ -20,10 +19,7 @@ export type BaileysEventMap = {
20
19
  chats: Chat[];
21
20
  contacts: Contact[];
22
21
  messages: WAMessage[];
23
- isLatest?: boolean;
24
- progress?: number | null;
25
- syncType?: proto.HistorySync.HistorySyncType;
26
- peerDataRequestSessionId?: string | null;
22
+ isLatest: boolean;
27
23
  };
28
24
  /** upsert chats */
29
25
  'chats.upsert': Chat[];
@@ -62,12 +58,10 @@ export type BaileysEventMap = {
62
58
  /**
63
59
  * add/update the given messages. If they were received while the connection was online,
64
60
  * the update will have type: "notify"
65
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
66
61
  * */
67
62
  'messages.upsert': {
68
63
  messages: WAMessage[];
69
64
  type: MessageUpsertType;
70
- requestId?: string;
71
65
  };
72
66
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
73
67
  'messages.reaction': {
@@ -84,39 +78,6 @@ export type BaileysEventMap = {
84
78
  participants: string[];
85
79
  action: ParticipantAction;
86
80
  };
87
- 'group.join-request': {
88
- id: string;
89
- author: string;
90
- participant: string;
91
- action: RequestJoinAction;
92
- method: RequestJoinMethod;
93
- };
94
- 'newsletter.reaction': {
95
- id: string;
96
- server_id: string;
97
- reaction: {
98
- code?: string;
99
- count?: number;
100
- removed?: boolean;
101
- };
102
- };
103
- 'newsletter.view': {
104
- id: string;
105
- server_id: string;
106
- count: number;
107
- };
108
- /**don't handles subscribe/unsubscribe actions */
109
- 'newsletter-participants.update': {
110
- id: string;
111
- author: string;
112
- user: string;
113
- new_role: NewsletterViewRole;
114
- action: SubscriberAction;
115
- };
116
- 'newsletter-settings.update': {
117
- id: string;
118
- update: NewsletterSettingsUpdate;
119
- };
120
81
  'blocklist.set': {
121
82
  blocklist: string[];
122
83
  };
@@ -145,9 +106,6 @@ export type BufferedEventData = {
145
106
  };
146
107
  empty: boolean;
147
108
  isLatest: boolean;
148
- progress?: number | null;
149
- syncType?: proto.HistorySync.HistorySyncType;
150
- peerDataRequestSessionId?: string;
151
109
  };
152
110
  chatUpserts: {
153
111
  [jid: string]: Chat;
@@ -3,30 +3,21 @@ export type GroupParticipant = (Contact & {
3
3
  isAdmin?: boolean;
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
- jid?: string;
7
- lid?: string;
8
6
  });
9
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
10
- export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
11
- export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
12
8
  export interface GroupMetadata {
13
9
  id: string;
14
- /** group uses 'lid' or 'pn' to send messages */
15
- addressingMode: 'pn' | 'lid';
16
10
  owner: string | undefined;
17
- ownerLid?: string | undefined;
18
11
  subject: string;
12
+ addressingMode: "pn" | "lid";
19
13
  /** group subject owner */
20
14
  subjectOwner?: string;
21
- subjectOwnerLid?: string;
22
15
  /** group subject modification date */
23
16
  subjectTime?: number;
24
17
  creation?: number;
25
18
  desc?: string;
26
19
  descOwner?: string;
27
- descOwnerLid?: string;
28
20
  descId?: string;
29
- descTime?: number;
30
21
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
31
22
  linkedParent?: string;
32
23
  /** is set when the group only allows admins to change group settings */
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor || (exports.LabelColor = LabelColor = {}));
27
+ })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
9
+ })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));