kyzorohan 1.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 (198) hide show
  1. package/WAProto/GenerateStatics.sh +4 -0
  2. package/WAProto/WAProto.proto +3345 -0
  3. package/WAProto/index.d.ts +37016 -0
  4. package/WAProto/index.js +169661 -0
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +3 -0
  7. package/lib/Defaults/index.d.ts +53 -0
  8. package/lib/Defaults/index.js +147 -0
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  13. package/lib/Signal/Group/group-session-builder.js +64 -0
  14. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  15. package/lib/Signal/Group/group_cipher.js +96 -0
  16. package/lib/Signal/Group/index.d.ts +11 -0
  17. package/lib/Signal/Group/index.js +57 -0
  18. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  19. package/lib/Signal/Group/keyhelper.js +55 -0
  20. package/lib/Signal/Group/queue-job.d.ts +1 -0
  21. package/lib/Signal/Group/queue-job.js +57 -0
  22. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  23. package/lib/Signal/Group/sender-chain-key.js +34 -0
  24. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  25. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  26. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  27. package/lib/Signal/Group/sender-key-message.js +69 -0
  28. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  29. package/lib/Signal/Group/sender-key-name.js +51 -0
  30. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  31. package/lib/Signal/Group/sender-key-record.js +53 -0
  32. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  33. package/lib/Signal/Group/sender-key-state.js +99 -0
  34. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  35. package/lib/Signal/Group/sender-message-key.js +29 -0
  36. package/lib/Signal/libsignal.d.ts +3 -0
  37. package/lib/Signal/libsignal.js +174 -0
  38. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  39. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  40. package/lib/Socket/Client/index.d.ts +3 -0
  41. package/lib/Socket/Client/index.js +19 -0
  42. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  43. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  44. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  45. package/lib/Socket/Client/web-socket-client.js +62 -0
  46. package/lib/Socket/business.d.ts +171 -0
  47. package/lib/Socket/business.js +261 -0
  48. package/lib/Socket/chats.d.ts +267 -0
  49. package/lib/Socket/chats.js +988 -0
  50. package/lib/Socket/dugong.d.ts +254 -0
  51. package/lib/Socket/groups.d.ts +115 -0
  52. package/lib/Socket/groups.js +322 -0
  53. package/lib/Socket/ibranihbossenggoldong.js +484 -0
  54. package/lib/Socket/index.d.ts +173 -0
  55. package/lib/Socket/index.js +11 -0
  56. package/lib/Socket/messages-recv.d.ts +161 -0
  57. package/lib/Socket/messages-recv.js +1117 -0
  58. package/lib/Socket/messages-send.d.ts +149 -0
  59. package/lib/Socket/messages-send.js +916 -0
  60. package/lib/Socket/newsletter.d.ts +139 -0
  61. package/lib/Socket/newsletter.js +386 -0
  62. package/lib/Socket/registration.d.ts +272 -0
  63. package/lib/Socket/registration.js +167 -0
  64. package/lib/Socket/socket.d.ts +43 -0
  65. package/lib/Socket/socket.js +669 -0
  66. package/lib/Socket/usync.d.ts +36 -0
  67. package/lib/Socket/usync.js +73 -0
  68. package/lib/Store/index.d.ts +3 -0
  69. package/lib/Store/index.js +10 -0
  70. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  71. package/lib/Store/make-cache-manager-store.js +83 -0
  72. package/lib/Store/make-in-memory-store.d.ts +118 -0
  73. package/lib/Store/make-in-memory-store.js +430 -0
  74. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  75. package/lib/Store/make-ordered-dictionary.js +81 -0
  76. package/lib/Store/object-repository.d.ts +10 -0
  77. package/lib/Store/object-repository.js +27 -0
  78. package/lib/Types/Auth.d.ts +110 -0
  79. package/lib/Types/Auth.js +2 -0
  80. package/lib/Types/Call.d.ts +13 -0
  81. package/lib/Types/Call.js +2 -0
  82. package/lib/Types/Chat.d.ts +102 -0
  83. package/lib/Types/Chat.js +4 -0
  84. package/lib/Types/Contact.d.ts +19 -0
  85. package/lib/Types/Contact.js +2 -0
  86. package/lib/Types/Events.d.ts +157 -0
  87. package/lib/Types/Events.js +2 -0
  88. package/lib/Types/GroupMetadata.d.ts +55 -0
  89. package/lib/Types/GroupMetadata.js +2 -0
  90. package/lib/Types/Label.d.ts +35 -0
  91. package/lib/Types/Label.js +27 -0
  92. package/lib/Types/LabelAssociation.d.ts +29 -0
  93. package/lib/Types/LabelAssociation.js +9 -0
  94. package/lib/Types/Message.d.ts +273 -0
  95. package/lib/Types/Message.js +9 -0
  96. package/lib/Types/Newsletter.d.ts +103 -0
  97. package/lib/Types/Newsletter.js +38 -0
  98. package/lib/Types/Product.d.ts +78 -0
  99. package/lib/Types/Product.js +2 -0
  100. package/lib/Types/Signal.d.ts +57 -0
  101. package/lib/Types/Signal.js +2 -0
  102. package/lib/Types/Socket.d.ts +111 -0
  103. package/lib/Types/Socket.js +2 -0
  104. package/lib/Types/State.d.ts +27 -0
  105. package/lib/Types/State.js +2 -0
  106. package/lib/Types/USync.d.ts +25 -0
  107. package/lib/Types/USync.js +2 -0
  108. package/lib/Types/index.d.ts +57 -0
  109. package/lib/Types/index.js +46 -0
  110. package/lib/Utils/auth-utils.d.ts +18 -0
  111. package/lib/Utils/auth-utils.js +209 -0
  112. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  113. package/lib/Utils/baileys-event-stream.js +63 -0
  114. package/lib/Utils/business.d.ts +22 -0
  115. package/lib/Utils/business.js +234 -0
  116. package/lib/Utils/chat-utils.d.ts +71 -0
  117. package/lib/Utils/chat-utils.js +729 -0
  118. package/lib/Utils/crypto.d.ts +41 -0
  119. package/lib/Utils/crypto.js +155 -0
  120. package/lib/Utils/decode-wa-message.d.ts +19 -0
  121. package/lib/Utils/decode-wa-message.js +198 -0
  122. package/lib/Utils/event-buffer.d.ts +35 -0
  123. package/lib/Utils/event-buffer.js +514 -0
  124. package/lib/Utils/generics.d.ts +92 -0
  125. package/lib/Utils/generics.js +427 -0
  126. package/lib/Utils/history.d.ts +15 -0
  127. package/lib/Utils/history.js +96 -0
  128. package/lib/Utils/ibra-decode.d.ts +2 -0
  129. package/lib/Utils/ibra-decode.js +54 -0
  130. package/lib/Utils/index.d.ts +17 -0
  131. package/lib/Utils/index.js +33 -0
  132. package/lib/Utils/link-preview.d.ts +21 -0
  133. package/lib/Utils/link-preview.js +93 -0
  134. package/lib/Utils/logger.d.ts +4 -0
  135. package/lib/Utils/logger.js +7 -0
  136. package/lib/Utils/lt-hash.d.ts +12 -0
  137. package/lib/Utils/lt-hash.js +51 -0
  138. package/lib/Utils/make-mutex.d.ts +7 -0
  139. package/lib/Utils/make-mutex.js +43 -0
  140. package/lib/Utils/messages-media.d.ts +116 -0
  141. package/lib/Utils/messages-media.js +819 -0
  142. package/lib/Utils/messages.d.ts +77 -0
  143. package/lib/Utils/messages.js +789 -0
  144. package/lib/Utils/noise-handler.d.ts +21 -0
  145. package/lib/Utils/noise-handler.js +155 -0
  146. package/lib/Utils/process-message.d.ts +41 -0
  147. package/lib/Utils/process-message.js +321 -0
  148. package/lib/Utils/signal.d.ts +32 -0
  149. package/lib/Utils/signal.js +157 -0
  150. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  151. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  152. package/lib/Utils/validate-connection.d.ts +11 -0
  153. package/lib/Utils/validate-connection.js +229 -0
  154. package/lib/WABinary/constants.d.ts +30 -0
  155. package/lib/WABinary/constants.js +40 -0
  156. package/lib/WABinary/decode.d.ts +7 -0
  157. package/lib/WABinary/decode.js +256 -0
  158. package/lib/WABinary/encode.d.ts +3 -0
  159. package/lib/WABinary/encode.js +269 -0
  160. package/lib/WABinary/generic-utils.d.ts +17 -0
  161. package/lib/WABinary/generic-utils.js +198 -0
  162. package/lib/WABinary/index.d.ts +5 -0
  163. package/lib/WABinary/index.js +21 -0
  164. package/lib/WABinary/jid-utils.d.ts +31 -0
  165. package/lib/WABinary/jid-utils.js +62 -0
  166. package/lib/WABinary/types.d.ts +18 -0
  167. package/lib/WABinary/types.js +2 -0
  168. package/lib/WAM/BinaryInfo.d.ts +17 -0
  169. package/lib/WAM/BinaryInfo.js +13 -0
  170. package/lib/WAM/constants.d.ts +38 -0
  171. package/lib/WAM/constants.js +15350 -0
  172. package/lib/WAM/encode.d.ts +3 -0
  173. package/lib/WAM/encode.js +155 -0
  174. package/lib/WAM/index.d.ts +3 -0
  175. package/lib/WAM/index.js +19 -0
  176. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  177. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  178. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  179. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  180. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  181. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  182. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  183. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  184. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  185. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  186. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  187. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  188. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  189. package/lib/WAUSync/Protocols/index.js +20 -0
  190. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  191. package/lib/WAUSync/USyncQuery.js +89 -0
  192. package/lib/WAUSync/USyncUser.d.ts +12 -0
  193. package/lib/WAUSync/USyncUser.js +26 -0
  194. package/lib/WAUSync/index.d.ts +3 -0
  195. package/lib/WAUSync/index.js +19 -0
  196. package/lib/index.d.ts +12 -0
  197. package/lib/index.js +45 -0
  198. package/package.json +112 -0
@@ -0,0 +1,254 @@
1
+ // dugong.d.ts
2
+ import { proto } from '../../WAProto';
3
+
4
+ declare namespace kikyy {
5
+ interface MediaUploadOptions {
6
+ fileEncSha256?: Buffer;
7
+ mediaType?: string;
8
+ newsletter?: boolean;
9
+ }
10
+
11
+ type WAMediaUploadFunction = (
12
+ stream: Buffer | NodeJS.ReadableStream,
13
+ options?: MediaUploadOptions
14
+ ) => Promise<{ url: string; directPath: string }>;
15
+
16
+ interface WAMessageContentGenerationOptions {
17
+ upload?: WAMediaUploadFunction;
18
+ mediaCache?: any;
19
+ options?: any;
20
+ logger?: any;
21
+ }
22
+
23
+ interface StickerMessage {
24
+ url: string;
25
+ fileSha256: Buffer | string;
26
+ fileEncSha256: Buffer | string;
27
+ mediaKey: Buffer | string;
28
+ mimetype: string;
29
+ directPath: string;
30
+ fileLength: number | string;
31
+ mediaKeyTimestamp: number | string;
32
+ isAnimated?: boolean;
33
+ stickerSentTs?: number | string;
34
+ isAvatar?: boolean;
35
+ isAiSticker?: boolean;
36
+ isLottie?: boolean;
37
+ }
38
+
39
+ interface PaymentMessage {
40
+ amount: number;
41
+ currency?: string;
42
+ from?: string;
43
+ expiry?: number;
44
+ sticker?: { stickerMessage: StickerMessage };
45
+ note?: string;
46
+ background?: {
47
+ id?: string;
48
+ fileLength?: string;
49
+ width?: number;
50
+ height?: number;
51
+ mimetype?: string;
52
+ placeholderArgb?: number;
53
+ textArgb?: number;
54
+ subtextArgb?: number;
55
+ };
56
+ }
57
+
58
+ interface ProductMessage {
59
+ title: string;
60
+ description: string;
61
+ thumbnail: Buffer | { url: string };
62
+ productId: string;
63
+ retailerId: string;
64
+ url: string;
65
+ body?: string;
66
+ footer?: string;
67
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
68
+ priceAmount1000?: number | null;
69
+ currencyCode?: string;
70
+ }
71
+
72
+ interface InteractiveMessage {
73
+ header?: string;
74
+ title: string;
75
+ footer?: string;
76
+ thumbnail?: string;
77
+ image?: string | Buffer | { url: string };
78
+ video?: string | Buffer | { url: string };
79
+ document?: string | Buffer | { url: string };
80
+ mimetype?: string;
81
+ fileName?: string;
82
+ jpegThumbnail?: string | Buffer | { url: string };
83
+ contextInfo?: {
84
+ mentionedJid?: string[];
85
+ forwardingScore?: number;
86
+ isForwarded?: boolean;
87
+ externalAdReply?: {
88
+ title?: string;
89
+ body?: string;
90
+ mediaType?: number;
91
+ thumbnailUrl?: string;
92
+ mediaUrl?: string;
93
+ sourceUrl?: string;
94
+ showAdAttribution?: boolean;
95
+ renderLargerThumbnail?: boolean;
96
+ [key: string]: any;
97
+ };
98
+ [key: string]: any;
99
+ };
100
+ externalAdReply?: {
101
+ title?: string;
102
+ body?: string;
103
+ mediaType?: number;
104
+ thumbnailUrl?: string;
105
+ mediaUrl?: string;
106
+ sourceUrl?: string;
107
+ showAdAttribution?: boolean;
108
+ renderLargerThumbnail?: boolean;
109
+ [key: string]: any;
110
+ };
111
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
112
+ nativeFlowMessage?: {
113
+ messageParamsJson?: string;
114
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
115
+ [key: string]: any;
116
+ };
117
+ }
118
+
119
+ interface AlbumItem {
120
+ image?: string | Buffer | { url: string; caption?: string };
121
+ video?: string | Buffer | { url: string; caption?: string };
122
+ }
123
+
124
+ interface EventMessageLocation {
125
+ degreesLatitude: number;
126
+ degreesLongitude: number;
127
+ name: string;
128
+ }
129
+
130
+ interface EventMessage {
131
+ isCanceled?: boolean;
132
+ name: string;
133
+ description: string;
134
+ location?: EventMessageLocation;
135
+ joinLink?: string;
136
+ startTime?: string | number;
137
+ endTime?: string | number;
138
+ extraGuestsAllowed?: boolean;
139
+ }
140
+
141
+ interface PollVote {
142
+ optionName: string;
143
+ optionVoteCount: string | number;
144
+ }
145
+
146
+ interface PollResultMessage {
147
+ name: string;
148
+ pollVotes: PollVote[];
149
+ }
150
+
151
+ interface GroupStatusMessage {
152
+ message?: any;
153
+ image?: string | Buffer | { url: string };
154
+ video?: string | Buffer | { url: string };
155
+ text?: string;
156
+ caption?: string;
157
+ document?: string | Buffer | { url: string };
158
+ [key: string]: any;
159
+ }
160
+
161
+ interface MessageContent {
162
+ requestPaymentMessage?: PaymentMessage;
163
+ productMessage?: ProductMessage;
164
+ interactiveMessage?: InteractiveMessage;
165
+ albumMessage?: AlbumItem[];
166
+ eventMessage?: EventMessage;
167
+ pollResultMessage?: PollResultMessage;
168
+ groupStatusMessage?: GroupStatusMessage;
169
+ sender?: string;
170
+ }
171
+
172
+ interface MessageOptions {
173
+ quoted?: proto.IWebMessageInfo;
174
+ filter?: boolean;
175
+ }
176
+
177
+ interface Utils {
178
+ prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
179
+ generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
180
+ generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
181
+ generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
182
+ generateMessageID: () => string;
183
+ prepareMessageContent?: (content: any, options?: any) => Promise<any>;
184
+ }
185
+
186
+ interface BailUtils {
187
+ generateWAMessageContent?: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
188
+ generateMessageID: () => string;
189
+ getContentType: (msg: any) => string;
190
+ }
191
+ }
192
+
193
+ declare class kikyy {
194
+ constructor(
195
+ utils: kikyy.Utils,
196
+ waUploadToServer: kikyy.WAMediaUploadFunction,
197
+ relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
198
+ );
199
+
200
+ detectType(content: kikyy.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | null;
201
+
202
+ handlePayment(
203
+ content: { requestPaymentMessage: kikyy.PaymentMessage },
204
+ quoted?: proto.IWebMessageInfo
205
+ ): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
206
+
207
+ handleProduct(
208
+ content: { productMessage: kikyy.ProductMessage },
209
+ jid: string,
210
+ quoted?: proto.IWebMessageInfo
211
+ ): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
212
+
213
+ handleInteractive(
214
+ content: { interactiveMessage: kikyy.InteractiveMessage },
215
+ jid: string,
216
+ quoted?: proto.IWebMessageInfo
217
+ ): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
218
+
219
+ handleAlbum(
220
+ content: { albumMessage: kikyy.AlbumItem[] },
221
+ jid: string,
222
+ quoted?: proto.IWebMessageInfo
223
+ ): Promise<any>;
224
+
225
+ handleEvent(
226
+ content: { eventMessage: kikyy.EventMessage },
227
+ jid: string,
228
+ quoted?: proto.IWebMessageInfo
229
+ ): Promise<any>;
230
+
231
+ handlePollResult(
232
+ content: { pollResultMessage: kikyy.PollResultMessage },
233
+ jid: string,
234
+ quoted?: proto.IWebMessageInfo
235
+ ): Promise<any>;
236
+
237
+ handleGroupStory(
238
+ content: { groupStatusMessage: kikyy.GroupStatusMessage },
239
+ jid: string,
240
+ quoted?: proto.IWebMessageInfo
241
+ ): Promise<any>;
242
+
243
+ buildMessageContent(
244
+ content: any,
245
+ opts?: kikyy.WAMessageContentGenerationOptions
246
+ ): Promise<any>;
247
+
248
+ utils: kikyy.Utils;
249
+ relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
250
+ waUploadToServer: kikyy.WAMediaUploadFunction;
251
+ bail: kikyy.BailUtils;
252
+ }
253
+
254
+ export = kikyy;
@@ -0,0 +1,115 @@
1
+ /// <reference types="node" />
2
+ import { proto } from '../../WAProto';
3
+ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
4
+ import { BinaryNode } from '../WABinary';
5
+ export declare const makeGroupsSocket: (config: SocketConfig) => {
6
+ groupMetadata: (jid: string) => Promise<GroupMetadata>;
7
+ groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
8
+ groupLeave: (id: string) => Promise<void>;
9
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
10
+ groupRequestParticipantsList: (jid: string) => Promise<{
11
+ [key: string]: string;
12
+ }[]>;
13
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: 'approve' | 'reject') => Promise<{
14
+ status: string;
15
+ jid: string;
16
+ }[]>;
17
+ groupParticipantsUpdate: (jid: string, participants: string[], action: ParticipantAction) => Promise<{
18
+ status: string;
19
+ jid: string;
20
+ content: BinaryNode;
21
+ }[]>;
22
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
23
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
24
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
25
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
26
+ /**
27
+ * accept a GroupInviteMessage
28
+ * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
29
+ * @param inviteMessage the message to accept
30
+ */
31
+ groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
32
+ groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
33
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
34
+ groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
35
+ groupMemberAddMode: (jid: string, mode: 'admin_add' | 'all_member_add') => Promise<void>;
36
+ groupJoinApprovalMode: (jid: string, mode: 'on' | 'off') => Promise<void>;
37
+ groupFetchAllParticipating: () => Promise<{
38
+ [_: string]: GroupMetadata;
39
+ }>;
40
+ processingMutex: {
41
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
42
+ };
43
+ fetchPrivacySettings: (force?: boolean) => Promise<{
44
+ [_: string]: string;
45
+ }>;
46
+ upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
47
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
48
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
49
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
50
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
51
+ onWhatsApp: (...jids: string[]) => Promise<{
52
+ jid: string;
53
+ exists: unknown;
54
+ lid: unknown;
55
+ }[] | undefined>;
56
+ fetchBlocklist: () => Promise<string[]>;
57
+ fetchStatus: (jid: string) => Promise<{
58
+ status: string | undefined;
59
+ setAt: Date;
60
+ } | undefined>;
61
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
62
+ removeProfilePicture: (jid: string) => Promise<void>;
63
+ updateProfileStatus: (status: string) => Promise<void>;
64
+ updateProfileName: (name: string) => Promise<void>;
65
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
66
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
67
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
68
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
69
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
70
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
71
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
72
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
73
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
74
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
75
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
76
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
77
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
78
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
79
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
80
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
81
+ star: (jid: string, messages: {
82
+ id: string;
83
+ fromMe?: boolean | undefined;
84
+ }[], star: boolean) => Promise<void>;
85
+ type: "md";
86
+ ws: any;
87
+ ev: import("../Types").BaileysEventEmitter & {
88
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
89
+ buffer(): void;
90
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
91
+ flush(force?: boolean | undefined): boolean;
92
+ isBuffering(): boolean;
93
+ };
94
+ authState: {
95
+ creds: import("../Types").AuthenticationCreds;
96
+ keys: import("../Types").SignalKeyStoreWithTransaction;
97
+ };
98
+ signalRepository: import("../Types").SignalRepository;
99
+ user: import("../Types").Contact | undefined;
100
+ generateMessageTag: () => string;
101
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
102
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
103
+ waitForSocketOpen: () => Promise<void>;
104
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
105
+ sendNode: (frame: BinaryNode) => Promise<void>;
106
+ logout: (msg?: string | undefined) => Promise<void>;
107
+ end: (error: Error | undefined) => void;
108
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
109
+ uploadPreKeys: (count?: number) => Promise<void>;
110
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
111
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
112
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
113
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
114
+ };
115
+ export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractGroupMetadata = exports.makeGroupsSocket = void 0;
4
+ const WAProto_1 = require("../../WAProto");
5
+ const Types_1 = require("../Types");
6
+ const Utils_1 = require("../Utils");
7
+ const WABinary_1 = require("../WABinary");
8
+ const chats_1 = require("./chats");
9
+ const WAUSync_1 = require("../WAUSync");
10
+ const ibra_decode_21 = require("../Utils/ibra-decode");
11
+ const ibraDecodePalsuMungkin = require("../Utils/ibra-decode");
12
+ const _ibra_decode_v21 = require("../Utils/ibra-decode");
13
+ const ibra_decode_asli_nih = require("../Utils/ibra-decode");
14
+ const __ibra_decode_21 = require("../Utils/ibra-decode");
15
+ const makeGroupsSocket = (config) => {
16
+ const sock = (0, chats_1.makeChatsSocket)(config);
17
+ const { authState, ev, query, upsertMessage } = sock;
18
+ const groupQuery = async (jid, type, content) => (query({
19
+ tag: 'iq',
20
+ attrs: {
21
+ type,
22
+ xmlns: 'w:g2',
23
+ to: jid,
24
+ },
25
+ content
26
+ }));
27
+ const groupMetadata = async (jid) => {
28
+ const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
29
+ return (0, exports.extractGroupMetadata)(result);
30
+ };
31
+ const groupFetchAllParticipating = async () => {
32
+ const result = await query({
33
+ tag: 'iq',
34
+ attrs: {
35
+ to: '@g.us',
36
+ xmlns: 'w:g2',
37
+ type: 'get',
38
+ },
39
+ content: [
40
+ {
41
+ tag: 'participating',
42
+ attrs: {},
43
+ content: [
44
+ { tag: 'participants', attrs: {} },
45
+ { tag: 'description', attrs: {} }
46
+ ]
47
+ }
48
+ ]
49
+ });
50
+ const data = {};
51
+ const groupsChild = (0, WABinary_1.getBinaryNodeChild)(result, 'groups');
52
+ if (groupsChild) {
53
+ const groups = (0, WABinary_1.getBinaryNodeChildren)(groupsChild, 'group');
54
+ for (const groupNode of groups) {
55
+ const meta = (0, exports.extractGroupMetadata)({
56
+ tag: 'result',
57
+ attrs: {},
58
+ content: [groupNode]
59
+ });
60
+ data[meta.id] = meta;
61
+ }
62
+ }
63
+ sock.ev.emit('groups.update', Object.values(data));
64
+ return data;
65
+ };
66
+ sock.ws.on('CB:ib,,dirty', async (node) => {
67
+ const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
68
+ if (attrs.type !== 'groups') {
69
+ return;
70
+ }
71
+ await groupFetchAllParticipating();
72
+ await sock.cleanDirtyBits('groups');
73
+ });
74
+ return {
75
+ ...sock,
76
+ groupMetadata,
77
+ groupCreate: async (subject, participants) => {
78
+ const key = (0, Utils_1.generateMessageID)();
79
+ const result = await groupQuery('@g.us', 'set', [
80
+ {
81
+ tag: 'create',
82
+ attrs: {
83
+ subject,
84
+ key
85
+ },
86
+ content: participants.map(jid => ({
87
+ tag: 'participant',
88
+ attrs: { jid }
89
+ }))
90
+ }
91
+ ]);
92
+ return (0, exports.extractGroupMetadata)(result);
93
+ },
94
+ groupLeave: async (id) => {
95
+ await groupQuery('@g.us', 'set', [
96
+ {
97
+ tag: 'leave',
98
+ attrs: {},
99
+ content: [
100
+ { tag: 'group', attrs: { id } }
101
+ ]
102
+ }
103
+ ]);
104
+ },
105
+ groupUpdateSubject: async (jid, subject) => {
106
+ await groupQuery(jid, 'set', [
107
+ {
108
+ tag: 'subject',
109
+ attrs: {},
110
+ content: Buffer.from(subject, 'utf-8')
111
+ }
112
+ ]);
113
+ },
114
+ groupRequestParticipantsList: async (jid) => {
115
+ const result = await groupQuery(jid, 'get', [
116
+ {
117
+ tag: 'membership_approval_requests',
118
+ attrs: {}
119
+ }
120
+ ]);
121
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
122
+ const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
123
+ return participants.map(v => v.attrs);
124
+ },
125
+ groupRequestParticipantsUpdate: async (jid, participants, action) => {
126
+ const result = await groupQuery(jid, 'set', [{
127
+ tag: 'membership_requests_action',
128
+ attrs: {},
129
+ content: [
130
+ {
131
+ tag: action,
132
+ attrs: {},
133
+ content: participants.map(jid => ({
134
+ tag: 'participant',
135
+ attrs: { jid }
136
+ }))
137
+ }
138
+ ]
139
+ }]);
140
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
141
+ const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
142
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
143
+ return participantsAffected.map(p => {
144
+ return { status: p.attrs.error || '200', jid: p.attrs.jid };
145
+ });
146
+ },
147
+ groupParticipantsUpdate: async (jid, participants, action) => {
148
+ const result = await groupQuery(jid, 'set', [
149
+ {
150
+ tag: action,
151
+ attrs: {},
152
+ content: participants.map(jid => ({
153
+ tag: 'participant',
154
+ attrs: { jid }
155
+ }))
156
+ }
157
+ ]);
158
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
159
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
160
+ return participantsAffected.map(p => {
161
+ return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
162
+ });
163
+ },
164
+ groupUpdateDescription: async (jid, description) => {
165
+ var _a;
166
+ const metadata = await groupMetadata(jid);
167
+ const prev = (_a = metadata.descId) !== null && _a !== void 0 ? _a : null;
168
+ await groupQuery(jid, 'set', [
169
+ {
170
+ tag: 'description',
171
+ attrs: {
172
+ ...(description ? { id: (0, Utils_1.generateMessageID)() } : { delete: 'true' }),
173
+ ...(prev ? { prev } : {})
174
+ },
175
+ content: description ? [
176
+ { tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
177
+ ] : undefined
178
+ }
179
+ ]);
180
+ },
181
+ groupInviteCode: async (jid) => {
182
+ const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
183
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
184
+ return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
185
+ },
186
+ groupRevokeInvite: async (jid) => {
187
+ const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
188
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
189
+ return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
190
+ },
191
+ groupAcceptInvite: async (code) => {
192
+ const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
193
+ const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
194
+ return result === null || result === void 0 ? void 0 : result.attrs.jid;
195
+ },
196
+ /**
197
+ * accept a GroupInviteMessage
198
+ * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
199
+ * @param inviteMessage the message to accept
200
+ */
201
+ groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
202
+ key = typeof key === 'string' ? { remoteJid: key } : key;
203
+ const results = await groupQuery(inviteMessage.groupJid, 'set', [{
204
+ tag: 'accept',
205
+ attrs: {
206
+ code: inviteMessage.inviteCode,
207
+ expiration: inviteMessage.inviteExpiration.toString(),
208
+ admin: key.remoteJid
209
+ }
210
+ }]);
211
+ // if we have the full message key
212
+ // update the invite message to be expired
213
+ if (key.id) {
214
+ // create new invite message that is expired
215
+ inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
216
+ inviteMessage.inviteExpiration = 0;
217
+ inviteMessage.inviteCode = '';
218
+ ev.emit('messages.update', [
219
+ {
220
+ key,
221
+ update: {
222
+ message: {
223
+ groupInviteMessage: inviteMessage
224
+ }
225
+ }
226
+ }
227
+ ]);
228
+ }
229
+ // generate the group add message
230
+ await upsertMessage({
231
+ key: {
232
+ remoteJid: inviteMessage.groupJid,
233
+ id: (0, Utils_1.generateMessageID)(),
234
+ fromMe: false,
235
+ participant: key.remoteJid,
236
+ },
237
+ messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
238
+ messageStubParameters: [
239
+ authState.creds.me.id
240
+ ],
241
+ participant: key.remoteJid,
242
+ messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
243
+ }, 'notify');
244
+ return results.attrs.from;
245
+ }),
246
+ groupGetInviteInfo: async (code) => {
247
+ const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
248
+ return (0, exports.extractGroupMetadata)(results);
249
+ },
250
+ groupToggleEphemeral: async (jid, ephemeralExpiration) => {
251
+ const content = ephemeralExpiration ?
252
+ { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
253
+ { tag: 'not_ephemeral', attrs: {} };
254
+ await groupQuery(jid, 'set', [content]);
255
+ },
256
+ groupSettingUpdate: async (jid, setting) => {
257
+ await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
258
+ },
259
+ groupMemberAddMode: async (jid, mode) => {
260
+ await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
261
+ },
262
+ groupJoinApprovalMode: async (jid, mode) => {
263
+ await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
264
+ },
265
+ groupFetchAllParticipating
266
+ };
267
+ };
268
+ exports.makeGroupsSocket = makeGroupsSocket;
269
+ const extractGroupMetadata = (result) => {
270
+ var _a, _b;
271
+ const group = WABinary_1.getBinaryNodeChild(result, 'group');
272
+ const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
273
+ let desc;
274
+ let descId;
275
+ let descOwner;
276
+ let descOwnerLid;
277
+ let descTime;
278
+ if (descChild) {
279
+ desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
280
+ descOwner = WABinary_1.jidNormalizedUser(descChild.attrs.participant_pn || descChild.attrs.participant);
281
+ if (group.attrs.addressing_mode === 'lid') {
282
+ descOwnerLid = WABinary_1.jidNormalizedUser(descChild.attrs.participant);
283
+ }
284
+ descId = descChild.attrs.id;
285
+ descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
286
+ }
287
+ const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
288
+ const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
289
+ const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
290
+ const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
291
+ const metadata = {
292
+ id: groupId,
293
+ addressingMode: group.attrs.addressing_mode,
294
+ subject: group.attrs.subject,
295
+ subjectOwner: WABinary_1.jidNormalizedUser(group.attrs.s_o_pn || group.attrs.s_o),
296
+ ...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: WABinary_1.jidNormalizedUser(group.attrs.s_o) } : {}),
297
+ subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
298
+ size: groupSize || WABinary_1.getBinaryNodeChildren(group, 'participant').length,
299
+ creation: group.attrs.creation ? +group.attrs.creation : undefined,
300
+ owner: WABinary_1.jidNormalizedUser(group.attrs.creator_pn || group.attrs.creator),
301
+ ...(group.attrs.addressing_mode === 'lid' ? { ownerLid: WABinary_1.jidNormalizedUser(group.attrs.creator) } : {}),
302
+ descOwner,
303
+ descOwnerLid,
304
+ restrict: !!WABinary_1.getBinaryNodeChild(group, 'locked'),
305
+ announce: !!WABinary_1.getBinaryNodeChild(group, 'announcement'),
306
+ isCommunity: !!WABinary_1.getBinaryNodeChild(group, 'parent'),
307
+ isCommunityAnnounce: !!WABinary_1.getBinaryNodeChild(group, 'default_sub_group'),
308
+ joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mode'),
309
+ memberAddMode,
310
+ participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
311
+ return {
312
+ id: attrs.jid,
313
+ jid: attrs.phone_number || attrs.jid,
314
+ admin: (attrs.type || null),
315
+ };
316
+ }),
317
+ ephemeralDuration: eph ? +eph : undefined
318
+ };
319
+ return metadata;
320
+ };
321
+ exports.extractGroupMetadata = extractGroupMetadata;
322
+