supunmd-bail 2.1.1 → 2.1.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 (216) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +428 -0
  3. package/WAProto/index.js +130529 -45236
  4. package/engine-requirements.js +1 -1
  5. package/lib/Defaults/baileys-version.json +1 -1
  6. package/lib/Defaults/index.d.ts +9 -18
  7. package/lib/Defaults/index.js +136 -104
  8. package/lib/Defaults/phonenumber-mcc.json +223 -0
  9. package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
  10. package/lib/Signal/Group/ciphertext-message.js +5 -2
  11. package/lib/Signal/Group/group-session-builder.d.ts +3 -4
  12. package/lib/Signal/Group/group-session-builder.js +41 -7
  13. package/lib/Signal/Group/group_cipher.d.ts +4 -4
  14. package/lib/Signal/Group/group_cipher.js +51 -37
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +57 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +1 -2
  18. package/lib/Signal/Group/keyhelper.js +44 -7
  19. package/lib/Signal/Group/queue-job.d.ts +0 -1
  20. package/lib/Signal/Group/queue-job.js +5 -2
  21. package/lib/Signal/Group/sender-chain-key.d.ts +2 -3
  22. package/lib/Signal/Group/sender-chain-key.js +15 -7
  23. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -2
  24. package/lib/Signal/Group/sender-key-distribution-message.js +11 -8
  25. package/lib/Signal/Group/sender-key-message.d.ts +1 -2
  26. package/lib/Signal/Group/sender-key-message.js +12 -9
  27. package/lib/Signal/Group/sender-key-name.d.ts +0 -1
  28. package/lib/Signal/Group/sender-key-name.js +5 -2
  29. package/lib/Signal/Group/sender-key-record.d.ts +2 -3
  30. package/lib/Signal/Group/sender-key-record.js +21 -9
  31. package/lib/Signal/Group/sender-key-state.d.ts +6 -7
  32. package/lib/Signal/Group/sender-key-state.js +42 -27
  33. package/lib/Signal/Group/sender-message-key.d.ts +0 -1
  34. package/lib/Signal/Group/sender-message-key.js +7 -4
  35. package/lib/Signal/libsignal.d.ts +3 -5
  36. package/lib/Signal/libsignal.js +90 -258
  37. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -2
  38. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  39. package/lib/Socket/Client/index.d.ts +3 -3
  40. package/lib/Socket/Client/index.js +19 -3
  41. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  42. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  43. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  44. package/lib/Socket/Client/web-socket-client.js +62 -0
  45. package/lib/Socket/business.d.ts +108 -125
  46. package/lib/Socket/business.js +43 -159
  47. package/lib/Socket/chats.d.ts +239 -70
  48. package/lib/Socket/chats.js +384 -363
  49. package/lib/Socket/dugong.d.ts +254 -0
  50. package/lib/Socket/dugong.js +484 -0
  51. package/lib/Socket/groups.d.ts +56 -78
  52. package/lib/Socket/groups.js +96 -106
  53. package/lib/Socket/index.d.ts +115 -173
  54. package/lib/Socket/index.js +10 -17
  55. package/lib/Socket/messages-recv.d.ts +79 -91
  56. package/lib/Socket/messages-recv.js +521 -639
  57. package/lib/Socket/messages-send.d.ts +91 -111
  58. package/lib/Socket/messages-send.js +438 -599
  59. package/lib/Socket/newsletter.d.ts +84 -97
  60. package/lib/Socket/newsletter.js +239 -145
  61. package/lib/Socket/registration.d.ts +267 -0
  62. package/lib/Socket/registration.js +166 -0
  63. package/lib/Socket/socket.d.ts +18 -26
  64. package/lib/Socket/socket.js +230 -448
  65. package/lib/Socket/usync.d.ts +16 -17
  66. package/lib/Socket/usync.js +26 -19
  67. package/lib/Store/index.d.ts +3 -0
  68. package/lib/Store/index.js +10 -0
  69. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  70. package/lib/Store/make-cache-manager-store.js +83 -0
  71. package/lib/Store/make-in-memory-store.d.ts +118 -0
  72. package/lib/Store/make-in-memory-store.js +427 -0
  73. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  74. package/lib/Store/make-ordered-dictionary.js +81 -0
  75. package/lib/Store/object-repository.d.ts +10 -0
  76. package/lib/Store/object-repository.js +27 -0
  77. package/lib/Types/Auth.d.ts +12 -13
  78. package/lib/Types/Auth.js +2 -2
  79. package/lib/Types/Call.d.ts +1 -2
  80. package/lib/Types/Call.js +2 -2
  81. package/lib/Types/Chat.d.ts +13 -34
  82. package/lib/Types/Chat.js +4 -8
  83. package/lib/Types/Contact.d.ts +1 -6
  84. package/lib/Types/Contact.js +2 -2
  85. package/lib/Types/Events.d.ts +15 -60
  86. package/lib/Types/Events.js +2 -2
  87. package/lib/Types/GroupMetadata.d.ts +5 -17
  88. package/lib/Types/GroupMetadata.js +2 -2
  89. package/lib/Types/Label.d.ts +0 -12
  90. package/lib/Types/Label.js +5 -3
  91. package/lib/Types/LabelAssociation.d.ts +0 -1
  92. package/lib/Types/LabelAssociation.js +5 -3
  93. package/lib/Types/Message.d.ts +54 -84
  94. package/lib/Types/Message.js +9 -11
  95. package/lib/Types/Newsletter.d.ts +98 -130
  96. package/lib/Types/Newsletter.js +38 -31
  97. package/lib/Types/Product.d.ts +1 -2
  98. package/lib/Types/Product.js +2 -2
  99. package/lib/Types/Signal.d.ts +1 -20
  100. package/lib/Types/Signal.js +2 -2
  101. package/lib/Types/Socket.d.ts +25 -47
  102. package/lib/Types/Socket.js +2 -3
  103. package/lib/Types/State.d.ts +2 -14
  104. package/lib/Types/State.js +2 -13
  105. package/lib/Types/USync.d.ts +2 -3
  106. package/lib/Types/USync.js +2 -2
  107. package/lib/Types/index.d.ts +14 -22
  108. package/lib/Types/index.js +31 -15
  109. package/lib/Utils/auth-utils.d.ts +6 -7
  110. package/lib/Utils/auth-utils.js +148 -199
  111. package/lib/Utils/baileys-event-stream.d.ts +1 -2
  112. package/lib/Utils/baileys-event-stream.js +22 -15
  113. package/lib/Utils/business.d.ts +2 -3
  114. package/lib/Utils/business.js +69 -66
  115. package/lib/Utils/chat-utils.d.ts +22 -21
  116. package/lib/Utils/chat-utils.js +226 -260
  117. package/lib/Utils/crypto.d.ts +19 -19
  118. package/lib/Utils/crypto.js +86 -77
  119. package/lib/Utils/decode-wa-message.d.ts +8 -37
  120. package/lib/Utils/decode-wa-message.js +83 -164
  121. package/lib/Utils/event-buffer.d.ts +8 -7
  122. package/lib/Utils/event-buffer.js +76 -110
  123. package/lib/Utils/generics.d.ts +29 -27
  124. package/lib/Utils/generics.js +210 -168
  125. package/lib/Utils/history.d.ts +8 -12
  126. package/lib/Utils/history.js +46 -34
  127. package/lib/Utils/index.d.ts +17 -20
  128. package/lib/Utils/index.js +33 -20
  129. package/lib/Utils/link-preview.d.ts +5 -5
  130. package/lib/Utils/link-preview.js +22 -14
  131. package/lib/Utils/logger.d.ts +3 -11
  132. package/lib/Utils/logger.js +7 -3
  133. package/lib/Utils/lt-hash.d.ts +8 -9
  134. package/lib/Utils/lt-hash.js +28 -25
  135. package/lib/Utils/make-mutex.d.ts +2 -3
  136. package/lib/Utils/make-mutex.js +10 -7
  137. package/lib/Utils/messages-media.d.ts +44 -42
  138. package/lib/Utils/messages-media.js +475 -319
  139. package/lib/Utils/messages.d.ts +18 -17
  140. package/lib/Utils/messages.js +259 -383
  141. package/lib/Utils/noise-handler.d.ts +15 -14
  142. package/lib/Utils/noise-handler.js +38 -30
  143. package/lib/Utils/process-message.d.ts +13 -14
  144. package/lib/Utils/process-message.js +147 -239
  145. package/lib/Utils/signal.d.ts +5 -7
  146. package/lib/Utils/signal.js +72 -78
  147. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -2
  148. package/lib/Utils/use-multi-file-auth-state.js +27 -29
  149. package/lib/Utils/validate-connection.d.ts +7 -7
  150. package/lib/Utils/validate-connection.js +106 -72
  151. package/lib/WABinary/constants.d.ts +27 -25
  152. package/lib/WABinary/constants.js +20 -1281
  153. package/lib/WABinary/decode.d.ts +5 -5
  154. package/lib/WABinary/decode.js +42 -28
  155. package/lib/WABinary/encode.d.ts +3 -3
  156. package/lib/WABinary/encode.js +154 -105
  157. package/lib/WABinary/generic-utils.d.ts +7 -5
  158. package/lib/WABinary/generic-utils.js +63 -56
  159. package/lib/WABinary/index.d.ts +5 -6
  160. package/lib/WABinary/index.js +21 -6
  161. package/lib/WABinary/jid-utils.d.ts +8 -25
  162. package/lib/WABinary/jid-utils.js +40 -74
  163. package/lib/WABinary/types.d.ts +1 -2
  164. package/lib/WABinary/types.js +2 -2
  165. package/lib/WAM/BinaryInfo.d.ts +11 -3
  166. package/lib/WAM/BinaryInfo.js +5 -2
  167. package/lib/WAM/constants.d.ts +3 -5
  168. package/lib/WAM/constants.js +11958 -19461
  169. package/lib/WAM/encode.d.ts +3 -3
  170. package/lib/WAM/encode.js +22 -17
  171. package/lib/WAM/index.d.ts +3 -4
  172. package/lib/WAM/index.js +19 -4
  173. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
  174. package/lib/WAUSync/Protocols/USyncContactProtocol.js +11 -8
  175. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
  176. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
  177. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
  178. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -9
  179. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
  180. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
  181. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
  182. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
  183. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -5
  184. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
  185. package/lib/WAUSync/Protocols/index.d.ts +4 -5
  186. package/lib/WAUSync/Protocols/index.js +20 -5
  187. package/lib/WAUSync/USyncQuery.d.ts +4 -5
  188. package/lib/WAUSync/USyncQuery.js +35 -40
  189. package/lib/WAUSync/USyncUser.d.ts +5 -6
  190. package/lib/WAUSync/USyncUser.js +5 -2
  191. package/lib/WAUSync/index.d.ts +3 -4
  192. package/lib/WAUSync/index.js +19 -4
  193. package/lib/index.d.ts +9 -19
  194. package/lib/index.js +47 -24
  195. package/package.json +109 -99
  196. package/WAProto/GenerateStatics.sh +0 -3
  197. package/WAProto/WAProto.proto +0 -5519
  198. package/WAProto/fix-imports.js +0 -29
  199. package/WAProto/index.d.ts +0 -11969
  200. package/lib/Signal/lid-mapping.d.ts +0 -23
  201. package/lib/Signal/lid-mapping.js +0 -171
  202. package/lib/Socket/Client/types.js +0 -11
  203. package/lib/Socket/Client/websocket.js +0 -50
  204. package/lib/Socket/communities.d.ts +0 -244
  205. package/lib/Socket/communities.js +0 -431
  206. package/lib/Socket/mex.d.ts +0 -3
  207. package/lib/Socket/mex.js +0 -42
  208. package/lib/Types/Bussines.d.ts +0 -25
  209. package/lib/Types/Bussines.js +0 -2
  210. package/lib/Utils/browser-utils.d.ts +0 -4
  211. package/lib/Utils/browser-utils.js +0 -28
  212. package/lib/Utils/message-retry-manager.d.ts +0 -82
  213. package/lib/Utils/message-retry-manager.js +0 -149
  214. package/lib/Utils/pre-key-manager.d.ts +0 -28
  215. package/lib/Utils/pre-key-manager.js +0 -106
  216. /package/lib/{supun → supunmd} +0 -0
@@ -1,30 +1,21 @@
1
- import type { proto } from '../../WAProto/index.js';
2
- import type { AccountSettings } from './Auth.js';
3
- import type { QuickReplyAction } from './Bussines.js';
4
- import type { BufferedEventData } from './Events.js';
5
- import type { LabelActionBody } from './Label.js';
6
- import type { ChatLabelAssociationActionBody } from './LabelAssociation.js';
7
- import type { MessageLabelAssociationActionBody } from './LabelAssociation.js';
8
- import type { MinimalMessage, WAMessageKey } from './Message.js';
1
+ import type { proto } from '../../WAProto';
2
+ import type { AccountSettings } from './Auth';
3
+ import type { BufferedEventData } from './Events';
4
+ import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
+ import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
+ import type { MinimalMessage } from './Message';
9
7
  /** privacy settings in WhatsApp Web */
10
8
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
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
- export type WAPrivacyCallValue = 'all' | 'known';
15
- export type WAPrivacyMessagesValue = 'all' | 'contacts';
16
11
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
17
12
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
18
13
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
19
- export type WAPatchName = (typeof ALL_WA_PATCH_NAMES)[number];
14
+ export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
20
15
  export interface PresenceData {
21
16
  lastKnownPresence: WAPresence;
22
17
  lastSeen?: number;
23
18
  }
24
- export type BotListInfo = {
25
- jid: string;
26
- personaId: string;
27
- };
28
19
  export type ChatMutation = {
29
20
  syncAction: proto.ISyncActionData;
30
21
  index: string[];
@@ -51,8 +42,6 @@ export type ChatUpdate = Partial<Chat & {
51
42
  * undefined if the condition is not yet fulfilled
52
43
  * */
53
44
  conditional: (bufferedData: BufferedEventData) => boolean | undefined;
54
- /** last update time */
55
- timestamp?: number;
56
45
  }>;
57
46
  /**
58
47
  * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
@@ -70,13 +59,12 @@ export type ChatModification = {
70
59
  /** mute for duration, or provide timestamp of mute to remove*/
71
60
  mute: number | null;
72
61
  } | {
73
- clear: boolean;
74
- lastMessages: LastMessageList;
75
- } | {
76
- deleteForMe: {
77
- deleteMedia: boolean;
78
- key: WAMessageKey;
79
- timestamp: number;
62
+ clear: 'all' | {
63
+ messages: {
64
+ id: string;
65
+ fromMe?: boolean;
66
+ timestamp: number;
67
+ }[];
80
68
  };
81
69
  } | {
82
70
  star: {
@@ -92,12 +80,6 @@ export type ChatModification = {
92
80
  } | {
93
81
  delete: true;
94
82
  lastMessages: LastMessageList;
95
- } | {
96
- contact: proto.SyncActionValue.IContactAction | null;
97
- } | {
98
- disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction;
99
- } | {
100
- addLabel: LabelActionBody;
101
83
  } | {
102
84
  addChatLabel: ChatLabelAssociationActionBody;
103
85
  } | {
@@ -106,8 +88,6 @@ export type ChatModification = {
106
88
  addMessageLabel: MessageLabelAssociationActionBody;
107
89
  } | {
108
90
  removeMessageLabel: MessageLabelAssociationActionBody;
109
- } | {
110
- quickReply: QuickReplyAction;
111
91
  };
112
92
  export type InitialReceivedChatsState = {
113
93
  [jid: string]: {
@@ -120,4 +100,3 @@ export type InitialReceivedChatsState = {
120
100
  export type InitialAppStateSyncOptions = {
121
101
  accountSettings: AccountSettings;
122
102
  };
123
- //# sourceMappingURL=Chat.d.ts.map
package/lib/Types/Chat.js CHANGED
@@ -1,8 +1,4 @@
1
- export const ALL_WA_PATCH_NAMES = [
2
- 'critical_block',
3
- 'critical_unblock_low',
4
- 'regular_high',
5
- 'regular_low',
6
- 'regular'
7
- ];
8
- //# sourceMappingURL=Chat.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_WA_PATCH_NAMES = void 0;
4
+ exports.ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'];
@@ -1,10 +1,6 @@
1
1
  export interface Contact {
2
- /** ID either in lid or jid format (preferred) **/
3
2
  id: string;
4
- /** ID in LID format (@lid) **/
5
3
  lid?: string;
6
- /** ID in PN format (@s.whatsapp.net) **/
7
- phoneNumber?: 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,7 +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
  }
24
- //# sourceMappingURL=Contact.d.ts.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=Contact.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +1,14 @@
1
1
  import type { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import type { AuthenticationCreds } from './Auth.js';
4
- import type { WACallEvent } from './Call.js';
5
- import type { Chat, ChatUpdate, PresenceData } from './Chat.js';
6
- import type { Contact } from './Contact.js';
7
- import type { GroupMetadata, GroupParticipant, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata.js';
8
- import type { Label } from './Label.js';
9
- import type { LabelAssociation } from './LabelAssociation.js';
10
- import type { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message.js';
11
- import type { ConnectionState } from './State.js';
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';
12
12
  export type BaileysEventMap = {
13
13
  /** connection state has been updated -- WS closed, opened, connecting etc. */
14
14
  'connection.update': Partial<ConnectionState>;
@@ -19,18 +19,15 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest?: boolean;
23
- progress?: number | null;
24
- syncType?: proto.HistorySync.HistorySyncType | null;
25
- peerDataRequestSessionId?: string | null;
22
+ isLatest: boolean;
26
23
  };
27
24
  /** upsert chats */
28
25
  'chats.upsert': Chat[];
29
26
  /** update the given chats */
30
27
  'chats.update': ChatUpdate[];
31
- 'lid-mapping.update': {
28
+ 'chats.phoneNumberShare': {
32
29
  lid: string;
33
- pn: string;
30
+ jid: string;
34
31
  };
35
32
  /** delete chats with given ID */
36
33
  'chats.delete': string[];
@@ -61,12 +58,10 @@ export type BaileysEventMap = {
61
58
  /**
62
59
  * add/update the given messages. If they were received while the connection was online,
63
60
  * the update will have type: "notify"
64
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
65
61
  * */
66
62
  'messages.upsert': {
67
63
  messages: WAMessage[];
68
64
  type: MessageUpsertType;
69
- requestId?: string;
70
65
  };
71
66
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
72
67
  'messages.reaction': {
@@ -80,19 +75,9 @@ export type BaileysEventMap = {
80
75
  'group-participants.update': {
81
76
  id: string;
82
77
  author: string;
83
- authorPn?: string;
84
- participants: GroupParticipant[];
78
+ participants: string[];
85
79
  action: ParticipantAction;
86
80
  };
87
- 'group.join-request': {
88
- id: string;
89
- author: string;
90
- authorPn?: string;
91
- participant: string;
92
- participantPn?: string;
93
- action: RequestJoinAction;
94
- method: RequestJoinMethod;
95
- };
96
81
  'blocklist.set': {
97
82
  blocklist: string[];
98
83
  };
@@ -101,38 +86,12 @@ export type BaileysEventMap = {
101
86
  type: 'add' | 'remove';
102
87
  };
103
88
  /** Receive an update on a call, including when the call was received, rejected, accepted */
104
- call: WACallEvent[];
89
+ 'call': WACallEvent[];
105
90
  'labels.edit': Label;
106
91
  'labels.association': {
107
92
  association: LabelAssociation;
108
93
  type: 'add' | 'remove';
109
94
  };
110
- /** Newsletter-related events */
111
- 'newsletter.reaction': {
112
- id: string;
113
- server_id: string;
114
- reaction: {
115
- code?: string;
116
- count?: number;
117
- removed?: boolean;
118
- };
119
- };
120
- 'newsletter.view': {
121
- id: string;
122
- server_id: string;
123
- count: number;
124
- };
125
- 'newsletter-participants.update': {
126
- id: string;
127
- author: string;
128
- user: string;
129
- new_role: string;
130
- action: string;
131
- };
132
- 'newsletter-settings.update': {
133
- id: string;
134
- update: any;
135
- };
136
95
  };
137
96
  export type BufferedEventData = {
138
97
  historySets: {
@@ -147,9 +106,6 @@ export type BufferedEventData = {
147
106
  };
148
107
  empty: boolean;
149
108
  isLatest: boolean;
150
- progress?: number | null;
151
- syncType?: proto.HistorySync.HistorySyncType;
152
- peerDataRequestSessionId?: string;
153
109
  };
154
110
  chatUpserts: {
155
111
  [jid: string]: Chat;
@@ -199,4 +155,3 @@ export interface BaileysEventEmitter {
199
155
  removeAllListeners<T extends keyof BaileysEventMap>(event: T): void;
200
156
  emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean;
201
157
  }
202
- //# sourceMappingURL=Events.d.ts.map
@@ -1,2 +1,2 @@
1
- import { proto } from '../../WAProto/index.js';
2
- //# sourceMappingURL=Events.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,33 +1,23 @@
1
- import type { Contact } from './Contact.js';
2
- import type { WAMessageAddressingMode } from './Message.js';
3
- export type GroupParticipant = Contact & {
1
+ import { Contact } from './Contact';
2
+ export type GroupParticipant = (Contact & {
4
3
  isAdmin?: boolean;
5
4
  isSuperAdmin?: boolean;
6
5
  admin?: 'admin' | 'superadmin' | null;
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;
6
+ });
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
11
8
  export interface GroupMetadata {
12
9
  id: string;
13
- notify?: string;
14
- /** group uses 'lid' or 'pn' to send messages */
15
- addressingMode?: WAMessageAddressingMode;
16
10
  owner: string | undefined;
17
- ownerPn?: string | undefined;
18
- owner_country_code?: string | undefined;
19
11
  subject: string;
12
+ addressingMode: "pn" | "lid";
20
13
  /** group subject owner */
21
14
  subjectOwner?: string;
22
- subjectOwnerPn?: string;
23
15
  /** group subject modification date */
24
16
  subjectTime?: number;
25
17
  creation?: number;
26
18
  desc?: string;
27
19
  descOwner?: string;
28
- descOwnerPn?: string;
29
20
  descId?: string;
30
- descTime?: number;
31
21
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
32
22
  linkedParent?: string;
33
23
  /** is set when the group only allows admins to change group settings */
@@ -49,7 +39,6 @@ export interface GroupMetadata {
49
39
  inviteCode?: string;
50
40
  /** the person who added you to group or changed some setting in group */
51
41
  author?: string;
52
- authorPn?: string;
53
42
  }
54
43
  export interface WAGroupCreateResponse {
55
44
  status: number;
@@ -64,4 +53,3 @@ export interface GroupModificationResponse {
64
53
  [key: string]: {};
65
54
  };
66
55
  }
67
- //# sourceMappingURL=GroupMetadata.d.ts.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=GroupMetadata.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,17 +10,6 @@ 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
- }
24
13
  /** WhatsApp has 20 predefined colors */
25
14
  export declare enum LabelColor {
26
15
  Color1 = 0,
@@ -44,4 +33,3 @@ export declare enum LabelColor {
44
33
  Color19 = 18,
45
34
  Color20 = 19
46
35
  }
47
- //# sourceMappingURL=Label.d.ts.map
@@ -1,5 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelColor = void 0;
1
4
  /** WhatsApp has 20 predefined colors */
2
- export var LabelColor;
5
+ var LabelColor;
3
6
  (function (LabelColor) {
4
7
  LabelColor[LabelColor["Color1"] = 0] = "Color1";
5
8
  LabelColor[LabelColor["Color2"] = 1] = "Color2";
@@ -21,5 +24,4 @@ export var LabelColor;
21
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
22
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
23
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
24
- })(LabelColor || (LabelColor = {}));
25
- //# sourceMappingURL=Label.js.map
27
+ })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
@@ -27,4 +27,3 @@ export interface MessageLabelAssociationActionBody {
27
27
  labelId: string;
28
28
  messageId: string;
29
29
  }
30
- //# sourceMappingURL=LabelAssociation.d.ts.map
@@ -1,7 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelAssociationType = void 0;
1
4
  /** Association type */
2
- export var LabelAssociationType;
5
+ var LabelAssociationType;
3
6
  (function (LabelAssociationType) {
4
7
  LabelAssociationType["Chat"] = "label_jid";
5
8
  LabelAssociationType["Message"] = "label_message";
6
- })(LabelAssociationType || (LabelAssociationType = {}));
7
- //# sourceMappingURL=LabelAssociation.js.map
9
+ })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
@@ -1,46 +1,34 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { AxiosRequestConfig } from 'axios';
5
+ import type { Logger } from 'pino';
1
6
  import type { Readable } from 'stream';
2
7
  import type { URL } from 'url';
3
- import { proto } from '../../WAProto/index.js';
4
- import type { MediaType } from '../Defaults/index.js';
5
- import type { BinaryNode } from '../WABinary/index.js';
6
- import type { GroupMetadata } from './GroupMetadata.js';
7
- import type { CacheStore } from './Socket.js';
8
+ import { BinaryNode } from '../WABinary';
9
+ import { proto } from '../../WAProto';
10
+ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
11
+ import type { GroupMetadata } from './GroupMetadata';
12
+ import { CacheStore } from './Socket';
8
13
  export { proto as WAProto };
9
- export type WAMessage = proto.IWebMessageInfo & {
10
- key: WAMessageKey;
11
- messageStubParameters?: any;
12
- };
14
+ export type WAMessage = proto.IWebMessageInfo;
13
15
  export type WAMessageContent = proto.IMessage;
14
16
  export type WAContactMessage = proto.Message.IContactMessage;
15
17
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
16
- export type WAMessageKey = proto.IMessageKey & {
17
- remoteJidAlt?: string;
18
- participantAlt?: string;
19
- server_id?: string;
20
- addressingMode?: string;
21
- isViewOnce?: boolean;
22
- };
18
+ export type WAMessageKey = proto.IMessageKey;
23
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
24
20
  export type WAContextInfo = proto.IContextInfo;
25
21
  export type WALocationMessage = proto.Message.ILocationMessage;
26
22
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
27
- export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
28
- export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
29
- import type { ILogger } from '../Utils/logger.js';
30
- export type WAMediaPayloadURL = {
23
+ export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
+ export import WAMessageStatus = proto.WebMessageInfo.Status;
25
+ export type WAMediaUpload = Buffer | {
31
26
  url: URL | string;
32
- };
33
- export type WAMediaPayloadStream = {
27
+ } | {
34
28
  stream: Readable;
35
29
  };
36
- export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
37
30
  /** Set of message types that are supported by the library */
38
31
  export type MessageType = keyof proto.Message;
39
- export declare enum WAMessageAddressingMode {
40
- PN = "pn",
41
- LID = "lid"
42
- }
43
- 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';
44
32
  export type DownloadableMessage = {
45
33
  mediaKey?: Uint8Array | null;
46
34
  directPath?: string | null;
@@ -76,9 +64,26 @@ type Contextable = {
76
64
  type ViewOnce = {
77
65
  viewOnce?: boolean;
78
66
  };
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
+ };
79
76
  type Editable = {
80
77
  edit?: WAMessageKey;
81
78
  };
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
+ };
82
87
  type WithDimensions = {
83
88
  width?: number;
84
89
  height?: number;
@@ -89,19 +94,6 @@ export type PollMessageOptions = {
89
94
  values: string[];
90
95
  /** 32 byte message secret to encrypt poll selections */
91
96
  messageSecret?: Uint8Array;
92
- toAnnouncementGroup?: boolean;
93
- };
94
- export type EventMessageOptions = {
95
- name: string;
96
- description?: string;
97
- startDate: Date;
98
- endDate?: Date;
99
- location?: WALocationMessage;
100
- call?: 'audio' | 'video';
101
- isCancelled?: boolean;
102
- isScheduleCall?: boolean;
103
- extraGuestsAllowed?: boolean;
104
- messageSecret?: Uint8Array<ArrayBufferLike>;
105
97
  };
106
98
  type SharePhoneNumber = {
107
99
  sharePhoneNumber: boolean;
@@ -109,18 +101,19 @@ type SharePhoneNumber = {
109
101
  type RequestPhoneNumber = {
110
102
  requestPhoneNumber: boolean;
111
103
  };
104
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
112
105
  export type AnyMediaMessageContent = (({
113
106
  image: WAMediaUpload;
114
107
  caption?: string;
115
108
  jpegThumbnail?: string;
116
- } & Mentionable & Contextable & WithDimensions) | ({
109
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
117
110
  video: WAMediaUpload;
118
111
  caption?: string;
119
112
  gifPlayback?: boolean;
120
113
  jpegThumbnail?: string;
121
114
  /** if set to true, will send as a `video note` */
122
115
  ptv?: boolean;
123
- } & Mentionable & Contextable & WithDimensions) | {
116
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
124
117
  audio: WAMediaUpload;
125
118
  /** if set to true, will send as a `voice note` */
126
119
  ptt?: boolean;
@@ -134,7 +127,7 @@ export type AnyMediaMessageContent = (({
134
127
  mimetype: string;
135
128
  fileName?: string;
136
129
  caption?: string;
137
- } & Contextable)) & {
130
+ } & Contextable & Buttonable & Templatable)) & {
138
131
  mimetype?: string;
139
132
  } & Editable;
140
133
  export type ButtonReplyInfo = {
@@ -142,24 +135,15 @@ export type ButtonReplyInfo = {
142
135
  id: string;
143
136
  index: number;
144
137
  };
145
- export type GroupInviteInfo = {
146
- inviteCode: string;
147
- inviteExpiration: number;
148
- text: string;
149
- jid: string;
150
- subject: string;
151
- };
152
138
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
153
139
  productImage: WAMediaUpload;
154
140
  };
155
141
  export type AnyRegularMessageContent = (({
156
142
  text: string;
157
143
  linkPreview?: WAUrlInfo | null;
158
- } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | {
159
- event: EventMessageOptions;
160
- } | ({
144
+ } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
161
145
  poll: PollMessageOptions;
162
- } & Mentionable & Contextable & Editable) | {
146
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
163
147
  contacts: {
164
148
  displayName?: string;
165
149
  contacts: proto.Message.IContactMessage[];
@@ -171,17 +155,8 @@ export type AnyRegularMessageContent = (({
171
155
  } | {
172
156
  buttonReply: ButtonReplyInfo;
173
157
  type: 'template' | 'plain';
174
- } | {
175
- groupInvite: GroupInviteInfo;
176
158
  } | {
177
159
  listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
178
- } | {
179
- pin: WAMessageKey;
180
- type: proto.PinInChat.Type;
181
- /**
182
- * 24 hours, 7 days, 30 days
183
- */
184
- time?: 86400 | 604800 | 2592000;
185
160
  } | {
186
161
  product: WASendableProduct;
187
162
  businessOwnerJid?: string;
@@ -196,15 +171,13 @@ export type AnyMessageContent = AnyRegularMessageContent | {
196
171
  delete: WAMessageKey;
197
172
  } | {
198
173
  disappearingMessagesInChat: boolean | number;
199
- } | {
200
- limitSharing: boolean;
201
174
  };
202
175
  export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
203
176
  type MinimalRelayOptions = {
204
177
  /** override the message ID with a custom provided string */
205
178
  messageId?: string;
206
- /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
207
- useCachedGroupMetadata?: boolean;
179
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
180
+ cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
208
181
  };
209
182
  export type MessageRelayOptions = MinimalRelayOptions & {
210
183
  /** only send to a specific participant; used when a message decryption fails for a single user */
@@ -227,6 +200,7 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
227
200
  timestamp?: Date;
228
201
  /** the message you want to quote */
229
202
  quoted?: WAMessage;
203
+ additionalNodes?: BinaryNode[];
230
204
  /** disappearing messages settings */
231
205
  ephemeralExpiration?: number | string;
232
206
  /** timeout for media upload to WA server */
@@ -243,35 +217,32 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
243
217
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
244
218
  userJid: string;
245
219
  };
246
- export type WAMediaUploadFunction = (encFilePath: string, opts: {
220
+ export type WAMediaUploadFunctionOpts = {
247
221
  fileEncSha256B64: string;
248
222
  mediaType: MediaType;
223
+ newsletter?: boolean;
249
224
  timeoutMs?: number;
250
- }) => Promise<{
225
+ };
226
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
251
227
  mediaUrl: string;
252
228
  directPath: string;
253
- meta_hmac?: string;
254
- ts?: number;
255
- fbid?: number;
229
+ handle?: string;
256
230
  }>;
257
231
  export type MediaGenerationOptions = {
258
- logger?: ILogger;
232
+ logger?: Logger;
259
233
  mediaTypeOverride?: MediaType;
260
234
  upload: WAMediaUploadFunction;
261
235
  /** cache media so it does not have to be uploaded again */
262
236
  mediaCache?: CacheStore;
263
237
  mediaUploadTimeoutMs?: number;
264
- options?: RequestInit;
238
+ options?: AxiosRequestConfig;
265
239
  backgroundColor?: string;
266
240
  font?: number;
241
+ /** The message is for newsletter? */
242
+ newsletter?: boolean;
267
243
  };
268
244
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
269
245
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
270
- getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
271
- getCallLink?: (type: 'audio' | 'video', event?: {
272
- startTime: number;
273
- }) => Promise<string | undefined>;
274
- jid?: string;
275
246
  };
276
247
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
277
248
  /**
@@ -283,7 +254,7 @@ export type MessageUpsertType = 'append' | 'notify';
283
254
  export type MessageUserReceipt = proto.IUserReceipt;
284
255
  export type WAMessageUpdate = {
285
256
  update: Partial<WAMessage>;
286
- key: WAMessageKey;
257
+ key: proto.IMessageKey;
287
258
  };
288
259
  export type WAMessageCursor = {
289
260
  before: WAMessageKey | undefined;
@@ -291,7 +262,7 @@ export type WAMessageCursor = {
291
262
  after: WAMessageKey | undefined;
292
263
  };
293
264
  export type MessageUserReceiptUpdate = {
294
- key: WAMessageKey;
265
+ key: proto.IMessageKey;
295
266
  receipt: MessageUserReceipt;
296
267
  };
297
268
  export type MediaDecryptionKeyInfo = {
@@ -299,5 +270,4 @@ export type MediaDecryptionKeyInfo = {
299
270
  cipherKey: Buffer;
300
271
  macKey?: Buffer;
301
272
  };
302
- export type MinimalMessage = Pick<WAMessage, 'key' | 'messageTimestamp'>;
303
- //# sourceMappingURL=Message.d.ts.map
273
+ export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;