@neelegirl/baileys 1.5.3 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +16 -195
  2. package/index.js +38 -0
  3. package/package.json +16 -96
  4. package/LICENSE +0 -21
  5. package/WAProto/WAProto.proto +0 -5308
  6. package/WAProto/index.d.ts +0 -61295
  7. package/WAProto/index.js +0 -189754
  8. package/lib/Defaults/baileys-version.json +0 -3
  9. package/lib/Defaults/index.d.ts +0 -78
  10. package/lib/Defaults/index.js +0 -149
  11. package/lib/Defaults/phonenumber-mcc.json +0 -223
  12. package/lib/Signal/WASignalGroup/GroupProtocol.js +0 -1909
  13. package/lib/Signal/WASignalGroup/ciphertext-message.d.ts +0 -9
  14. package/lib/Signal/WASignalGroup/ciphertext-message.js +0 -19
  15. package/lib/Signal/WASignalGroup/ciphertext_message.js +0 -16
  16. package/lib/Signal/WASignalGroup/generate-proto.sh +0 -1
  17. package/lib/Signal/WASignalGroup/group-session-builder.d.ts +0 -17
  18. package/lib/Signal/WASignalGroup/group-session-builder.js +0 -72
  19. package/lib/Signal/WASignalGroup/group.proto +0 -42
  20. package/lib/Signal/WASignalGroup/group_cipher.d.ts +0 -19
  21. package/lib/Signal/WASignalGroup/group_cipher.js +0 -111
  22. package/lib/Signal/WASignalGroup/group_session_builder.js +0 -46
  23. package/lib/Signal/WASignalGroup/index.d.ts +0 -11
  24. package/lib/Signal/WASignalGroup/index.js +0 -61
  25. package/lib/Signal/WASignalGroup/keyhelper.d.ts +0 -16
  26. package/lib/Signal/WASignalGroup/keyhelper.js +0 -66
  27. package/lib/Signal/WASignalGroup/protobufs.js +0 -3
  28. package/lib/Signal/WASignalGroup/queue_job.js +0 -69
  29. package/lib/Signal/WASignalGroup/readme.md +0 -6
  30. package/lib/Signal/WASignalGroup/sender-chain-key.d.ts +0 -14
  31. package/lib/Signal/WASignalGroup/sender-chain-key.js +0 -47
  32. package/lib/Signal/WASignalGroup/sender-key-distribution-message.d.ts +0 -17
  33. package/lib/Signal/WASignalGroup/sender-key-distribution-message.js +0 -71
  34. package/lib/Signal/WASignalGroup/sender-key-message.d.ts +0 -19
  35. package/lib/Signal/WASignalGroup/sender-key-message.js +0 -73
  36. package/lib/Signal/WASignalGroup/sender-key-name.d.ts +0 -19
  37. package/lib/Signal/WASignalGroup/sender-key-name.js +0 -59
  38. package/lib/Signal/WASignalGroup/sender-key-record.d.ts +0 -32
  39. package/lib/Signal/WASignalGroup/sender-key-record.js +0 -58
  40. package/lib/Signal/WASignalGroup/sender-key-state.d.ts +0 -44
  41. package/lib/Signal/WASignalGroup/sender-key-state.js +0 -147
  42. package/lib/Signal/WASignalGroup/sender-message-key.d.ts +0 -11
  43. package/lib/Signal/WASignalGroup/sender-message-key.js +0 -33
  44. package/lib/Signal/WASignalGroup/sender_chain_key.js +0 -50
  45. package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +0 -78
  46. package/lib/Signal/WASignalGroup/sender_key_message.js +0 -92
  47. package/lib/Signal/WASignalGroup/sender_key_name.js +0 -70
  48. package/lib/Signal/WASignalGroup/sender_key_record.js +0 -56
  49. package/lib/Signal/WASignalGroup/sender_key_state.js +0 -129
  50. package/lib/Signal/WASignalGroup/sender_message_key.js +0 -39
  51. package/lib/Signal/libsignal.d.ts +0 -8
  52. package/lib/Signal/libsignal.js +0 -391
  53. package/lib/Signal/lid-mapping.d.ts +0 -28
  54. package/lib/Signal/lid-mapping.js +0 -184
  55. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
  56. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  57. package/lib/Socket/Client/index.d.ts +0 -2
  58. package/lib/Socket/Client/index.js +0 -22
  59. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
  60. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  61. package/lib/Socket/Client/types.d.ts +0 -16
  62. package/lib/Socket/Client/types.js +0 -18
  63. package/lib/Socket/Client/websocket.d.ts +0 -13
  64. package/lib/Socket/Client/websocket.js +0 -62
  65. package/lib/Socket/business.d.ts +0 -187
  66. package/lib/Socket/business.js +0 -415
  67. package/lib/Socket/chats.d.ts +0 -97
  68. package/lib/Socket/chats.js +0 -1118
  69. package/lib/Socket/communities.d.ts +0 -223
  70. package/lib/Socket/communities.js +0 -433
  71. package/lib/Socket/groups.d.ts +0 -129
  72. package/lib/Socket/groups.js +0 -360
  73. package/lib/Socket/index.d.ts +0 -191
  74. package/lib/Socket/index.js +0 -24
  75. package/lib/Socket/messages-recv.d.ts +0 -174
  76. package/lib/Socket/messages-recv.js +0 -1506
  77. package/lib/Socket/messages-send.d.ts +0 -165
  78. package/lib/Socket/messages-send.js +0 -1785
  79. package/lib/Socket/mex.d.ts +0 -2
  80. package/lib/Socket/mex.js +0 -47
  81. package/lib/Socket/newsletter.d.ts +0 -145
  82. package/lib/Socket/newsletter.js +0 -295
  83. package/lib/Socket/socket.d.ts +0 -45
  84. package/lib/Socket/socket.js +0 -934
  85. package/lib/Socket/usync.d.ts +0 -37
  86. package/lib/Socket/usync.js +0 -83
  87. package/lib/Store/index.d.ts +0 -4
  88. package/lib/Store/index.js +0 -24
  89. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  90. package/lib/Store/make-cache-manager-store.js +0 -90
  91. package/lib/Store/make-in-memory-store.d.ts +0 -123
  92. package/lib/Store/make-in-memory-store.js +0 -429
  93. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  94. package/lib/Store/make-ordered-dictionary.js +0 -86
  95. package/lib/Store/object-repository.d.ts +0 -10
  96. package/lib/Store/object-repository.js +0 -31
  97. package/lib/Types/Auth.d.ts +0 -121
  98. package/lib/Types/Auth.js +0 -3
  99. package/lib/Types/Bussines.js +0 -3
  100. package/lib/Types/Bussiness.d.ts +0 -28
  101. package/lib/Types/Call.d.ts +0 -14
  102. package/lib/Types/Call.js +0 -3
  103. package/lib/Types/Chat.d.ts +0 -143
  104. package/lib/Types/Chat.js +0 -9
  105. package/lib/Types/Contact.d.ts +0 -23
  106. package/lib/Types/Contact.js +0 -3
  107. package/lib/Types/Events.d.ts +0 -226
  108. package/lib/Types/Events.js +0 -3
  109. package/lib/Types/GroupMetadata.d.ts +0 -66
  110. package/lib/Types/GroupMetadata.js +0 -3
  111. package/lib/Types/Label.d.ts +0 -48
  112. package/lib/Types/Label.js +0 -31
  113. package/lib/Types/LabelAssociation.d.ts +0 -35
  114. package/lib/Types/LabelAssociation.js +0 -13
  115. package/lib/Types/Message.d.ts +0 -484
  116. package/lib/Types/Message.js +0 -19
  117. package/lib/Types/MexUpdates.d.ts +0 -9
  118. package/lib/Types/MexUpdates.js +0 -18
  119. package/lib/Types/Newsletter.d.ts +0 -109
  120. package/lib/Types/Newsletter.js +0 -40
  121. package/lib/Types/Product.d.ts +0 -92
  122. package/lib/Types/Product.js +0 -3
  123. package/lib/Types/Signal.d.ts +0 -98
  124. package/lib/Types/Signal.js +0 -3
  125. package/lib/Types/Socket.d.ts +0 -141
  126. package/lib/Types/Socket.js +0 -3
  127. package/lib/Types/State.d.ts +0 -41
  128. package/lib/Types/State.js +0 -14
  129. package/lib/Types/USync.d.ts +0 -26
  130. package/lib/Types/USync.js +0 -3
  131. package/lib/Types/index.d.ts +0 -80
  132. package/lib/Types/index.js +0 -50
  133. package/lib/Utils/auth-utils.d.ts +0 -21
  134. package/lib/Utils/auth-utils.js +0 -528
  135. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  136. package/lib/Utils/baileys-event-stream.js +0 -70
  137. package/lib/Utils/business.d.ts +0 -29
  138. package/lib/Utils/business.js +0 -255
  139. package/lib/Utils/chat-utils.d.ts +0 -82
  140. package/lib/Utils/chat-utils.js +0 -809
  141. package/lib/Utils/crypto.d.ts +0 -56
  142. package/lib/Utils/crypto.js +0 -189
  143. package/lib/Utils/decode-wa-message.d.ts +0 -53
  144. package/lib/Utils/decode-wa-message.js +0 -323
  145. package/lib/Utils/event-buffer.d.ts +0 -39
  146. package/lib/Utils/event-buffer.js +0 -595
  147. package/lib/Utils/generics.d.ts +0 -131
  148. package/lib/Utils/generics.js +0 -630
  149. package/lib/Utils/history.d.ts +0 -23
  150. package/lib/Utils/history.js +0 -104
  151. package/lib/Utils/index.d.ts +0 -20
  152. package/lib/Utils/index.js +0 -40
  153. package/lib/Utils/link-preview.d.ts +0 -23
  154. package/lib/Utils/link-preview.js +0 -120
  155. package/lib/Utils/logger.d.ts +0 -13
  156. package/lib/Utils/logger.js +0 -7
  157. package/lib/Utils/lt-hash.d.ts +0 -14
  158. package/lib/Utils/lt-hash.js +0 -58
  159. package/lib/Utils/make-mutex.d.ts +0 -9
  160. package/lib/Utils/make-mutex.js +0 -49
  161. package/lib/Utils/message-retry-manager.d.ts +0 -88
  162. package/lib/Utils/message-retry-manager.js +0 -160
  163. package/lib/Utils/messages-media.d.ts +0 -135
  164. package/lib/Utils/messages-media.js +0 -869
  165. package/lib/Utils/messages.d.ts +0 -105
  166. package/lib/Utils/messages.js +0 -1745
  167. package/lib/Utils/noise-handler.d.ts +0 -21
  168. package/lib/Utils/noise-handler.js +0 -165
  169. package/lib/Utils/process-message.d.ts +0 -49
  170. package/lib/Utils/process-message.js +0 -427
  171. package/lib/Utils/signal.d.ts +0 -42
  172. package/lib/Utils/signal.js +0 -166
  173. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  174. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  175. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -18
  176. package/lib/Utils/use-multi-file-auth-state.js +0 -238
  177. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  178. package/lib/Utils/use-single-file-auth-state.js +0 -80
  179. package/lib/Utils/validate-connection.d.ts +0 -13
  180. package/lib/Utils/validate-connection.js +0 -220
  181. package/lib/WABinary/constants.d.ts +0 -30
  182. package/lib/WABinary/constants.js +0 -1316
  183. package/lib/WABinary/decode.d.ts +0 -9
  184. package/lib/WABinary/decode.js +0 -288
  185. package/lib/WABinary/encode.d.ts +0 -3
  186. package/lib/WABinary/encode.js +0 -265
  187. package/lib/WABinary/generic-utils.d.ts +0 -28
  188. package/lib/WABinary/generic-utils.js +0 -142
  189. package/lib/WABinary/index.d.ts +0 -5
  190. package/lib/WABinary/index.js +0 -25
  191. package/lib/WABinary/jid-utils.d.ts +0 -58
  192. package/lib/WABinary/jid-utils.js +0 -104
  193. package/lib/WABinary/types.d.ts +0 -22
  194. package/lib/WABinary/types.js +0 -3
  195. package/lib/WAM/BinaryInfo.d.ts +0 -16
  196. package/lib/WAM/BinaryInfo.js +0 -17
  197. package/lib/WAM/constants.d.ts +0 -47
  198. package/lib/WAM/constants.js +0 -15371
  199. package/lib/WAM/encode.d.ts +0 -3
  200. package/lib/WAM/encode.js +0 -164
  201. package/lib/WAM/index.d.ts +0 -3
  202. package/lib/WAM/index.js +0 -23
  203. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  204. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -69
  205. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  206. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -36
  207. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  208. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -62
  209. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  210. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -35
  211. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
  212. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -38
  213. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  214. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -46
  215. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  216. package/lib/WAUSync/Protocols/index.js +0 -26
  217. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  218. package/lib/WAUSync/USyncQuery.js +0 -92
  219. package/lib/WAUSync/USyncUser.d.ts +0 -12
  220. package/lib/WAUSync/USyncUser.js +0 -30
  221. package/lib/WAUSync/index.d.ts +0 -3
  222. package/lib/WAUSync/index.js +0 -23
  223. package/lib/index.d.ts +0 -13
  224. package/lib/index.js +0 -33
@@ -1,2 +0,0 @@
1
- import type { BinaryNode } from '../WABinary/index.js';
2
- export declare const executeWMexQuery: <T>(variables: Record<string, unknown>, queryId: string, dataPath: string, query: (node: BinaryNode) => Promise<BinaryNode>, generateMessageTag: () => string) => Promise<T>;
package/lib/Socket/mex.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict"
2
- Object.defineProperty(exports, "__esModule", { value: true })
3
-
4
- const { Boom } = require("@hapi/boom")
5
- const { getBinaryNodeChild, S_WHATSAPP_NET }= require("../WABinary/index.js")
6
- const wMexQuery = (variables, queryId, query, generateMessageTag) => {
7
- return query({
8
- tag: 'iq',
9
- attrs: {
10
- id: generateMessageTag(),
11
- type: 'get',
12
- to: S_WHATSAPP_NET,
13
- xmlns: 'w:mex'
14
- },
15
- content: [
16
- {
17
- tag: 'query',
18
- attrs: { query_id: queryId },
19
- content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
20
- }
21
- ]
22
- });
23
- };
24
- const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
25
- const result = await wMexQuery(variables, queryId, query, generateMessageTag);
26
- const child = getBinaryNodeChild(result, 'result');
27
- if (child?.content) {
28
- const data = JSON.parse(child.content.toString());
29
- if (data.errors && data.errors.length > 0) {
30
- const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ');
31
- const firstError = data.errors[0];
32
- const errorCode = firstError.extensions?.error_code || 400;
33
- throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError });
34
- }
35
- const response = dataPath ? data?.data?.[dataPath] : data?.data;
36
- if (typeof response !== 'undefined') {
37
- return response;
38
- }
39
- }
40
- const action = (dataPath || '').startsWith('xwa2_')
41
- ? dataPath.substring(5).replace(/_/g, ' ')
42
- : dataPath?.replace(/_/g, ' ');
43
- throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result });
44
- };
45
- module.exports = {
46
- executeWMexQuery
47
- }
@@ -1,145 +0,0 @@
1
- import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate, ContactAction } from '../Types'
2
- import { BinaryNode } from '../WABinary'
3
-
4
- export declare const makeNewsletterSocket: (config: SocketConfig) => {
5
- subscribeNewsletterUpdates: (jid: string) => Promise<{
6
- duration: string
7
- }>
8
- newsletterReactionMode: (jid: string, mode: NewsletterReactionMode) => Promise<void>
9
- newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>
10
- newsletterUpdateName: (jid: string, name: string) => Promise<void>
11
- newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<void>
12
- newsletterRemovePicture: (jid: string) => Promise<void>
13
- newsletterUnfollow: (jid: string) => Promise<void>
14
- newsletterFollow: (jid: string) => Promise<void>
15
- newsletterUnmute: (jid: string) => Promise<void>
16
- newsletterMute: (jid: string) => Promise<void>
17
- newsletterCreate: (name: string, description?: string, picture?: WAMediaUpload) => Promise<NewsletterMetadata>
18
- newsletterQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
19
- newsletterWMexQuery: (jid?: string | undefined, query_id: number, content: BinaryNode) => Promise<BinaryNode>
20
- newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>
21
- newsletterFetchAllParticipating: () => Promise<{
22
- [_: string]: NewsletterMetadata
23
- }>
24
- newsletterAdminCount: (jid: string) => Promise<number>
25
- newsletterChangeOwner: (jid: string, userLid: string) => Promise<void>
26
- newsletterDemote: (jid: string, userLid: string) => Promise<void>
27
- newsletterDelete: (jid: string) => Promise<void>
28
- /**if code wasn't passed, the reaction will be removed (if is reacted) */
29
- newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>
30
- newsletterFetchMessages: (type: 'invite' | 'jid', key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>
31
- newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>
32
- groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
33
- groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>
34
- groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>
35
- groupLeave: (id: string) => Promise<void>
36
- groupUpdateSubject: (jid: string, subject: string) => Promise<void>
37
- groupRequestParticipantsList: (jid: string) => Promise<{
38
- [key: string]: string
39
- }[]>
40
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
41
- status: string
42
- jid: string
43
- }[]>
44
- groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
45
- status: string
46
- jid: string
47
- content: BinaryNode
48
- }[]>
49
- groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
50
- groupInviteCode: (jid: string) => Promise<string | undefined>
51
- groupRevokeInvite: (jid: string) => Promise<string | undefined>
52
- groupAcceptInvite: (code: string) => Promise<string | undefined>
53
- groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
54
- groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>
55
- groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>
56
- groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
57
- groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>
58
- groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>
59
- groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>
60
- groupFetchAllParticipating: () => Promise<{
61
- [_: string]: import("../Types").GroupMetadata
62
- }>
63
- processingMutex: {
64
- mutex<T>(code: () => T | Promise<T>): Promise<T>
65
- }
66
- fetchPrivacySettings: (force?: boolean) => Promise<{
67
- [_: string]: string
68
- }>
69
- upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>
70
- appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>
71
- createCallLink: (type: 'audio' | 'video', event?: number, timeoutMs?: number) => Promise<void>
72
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>
73
- presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>
74
- getBotListV2: () => Promise<BotListInfo[]>
75
- getLidUser: (jid: string) => Promise<{
76
- lid: string
77
- id: string
78
- }[] | undefined>
79
- fetchBlocklist: () => Promise<string[]>
80
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
81
- fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
82
- updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
83
- removeProfilePicture: (jid: string) => Promise<void>
84
- updateProfileStatus: (status: string) => Promise<void>
85
- updateProfileName: (name: string) => Promise<void>
86
- updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
87
- updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>
88
- updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
89
- updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>
90
- updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
91
- updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
92
- updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>
93
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>
94
- updateDefaultDisappearingMode: (duration: number) => Promise<void>
95
- updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>
96
- getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>
97
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
98
- chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>
99
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>
100
- addChatLabel: (jid: string, labelId: string) => Promise<void>
101
- removeChatLabel: (jid: string, labelId: string) => Promise<void>
102
- addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
103
- removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
104
- clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
105
- star: (jid: string, messages: {
106
- id: string
107
- fromMe?: boolean | undefined
108
- }[], star: boolean) => Promise<void>
109
- addOrEditQuickReply: (quickReply: import("../Types/Bussines").QuickReplyAction) => Promise<void>
110
- removeQuickReply: (timestamp: string) => Promise<void>
111
- addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
112
- removeContact: (jid: string) => Promise<void>
113
- executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>
114
- type: "md"
115
- ws: any
116
- ev: import("../Types").BaileysEventEmitter & {
117
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
118
- buffer(): void
119
- createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
120
- flush(force?: boolean | undefined): boolean
121
- isBuffering(): boolean
122
- }
123
- authState: {
124
- creds: import("../Types").AuthenticationCreds
125
- keys: import("../Types").SignalKeyStoreWithTransaction
126
- }
127
- signalRepository: import("../Types").SignalRepository
128
- user: import("../Types").Contact | undefined
129
- generateMessageTag: () => string
130
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
131
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
132
- waitForSocketOpen: () => Promise<void>
133
- sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
134
- sendNode: (frame: BinaryNode) => Promise<void>
135
- logout: (msg?: string | undefined) => Promise<void>
136
- end: (error: Error | undefined) => void
137
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
138
- uploadPreKeys: (count?: number) => Promise<void>
139
- uploadPreKeysToServerIfRequired: () => Promise<void>
140
- requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
141
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
142
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
143
- }
144
-
145
- export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata
@@ -1,295 +0,0 @@
1
- "use strict"
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true })
4
-
5
- const Types_1 = require("../Types")
6
- const Utils_1 = require("../Utils")
7
- const WABinary_1 = require("../WABinary")
8
- const groups_1 = require("./groups")
9
-
10
- const makeNewsletterSocket = (config) => {
11
- const baron = groups_1.makeGroupsSocket(config)
12
- const { authState, signalRepository, query, generateMessageTag } = baron
13
- const encoder = new TextEncoder()
14
-
15
- const newsletterQuery = async (jid, type, content) => (query({
16
- tag: 'iq',
17
- attrs: {
18
- id: generateMessageTag(),
19
- type,
20
- xmlns: 'newsletter',
21
- to: jid,
22
- },
23
- content
24
- }))
25
-
26
- const newsletterWMexQuery = async (jid, queryId, content) => (query({
27
- tag: 'iq',
28
- attrs: {
29
- id: generateMessageTag(),
30
- type: 'get',
31
- xmlns: 'w:mex',
32
- to: WABinary_1.S_WHATSAPP_NET,
33
- },
34
- content: [
35
- {
36
- tag: 'query',
37
- attrs: { 'query_id': queryId },
38
- content: encoder.encode(JSON.stringify({
39
- variables: {
40
- 'newsletter_id': jid,
41
- ...content
42
- }
43
- }))
44
- }
45
- ]
46
- }))
47
-
48
- const parseFetchedUpdates = async (node, type) => {
49
- let child
50
- if (type === 'messages') {
51
- child = WABinary_1.getBinaryNodeChild(node, 'messages')
52
- }
53
-
54
- else {
55
- const parent = WABinary_1.getBinaryNodeChild(node, 'message_updates')
56
- child = WABinary_1.getBinaryNodeChild(parent, 'messages')
57
- }
58
-
59
- return await Promise.all(WABinary_1.getAllBinaryNodeChildren(child).map(async (messageNode) => {
60
- messageNode.attrs.from = child?.attrs.jid
61
-
62
- const views = parseInt(WABinary_1.getBinaryNodeChild(messageNode, 'views_count')?.attrs?.count || '0')
63
- const reactionNode = WABinary_1.getBinaryNodeChild(messageNode, 'reactions')
64
- const reactions = WABinary_1.getBinaryNodeChildren(reactionNode, 'reaction')
65
- .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }))
66
-
67
- const data = {
68
- 'server_id': messageNode.attrs.server_id,
69
- views,
70
- reactions
71
- }
72
-
73
- if (type === 'messages') {
74
- const { fullMessage: message, decrypt } = await Utils_1.decryptMessageNode(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger)
75
- await decrypt()
76
- data.message = message
77
- }
78
-
79
- return data
80
- }))
81
- }
82
-
83
- const newsletterMetadata = async (type, key, role) => {
84
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
85
- input: {
86
- key,
87
- type: type.toUpperCase(),
88
- view_role: role || 'GUEST'
89
- },
90
- fetch_viewer_metadata: true,
91
- fetch_full_image: true,
92
- fetch_creation_time: true
93
- })
94
-
95
- return extractNewsletterMetadata(result)
96
- }
97
-
98
- return {
99
- ...baron,
100
- newsletterQuery,
101
- newsletterWMexQuery,
102
- subscribeNewsletterUpdates: async (jid) => {
103
- const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }])
104
-
105
- return WABinary_1.getBinaryNodeChild(result, 'live_updates')?.attrs
106
- },
107
- newsletterReactionMode: async (jid, mode) => {
108
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
109
- updates: { settings: { 'reaction_codes': { value: mode } } }
110
- })
111
- },
112
- newsletterUpdateDescription: async (jid, description) => {
113
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
114
- updates: { description: description || '', settings: null }
115
- })
116
- },
117
- newsletterUpdateName: async (jid, name) => {
118
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
119
- updates: { name, settings: null }
120
- })
121
- },
122
- newsletterUpdatePicture: async (jid, content) => {
123
- const { img } = await Utils_1.generateProfilePicture(content)
124
-
125
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
126
- updates: { picture: img.toString('base64'), settings: null }
127
- })
128
- },
129
- newsletterRemovePicture: async (jid) => {
130
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
131
- updates: { picture: '', settings: null }
132
- })
133
- },
134
- newsletterUnfollow: async (jid) => {
135
- await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW)
136
- },
137
- newsletterFollow: async (jid) => {
138
- await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW)
139
- },
140
- newsletterUnmute: async (jid) => {
141
- await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE)
142
- },
143
- newsletterMute: async (jid) => {
144
- await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE)
145
- },
146
- newsletterAction: async (jid, type) => {
147
- await newsletterWMexQuery(jid, Types_1.QueryIds[type.toUpperCase()])
148
- },
149
- newsletterCreate: async (name, description, picture) => {
150
- //TODO: Implement TOS system wide for Meta AI, communities, and here etc.
151
- /**tos query */
152
- await query({
153
- tag: 'iq',
154
- attrs: {
155
- to: WABinary_1.S_WHATSAPP_NET,
156
- xmlns: 'tos',
157
- id: generateMessageTag(),
158
- type: 'set'
159
- },
160
- content: [
161
- {
162
- tag: 'notice',
163
- attrs: {
164
- id: '20601218',
165
- stage: '5'
166
- },
167
- content: []
168
- }
169
- ]
170
- })
171
-
172
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
173
- input: {
174
- name,
175
- description: description || null,
176
- picture: picture ? (await Utils_1.generateProfilePicture(picture)).img.toString('base64') : null,
177
- settings: {
178
- reaction_codes: {
179
- value: 'ALL'
180
- }
181
- }
182
- }
183
- })
184
-
185
- return extractNewsletterMetadata(result, true)
186
- },
187
- newsletterMetadata,
188
- newsletterFetchAllParticipating: async () => {
189
- const data = {}
190
-
191
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.SUBSCRIBED)
192
- const child = JSON.parse(WABinary_1.getBinaryNodeChild(result, 'result')?.content?.toString())
193
- const newsletters = child.data[Types_1.XWAPaths.SUBSCRIBED]
194
-
195
- for (const i of newsletters) {
196
- if (!WABinary_1.isJidNewsletter(i.id)) {
197
- continue
198
- }
199
-
200
- const metadata = await newsletterMetadata('JID', i.id)
201
- data[metadata.id] = metadata
202
- }
203
-
204
- return data
205
- },
206
- newsletterFetchAllParticipating: async () => {
207
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.SUBSCRIBED)
208
- const child = JSON.parse(WABinary_1.getBinaryNodeChild(result, 'result')?.content?.toString())
209
- const newsletters = child.data[Types_1.XWAPaths.SUBSCRIBED] || []
210
-
211
- const data = {}
212
-
213
- for (const { id } of newsletters) {
214
- if (!WABinary_1.isJidNewsletter(id)) continue
215
- const metadata = await newsletterMetadata('JID', id)
216
- data[metadata.id] = metadata
217
- }
218
-
219
- return data
220
- },
221
- newsletterChangeOwner: async (jid, userLid) => {
222
- await newsletterWMexQuery(jid, Types_1.QueryIds.CHANGE_OWNER, {
223
- user_id: userLid
224
- })
225
- },
226
- newsletterDemote: async (jid, userLid) => {
227
- await newsletterWMexQuery(jid, Types_1.QueryIds.DEMOTE, {
228
- user_id: userLid
229
- })
230
- },
231
- newsletterDelete: async (jid) => {
232
- await newsletterWMexQuery(jid, Types_1.QueryIds.DELETE)
233
- },
234
- /**if code wasn't passed, the reaction will be removed (if is reacted) */
235
- newsletterReactMessage: async (jid, serverId, code) => {
236
- await query({
237
- tag: 'message',
238
- attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id: serverId, id: Utils_1.generateMessageID() },
239
- content: [{
240
- tag: 'reaction',
241
- attrs: code ? { code } : {}
242
- }]
243
- })
244
- },
245
- newsletterFetchMessages: async (type, key, count, after) => {
246
- const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
247
- {
248
- tag: 'messages',
249
- attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: after?.toString() || '100' }
250
- }
251
- ])
252
-
253
- return await parseFetchedUpdates(result, 'messages')
254
- },
255
- newsletterFetchUpdates: async (jid, count, after, since) => {
256
- const result = await newsletterQuery(jid, 'get', [
257
- {
258
- tag: 'message_updates',
259
- attrs: { count: count.toString(), after: after?.toString() || '100', since: since?.toString() || '0' }
260
- }
261
- ])
262
-
263
- return await parseFetchedUpdates(result, 'updates')
264
- }
265
- }
266
- }
267
-
268
- const extractNewsletterMetadata = (node, isCreate) => {
269
- const result = WABinary_1.getBinaryNodeChild(node, 'result')?.content?.toString()
270
- const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER]
271
-
272
- const metadata = {
273
- id: metadataPath?.id,
274
- state: metadataPath?.state?.type,
275
- creation_time: +metadataPath?.thread_metadata?.creation_time,
276
- name: metadataPath?.thread_metadata?.name?.text,
277
- nameTime: +metadataPath?.thread_metadata?.name?.update_time,
278
- description: metadataPath?.thread_metadata?.description?.text,
279
- descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
280
- invite: metadataPath?.thread_metadata?.invite,
281
- handle: metadataPath?.thread_metadata?.handle,
282
- picture: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
283
- preview: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
284
- reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
285
- subscribers: +metadataPath?.thread_metadata?.subscribers_count,
286
- verification: metadataPath?.thread_metadata?.verification,
287
- viewer_metadata: metadataPath?.viewer_metadata
288
- }
289
- return metadata
290
- }
291
-
292
- module.exports = {
293
- makeNewsletterSocket,
294
- extractNewsletterMetadata
295
- }
@@ -1,45 +0,0 @@
1
- import { Boom } from '@hapi/boom'
2
- import { SocketConfig } from '../Types'
3
- import { BinaryNode } from '../WABinary'
4
- import { WebSocketClient } from './Client'
5
-
6
- /**
7
- * Connects to WA servers and performs:
8
- * - simple queries (no retry mechanism, wait for connection establishment)
9
- * - listen to messages and emit events
10
- * - query phone connection
11
- */
12
- export declare const makeSocket: (config: SocketConfig) => {
13
- type: "md"
14
- ws: WebSocketClient
15
- ev: import("../Types").BaileysEventEmitter & {
16
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
17
- buffer(): void
18
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>
19
- flush(force?: boolean | undefined): boolean
20
- isBuffering(): boolean
21
- }
22
- authState: {
23
- creds: import("../Types").AuthenticationCreds
24
- keys: import("../Types").SignalKeyStoreWithTransaction
25
- }
26
- signalRepository: import("../Types").SignalRepository
27
- readonly user: import("../Types").Contact | undefined
28
- generateMessageTag: () => string
29
- query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>
30
- waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>
31
- waitForSocketOpen: () => Promise<void>
32
- sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
33
- sendNode: (frame: BinaryNode) => Promise<void>
34
- logout: (msg?: string) => Promise<void>
35
- end: (error: Error | undefined) => void
36
- onUnexpectedError: (err: Error | Boom, msg: string) => void
37
- uploadPreKeys: (count?: number) => Promise<void>
38
- uploadPreKeysToServerIfRequired: () => Promise<void>
39
- requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
40
- /** Waits for the connection to WA to reach a state */
41
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
42
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
43
- }
44
-
45
- export type Socket = ReturnType<typeof makeSocket>