@alannxd/baileys 6.0.3 → 6.0.5

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 (234) hide show
  1. package/WAProto/GenerateStatics.sh +3 -0
  2. package/WAProto/WAProto.proto +5479 -0
  3. package/WAProto/fix-imports.js +85 -0
  4. package/WAProto/index.d.ts +14017 -0
  5. package/WAProto/index.js +201 -160
  6. package/engine-requirements.js +1 -1
  7. package/lib/Defaults/index.d.ts +37 -15
  8. package/lib/Defaults/index.js +119 -136
  9. package/lib/Signal/Group/ciphertext-message.d.ts +1 -0
  10. package/lib/Signal/Group/ciphertext-message.js +2 -5
  11. package/lib/Signal/Group/group-session-builder.d.ts +4 -3
  12. package/lib/Signal/Group/group-session-builder.js +7 -41
  13. package/lib/Signal/Group/group_cipher.d.ts +4 -4
  14. package/lib/Signal/Group/group_cipher.js +37 -51
  15. package/lib/Signal/Group/index.d.ts +12 -11
  16. package/lib/Signal/Group/index.js +12 -57
  17. package/lib/Signal/Group/keyhelper.d.ts +2 -1
  18. package/lib/Signal/Group/keyhelper.js +7 -44
  19. package/lib/Signal/Group/sender-chain-key.d.ts +3 -2
  20. package/lib/Signal/Group/sender-chain-key.js +7 -15
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +2 -1
  22. package/lib/Signal/Group/sender-key-distribution-message.js +8 -11
  23. package/lib/Signal/Group/sender-key-message.d.ts +2 -1
  24. package/lib/Signal/Group/sender-key-message.js +9 -12
  25. package/lib/Signal/Group/sender-key-name.d.ts +1 -0
  26. package/lib/Signal/Group/sender-key-name.js +2 -5
  27. package/lib/Signal/Group/sender-key-record.d.ts +3 -2
  28. package/lib/Signal/Group/sender-key-record.js +9 -21
  29. package/lib/Signal/Group/sender-key-state.d.ts +7 -6
  30. package/lib/Signal/Group/sender-key-state.js +27 -42
  31. package/lib/Signal/Group/sender-message-key.d.ts +1 -0
  32. package/lib/Signal/Group/sender-message-key.js +4 -7
  33. package/lib/Signal/libsignal.d.ts +5 -3
  34. package/lib/Signal/libsignal.js +347 -90
  35. package/lib/Signal/lid-mapping.d.ts +23 -0
  36. package/lib/Signal/lid-mapping.js +277 -0
  37. package/lib/Socket/Client/index.d.ts +3 -3
  38. package/lib/Socket/Client/index.js +3 -19
  39. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +4 -5
  40. package/lib/Socket/Client/types.js +11 -0
  41. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +3 -2
  42. package/lib/Socket/Client/websocket.js +54 -0
  43. package/lib/Socket/business.d.ts +154 -108
  44. package/lib/Socket/business.js +162 -43
  45. package/lib/Socket/chats.d.ts +96 -239
  46. package/lib/Socket/chats.js +627 -427
  47. package/lib/Socket/communities.d.ts +239 -146
  48. package/lib/Socket/communities.js +90 -80
  49. package/lib/Socket/groups.d.ts +104 -57
  50. package/lib/Socket/groups.js +154 -161
  51. package/lib/Socket/index.d.ts +202 -115
  52. package/lib/Socket/index.js +11 -10
  53. package/lib/Socket/luxu.d.ts +22 -266
  54. package/lib/Socket/luxu.js +422 -465
  55. package/lib/Socket/messages-recv.d.ts +136 -84
  56. package/lib/Socket/messages-recv.js +1421 -615
  57. package/lib/Socket/messages-send.d.ts +142 -126
  58. package/lib/Socket/messages-send.js +878 -671
  59. package/lib/Socket/mex.d.ts +3 -0
  60. package/lib/Socket/mex.js +42 -0
  61. package/lib/Socket/newsletter.d.ts +121 -85
  62. package/lib/Socket/newsletter.js +147 -272
  63. package/lib/Socket/socket.d.ts +34 -19
  64. package/lib/Socket/socket.js +544 -313
  65. package/lib/Store/index.d.ts +10 -3
  66. package/lib/Store/index.js +10 -10
  67. package/lib/Store/keyed-db.d.ts +22 -0
  68. package/lib/Store/keyed-db.js +108 -0
  69. package/lib/Store/make-cache-manager-store.d.ts +17 -11
  70. package/lib/Store/make-cache-manager-store.js +43 -41
  71. package/lib/Store/make-in-memory-store.d.ts +39 -118
  72. package/lib/Store/make-in-memory-store.js +112 -341
  73. package/lib/Store/make-ordered-dictionary.d.ts +11 -10
  74. package/lib/Store/make-ordered-dictionary.js +14 -20
  75. package/lib/Store/object-repository.d.ts +10 -9
  76. package/lib/Store/object-repository.js +11 -6
  77. package/lib/Types/Auth.d.ts +19 -12
  78. package/lib/Types/Auth.js +2 -2
  79. package/lib/Types/Bussines.d.ts +25 -0
  80. package/lib/Types/Bussines.js +2 -0
  81. package/lib/Types/Call.d.ts +3 -1
  82. package/lib/Types/Call.js +2 -2
  83. package/lib/Types/Chat.d.ts +35 -13
  84. package/lib/Types/Chat.js +8 -4
  85. package/lib/Types/Contact.d.ts +8 -1
  86. package/lib/Types/Contact.js +2 -2
  87. package/lib/Types/Events.d.ts +116 -17
  88. package/lib/Types/Events.js +2 -2
  89. package/lib/Types/GroupMetadata.d.ts +21 -5
  90. package/lib/Types/GroupMetadata.js +2 -2
  91. package/lib/Types/Label.d.ts +12 -0
  92. package/lib/Types/Label.js +3 -5
  93. package/lib/Types/LabelAssociation.d.ts +1 -0
  94. package/lib/Types/LabelAssociation.js +3 -5
  95. package/lib/Types/Message.d.ts +105 -58
  96. package/lib/Types/Message.js +11 -9
  97. package/lib/Types/Mex.d.ts +141 -0
  98. package/lib/Types/Mex.js +37 -0
  99. package/lib/Types/Product.d.ts +2 -1
  100. package/lib/Types/Product.js +2 -2
  101. package/lib/Types/Signal.d.ts +32 -2
  102. package/lib/Types/Signal.js +2 -2
  103. package/lib/Types/Socket.d.ts +50 -25
  104. package/lib/Types/Socket.js +3 -2
  105. package/lib/Types/State.d.ts +72 -2
  106. package/lib/Types/State.js +56 -2
  107. package/lib/Types/USync.d.ts +3 -2
  108. package/lib/Types/USync.js +2 -2
  109. package/lib/Types/index.d.ts +22 -14
  110. package/lib/Types/index.js +15 -31
  111. package/lib/Utils/auth-utils.d.ts +12 -6
  112. package/lib/Utils/auth-utils.js +239 -143
  113. package/lib/Utils/browser-utils.d.ts +4 -0
  114. package/lib/Utils/browser-utils.js +28 -0
  115. package/lib/Utils/business.d.ts +3 -2
  116. package/lib/Utils/business.js +66 -69
  117. package/lib/Utils/chat-utils.d.ts +52 -23
  118. package/lib/Utils/chat-utils.js +396 -253
  119. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  120. package/lib/Utils/companion-reg-client-utils.js +35 -0
  121. package/lib/Utils/crypto.d.ts +18 -22
  122. package/lib/Utils/crypto.js +57 -90
  123. package/lib/Utils/decode-wa-message.d.ts +55 -8
  124. package/lib/Utils/decode-wa-message.js +203 -84
  125. package/lib/Utils/event-buffer.d.ts +9 -8
  126. package/lib/Utils/event-buffer.js +185 -77
  127. package/lib/Utils/generics.d.ts +28 -29
  128. package/lib/Utils/generics.js +180 -210
  129. package/lib/Utils/history.d.ts +18 -9
  130. package/lib/Utils/history.js +93 -55
  131. package/lib/Utils/identity-change-handler.d.ts +44 -0
  132. package/lib/Utils/identity-change-handler.js +50 -0
  133. package/lib/Utils/index.d.ts +22 -17
  134. package/lib/Utils/index.js +22 -33
  135. package/lib/Utils/link-preview.d.ts +5 -5
  136. package/lib/Utils/link-preview.js +16 -24
  137. package/lib/Utils/logger.d.ts +11 -3
  138. package/lib/Utils/logger.js +3 -7
  139. package/lib/Utils/lt-hash.d.ts +8 -12
  140. package/lib/Utils/lt-hash.js +3 -46
  141. package/lib/Utils/make-mutex.d.ts +4 -2
  142. package/lib/Utils/make-mutex.js +24 -34
  143. package/lib/Utils/message-retry-manager.d.ts +115 -0
  144. package/lib/Utils/message-retry-manager.js +265 -0
  145. package/lib/Utils/messages-media.d.ts +61 -44
  146. package/lib/Utils/messages-media.js +451 -482
  147. package/lib/Utils/messages.d.ts +32 -18
  148. package/lib/Utils/messages.js +458 -369
  149. package/lib/Utils/noise-handler.d.ts +13 -14
  150. package/lib/Utils/noise-handler.js +145 -99
  151. package/lib/Utils/offline-node-processor.d.ts +17 -0
  152. package/lib/Utils/offline-node-processor.js +40 -0
  153. package/lib/Utils/pre-key-manager.d.ts +28 -0
  154. package/lib/Utils/pre-key-manager.js +106 -0
  155. package/lib/Utils/process-message.d.ts +31 -12
  156. package/lib/Utils/process-message.js +459 -150
  157. package/lib/Utils/reporting-utils.d.ts +11 -0
  158. package/lib/Utils/reporting-utils.js +258 -0
  159. package/lib/Utils/signal.d.ts +20 -5
  160. package/lib/Utils/signal.js +120 -72
  161. package/lib/Utils/stanza-ack.d.ts +11 -0
  162. package/lib/Utils/stanza-ack.js +38 -0
  163. package/lib/Utils/sync-action-utils.d.ts +19 -0
  164. package/lib/Utils/sync-action-utils.js +49 -0
  165. package/lib/Utils/tc-token-utils.d.ts +37 -0
  166. package/lib/Utils/tc-token-utils.js +163 -0
  167. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -2
  168. package/lib/Utils/use-multi-file-auth-state.js +29 -27
  169. package/lib/Utils/validate-connection.d.ts +7 -7
  170. package/lib/Utils/validate-connection.js +73 -99
  171. package/lib/WABinary/constants.d.ts +25 -27
  172. package/lib/WABinary/constants.js +1281 -20
  173. package/lib/WABinary/decode.d.ts +5 -5
  174. package/lib/WABinary/decode.js +52 -42
  175. package/lib/WABinary/encode.d.ts +3 -3
  176. package/lib/WABinary/encode.js +110 -155
  177. package/lib/WABinary/generic-utils.d.ts +8 -7
  178. package/lib/WABinary/generic-utils.js +48 -49
  179. package/lib/WABinary/index.d.ts +6 -5
  180. package/lib/WABinary/index.js +6 -21
  181. package/lib/WABinary/jid-utils.d.ts +25 -8
  182. package/lib/WABinary/jid-utils.js +74 -40
  183. package/lib/WABinary/types.d.ts +2 -1
  184. package/lib/WABinary/types.js +2 -2
  185. package/lib/WAM/BinaryInfo.d.ts +3 -11
  186. package/lib/WAM/BinaryInfo.js +2 -5
  187. package/lib/WAM/constants.d.ts +5 -3
  188. package/lib/WAM/constants.js +19071 -11568
  189. package/lib/WAM/encode.d.ts +3 -3
  190. package/lib/WAM/encode.js +17 -22
  191. package/lib/WAM/index.d.ts +4 -3
  192. package/lib/WAM/index.js +4 -19
  193. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +4 -3
  194. package/lib/WAUSync/Protocols/USyncContactProtocol.js +33 -13
  195. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +3 -2
  196. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
  197. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +3 -2
  198. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
  199. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +3 -2
  200. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
  201. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  202. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  203. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +4 -3
  204. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
  205. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +5 -3
  206. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -8
  207. package/lib/WAUSync/Protocols/index.d.ts +6 -4
  208. package/lib/WAUSync/Protocols/index.js +6 -20
  209. package/lib/WAUSync/USyncQuery.d.ts +6 -4
  210. package/lib/WAUSync/USyncQuery.js +44 -35
  211. package/lib/WAUSync/USyncUser.d.ts +10 -5
  212. package/lib/WAUSync/USyncUser.js +10 -5
  213. package/lib/WAUSync/index.d.ts +4 -0
  214. package/lib/WAUSync/index.js +4 -19
  215. package/lib/index.d.ts +10 -9
  216. package/lib/index.js +12 -34
  217. package/package.json +84 -53
  218. package/WAProto/fix-import.js +0 -29
  219. package/lib/Defaults/baileys-version.json +0 -3
  220. package/lib/Defaults/phonenumber-mcc.json +0 -223
  221. package/lib/Signal/Group/queue-job.d.ts +0 -1
  222. package/lib/Signal/Group/queue-job.js +0 -57
  223. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  224. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  225. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  226. package/lib/Socket/Client/web-socket-client.js +0 -62
  227. package/lib/Socket/registration.d.ts +0 -267
  228. package/lib/Socket/registration.js +0 -166
  229. package/lib/Socket/usync.d.ts +0 -36
  230. package/lib/Socket/usync.js +0 -70
  231. package/lib/Types/Newsletter.d.ts +0 -103
  232. package/lib/Types/Newsletter.js +0 -38
  233. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  234. package/lib/Utils/baileys-event-stream.js +0 -63
@@ -1,27 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectRepository = void 0;
4
- class ObjectRepository {
1
+ export class ObjectRepository {
5
2
  constructor(entities = {}) {
6
3
  this.entityMap = new Map(Object.entries(entities));
7
4
  }
5
+
8
6
  findById(id) {
9
7
  return this.entityMap.get(id);
10
8
  }
9
+
11
10
  findAll() {
12
11
  return Array.from(this.entityMap.values());
13
12
  }
13
+
14
14
  upsertById(id, entity) {
15
- return this.entityMap.set(id, { ...entity });
15
+ this.entityMap.set(id, { ...entity });
16
+ return this;
16
17
  }
18
+
17
19
  deleteById(id) {
18
20
  return this.entityMap.delete(id);
19
21
  }
22
+
20
23
  count() {
21
24
  return this.entityMap.size;
22
25
  }
26
+
23
27
  toJSON() {
24
28
  return this.findAll();
25
29
  }
26
30
  }
27
- exports.ObjectRepository = ObjectRepository;
31
+
32
+ export default ObjectRepository;
@@ -1,8 +1,6 @@
1
- /// <reference types="node" />
2
- import type { proto } from '../../WAProto';
3
- import { RegistrationOptions } from '../Socket/registration';
4
- import type { Contact } from './Contact';
5
- import type { MinimalMessage } from './Message';
1
+ import type { proto } from '../../WAProto/index.js';
2
+ import type { Contact } from './Contact.js';
3
+ import type { MinimalMessage } from './Message.js';
6
4
  export type KeyPair = {
7
5
  public: Uint8Array;
8
6
  private: Uint8Array;
@@ -21,6 +19,10 @@ export type SignalIdentity = {
21
19
  identifier: ProtocolAddress;
22
20
  identifierKey: Uint8Array;
23
21
  };
22
+ export type LIDMapping = {
23
+ pn: string;
24
+ lid: string;
25
+ };
24
26
  export type LTHashState = {
25
27
  version: number;
26
28
  hash: Buffer;
@@ -57,25 +59,29 @@ export type AuthenticationCreds = SignalCreds & {
57
59
  /** number of times history & app state has been synced */
58
60
  accountSyncCounter: number;
59
61
  accountSettings: AccountSettings;
60
- deviceId: string;
61
- phoneId: string;
62
- identityId: Buffer;
63
62
  registered: boolean;
64
- backupToken: Buffer;
65
- registration: RegistrationOptions;
66
63
  pairingCode: string | undefined;
67
64
  lastPropHash: string | undefined;
68
65
  routingInfo: Buffer | undefined;
66
+ additionalData?: any | undefined;
69
67
  };
70
68
  export type SignalDataTypeMap = {
71
69
  'pre-key': KeyPair;
72
- 'session': Uint8Array;
70
+ session: Uint8Array;
73
71
  'sender-key': Uint8Array;
74
72
  'sender-key-memory': {
75
73
  [jid: string]: boolean;
76
74
  };
77
75
  'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
78
76
  'app-state-sync-version': LTHashState;
77
+ 'lid-mapping': string;
78
+ 'device-list': string[];
79
+ tctoken: {
80
+ token: Buffer;
81
+ timestamp?: string;
82
+ senderTimestamp?: number;
83
+ };
84
+ 'identity-key': Uint8Array;
79
85
  };
80
86
  export type SignalDataSet = {
81
87
  [T in keyof SignalDataTypeMap]?: {
@@ -93,7 +99,7 @@ export type SignalKeyStore = {
93
99
  };
94
100
  export type SignalKeyStoreWithTransaction = SignalKeyStore & {
95
101
  isInTransaction: () => boolean;
96
- transaction<T>(exec: () => Promise<T>): Promise<T>;
102
+ transaction<T>(exec: () => Promise<T>, key: string): Promise<T>;
97
103
  };
98
104
  export type TransactionCapabilityOptions = {
99
105
  maxCommitRetries: number;
@@ -108,3 +114,4 @@ export type AuthenticationState = {
108
114
  keys: SignalKeyStore;
109
115
  };
110
116
  export {};
117
+ //# sourceMappingURL=Auth.d.ts.map
package/lib/Types/Auth.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=Auth.js.map
@@ -0,0 +1,25 @@
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
+ };
25
+ //# sourceMappingURL=Bussines.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Bussines.js.map
@@ -1,7 +1,8 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'preaccept' | 'transport' | 'relaylatency' | 'timeout' | 'reject' | 'accept' | 'terminate';
2
2
  export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
5
+ callerPn?: string;
5
6
  isGroup?: boolean;
6
7
  groupJid?: string;
7
8
  id: string;
@@ -11,3 +12,4 @@ export type WACallEvent = {
11
12
  offline: boolean;
12
13
  latencyMs?: number;
13
14
  };
15
+ //# sourceMappingURL=Call.d.ts.map
package/lib/Types/Call.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=Call.js.map
@@ -1,21 +1,31 @@
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';
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';
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;
23
+ groupOnlineCount?: number;
18
24
  }
25
+ export type BotListInfo = {
26
+ jid: string;
27
+ personaId: string;
28
+ };
19
29
  export type ChatMutation = {
20
30
  syncAction: proto.ISyncActionData;
21
31
  index: string[];
@@ -42,6 +52,8 @@ export type ChatUpdate = Partial<Chat & {
42
52
  * undefined if the condition is not yet fulfilled
43
53
  * */
44
54
  conditional: (bufferedData: BufferedEventData) => boolean | undefined;
55
+ /** last update time */
56
+ timestamp?: number;
45
57
  }>;
46
58
  /**
47
59
  * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
@@ -59,12 +71,13 @@ export type ChatModification = {
59
71
  /** mute for duration, or provide timestamp of mute to remove*/
60
72
  mute: number | null;
61
73
  } | {
62
- clear: 'all' | {
63
- messages: {
64
- id: string;
65
- fromMe?: boolean;
66
- timestamp: number;
67
- }[];
74
+ clear: boolean;
75
+ lastMessages: LastMessageList;
76
+ } | {
77
+ deleteForMe: {
78
+ deleteMedia: boolean;
79
+ key: WAMessageKey;
80
+ timestamp: number;
68
81
  };
69
82
  } | {
70
83
  star: {
@@ -80,6 +93,12 @@ export type ChatModification = {
80
93
  } | {
81
94
  delete: true;
82
95
  lastMessages: LastMessageList;
96
+ } | {
97
+ contact: proto.SyncActionValue.IContactAction | null;
98
+ } | {
99
+ disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction;
100
+ } | {
101
+ addLabel: LabelActionBody;
83
102
  } | {
84
103
  addChatLabel: ChatLabelAssociationActionBody;
85
104
  } | {
@@ -88,6 +107,8 @@ export type ChatModification = {
88
107
  addMessageLabel: MessageLabelAssociationActionBody;
89
108
  } | {
90
109
  removeMessageLabel: MessageLabelAssociationActionBody;
110
+ } | {
111
+ quickReply: QuickReplyAction;
91
112
  };
92
113
  export type InitialReceivedChatsState = {
93
114
  [jid: string]: {
@@ -100,3 +121,4 @@ export type InitialReceivedChatsState = {
100
121
  export type InitialAppStateSyncOptions = {
101
122
  accountSettings: AccountSettings;
102
123
  };
124
+ //# sourceMappingURL=Chat.d.ts.map
package/lib/Types/Chat.js CHANGED
@@ -1,4 +1,8 @@
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
+ 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,10 +1,16 @@
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 */
7
11
  notify?: string;
12
+ /** username associated with this contact, when provided by WA */
13
+ username?: string;
8
14
  /** I have no idea */
9
15
  verifiedName?: string;
10
16
  /**
@@ -14,6 +20,7 @@ export interface Contact {
14
20
  * null => if the profile picture has not been set (default profile picture)
15
21
  * any other string => url of the profile picture
16
22
  */
17
- imgUrl?: string | null | 'changed';
23
+ imgUrl?: string | null;
18
24
  status?: string;
19
25
  }
26
+ //# sourceMappingURL=Contact.d.ts.map
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=Contact.js.map
@@ -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, LIDMapping } 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, NewChatMessageCapInfo } from './State.js';
12
12
  export type BaileysEventMap = {
13
13
  /** connection state has been updated -- WS closed, opened, connecting etc. */
14
14
  'connection.update': Partial<ConnectionState>;
@@ -19,16 +19,31 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest: boolean;
22
+ lidPnMappings?: LIDMapping[];
23
+ isLatest?: boolean;
24
+ progress?: number | null;
25
+ syncType?: proto.HistorySync.HistorySyncType | null;
26
+ pastParticipants?: proto.IPastParticipants[] | null;
27
+ chunkOrder?: number | null;
28
+ peerDataRequestSessionId?: string | null;
29
+ };
30
+ /** signals history sync milestones (completion or stall) per sync type */
31
+ 'messaging-history.status': {
32
+ /** which sync phase this status refers to */
33
+ syncType: proto.HistorySync.HistorySyncType;
34
+ /** the status of this sync phase */
35
+ status: 'complete' | 'paused';
36
+ /**
37
+ * progress === 100 was received from the server.
38
+ * when false, completion was inferred via timeout (no more chunks arriving).
39
+ */
40
+ explicit: boolean;
23
41
  };
24
42
  /** upsert chats */
25
43
  'chats.upsert': Chat[];
26
44
  /** update the given chats */
27
45
  'chats.update': ChatUpdate[];
28
- 'chats.phoneNumberShare': {
29
- lid: string;
30
- jid: string;
31
- };
46
+ 'lid-mapping.update': LIDMapping;
32
47
  /** delete chats with given ID */
33
48
  'chats.delete': string[];
34
49
  /** presence of contact in a chat updated */
@@ -58,10 +73,12 @@ export type BaileysEventMap = {
58
73
  /**
59
74
  * add/update the given messages. If they were received while the connection was online,
60
75
  * the update will have type: "notify"
76
+ * if requestId is provided, then the messages was received from the phone due to it being unavailable
61
77
  * */
62
78
  'messages.upsert': {
63
79
  messages: WAMessage[];
64
80
  type: MessageUpsertType;
81
+ requestId?: string;
65
82
  };
66
83
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
67
84
  'messages.reaction': {
@@ -75,9 +92,28 @@ export type BaileysEventMap = {
75
92
  'group-participants.update': {
76
93
  id: string;
77
94
  author: string;
78
- participants: string[];
95
+ authorPn?: string;
96
+ authorUsername?: string;
97
+ participants: GroupParticipant[];
79
98
  action: ParticipantAction;
80
99
  };
100
+ 'group.join-request': {
101
+ id: string;
102
+ author: string;
103
+ authorPn?: string;
104
+ authorUsername?: string;
105
+ participant: string;
106
+ participantPn?: string;
107
+ action: RequestJoinAction;
108
+ method: RequestJoinMethod;
109
+ };
110
+ 'group.member-tag.update': {
111
+ groupId: string;
112
+ participant: string;
113
+ participantAlt?: string;
114
+ label: string;
115
+ messageTimestamp?: number;
116
+ };
81
117
  'blocklist.set': {
82
118
  blocklist: string[];
83
119
  };
@@ -86,12 +122,69 @@ export type BaileysEventMap = {
86
122
  type: 'add' | 'remove';
87
123
  };
88
124
  /** Receive an update on a call, including when the call was received, rejected, accepted */
89
- 'call': WACallEvent[];
125
+ call: WACallEvent[];
90
126
  'labels.edit': Label;
91
127
  'labels.association': {
92
128
  association: LabelAssociation;
93
129
  type: 'add' | 'remove';
94
130
  };
131
+ /** Newsletter-related events */
132
+ 'newsletter.reaction': {
133
+ id: string;
134
+ server_id: string;
135
+ reaction: {
136
+ code?: string;
137
+ count?: number;
138
+ removed?: boolean;
139
+ };
140
+ };
141
+ 'newsletter.view': {
142
+ id: string;
143
+ server_id: string;
144
+ count: number;
145
+ };
146
+ 'newsletter-participants.update': {
147
+ id: string;
148
+ author: string;
149
+ user: string;
150
+ new_role: string;
151
+ action: string;
152
+ };
153
+ 'newsletter-settings.update': {
154
+ id: string;
155
+ update: any;
156
+ };
157
+ 'message-capping.update': NewChatMessageCapInfo;
158
+ /** Settings and actions sync events */
159
+ 'chats.lock': {
160
+ id: string;
161
+ locked: boolean;
162
+ };
163
+ 'settings.update': {
164
+ setting: 'unarchiveChats';
165
+ value: boolean;
166
+ } | {
167
+ setting: 'locale';
168
+ value: string;
169
+ } | {
170
+ setting: 'disableLinkPreviews';
171
+ value: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction;
172
+ } | {
173
+ setting: 'timeFormat';
174
+ value: proto.SyncActionValue.ITimeFormatAction;
175
+ } | {
176
+ setting: 'privacySettingRelayAllCalls';
177
+ value: proto.SyncActionValue.IPrivacySettingRelayAllCalls;
178
+ } | {
179
+ setting: 'statusPrivacy';
180
+ value: proto.SyncActionValue.IStatusPrivacyAction;
181
+ } | {
182
+ setting: 'notificationActivitySetting';
183
+ value: proto.SyncActionValue.NotificationActivitySettingAction.NotificationActivitySetting;
184
+ } | {
185
+ setting: 'channelsPersonalisedRecommendation';
186
+ value: proto.SyncActionValue.IPrivacySettingChannelsPersonalisedRecommendationAction;
187
+ };
95
188
  };
96
189
  export type BufferedEventData = {
97
190
  historySets: {
@@ -106,6 +199,11 @@ export type BufferedEventData = {
106
199
  };
107
200
  empty: boolean;
108
201
  isLatest: boolean;
202
+ progress?: number | null;
203
+ syncType?: proto.HistorySync.HistorySyncType;
204
+ pastParticipants?: proto.IPastParticipants[];
205
+ chunkOrder?: number | null;
206
+ peerDataRequestSessionId?: string;
109
207
  };
110
208
  chatUpserts: {
111
209
  [jid: string]: Chat;
@@ -155,3 +253,4 @@ export interface BaileysEventEmitter {
155
253
  removeAllListeners<T extends keyof BaileysEventMap>(event: T): void;
156
254
  emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean;
157
255
  }
256
+ //# sourceMappingURL=Events.d.ts.map
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ import { proto } from '../../WAProto/index.js';
2
+ //# sourceMappingURL=Events.js.map
@@ -1,23 +1,36 @@
1
- import { Contact } from './Contact';
2
- export type GroupParticipant = (Contact & {
1
+ import type { Contact } from './Contact.js';
2
+ import type { WAMessageAddressingMode } from './Message.js';
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
+ ownerUsername?: string | undefined;
19
+ owner_country_code?: string | undefined;
11
20
  subject: string;
12
- addressingMode: "pn" | "lid";
13
21
  /** group subject owner */
14
22
  subjectOwner?: string;
23
+ subjectOwnerPn?: string;
24
+ subjectOwnerUsername?: string;
15
25
  /** group subject modification date */
16
26
  subjectTime?: number;
17
27
  creation?: number;
18
28
  desc?: string;
19
29
  descOwner?: string;
30
+ descOwnerPn?: string;
31
+ descOwnerUsername?: string;
20
32
  descId?: string;
33
+ descTime?: number;
21
34
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
22
35
  linkedParent?: string;
23
36
  /** is set when the group only allows admins to change group settings */
@@ -39,6 +52,8 @@ export interface GroupMetadata {
39
52
  inviteCode?: string;
40
53
  /** the person who added you to group or changed some setting in group */
41
54
  author?: string;
55
+ authorPn?: string;
56
+ authorUsername?: string;
42
57
  }
43
58
  export interface WAGroupCreateResponse {
44
59
  status: number;
@@ -53,3 +68,4 @@ export interface GroupModificationResponse {
53
68
  [key: string]: {};
54
69
  };
55
70
  }
71
+ //# sourceMappingURL=GroupMetadata.d.ts.map
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=GroupMetadata.js.map
@@ -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,
@@ -33,3 +44,4 @@ export declare enum LabelColor {
33
44
  Color19 = 18,
34
45
  Color20 = 19
35
46
  }
47
+ //# sourceMappingURL=Label.d.ts.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LabelColor = void 0;
4
1
  /** WhatsApp has 20 predefined colors */
5
- var LabelColor;
2
+ export var LabelColor;
6
3
  (function (LabelColor) {
7
4
  LabelColor[LabelColor["Color1"] = 0] = "Color1";
8
5
  LabelColor[LabelColor["Color2"] = 1] = "Color2";
@@ -24,4 +21,5 @@ var LabelColor;
24
21
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
22
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
23
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
24
+ })(LabelColor || (LabelColor = {}));
25
+ //# sourceMappingURL=Label.js.map
@@ -27,3 +27,4 @@ export interface MessageLabelAssociationActionBody {
27
27
  labelId: string;
28
28
  messageId: string;
29
29
  }
30
+ //# sourceMappingURL=LabelAssociation.d.ts.map
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LabelAssociationType = void 0;
4
1
  /** Association type */
5
- var LabelAssociationType;
2
+ export var LabelAssociationType;
6
3
  (function (LabelAssociationType) {
7
4
  LabelAssociationType["Chat"] = "label_jid";
8
5
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
6
+ })(LabelAssociationType || (LabelAssociationType = {}));
7
+ //# sourceMappingURL=LabelAssociation.js.map