@hbmodsofc/baileys 1.5.0 → 1.7.6

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 (156) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +19671 -152026
  3. package/engine-requirements.js +4 -4
  4. package/lib/Defaults/index.d.ts +12 -8
  5. package/lib/Defaults/index.js +90 -124
  6. package/lib/Signal/Group/group_cipher.d.ts +0 -1
  7. package/lib/Signal/Group/group_cipher.js +28 -39
  8. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  9. package/lib/Signal/Group/sender-chain-key.js +9 -2
  10. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  11. package/lib/Signal/Group/sender-key-message.js +3 -3
  12. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  13. package/lib/Signal/Group/sender-key-state.js +47 -16
  14. package/lib/Signal/libsignal.d.ts +7 -3
  15. package/lib/Signal/libsignal.js +224 -39
  16. package/lib/Signal/lid-mapping.d.ts +26 -0
  17. package/lib/Signal/lid-mapping.js +146 -0
  18. package/lib/Socket/Client/index.d.ts +2 -3
  19. package/lib/Socket/Client/index.js +2 -3
  20. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
  21. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  22. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
  23. package/lib/Socket/business.d.ts +94 -78
  24. package/lib/Socket/business.js +130 -11
  25. package/lib/Socket/chats.d.ts +63 -233
  26. package/lib/Socket/chats.js +234 -184
  27. package/lib/Socket/communities.d.ts +232 -0
  28. package/lib/Socket/communities.js +402 -0
  29. package/lib/Socket/groups.d.ts +62 -41
  30. package/lib/Socket/groups.js +76 -64
  31. package/lib/Socket/index.d.ts +129 -83
  32. package/lib/Socket/index.js +13 -6
  33. package/lib/Socket/messages-recv.d.ts +59 -48
  34. package/lib/Socket/messages-recv.js +516 -371
  35. package/lib/Socket/messages-send.d.ts +86 -67
  36. package/lib/Socket/messages-send.js +1091 -1
  37. package/lib/Socket/mex.d.ts +2 -0
  38. package/lib/Socket/mex.js +45 -0
  39. package/lib/Socket/newsletter.d.ts +76 -64
  40. package/lib/Socket/newsletter.js +184 -1
  41. package/lib/Socket/socket.d.ts +19 -13
  42. package/lib/Socket/socket.js +805 -1
  43. package/lib/Types/Auth.d.ts +4 -10
  44. package/lib/Types/Bussines.d.ts +24 -0
  45. package/lib/Types/Bussines.js +2 -0
  46. package/lib/Types/Call.d.ts +1 -1
  47. package/lib/Types/Chat.d.ts +29 -9
  48. package/lib/Types/Chat.js +7 -1
  49. package/lib/Types/Contact.d.ts +5 -1
  50. package/lib/Types/Events.d.ts +55 -14
  51. package/lib/Types/GroupMetadata.d.ts +15 -5
  52. package/lib/Types/Label.d.ts +11 -0
  53. package/lib/Types/Label.js +1 -1
  54. package/lib/Types/LabelAssociation.js +1 -1
  55. package/lib/Types/Message.d.ts +75 -49
  56. package/lib/Types/Message.js +10 -7
  57. package/lib/Types/Newsletter.d.ts +129 -98
  58. package/lib/Types/Newsletter.js +33 -38
  59. package/lib/Types/Product.d.ts +1 -1
  60. package/lib/Types/Signal.d.ts +29 -1
  61. package/lib/Types/Socket.d.ts +48 -22
  62. package/lib/Types/State.d.ts +13 -2
  63. package/lib/Types/State.js +12 -0
  64. package/lib/Types/USync.d.ts +1 -1
  65. package/lib/Types/index.d.ts +10 -3
  66. package/lib/Types/index.js +2 -2
  67. package/lib/Utils/auth-utils.d.ts +3 -3
  68. package/lib/Utils/auth-utils.js +378 -102
  69. package/lib/Utils/baileys-event-stream.js +1 -1
  70. package/lib/Utils/business.d.ts +2 -2
  71. package/lib/Utils/business.js +19 -13
  72. package/lib/Utils/chat-utils.d.ts +21 -22
  73. package/lib/Utils/chat-utils.js +201 -154
  74. package/lib/Utils/crypto.d.ts +18 -19
  75. package/lib/Utils/crypto.js +78 -37
  76. package/lib/Utils/decode-wa-message.d.ts +34 -7
  77. package/lib/Utils/decode-wa-message.js +138 -66
  78. package/lib/Utils/event-buffer.d.ts +6 -8
  79. package/lib/Utils/event-buffer.js +81 -43
  80. package/lib/Utils/generics.d.ts +27 -27
  81. package/lib/Utils/generics.js +128 -133
  82. package/lib/Utils/history.d.ts +9 -5
  83. package/lib/Utils/history.js +17 -23
  84. package/lib/Utils/index.d.ts +2 -0
  85. package/lib/Utils/index.js +2 -0
  86. package/lib/Utils/lidToJid-test.d.ts +11 -0
  87. package/lib/Utils/lidToJid-test.js +27 -0
  88. package/lib/Utils/link-preview.d.ts +4 -4
  89. package/lib/Utils/link-preview.js +40 -12
  90. package/lib/Utils/logger.d.ts +11 -3
  91. package/lib/Utils/lt-hash.d.ts +8 -8
  92. package/lib/Utils/lt-hash.js +23 -24
  93. package/lib/Utils/make-mutex.d.ts +2 -2
  94. package/lib/Utils/make-mutex.js +3 -2
  95. package/lib/Utils/message-retry-manager.d.ts +81 -0
  96. package/lib/Utils/message-retry-manager.js +152 -0
  97. package/lib/Utils/messages-media.d.ts +37 -41
  98. package/lib/Utils/messages-media.js +252 -368
  99. package/lib/Utils/messages.d.ts +13 -15
  100. package/lib/Utils/messages.js +274 -261
  101. package/lib/Utils/noise-handler.d.ts +13 -15
  102. package/lib/Utils/noise-handler.js +20 -26
  103. package/lib/Utils/process-message.d.ts +9 -8
  104. package/lib/Utils/process-message.js +157 -93
  105. package/lib/Utils/signal.d.ts +6 -5
  106. package/lib/Utils/signal.js +37 -29
  107. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  108. package/lib/Utils/use-multi-file-auth-state.js +12 -7
  109. package/lib/Utils/validate-connection.d.ts +5 -6
  110. package/lib/Utils/validate-connection.js +39 -97
  111. package/lib/WABinary/constants.d.ts +24 -27
  112. package/lib/WABinary/constants.js +1276 -13
  113. package/lib/WABinary/decode.d.ts +3 -4
  114. package/lib/WABinary/decode.js +28 -14
  115. package/lib/WABinary/encode.d.ts +1 -2
  116. package/lib/WABinary/encode.js +134 -147
  117. package/lib/WABinary/generic-utils.d.ts +4 -7
  118. package/lib/WABinary/generic-utils.js +40 -125
  119. package/lib/WABinary/jid-utils.d.ts +13 -8
  120. package/lib/WABinary/jid-utils.js +27 -16
  121. package/lib/WAM/BinaryInfo.d.ts +2 -11
  122. package/lib/WAM/constants.d.ts +3 -2
  123. package/lib/WAM/constants.js +2252 -2359
  124. package/lib/WAM/encode.d.ts +1 -2
  125. package/lib/WAM/encode.js +8 -11
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  127. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  129. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  131. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  135. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
  137. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
  138. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  139. package/lib/WAUSync/USyncQuery.js +19 -15
  140. package/lib/WAUSync/USyncUser.d.ts +5 -5
  141. package/lib/WAUSync/index.d.ts +1 -1
  142. package/lib/WAUSync/index.js +1 -1
  143. package/package.json +102 -102
  144. package/lib/Defaults/baileys-version.json +0 -3
  145. package/lib/Defaults/phonenumber-mcc.json +0 -223
  146. package/lib/Signal/Group/queue-job.d.ts +0 -1
  147. package/lib/Signal/Group/queue-job.js +0 -57
  148. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  149. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  150. package/lib/Socket/hbmods.d.ts +0 -253
  151. package/lib/Socket/hbmods.js +0 -1
  152. package/lib/Socket/registration.d.ts +0 -267
  153. package/lib/Socket/registration.js +0 -166
  154. package/lib/Socket/usync.d.ts +0 -36
  155. package/lib/Socket/usync.js +0 -70
  156. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -1,6 +1,4 @@
1
- /// <reference types="node" />
2
- import type { proto } from '../../WAProto';
3
- import { RegistrationOptions } from '../Socket/registration';
1
+ import type { proto } from '../../WAProto/index.js';
4
2
  import type { Contact } from './Contact';
5
3
  import type { MinimalMessage } from './Message';
6
4
  export type KeyPair = {
@@ -57,25 +55,21 @@ export type AuthenticationCreds = SignalCreds & {
57
55
  /** number of times history & app state has been synced */
58
56
  accountSyncCounter: number;
59
57
  accountSettings: AccountSettings;
60
- deviceId: string;
61
- phoneId: string;
62
- identityId: Buffer;
63
58
  registered: boolean;
64
- backupToken: Buffer;
65
- registration: RegistrationOptions;
66
59
  pairingCode: string | undefined;
67
60
  lastPropHash: string | undefined;
68
61
  routingInfo: Buffer | undefined;
69
62
  };
70
63
  export type SignalDataTypeMap = {
71
64
  'pre-key': KeyPair;
72
- 'session': Uint8Array;
65
+ session: Uint8Array;
73
66
  'sender-key': Uint8Array;
74
67
  'sender-key-memory': {
75
68
  [jid: string]: boolean;
76
69
  };
77
70
  'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
78
71
  'app-state-sync-version': LTHashState;
72
+ 'lid-mapping': string;
79
73
  };
80
74
  export type SignalDataSet = {
81
75
  [T in keyof SignalDataTypeMap]?: {
@@ -93,7 +87,7 @@ export type SignalKeyStore = {
93
87
  };
94
88
  export type SignalKeyStoreWithTransaction = SignalKeyStore & {
95
89
  isInTransaction: () => boolean;
96
- transaction<T>(exec: () => Promise<T>): Promise<T>;
90
+ transaction<T>(exec: () => Promise<T>, key: string): Promise<T>;
97
91
  };
98
92
  export type TransactionCapabilityOptions = {
99
93
  maxCommitRetries: number;
@@ -0,0 +1,24 @@
1
+ import type { proto } from '../../WAProto';
2
+ export type DayOfWeekBussines = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
3
+ export type HoursDay = {
4
+ day: DayOfWeekBussines;
5
+ mode: 'specific_hours';
6
+ openTimeInMinutes: string;
7
+ closeTimeInMinutes: string;
8
+ } | {
9
+ day: DayOfWeekBussines;
10
+ mode: 'open_24h' | 'appointment_only';
11
+ };
12
+ export type UpdateBussinesProfileProps = {
13
+ address?: string;
14
+ websites?: string[];
15
+ email?: string;
16
+ description?: string;
17
+ hours?: {
18
+ timezone: string;
19
+ days: HoursDay[];
20
+ };
21
+ };
22
+ export type QuickReplyAction = proto.SyncActionValue.IQuickReplyAction & {
23
+ timestamp?: string;
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,21 +1,30 @@
1
- import type { proto } from '../../WAProto';
1
+ import type { proto } from '../../WAProto/index.js';
2
2
  import type { AccountSettings } from './Auth';
3
+ import type { QuickReplyAction } from './Bussines.js';
3
4
  import type { BufferedEventData } from './Events';
5
+ import type { LabelActionBody } from './Label';
4
6
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
7
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage } from './Message';
8
+ import type { MinimalMessage, WAMessageKey } from './Message';
7
9
  /** privacy settings in WhatsApp Web */
8
10
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
11
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
12
+ export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
10
13
  export type WAReadReceiptsValue = 'all' | 'none';
14
+ export type WAPrivacyCallValue = 'all' | 'known';
15
+ export type WAPrivacyMessagesValue = 'all' | 'contacts';
11
16
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
17
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
18
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
14
- export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
19
+ export type WAPatchName = (typeof ALL_WA_PATCH_NAMES)[number];
15
20
  export interface PresenceData {
16
21
  lastKnownPresence: WAPresence;
17
22
  lastSeen?: number;
18
23
  }
24
+ export type BotListInfo = {
25
+ jid: string;
26
+ personaId: string;
27
+ };
19
28
  export type ChatMutation = {
20
29
  syncAction: proto.ISyncActionData;
21
30
  index: string[];
@@ -42,6 +51,8 @@ export type ChatUpdate = Partial<Chat & {
42
51
  * undefined if the condition is not yet fulfilled
43
52
  * */
44
53
  conditional: (bufferedData: BufferedEventData) => boolean | undefined;
54
+ /** last update time */
55
+ timestamp?: number;
45
56
  }>;
46
57
  /**
47
58
  * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
@@ -59,12 +70,13 @@ export type ChatModification = {
59
70
  /** mute for duration, or provide timestamp of mute to remove*/
60
71
  mute: number | null;
61
72
  } | {
62
- clear: 'all' | {
63
- messages: {
64
- id: string;
65
- fromMe?: boolean;
66
- timestamp: number;
67
- }[];
73
+ clear: boolean;
74
+ lastMessages: LastMessageList;
75
+ } | {
76
+ deleteForMe: {
77
+ deleteMedia: boolean;
78
+ key: WAMessageKey;
79
+ timestamp: number;
68
80
  };
69
81
  } | {
70
82
  star: {
@@ -80,6 +92,12 @@ export type ChatModification = {
80
92
  } | {
81
93
  delete: true;
82
94
  lastMessages: LastMessageList;
95
+ } | {
96
+ contact: proto.SyncActionValue.IContactAction | null;
97
+ } | {
98
+ disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction;
99
+ } | {
100
+ addLabel: LabelActionBody;
83
101
  } | {
84
102
  addChatLabel: ChatLabelAssociationActionBody;
85
103
  } | {
@@ -88,6 +106,8 @@ export type ChatModification = {
88
106
  addMessageLabel: MessageLabelAssociationActionBody;
89
107
  } | {
90
108
  removeMessageLabel: MessageLabelAssociationActionBody;
109
+ } | {
110
+ quickReply: QuickReplyAction;
91
111
  };
92
112
  export type InitialReceivedChatsState = {
93
113
  [jid: string]: {
package/lib/Types/Chat.js CHANGED
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ALL_WA_PATCH_NAMES = void 0;
4
- exports.ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'];
4
+ exports.ALL_WA_PATCH_NAMES = [
5
+ 'critical_block',
6
+ 'critical_unblock_low',
7
+ 'regular_high',
8
+ 'regular_low',
9
+ 'regular'
10
+ ];
@@ -1,6 +1,10 @@
1
1
  export interface Contact {
2
+ /** ID either in lid or jid format (preferred) **/
2
3
  id: string;
4
+ /** ID in LID format (@lid) **/
3
5
  lid?: string;
6
+ /** ID in PN format (@s.whatsapp.net) **/
7
+ phoneNumber?: string;
4
8
  /** name of the contact, you have saved on your WA */
5
9
  name?: string;
6
10
  /** name of the contact, the contact has set on their own on WA */
@@ -14,6 +18,6 @@ export interface Contact {
14
18
  * null => if the profile picture has not been set (default profile picture)
15
19
  * any other string => url of the profile picture
16
20
  */
17
- imgUrl?: string | null | 'changed';
21
+ imgUrl?: string | null;
18
22
  status?: string;
19
23
  }
@@ -1,14 +1,14 @@
1
1
  import type { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto';
3
- import { AuthenticationCreds } from './Auth';
4
- import { WACallEvent } from './Call';
5
- import { Chat, ChatUpdate, PresenceData } from './Chat';
6
- import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction } from './GroupMetadata';
8
- import { Label } from './Label';
9
- import { LabelAssociation } from './LabelAssociation';
10
- import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
- import { ConnectionState } from './State';
2
+ import { proto } from '../../WAProto/index.js';
3
+ import type { AuthenticationCreds } from './Auth';
4
+ import type { WACallEvent } from './Call';
5
+ import type { Chat, ChatUpdate, PresenceData } from './Chat';
6
+ import type { Contact } from './Contact';
7
+ import type { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
8
+ import type { Label } from './Label';
9
+ import type { LabelAssociation } from './LabelAssociation';
10
+ import type { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
+ import type { ConnectionState } from './State';
12
12
  export type BaileysEventMap = {
13
13
  /** connection state has been updated -- WS closed, opened, connecting etc. */
14
14
  'connection.update': Partial<ConnectionState>;
@@ -19,15 +19,18 @@ 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[];
26
29
  /** update the given chats */
27
30
  'chats.update': ChatUpdate[];
28
- 'chats.phoneNumberShare': {
31
+ 'lid-mapping.update': {
29
32
  lid: string;
30
- jid: string;
33
+ pn: string;
31
34
  };
32
35
  /** delete chats with given ID */
33
36
  'chats.delete': string[];
@@ -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
  };
@@ -86,12 +98,38 @@ export type BaileysEventMap = {
86
98
  type: 'add' | 'remove';
87
99
  };
88
100
  /** Receive an update on a call, including when the call was received, rejected, accepted */
89
- 'call': WACallEvent[];
101
+ call: WACallEvent[];
90
102
  'labels.edit': Label;
91
103
  'labels.association': {
92
104
  association: LabelAssociation;
93
105
  type: 'add' | 'remove';
94
106
  };
107
+ /** Newsletter-related events */
108
+ 'newsletter.reaction': {
109
+ id: string;
110
+ server_id: string;
111
+ reaction: {
112
+ code?: string;
113
+ count?: number;
114
+ removed?: boolean;
115
+ };
116
+ };
117
+ 'newsletter.view': {
118
+ id: string;
119
+ server_id: string;
120
+ count: number;
121
+ };
122
+ 'newsletter-participants.update': {
123
+ id: string;
124
+ author: string;
125
+ user: string;
126
+ new_role: string;
127
+ action: string;
128
+ };
129
+ 'newsletter-settings.update': {
130
+ id: string;
131
+ update: any;
132
+ };
95
133
  };
96
134
  export type BufferedEventData = {
97
135
  historySets: {
@@ -106,6 +144,9 @@ export type BufferedEventData = {
106
144
  };
107
145
  empty: boolean;
108
146
  isLatest: boolean;
147
+ progress?: number | null;
148
+ syncType?: proto.HistorySync.HistorySyncType;
149
+ peerDataRequestSessionId?: string;
109
150
  };
110
151
  chatUpserts: {
111
152
  [jid: string]: Chat;
@@ -1,23 +1,33 @@
1
- import { Contact } from './Contact';
2
- export type GroupParticipant = (Contact & {
1
+ import type { Contact } from './Contact';
2
+ import type { WAMessageAddressingMode } from './Message';
3
+ export type GroupParticipant = Contact & {
3
4
  isAdmin?: boolean;
4
5
  isSuperAdmin?: boolean;
5
6
  admin?: 'admin' | 'superadmin' | null;
6
- });
7
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
7
+ };
8
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
9
+ export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
10
+ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
8
11
  export interface GroupMetadata {
9
12
  id: string;
13
+ notify?: string;
14
+ /** group uses 'lid' or 'pn' to send messages */
15
+ addressingMode?: WAMessageAddressingMode;
10
16
  owner: string | undefined;
17
+ ownerPn?: string | undefined;
18
+ owner_country_code?: string | undefined;
11
19
  subject: string;
12
- addressingMode: "pn" | "lid";
13
20
  /** group subject owner */
14
21
  subjectOwner?: string;
22
+ subjectOwnerPn?: string;
15
23
  /** group subject modification date */
16
24
  subjectTime?: number;
17
25
  creation?: number;
18
26
  desc?: string;
19
27
  descOwner?: string;
28
+ descOwnerPn?: string;
20
29
  descId?: string;
30
+ descTime?: number;
21
31
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
22
32
  linkedParent?: string;
23
33
  /** is set when the group only allows admins to change group settings */
@@ -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,
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
27
+ })(LabelColor || (exports.LabelColor = LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
9
+ })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
@@ -1,34 +1,45 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { AxiosRequestConfig } from 'axios';
5
- import type { Logger } from 'pino';
1
+ import type { AxiosRequestConfig } from 'axios';
6
2
  import type { Readable } from 'stream';
7
3
  import type { URL } from 'url';
8
- import { BinaryNode } from '../WABinary';
9
- import { proto } from '../../WAProto';
10
- import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
4
+ import { proto } from '../../WAProto/index.js';
5
+ import type { MediaType } from '../Defaults';
6
+ import type { BinaryNode } from '../WABinary';
11
7
  import type { GroupMetadata } from './GroupMetadata';
12
- import { CacheStore } from './Socket';
8
+ import type { CacheStore } from './Socket';
13
9
  export { proto as WAProto };
14
- export type WAMessage = proto.IWebMessageInfo;
10
+ export type WAMessage = proto.IWebMessageInfo & {
11
+ key: WAMessageKey;
12
+ };
15
13
  export type WAMessageContent = proto.IMessage;
16
14
  export type WAContactMessage = proto.Message.IContactMessage;
17
15
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
18
- export type WAMessageKey = proto.IMessageKey;
16
+ export type WAMessageKey = proto.IMessageKey & {
17
+ remoteJidAlt?: string;
18
+ participantAlt?: string;
19
+ server_id?: string;
20
+ isViewOnce?: boolean;
21
+ };
19
22
  export type WATextMessage = proto.Message.IExtendedTextMessage;
20
23
  export type WAContextInfo = proto.IContextInfo;
21
24
  export type WALocationMessage = proto.Message.ILocationMessage;
22
25
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
23
- export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
- export import WAMessageStatus = proto.WebMessageInfo.Status;
25
- export type WAMediaUpload = Buffer | {
26
+ export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
27
+ export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
28
+ import type { ILogger } from '../Utils/logger';
29
+ export type WAMediaPayloadURL = {
26
30
  url: URL | string;
27
- } | {
31
+ };
32
+ export type WAMediaPayloadStream = {
28
33
  stream: Readable;
29
34
  };
35
+ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
30
36
  /** Set of message types that are supported by the library */
31
37
  export type MessageType = keyof proto.Message;
38
+ export declare enum WAMessageAddressingMode {
39
+ PN = "pn",
40
+ LID = "lid"
41
+ }
42
+ export type MessageWithContextInfo = 'imageMessage' | 'contactMessage' | 'locationMessage' | 'extendedTextMessage' | 'documentMessage' | 'audioMessage' | 'videoMessage' | 'call' | 'contactsArrayMessage' | 'liveLocationMessage' | 'templateMessage' | 'stickerMessage' | 'groupInviteMessage' | 'templateButtonReplyMessage' | 'productMessage' | 'listMessage' | 'orderMessage' | 'listResponseMessage' | 'buttonsMessage' | 'buttonsResponseMessage' | 'interactiveMessage' | 'interactiveResponseMessage' | 'pollCreationMessage' | 'requestPhoneNumberMessage' | 'messageHistoryBundle' | 'eventMessage' | 'newsletterAdminInviteMessage' | 'albumMessage' | 'stickerPackMessage' | 'pollResultSnapshotMessage' | 'messageHistoryNotice';
32
43
  export type DownloadableMessage = {
33
44
  mediaKey?: Uint8Array | null;
34
45
  directPath?: string | null;
@@ -64,26 +75,9 @@ type Contextable = {
64
75
  type ViewOnce = {
65
76
  viewOnce?: boolean;
66
77
  };
67
- type Buttonable = {
68
- /** add buttons to the message */
69
- buttons?: proto.Message.ButtonsMessage.IButton[];
70
- };
71
- type Templatable = {
72
- /** add buttons to the message (conflicts with normal buttons)*/
73
- templateButtons?: proto.IHydratedTemplateButton[];
74
- footer?: string;
75
- };
76
78
  type Editable = {
77
79
  edit?: WAMessageKey;
78
80
  };
79
- type Listable = {
80
- /** Sections of the List */
81
- sections?: proto.Message.ListMessage.ISection[];
82
- /** Title of a List Message only */
83
- title?: string;
84
- /** Text of the bnutton on the list (required) */
85
- buttonText?: string;
86
- };
87
81
  type WithDimensions = {
88
82
  width?: number;
89
83
  height?: number;
@@ -94,6 +88,19 @@ export type PollMessageOptions = {
94
88
  values: string[];
95
89
  /** 32 byte message secret to encrypt poll selections */
96
90
  messageSecret?: Uint8Array;
91
+ toAnnouncementGroup?: boolean;
92
+ };
93
+ export type EventMessageOptions = {
94
+ name: string;
95
+ description?: string;
96
+ startDate: Date;
97
+ endDate?: Date;
98
+ location?: WALocationMessage;
99
+ call?: 'audio' | 'video';
100
+ isCancelled?: boolean;
101
+ isScheduleCall?: boolean;
102
+ extraGuestsAllowed?: boolean;
103
+ messageSecret?: Uint8Array<ArrayBufferLike>;
97
104
  };
98
105
  type SharePhoneNumber = {
99
106
  sharePhoneNumber: boolean;
@@ -101,19 +108,18 @@ type SharePhoneNumber = {
101
108
  type RequestPhoneNumber = {
102
109
  requestPhoneNumber: boolean;
103
110
  };
104
- export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
105
111
  export type AnyMediaMessageContent = (({
106
112
  image: WAMediaUpload;
107
113
  caption?: string;
108
114
  jpegThumbnail?: string;
109
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
115
+ } & Mentionable & Contextable & WithDimensions) | ({
110
116
  video: WAMediaUpload;
111
117
  caption?: string;
112
118
  gifPlayback?: boolean;
113
119
  jpegThumbnail?: string;
114
120
  /** if set to true, will send as a `video note` */
115
121
  ptv?: boolean;
116
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
122
+ } & Mentionable & Contextable & WithDimensions) | {
117
123
  audio: WAMediaUpload;
118
124
  /** if set to true, will send as a `voice note` */
119
125
  ptt?: boolean;
@@ -127,7 +133,7 @@ export type AnyMediaMessageContent = (({
127
133
  mimetype: string;
128
134
  fileName?: string;
129
135
  caption?: string;
130
- } & Contextable & Buttonable & Templatable)) & {
136
+ } & Contextable)) & {
131
137
  mimetype?: string;
132
138
  } & Editable;
133
139
  export type ButtonReplyInfo = {
@@ -135,15 +141,24 @@ export type ButtonReplyInfo = {
135
141
  id: string;
136
142
  index: number;
137
143
  };
144
+ export type GroupInviteInfo = {
145
+ inviteCode: string;
146
+ inviteExpiration: number;
147
+ text: string;
148
+ jid: string;
149
+ subject: string;
150
+ };
138
151
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
139
152
  productImage: WAMediaUpload;
140
153
  };
141
154
  export type AnyRegularMessageContent = (({
142
155
  text: string;
143
156
  linkPreview?: WAUrlInfo | null;
144
- } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
157
+ } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | {
158
+ event: EventMessageOptions;
159
+ } | ({
145
160
  poll: PollMessageOptions;
146
- } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
161
+ } & Mentionable & Contextable & Editable) | {
147
162
  contacts: {
148
163
  displayName?: string;
149
164
  contacts: proto.Message.IContactMessage[];
@@ -155,8 +170,17 @@ export type AnyRegularMessageContent = (({
155
170
  } | {
156
171
  buttonReply: ButtonReplyInfo;
157
172
  type: 'template' | 'plain';
173
+ } | {
174
+ groupInvite: GroupInviteInfo;
158
175
  } | {
159
176
  listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
177
+ } | {
178
+ pin: WAMessageKey;
179
+ type: proto.PinInChat.Type;
180
+ /**
181
+ * 24 hours, 7 days, 30 days
182
+ */
183
+ time?: 86400 | 604800 | 2592000;
160
184
  } | {
161
185
  product: WASendableProduct;
162
186
  businessOwnerJid?: string;
@@ -176,8 +200,8 @@ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
176
200
  type MinimalRelayOptions = {
177
201
  /** override the message ID with a custom provided string */
178
202
  messageId?: string;
179
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
180
- cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
203
+ /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
204
+ useCachedGroupMetadata?: boolean;
181
205
  };
182
206
  export type MessageRelayOptions = MinimalRelayOptions & {
183
207
  /** only send to a specific participant; used when a message decryption fails for a single user */
@@ -200,7 +224,6 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
200
224
  timestamp?: Date;
201
225
  /** the message you want to quote */
202
226
  quoted?: WAMessage;
203
- additionalNodes?: BinaryNode[];
204
227
  /** disappearing messages settings */
205
228
  ephemeralExpiration?: number | string;
206
229
  /** timeout for media upload to WA server */
@@ -217,19 +240,19 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
217
240
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
218
241
  userJid: string;
219
242
  };
220
- export type WAMediaUploadFunctionOpts = {
243
+ export type WAMediaUploadFunction = (encFilePath: string, opts: {
221
244
  fileEncSha256B64: string;
222
245
  mediaType: MediaType;
223
- newsletter?: boolean;
224
246
  timeoutMs?: number;
225
- };
226
- export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
247
+ }) => Promise<{
227
248
  mediaUrl: string;
228
249
  directPath: string;
229
- handle?: string;
250
+ meta_hmac?: string;
251
+ ts?: number;
252
+ fbid?: number;
230
253
  }>;
231
254
  export type MediaGenerationOptions = {
232
- logger?: Logger;
255
+ logger?: ILogger;
233
256
  mediaTypeOverride?: MediaType;
234
257
  upload: WAMediaUploadFunction;
235
258
  /** cache media so it does not have to be uploaded again */
@@ -238,11 +261,14 @@ export type MediaGenerationOptions = {
238
261
  options?: AxiosRequestConfig;
239
262
  backgroundColor?: string;
240
263
  font?: number;
241
- /** The message is for newsletter? */
242
- newsletter?: boolean;
243
264
  };
244
265
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
245
266
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
267
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
268
+ getCallLink?: (type: 'audio' | 'video', event?: {
269
+ startTime: number;
270
+ }) => Promise<string | undefined>;
271
+ jid?: string;
246
272
  };
247
273
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
248
274
  /**
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
4
- const WAProto_1 = require("../../WAProto");
5
- Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
6
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
7
- exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
8
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
9
- exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
3
+ exports.WAMessageAddressingMode = exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
4
+ const index_js_1 = require("../../WAProto/index.js");
5
+ Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return index_js_1.proto; } });
6
+ exports.WAMessageStubType = index_js_1.proto.WebMessageInfo.StubType;
7
+ exports.WAMessageStatus = index_js_1.proto.WebMessageInfo.Status;
8
+ var WAMessageAddressingMode;
9
+ (function (WAMessageAddressingMode) {
10
+ WAMessageAddressingMode["PN"] = "pn";
11
+ WAMessageAddressingMode["LID"] = "lid";
12
+ })(WAMessageAddressingMode || (exports.WAMessageAddressingMode = WAMessageAddressingMode = {}));