@skyzopedia/baileys-mod 5.0.7 → 6.0.0

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 (210) hide show
  1. package/WAProto/index.js +133384 -57814
  2. package/engine-requirements.js +10 -0
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +53 -0
  5. package/lib/Defaults/index.js +141 -117
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +14 -12
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +42 -10
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +87 -75
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -13
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +52 -17
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +33 -27
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +63 -62
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +66 -65
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +44 -45
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +49 -39
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +93 -80
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/lib/Signal/Group/sender-message-key.js +28 -27
  33. package/lib/Signal/libsignal.d.ts +3 -0
  34. package/lib/Signal/libsignal.js +163 -313
  35. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  36. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +19 -4
  39. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  40. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  41. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  42. package/lib/Socket/Client/web-socket-client.js +62 -0
  43. package/lib/Socket/business.d.ts +171 -0
  44. package/lib/Socket/business.js +242 -359
  45. package/lib/Socket/chats.d.ts +267 -0
  46. package/lib/Socket/chats.js +935 -846
  47. package/lib/Socket/dugong.d.ts +254 -0
  48. package/lib/Socket/dugong.js +484 -0
  49. package/lib/Socket/groups.d.ts +115 -0
  50. package/lib/Socket/groups.js +309 -304
  51. package/lib/Socket/index.d.ts +173 -0
  52. package/lib/Socket/index.js +10 -15
  53. package/lib/Socket/messages-recv.d.ts +161 -0
  54. package/lib/Socket/messages-recv.js +1054 -1107
  55. package/lib/Socket/messages-send.d.ts +149 -0
  56. package/lib/Socket/messages-send.js +447 -706
  57. package/lib/Socket/newsletter.d.ts +134 -0
  58. package/lib/Socket/newsletter.js +314 -199
  59. package/lib/Socket/registration.d.ts +267 -0
  60. package/lib/Socket/registration.js +166 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +650 -777
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +70 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +10 -6
  67. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  68. package/lib/Store/make-cache-manager-store.js +81 -73
  69. package/lib/Store/make-in-memory-store.d.ts +118 -0
  70. package/lib/Store/make-in-memory-store.js +423 -286
  71. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  72. package/lib/Store/make-ordered-dictionary.js +79 -77
  73. package/lib/Store/object-repository.d.ts +10 -0
  74. package/lib/Store/object-repository.js +26 -24
  75. package/lib/Types/Auth.d.ts +110 -0
  76. package/lib/Types/Auth.js +2 -3
  77. package/lib/Types/Call.d.ts +13 -0
  78. package/lib/Types/Call.js +2 -3
  79. package/lib/Types/Chat.d.ts +102 -0
  80. package/lib/Types/Chat.js +4 -9
  81. package/lib/Types/Contact.d.ts +19 -0
  82. package/lib/Types/Contact.js +2 -3
  83. package/lib/Types/Events.d.ts +157 -0
  84. package/lib/Types/Events.js +2 -3
  85. package/lib/Types/GroupMetadata.d.ts +55 -0
  86. package/lib/Types/GroupMetadata.js +2 -3
  87. package/lib/Types/Label.d.ts +35 -0
  88. package/lib/Types/Label.js +26 -24
  89. package/lib/Types/LabelAssociation.d.ts +29 -0
  90. package/lib/Types/LabelAssociation.js +8 -6
  91. package/lib/Types/Message.d.ts +273 -0
  92. package/lib/Types/Message.js +9 -12
  93. package/lib/Types/Newsletter.d.ts +103 -0
  94. package/lib/Types/Newsletter.js +38 -33
  95. package/lib/Types/Product.d.ts +78 -0
  96. package/lib/Types/Product.js +2 -3
  97. package/lib/Types/Signal.d.ts +57 -0
  98. package/lib/Types/Signal.js +2 -3
  99. package/lib/Types/Socket.d.ts +111 -0
  100. package/lib/Types/Socket.js +2 -4
  101. package/lib/Types/State.d.ts +27 -0
  102. package/lib/Types/State.js +2 -11
  103. package/lib/Types/USync.d.ts +25 -0
  104. package/lib/Types/USync.js +2 -3
  105. package/lib/Types/index.d.ts +57 -0
  106. package/lib/Types/index.js +41 -27
  107. package/lib/Utils/auth-utils.d.ts +18 -0
  108. package/lib/Utils/auth-utils.js +198 -211
  109. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  110. package/lib/Utils/baileys-event-stream.js +61 -42
  111. package/lib/Utils/business.d.ts +22 -0
  112. package/lib/Utils/business.js +214 -213
  113. package/lib/Utils/chat-utils.d.ts +71 -0
  114. package/lib/Utils/chat-utils.js +687 -710
  115. package/lib/Utils/crypto.d.ts +41 -0
  116. package/lib/Utils/crypto.js +133 -112
  117. package/lib/Utils/decode-wa-message.d.ts +19 -0
  118. package/lib/Utils/decode-wa-message.js +183 -252
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +496 -510
  121. package/lib/Utils/generics.d.ts +92 -0
  122. package/lib/Utils/generics.js +387 -319
  123. package/lib/Utils/history.d.ts +15 -0
  124. package/lib/Utils/history.js +92 -83
  125. package/lib/Utils/index.d.ts +17 -0
  126. package/lib/Utils/index.js +33 -21
  127. package/lib/Utils/link-preview.d.ts +21 -0
  128. package/lib/Utils/link-preview.js +83 -71
  129. package/lib/Utils/logger.d.ts +4 -0
  130. package/lib/Utils/logger.js +7 -5
  131. package/lib/Utils/lt-hash.d.ts +12 -0
  132. package/lib/Utils/lt-hash.js +46 -40
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +41 -34
  135. package/lib/Utils/messages-media.d.ts +116 -0
  136. package/lib/Utils/messages-media.js +768 -550
  137. package/lib/Utils/messages.d.ts +77 -0
  138. package/lib/Utils/messages.js +263 -362
  139. package/lib/Utils/noise-handler.d.ts +21 -0
  140. package/lib/Utils/noise-handler.js +149 -138
  141. package/lib/Utils/process-message.d.ts +41 -0
  142. package/lib/Utils/process-message.js +303 -323
  143. package/lib/Utils/signal.d.ts +32 -0
  144. package/lib/Utils/signal.js +141 -149
  145. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  146. package/lib/Utils/use-multi-file-auth-state.js +103 -95
  147. package/lib/Utils/validate-connection.d.ts +11 -0
  148. package/lib/Utils/validate-connection.js +220 -183
  149. package/lib/WABinary/constants.d.ts +30 -0
  150. package/lib/WABinary/constants.js +35 -1298
  151. package/lib/WABinary/decode.d.ts +7 -0
  152. package/lib/WABinary/decode.js +249 -237
  153. package/lib/WABinary/encode.d.ts +3 -0
  154. package/lib/WABinary/encode.js +260 -213
  155. package/lib/WABinary/generic-utils.d.ts +17 -0
  156. package/lib/WABinary/generic-utils.js +65 -56
  157. package/lib/WABinary/index.d.ts +5 -0
  158. package/lib/WABinary/index.js +21 -7
  159. package/lib/WABinary/jid-utils.d.ts +31 -0
  160. package/lib/WABinary/jid-utils.js +58 -89
  161. package/lib/WABinary/types.d.ts +18 -0
  162. package/lib/WABinary/types.js +2 -3
  163. package/lib/WAM/BinaryInfo.d.ts +17 -0
  164. package/lib/WAM/BinaryInfo.js +12 -10
  165. package/lib/WAM/constants.d.ts +38 -0
  166. package/lib/WAM/constants.js +15348 -22851
  167. package/lib/WAM/encode.d.ts +3 -0
  168. package/lib/WAM/encode.js +136 -135
  169. package/lib/WAM/index.d.ts +3 -0
  170. package/lib/WAM/index.js +19 -5
  171. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  172. package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -28
  173. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  174. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -49
  175. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  176. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -27
  177. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  178. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -36
  179. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  180. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
  181. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  182. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +20 -26
  183. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  184. package/lib/WAUSync/Protocols/index.js +20 -6
  185. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  186. package/lib/WAUSync/USyncQuery.js +85 -86
  187. package/lib/WAUSync/USyncUser.d.ts +12 -0
  188. package/lib/WAUSync/USyncUser.js +25 -23
  189. package/lib/WAUSync/index.d.ts +3 -0
  190. package/lib/WAUSync/index.js +19 -5
  191. package/lib/index.d.ts +12 -0
  192. package/lib/index.js +36 -24
  193. package/package.json +106 -98
  194. package/LICENSE +0 -21
  195. package/WAProto/WAProto.proto +0 -5311
  196. package/lib/KeyDB/BinarySearch.js +0 -20
  197. package/lib/KeyDB/KeyedDB.js +0 -167
  198. package/lib/KeyDB/index.js +0 -4
  199. package/lib/Signal/lid-mapping.js +0 -155
  200. package/lib/Socket/Client/types.js +0 -13
  201. package/lib/Socket/Client/websocket.js +0 -52
  202. package/lib/Socket/Client/websocket.js.bak +0 -53
  203. package/lib/Socket/communities.js +0 -413
  204. package/lib/Socket/mex.js +0 -45
  205. package/lib/Types/Bussines.js +0 -3
  206. package/lib/Types/Newsletter.js.bak +0 -33
  207. package/lib/Utils/browser-utils.js +0 -25
  208. package/lib/Utils/message-retry-manager.js +0 -113
  209. package/lib/Utils/messages.js.bak +0 -907
  210. package/lib/Utils/pre-key-manager.js +0 -85
@@ -0,0 +1,55 @@
1
+ import { Contact } from './Contact';
2
+ export type GroupParticipant = (Contact & {
3
+ isAdmin?: boolean;
4
+ isSuperAdmin?: boolean;
5
+ admin?: 'admin' | 'superadmin' | null;
6
+ });
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
8
+ export interface GroupMetadata {
9
+ id: string;
10
+ owner: string | undefined;
11
+ subject: string;
12
+ addressingMode: "pn" | "lid";
13
+ /** group subject owner */
14
+ subjectOwner?: string;
15
+ /** group subject modification date */
16
+ subjectTime?: number;
17
+ creation?: number;
18
+ desc?: string;
19
+ descOwner?: string;
20
+ descId?: string;
21
+ /** if this group is part of a community, it returns the jid of the community to which it belongs */
22
+ linkedParent?: string;
23
+ /** is set when the group only allows admins to change group settings */
24
+ restrict?: boolean;
25
+ /** is set when the group only allows admins to write messages */
26
+ announce?: boolean;
27
+ /** is set when the group also allows members to add participants */
28
+ memberAddMode?: boolean;
29
+ /** Request approval to join the group */
30
+ joinApprovalMode?: boolean;
31
+ /** is this a community */
32
+ isCommunity?: boolean;
33
+ /** is this the announce of a community */
34
+ isCommunityAnnounce?: boolean;
35
+ /** number of group participants */
36
+ size?: number;
37
+ participants: GroupParticipant[];
38
+ ephemeralDuration?: number;
39
+ inviteCode?: string;
40
+ /** the person who added you to group or changed some setting in group */
41
+ author?: string;
42
+ }
43
+ export interface WAGroupCreateResponse {
44
+ status: number;
45
+ gid?: string;
46
+ participants?: [{
47
+ [key: string]: {};
48
+ }];
49
+ }
50
+ export interface GroupModificationResponse {
51
+ status: number;
52
+ participants?: {
53
+ [key: string]: {};
54
+ };
55
+ }
@@ -1,3 +1,2 @@
1
- //=======================================================//
2
- export {};
3
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ export interface Label {
2
+ /** Label uniq ID */
3
+ id: string;
4
+ /** Label name */
5
+ name: string;
6
+ /** Label color ID */
7
+ color: number;
8
+ /** Is label has been deleted */
9
+ deleted: boolean;
10
+ /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
+ predefinedId?: string;
12
+ }
13
+ /** WhatsApp has 20 predefined colors */
14
+ export declare enum LabelColor {
15
+ Color1 = 0,
16
+ Color2 = 1,
17
+ Color3 = 2,
18
+ Color4 = 3,
19
+ Color5 = 4,
20
+ Color6 = 5,
21
+ Color7 = 6,
22
+ Color8 = 7,
23
+ Color9 = 8,
24
+ Color10 = 9,
25
+ Color11 = 10,
26
+ Color12 = 11,
27
+ Color13 = 12,
28
+ Color14 = 13,
29
+ Color15 = 14,
30
+ Color16 = 15,
31
+ Color17 = 16,
32
+ Color18 = 17,
33
+ Color19 = 18,
34
+ Color20 = 19
35
+ }
@@ -1,25 +1,27 @@
1
- //=======================================================//
2
- export var LabelColor;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelColor = void 0;
4
+ /** WhatsApp has 20 predefined colors */
5
+ var LabelColor;
3
6
  (function (LabelColor) {
4
- LabelColor[LabelColor["Color1"] = 0] = "Color1";
5
- LabelColor[LabelColor["Color2"] = 1] = "Color2";
6
- LabelColor[LabelColor["Color3"] = 2] = "Color3";
7
- LabelColor[LabelColor["Color4"] = 3] = "Color4";
8
- LabelColor[LabelColor["Color5"] = 4] = "Color5";
9
- LabelColor[LabelColor["Color6"] = 5] = "Color6";
10
- LabelColor[LabelColor["Color7"] = 6] = "Color7";
11
- LabelColor[LabelColor["Color8"] = 7] = "Color8";
12
- LabelColor[LabelColor["Color9"] = 8] = "Color9";
13
- LabelColor[LabelColor["Color10"] = 9] = "Color10";
14
- LabelColor[LabelColor["Color11"] = 10] = "Color11";
15
- LabelColor[LabelColor["Color12"] = 11] = "Color12";
16
- LabelColor[LabelColor["Color13"] = 12] = "Color13";
17
- LabelColor[LabelColor["Color14"] = 13] = "Color14";
18
- LabelColor[LabelColor["Color15"] = 14] = "Color15";
19
- LabelColor[LabelColor["Color16"] = 15] = "Color16";
20
- LabelColor[LabelColor["Color17"] = 16] = "Color17";
21
- LabelColor[LabelColor["Color18"] = 17] = "Color18";
22
- LabelColor[LabelColor["Color19"] = 18] = "Color19";
23
- LabelColor[LabelColor["Color20"] = 19] = "Color20";
24
- })(LabelColor || (LabelColor = {}));
25
- //=======================================================//
7
+ LabelColor[LabelColor["Color1"] = 0] = "Color1";
8
+ LabelColor[LabelColor["Color2"] = 1] = "Color2";
9
+ LabelColor[LabelColor["Color3"] = 2] = "Color3";
10
+ LabelColor[LabelColor["Color4"] = 3] = "Color4";
11
+ LabelColor[LabelColor["Color5"] = 4] = "Color5";
12
+ LabelColor[LabelColor["Color6"] = 5] = "Color6";
13
+ LabelColor[LabelColor["Color7"] = 6] = "Color7";
14
+ LabelColor[LabelColor["Color8"] = 7] = "Color8";
15
+ LabelColor[LabelColor["Color9"] = 8] = "Color9";
16
+ LabelColor[LabelColor["Color10"] = 9] = "Color10";
17
+ LabelColor[LabelColor["Color11"] = 10] = "Color11";
18
+ LabelColor[LabelColor["Color12"] = 11] = "Color12";
19
+ LabelColor[LabelColor["Color13"] = 12] = "Color13";
20
+ LabelColor[LabelColor["Color14"] = 13] = "Color14";
21
+ LabelColor[LabelColor["Color15"] = 14] = "Color15";
22
+ LabelColor[LabelColor["Color16"] = 15] = "Color16";
23
+ LabelColor[LabelColor["Color17"] = 16] = "Color17";
24
+ LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
+ LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
+ LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
+ })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
@@ -0,0 +1,29 @@
1
+ /** Association type */
2
+ export declare enum LabelAssociationType {
3
+ Chat = "label_jid",
4
+ Message = "label_message"
5
+ }
6
+ export type LabelAssociationTypes = `${LabelAssociationType}`;
7
+ /** Association for chat */
8
+ export interface ChatLabelAssociation {
9
+ type: LabelAssociationType.Chat;
10
+ chatId: string;
11
+ labelId: string;
12
+ }
13
+ /** Association for message */
14
+ export interface MessageLabelAssociation {
15
+ type: LabelAssociationType.Message;
16
+ chatId: string;
17
+ messageId: string;
18
+ labelId: string;
19
+ }
20
+ export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation;
21
+ /** Body for add/remove chat label association action */
22
+ export interface ChatLabelAssociationActionBody {
23
+ labelId: string;
24
+ }
25
+ /** body for add/remove message label association action */
26
+ export interface MessageLabelAssociationActionBody {
27
+ labelId: string;
28
+ messageId: string;
29
+ }
@@ -1,7 +1,9 @@
1
- //=======================================================//
2
- export var LabelAssociationType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelAssociationType = void 0;
4
+ /** Association type */
5
+ var LabelAssociationType;
3
6
  (function (LabelAssociationType) {
4
- LabelAssociationType["Chat"] = "label_jid";
5
- LabelAssociationType["Message"] = "label_message";
6
- })(LabelAssociationType || (LabelAssociationType = {}));
7
- //=======================================================//
7
+ LabelAssociationType["Chat"] = "label_jid";
8
+ LabelAssociationType["Message"] = "label_message";
9
+ })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
@@ -0,0 +1,273 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { AxiosRequestConfig } from 'axios';
5
+ import type { Logger } from 'pino';
6
+ import type { Readable } from 'stream';
7
+ import type { URL } from 'url';
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';
13
+ export { proto as WAProto };
14
+ export type WAMessage = proto.IWebMessageInfo;
15
+ export type WAMessageContent = proto.IMessage;
16
+ export type WAContactMessage = proto.Message.IContactMessage;
17
+ export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
18
+ export type WAMessageKey = proto.IMessageKey;
19
+ export type WATextMessage = proto.Message.IExtendedTextMessage;
20
+ export type WAContextInfo = proto.IContextInfo;
21
+ export type WALocationMessage = proto.Message.ILocationMessage;
22
+ 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
+ url: URL | string;
27
+ } | {
28
+ stream: Readable;
29
+ };
30
+ /** Set of message types that are supported by the library */
31
+ export type MessageType = keyof proto.Message;
32
+ export type DownloadableMessage = {
33
+ mediaKey?: Uint8Array | null;
34
+ directPath?: string | null;
35
+ url?: string | null;
36
+ };
37
+ export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
38
+ export type MediaConnInfo = {
39
+ auth: string;
40
+ ttl: number;
41
+ hosts: {
42
+ hostname: string;
43
+ maxContentLengthBytes: number;
44
+ }[];
45
+ fetchDate: Date;
46
+ };
47
+ export interface WAUrlInfo {
48
+ 'canonical-url': string;
49
+ 'matched-text': string;
50
+ title: string;
51
+ description?: string;
52
+ jpegThumbnail?: Buffer;
53
+ highQualityThumbnail?: proto.Message.IImageMessage;
54
+ originalThumbnailUrl?: string;
55
+ }
56
+ type Mentionable = {
57
+ /** list of jids that are mentioned in the accompanying text */
58
+ mentions?: string[];
59
+ };
60
+ type Contextable = {
61
+ /** add contextInfo to the message */
62
+ contextInfo?: proto.IContextInfo;
63
+ };
64
+ type ViewOnce = {
65
+ viewOnce?: boolean;
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
+ };
76
+ type Editable = {
77
+ edit?: WAMessageKey;
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
+ };
87
+ type WithDimensions = {
88
+ width?: number;
89
+ height?: number;
90
+ };
91
+ export type PollMessageOptions = {
92
+ name: string;
93
+ selectableCount?: number;
94
+ values: string[];
95
+ /** 32 byte message secret to encrypt poll selections */
96
+ messageSecret?: Uint8Array;
97
+ };
98
+ type SharePhoneNumber = {
99
+ sharePhoneNumber: boolean;
100
+ };
101
+ type RequestPhoneNumber = {
102
+ requestPhoneNumber: boolean;
103
+ };
104
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
105
+ export type AnyMediaMessageContent = (({
106
+ image: WAMediaUpload;
107
+ caption?: string;
108
+ jpegThumbnail?: string;
109
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
110
+ video: WAMediaUpload;
111
+ caption?: string;
112
+ gifPlayback?: boolean;
113
+ jpegThumbnail?: string;
114
+ /** if set to true, will send as a `video note` */
115
+ ptv?: boolean;
116
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
117
+ audio: WAMediaUpload;
118
+ /** if set to true, will send as a `voice note` */
119
+ ptt?: boolean;
120
+ /** optionally tell the duration of the audio */
121
+ seconds?: number;
122
+ } | ({
123
+ sticker: WAMediaUpload;
124
+ isAnimated?: boolean;
125
+ } & WithDimensions) | ({
126
+ document: WAMediaUpload;
127
+ mimetype: string;
128
+ fileName?: string;
129
+ caption?: string;
130
+ } & Contextable & Buttonable & Templatable)) & {
131
+ mimetype?: string;
132
+ } & Editable;
133
+ export type ButtonReplyInfo = {
134
+ displayText: string;
135
+ id: string;
136
+ index: number;
137
+ };
138
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
139
+ productImage: WAMediaUpload;
140
+ };
141
+ export type AnyRegularMessageContent = (({
142
+ text: string;
143
+ linkPreview?: WAUrlInfo | null;
144
+ } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
145
+ poll: PollMessageOptions;
146
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
147
+ contacts: {
148
+ displayName?: string;
149
+ contacts: proto.Message.IContactMessage[];
150
+ };
151
+ } | {
152
+ location: WALocationMessage;
153
+ } | {
154
+ react: proto.Message.IReactionMessage;
155
+ } | {
156
+ buttonReply: ButtonReplyInfo;
157
+ type: 'template' | 'plain';
158
+ } | {
159
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
160
+ } | {
161
+ product: WASendableProduct;
162
+ businessOwnerJid?: string;
163
+ body?: string;
164
+ footer?: string;
165
+ } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
166
+ export type AnyMessageContent = AnyRegularMessageContent | {
167
+ forward: WAMessage;
168
+ force?: boolean;
169
+ } | {
170
+ /** Delete your message or anyone's message in a group (admin required) */
171
+ delete: WAMessageKey;
172
+ } | {
173
+ disappearingMessagesInChat: boolean | number;
174
+ };
175
+ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
176
+ type MinimalRelayOptions = {
177
+ /** override the message ID with a custom provided string */
178
+ messageId?: string;
179
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
180
+ cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
181
+ };
182
+ export type MessageRelayOptions = MinimalRelayOptions & {
183
+ /** only send to a specific participant; used when a message decryption fails for a single user */
184
+ participant?: {
185
+ jid: string;
186
+ count: number;
187
+ };
188
+ /** additional attributes to add to the WA binary node */
189
+ additionalAttributes?: {
190
+ [_: string]: string;
191
+ };
192
+ additionalNodes?: BinaryNode[];
193
+ /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
194
+ useUserDevicesCache?: boolean;
195
+ /** jid list of participants for status@broadcast */
196
+ statusJidList?: string[];
197
+ };
198
+ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
199
+ /** optional, if you want to manually set the timestamp of the message */
200
+ timestamp?: Date;
201
+ /** the message you want to quote */
202
+ quoted?: WAMessage;
203
+ additionalNodes?: BinaryNode[];
204
+ /** disappearing messages settings */
205
+ ephemeralExpiration?: number | string;
206
+ /** timeout for media upload to WA server */
207
+ mediaUploadTimeoutMs?: number;
208
+ /** jid list of participants for status@broadcast */
209
+ statusJidList?: string[];
210
+ /** backgroundcolor for status */
211
+ backgroundColor?: string;
212
+ /** font type for status */
213
+ font?: number;
214
+ /** if it is broadcast */
215
+ broadcast?: boolean;
216
+ };
217
+ export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
218
+ userJid: string;
219
+ };
220
+ export type WAMediaUploadFunctionOpts = {
221
+ fileEncSha256B64: string;
222
+ mediaType: MediaType;
223
+ newsletter?: boolean;
224
+ timeoutMs?: number;
225
+ };
226
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
227
+ mediaUrl: string;
228
+ directPath: string;
229
+ handle?: string;
230
+ }>;
231
+ export type MediaGenerationOptions = {
232
+ logger?: Logger;
233
+ mediaTypeOverride?: MediaType;
234
+ upload: WAMediaUploadFunction;
235
+ /** cache media so it does not have to be uploaded again */
236
+ mediaCache?: CacheStore;
237
+ mediaUploadTimeoutMs?: number;
238
+ options?: AxiosRequestConfig;
239
+ backgroundColor?: string;
240
+ font?: number;
241
+ /** The message is for newsletter? */
242
+ newsletter?: boolean;
243
+ };
244
+ export type MessageContentGenerationOptions = MediaGenerationOptions & {
245
+ getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
246
+ };
247
+ export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
248
+ /**
249
+ * Type of message upsert
250
+ * 1. notify => notify the user, this message was just received
251
+ * 2. append => append the message to the chat history, no notification required
252
+ */
253
+ export type MessageUpsertType = 'append' | 'notify';
254
+ export type MessageUserReceipt = proto.IUserReceipt;
255
+ export type WAMessageUpdate = {
256
+ update: Partial<WAMessage>;
257
+ key: proto.IMessageKey;
258
+ };
259
+ export type WAMessageCursor = {
260
+ before: WAMessageKey | undefined;
261
+ } | {
262
+ after: WAMessageKey | undefined;
263
+ };
264
+ export type MessageUserReceiptUpdate = {
265
+ key: proto.IMessageKey;
266
+ receipt: MessageUserReceipt;
267
+ };
268
+ export type MediaDecryptionKeyInfo = {
269
+ iv: Buffer;
270
+ cipherKey: Buffer;
271
+ macKey?: Buffer;
272
+ };
273
+ export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
@@ -1,12 +1,9 @@
1
- //=======================================================//
2
- import { proto } from "../../WAProto/index.js";
3
- //=======================================================//
4
- export { proto as WAProto };
5
- export const WAMessageStubType = proto.WebMessageInfo.StubType;
6
- export const WAMessageStatus = proto.WebMessageInfo.Status;
7
- export var WAMessageAddressingMode;
8
- (function (WAMessageAddressingMode) {
9
- WAMessageAddressingMode["PN"] = "pn";
10
- WAMessageAddressingMode["LID"] = "lid";
11
- })(WAMessageAddressingMode || (WAMessageAddressingMode = {}));
12
- //=======================================================//
1
+ "use strict";
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;
@@ -0,0 +1,103 @@
1
+ import { proto } from "../../WAProto"
2
+
3
+ export type NewsletterReactionMode = "ALL" | "BASIC" | "NONE"
4
+ export type NewsletterState = "ACTIVE" | "GEOSUSPENDED" | "SUSPENDED"
5
+ export type NewsletterVerification = "VERIFIED" | "UNVERIFIED"
6
+ export type NewsletterMute = "ON" | "OFF" | "UNDEFINED"
7
+ export type NewsletterViewRole = "ADMIN" | "GUEST" | "OWNER" | "SUBSCRIBER"
8
+
9
+ export type NewsletterViewerMetadata = {
10
+ mute: NewsletterMute
11
+ view_role: NewsletterViewRole
12
+ }
13
+
14
+ export type NewsletterMetadata = {
15
+ /** jid of newsletter */
16
+ id: string
17
+ /** state of newsletter */
18
+ state: NewsletterState
19
+ /** creation timestamp of newsletter */
20
+ creation_time: number
21
+ /** name of newsletter */
22
+ name: string
23
+ /** timestamp of last name modification of newsletter */
24
+ nameTime: number
25
+ /** description of newsletter */
26
+ description: string
27
+ /** timestamp of last description modification of newsletter */
28
+ descriptionTime: number
29
+ /** invite code of newsletter */
30
+ invite: string
31
+ /** direct path of picture */
32
+ picture: string | null
33
+ /** direct path of picture preview (lower quality) */
34
+ preview: string | null
35
+ /** reaction mode of newsletter */
36
+ reaction_codes?: NewsletterReactionMode
37
+ /** subscribers count of newsletter */
38
+ subscribers: number
39
+ /** verification state of newsletter */
40
+ verification: NewsletterVerification
41
+ /** viewer metadata */
42
+ viewer_metadata: NewsletterViewerMetadata
43
+ }
44
+
45
+ export type SubscriberAction = "promote" | "demote"
46
+
47
+ export type ReactionModeUpdate = {
48
+ reaction_codes: {
49
+ blocked_codes: null
50
+ enabled_ts_sec: null
51
+ value: NewsletterReactionMode
52
+ }
53
+ }
54
+
55
+ /** only exists reaction mode update */
56
+ export type NewsletterSettingsUpdate = ReactionModeUpdate
57
+
58
+ export type NewsletterReaction = {
59
+ count: number
60
+ code: string
61
+ }
62
+
63
+ export type NewsletterFetchedUpdate = {
64
+ /** id of message in newsletter, starts from 100 */
65
+ server_id: string
66
+ /** count of views in this message */
67
+ views?: number
68
+ /** reactions in this message */
69
+ reactions: NewsletterReaction[]
70
+ /** the message, if you requested only updates, you will not receive message */
71
+ message?: proto.IWebMessageInfo
72
+ }
73
+
74
+ export const MexOperations = {
75
+ PROMOTE: "NotificationNewsletterAdminPromote",
76
+ DEMOTE: "NotificationNewsletterAdminDemote",
77
+ UPDATE: "NotificationNewsletterUpdate"
78
+ } as const
79
+
80
+ export const XWAPaths = {
81
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
82
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
83
+ ADMIN_COUNT: "xwa2_newsletter_admin",
84
+ CREATE: "xwa2_newsletter_create",
85
+ NEWSLETTER: "xwa2_newsletter",
86
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
87
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
88
+ } as const
89
+
90
+ export const QueryIds = {
91
+ JOB_MUTATION: "7150902998257522",
92
+ METADATA: "6620195908089573",
93
+ UNFOLLOW: "7238632346214362",
94
+ FOLLOW: "7871414976211147",
95
+ UNMUTE: "7337137176362961",
96
+ MUTE: "25151904754424642",
97
+ CREATE: "6996806640408138",
98
+ ADMIN_COUNT: "7130823597031706",
99
+ CHANGE_OWNER: "7341777602580933",
100
+ DELETE: "8316537688363079",
101
+ DEMOTE: "6551828931592903",
102
+ SUBSCRIBED: "6388546374527196"
103
+ } as const
@@ -1,33 +1,38 @@
1
- //=======================================================//
2
- export var XWAPaths;
3
- (function (XWAPaths) {
4
- XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
5
- XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
6
- XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
7
- XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
8
- XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
9
- XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
10
- XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
11
- XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
12
- XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
13
- XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
14
- XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
15
- XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
16
- })(XWAPaths || (XWAPaths = {}));
17
- //=======================================================//
18
- export var QueryIds;
19
- (function (QueryIds) {
20
- QueryIds["CREATE"] = "8823471724422422";
21
- QueryIds["UPDATE_METADATA"] = "24250201037901610";
22
- QueryIds["METADATA"] = "6620195908089573";
23
- QueryIds["SUBSCRIBERS"] = "6388546374527196";
24
- QueryIds["FOLLOW"] = "7871414976211147";
25
- QueryIds["UNFOLLOW"] = "7238632346214362";
26
- QueryIds["MUTE"] = "29766401636284406";
27
- QueryIds["UNMUTE"] = "9864994326891137";
28
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
29
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
- QueryIds["DEMOTE"] = "6551828931592903";
31
- QueryIds["DELETE"] = "30062808666639665";
32
- })(QueryIds || (QueryIds = {}));
33
- //=======================================================//
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const MexOperations = {
6
+ PROMOTE: "NotificationNewsletterAdminPromote",
7
+ DEMOTE: "NotificationNewsletterAdminDemote",
8
+ UPDATE: "NotificationNewsletterUpdate"
9
+ }
10
+
11
+ const XWAPaths = {
12
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
13
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
14
+ ADMIN_COUNT: "xwa2_newsletter_admin",
15
+ CREATE: "xwa2_newsletter_create",
16
+ NEWSLETTER: "xwa2_newsletter",
17
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
18
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
19
+ }
20
+
21
+ const QueryIds = {
22
+ JOB_MUTATION: "7150902998257522",
23
+ METADATA: "6620195908089573",
24
+ UNFOLLOW: "7238632346214362",
25
+ FOLLOW: "7871414976211147",
26
+ UNMUTE: "7337137176362961",
27
+ MUTE: "25151904754424642",
28
+ CREATE: "6996806640408138",
29
+ ADMIN_COUNT: "7130823597031706",
30
+ CHANGE_OWNER: "7341777602580933",
31
+ DELETE: "8316537688363079",
32
+ DEMOTE: "6551828931592903",
33
+ SUBSCRIBED: "6388546374527196"
34
+ }
35
+
36
+ exports.MexOperations = MexOperations
37
+ exports.XWAPaths = XWAPaths
38
+ exports.QueryIds = QueryIds