@pontalabs/baileys 1.0.6 → 1.0.7

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 (185) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +839 -267
  3. package/WAProto/GenerateStatics.sh +4 -3
  4. package/WAProto/WAProto.proto +511 -1215
  5. package/WAProto/index.d.ts +55 -14017
  6. package/WAProto/index.js +29 -97689
  7. package/lib/Defaults/index.d.ts +74 -72
  8. package/lib/Defaults/index.js +108 -94
  9. package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
  10. package/lib/Signal/Group/ciphertext-message.js +16 -9
  11. package/lib/Signal/Group/group-session-builder.d.ts +13 -11
  12. package/lib/Signal/Group/group-session-builder.js +61 -19
  13. package/lib/Signal/Group/group_cipher.d.ts +16 -14
  14. package/lib/Signal/Group/group_cipher.js +70 -41
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +61 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +14 -9
  18. package/lib/Signal/Group/keyhelper.js +58 -10
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
  20. package/lib/Signal/Group/sender-chain-key.js +34 -13
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
  22. package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -18
  24. package/lib/Signal/Group/sender-key-message.js +45 -38
  25. package/lib/Signal/Group/sender-key-name.d.ts +15 -14
  26. package/lib/Signal/Group/sender-key-name.js +31 -20
  27. package/lib/Signal/Group/sender-key-record.d.ts +25 -24
  28. package/lib/Signal/Group/sender-key-record.js +35 -18
  29. package/lib/Signal/Group/sender-key-state.d.ts +34 -29
  30. package/lib/Signal/Group/sender-key-state.js +100 -37
  31. package/lib/Signal/Group/sender-message-key.d.ts +10 -11
  32. package/lib/Signal/Group/sender-message-key.js +22 -15
  33. package/lib/Signal/libsignal.d.ts +8 -5
  34. package/lib/Signal/libsignal.js +142 -288
  35. package/lib/Signal/lid-mapping.d.ts +28 -23
  36. package/lib/Signal/lid-mapping.js +184 -277
  37. package/lib/Socket/Client/index.d.ts +2 -3
  38. package/lib/Socket/Client/index.js +22 -3
  39. package/lib/Socket/Client/types.d.ts +15 -15
  40. package/lib/Socket/Client/types.js +15 -8
  41. package/lib/Socket/Client/websocket.d.ts +12 -12
  42. package/lib/Socket/Client/websocket.js +37 -29
  43. package/lib/Socket/business.d.ts +178 -208
  44. package/lib/Socket/business.js +127 -91
  45. package/lib/Socket/chats.d.ts +93 -120
  46. package/lib/Socket/chats.js +652 -727
  47. package/lib/Socket/community.js +10 -2
  48. package/lib/Socket/groups.d.ts +111 -143
  49. package/lib/Socket/groups.js +186 -165
  50. package/lib/Socket/index.d.ts +183 -252
  51. package/lib/Socket/index.js +18 -38
  52. package/lib/Socket/messages-recv.d.ts +167 -196
  53. package/lib/Socket/messages-recv.js +1567 -1443
  54. package/lib/Socket/messages-send.d.ts +158 -192
  55. package/lib/Socket/messages-send.js +1208 -1102
  56. package/lib/Socket/newsletter.d.ts +138 -163
  57. package/lib/Socket/newsletter.js +249 -153
  58. package/lib/Socket/socket.d.ts +36 -50
  59. package/lib/Socket/socket.js +820 -749
  60. package/lib/Store/index.d.ts +4 -4
  61. package/lib/Store/index.js +24 -4
  62. package/lib/Store/make-in-memory-store.d.ts +104 -44
  63. package/lib/Store/make-in-memory-store.js +213 -199
  64. package/lib/Store/make-ordered-dictionary.d.ts +12 -13
  65. package/lib/Store/make-ordered-dictionary.js +45 -38
  66. package/lib/Store/object-repository.d.ts +10 -11
  67. package/lib/Store/object-repository.js +16 -9
  68. package/lib/Types/Auth.d.ts +97 -93
  69. package/lib/Types/Auth.js +3 -2
  70. package/lib/Types/Bussines.js +3 -2
  71. package/lib/Types/Call.d.ts +13 -14
  72. package/lib/Types/Call.js +3 -2
  73. package/lib/Types/Chat.d.ts +97 -78
  74. package/lib/Types/Chat.js +9 -8
  75. package/lib/Types/Contact.d.ts +9 -12
  76. package/lib/Types/Contact.js +3 -2
  77. package/lib/Types/Events.d.ts +176 -206
  78. package/lib/Types/Events.js +3 -2
  79. package/lib/Types/GroupMetadata.d.ts +48 -53
  80. package/lib/Types/GroupMetadata.js +3 -2
  81. package/lib/Types/Label.d.ts +14 -13
  82. package/lib/Types/Label.js +30 -24
  83. package/lib/Types/LabelAssociation.d.ts +20 -15
  84. package/lib/Types/LabelAssociation.js +12 -6
  85. package/lib/Types/Message.d.ts +412 -248
  86. package/lib/Types/Message.js +19 -17
  87. package/lib/Types/Product.d.ts +71 -58
  88. package/lib/Types/Product.js +3 -2
  89. package/lib/Types/Signal.d.ts +82 -71
  90. package/lib/Types/Signal.js +3 -2
  91. package/lib/Types/Socket.d.ts +81 -76
  92. package/lib/Types/Socket.js +3 -3
  93. package/lib/Types/State.d.ts +19 -75
  94. package/lib/Types/State.js +14 -56
  95. package/lib/Types/USync.d.ts +8 -8
  96. package/lib/Types/USync.js +3 -2
  97. package/lib/Types/index.d.ts +62 -47
  98. package/lib/Types/index.js +50 -26
  99. package/lib/Utils/auth-utils.d.ts +10 -13
  100. package/lib/Utils/auth-utils.js +472 -213
  101. package/lib/Utils/business.d.ts +20 -14
  102. package/lib/Utils/business.js +134 -110
  103. package/lib/Utils/chat-utils.d.ts +70 -88
  104. package/lib/Utils/chat-utils.js +403 -466
  105. package/lib/Utils/crypto.d.ts +46 -27
  106. package/lib/Utils/crypto.js +188 -117
  107. package/lib/Utils/decode-wa-message.d.ts +45 -58
  108. package/lib/Utils/decode-wa-message.js +311 -212
  109. package/lib/Utils/event-buffer.d.ts +17 -14
  110. package/lib/Utils/event-buffer.js +296 -321
  111. package/lib/Utils/generics.d.ts +92 -66
  112. package/lib/Utils/generics.js +436 -270
  113. package/lib/Utils/history.d.ts +23 -24
  114. package/lib/Utils/history.js +76 -106
  115. package/lib/Utils/index.d.ts +21 -24
  116. package/lib/Utils/index.js +41 -24
  117. package/lib/Utils/link-preview.d.ts +14 -12
  118. package/lib/Utils/link-preview.js +75 -40
  119. package/lib/Utils/logger.d.ts +11 -10
  120. package/lib/Utils/logger.js +7 -3
  121. package/lib/Utils/lt-hash.d.ts +14 -8
  122. package/lib/Utils/lt-hash.js +53 -3
  123. package/lib/Utils/make-mutex.d.ts +7 -7
  124. package/lib/Utils/make-mutex.js +44 -28
  125. package/lib/Utils/message-retry-manager.d.ts +88 -115
  126. package/lib/Utils/message-retry-manager.js +160 -265
  127. package/lib/Utils/messages-media.d.ts +107 -105
  128. package/lib/Utils/messages-media.js +619 -548
  129. package/lib/Utils/messages.d.ts +66 -52
  130. package/lib/Utils/messages.js +1558 -1730
  131. package/lib/Utils/noise-handler.d.ts +18 -18
  132. package/lib/Utils/noise-handler.js +130 -176
  133. package/lib/Utils/process-message.d.ts +32 -43
  134. package/lib/Utils/process-message.js +282 -484
  135. package/lib/Utils/rich-message-utils.js +724 -1220
  136. package/lib/Utils/signal.d.ts +32 -37
  137. package/lib/Utils/signal.js +105 -140
  138. package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
  139. package/lib/Utils/use-multi-file-auth-state.js +120 -70
  140. package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
  141. package/lib/Utils/use-single-file-auth-state.js +66 -92
  142. package/lib/Utils/validate-connection.d.ts +13 -11
  143. package/lib/Utils/validate-connection.js +113 -128
  144. package/lib/WABinary/constants.d.ts +27 -25
  145. package/lib/WABinary/constants.js +1292 -1451
  146. package/lib/WABinary/decode.d.ts +9 -7
  147. package/lib/WABinary/decode.js +189 -163
  148. package/lib/WABinary/encode.d.ts +3 -3
  149. package/lib/WABinary/encode.js +155 -110
  150. package/lib/WABinary/generic-utils.d.ts +27 -14
  151. package/lib/WABinary/generic-utils.js +105 -177
  152. package/lib/WABinary/index.d.ts +5 -6
  153. package/lib/WABinary/index.js +25 -6
  154. package/lib/WABinary/jid-utils.d.ts +54 -41
  155. package/lib/WABinary/jid-utils.js +152 -83
  156. package/lib/WABinary/types.d.ts +13 -10
  157. package/lib/WABinary/types.js +3 -2
  158. package/lib/WAM/BinaryInfo.d.ts +15 -8
  159. package/lib/WAM/BinaryInfo.js +14 -7
  160. package/lib/WAM/constants.d.ts +37 -30
  161. package/lib/WAM/constants.js +11983 -19465
  162. package/lib/WAM/encode.d.ts +3 -3
  163. package/lib/WAM/encode.js +109 -95
  164. package/lib/WAM/index.d.ts +3 -4
  165. package/lib/WAM/index.js +23 -4
  166. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  167. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
  168. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
  169. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
  170. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
  171. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
  172. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
  173. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
  174. package/lib/WAUSync/Protocols/index.d.ts +6 -6
  175. package/lib/WAUSync/Protocols/index.js +26 -6
  176. package/lib/WAUSync/USyncQuery.d.ts +28 -27
  177. package/lib/WAUSync/USyncQuery.js +62 -68
  178. package/lib/WAUSync/USyncUser.d.ts +10 -15
  179. package/lib/WAUSync/USyncUser.js +19 -20
  180. package/lib/WAUSync/index.d.ts +3 -4
  181. package/lib/WAUSync/index.js +23 -4
  182. package/lib/index.d.ts +12 -11
  183. package/lib/index.js +39 -12
  184. package/package.json +42 -86
  185. package/engine-requirements.js +0 -10
@@ -1,320 +1,484 @@
1
- import type { Readable } from 'stream';
2
- import type { URL } from 'url';
3
- import { proto } from '../../WAProto/index.js';
4
- import type { MediaType } from '../Defaults/index.js';
5
- import type { BinaryNode } from '../WABinary/index.js';
6
- import type { GroupMetadata } from './GroupMetadata.js';
7
- import type { CacheStore } from './Socket.js';
8
- export { proto as WAProto };
9
- export type WAMessage = proto.IWebMessageInfo & {
10
- key: WAMessageKey;
11
- messageStubParameters?: any;
12
- category?: string;
13
- retryCount?: number;
14
- };
15
- export type WAMessageContent = proto.IMessage;
16
- export type WAContactMessage = proto.Message.IContactMessage;
17
- export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
1
+ import { AxiosRequestConfig } from 'axios'
2
+ import { ILogger } from '../Utils/logger'
3
+ import type { Readable } from 'stream'
4
+ import type { URL } from 'url'
5
+ import { proto } from '../../WAProto'
6
+ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults'
7
+ import { BinaryNode } from '../WABinary'
8
+ import type { GroupMetadata } from './GroupMetadata'
9
+ import { CacheStore } from './Socket'
10
+
11
+ export { proto as WAProto }
12
+
13
+ export type WAMessage = proto.IWebMessageInfo
14
+
15
+ export type WAMessageContent = proto.IMessage
16
+
17
+ export type WAContactMessage = proto.Message.IContactMessage
18
+
19
+ export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
20
+
18
21
  export type WAMessageKey = proto.IMessageKey & {
19
- remoteJidAlt?: string;
20
- remoteJidUsername?: string;
21
- participantAlt?: string;
22
- participantUsername?: string;
23
- server_id?: string;
24
- addressingMode?: string;
25
- isViewOnce?: boolean;
26
- };
27
- export type WATextMessage = proto.Message.IExtendedTextMessage;
28
- export type WAContextInfo = proto.IContextInfo;
29
- export type WALocationMessage = proto.Message.ILocationMessage;
30
- export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
31
- export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
32
- export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
33
- import type { ILogger } from '../Utils/logger.js';
34
- export type WAMediaPayloadURL = {
35
- url: URL | string;
36
- };
37
- export type WAMediaPayloadStream = {
38
- stream: Readable;
22
+ remoteJidAlt?: string
23
+ participantAlt?: string
24
+ newsletter_server_id?: string
25
+ isViewOnce?: boolean
39
26
  };
40
- export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
27
+
28
+ export type WATextMessage = proto.Message.IExtendedTextMessage
29
+
30
+ export type WAContextInfo = proto.IContextInfo
31
+
32
+ export type WALocationMessage = proto.Message.ILocationMessage
33
+
34
+ export type WAOrderMessage = proto.Message.IOrderMessage
35
+
36
+ export type WAEventMessage = proto.Message.IEventMessage
37
+
38
+ export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
39
+
40
+ export declare const WAMessageStubType = proto.WebMessageInfo.StubType
41
+
42
+ export declare const WAMessageStatus = proto.WebMessageInfo.Status
43
+
44
+ export type WAMediaUpload = Buffer | {
45
+ url: URL | string
46
+ } | {
47
+ stream: Readable
48
+ }
49
+
41
50
  /** Set of message types that are supported by the library */
42
- export type MessageType = keyof proto.Message;
51
+ export type MessageType = keyof proto.Message
52
+
43
53
  export declare enum WAMessageAddressingMode {
44
- PN = "pn",
45
- LID = "lid"
54
+ PN = 'pn',
55
+ LID = 'lid'
46
56
  }
47
- 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';
57
+
48
58
  export type DownloadableMessage = {
49
- mediaKey?: Uint8Array | null;
50
- directPath?: string | null;
51
- url?: string | null;
52
- };
53
- export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
59
+ mediaKey?: Uint8Array | null
60
+ directPath?: string | null
61
+ url?: string | null
62
+ }
63
+
64
+ export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined
65
+
54
66
  export type MediaConnInfo = {
55
- auth: string;
56
- ttl: number;
67
+ auth: string
68
+ ttl: number
57
69
  hosts: {
58
- hostname: string;
59
- maxContentLengthBytes: number;
60
- }[];
61
- fetchDate: Date;
62
- };
70
+ hostname: string
71
+ maxContentLengthBytes: number
72
+ }[]
73
+ fetchDate: Date
74
+ }
75
+
76
+ export interface StickerPack {
77
+ stickers: Sticker[]
78
+ cover: WAMediaUpload
79
+ name: string
80
+ publisher: string
81
+ description?: string
82
+ packId?: string
83
+ }
84
+
85
+ export interface Carousel {
86
+ image?: WAMediaUpload
87
+ video?: WAMediaUpload
88
+ product?: WASendableProduct
89
+ title?: string
90
+ body?: string
91
+ footer?: string
92
+ buttons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[]
93
+ }
94
+
63
95
  export interface WAUrlInfo {
64
- 'canonical-url': string;
65
- 'matched-text': string;
66
- title: string;
67
- description?: string;
68
- jpegThumbnail?: Buffer;
69
- highQualityThumbnail?: proto.Message.IImageMessage;
70
- originalThumbnailUrl?: string;
96
+ 'canonical-url': string
97
+ 'matched-text': string
98
+ title: string
99
+ description?: string
100
+ jpegThumbnail?: Buffer
101
+ highQualityThumbnail?: proto.Message.IImageMessage
102
+ originalThumbnailUrl?: string
71
103
  }
104
+
72
105
  type Mentionable = {
73
106
  /** list of jids that are mentioned in the accompanying text */
74
- mentions?: string[];
75
- /** mention all */
76
- mentionAll?: boolean;
77
- };
107
+ mentions?: string[]
108
+ }
109
+
78
110
  type Contextable = {
79
111
  /** add contextInfo to the message */
80
- contextInfo?: proto.IContextInfo;
81
- };
112
+ contextInfo?: proto.IContextInfo
113
+ }
114
+
115
+ type Ephemeral = {
116
+ ephemeral?: boolean
117
+ }
118
+
82
119
  type ViewOnce = {
83
- viewOnce?: boolean;
84
- };
120
+ viewOnce?: boolean
121
+ }
122
+
123
+ type ViewOnceExt = {
124
+ viewOnceExt?: boolean
125
+ }
126
+
127
+ type Buttonable = {
128
+ /** add buttons to the message */
129
+ buttons?: proto.Message.ButtonsMessage.IButton[]
130
+ }
131
+
132
+ type Templatable = {
133
+ /** add buttons to the message (conflicts with normal buttons)*/
134
+ templateButtons?: proto.IHydratedTemplateButton[]
135
+ footer?: string
136
+ }
137
+
138
+ type Interactiveable = {
139
+ /** add buttons to the message (conflicts with normal buttons)*/
140
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.INativeFlowButton[]
141
+ title?: string
142
+ subtitle?: string
143
+ footer?: string
144
+ hasMediaAttachment?: boolean
145
+ }
146
+
147
+ type Shopable = {
148
+ shop?: proto.Message.InteractiveMessage.ShopMessage
149
+ title?: string
150
+ subtitle?: string
151
+ footer?: string
152
+ hasMediaAttachment?: boolean
153
+ }
154
+
155
+ type Collectionable = {
156
+ collection?: proto.Message.InteractiveMessage.CollectionMessage
157
+ title?: string
158
+ subtitle?: string
159
+ footer?: string
160
+ hasMediaAttachment?: boolean
161
+ }
162
+
163
+ type Listable = {
164
+ /** Sections of the List */
165
+ sections?: proto.Message.ListMessage.ISection[]
166
+ /** Title of a List Message only */
167
+ title?: string
168
+ /** Text of the button on the list (required) */
169
+ buttonText?: string
170
+ /** ListType of a List Message only */
171
+ listType?: proto.Message.ListMessage.ListType
172
+ }
173
+
174
+ type Cardsable = {
175
+ cards?: Carousel[]
176
+ title?: string
177
+ subtitle?: string
178
+ footer?: string
179
+ }
180
+
85
181
  type Editable = {
86
- edit?: WAMessageKey;
87
- };
182
+ edit?: WAMessageKey
183
+ }
184
+
88
185
  type WithDimensions = {
89
- width?: number;
90
- height?: number;
91
- };
186
+ width?: number
187
+ height?: number
188
+ }
189
+
190
+ export type Sticker = {
191
+ data: WAMediaUpload
192
+ emojis?: string[]
193
+ accessibilityLabel?: string
194
+ }
195
+
92
196
  export type PollMessageOptions = {
93
- name: string;
94
- selectableCount?: number;
95
- values: string[];
197
+ name: string
198
+ selectableCount?: number
199
+ values: string[]
96
200
  /** 32 byte message secret to encrypt poll selections */
97
- messageSecret?: Uint8Array;
98
- toAnnouncementGroup?: boolean;
99
- };
100
- export type EventMessageOptions = {
101
- name: string;
102
- description?: string;
103
- startDate: Date;
104
- endDate?: Date;
105
- location?: WALocationMessage;
106
- call?: 'audio' | 'video';
107
- isCancelled?: boolean;
108
- isScheduleCall?: boolean;
109
- extraGuestsAllowed?: boolean;
110
- messageSecret?: Uint8Array<ArrayBufferLike>;
111
- };
112
- export type AlbumMessageOptions = {
113
- /** Number of images expected in the album */
114
- expectedImageCount?: number;
115
- /** Number of videos expected in the album */
116
- expectedVideoCount?: number;
117
- };
201
+ messageSecret?: Uint8Array
202
+ toAnnouncementGroup?: boolean
203
+ }
204
+
205
+ export type PollResultOptions = {
206
+ name: string
207
+ values: string[]
208
+ }
209
+
118
210
  type SharePhoneNumber = {
119
- sharePhoneNumber: boolean;
120
- };
211
+ sharePhoneNumber: boolean
212
+ }
213
+
121
214
  type RequestPhoneNumber = {
122
- requestPhoneNumber: boolean;
123
- };
215
+ requestPhoneNumber: boolean
216
+ }
217
+
218
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING
219
+
124
220
  export type AnyMediaMessageContent = (({
125
- image: WAMediaUpload;
126
- caption?: string;
127
- jpegThumbnail?: string;
128
- } & Mentionable & Contextable & WithDimensions) | ({
129
- video: WAMediaUpload;
130
- caption?: string;
131
- gifPlayback?: boolean;
132
- jpegThumbnail?: string;
133
- /** if set to true, will send as a `video note` */
134
- ptv?: boolean;
135
- } & Mentionable & Contextable & WithDimensions) | {
136
- audio: WAMediaUpload;
221
+ image: WAMediaUpload
222
+ caption?: string
223
+ jpegThumbnail?: string
224
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & WithDimensions) | ({
225
+ video: WAMediaUpload
226
+ caption?: string
227
+ gifPlayback?: boolean
228
+ jpegThumbnail?: string
229
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & WithDimensions) | {
230
+ audio: WAMediaUpload
137
231
  /** if set to true, will send as a `voice note` */
138
- ptt?: boolean;
232
+ ptt?: boolean
139
233
  /** optionally tell the duration of the audio */
140
- seconds?: number;
234
+ seconds?: number
141
235
  } | ({
142
- sticker: WAMediaUpload;
143
- isAnimated?: boolean;
236
+ sticker: WAMediaUpload
237
+ isAnimated?: boolean
144
238
  } & WithDimensions) | ({
145
- document: WAMediaUpload;
146
- mimetype: string;
147
- fileName?: string;
148
- caption?: string;
149
- } & Contextable)) & {
150
- mimetype?: string;
151
- } & Editable & {
152
- /** key of the parent albumMessage to associate this media with */
153
- albumParentKey?: WAMessageKey;
154
- };
239
+ document: WAMediaUpload
240
+ mimetype: string
241
+ fileName?: string
242
+ caption?: string
243
+ } & Contextable & Buttonable & Templatable & Interactiveable )) & {
244
+ mimetype?: string
245
+ } & Editable
246
+
155
247
  export type ButtonReplyInfo = {
156
- displayText: string;
157
- id: string;
158
- index: number;
159
- };
248
+ displayText: string
249
+ id: string
250
+ index: number
251
+ }
252
+
160
253
  export type GroupInviteInfo = {
161
- inviteCode: string;
162
- inviteExpiration: number;
163
- text: string;
164
- jid: string;
165
- subject: string;
166
- };
254
+ code: string
255
+ expiration: number
256
+ caption: string
257
+ jid: string
258
+ name: string
259
+ jpegThumbnail?: string
260
+ }
261
+
262
+ export type CallCreationInfo = {
263
+ time?: number
264
+ type?: number
265
+ name: string
266
+ }
267
+
268
+ export type AdminInviteInfo = {
269
+ jid: string
270
+ name: string
271
+ caption: string
272
+ expiration: number
273
+ jpegThumbnail: string
274
+ }
275
+
276
+ export type PinInfo = {
277
+ key: WAMessageKey
278
+ type?: number
279
+ time?: number
280
+ }
281
+
282
+ export type KeepInfo = {
283
+ key: WAMessageKey
284
+ type: number
285
+ }
286
+
287
+ export type PaymentInfo = {
288
+ note: string
289
+ currency?: string
290
+ offset?: number
291
+ amount?: number
292
+ expiry?: number
293
+ from?: string
294
+ image?: {
295
+ placeholderArgb: number
296
+ textArgb: number
297
+ subtextArgb: number
298
+ }
299
+ }
300
+
167
301
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
168
- productImage: WAMediaUpload;
169
- };
302
+ productImage: WAMediaUpload
303
+ }
304
+
170
305
  export type AnyRegularMessageContent = (({
171
- text: string;
172
- linkPreview?: WAUrlInfo | null;
173
- } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | {
174
- event: EventMessageOptions;
175
- } | ({
176
- poll: PollMessageOptions;
177
- } & Mentionable & Contextable & Editable) | ({
178
- album: AlbumMessageOptions;
179
- } & Contextable & Mentionable) | {
306
+ text: string
307
+ linkPreview?: WAUrlInfo | null
308
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & Listable & Editable & WithDimensions) | AnyMediaMessageContent | ({
309
+ poll: PollMessageOptions
310
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & Listable & Editable & WithDimensions) | {
180
311
  contacts: {
181
- displayName?: string;
182
- contacts: proto.Message.IContactMessage[];
183
- };
312
+ displayName?: string
313
+ contacts: proto.Message.IContactMessage[]
314
+ }
315
+ } | {
316
+ location: WALocationMessage
184
317
  } | {
185
- location: WALocationMessage;
318
+ react: proto.Message.IReactionMessage
186
319
  } | {
187
- react: proto.Message.IReactionMessage;
320
+ buttonReply: ButtonReplyInfo
321
+ type: 'template' | 'plain' | 'list' | 'interactive'
188
322
  } | {
189
- buttonReply: ButtonReplyInfo;
190
- type: 'template' | 'plain';
323
+ groupInvite: GroupInviteInfo
191
324
  } | {
192
- groupInvite: GroupInviteInfo;
325
+ pin: PinInfo
193
326
  } | {
194
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
327
+ keep: KeepInfo
195
328
  } | {
196
- pin: WAMessageKey;
197
- type: proto.PinInChat.Type;
198
- /**
199
- * 24 hours, 7 days, 30 days
200
- */
201
- time?: 86400 | 604800 | 2592000;
329
+ call: CallCreationInfo
202
330
  } | {
203
- product: WASendableProduct;
204
- businessOwnerJid?: string;
205
- body?: string;
206
- footer?: string;
207
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
331
+ event: WAEventMessage
332
+ } | {
333
+ adminInvite: AdminInviteInfo
334
+ } | {
335
+ payment: PaymentInfo
336
+ } | {
337
+ paymentInvite: {
338
+ type: number
339
+ expiry: number
340
+ }
341
+ } | {
342
+ pollResult: PollResultOptions
343
+ } | {
344
+ order: WAOrderMessage
345
+ } | {
346
+ product: WASendableProduct
347
+ businessOwnerJid?: string
348
+ body?: string
349
+ footer?: string
350
+ } | {
351
+ stickerPack: StickerPack
352
+ } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce & ViewOnceExt
353
+
208
354
  export type AnyMessageContent = AnyRegularMessageContent | {
209
- forward: WAMessage;
210
- force?: boolean;
355
+ forward: WAMessage
356
+ force?: boolean
211
357
  } | {
212
358
  /** Delete your message or anyone's message in a group (admin required) */
213
- delete: WAMessageKey;
214
- } | {
215
- disappearingMessagesInChat: boolean | number;
359
+ delete: WAMessageKey
216
360
  } | {
217
- limitSharing: boolean;
218
- };
219
- export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
361
+ disappearingMessagesInChat: boolean | number
362
+ }
363
+
364
+ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>
365
+
220
366
  type MinimalRelayOptions = {
221
367
  /** override the message ID with a custom provided string */
222
- messageId?: string;
223
- /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
224
- useCachedGroupMetadata?: boolean;
225
- };
368
+ messageId?: string
369
+ /** should we use group metadata cache, or fetch afresh from the server default assumed to be "true" */
370
+ useCachedGroupMetadata?: boolean
371
+ }
372
+
226
373
  export type MessageRelayOptions = MinimalRelayOptions & {
227
- /** only send to a specific participant; used when a message decryption fails for a single user */
374
+ /** only send to a specific participant used when a message decryption fails for a single user */
228
375
  participant?: {
229
- jid: string;
230
- count: number;
231
- };
376
+ jid: string
377
+ count: number
378
+ }
232
379
  /** additional attributes to add to the WA binary node */
233
380
  additionalAttributes?: {
234
- [_: string]: string;
235
- };
236
- additionalNodes?: BinaryNode[];
237
- /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
238
- useUserDevicesCache?: boolean;
381
+ [_: string]: string
382
+ }
383
+ additionalNodes?: BinaryNode[]
384
+ /** should we use the devices cache, or fetch afresh from the server default assumed to be "true" */
385
+ useUserDevicesCache?: boolean
239
386
  /** jid list of participants for status@broadcast */
240
- statusJidList?: string[];
241
- };
387
+ statusJidList?: string[]
388
+ newsletter?: boolean
389
+ }
390
+
242
391
  export type MiscMessageGenerationOptions = MinimalRelayOptions & {
243
392
  /** optional, if you want to manually set the timestamp of the message */
244
- timestamp?: Date;
393
+ timestamp?: Date
245
394
  /** the message you want to quote */
246
- quoted?: WAMessage;
395
+ quoted?: WAMessage
247
396
  /** disappearing messages settings */
248
- ephemeralExpiration?: number | string;
397
+ ephemeralExpiration?: number | string
249
398
  /** timeout for media upload to WA server */
250
- mediaUploadTimeoutMs?: number;
399
+ mediaUploadTimeoutMs?: number
251
400
  /** jid list of participants for status@broadcast */
252
- statusJidList?: string[];
401
+ statusJidList?: string[]
253
402
  /** backgroundcolor for status */
254
- backgroundColor?: string;
403
+ backgroundColor?: string
255
404
  /** font type for status */
256
- font?: number;
405
+ font?: number
257
406
  /** if it is broadcast */
258
- broadcast?: boolean;
259
- };
407
+ broadcast?: boolean
408
+ newsletter?: boolean
409
+ additionalNodes?: BinaryNode[]
410
+ }
411
+
260
412
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
261
- userJid: string;
262
- };
263
- export type WAMediaUploadFunction = (encFilePath: string, opts: {
264
- fileEncSha256B64: string;
265
- mediaType: MediaType;
266
- timeoutMs?: number;
267
- }) => Promise<{
268
- mediaUrl: string;
269
- directPath: string;
270
- meta_hmac?: string;
271
- ts?: number;
272
- fbid?: number;
273
- }>;
413
+ userJid: string
414
+ }
415
+
416
+ export type WAMediaUploadFunctionOpts = {
417
+ fileEncSha256B64: string
418
+ mediaType: MediaType
419
+ newsletter?: boolean
420
+ timeoutMs?: number
421
+ }
422
+
423
+ export type WAMediaUploadFunction = (encFilePath: string | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
424
+ mediaUrl: string
425
+ directPath: string
426
+ handle?: string
427
+ meta_hmac?: string
428
+ ts?: number
429
+ fbid?: number
430
+ }>
431
+
274
432
  export type MediaGenerationOptions = {
275
- logger?: ILogger;
276
- mediaTypeOverride?: MediaType;
277
- upload: WAMediaUploadFunction;
433
+ logger?: ILogger
434
+ mediaTypeOverride?: MediaType
435
+ upload: WAMediaUploadFunction
278
436
  /** cache media so it does not have to be uploaded again */
279
- mediaCache?: CacheStore;
280
- mediaUploadTimeoutMs?: number;
281
- options?: RequestInit;
282
- backgroundColor?: string;
283
- font?: number;
284
- };
437
+ mediaCache?: CacheStore
438
+ mediaUploadTimeoutMs?: number
439
+ options?: AxiosRequestConfig
440
+ backgroundColor?: string
441
+ font?: number
442
+ /** The message is for newsletter? */
443
+ newsletter?: boolean
444
+ }
445
+
285
446
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
286
- getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
287
- getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
288
- getCallLink?: (type: 'audio' | 'video', event?: {
289
- startTime: number;
290
- }) => Promise<string | undefined>;
291
- jid?: string;
292
- };
293
- export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
447
+ getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>
448
+ getProfilePicUrl?: (jid: string) => Promise<string | undefined>
449
+ getCallLink?: (type: 'audio' | 'video', event?: number) => Promise<string | undefined>
450
+ }
451
+
452
+ export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent
294
453
  /**
295
454
  * Type of message upsert
296
455
  * 1. notify => notify the user, this message was just received
297
456
  * 2. append => append the message to the chat history, no notification required
298
457
  */
299
- export type MessageUpsertType = 'append' | 'notify';
300
- export type MessageUserReceipt = proto.IUserReceipt;
458
+ export type MessageUpsertType = 'append' | 'notify'
459
+
460
+ export type MessageUserReceipt = proto.IUserReceipt
461
+
301
462
  export type WAMessageUpdate = {
302
- update: Partial<WAMessage>;
303
- key: WAMessageKey;
304
- };
463
+ update: Partial<WAMessage>
464
+ key: proto.IMessageKey
465
+ }
466
+
305
467
  export type WAMessageCursor = {
306
- before: WAMessageKey | undefined;
468
+ before: WAMessageKey | undefined
307
469
  } | {
308
- after: WAMessageKey | undefined;
309
- };
470
+ after: WAMessageKey | undefined
471
+ }
472
+
310
473
  export type MessageUserReceiptUpdate = {
311
- key: WAMessageKey;
312
- receipt: MessageUserReceipt;
313
- };
474
+ key: proto.IMessageKey
475
+ receipt: MessageUserReceipt
476
+ }
477
+
314
478
  export type MediaDecryptionKeyInfo = {
315
- iv: Uint8Array;
316
- cipherKey: Uint8Array;
317
- macKey?: Uint8Array;
318
- };
319
- export type MinimalMessage = Pick<WAMessage, 'key' | 'messageTimestamp'>;
320
- //# sourceMappingURL=Message.d.ts.map
479
+ iv: Buffer
480
+ cipherKey: Buffer
481
+ macKey?: Buffer
482
+ }
483
+
484
+ export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>