supunmd-bail 2.0.1

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 (196) hide show
  1. package/LICENSE +21 -0
  2. package/WAProto/GenerateStatics.sh +3 -0
  3. package/WAProto/WAProto.proto +5519 -0
  4. package/WAProto/fix-imports.js +29 -0
  5. package/WAProto/index.d.ts +11969 -0
  6. package/WAProto/index.js +84368 -0
  7. package/engine-requirements.js +10 -0
  8. package/lib/Defaults/baileys-version.json +3 -0
  9. package/lib/Defaults/index.d.ts +62 -0
  10. package/lib/Defaults/index.js +115 -0
  11. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  12. package/lib/Signal/Group/ciphertext-message.js +12 -0
  13. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  14. package/lib/Signal/Group/group-session-builder.js +30 -0
  15. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  16. package/lib/Signal/Group/group_cipher.js +82 -0
  17. package/lib/Signal/Group/index.d.ts +12 -0
  18. package/lib/Signal/Group/index.js +12 -0
  19. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  20. package/lib/Signal/Group/keyhelper.js +18 -0
  21. package/lib/Signal/Group/queue-job.d.ts +2 -0
  22. package/lib/Signal/Group/queue-job.js +54 -0
  23. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  24. package/lib/Signal/Group/sender-chain-key.js +26 -0
  25. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  27. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  28. package/lib/Signal/Group/sender-key-message.js +66 -0
  29. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  30. package/lib/Signal/Group/sender-key-name.js +48 -0
  31. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  32. package/lib/Signal/Group/sender-key-record.js +41 -0
  33. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  34. package/lib/Signal/Group/sender-key-state.js +84 -0
  35. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  36. package/lib/Signal/Group/sender-message-key.js +26 -0
  37. package/lib/Signal/libsignal.d.ts +5 -0
  38. package/lib/Signal/libsignal.js +342 -0
  39. package/lib/Signal/lid-mapping.d.ts +23 -0
  40. package/lib/Signal/lid-mapping.js +171 -0
  41. package/lib/Socket/Client/index.d.ts +3 -0
  42. package/lib/Socket/Client/index.js +3 -0
  43. package/lib/Socket/Client/types.d.ts +16 -0
  44. package/lib/Socket/Client/types.js +11 -0
  45. package/lib/Socket/Client/websocket.d.ts +13 -0
  46. package/lib/Socket/Client/websocket.js +50 -0
  47. package/lib/Socket/business.d.ts +188 -0
  48. package/lib/Socket/business.js +376 -0
  49. package/lib/Socket/chats.d.ts +98 -0
  50. package/lib/Socket/chats.js +962 -0
  51. package/lib/Socket/communities.d.ts +244 -0
  52. package/lib/Socket/communities.js +431 -0
  53. package/lib/Socket/groups.d.ts +137 -0
  54. package/lib/Socket/groups.js +327 -0
  55. package/lib/Socket/index.d.ts +231 -0
  56. package/lib/Socket/index.js +18 -0
  57. package/lib/Socket/messages-recv.d.ts +173 -0
  58. package/lib/Socket/messages-recv.js +1228 -0
  59. package/lib/Socket/messages-send.d.ts +169 -0
  60. package/lib/Socket/messages-send.js +1070 -0
  61. package/lib/Socket/mex.d.ts +3 -0
  62. package/lib/Socket/mex.js +42 -0
  63. package/lib/Socket/newsletter.d.ts +147 -0
  64. package/lib/Socket/newsletter.js +181 -0
  65. package/lib/Socket/socket.d.ts +51 -0
  66. package/lib/Socket/socket.js +883 -0
  67. package/lib/Socket/usync.d.ts +37 -0
  68. package/lib/Socket/usync.js +63 -0
  69. package/lib/Types/Auth.d.ts +111 -0
  70. package/lib/Types/Auth.js +2 -0
  71. package/lib/Types/Bussines.d.ts +25 -0
  72. package/lib/Types/Bussines.js +2 -0
  73. package/lib/Types/Call.d.ts +14 -0
  74. package/lib/Types/Call.js +2 -0
  75. package/lib/Types/Chat.d.ts +123 -0
  76. package/lib/Types/Chat.js +8 -0
  77. package/lib/Types/Contact.d.ts +24 -0
  78. package/lib/Types/Contact.js +2 -0
  79. package/lib/Types/Events.d.ts +202 -0
  80. package/lib/Types/Events.js +2 -0
  81. package/lib/Types/GroupMetadata.d.ts +67 -0
  82. package/lib/Types/GroupMetadata.js +2 -0
  83. package/lib/Types/Label.d.ts +47 -0
  84. package/lib/Types/Label.js +25 -0
  85. package/lib/Types/LabelAssociation.d.ts +30 -0
  86. package/lib/Types/LabelAssociation.js +7 -0
  87. package/lib/Types/Message.d.ts +303 -0
  88. package/lib/Types/Message.js +11 -0
  89. package/lib/Types/Newsletter.d.ts +135 -0
  90. package/lib/Types/Newsletter.js +31 -0
  91. package/lib/Types/Product.d.ts +79 -0
  92. package/lib/Types/Product.js +2 -0
  93. package/lib/Types/Signal.d.ts +76 -0
  94. package/lib/Types/Signal.js +2 -0
  95. package/lib/Types/Socket.d.ts +133 -0
  96. package/lib/Types/Socket.js +3 -0
  97. package/lib/Types/State.d.ts +39 -0
  98. package/lib/Types/State.js +13 -0
  99. package/lib/Types/USync.d.ts +26 -0
  100. package/lib/Types/USync.js +2 -0
  101. package/lib/Types/index.d.ts +65 -0
  102. package/lib/Types/index.js +26 -0
  103. package/lib/Utils/auth-utils.d.ts +19 -0
  104. package/lib/Utils/auth-utils.js +257 -0
  105. package/lib/Utils/baileys-event-stream.d.ts +17 -0
  106. package/lib/Utils/baileys-event-stream.js +56 -0
  107. package/lib/Utils/browser-utils.d.ts +4 -0
  108. package/lib/Utils/browser-utils.js +28 -0
  109. package/lib/Utils/business.d.ts +23 -0
  110. package/lib/Utils/business.js +231 -0
  111. package/lib/Utils/chat-utils.d.ts +70 -0
  112. package/lib/Utils/chat-utils.js +763 -0
  113. package/lib/Utils/crypto.d.ts +41 -0
  114. package/lib/Utils/crypto.js +142 -0
  115. package/lib/Utils/decode-wa-message.d.ts +48 -0
  116. package/lib/Utils/decode-wa-message.js +279 -0
  117. package/lib/Utils/event-buffer.d.ts +34 -0
  118. package/lib/Utils/event-buffer.js +548 -0
  119. package/lib/Utils/generics.d.ts +90 -0
  120. package/lib/Utils/generics.js +381 -0
  121. package/lib/Utils/history.d.ts +19 -0
  122. package/lib/Utils/history.js +84 -0
  123. package/lib/Utils/index.d.ts +20 -0
  124. package/lib/Utils/index.js +20 -0
  125. package/lib/Utils/link-preview.d.ts +21 -0
  126. package/lib/Utils/link-preview.js +85 -0
  127. package/lib/Utils/logger.d.ts +12 -0
  128. package/lib/Utils/logger.js +3 -0
  129. package/lib/Utils/lt-hash.d.ts +13 -0
  130. package/lib/Utils/lt-hash.js +48 -0
  131. package/lib/Utils/make-mutex.d.ts +8 -0
  132. package/lib/Utils/make-mutex.js +40 -0
  133. package/lib/Utils/message-retry-manager.d.ts +82 -0
  134. package/lib/Utils/message-retry-manager.js +149 -0
  135. package/lib/Utils/messages-media.d.ts +114 -0
  136. package/lib/Utils/messages-media.js +663 -0
  137. package/lib/Utils/messages.d.ts +76 -0
  138. package/lib/Utils/messages.js +908 -0
  139. package/lib/Utils/noise-handler.d.ts +20 -0
  140. package/lib/Utils/noise-handler.js +147 -0
  141. package/lib/Utils/pre-key-manager.d.ts +28 -0
  142. package/lib/Utils/pre-key-manager.js +106 -0
  143. package/lib/Utils/process-message.d.ts +42 -0
  144. package/lib/Utils/process-message.js +413 -0
  145. package/lib/Utils/signal.d.ts +34 -0
  146. package/lib/Utils/signal.js +159 -0
  147. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  148. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  149. package/lib/Utils/validate-connection.d.ts +11 -0
  150. package/lib/Utils/validate-connection.js +195 -0
  151. package/lib/WABinary/constants.d.ts +28 -0
  152. package/lib/WABinary/constants.js +1301 -0
  153. package/lib/WABinary/decode.d.ts +7 -0
  154. package/lib/WABinary/decode.js +238 -0
  155. package/lib/WABinary/encode.d.ts +3 -0
  156. package/lib/WABinary/encode.js +216 -0
  157. package/lib/WABinary/generic-utils.d.ts +15 -0
  158. package/lib/WABinary/generic-utils.js +191 -0
  159. package/lib/WABinary/index.d.ts +6 -0
  160. package/lib/WABinary/index.js +6 -0
  161. package/lib/WABinary/jid-utils.d.ts +48 -0
  162. package/lib/WABinary/jid-utils.js +96 -0
  163. package/lib/WABinary/types.d.ts +19 -0
  164. package/lib/WABinary/types.js +2 -0
  165. package/lib/WAM/BinaryInfo.d.ts +9 -0
  166. package/lib/WAM/BinaryInfo.js +10 -0
  167. package/lib/WAM/constants.d.ts +40 -0
  168. package/lib/WAM/constants.js +22853 -0
  169. package/lib/WAM/encode.d.ts +3 -0
  170. package/lib/WAM/encode.js +150 -0
  171. package/lib/WAM/index.d.ts +4 -0
  172. package/lib/WAM/index.js +4 -0
  173. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  174. package/lib/WAUSync/Protocols/USyncContactProtocol.js +29 -0
  175. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  176. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  177. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  178. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  179. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  180. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  181. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  182. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  183. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  184. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  185. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  186. package/lib/WAUSync/Protocols/index.js +5 -0
  187. package/lib/WAUSync/USyncQuery.d.ts +29 -0
  188. package/lib/WAUSync/USyncQuery.js +94 -0
  189. package/lib/WAUSync/USyncUser.d.ts +13 -0
  190. package/lib/WAUSync/USyncUser.js +23 -0
  191. package/lib/WAUSync/index.d.ts +4 -0
  192. package/lib/WAUSync/index.js +4 -0
  193. package/lib/index.d.ts +22 -0
  194. package/lib/index.js +36 -0
  195. package/lib/supun +1 -0
  196. package/package.json +104 -0
@@ -0,0 +1,188 @@
1
+ import type { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig, WAMediaUpload } from '../Types/index.js';
2
+ import type { UpdateBussinesProfileProps } from '../Types/Bussines.js';
3
+ import { type BinaryNode } from '../WABinary/index.js';
4
+ export declare const makeBusinessSocket: (config: SocketConfig) => {
5
+ logger: import("../Utils/logger.js").ILogger;
6
+ getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../index.js").OrderDetails>;
7
+ getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
8
+ products: import("../index.js").Product[];
9
+ nextPageCursor: string | undefined;
10
+ }>;
11
+ getCollections: (jid?: string, limit?: number) => Promise<{
12
+ collections: import("../index.js").CatalogCollection[];
13
+ }>;
14
+ productCreate: (create: ProductCreate) => Promise<import("../index.js").Product>;
15
+ productDelete: (productIds: string[]) => Promise<{
16
+ deleted: number;
17
+ }>;
18
+ productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../index.js").Product>;
19
+ updateBussinesProfile: (args: UpdateBussinesProfileProps) => Promise<any>;
20
+ updateCoverPhoto: (photo: WAMediaUpload) => Promise<number>;
21
+ removeCoverPhoto: (id: string) => Promise<any>;
22
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
23
+ sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
24
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
25
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../index.js").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
26
+ requestPlaceholderResend: (messageKey: import("../index.js").WAMessageKey) => Promise<string | undefined>;
27
+ messageRetryManager: import("../index.js").MessageRetryManager | null;
28
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
29
+ assertSessions: (jids: string[]) => Promise<boolean>;
30
+ relayMessage: (jid: string, message: import("../index.js").proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../index.js").MessageRelayOptions) => Promise<string>;
31
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../index.js").MessageReceiptType) => Promise<void>;
32
+ sendReceipts: (keys: import("../index.js").WAMessageKey[], type: import("../index.js").MessageReceiptType) => Promise<void>;
33
+ readMessages: (keys: import("../index.js").WAMessageKey[]) => Promise<void>;
34
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../index.js").MediaConnInfo>;
35
+ waUploadToServer: import("../index.js").WAMediaUploadFunction;
36
+ fetchPrivacySettings: (force?: boolean) => Promise<{
37
+ [_: string]: string;
38
+ }>;
39
+ sendPeerDataOperationMessage: (pdoMessage: import("../index.js").proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
40
+ createParticipantNodes: (recipientJids: string[], message: import("../index.js").proto.IMessage, extraAttrs?: BinaryNode["attrs"], dsmMessage?: import("../index.js").proto.IMessage) => Promise<{
41
+ nodes: BinaryNode[];
42
+ shouldIncludeDeviceIdentity: boolean;
43
+ }>;
44
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<(import("../index.js").JidWithDevice & {
45
+ jid: string;
46
+ })[]>;
47
+ updateMediaMessage: (message: import("../index.js").WAMessage) => Promise<import("../index.js").WAMessage>;
48
+ sendMessage: (jid: string, content: import("../index.js").AnyMessageContent, options?: import("../index.js").MiscMessageGenerationOptions) => Promise<import("../index.js").WAMessage | undefined>;
49
+ newsletterCreate: (name: string, description?: string) => Promise<import("../index.js").NewsletterMetadata>;
50
+ newsletterUpdate: (jid: string, updates: import("../index.js").NewsletterUpdate) => Promise<unknown>;
51
+ newsletterSubscribers: (jid: string) => Promise<{
52
+ subscribers: number;
53
+ }>;
54
+ newsletterMetadata: (type: "invite" | "jid", key: string) => Promise<import("../index.js").NewsletterMetadata | null>;
55
+ newsletterFollow: (jid: string) => Promise<unknown>;
56
+ newsletterUnfollow: (jid: string) => Promise<unknown>;
57
+ newsletterMute: (jid: string) => Promise<unknown>;
58
+ newsletterUnmute: (jid: string) => Promise<unknown>;
59
+ newsletterUpdateName: (jid: string, name: string) => Promise<unknown>;
60
+ newsletterUpdateDescription: (jid: string, description: string) => Promise<unknown>;
61
+ newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<unknown>;
62
+ newsletterRemovePicture: (jid: string) => Promise<unknown>;
63
+ newsletterReactMessage: (jid: string, serverId: string, reaction?: string) => Promise<void>;
64
+ newsletterFetchMessages: (jid: string, count: number, since: number, after: number) => Promise<any>;
65
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
66
+ duration: string;
67
+ } | null>;
68
+ newsletterAdminCount: (jid: string) => Promise<number>;
69
+ newsletterChangeOwner: (jid: string, newOwnerJid: string) => Promise<void>;
70
+ newsletterDemote: (jid: string, userJid: string) => Promise<void>;
71
+ newsletterDelete: (jid: string) => Promise<void>;
72
+ groupMetadata: (jid: string) => Promise<import("../index.js").GroupMetadata>;
73
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../index.js").GroupMetadata>;
74
+ groupLeave: (id: string) => Promise<void>;
75
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
76
+ groupRequestParticipantsList: (jid: string) => Promise<{
77
+ [key: string]: string;
78
+ }[]>;
79
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
80
+ status: string;
81
+ jid: string | undefined;
82
+ }[]>;
83
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../index.js").ParticipantAction) => Promise<{
84
+ status: string;
85
+ jid: string | undefined;
86
+ content: BinaryNode;
87
+ }[]>;
88
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
89
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
90
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
91
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
92
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
93
+ groupAcceptInviteV4: (key: string | import("../index.js").WAMessageKey, inviteMessage: import("../index.js").proto.Message.IGroupInviteMessage) => Promise<any>;
94
+ groupGetInviteInfo: (code: string) => Promise<import("../index.js").GroupMetadata>;
95
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
96
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
97
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
98
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
99
+ groupFetchAllParticipating: () => Promise<{
100
+ [_: string]: import("../index.js").GroupMetadata;
101
+ }>;
102
+ createCallLink: (type: "audio" | "video", event?: {
103
+ startTime: number;
104
+ }, timeoutMs?: number) => Promise<string | undefined>;
105
+ getBotListV2: () => Promise<import("../index.js").BotListInfo[]>;
106
+ processingMutex: {
107
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
108
+ };
109
+ upsertMessage: (msg: import("../index.js").WAMessage, type: import("../index.js").MessageUpsertType) => Promise<void>;
110
+ appPatch: (patchCreate: import("../index.js").WAPatchCreate) => Promise<void>;
111
+ sendPresenceUpdate: (type: import("../index.js").WAPresence, toJid?: string) => Promise<void>;
112
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
113
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
114
+ fetchBlocklist: () => Promise<(string | undefined)[]>;
115
+ fetchStatus: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
116
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
117
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
118
+ width: number;
119
+ height: number;
120
+ }) => Promise<void>;
121
+ removeProfilePicture: (jid: string) => Promise<void>;
122
+ updateProfileStatus: (status: string) => Promise<void>;
123
+ updateProfileName: (name: string) => Promise<void>;
124
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
125
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
126
+ updateCallPrivacy: (value: import("../index.js").WAPrivacyCallValue) => Promise<void>;
127
+ updateMessagesPrivacy: (value: import("../index.js").WAPrivacyMessagesValue) => Promise<void>;
128
+ updateLastSeenPrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
129
+ updateOnlinePrivacy: (value: import("../index.js").WAPrivacyOnlineValue) => Promise<void>;
130
+ updateProfilePicturePrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
131
+ updateStatusPrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
132
+ updateReadReceiptsPrivacy: (value: import("../index.js").WAReadReceiptsValue) => Promise<void>;
133
+ updateGroupsAddPrivacy: (value: import("../index.js").WAPrivacyGroupAddValue) => Promise<void>;
134
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
135
+ getBusinessProfile: (jid: string) => Promise<import("../index.js").WABusinessProfile | void>;
136
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
137
+ chatModify: (mod: import("../index.js").ChatModification, jid: string) => Promise<void>;
138
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
139
+ addOrEditContact: (jid: string, contact: import("../index.js").proto.SyncActionValue.IContactAction) => Promise<void>;
140
+ removeContact: (jid: string) => Promise<void>;
141
+ addLabel: (jid: string, labels: import("../Types/Label.js").LabelActionBody) => Promise<void>;
142
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
143
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
144
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
145
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
146
+ star: (jid: string, messages: {
147
+ id: string;
148
+ fromMe?: boolean;
149
+ }[], star: boolean) => Promise<void>;
150
+ addOrEditQuickReply: (quickReply: import("../Types/Bussines.js").QuickReplyAction) => Promise<void>;
151
+ removeQuickReply: (timestamp: string) => Promise<void>;
152
+ type: "md";
153
+ ws: import("./Client/index.js").WebSocketClient;
154
+ ev: import("../index.js").BaileysEventEmitter & {
155
+ process(handler: (events: Partial<import("../index.js").BaileysEventMap>) => void | Promise<void>): () => void;
156
+ buffer(): void;
157
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
158
+ flush(): boolean;
159
+ isBuffering(): boolean;
160
+ };
161
+ authState: {
162
+ creds: import("../index.js").AuthenticationCreds;
163
+ keys: import("../index.js").SignalKeyStoreWithTransaction;
164
+ };
165
+ signalRepository: import("../index.js").SignalRepositoryWithLIDStore;
166
+ user: import("../index.js").Contact | undefined;
167
+ generateMessageTag: () => string;
168
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
169
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
170
+ waitForSocketOpen: () => Promise<void>;
171
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
172
+ sendNode: (frame: BinaryNode) => Promise<void>;
173
+ logout: (msg?: string) => Promise<void>;
174
+ end: (error: Error | undefined) => void;
175
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
176
+ uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
177
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
178
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
179
+ wamBuffer: import("../index.js").BinaryInfo;
180
+ waitForConnectionUpdate: (check: (u: Partial<import("../index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
181
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
182
+ executeUSyncQuery: (usyncQuery: import("../index.js").USyncQuery) => Promise<import("../index.js").USyncQueryResult | undefined>;
183
+ onWhatsApp: (...phoneNumber: string[]) => Promise<{
184
+ jid: string;
185
+ exists: boolean;
186
+ }[] | undefined>;
187
+ };
188
+ //# sourceMappingURL=business.d.ts.map
@@ -0,0 +1,376 @@
1
+ import { getRawMediaUploadData } from '../Utils/index.js';
2
+ import { parseCatalogNode, parseCollectionsNode, parseOrderDetailsNode, parseProductNode, toProductNode, uploadingNecessaryImagesOfProduct } from '../Utils/business.js';
3
+ import { jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
4
+ import { getBinaryNodeChild } from '../WABinary/generic-utils.js';
5
+ import { makeMessagesRecvSocket } from './messages-recv.js';
6
+ export const makeBusinessSocket = (config) => {
7
+ const sock = makeMessagesRecvSocket(config);
8
+ const { authState, query, waUploadToServer } = sock;
9
+ const updateBussinesProfile = async (args) => {
10
+ const node = [];
11
+ const simpleFields = ['address', 'email', 'description'];
12
+ node.push(...simpleFields
13
+ .filter(key => args[key])
14
+ .map(key => ({
15
+ tag: key,
16
+ attrs: {},
17
+ content: args[key]
18
+ })));
19
+ if (args.websites) {
20
+ node.push(...args.websites.map(website => ({
21
+ tag: 'website',
22
+ attrs: {},
23
+ content: website
24
+ })));
25
+ }
26
+ if (args.hours) {
27
+ node.push({
28
+ tag: 'business_hours',
29
+ attrs: { timezone: args.hours.timezone },
30
+ content: args.hours.days.map(config => {
31
+ const base = {
32
+ tag: 'business_hours_config',
33
+ attrs: { day_of_week: config.day, mode: config.mode }
34
+ };
35
+ if (config.mode === 'specific_hours') {
36
+ return {
37
+ ...base,
38
+ attrs: {
39
+ ...base.attrs,
40
+ open_time: config.openTimeInMinutes,
41
+ close_time: config.closeTimeInMinutes
42
+ }
43
+ };
44
+ }
45
+ return base;
46
+ })
47
+ });
48
+ }
49
+ const result = await query({
50
+ tag: 'iq',
51
+ attrs: {
52
+ to: S_WHATSAPP_NET,
53
+ type: 'set',
54
+ xmlns: 'w:biz'
55
+ },
56
+ content: [
57
+ {
58
+ tag: 'business_profile',
59
+ attrs: {
60
+ v: '3',
61
+ mutation_type: 'delta'
62
+ },
63
+ content: node
64
+ }
65
+ ]
66
+ });
67
+ return result;
68
+ };
69
+ const updateCoverPhoto = async (photo) => {
70
+ const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo');
71
+ const fileSha256B64 = fileSha256.toString('base64');
72
+ const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
73
+ fileEncSha256B64: fileSha256B64,
74
+ mediaType: 'biz-cover-photo'
75
+ });
76
+ await query({
77
+ tag: 'iq',
78
+ attrs: {
79
+ to: S_WHATSAPP_NET,
80
+ type: 'set',
81
+ xmlns: 'w:biz'
82
+ },
83
+ content: [
84
+ {
85
+ tag: 'business_profile',
86
+ attrs: {
87
+ v: '3',
88
+ mutation_type: 'delta'
89
+ },
90
+ content: [
91
+ {
92
+ tag: 'cover_photo',
93
+ attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
94
+ }
95
+ ]
96
+ }
97
+ ]
98
+ });
99
+ return fbid;
100
+ };
101
+ const removeCoverPhoto = async (id) => {
102
+ return await query({
103
+ tag: 'iq',
104
+ attrs: {
105
+ to: S_WHATSAPP_NET,
106
+ type: 'set',
107
+ xmlns: 'w:biz'
108
+ },
109
+ content: [
110
+ {
111
+ tag: 'business_profile',
112
+ attrs: {
113
+ v: '3',
114
+ mutation_type: 'delta'
115
+ },
116
+ content: [
117
+ {
118
+ tag: 'cover_photo',
119
+ attrs: { op: 'delete', id }
120
+ }
121
+ ]
122
+ }
123
+ ]
124
+ });
125
+ };
126
+ const getCatalog = async ({ jid, limit, cursor }) => {
127
+ jid = jid || authState.creds.me?.id;
128
+ jid = jidNormalizedUser(jid);
129
+ const queryParamNodes = [
130
+ {
131
+ tag: 'limit',
132
+ attrs: {},
133
+ content: Buffer.from((limit || 10).toString())
134
+ },
135
+ {
136
+ tag: 'width',
137
+ attrs: {},
138
+ content: Buffer.from('100')
139
+ },
140
+ {
141
+ tag: 'height',
142
+ attrs: {},
143
+ content: Buffer.from('100')
144
+ }
145
+ ];
146
+ if (cursor) {
147
+ queryParamNodes.push({
148
+ tag: 'after',
149
+ attrs: {},
150
+ content: cursor
151
+ });
152
+ }
153
+ const result = await query({
154
+ tag: 'iq',
155
+ attrs: {
156
+ to: S_WHATSAPP_NET,
157
+ type: 'get',
158
+ xmlns: 'w:biz:catalog'
159
+ },
160
+ content: [
161
+ {
162
+ tag: 'product_catalog',
163
+ attrs: {
164
+ jid,
165
+ allow_shop_source: 'true'
166
+ },
167
+ content: queryParamNodes
168
+ }
169
+ ]
170
+ });
171
+ return parseCatalogNode(result);
172
+ };
173
+ const getCollections = async (jid, limit = 51) => {
174
+ jid = jid || authState.creds.me?.id;
175
+ jid = jidNormalizedUser(jid);
176
+ const result = await query({
177
+ tag: 'iq',
178
+ attrs: {
179
+ to: S_WHATSAPP_NET,
180
+ type: 'get',
181
+ xmlns: 'w:biz:catalog',
182
+ smax_id: '35'
183
+ },
184
+ content: [
185
+ {
186
+ tag: 'collections',
187
+ attrs: {
188
+ biz_jid: jid
189
+ },
190
+ content: [
191
+ {
192
+ tag: 'collection_limit',
193
+ attrs: {},
194
+ content: Buffer.from(limit.toString())
195
+ },
196
+ {
197
+ tag: 'item_limit',
198
+ attrs: {},
199
+ content: Buffer.from(limit.toString())
200
+ },
201
+ {
202
+ tag: 'width',
203
+ attrs: {},
204
+ content: Buffer.from('100')
205
+ },
206
+ {
207
+ tag: 'height',
208
+ attrs: {},
209
+ content: Buffer.from('100')
210
+ }
211
+ ]
212
+ }
213
+ ]
214
+ });
215
+ return parseCollectionsNode(result);
216
+ };
217
+ const getOrderDetails = async (orderId, tokenBase64) => {
218
+ const result = await query({
219
+ tag: 'iq',
220
+ attrs: {
221
+ to: S_WHATSAPP_NET,
222
+ type: 'get',
223
+ xmlns: 'fb:thrift_iq',
224
+ smax_id: '5'
225
+ },
226
+ content: [
227
+ {
228
+ tag: 'order',
229
+ attrs: {
230
+ op: 'get',
231
+ id: orderId
232
+ },
233
+ content: [
234
+ {
235
+ tag: 'image_dimensions',
236
+ attrs: {},
237
+ content: [
238
+ {
239
+ tag: 'width',
240
+ attrs: {},
241
+ content: Buffer.from('100')
242
+ },
243
+ {
244
+ tag: 'height',
245
+ attrs: {},
246
+ content: Buffer.from('100')
247
+ }
248
+ ]
249
+ },
250
+ {
251
+ tag: 'token',
252
+ attrs: {},
253
+ content: Buffer.from(tokenBase64)
254
+ }
255
+ ]
256
+ }
257
+ ]
258
+ });
259
+ return parseOrderDetailsNode(result);
260
+ };
261
+ const productUpdate = async (productId, update) => {
262
+ update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
263
+ const editNode = toProductNode(productId, update);
264
+ const result = await query({
265
+ tag: 'iq',
266
+ attrs: {
267
+ to: S_WHATSAPP_NET,
268
+ type: 'set',
269
+ xmlns: 'w:biz:catalog'
270
+ },
271
+ content: [
272
+ {
273
+ tag: 'product_catalog_edit',
274
+ attrs: { v: '1' },
275
+ content: [
276
+ editNode,
277
+ {
278
+ tag: 'width',
279
+ attrs: {},
280
+ content: '100'
281
+ },
282
+ {
283
+ tag: 'height',
284
+ attrs: {},
285
+ content: '100'
286
+ }
287
+ ]
288
+ }
289
+ ]
290
+ });
291
+ const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
292
+ const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
293
+ return parseProductNode(productNode);
294
+ };
295
+ const productCreate = async (create) => {
296
+ // ensure isHidden is defined
297
+ create.isHidden = !!create.isHidden;
298
+ create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
299
+ const createNode = toProductNode(undefined, create);
300
+ const result = await query({
301
+ tag: 'iq',
302
+ attrs: {
303
+ to: S_WHATSAPP_NET,
304
+ type: 'set',
305
+ xmlns: 'w:biz:catalog'
306
+ },
307
+ content: [
308
+ {
309
+ tag: 'product_catalog_add',
310
+ attrs: { v: '1' },
311
+ content: [
312
+ createNode,
313
+ {
314
+ tag: 'width',
315
+ attrs: {},
316
+ content: '100'
317
+ },
318
+ {
319
+ tag: 'height',
320
+ attrs: {},
321
+ content: '100'
322
+ }
323
+ ]
324
+ }
325
+ ]
326
+ });
327
+ const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
328
+ const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
329
+ return parseProductNode(productNode);
330
+ };
331
+ const productDelete = async (productIds) => {
332
+ const result = await query({
333
+ tag: 'iq',
334
+ attrs: {
335
+ to: S_WHATSAPP_NET,
336
+ type: 'set',
337
+ xmlns: 'w:biz:catalog'
338
+ },
339
+ content: [
340
+ {
341
+ tag: 'product_catalog_delete',
342
+ attrs: { v: '1' },
343
+ content: productIds.map(id => ({
344
+ tag: 'product',
345
+ attrs: {},
346
+ content: [
347
+ {
348
+ tag: 'id',
349
+ attrs: {},
350
+ content: Buffer.from(id)
351
+ }
352
+ ]
353
+ }))
354
+ }
355
+ ]
356
+ });
357
+ const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
358
+ return {
359
+ deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
360
+ };
361
+ };
362
+ return {
363
+ ...sock,
364
+ logger: config.logger,
365
+ getOrderDetails,
366
+ getCatalog,
367
+ getCollections,
368
+ productCreate,
369
+ productDelete,
370
+ productUpdate,
371
+ updateBussinesProfile,
372
+ updateCoverPhoto,
373
+ removeCoverPhoto
374
+ };
375
+ };
376
+ //# sourceMappingURL=business.js.map
@@ -0,0 +1,98 @@
1
+ import { Boom } from '@hapi/boom';
2
+ import { proto } from '../../WAProto/index.js';
3
+ import type { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types/index.js';
4
+ import type { QuickReplyAction } from '../Types/Bussines.js';
5
+ import type { LabelActionBody } from '../Types/Label.js';
6
+ import { type BinaryNode } from '../WABinary/index.js';
7
+ import { USyncQuery } from '../WAUSync/index.js';
8
+ export declare const makeChatsSocket: (config: SocketConfig) => {
9
+ createCallLink: (type: "audio" | "video", event?: {
10
+ startTime: number;
11
+ }, timeoutMs?: number) => Promise<string | undefined>;
12
+ getBotListV2: () => Promise<BotListInfo[]>;
13
+ processingMutex: {
14
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
15
+ };
16
+ fetchPrivacySettings: (force?: boolean) => Promise<{
17
+ [_: string]: string;
18
+ }>;
19
+ upsertMessage: (msg: WAMessage, type: MessageUpsertType) => Promise<void>;
20
+ appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
21
+ sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
22
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
23
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
24
+ fetchBlocklist: () => Promise<(string | undefined)[]>;
25
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
26
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
27
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
28
+ width: number;
29
+ height: number;
30
+ }) => Promise<void>;
31
+ removeProfilePicture: (jid: string) => Promise<void>;
32
+ updateProfileStatus: (status: string) => Promise<void>;
33
+ updateProfileName: (name: string) => Promise<void>;
34
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
35
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
36
+ updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
37
+ updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
38
+ updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
39
+ updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
40
+ updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
41
+ updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
42
+ updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
43
+ updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
44
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
45
+ getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
46
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
47
+ chatModify: (mod: ChatModification, jid: string) => Promise<void>;
48
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
49
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
50
+ removeContact: (jid: string) => Promise<void>;
51
+ addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
52
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
53
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
54
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
55
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
56
+ star: (jid: string, messages: {
57
+ id: string;
58
+ fromMe?: boolean;
59
+ }[], star: boolean) => Promise<void>;
60
+ addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
61
+ removeQuickReply: (timestamp: string) => Promise<void>;
62
+ type: "md";
63
+ ws: import("./Client/websocket.js").WebSocketClient;
64
+ ev: import("../Types/index.js").BaileysEventEmitter & {
65
+ process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
66
+ buffer(): void;
67
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
68
+ flush(): boolean;
69
+ isBuffering(): boolean;
70
+ };
71
+ authState: {
72
+ creds: import("../Types/index.js").AuthenticationCreds;
73
+ keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
74
+ };
75
+ signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
76
+ user: import("../Types/index.js").Contact | undefined;
77
+ generateMessageTag: () => string;
78
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
79
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
80
+ waitForSocketOpen: () => Promise<void>;
81
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
82
+ sendNode: (frame: BinaryNode) => Promise<void>;
83
+ logout: (msg?: string) => Promise<void>;
84
+ end: (error: Error | undefined) => void;
85
+ onUnexpectedError: (err: Error | Boom, msg: string) => void;
86
+ uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
87
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
88
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
89
+ wamBuffer: import("../index.js").BinaryInfo;
90
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
91
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
92
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
93
+ onWhatsApp: (...phoneNumber: string[]) => Promise<{
94
+ jid: string;
95
+ exists: boolean;
96
+ }[] | undefined>;
97
+ };
98
+ //# sourceMappingURL=chats.d.ts.map