@hbmodsofc/baileys 1.7.8 → 2.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 (155) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +157084 -24729
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +8 -12
  5. package/lib/Defaults/index.js +124 -90
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/group_cipher.d.ts +1 -0
  8. package/lib/Signal/Group/group_cipher.js +39 -28
  9. package/lib/Signal/Group/queue-job.d.ts +1 -0
  10. package/lib/Signal/Group/queue-job.js +57 -0
  11. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  12. package/lib/Signal/Group/sender-chain-key.js +2 -9
  13. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  14. package/lib/Signal/Group/sender-key-message.js +3 -3
  15. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  16. package/lib/Signal/Group/sender-key-state.js +16 -47
  17. package/lib/Signal/libsignal.d.ts +3 -7
  18. package/lib/Signal/libsignal.js +39 -224
  19. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
  20. package/lib/Socket/Client/index.d.ts +3 -2
  21. package/lib/Socket/Client/index.js +3 -2
  22. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  23. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  24. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  25. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
  26. package/lib/Socket/business.d.ts +78 -94
  27. package/lib/Socket/business.js +11 -130
  28. package/lib/Socket/chats.d.ts +233 -63
  29. package/lib/Socket/chats.js +184 -234
  30. package/lib/Socket/groups.d.ts +41 -62
  31. package/lib/Socket/groups.js +64 -76
  32. package/lib/Socket/hbmods.d.ts +253 -0
  33. package/lib/Socket/hbmods.js +1 -0
  34. package/lib/Socket/index.d.ts +83 -129
  35. package/lib/Socket/index.js +6 -13
  36. package/lib/Socket/messages-recv.d.ts +48 -59
  37. package/lib/Socket/messages-recv.js +371 -516
  38. package/lib/Socket/messages-send.d.ts +67 -86
  39. package/lib/Socket/messages-send.js +1 -1091
  40. package/lib/Socket/newsletter.d.ts +64 -76
  41. package/lib/Socket/newsletter.js +1 -184
  42. package/lib/Socket/registration.d.ts +267 -0
  43. package/lib/Socket/registration.js +166 -0
  44. package/lib/Socket/socket.d.ts +13 -19
  45. package/lib/Socket/socket.js +1 -805
  46. package/lib/Socket/usync.d.ts +36 -0
  47. package/lib/Socket/usync.js +70 -0
  48. package/lib/Types/Auth.d.ts +10 -4
  49. package/lib/Types/Call.d.ts +1 -1
  50. package/lib/Types/Chat.d.ts +9 -29
  51. package/lib/Types/Chat.js +1 -7
  52. package/lib/Types/Contact.d.ts +1 -5
  53. package/lib/Types/Events.d.ts +14 -55
  54. package/lib/Types/GroupMetadata.d.ts +5 -15
  55. package/lib/Types/Label.d.ts +0 -11
  56. package/lib/Types/Label.js +1 -1
  57. package/lib/Types/LabelAssociation.js +1 -1
  58. package/lib/Types/Message.d.ts +49 -75
  59. package/lib/Types/Message.js +7 -10
  60. package/lib/Types/Newsletter.d.ts +98 -129
  61. package/lib/Types/Newsletter.js +38 -33
  62. package/lib/Types/Product.d.ts +1 -1
  63. package/lib/Types/Signal.d.ts +1 -29
  64. package/lib/Types/Socket.d.ts +22 -48
  65. package/lib/Types/State.d.ts +2 -13
  66. package/lib/Types/State.js +0 -12
  67. package/lib/Types/USync.d.ts +1 -1
  68. package/lib/Types/index.d.ts +3 -10
  69. package/lib/Types/index.js +2 -2
  70. package/lib/Utils/auth-utils.d.ts +3 -3
  71. package/lib/Utils/auth-utils.js +102 -378
  72. package/lib/Utils/baileys-event-stream.js +1 -1
  73. package/lib/Utils/business.d.ts +2 -2
  74. package/lib/Utils/business.js +13 -19
  75. package/lib/Utils/chat-utils.d.ts +22 -21
  76. package/lib/Utils/chat-utils.js +154 -201
  77. package/lib/Utils/crypto.d.ts +19 -18
  78. package/lib/Utils/crypto.js +37 -78
  79. package/lib/Utils/decode-wa-message.d.ts +7 -34
  80. package/lib/Utils/decode-wa-message.js +66 -138
  81. package/lib/Utils/event-buffer.d.ts +8 -6
  82. package/lib/Utils/event-buffer.js +43 -81
  83. package/lib/Utils/generics.d.ts +27 -27
  84. package/lib/Utils/generics.js +133 -128
  85. package/lib/Utils/history.d.ts +5 -9
  86. package/lib/Utils/history.js +23 -17
  87. package/lib/Utils/index.d.ts +0 -2
  88. package/lib/Utils/index.js +0 -2
  89. package/lib/Utils/link-preview.d.ts +4 -4
  90. package/lib/Utils/link-preview.js +12 -40
  91. package/lib/Utils/logger.d.ts +3 -11
  92. package/lib/Utils/lt-hash.d.ts +8 -8
  93. package/lib/Utils/lt-hash.js +24 -23
  94. package/lib/Utils/make-mutex.d.ts +2 -2
  95. package/lib/Utils/make-mutex.js +2 -3
  96. package/lib/Utils/messages-media.d.ts +41 -37
  97. package/lib/Utils/messages-media.js +368 -252
  98. package/lib/Utils/messages.d.ts +15 -13
  99. package/lib/Utils/messages.js +261 -274
  100. package/lib/Utils/noise-handler.d.ts +15 -13
  101. package/lib/Utils/noise-handler.js +26 -20
  102. package/lib/Utils/process-message.d.ts +8 -9
  103. package/lib/Utils/process-message.js +93 -157
  104. package/lib/Utils/signal.d.ts +5 -6
  105. package/lib/Utils/signal.js +29 -37
  106. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
  107. package/lib/Utils/use-multi-file-auth-state.js +7 -12
  108. package/lib/Utils/validate-connection.d.ts +6 -5
  109. package/lib/Utils/validate-connection.js +97 -39
  110. package/lib/WABinary/constants.d.ts +27 -24
  111. package/lib/WABinary/constants.js +13 -1276
  112. package/lib/WABinary/decode.d.ts +4 -3
  113. package/lib/WABinary/decode.js +14 -28
  114. package/lib/WABinary/encode.d.ts +2 -1
  115. package/lib/WABinary/encode.js +147 -134
  116. package/lib/WABinary/generic-utils.d.ts +7 -4
  117. package/lib/WABinary/generic-utils.js +125 -40
  118. package/lib/WABinary/jid-utils.d.ts +8 -13
  119. package/lib/WABinary/jid-utils.js +16 -27
  120. package/lib/WAM/BinaryInfo.d.ts +11 -2
  121. package/lib/WAM/constants.d.ts +2 -3
  122. package/lib/WAM/constants.js +2359 -2252
  123. package/lib/WAM/encode.d.ts +2 -1
  124. package/lib/WAM/encode.js +11 -8
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
  127. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  129. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  131. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
  137. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  138. package/lib/WAUSync/USyncQuery.js +15 -19
  139. package/lib/WAUSync/USyncUser.d.ts +5 -5
  140. package/lib/WAUSync/index.d.ts +1 -1
  141. package/lib/WAUSync/index.js +1 -1
  142. package/package.json +102 -104
  143. package/lib/Signal/lid-mapping.d.ts +0 -26
  144. package/lib/Signal/lid-mapping.js +0 -146
  145. package/lib/Socket/communities.d.ts +0 -232
  146. package/lib/Socket/communities.js +0 -402
  147. package/lib/Socket/mex.d.ts +0 -2
  148. package/lib/Socket/mex.js +0 -45
  149. package/lib/Types/Bussines.d.ts +0 -24
  150. package/lib/Types/Bussines.js +0 -2
  151. package/lib/Utils/lidToJid-test.d.ts +0 -11
  152. package/lib/Utils/lidToJid-test.js +0 -27
  153. package/lib/Utils/message-retry-manager.d.ts +0 -81
  154. package/lib/Utils/message-retry-manager.js +0 -152
  155. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -1,45 +1,34 @@
1
- import type { AxiosRequestConfig } from 'axios';
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { AxiosRequestConfig } from 'axios';
5
+ import type { Logger } from 'pino';
2
6
  import type { Readable } from 'stream';
3
7
  import type { URL } from 'url';
4
- import { proto } from '../../WAProto/index.js';
5
- import type { MediaType } from '../Defaults';
6
- import type { BinaryNode } from '../WABinary';
8
+ import { BinaryNode } from '../WABinary';
9
+ import { proto } from '../../WAProto';
10
+ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
7
11
  import type { GroupMetadata } from './GroupMetadata';
8
- import type { CacheStore } from './Socket';
12
+ import { CacheStore } from './Socket';
9
13
  export { proto as WAProto };
10
- export type WAMessage = proto.IWebMessageInfo & {
11
- key: WAMessageKey;
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
- isViewOnce?: boolean;
21
- };
18
+ export type WAMessageKey = proto.IMessageKey;
22
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
23
20
  export type WAContextInfo = proto.IContextInfo;
24
21
  export type WALocationMessage = proto.Message.ILocationMessage;
25
22
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
26
- export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
27
- export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
28
- import type { ILogger } from '../Utils/logger';
29
- export type WAMediaPayloadURL = {
23
+ export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
+ export import WAMessageStatus = proto.WebMessageInfo.Status;
25
+ export type WAMediaUpload = Buffer | {
30
26
  url: URL | string;
31
- };
32
- export type WAMediaPayloadStream = {
27
+ } | {
33
28
  stream: Readable;
34
29
  };
35
- export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
36
30
  /** Set of message types that are supported by the library */
37
31
  export type MessageType = keyof proto.Message;
38
- export declare enum WAMessageAddressingMode {
39
- PN = "pn",
40
- LID = "lid"
41
- }
42
- export type MessageWithContextInfo = 'imageMessage' | 'contactMessage' | 'locationMessage' | 'extendedTextMessage' | 'documentMessage' | 'audioMessage' | 'videoMessage' | 'call' | 'contactsArrayMessage' | 'liveLocationMessage' | 'templateMessage' | 'stickerMessage' | 'groupInviteMessage' | 'templateButtonReplyMessage' | 'productMessage' | 'listMessage' | 'orderMessage' | 'listResponseMessage' | 'buttonsMessage' | 'buttonsResponseMessage' | 'interactiveMessage' | 'interactiveResponseMessage' | 'pollCreationMessage' | 'requestPhoneNumberMessage' | 'messageHistoryBundle' | 'eventMessage' | 'newsletterAdminInviteMessage' | 'albumMessage' | 'stickerPackMessage' | 'pollResultSnapshotMessage' | 'messageHistoryNotice';
43
32
  export type DownloadableMessage = {
44
33
  mediaKey?: Uint8Array | null;
45
34
  directPath?: string | null;
@@ -75,9 +64,26 @@ type Contextable = {
75
64
  type ViewOnce = {
76
65
  viewOnce?: boolean;
77
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
+ };
78
76
  type Editable = {
79
77
  edit?: WAMessageKey;
80
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
+ };
81
87
  type WithDimensions = {
82
88
  width?: number;
83
89
  height?: number;
@@ -88,19 +94,6 @@ export type PollMessageOptions = {
88
94
  values: string[];
89
95
  /** 32 byte message secret to encrypt poll selections */
90
96
  messageSecret?: Uint8Array;
91
- toAnnouncementGroup?: boolean;
92
- };
93
- export type EventMessageOptions = {
94
- name: string;
95
- description?: string;
96
- startDate: Date;
97
- endDate?: Date;
98
- location?: WALocationMessage;
99
- call?: 'audio' | 'video';
100
- isCancelled?: boolean;
101
- isScheduleCall?: boolean;
102
- extraGuestsAllowed?: boolean;
103
- messageSecret?: Uint8Array<ArrayBufferLike>;
104
97
  };
105
98
  type SharePhoneNumber = {
106
99
  sharePhoneNumber: boolean;
@@ -108,18 +101,19 @@ type SharePhoneNumber = {
108
101
  type RequestPhoneNumber = {
109
102
  requestPhoneNumber: boolean;
110
103
  };
104
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
111
105
  export type AnyMediaMessageContent = (({
112
106
  image: WAMediaUpload;
113
107
  caption?: string;
114
108
  jpegThumbnail?: string;
115
- } & Mentionable & Contextable & WithDimensions) | ({
109
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
116
110
  video: WAMediaUpload;
117
111
  caption?: string;
118
112
  gifPlayback?: boolean;
119
113
  jpegThumbnail?: string;
120
114
  /** if set to true, will send as a `video note` */
121
115
  ptv?: boolean;
122
- } & Mentionable & Contextable & WithDimensions) | {
116
+ } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
123
117
  audio: WAMediaUpload;
124
118
  /** if set to true, will send as a `voice note` */
125
119
  ptt?: boolean;
@@ -133,7 +127,7 @@ export type AnyMediaMessageContent = (({
133
127
  mimetype: string;
134
128
  fileName?: string;
135
129
  caption?: string;
136
- } & Contextable)) & {
130
+ } & Contextable & Buttonable & Templatable)) & {
137
131
  mimetype?: string;
138
132
  } & Editable;
139
133
  export type ButtonReplyInfo = {
@@ -141,24 +135,15 @@ export type ButtonReplyInfo = {
141
135
  id: string;
142
136
  index: number;
143
137
  };
144
- export type GroupInviteInfo = {
145
- inviteCode: string;
146
- inviteExpiration: number;
147
- text: string;
148
- jid: string;
149
- subject: string;
150
- };
151
138
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
152
139
  productImage: WAMediaUpload;
153
140
  };
154
141
  export type AnyRegularMessageContent = (({
155
142
  text: string;
156
143
  linkPreview?: WAUrlInfo | null;
157
- } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | {
158
- event: EventMessageOptions;
159
- } | ({
144
+ } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
160
145
  poll: PollMessageOptions;
161
- } & Mentionable & Contextable & Editable) | {
146
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
162
147
  contacts: {
163
148
  displayName?: string;
164
149
  contacts: proto.Message.IContactMessage[];
@@ -170,17 +155,8 @@ export type AnyRegularMessageContent = (({
170
155
  } | {
171
156
  buttonReply: ButtonReplyInfo;
172
157
  type: 'template' | 'plain';
173
- } | {
174
- groupInvite: GroupInviteInfo;
175
158
  } | {
176
159
  listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
177
- } | {
178
- pin: WAMessageKey;
179
- type: proto.PinInChat.Type;
180
- /**
181
- * 24 hours, 7 days, 30 days
182
- */
183
- time?: 86400 | 604800 | 2592000;
184
160
  } | {
185
161
  product: WASendableProduct;
186
162
  businessOwnerJid?: string;
@@ -200,8 +176,8 @@ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
200
176
  type MinimalRelayOptions = {
201
177
  /** override the message ID with a custom provided string */
202
178
  messageId?: string;
203
- /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
204
- useCachedGroupMetadata?: boolean;
179
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
180
+ cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
205
181
  };
206
182
  export type MessageRelayOptions = MinimalRelayOptions & {
207
183
  /** only send to a specific participant; used when a message decryption fails for a single user */
@@ -224,6 +200,7 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
224
200
  timestamp?: Date;
225
201
  /** the message you want to quote */
226
202
  quoted?: WAMessage;
203
+ additionalNodes?: BinaryNode[];
227
204
  /** disappearing messages settings */
228
205
  ephemeralExpiration?: number | string;
229
206
  /** timeout for media upload to WA server */
@@ -240,19 +217,19 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
240
217
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
241
218
  userJid: string;
242
219
  };
243
- export type WAMediaUploadFunction = (encFilePath: string, opts: {
220
+ export type WAMediaUploadFunctionOpts = {
244
221
  fileEncSha256B64: string;
245
222
  mediaType: MediaType;
223
+ newsletter?: boolean;
246
224
  timeoutMs?: number;
247
- }) => Promise<{
225
+ };
226
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
248
227
  mediaUrl: string;
249
228
  directPath: string;
250
- meta_hmac?: string;
251
- ts?: number;
252
- fbid?: number;
229
+ handle?: string;
253
230
  }>;
254
231
  export type MediaGenerationOptions = {
255
- logger?: ILogger;
232
+ logger?: Logger;
256
233
  mediaTypeOverride?: MediaType;
257
234
  upload: WAMediaUploadFunction;
258
235
  /** cache media so it does not have to be uploaded again */
@@ -261,14 +238,11 @@ export type MediaGenerationOptions = {
261
238
  options?: AxiosRequestConfig;
262
239
  backgroundColor?: string;
263
240
  font?: number;
241
+ /** The message is for newsletter? */
242
+ newsletter?: boolean;
264
243
  };
265
244
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
266
245
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
267
- getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
268
- getCallLink?: (type: 'audio' | 'video', event?: {
269
- startTime: number;
270
- }) => Promise<string | undefined>;
271
- jid?: string;
272
246
  };
273
247
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
274
248
  /**
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WAMessageAddressingMode = exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
4
- const index_js_1 = require("../../WAProto/index.js");
5
- Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return index_js_1.proto; } });
6
- exports.WAMessageStubType = index_js_1.proto.WebMessageInfo.StubType;
7
- exports.WAMessageStatus = index_js_1.proto.WebMessageInfo.Status;
8
- var WAMessageAddressingMode;
9
- (function (WAMessageAddressingMode) {
10
- WAMessageAddressingMode["PN"] = "pn";
11
- WAMessageAddressingMode["LID"] = "lid";
12
- })(WAMessageAddressingMode || (exports.WAMessageAddressingMode = WAMessageAddressingMode = {}));
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;
@@ -1,134 +1,103 @@
1
- export declare enum XWAPaths {
2
- xwa2_newsletter_create = "xwa2_newsletter_create",
3
- xwa2_newsletter_subscribers = "xwa2_newsletter_subscribers",
4
- xwa2_newsletter_view = "xwa2_newsletter_view",
5
- xwa2_newsletter_metadata = "xwa2_newsletter",
6
- xwa2_newsletter_admin_count = "xwa2_newsletter_admin",
7
- xwa2_newsletter_mute_v2 = "xwa2_newsletter_mute_v2",
8
- xwa2_newsletter_unmute_v2 = "xwa2_newsletter_unmute_v2",
9
- xwa2_newsletter_follow = "xwa2_newsletter_follow",
10
- xwa2_newsletter_unfollow = "xwa2_newsletter_unfollow",
11
- xwa2_newsletter_change_owner = "xwa2_newsletter_change_owner",
12
- xwa2_newsletter_demote = "xwa2_newsletter_demote",
13
- xwa2_newsletter_delete_v2 = "xwa2_newsletter_delete_v2"
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
14
12
  }
15
- export declare enum QueryIds {
16
- CREATE = "8823471724422422",
17
- UPDATE_METADATA = "24250201037901610",
18
- METADATA = "6563316087068696",
19
- SUBSCRIBERS = "9783111038412085",
20
- FOLLOW = "7871414976211147",
21
- UNFOLLOW = "7238632346214362",
22
- MUTE = "29766401636284406",
23
- UNMUTE = "9864994326891137",
24
- ADMIN_COUNT = "7130823597031706",
25
- CHANGE_OWNER = "7341777602580933",
26
- DEMOTE = "6551828931592903",
27
- DELETE = "30062808666639665"
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
28
43
  }
29
- export type NewsletterUpdate = {
30
- name?: string;
31
- description?: string;
32
- picture?: string;
33
- };
34
- export interface NewsletterCreateResponse {
35
- id: string;
36
- state: {
37
- type: string;
38
- };
39
- thread_metadata: {
40
- creation_time: string;
41
- description: {
42
- id: string;
43
- text: string;
44
- update_time: string;
45
- };
46
- handle: string | null;
47
- invite: string;
48
- name: {
49
- id: string;
50
- text: string;
51
- update_time: string;
52
- };
53
- picture: {
54
- direct_path: string;
55
- id: string;
56
- type: string;
57
- };
58
- preview: {
59
- direct_path: string;
60
- id: string;
61
- type: string;
62
- };
63
- subscribers_count: string;
64
- verification: 'VERIFIED' | 'UNVERIFIED';
65
- };
66
- viewer_metadata: {
67
- mute: 'ON' | 'OFF';
68
- role: NewsletterViewRole;
69
- };
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
+ }
70
53
  }
71
- export interface NewsletterCreateResponse {
72
- id: string;
73
- state: {
74
- type: string;
75
- };
76
- thread_metadata: {
77
- creation_time: string;
78
- description: {
79
- id: string;
80
- text: string;
81
- update_time: string;
82
- };
83
- handle: string | null;
84
- invite: string;
85
- name: {
86
- id: string;
87
- text: string;
88
- update_time: string;
89
- };
90
- picture: {
91
- direct_path: string;
92
- id: string;
93
- type: string;
94
- };
95
- preview: {
96
- direct_path: string;
97
- id: string;
98
- type: string;
99
- };
100
- subscribers_count: string;
101
- verification: 'VERIFIED' | 'UNVERIFIED';
102
- };
103
- viewer_metadata: {
104
- mute: 'ON' | 'OFF';
105
- role: NewsletterViewRole;
106
- };
54
+
55
+ /** only exists reaction mode update */
56
+ export type NewsletterSettingsUpdate = ReactionModeUpdate
57
+
58
+ export type NewsletterReaction = {
59
+ count: number
60
+ code: string
107
61
  }
108
- export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
109
- export interface NewsletterMetadata {
110
- id: string;
111
- owner?: string;
112
- name: string;
113
- description?: string;
114
- invite?: string;
115
- creation_time?: number;
116
- subscribers?: number;
117
- picture?: {
118
- url?: string;
119
- directPath?: string;
120
- mediaKey?: string;
121
- id?: string;
122
- };
123
- verification?: 'VERIFIED' | 'UNVERIFIED';
124
- reaction_codes?: {
125
- code: string;
126
- count: number;
127
- }[];
128
- mute_state?: 'ON' | 'OFF';
129
- thread_metadata?: {
130
- creation_time?: number;
131
- name?: string;
132
- description?: string;
133
- };
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
134
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryIds = exports.XWAPaths = void 0;
4
- var XWAPaths;
5
- (function (XWAPaths) {
6
- XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
7
- XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
8
- XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
9
- XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
10
- XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
11
- XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
12
- XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
13
- XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
14
- XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
15
- XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
16
- XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
17
- XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
18
- })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
- var QueryIds;
20
- (function (QueryIds) {
21
- QueryIds["CREATE"] = "8823471724422422";
22
- QueryIds["UPDATE_METADATA"] = "24250201037901610";
23
- QueryIds["METADATA"] = "6563316087068696";
24
- QueryIds["SUBSCRIBERS"] = "9783111038412085";
25
- QueryIds["FOLLOW"] = "7871414976211147";
26
- QueryIds["UNFOLLOW"] = "7238632346214362";
27
- QueryIds["MUTE"] = "29766401636284406";
28
- QueryIds["UNMUTE"] = "9864994326891137";
29
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
30
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
31
- QueryIds["DEMOTE"] = "6551828931592903";
32
- QueryIds["DELETE"] = "30062808666639665";
33
- })(QueryIds || (exports.QueryIds = QueryIds = {}));
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
@@ -1,4 +1,4 @@
1
- import type { WAMediaUpload } from './Message';
1
+ import { WAMediaUpload } from './Message';
2
2
  export type CatalogResult = {
3
3
  data: {
4
4
  paging: {
@@ -1,5 +1,4 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import type { LIDMappingStore } from '../Signal/lid-mapping';
1
+ import { proto } from '../../WAProto';
3
2
  type DecryptGroupSignalOpts = {
4
3
  group: string;
5
4
  authorJid: string;
@@ -18,11 +17,6 @@ type EncryptMessageOpts = {
18
17
  jid: string;
19
18
  data: Uint8Array;
20
19
  };
21
- type EncryptMessageWithWireOpts = {
22
- encryptionJid: string;
23
- wireJid: string;
24
- data: Uint8Array;
25
- };
26
20
  type EncryptGroupMessageOpts = {
27
21
  group: string;
28
22
  data: Uint8Array;
@@ -53,33 +47,11 @@ export type SignalRepository = {
53
47
  type: 'pkmsg' | 'msg';
54
48
  ciphertext: Uint8Array;
55
49
  }>;
56
- encryptMessageWithWire(opts: EncryptMessageWithWireOpts): Promise<{
57
- type: 'pkmsg' | 'msg';
58
- ciphertext: Uint8Array;
59
- wireJid: string;
60
- }>;
61
50
  encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
62
51
  senderKeyDistributionMessage: Uint8Array;
63
52
  ciphertext: Uint8Array;
64
53
  }>;
65
54
  injectE2ESession(opts: E2ESessionOpts): Promise<void>;
66
- validateSession(jid: string): Promise<{
67
- exists: boolean;
68
- reason?: string;
69
- }>;
70
55
  jidToSignalProtocolAddress(jid: string): string;
71
- migrateSession(fromJids: string[], toJid: string): Promise<{
72
- migrated: number;
73
- skipped: number;
74
- total: number;
75
- }>;
76
- validateSession(jid: string): Promise<{
77
- exists: boolean;
78
- reason?: string;
79
- }>;
80
- deleteSession(jids: string[]): Promise<void>;
81
56
  };
82
- export interface SignalRepositoryWithLIDStore extends SignalRepository {
83
- lidMapping: LIDMappingStore;
84
- }
85
57
  export {};